import { Maybe, ObjectForExtending, Prettify } from './utils.type'; import { DataGridPropsDefault } from './data-grid.type'; import { DomMetadata } from './additional.type'; import { FeatureItem, SidebarTab } from '../widgets/control-block/types'; import { ControlBlockButtonProps } from '../widgets/control-block/control-block-button.types'; import { SubRows } from '../feature-tree/types'; import { ChildrenInfo, RowCheckboxDisabled, RowGetStatesProps, RowGetStatesReturnType, RowShowCheckbox } from '../feature-select-row/types'; import { SELECTING_KEYS } from '../feature-select-row/constants'; import { SearchingProps } from '../feature-searching/types'; import { GroupRow, RowsGrouping } from '../feature-rows-grouping/types'; import { RowDetailConfig } from '../feature-row-detail/types'; import { PaginationProps } from '../feature-pagination/types'; import { KeyTextConfig } from '../feature-key-text/types'; import { FullScreen } from '../feature-full-screen/types'; import { CellContextMenuDropDownProps, HeaderContextMenuDropDownProps, HeaderContextMenuProps } from '../feature-context-menu'; import { ColumnsControlConfig } from '../feature-column-control/types'; import { TableDropdownConfigProps } from '../components/TableDropdown/types'; import { CSSObject } from 'styled-components'; import { CalculatedColumn, SortColumn } from 'react-data-grid'; import { ChangeEvent, CSSProperties, ReactNode } from 'react'; import { RowInstrumentsType, SIZE } from '..'; import { MassActionsButtonProps, MassActionsSize } from '../../MassActions/types'; import { Group, Item, ItemOrGroup } from '../../ListOfFilters'; export type HighlightActiveType = 'cell' | 'row' | 'disabled'; export type ViewMods = { rows: { type: 'rows'; domMetadata?: DomMetadata; }; cards: { type: 'cards'; typeCardsRender: ReactNode; domMetadata?: DomMetadata; }; bothTypes: { type: 'both-types'; typeCardsRender: ReactNode; default?: 'cards' | 'rows'; domMetadata?: DomMetadata; }; }; export interface RowsChangeData { indexes: number[]; column: CalculatedColumn; rows: { before: R; after: R; }[]; } export type ActiveViewModsType = Exclude; export type View = ViewMods['rows' | 'bothTypes' | 'cards']; export type { ControlBlockButtonProps }; export type RowSize = { showInControl: boolean; default?: SIZE; available?: SIZE[]; onRowSizeChange?: (size: SIZE) => void; domMetadata?: DomMetadata; }; export type RowHeightFunc = (row: RowType, currentRowSize: { rowSizeName: SIZE; rowSizeValue: number; }) => number; type SummaryCheckedFunc = (props: { rows: RowType[]; flattenedRows: (RowType & { level?: number; parent?: RowType | null; })[]; selectedRowsIds: ReadonlySet; rowKeyGetter: (row: RowType) => string | number; rowCheckboxDisabled: SelectingRowConfig['rowCheckboxDisabled']; rowShowCheckbox: SelectingRowConfig['rowShowCheckbox']; allRowsInLevels: (RowType & { level?: number; parent?: RowType | null; })[]; getAllRowsInfo: () => ChildrenInfo; } & (AdditionalPropsObj extends ObjectForExtending ? AdditionalPropsObj : {})) => ReturnType; export type TableCollapseConfig = { enableCollapse?: boolean; defaultCollapsed?: boolean; collapseText?: string; expandText?: string; onToggleCollapse?: (isCollapsed: boolean) => void; collapsedState?: [boolean, React.Dispatch>]; domMetadata?: DomMetadata; collapseButtonPlacement?: 'inside' | 'above'; collapseButtonAboveRightSlot?: React.ReactNode; }; export type FlattenedRowsArrAndMap = { flattenedRows: (RowType & { [SELECTING_KEYS.level]?: number; [SELECTING_KEYS.parent]?: RowType | null; })[]; flattenedRowsMap: Map; }; export type SelectingRowConfig = { rowKeyGetter: (row: RowType) => RowIdType; showDefault?: boolean; showState?: [boolean, React.Dispatch>]; showInControl?: boolean; selectingRules?: { levels?: number | 'all' | number[] | ((lvl: number) => boolean); }; disableSummaryCheckboxInHeader?: boolean; hideSummaryCheckboxInHeader?: boolean; hideSummaryCheckbox?: boolean; summaryChecked?: { checked: boolean | SummaryCheckedFunc; indeterminate: boolean | SummaryCheckedFunc; getCountOfChecked: SummaryCheckedFunc; onChange: SummaryCheckedFunc>>; }>; }; summaryCheckedUncontrolled?: { onChange: (event: ChangeEvent) => void; }; rowShowCheckbox?: RowShowCheckbox; rowCheckboxDisabled?: RowCheckboxDisabled; rowGetStates?: (p: RowGetStatesProps) => RowGetStatesReturnType | null; groupedRow?: { getStates: (p: { checkedCalculated: boolean; indeterminateCalculated: boolean; row: GroupRow; selectedRows: ReadonlySet; selectedChildCount: number; childCount: number; }) => { checked?: boolean | null; indeterminate?: boolean | null; showCheckbox?: boolean | null; checkboxDisabled?: boolean | null; } | null; onChange?: (p: { row: GroupRow; setSelectedRows: React.Dispatch>>; checked: boolean; indeterminate: boolean; checkboxDisabled: boolean; showCheckbox: boolean; defaultSetter: () => void; }) => void; }; }; export type FilteringConfig = { state: [T, React.Dispatch>]; clearedValue?: T; filtersInfo?: Record; manualFiltering?: boolean; sidebarConfig?: { order?: string[]; items: Partial>) => React.ReactNode; }>>; }; chipStyle?: (itemOrGroup: ItemOrGroup, item: Item | undefined) => CSSObject; renderGroupLabel?: (group: Group) => string; renderChipLabel?: (group: Group | null, item: Item) => string; }; export type DefaultSidebarTabIds = 'columns' | 'tableSettings' | 'filtering'; type SidebarConfig = { enabled?: boolean; defaultOpen?: boolean; openState?: [boolean, React.Dispatch>]; defaultActiveTabId?: string; activeTabState?: [ string | null, React.Dispatch> ]; onActiveTabChange?: (tabId: string | null, tab?: SidebarTab) => void; customTabs?: Array & { id: Exclude; }>; customTabsOrder?: Array>; defaultTabs?: Array<{ id: 'filtering' | 'columns'; label?: string; title?: string; domMetadata?: DomMetadata; titleRightSlot?: React.ReactNode; } | { id: 'tableSettings'; label?: string; title?: string; domMetadata?: DomMetadata; customGeneralSettingsSlot?: React.ReactNode; titleRightSlot?: React.ReactNode; }>; }; export declare function activeViewIs(checkType: T, viewState: 'cards' | 'rows', view: View): view is ViewMods[T]; export type ControlBlockConfig = { show?: boolean; leftSideInner?: ControlBlockButtonProps[]; rightSideInner?: ControlBlockButtonProps[]; customFeatures?: FeatureItem[]; leftSideDropdownProps?: TableDropdownConfigProps; rightSideDropdownProps?: TableDropdownConfigProps; enableAdaptiveCompress?: boolean; massActionPanel?: { buttons: MassActionsButtonProps[]; collapsedDropdownProps?: TableDropdownConfigProps; bottom?: number; show?: boolean; size?: MassActionsSize; }; }; export type EditingConfig = { onRowsChange: Maybe<(rows: RowType[], data: RowsChangeData) => void>; subRowsKey?: string; rowKeyGetter: (row: RowType) => RowIdType; rowEditable?: (row: RowType) => boolean; defaultEnabled?: boolean; enabled?: boolean | [boolean, React.Dispatch>]; showToggleEnabledButton?: boolean; onToggleEnableEditing?: (editingIsActive: boolean) => void; domMetadata?: DomMetadata; }; export type SummaryRowsConfig = { showDefault: boolean; showInControl: boolean; } & { domMetadata?: DomMetadata; }; export type TableConfig = { highlightActiveType?: HighlightActiveType; rowSize?: Prettify; rowHeight?: Maybe>; sorting?: { state: [ readonly SortColumn[], React.Dispatch> ]; manualSorting?: boolean; }; view?: View; filtering?: FilteringConfig; collapsing?: TableCollapseConfig; selecting?: { state: [ ReadonlySet, React.Dispatch>> ]; } & Prettify> & { controlBlock?: { domMetadata?: DomMetadata; }; sidebar?: { domMetadata?: DomMetadata; }; }; editing?: EditingConfig; subRows?: SubRows; rowsGrouping?: RowsGrouping; resizableColumn?: boolean; style?: Omit; css?: string | CSSObject; summaryRows?: SummaryRowsConfig; controlBlock?: ControlBlockConfig; containerStyle?: CSSProperties | undefined; containerCss?: string | CSSObject | undefined; containerId?: string | undefined; infinityScroll?: { onTrigger: (rows: RowType[]) => Promise | void; isLoading: boolean; hasMore?: boolean; scrollThreshold?: number; }; isLoading?: boolean | { boolean: boolean; skeletonRowsCount: number; }; loadingOverlay?: { active?: boolean; spinner?: ReactNode; title?: string; subtitle?: string; showSubtitleDelay?: number; }; noRowsFallback?: boolean | { custom: ReactNode; }; columnsControl?: ColumnsControlConfig; rowDetailPanel?: RowDetailConfig; rowInstruments?: { getRowDropdownConfig: RowInstrumentsType; defaultOpened?: boolean; showInControl?: boolean; openedState?: [boolean, React.Dispatch>]; }; fullScreenEnabled?: FullScreen; keyText?: boolean | KeyTextConfig; pagination?: PaginationProps; sidebarConfig?: SidebarConfig; searching?: SearchingProps; onHeaderContextMenu?: HeaderContextMenuProps; onHeaderContextMenuDropDown?: HeaderContextMenuDropDownProps; onCellContextMenuDropDown?: CellContextMenuDropDownProps; } & Pick, 'summaryRowHeight' | 'onFill' | 'onCopy' | 'onPaste' | 'onCellClick' | 'onCellDoubleClick' | 'onCellContextMenu' | 'onCellKeyDown' | 'onSelectedCellChange' | 'onScroll' | 'onColumnResize' | 'onColumnsReorder' | 'enableVirtualization' | 'rowClass' | 'data-testid' | 'headerRowHeight'>;