<commit_before>import {autobind} from "core-decorators";
import i18n from "i18next";
import {computed} from "mobx";
import {observer} from "mobx-react";
import * as React from "react";
import {themr} from "react-css-themr";

import Icon from "focus-components/icon";

import {LineOperationListItem} from "./contextual-actions";
import {LineWrapper} from "./line";
import {ListBase, ListBaseProps} from "./list-base";

import * as styles from "./__style__/list.css";

export interface ListProps<T, P extends {data?: T}> extends ListBaseProps<T, P> {
    addItemHandler?: () => void;
    data?: T[];
    hideAddItemHandler?: boolean;
    LineComponent?: ReactComponent<P>;
    mode?: "list" | "mosaic";
    mosaic?: {width: number, height: number};
    MosaicComponent?: ReactComponent<P>;
    operationList?: (data: T) => LineOperationListItem<T>[];
}

@autobind
@observer
export class ListWithoutStyle<T, P extends {data?: T}, AP> extends ListBase<T, ListProps<T, P> & AP> {

    static contextTypes = {
        listWrapper: React.PropTypes.object
    };

    context: {
        listWrapper?: {
            addItemHandler: () => void;
            mosaic: {
                width: number;
                height: number;
            },
            mode: "list" | "mosaic";
        }
    };

    @computed
    protected get addItemHandler() {
        return this.props.addItemHandler || this.context.listWrapper && this.context.listWrapper.addItemHandler;
    }

    @computed
    protected get mode() {
        return this.props.mode || this.context.listWrapper && this.context.listWrapper.mode || "list";
    }

    @computed
    protected get mosaic() {
        return this.mode === "list" ? undefined : this.props.mosaic || this.context.listWrapper && this.context.listWrapper.mosaic || {width: 200, height: 200};
    }

    protected get data() {
        return this.props.data || [];
    }

    protected getItems(Line: new() => LineWrapper<T, P>, Component: ReactComponent<P>) {
        const {itemKey, lineTheme, lineProps, operationList} = this.props;
        return this.displayedData.map((item, idx) => (
            <Line
                key={itemKey && item[itemKey] && (item[itemKey] as any).value || itemKey && item[itemKey] || idx}
                theme={lineTheme}
                data={item}
                mosaic={this.mosaic}
                LineComponent={Component}
                lineProps={lineProps}
                operationList={operationList}
            />
        ));
    }
<commit_msg>Liste : Détermine le mode en fonction des composants fournis<commit_after>import {autobind} from "core-decorators";
import i18n from "i18next";
import {computed} from "mobx";
import {observer} from "mobx-react";
import * as React from "react";
import {themr} from "react-css-themr";

import Icon from "focus-components/icon";

import {LineOperationListItem} from "./contextual-actions";
import {LineWrapper} from "./line";
import {ListBase, ListBaseProps} from "./list-base";

import * as styles from "./__style__/list.css";

export interface ListProps<T, P extends {data?: T}> extends ListBaseProps<T, P> {
    addItemHandler?: () => void;
    data?: T[];
    hideAddItemHandler?: boolean;
    LineComponent?: ReactComponent<P>;
    mode?: "list" | "mosaic";
    mosaic?: {width: number, height: number};
    MosaicComponent?: ReactComponent<P>;
    operationList?: (data: T) => LineOperationListItem<T>[];
}

@autobind
@observer
export class ListWithoutStyle<T, P extends {data?: T}, AP> extends ListBase<T, ListProps<T, P> & AP> {

    static contextTypes = {
        listWrapper: React.PropTypes.object
    };

    context: {
        listWrapper?: {
            addItemHandler: () => void;
            mosaic: {
                width: number;
                height: number;
            },
            mode: "list" | "mosaic";
        }
    };

    @computed
    protected get addItemHandler() {
        const {listWrapper} = this.context;
        return this.props.addItemHandler || listWrapper && listWrapper.addItemHandler;
    }

    @computed
    protected get mode() {
        const {mode, MosaicComponent, LineComponent} = this.props;
        const {listWrapper} = this.context;
        return mode || listWrapper && listWrapper.mode || MosaicComponent && !LineComponent && "mosaic" || "list";
    }

    @computed
    protected get mosaic() {
        const {listWrapper} = this.context;
        return this.mode === "list" ? undefined : this.props.mosaic || listWrapper && listWrapper.mosaic || {width: 200, height: 200};
    }

    protected get data() {
        return this.props.data || [];
    }

    protected getItems(Line: new() => LineWrapper<T, P>, Component: ReactComponent<P>) {
        const {itemKey, lineTheme, lineProps, operationList} = this.props;
        return this.displayedData.map((item, idx) => (
            <Line
                key={itemKey && item[itemKey] && (item[itemKey] as any).value || itemKey && item[itemKey] || idx}
                theme={lineTheme}
                data={item}
                mosaic={this.mosaic}
                LineComponent={Component}
                lineProps={lineProps}
                operationList={operationList}
            />
        ));
    }

{'fraction_non_alphanumeric': 0.13745704467353953, 'fraction_numerical': 0.0038182512409316535, 'mean_word_length': 2.6381944444444443, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2858265', 'n_tokens_mistral': 1575, 'n_tokens_neox': 1500, 'n_words': 381}