import {autobind} from "core-decorators"; import {computed} from "mobx"; import {observer} from "mobx-react"; import * as React from "react"; import Checkbox from "focus-components/input-checkbox"; import {injectStyle} from "../../theming"; import {ListStore} from "../store"; import {ListStoreBase} from "../store-base"; import {LineProps} from "./line"; import {ListWithoutStyle} from "./list"; import * as styles from "./style/line.css"; export interface StoreListProps { hasSelection?: boolean; selectionnableInitializer?: (data?: T) => boolean; store: ListStoreBase; } interface LineSelectionProps> { classNames?: Partial; data: T; isSelection: boolean; LineComponent: ReactComponent

; lineProps?: P; selectionnableInitializer: (data: T) => boolean; store: ListStoreBase; } @injectStyle("line") @observer class LineSelection> extends React.Component, void> { @computed get isSelected() { return this.props.store.selectedItems.has(this.props.data); } onSelection = () => this.props.store.toggle(this.props.data); render() { const {LineComponent, data, lineProps, isSelection, selectionnableInitializer, classNames} = this.props; return (

  • {isSelection && selectionnableInitializer(data) ?
    : null}
  • ); } } @injectStyle("list") @autobind @observer export class StoreList> extends ListWithoutStyle> { @computed protected get data() { const data = this.props.data || (this.props.store as ListStore).dataList; if (!data) { throw new Error("`props.data` doit ĂȘtre renseignĂ© pour un usage avec un `SearchStore`"); } return data; } @computed protected get hasMoreData() { const {store} = this.props; if (this.maxElements) { return this.data.length > this.maxElements; } else { return store.totalCount > store.currentCount; } } protected renderLines() { const {LineComponent, hasSelection = false, selectionnableInitializer = () => true, lineProps, store} = this.props; const Line = LineSelection as new() => LineSelection; return this.displayedData.map((data, i) => ); } protected handleShowMore() { if ((this.props.store as ListStore).service) { (this.props.store as ListStore).load(true); } else { super.handleShowMore(); } } }