@economic/taco 2.13.0 → 2.14.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Field/Field.d.ts +4 -2
- package/dist/components/Icon/components/Location.d.ts +3 -0
- package/dist/components/Icon/components/index.d.ts +1 -1
- package/dist/components/Input/Input.d.ts +1 -1
- package/dist/components/Menu/components/Item.d.ts +1 -1
- package/dist/components/Menu/components/Link.d.ts +1 -1
- package/dist/components/Navigation2/components/Link.d.ts +1 -1
- package/dist/components/Provider/Localization.d.ts +0 -113
- package/dist/components/Select2/components/Option.d.ts +2 -2
- package/dist/components/Select2/components/Search.d.ts +1 -1
- package/dist/components/Table3/components/columns/styles.d.ts +2 -2
- package/dist/components/Table3/components/toolbar/Filter/filters/components/Filter.d.ts +4 -4
- package/dist/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.d.ts +3 -2
- package/dist/components/Table3/components/toolbar/Filter/filters/components/Placeholder.d.ts +3 -2
- package/dist/components/Table3/components/toolbar/FontSize.d.ts +4 -0
- package/dist/components/Table3/hooks/useCssGrid.d.ts +2 -1
- package/dist/components/Table3/hooks/useTable.d.ts +1 -1
- package/dist/components/Table3/types.d.ts +1 -1
- package/dist/components/Tag/Tag.d.ts +1 -1
- package/dist/esm/packages/taco/src/components/Field/Field.js +6 -4
- package/dist/esm/packages/taco/src/components/Field/Field.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Icon/components/Location.js +17 -0
- package/dist/esm/packages/taco/src/components/Icon/components/Location.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Icon/components/index.js +2 -0
- package/dist/esm/packages/taco/src/components/Icon/components/index.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Provider/Localization.js +0 -110
- package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Search.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Search.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +5 -4
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +2 -5
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +1 -4
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js +6 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js +3 -2
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/styles.js +14 -2
- package/dist/esm/packages/taco/src/components/Table3/components/columns/styles.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js +15 -8
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js +12 -3
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js +0 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterValue.js +5 -3
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterValue.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/FontSize.js +9 -4
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/FontSize.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +2 -3
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/RowHeight.js +3 -2
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/RowHeight.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Settings.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSettings.js +6 -7
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSettings.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js +48 -0
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js +4 -2
- package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useCssGrid.js +6 -5
- package/dist/esm/packages/taco/src/components/Table3/hooks/useCssGrid.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js +11 -9
- package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/types.js.map +1 -1
- package/dist/esm/packages/taco/src/index.js +1 -2
- package/dist/esm/packages/taco/src/index.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/dom.js +1 -2
- package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/taco.cjs.development.js +485 -4052
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +2 -2
- package/tailwind.config.js +3 -0
- package/types.json +13748 -32551
- package/dist/components/Table2/Table2.d.ts +0 -130
- package/dist/components/Table2/components/BatchActionsMenu.d.ts +0 -10
- package/dist/components/Table2/components/ColumnSettingsButton.d.ts +0 -6
- package/dist/components/Table2/components/EditModeButton.d.ts +0 -8
- package/dist/components/Table2/components/RowDensityButton.d.ts +0 -7
- package/dist/components/Table2/components/Search.d.ts +0 -3
- package/dist/components/Table2/components/ShortcutsGuideButton.d.ts +0 -7
- package/dist/components/Table2/components/column/Base.d.ts +0 -14
- package/dist/components/Table2/components/column/Cell.d.ts +0 -15
- package/dist/components/Table2/components/column/Footer.d.ts +0 -9
- package/dist/components/Table2/components/column/Header.d.ts +0 -11
- package/dist/components/Table2/components/column/Indicator.d.ts +0 -17
- package/dist/components/Table2/components/column/ValidationError.d.ts +0 -5
- package/dist/components/Table2/components/column/utils.d.ts +0 -3
- package/dist/components/Table2/components/filters/FiltersButton.d.ts +0 -7
- package/dist/components/Table2/components/filters/components/Column.d.ts +0 -11
- package/dist/components/Table2/components/filters/components/ColumnFilter.d.ts +0 -10
- package/dist/components/Table2/components/filters/components/Comparator.d.ts +0 -11
- package/dist/components/Table2/components/filters/components/EmptyFilter.d.ts +0 -13
- package/dist/components/Table2/components/filters/components/InferredControl.d.ts +0 -10
- package/dist/components/Table2/components/row/Context.d.ts +0 -24
- package/dist/components/Table2/components/row/ExpandedRow.d.ts +0 -6
- package/dist/components/Table2/components/row/Row.d.ts +0 -2
- package/dist/components/Table2/hooks/listeners/useActiveCellStateListener.d.ts +0 -3
- package/dist/components/Table2/hooks/listeners/useActiveRowStateListener.d.ts +0 -3
- package/dist/components/Table2/hooks/listeners/useColumnOffsetStateListener.d.ts +0 -3
- package/dist/components/Table2/hooks/listeners/useFilterStateListener.d.ts +0 -3
- package/dist/components/Table2/hooks/listeners/useRowSelectionListener.d.ts +0 -3
- package/dist/components/Table2/hooks/listeners/useSettingsStateListener.d.ts +0 -3
- package/dist/components/Table2/hooks/useActiveCell.d.ts +0 -26
- package/dist/components/Table2/hooks/useActiveRow.d.ts +0 -10
- package/dist/components/Table2/hooks/useColumnDefinitions.d.ts +0 -37
- package/dist/components/Table2/hooks/useEditMode.d.ts +0 -28
- package/dist/components/Table2/hooks/useGridTemplate.d.ts +0 -2
- package/dist/components/Table2/hooks/useTable.d.ts +0 -46
- package/dist/components/Table2/hooks/useTableShortcuts.d.ts +0 -2
- package/dist/components/Table2/hooks/useVirtualiser.d.ts +0 -23
- package/dist/components/Table2/types.d.ts +0 -148
- package/dist/components/Table2/utilities/cell.d.ts +0 -14
- package/dist/components/Table2/utilities/columns.d.ts +0 -16
- package/dist/components/Table2/utilities/filterFn.d.ts +0 -3
- package/dist/esm/packages/taco/src/components/Table2/Table2.js +0 -422
- package/dist/esm/packages/taco/src/components/Table2/Table2.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/BatchActionsMenu.js +0 -83
- package/dist/esm/packages/taco/src/components/Table2/components/BatchActionsMenu.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js +0 -116
- package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/EditModeButton.js +0 -81
- package/dist/esm/packages/taco/src/components/Table2/components/EditModeButton.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/RowDensityButton.js +0 -47
- package/dist/esm/packages/taco/src/components/Table2/components/RowDensityButton.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/Search.js +0 -62
- package/dist/esm/packages/taco/src/components/Table2/components/Search.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/Base.js +0 -32
- package/dist/esm/packages/taco/src/components/Table2/components/column/Base.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js +0 -605
- package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/Footer.js +0 -32
- package/dist/esm/packages/taco/src/components/Table2/components/column/Footer.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js +0 -243
- package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js +0 -73
- package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/ValidationError.js +0 -30
- package/dist/esm/packages/taco/src/components/Table2/components/column/ValidationError.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/utils.js +0 -39
- package/dist/esm/packages/taco/src/components/Table2/components/column/utils.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/FiltersButton.js +0 -155
- package/dist/esm/packages/taco/src/components/Table2/components/filters/FiltersButton.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Column.js +0 -31
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Column.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/ColumnFilter.js +0 -129
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/ColumnFilter.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Comparator.js +0 -68
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Comparator.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/EmptyFilter.js +0 -63
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/EmptyFilter.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/InferredControl.js +0 -99
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/InferredControl.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js +0 -58
- package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/row/ExpandedRow.js +0 -36
- package/dist/esm/packages/taco/src/components/Table2/components/row/ExpandedRow.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js +0 -44
- package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useActiveRowStateListener.js +0 -19
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useActiveRowStateListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useColumnOffsetStateListener.js +0 -28
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useColumnOffsetStateListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useFilterStateListener.js +0 -12
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useFilterStateListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useRowSelectionListener.js +0 -18
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useRowSelectionListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useSettingsStateListener.js +0 -25
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useSettingsStateListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useActiveRow.js +0 -33
- package/dist/esm/packages/taco/src/components/Table2/hooks/useActiveRow.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js +0 -122
- package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useEditMode.js +0 -112
- package/dist/esm/packages/taco/src/components/Table2/hooks/useEditMode.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useGridTemplate.js +0 -34
- package/dist/esm/packages/taco/src/components/Table2/hooks/useGridTemplate.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js +0 -222
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTableShortcuts.js +0 -46
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTableShortcuts.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useVirtualiser.js +0 -48
- package/dist/esm/packages/taco/src/components/Table2/hooks/useVirtualiser.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/types.js +0 -18
- package/dist/esm/packages/taco/src/components/Table2/types.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/utilities/cell.js +0 -41
- package/dist/esm/packages/taco/src/components/Table2/utilities/cell.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js +0 -387
- package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/utilities/filterFn.js +0 -100
- package/dist/esm/packages/taco/src/components/Table2/utilities/filterFn.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Truncate/Truncate.js +0 -32
- package/dist/esm/packages/taco/src/components/Truncate/Truncate.js.map +0 -1
- package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js +0 -20
- package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js.map +0 -1
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useColumnDefinitions.js","sources":["../../../../../../../../src/components/Table2/hooks/useColumnDefinitions.tsx"],"sourcesContent":["import React from 'react';\nimport {\n createColumnHelper,\n ColumnSort,\n ColumnSizingState,\n Row,\n RowData,\n VisibilityState,\n SortingFnOption,\n Table,\n} from '@tanstack/react-table';\nimport {\n CellAlignment,\n ColumnDataType,\n RowDragHandler,\n RowExpansionRenderer,\n SortFn,\n Table2Children,\n Table2ColumnControlRenderer,\n Table2ColumnFooterRenderer,\n Table2ColumnHeaderMenu,\n Table2ColumnProps,\n Table2RowActionRenderer,\n} from '../types';\nimport {\n createRowActionsColumn,\n createRowDraggableColumn,\n createRowExpansionColumn,\n createRowSelectionColumn,\n MIN_COLUMN_SIZE,\n} from '../utilities/columns';\nimport { useLocalization } from '../../Provider/Localization';\n\ndeclare module '@tanstack/table-core' {\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: CellAlignment;\n className?: string | ((row: Row<TData>, table: Table<TData>) => string);\n control?: Table2ColumnControlRenderer;\n dataType?: ColumnDataType;\n disableReordering?: boolean;\n defaultWidth?: number | 'grow';\n headerClassName?: string;\n menu?: Table2ColumnHeaderMenu;\n tooltip?: string;\n }\n}\n\ntype useColumnDefinitionsOptions<TType> = {\n actionsForRow: Table2RowActionRenderer<TType>[];\n actionsForRowLength: number;\n enableColumnFiltering: boolean;\n enableColumnHiding: boolean;\n enableColumnFreezing: boolean;\n enableRowExpansion: boolean;\n enableRowSelection: boolean;\n enableMultipleRowSelection: boolean;\n expandedRowRenderer?: RowExpansionRenderer<TType>;\n onRowDrag?: RowDragHandler<TType>;\n};\n\nexport function useColumnDefinitions<TType = any>(\n children: Table2Children,\n options: useColumnDefinitionsOptions<TType>,\n tableRef: React.RefObject<HTMLDivElement>\n) {\n const { texts } = useLocalization();\n const lastSelectedRowIndex = React.useRef<number>();\n const columnHelper = createColumnHelper<TType>();\n\n return React.useMemo(() => {\n let internalFrozenColumnCount = 0;\n // cannot be typed correctly until https://github.com/TanStack/table/discussions/4530 is resolved\n const columns: any[] = [];\n const defaultColumnSizing: ColumnSizingState = {};\n const defaultColumnVisibility: VisibilityState = {};\n const defaultSorting: ColumnSort[] = [];\n const footers: Record<string, Table2ColumnFooterRenderer> = {};\n\n (React.Children.toArray(children) as React.ReactElement<Table2ColumnProps<TType>>[])\n .filter((child: any) => !!child)\n .forEach(child => {\n if (React.isValidElement(child)) {\n const defaultWidth = child.props.defaultWidth === 'grow' ? '1fr' : child.props.defaultWidth;\n\n if (defaultWidth) {\n defaultColumnSizing[child.props.accessor] = defaultWidth as any;\n }\n\n if (child.props.defaultHidden && options.enableColumnHiding) {\n defaultColumnVisibility[child.props.accessor] = false;\n }\n\n if (child.props.sort !== undefined) {\n defaultSorting.push({\n id: child.props.accessor,\n desc: child.props.sort === 'desc',\n });\n }\n\n if (child.props.footer) {\n footers[child.props.accessor] = child.props.footer;\n }\n\n columns.push({\n accessorKey: child.props.accessor,\n id: child.props.accessor,\n cell: props => {\n let value = props.getValue();\n\n if (typeof child.props.renderer === 'function') {\n value = child.props.renderer(value, props.row.original);\n }\n\n if (typeof value === 'string' || typeof value === 'number') {\n return <span className=\"truncate\">{value}</span>;\n }\n\n return value ?? null;\n },\n header: child.props.header,\n meta: {\n align: child.props.align,\n className: child.props.className,\n control: child.props.control,\n dataType: child.props.dataType,\n defaultWidth,\n disableReordering: child.props.disableReordering,\n menu: child.props.menu,\n tooltip: child.props.tooltip,\n },\n enableHiding: !child.props.disableHiding,\n // filtering\n enableColumnFilter: !child.props.disableFiltering,\n filterFn:\n options.enableColumnFiltering && !child.props.disableFiltering ? ('tacoFilter' as any) : undefined,\n // sizing\n enableResizing: !child.props.disableResizing,\n minSize: child.props.minWidth ?? MIN_COLUMN_SIZE,\n size: child.props.defaultWidth,\n // sorting\n enableSorting: !child.props.disableSorting,\n sortingFn: getSortingFn<TType>(child.props.dataType, child.props.sortFn),\n sortDescFirst: false,\n sortUndefined: 1,\n });\n }\n });\n\n if (options.enableRowExpansion && options.expandedRowRenderer) {\n columns.unshift(columnHelper.display(createRowExpansionColumn(options.expandedRowRenderer, texts)));\n internalFrozenColumnCount++;\n }\n\n if (options.enableRowSelection) {\n columns.unshift(\n columnHelper.display(\n createRowSelectionColumn(\n options.enableMultipleRowSelection,\n lastSelectedRowIndex,\n options.onRowDrag,\n tableRef,\n texts\n )\n )\n );\n internalFrozenColumnCount++;\n }\n\n if (options.onRowDrag) {\n columns.unshift(columnHelper.display(createRowDraggableColumn(options.onRowDrag, texts)));\n internalFrozenColumnCount++;\n }\n\n if (options.actionsForRow?.length) {\n columns.push(columnHelper.display(createRowActionsColumn(options.actionsForRow, options.actionsForRowLength, texts)));\n }\n\n return { columns, internalFrozenColumnCount, defaultColumnSizing, defaultColumnVisibility, defaultSorting, footers };\n }, [children]);\n}\n\nfunction getSortingFn<TType>(dataType?: ColumnDataType, customFn?: SortFn<TType>): SortingFnOption<TType> {\n if (typeof customFn === 'function') {\n return (rowA, rowB, columnId) => customFn(rowA.original, rowB.original, columnId);\n }\n\n if (customFn) {\n return customFn;\n }\n\n if (dataType && dataType !== 'boolean') {\n return dataType;\n }\n\n return 'auto';\n}\n"],"names":["useColumnDefinitions","children","options","tableRef","texts","useLocalization","lastSelectedRowIndex","React","useRef","columnHelper","createColumnHelper","useMemo","internalFrozenColumnCount","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","footers","Children","toArray","filter","child","forEach","isValidElement","_child$props$minWidth","defaultWidth","props","accessor","defaultHidden","enableColumnHiding","sort","undefined","push","id","desc","footer","accessorKey","cell","value","getValue","renderer","row","original","className","_value","header","meta","align","control","dataType","disableReordering","menu","tooltip","enableHiding","disableHiding","enableColumnFilter","disableFiltering","filterFn","enableColumnFiltering","enableResizing","disableResizing","minSize","minWidth","MIN_COLUMN_SIZE","size","enableSorting","disableSorting","sortingFn","getSortingFn","sortFn","sortDescFirst","sortUndefined","enableRowExpansion","expandedRowRenderer","unshift","display","createRowExpansionColumn","enableRowSelection","createRowSelectionColumn","enableMultipleRowSelection","onRowDrag","createRowDraggableColumn","_options$actionsForRo","actionsForRow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DIR[MOVE_DIR["LAST"] = 1] = "LAST";
|
7
|
-
MOVE_DIR[MOVE_DIR["PREV"] = 2] = "PREV";
|
8
|
-
MOVE_DIR[MOVE_DIR["NEXT"] = 3] = "NEXT";
|
9
|
-
})(MOVE_DIR || (MOVE_DIR = {}));
|
10
|
-
const useEditMode = handleSave => {
|
11
|
-
const enableEditMode = !!handleSave;
|
12
|
-
const [editMode, setEditMode] = React__default.useState({
|
13
|
-
enableEditMode,
|
14
|
-
isEditing: false,
|
15
|
-
columnIndex: 0
|
16
|
-
});
|
17
|
-
React__default.useEffect(() => {
|
18
|
-
setEditMode(editMode => ({
|
19
|
-
...editMode,
|
20
|
-
enableEditMode
|
21
|
-
}));
|
22
|
-
}, [enableEditMode]);
|
23
|
-
const _moveActiveColumn = (moveDirection, focussableColumnIndexes, moveRow) => {
|
24
|
-
var _focussableColumnInde, _focussableColumnInde2;
|
25
|
-
const firstDataColumnIndex = (_focussableColumnInde = focussableColumnIndexes.at(0)) !== null && _focussableColumnInde !== void 0 ? _focussableColumnInde : 0;
|
26
|
-
const lastDataColumnIndex = (_focussableColumnInde2 = focussableColumnIndexes.at(-1)) !== null && _focussableColumnInde2 !== void 0 ? _focussableColumnInde2 : 0;
|
27
|
-
if (!editMode.enableEditMode) {
|
28
|
-
return;
|
29
|
-
}
|
30
|
-
setEditMode(({
|
31
|
-
columnIndex: currentColumnIndex,
|
32
|
-
...currentEditMode
|
33
|
-
}) => {
|
34
|
-
let nextCellIndex;
|
35
|
-
switch (moveDirection) {
|
36
|
-
case MOVE_DIR.FIRST:
|
37
|
-
nextCellIndex = firstDataColumnIndex;
|
38
|
-
break;
|
39
|
-
case MOVE_DIR.LAST:
|
40
|
-
nextCellIndex = lastDataColumnIndex;
|
41
|
-
break;
|
42
|
-
case MOVE_DIR.PREV:
|
43
|
-
// moves to the last data column of the previous row, if the current column is the first column
|
44
|
-
if (currentColumnIndex === firstDataColumnIndex) {
|
45
|
-
moveRow === null || moveRow === void 0 ? void 0 : moveRow(MOVE_DIR.PREV);
|
46
|
-
nextCellIndex = lastDataColumnIndex;
|
47
|
-
} else {
|
48
|
-
nextCellIndex = focussableColumnIndexes[getNextIndex(-1, currentColumnIndex, focussableColumnIndexes)];
|
49
|
-
}
|
50
|
-
break;
|
51
|
-
case MOVE_DIR.NEXT:
|
52
|
-
// moves to the first data column of the next row, if the current column is the last column
|
53
|
-
if (currentColumnIndex === lastDataColumnIndex) {
|
54
|
-
moveRow === null || moveRow === void 0 ? void 0 : moveRow(MOVE_DIR.NEXT);
|
55
|
-
nextCellIndex = firstDataColumnIndex;
|
56
|
-
} else {
|
57
|
-
nextCellIndex = focussableColumnIndexes[getNextIndex(1, currentColumnIndex, focussableColumnIndexes)];
|
58
|
-
}
|
59
|
-
break;
|
60
|
-
}
|
61
|
-
return {
|
62
|
-
...currentEditMode,
|
63
|
-
columnIndex: nextCellIndex
|
64
|
-
};
|
65
|
-
});
|
66
|
-
};
|
67
|
-
// output
|
68
|
-
const toggleEditing = (isEditing, columnIndex = 0) => {
|
69
|
-
if (!editMode.enableEditMode) {
|
70
|
-
return;
|
71
|
-
}
|
72
|
-
setEditMode(editMode => ({
|
73
|
-
...editMode,
|
74
|
-
isEditing: isEditing !== null && isEditing !== void 0 ? isEditing : !editMode.isEditing,
|
75
|
-
columnIndex
|
76
|
-
}));
|
77
|
-
};
|
78
|
-
const moveToPreviousColumn = (focussableColumnIndexes, moveRow) => _moveActiveColumn(MOVE_DIR.PREV, focussableColumnIndexes, moveRow);
|
79
|
-
const moveToNextColumn = (focussableColumnIndexes, moveRow) => _moveActiveColumn(MOVE_DIR.NEXT, focussableColumnIndexes, moveRow);
|
80
|
-
const moveToFirstColumn = focussableColumnIndexes => _moveActiveColumn(MOVE_DIR.FIRST, focussableColumnIndexes);
|
81
|
-
const moveToLastColumn = focussableColumnIndexes => _moveActiveColumn(MOVE_DIR.LAST, focussableColumnIndexes);
|
82
|
-
const setColumn = columnIndex => {
|
83
|
-
if (!editMode.enableEditMode) {
|
84
|
-
return;
|
85
|
-
}
|
86
|
-
setEditMode(currentEditMode => ({
|
87
|
-
...currentEditMode,
|
88
|
-
columnIndex
|
89
|
-
}));
|
90
|
-
};
|
91
|
-
return {
|
92
|
-
...editMode,
|
93
|
-
onSave: handleSave,
|
94
|
-
toggleEditing,
|
95
|
-
moveToPreviousColumn,
|
96
|
-
moveToNextColumn,
|
97
|
-
moveToFirstColumn,
|
98
|
-
moveToLastColumn,
|
99
|
-
setColumn
|
100
|
-
};
|
101
|
-
};
|
102
|
-
const getNextIndex = (direction, currentIndex, focussableColumnIndexes) => {
|
103
|
-
const currentIndexPosition = focussableColumnIndexes.indexOf(currentIndex);
|
104
|
-
const length = focussableColumnIndexes.length;
|
105
|
-
if (direction === -1) {
|
106
|
-
return currentIndexPosition - 1 > 0 ? currentIndexPosition - 1 : 0;
|
107
|
-
}
|
108
|
-
return currentIndexPosition + 1 < length ? currentIndexPosition + 1 : currentIndexPosition;
|
109
|
-
};
|
110
|
-
|
111
|
-
export { MOVE_DIR, useEditMode };
|
112
|
-
//# sourceMappingURL=useEditMode.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useEditMode.js","sources":["../../../../../../../../src/components/Table2/hooks/useEditMode.ts"],"sourcesContent":["import React from 'react';\nimport { SaveHandler } from '../types';\n\nexport type EditModeHandler = (isEditing?: boolean) => void;\nexport type EditModeColumnMoveHandler = (columns: number[], moveRow?: (moveDirection: MOVE_DIR) => void) => void;\nexport type EditModeColumnHandler = (columnIndex: number) => void;\n\nexport type useEditMode = {\n enableEditMode: boolean;\n isEditing: boolean;\n toggleEditing: EditModeHandler;\n onSave?: SaveHandler;\n // columns\n columnIndex: number;\n moveToPreviousColumn: EditModeColumnMoveHandler;\n moveToNextColumn: EditModeColumnMoveHandler;\n moveToFirstColumn: EditModeColumnMoveHandler;\n moveToLastColumn: EditModeColumnMoveHandler;\n setColumn: EditModeColumnHandler;\n};\n\nexport type EditMode = {\n enableEditMode: boolean;\n isEditing: boolean;\n columnIndex: number;\n};\n\nexport enum MOVE_DIR {\n FIRST,\n LAST,\n PREV,\n NEXT,\n}\n\nexport const useEditMode = (handleSave?: SaveHandler): useEditMode => {\n const enableEditMode = !!handleSave;\n const [editMode, setEditMode] = React.useState<EditMode>({\n enableEditMode,\n isEditing: false,\n columnIndex: 0,\n });\n\n React.useEffect(() => {\n setEditMode(editMode => ({ ...editMode, enableEditMode }));\n }, [enableEditMode]);\n\n const _moveActiveColumn = (\n moveDirection: MOVE_DIR,\n focussableColumnIndexes: number[],\n moveRow?: (moveDirection: MOVE_DIR) => void\n ) => {\n const firstDataColumnIndex = focussableColumnIndexes.at(0) ?? 0;\n const lastDataColumnIndex = focussableColumnIndexes.at(-1) ?? 0;\n\n if (!editMode.enableEditMode) {\n return;\n }\n\n setEditMode(({ columnIndex: currentColumnIndex, ...currentEditMode }) => {\n let nextCellIndex: number;\n\n switch (moveDirection) {\n case MOVE_DIR.FIRST:\n nextCellIndex = firstDataColumnIndex;\n break;\n case MOVE_DIR.LAST:\n nextCellIndex = lastDataColumnIndex;\n break;\n case MOVE_DIR.PREV:\n // moves to the last data column of the previous row, if the current column is the first column\n if (currentColumnIndex === firstDataColumnIndex) {\n moveRow?.(MOVE_DIR.PREV);\n nextCellIndex = lastDataColumnIndex;\n } else {\n nextCellIndex = focussableColumnIndexes[getNextIndex(-1, currentColumnIndex, focussableColumnIndexes)];\n }\n break;\n case MOVE_DIR.NEXT:\n // moves to the first data column of the next row, if the current column is the last column\n if (currentColumnIndex === lastDataColumnIndex) {\n moveRow?.(MOVE_DIR.NEXT);\n nextCellIndex = firstDataColumnIndex;\n } else {\n nextCellIndex = focussableColumnIndexes[getNextIndex(1, currentColumnIndex, focussableColumnIndexes)];\n }\n break;\n }\n\n return { ...currentEditMode, columnIndex: nextCellIndex };\n });\n };\n\n // output\n const toggleEditing = (isEditing?: boolean, columnIndex = 0) => {\n if (!editMode.enableEditMode) {\n return;\n }\n\n setEditMode(editMode => ({ ...editMode, isEditing: isEditing ?? !editMode.isEditing, columnIndex }));\n };\n const moveToPreviousColumn = (focussableColumnIndexes: number[], moveRow?: (moveDirecttion: MOVE_DIR) => void) =>\n _moveActiveColumn(MOVE_DIR.PREV, focussableColumnIndexes, moveRow);\n const moveToNextColumn = (focussableColumnIndexes: number[], moveRow?: (moveDirecttion: MOVE_DIR) => void) =>\n _moveActiveColumn(MOVE_DIR.NEXT, focussableColumnIndexes, moveRow);\n const moveToFirstColumn = (focussableColumnIndexes: number[]) => _moveActiveColumn(MOVE_DIR.FIRST, focussableColumnIndexes);\n const moveToLastColumn = (focussableColumnIndexes: number[]) => _moveActiveColumn(MOVE_DIR.LAST, focussableColumnIndexes);\n const setColumn = (columnIndex: number) => {\n if (!editMode.enableEditMode) {\n return;\n }\n\n setEditMode(currentEditMode => ({ ...currentEditMode, columnIndex }));\n };\n\n return {\n ...editMode,\n onSave: handleSave,\n toggleEditing,\n moveToPreviousColumn,\n moveToNextColumn,\n moveToFirstColumn,\n moveToLastColumn,\n setColumn,\n };\n};\n\nconst getNextIndex = (direction: -1 | 1, currentIndex: number, focussableColumnIndexes: number[]) => {\n const currentIndexPosition = focussableColumnIndexes.indexOf(currentIndex);\n const length = focussableColumnIndexes.length;\n\n if (direction === -1) {\n return currentIndexPosition - 1 > 0 ? currentIndexPosition - 1 : 0;\n }\n\n return currentIndexPosition + 1 < length ? currentIndexPosition + 1 : currentIndexPosition;\n};\n"],"names":["MOVE_DIR","useEditMode","handleSave","enableEditMode","editMode","setEditMode","React","useState","isEditing","columnIndex","useEffect","_moveActiveColumn","moveDirection","focussableColumnIndexes","moveRow","firstDataColumnIndex","_focussableColumnInde","at","lastDataColumnIndex","_focussableColumnInde2","currentColumnIndex","currentEditMode","nextCellIndex","FIRST","LAST","PREV","getNextIndex","NEXT","toggleEditing","moveToPreviousColumn","moveToNextColumn","moveToFirstColumn","moveToLastColumn","setColumn","onSave","direction","currentIndex","currentIndexPosition","indexOf","length"],"mappings":";;IA2BYA;AAA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C3H,MAAMmB,gBAAgB,GAAInB,uBAAiC,IAAKF,iBAAiB,CAACX,QAAQ,CAACwB,IAAI,EAAEX,uBAAuB,CAAC;EACzH,MAAMoB,SAAS,GAAIxB,WAAmB;IAClC,IAAI,CAACL,QAAQ,CAACD,cAAc,EAAE;MAC1B;;IAGJE,WAAW,CAACgB,eAAe,KAAK;MAAE,GAAGA,eAAe;MAAEZ;KAAa,CAAC,CAAC;GACxE;EAED,OAAO;IACH,GAAGL,QAAQ;IACX8B,MAAM,EAAEhC,UAAU;IAClB0B,aAAa;IACbC,oBAAoB;IACpBC,gBAAgB;IAChBC,iBAAiB;IACjBC,gBAAgB;IAChBC;GACH;AACL;AAEA,MAAMP,YAAY,GAAGA,CAACS,SAAiB,EAAEC,YAAoB,EAAEvB,uBAAiC;EAC5F,MAAMwB,oBAAoB,GAAGxB,uBAAuB,CAACyB,OAAO,CAACF,YAAY,CAAC;EAC1E,MAAMG,MAAM,GAAG1B,uBAAuB,CAAC0B,MAAM;EAE7C,IAAIJ,SAAS,KAAK,CAAC,CAAC,EAAE;IAClB,OAAOE,oBAAoB,GAAG,CAAC,GAAG,CAAC,GAAGA,oBAAoB,GAAG,CAAC,GAAG,CAAC;;EAGtE,OAAOA,oBAAoB,GAAG,CAAC,GAAGE,MAAM,GAAGF,oBAAoB,GAAG,CAAC,GAAGA,oBAAoB;AAC9F,CAAC;;;;"}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
import { COLUMN_ID_FOR_ACTIONS, isInternalColumn } from '../utilities/columns.js';
|
2
|
-
|
3
|
-
const useGridTemplate = table => {
|
4
|
-
const allVisibleColumns = table.getVisibleLeafColumns();
|
5
|
-
return allVisibleColumns.reduce((accum, column, index) => {
|
6
|
-
let size;
|
7
|
-
const isLastColumn = index === allVisibleColumns.length - 1;
|
8
|
-
const width = table.getState().columnSizing[column.id];
|
9
|
-
if (column.id === COLUMN_ID_FOR_ACTIONS) {
|
10
|
-
size = `minmax(max-content, auto)`;
|
11
|
-
} else if (isInternalColumn(column.id)) {
|
12
|
-
size = `${column.getSize()}px`;
|
13
|
-
} else if (width) {
|
14
|
-
if (width === '1fr') {
|
15
|
-
size = 'minmax(max-content, 1fr)';
|
16
|
-
} else if (isLastColumn) {
|
17
|
-
size = `minmax(${width}px, auto)`;
|
18
|
-
} else if (column.columnDef.minSize && width < column.columnDef.minSize) {
|
19
|
-
// react-table is supposed to handle minSize itself but it is really buggy
|
20
|
-
size = `${column.columnDef.minSize}px`;
|
21
|
-
} else {
|
22
|
-
size = `${width}px`;
|
23
|
-
}
|
24
|
-
} else if (column.getCanResize()) {
|
25
|
-
size = 'minmax(max-content, auto)';
|
26
|
-
} else {
|
27
|
-
size = 'max-content';
|
28
|
-
}
|
29
|
-
return `${accum} ${size}`;
|
30
|
-
}, '');
|
31
|
-
};
|
32
|
-
|
33
|
-
export { useGridTemplate };
|
34
|
-
//# sourceMappingURL=useGridTemplate.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useGridTemplate.js","sources":["../../../../../../../../src/components/Table2/hooks/useGridTemplate.ts"],"sourcesContent":["import { Table } from '@tanstack/react-table';\nimport { COLUMN_ID_FOR_ACTIONS, isInternalColumn } from '../utilities/columns';\n\nexport const useGridTemplate = (table: Table<any>) => {\n const allVisibleColumns = table.getVisibleLeafColumns();\n\n return allVisibleColumns.reduce((accum, column, index) => {\n let size;\n const isLastColumn = index === allVisibleColumns.length - 1;\n const width = table.getState().columnSizing[column.id] as number | '1fr';\n\n if (column.id === COLUMN_ID_FOR_ACTIONS) {\n size = `minmax(max-content, auto)`;\n } else if (isInternalColumn(column.id)) {\n size = `${column.getSize()}px`;\n } else if (width) {\n if (width === '1fr') {\n size = 'minmax(max-content, 1fr)';\n } else if (isLastColumn) {\n size = `minmax(${width}px, auto)`;\n } else if (column.columnDef.minSize && width < column.columnDef.minSize) {\n // react-table is supposed to handle minSize itself but it is really buggy\n size = `${column.columnDef.minSize}px`;\n } else {\n size = `${width}px`;\n }\n } else if (column.getCanResize()) {\n size = 'minmax(max-content, auto)';\n } else {\n size = 'max-content';\n }\n\n return `${accum} ${size}`;\n }, '');\n};\n"],"names":["useGridTemplate","table","allVisibleColumns","getVisibleLeafColumns","reduce","accum","column","index","size","isLastColumn","length","width","getState","columnSizing","id","COLUMN_ID_FOR_ACTIONS","isInternalColumn","getSize","columnDef","minSize","getCanResize"],"mappings":";;MAGaA,eAAe,GAAIC,KAAiB;EAC7C,MAAMC,iBAAiB,GAAGD,KAAK,CAACE,qBAAqB,EAAE;EAEvD,OAAOD,iBAAiB,CAACE,MAAM,CAAC,CAACC,KAAK,EAAEC,MAAM,EAAEC,KAAK;IACjD,IAAIC,IAAI;IACR,MAAMC,YAAY,GAAGF,KAAK,KAAKL,iBAAiB,CAACQ,MAAM,GAAG,CAAC;IAC3D,MAAMC,KAAK,GAAGV,KAAK,CAACW,QAAQ,EAAE,CAACC,YAAY,CAACP,MAAM,CAACQ,EAAE,CAAmB;IAExE,IAAIR,MAAM,CAACQ,EAAE,KAAKC,qBAAqB,EAAE;MACrCP,IAAI,8BAA8B;KACrC,MAAM,IAAIQ,gBAAgB,CAACV,MAAM,CAACQ,EAAE,CAAC,EAAE;MACpCN,IAAI,MAAMF,MAAM,CAACW,OAAO,MAAM;KACjC,MAAM,IAAIN,KAAK,EAAE;MACd,IAAIA,KAAK,KAAK,KAAK,EAAE;QACjBH,IAAI,GAAG,0BAA0B;OACpC,MAAM,IAAIC,YAAY,EAAE;QACrBD,IAAI,aAAaG,gBAAgB;OACpC,MAAM,IAAIL,MAAM,CAACY,SAAS,CAACC,OAAO,IAAIR,KAAK,GAAGL,MAAM,CAACY,SAAS,CAACC,OAAO,EAAE;;QAErEX,IAAI,MAAMF,MAAM,CAACY,SAAS,CAACC,WAAW;OACzC,MAAM;QACHX,IAAI,MAAMG,SAAS;;KAE1B,MAAM,IAAIL,MAAM,CAACc,YAAY,EAAE,EAAE;MAC9BZ,IAAI,GAAG,2BAA2B;KACrC,MAAM;MACHA,IAAI,GAAG,aAAa;;IAGxB,UAAUH,SAASG,MAAM;GAC5B,EAAE,EAAE,CAAC;AACV;;;;"}
|
@@ -1,222 +0,0 @@
|
|
1
|
-
import React__default from 'react';
|
2
|
-
import { useIsHoverStatePaused } from '../../../hooks/useIsHoverStatePaused.js';
|
3
|
-
import { getSortedRowModel, getFilteredRowModel, useReactTable, getCoreRowModel } from '@tanstack/react-table';
|
4
|
-
import { ensureOrdering } from '../utilities/columns.js';
|
5
|
-
import { columnFilterFn, globalFilterFn } from '../utilities/filterFn.js';
|
6
|
-
import { useEditMode } from './useEditMode.js';
|
7
|
-
import { useColumnDefinitions } from './useColumnDefinitions.js';
|
8
|
-
import { useColumnOffsetStateListener } from './listeners/useColumnOffsetStateListener.js';
|
9
|
-
import { useRowSelectionListener } from './listeners/useRowSelectionListener.js';
|
10
|
-
import { useSettingsStateListener } from './listeners/useSettingsStateListener.js';
|
11
|
-
import { useActiveRow } from './useActiveRow.js';
|
12
|
-
import { useActiveRowStateListener } from './listeners/useActiveRowStateListener.js';
|
13
|
-
import { useFilterStateListener } from './listeners/useFilterStateListener.js';
|
14
|
-
import { useTableShortcuts } from './useTableShortcuts.js';
|
15
|
-
|
16
|
-
const ACTIONS_ON_ROW_LENGTH = 4;
|
17
|
-
function useTable(children, props, ref) {
|
18
|
-
var _settings$frozenColum, _settings$columnSizin, _settings$columnVisib, _settings$rowDensity, _tableRows$activeRow$;
|
19
|
-
const {
|
20
|
-
actionsForRow = [],
|
21
|
-
actionsForRowLength = ACTIONS_ON_ROW_LENGTH,
|
22
|
-
data,
|
23
|
-
defaultActiveRowIndex,
|
24
|
-
disableColumnFiltering = false,
|
25
|
-
disableColumnHiding = false,
|
26
|
-
disableColumnFreezing = false,
|
27
|
-
disableColumnReordering = false,
|
28
|
-
disableColumnResizing = false,
|
29
|
-
disableRowDensity = false,
|
30
|
-
disableRowExpansion = false,
|
31
|
-
disableRowSelection = false,
|
32
|
-
disableMultipleRowSelection = false,
|
33
|
-
disableSearch = false,
|
34
|
-
disableSorting = false,
|
35
|
-
expandedRowRenderer,
|
36
|
-
manualColumnFiltering = false,
|
37
|
-
manualSearch = false,
|
38
|
-
manualSorting = false,
|
39
|
-
onChangeSettings,
|
40
|
-
onRowClick,
|
41
|
-
onRowDrag,
|
42
|
-
onRowSelect,
|
43
|
-
onSave,
|
44
|
-
settings = {},
|
45
|
-
shortcuts,
|
46
|
-
// experimental
|
47
|
-
_experimentalActionsForTable
|
48
|
-
} = props;
|
49
|
-
const enableRowExpansion = !disableRowExpansion && !!expandedRowRenderer;
|
50
|
-
const enableRowSelection = !disableRowSelection && (!!onRowSelect || !!(_experimentalActionsForTable !== null && _experimentalActionsForTable !== void 0 && _experimentalActionsForTable.length));
|
51
|
-
const enableMultipleRowSelection = !disableMultipleRowSelection && enableRowSelection;
|
52
|
-
const {
|
53
|
-
columns,
|
54
|
-
internalFrozenColumnCount,
|
55
|
-
defaultColumnSizing,
|
56
|
-
defaultSorting,
|
57
|
-
defaultColumnVisibility,
|
58
|
-
footers
|
59
|
-
} = useColumnDefinitions(children, {
|
60
|
-
actionsForRow,
|
61
|
-
actionsForRowLength,
|
62
|
-
enableColumnFiltering: !disableColumnFiltering,
|
63
|
-
enableColumnHiding: !disableColumnHiding,
|
64
|
-
enableColumnFreezing: !disableColumnFreezing,
|
65
|
-
enableRowExpansion,
|
66
|
-
enableRowSelection,
|
67
|
-
enableMultipleRowSelection,
|
68
|
-
expandedRowRenderer,
|
69
|
-
onRowDrag
|
70
|
-
}, ref);
|
71
|
-
const lastSortedOrFilteredRows = React__default.useRef(null);
|
72
|
-
const totalFrozenColumns = internalFrozenColumnCount + ((_settings$frozenColum = settings === null || settings === void 0 ? void 0 : settings.frozenColumnCount) !== null && _settings$frozenColum !== void 0 ? _settings$frozenColum : 0);
|
73
|
-
const frozenColumns = columns.slice(0, totalFrozenColumns).map(column => column.id);
|
74
|
-
// defaults
|
75
|
-
const initialState = {
|
76
|
-
columnOrder: ensureOrdering(columns, settings === null || settings === void 0 ? void 0 : settings.columnOrder),
|
77
|
-
columnPinning: {
|
78
|
-
left: frozenColumns,
|
79
|
-
right: []
|
80
|
-
},
|
81
|
-
columnSizing: (_settings$columnSizin = settings === null || settings === void 0 ? void 0 : settings.columnSizing) !== null && _settings$columnSizin !== void 0 ? _settings$columnSizin : defaultColumnSizing,
|
82
|
-
columnVisibility: (_settings$columnVisib = settings === null || settings === void 0 ? void 0 : settings.columnVisibility) !== null && _settings$columnVisib !== void 0 ? _settings$columnVisib : defaultColumnVisibility
|
83
|
-
};
|
84
|
-
// Data column index - these are needed to make sure left and right arrow key shortcuts focuses only the data columns
|
85
|
-
const dataColumnStartOffset = [!!onRowDrag, !!enableRowExpansion, !!enableRowSelection].reduce((t, e) => t + (e ? 1 : 0), 0);
|
86
|
-
const dataColumnEndOffset = actionsForRow.length ? 1 : 0;
|
87
|
-
// custom
|
88
|
-
const activeRow = useActiveRow(defaultActiveRowIndex);
|
89
|
-
const [shouldPauseHoverState, setShouldPauseHoverState] = useIsHoverStatePaused();
|
90
|
-
const editMode = useEditMode(onSave);
|
91
|
-
const [columnOffsets, setColumnOffsets] = React__default.useState({});
|
92
|
-
const [rowDensity, setRowDensity] = React__default.useState((_settings$rowDensity = settings === null || settings === void 0 ? void 0 : settings.rowDensity) !== null && _settings$rowDensity !== void 0 ? _settings$rowDensity : 'normal');
|
93
|
-
const [dragging, setDragging] = React__default.useState({});
|
94
|
-
const [shouldPauseSortingAndFiltering, setShouldPauseSortingAndFiltering] = React__default.useState(false);
|
95
|
-
const [shouldDisableTableActions, setShouldDisableTableActions] = React__default.useState(false);
|
96
|
-
// Frozen column count is the count of external columns that are frozen
|
97
|
-
const [frozenColumnsCount, setFrozenColumnsCount] = React__default.useState(totalFrozenColumns - internalFrozenColumnCount);
|
98
|
-
// For some reason, using state instead of ref didn't work as expected, that's why ref is used
|
99
|
-
const focussableColumnIndexes = React__default.useRef([]);
|
100
|
-
// some options get set even if they are undefined, so we have to do it conditionally
|
101
|
-
const options = {
|
102
|
-
enableExpanding: enableRowExpansion,
|
103
|
-
enableColumnFilters: !disableColumnFiltering,
|
104
|
-
enableColumnResizing: !disableColumnResizing,
|
105
|
-
enableGlobalFilter: !disableSearch,
|
106
|
-
enableHiding: !disableColumnHiding,
|
107
|
-
enablePinning: !disableColumnFreezing,
|
108
|
-
enableRowSelection: enableRowSelection,
|
109
|
-
enableMultiRowSelection: enableMultipleRowSelection,
|
110
|
-
enableSorting: !disableSorting
|
111
|
-
};
|
112
|
-
// resizing
|
113
|
-
if (options.enableColumnResizing) {
|
114
|
-
options.columnResizeMode = 'onChange';
|
115
|
-
}
|
116
|
-
// sorting
|
117
|
-
if (options.enableSorting) {
|
118
|
-
const sanitizeSortedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);
|
119
|
-
initialState.sorting = settings !== null && settings !== void 0 && settings.sorting ? settings === null || settings === void 0 ? void 0 : settings.sorting.filter(sanitizeSortedColumns) : defaultSorting;
|
120
|
-
if (manualSorting) {
|
121
|
-
options.manualSorting = true;
|
122
|
-
} else {
|
123
|
-
options.getSortedRowModel = getSortedRowModel();
|
124
|
-
}
|
125
|
-
}
|
126
|
-
// filtering
|
127
|
-
if (options.enableColumnFilters) {
|
128
|
-
var _settings$columnFilte;
|
129
|
-
initialState.columnFilters = (_settings$columnFilte = settings === null || settings === void 0 ? void 0 : settings.columnFilters) !== null && _settings$columnFilte !== void 0 ? _settings$columnFilte : [];
|
130
|
-
if (manualColumnFiltering) {
|
131
|
-
options.manualFiltering = true;
|
132
|
-
} else {
|
133
|
-
options.filterFns = {
|
134
|
-
tacoFilter: (row, columnId, filter) => columnFilterFn(row.getValue(columnId), filter)
|
135
|
-
};
|
136
|
-
options.getFilteredRowModel = getFilteredRowModel();
|
137
|
-
}
|
138
|
-
}
|
139
|
-
// search
|
140
|
-
if (options.enableGlobalFilter) {
|
141
|
-
if (manualSearch) {
|
142
|
-
options.manualFiltering = true;
|
143
|
-
} else {
|
144
|
-
options.globalFilterFn = (row, columnId, query) => globalFilterFn(row.getValue(columnId), query);
|
145
|
-
options.getFilteredRowModel = getFilteredRowModel();
|
146
|
-
}
|
147
|
-
}
|
148
|
-
const table = useReactTable({
|
149
|
-
data,
|
150
|
-
columns: columns,
|
151
|
-
getCoreRowModel: getCoreRowModel(),
|
152
|
-
initialState,
|
153
|
-
...options,
|
154
|
-
meta: {
|
155
|
-
...activeRow,
|
156
|
-
editMode,
|
157
|
-
// offsets
|
158
|
-
columnOffsets,
|
159
|
-
// density
|
160
|
-
enableRowDensity: !disableRowDensity,
|
161
|
-
rowDensity,
|
162
|
-
setRowDensity,
|
163
|
-
// dragging
|
164
|
-
enableRowDragging: !!onRowDrag,
|
165
|
-
dragging,
|
166
|
-
setDragging,
|
167
|
-
// computed
|
168
|
-
enableColumnFreezing: !disableColumnFreezing,
|
169
|
-
enableColumnReordering: !disableColumnReordering,
|
170
|
-
enableColumnHiding: !disableColumnHiding,
|
171
|
-
shouldPauseHoverState,
|
172
|
-
setShouldPauseHoverState,
|
173
|
-
frozenColumnsCount,
|
174
|
-
setFrozenColumnsCount,
|
175
|
-
// resorting
|
176
|
-
shouldPauseSortingAndFiltering,
|
177
|
-
setShouldPauseSortingAndFiltering,
|
178
|
-
// other
|
179
|
-
onRowClick,
|
180
|
-
// data column positions
|
181
|
-
dataColumnStartOffset,
|
182
|
-
dataColumnEndOffset,
|
183
|
-
// disable table actions
|
184
|
-
shouldDisableTableActions,
|
185
|
-
setShouldDisableTableActions,
|
186
|
-
// active row column indexes
|
187
|
-
focussableColumnIndexes: focussableColumnIndexes.current,
|
188
|
-
addFocussableColumnIndex: index => {
|
189
|
-
if (!focussableColumnIndexes.current.includes(index)) {
|
190
|
-
focussableColumnIndexes.current = [...focussableColumnIndexes.current, index].sort((a, b) => a - b);
|
191
|
-
}
|
192
|
-
},
|
193
|
-
resetFocussableColumnIndexes: () => {
|
194
|
-
focussableColumnIndexes.current = [];
|
195
|
-
},
|
196
|
-
// table ref
|
197
|
-
tableRef: ref,
|
198
|
-
// last sorted or filtered rows
|
199
|
-
lastSortedOrFilteredRows
|
200
|
-
}
|
201
|
-
});
|
202
|
-
const tableRows = table.getRowModel().rows;
|
203
|
-
if (!shouldPauseSortingAndFiltering) {
|
204
|
-
lastSortedOrFilteredRows.current = tableRows;
|
205
|
-
}
|
206
|
-
const rows = shouldPauseSortingAndFiltering ? lastSortedOrFilteredRows.current : tableRows;
|
207
|
-
// state listeners
|
208
|
-
useActiveRowStateListener(table, rows, activeRow);
|
209
|
-
useColumnOffsetStateListener(table, setColumnOffsets);
|
210
|
-
useFilterStateListener(table, onRowSelect);
|
211
|
-
useRowSelectionListener(table, onRowSelect);
|
212
|
-
useSettingsStateListener(table, onChangeSettings);
|
213
|
-
useTableShortcuts(shortcuts, (_tableRows$activeRow$ = tableRows[activeRow.activeRowIndex]) === null || _tableRows$activeRow$ === void 0 ? void 0 : _tableRows$activeRow$.original);
|
214
|
-
return {
|
215
|
-
rows,
|
216
|
-
table,
|
217
|
-
footers
|
218
|
-
};
|
219
|
-
}
|
220
|
-
|
221
|
-
export { useTable };
|
222
|
-
//# sourceMappingURL=useTable.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useTable.js","sources":["../../../../../../../../src/components/Table2/hooks/useTable.ts"],"sourcesContent":["import React from 'react';\nimport {\n useReactTable,\n getCoreRowModel,\n OnChangeFn,\n getSortedRowModel,\n getFilteredRowModel,\n RowData,\n TableState,\n TableOptions,\n} from '@tanstack/react-table';\nimport { RowClickHandler, RowDensity, Table2Children, Table2Props } from '../types';\nimport { useColumnDefinitions } from './useColumnDefinitions';\nimport { useColumnOffsetStateListener } from './listeners/useColumnOffsetStateListener';\nimport { ColumnOffsetState } from '../types';\nimport { useRowSelectionListener } from './listeners/useRowSelectionListener';\nimport { useSettingsStateListener } from './listeners/useSettingsStateListener';\nimport { columnFilterFn, globalFilterFn } from '../utilities/filterFn';\nimport { ActiveRowHandler, ActiveRowMoveHandler, useActiveRow } from './useActiveRow';\nimport { useActiveRowStateListener } from './listeners/useActiveRowStateListener';\nimport { useEditMode } from './useEditMode';\nimport { useIsHoverStatePaused } from '../../../hooks/useIsHoverStatePaused';\nimport { useFilterStateListener } from './listeners/useFilterStateListener';\nimport { ensureOrdering } from '../utilities/columns';\nimport { useTableShortcuts } from './useTableShortcuts';\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n // active row\n activeRowIndex: number;\n setActiveRowIndex: ActiveRowHandler;\n moveToPreviousRow: ActiveRowMoveHandler<TData>;\n moveToNextRow: ActiveRowMoveHandler<TData>;\n // offsets\n columnOffsets: ColumnOffsetState;\n // density\n enableRowDensity: boolean;\n rowDensity: RowDensity;\n setRowDensity: OnChangeFn<RowDensity>;\n // dragging\n enableRowDragging: boolean;\n dragging: Record<string, boolean>;\n setDragging: OnChangeFn<Record<string, boolean>>;\n // computed\n enableColumnFreezing: boolean;\n enableColumnReordering: boolean;\n enableColumnHiding: boolean;\n shouldPauseSortingAndFiltering: boolean;\n setShouldPauseSortingAndFiltering: OnChangeFn<boolean>;\n shouldPauseHoverState: boolean;\n setShouldPauseHoverState: OnChangeFn<boolean>;\n frozenColumnsCount: number;\n setFrozenColumnsCount: OnChangeFn<number>;\n // other\n onRowClick?: RowClickHandler<TData>;\n // editing\n editMode: useEditMode;\n // used to determine first and last data column position\n dataColumnStartOffset: number;\n dataColumnEndOffset: number;\n // disable table actions\n shouldDisableTableActions: boolean;\n setShouldDisableTableActions: OnChangeFn<boolean>;\n // active row column indexes\n focussableColumnIndexes: number[];\n addFocussableColumnIndex: (index: number) => void;\n resetFocussableColumnIndexes: () => void;\n // table ref\n tableRef: React.RefObject<HTMLDivElement>;\n // last sorted or filtered rows\n lastSortedOrFilteredRows: React.MutableRefObject<Array<any>>;\n }\n}\n\nconst ACTIONS_ON_ROW_LENGTH = 4;\n\nexport function useTable<TType = any>(children: Table2Children, props: Table2Props<TType>, ref: React.RefObject<HTMLDivElement>) {\n const {\n actionsForRow = [],\n actionsForRowLength = ACTIONS_ON_ROW_LENGTH,\n data,\n defaultActiveRowIndex,\n disableColumnFiltering = false,\n disableColumnHiding = false,\n disableColumnFreezing = false,\n disableColumnReordering = false,\n disableColumnResizing = false,\n disableRowDensity = false,\n disableRowExpansion = false,\n disableRowSelection = false,\n disableMultipleRowSelection = false,\n disableSearch = false,\n disableSorting = false,\n expandedRowRenderer,\n manualColumnFiltering = false,\n manualSearch = false,\n manualSorting = false,\n onChangeSettings,\n onRowClick,\n onRowDrag,\n onRowSelect,\n onSave,\n settings = {},\n shortcuts,\n // experimental\n _experimentalActionsForTable,\n } = props;\n\n const enableRowExpansion = !disableRowExpansion && !!expandedRowRenderer;\n const enableRowSelection = !disableRowSelection && (!!onRowSelect || !!_experimentalActionsForTable?.length);\n const enableMultipleRowSelection = !disableMultipleRowSelection && enableRowSelection;\n\n const { columns, internalFrozenColumnCount, defaultColumnSizing, defaultSorting, defaultColumnVisibility, footers } =\n useColumnDefinitions<TType>(\n children,\n {\n actionsForRow,\n actionsForRowLength,\n enableColumnFiltering: !disableColumnFiltering,\n enableColumnHiding: !disableColumnHiding,\n enableColumnFreezing: !disableColumnFreezing,\n enableRowExpansion,\n enableRowSelection,\n enableMultipleRowSelection,\n expandedRowRenderer,\n onRowDrag,\n },\n ref\n );\n\n const lastSortedOrFilteredRows = React.useRef<any>(null);\n const totalFrozenColumns = internalFrozenColumnCount + (settings?.frozenColumnCount ?? 0);\n const frozenColumns = columns.slice(0, totalFrozenColumns).map(column => column.id);\n\n // defaults\n const initialState: Partial<TableState> = {\n columnOrder: ensureOrdering<TType>(columns, settings?.columnOrder),\n columnPinning: {\n left: frozenColumns,\n right: [],\n },\n columnSizing: settings?.columnSizing ?? defaultColumnSizing,\n columnVisibility: settings?.columnVisibility ?? defaultColumnVisibility,\n };\n\n // Data column index - these are needed to make sure left and right arrow key shortcuts focuses only the data columns\n const dataColumnStartOffset = [!!onRowDrag, !!enableRowExpansion, !!enableRowSelection].reduce((t, e) => t + (e ? 1 : 0), 0);\n const dataColumnEndOffset = actionsForRow.length ? 1 : 0;\n\n // custom\n const activeRow = useActiveRow<TType>(defaultActiveRowIndex);\n const [shouldPauseHoverState, setShouldPauseHoverState] = useIsHoverStatePaused();\n const editMode = useEditMode(onSave);\n const [columnOffsets, setColumnOffsets] = React.useState({});\n const [rowDensity, setRowDensity] = React.useState<RowDensity>(settings?.rowDensity ?? 'normal');\n const [dragging, setDragging] = React.useState<Record<string, boolean>>({});\n const [shouldPauseSortingAndFiltering, setShouldPauseSortingAndFiltering] = React.useState<boolean>(false);\n const [shouldDisableTableActions, setShouldDisableTableActions] = React.useState<boolean>(false);\n // Frozen column count is the count of external columns that are frozen\n const [frozenColumnsCount, setFrozenColumnsCount] = React.useState(totalFrozenColumns - internalFrozenColumnCount);\n // For some reason, using state instead of ref didn't work as expected, that's why ref is used\n const focussableColumnIndexes = React.useRef<number[]>([]);\n\n // some options get set even if they are undefined, so we have to do it conditionally\n const options: Partial<TableOptions<any>> = {\n enableExpanding: enableRowExpansion,\n enableColumnFilters: !disableColumnFiltering,\n enableColumnResizing: !disableColumnResizing,\n enableGlobalFilter: !disableSearch,\n enableHiding: !disableColumnHiding,\n enablePinning: !disableColumnFreezing,\n enableRowSelection: enableRowSelection,\n enableMultiRowSelection: enableMultipleRowSelection,\n enableSorting: !disableSorting,\n };\n\n // resizing\n if (options.enableColumnResizing) {\n options.columnResizeMode = 'onChange';\n }\n\n // sorting\n if (options.enableSorting) {\n const sanitizeSortedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);\n initialState.sorting = settings?.sorting ? settings?.sorting.filter(sanitizeSortedColumns) : defaultSorting;\n\n if (manualSorting) {\n options.manualSorting = true;\n } else {\n options.getSortedRowModel = getSortedRowModel();\n }\n }\n\n // filtering\n if (options.enableColumnFilters) {\n initialState.columnFilters = settings?.columnFilters ?? [];\n\n if (manualColumnFiltering) {\n options.manualFiltering = true;\n } else {\n options.filterFns = {\n tacoFilter: (row, columnId, filter) => columnFilterFn(row.getValue(columnId), filter),\n };\n options.getFilteredRowModel = getFilteredRowModel();\n }\n }\n\n // search\n if (options.enableGlobalFilter) {\n if (manualSearch) {\n options.manualFiltering = true;\n } else {\n options.globalFilterFn = (row, columnId, query) => globalFilterFn(row.getValue(columnId), query);\n options.getFilteredRowModel = getFilteredRowModel();\n }\n }\n\n const table = useReactTable({\n data,\n columns: columns as any,\n getCoreRowModel: getCoreRowModel(),\n initialState,\n ...options,\n meta: {\n ...activeRow,\n editMode,\n // offsets\n columnOffsets,\n // density\n enableRowDensity: !disableRowDensity,\n rowDensity,\n setRowDensity,\n // dragging\n enableRowDragging: !!onRowDrag,\n dragging,\n setDragging,\n // computed\n enableColumnFreezing: !disableColumnFreezing,\n enableColumnReordering: !disableColumnReordering,\n enableColumnHiding: !disableColumnHiding,\n shouldPauseHoverState,\n setShouldPauseHoverState,\n frozenColumnsCount,\n setFrozenColumnsCount,\n // resorting\n shouldPauseSortingAndFiltering,\n setShouldPauseSortingAndFiltering,\n // other\n onRowClick,\n // data column positions\n dataColumnStartOffset,\n dataColumnEndOffset,\n // disable table actions\n shouldDisableTableActions,\n setShouldDisableTableActions,\n // active row column indexes\n focussableColumnIndexes: focussableColumnIndexes.current,\n addFocussableColumnIndex: (index: number) => {\n if (!focussableColumnIndexes.current.includes(index)) {\n focussableColumnIndexes.current = [...focussableColumnIndexes.current, index].sort((a, b) => a - b);\n }\n },\n resetFocussableColumnIndexes: () => {\n focussableColumnIndexes.current = [];\n },\n // table ref\n tableRef: ref,\n // last sorted or filtered rows\n lastSortedOrFilteredRows,\n },\n });\n\n const tableRows = table.getRowModel().rows;\n\n if (!shouldPauseSortingAndFiltering) {\n lastSortedOrFilteredRows.current = tableRows;\n }\n\n const rows = shouldPauseSortingAndFiltering ? lastSortedOrFilteredRows.current : tableRows;\n\n // state listeners\n useActiveRowStateListener<TType>(table, rows, activeRow);\n useColumnOffsetStateListener(table, setColumnOffsets);\n useFilterStateListener<TType>(table, onRowSelect);\n useRowSelectionListener<TType>(table, onRowSelect);\n useSettingsStateListener(table, onChangeSettings);\n\n useTableShortcuts(shortcuts, tableRows[activeRow.activeRowIndex]?.original);\n\n return { rows, table, footers };\n}\n"],"names":["ACTIONS_ON_ROW_LENGTH","useTable","children","props","ref","actionsForRow","actionsForRowLength","data","defaultActiveRowIndex","disableColumnFiltering","disableColumnHiding","disableColumnFreezing","disableColumnReordering","disableColumnResizing","disableRowDensity","disableRowExpansion","disableRowSelection","disableMultipleRowSelection","disableSearch","disableSorting","expandedRowRenderer","manualColumnFiltering","manualSearch","manualSorting","onChangeSettings","onRowClick","onRowDrag","onRowSelect","onSave","settings","shortcuts","_experimentalActionsForTable","enableRowExpansion","enableRowSelection","length","enableMultipleRowSelection","columns","internalFrozenColumnCount","defaultColumnSizing","defaultSorting","defaultColumnVisibility","footers","useColumnDefinitions","enableColumnFiltering","enableColumnHiding","enableColumnFreezing","lastSortedOrFilteredRows","React","useRef","totalFrozenColumns","_settings$frozenColum","frozenColumnCount","frozenColumns","slice","map","column","id","initialState","columnOrder","ensureOrdering","columnPinning","left","right","columnSizing","_settings$columnSizin","columnVisibility","_settings$columnVisib","dataColumnStartOffset","reduce","t","e","dataColumnEndOffset","activeRow","useActiveRow","shouldPauseHoverState","setShouldPauseHoverState","useIsHoverStatePaused","editMode","useEditMode","columnOffsets","setColumnOffsets","useState","rowDensity","setRowDensity","_settings$rowDensity","dragging","setDragging","shouldPauseSortingAndFiltering","setShouldPauseSortingAndFiltering","shouldDisableTableActions","setShouldDisableTableActions","frozenColumnsCount","setFrozenColumnsCount","focussableColumnIndexes","options","enableExpanding","enableColumnFilters","enableColumnResizing","enableGlobalFilter","enableHiding","enablePinning","enableMultiRowSelection","enableSorting","columnResizeMode","sanitizeSortedColumns","find","definedColumn","sorting","filter","getSortedRowModel","_settings$columnFilte","columnFilters","manualFiltering","filterFns","tacoFilter","row","columnId","columnFilterFn","getValue","getFilteredRowModel","globalFilterFn","query","table","useReactTable","getCoreRowModel","meta","enableRowDensity","enableRowDragging","enableColumnReordering","current","addFocussableColumnIndex","index","includes","sort","a","b","resetFocussableColumnIndexes","tableRef","tableRows","getRowModel","rows","useActiveRowStateListener","useColumnOffsetStateListener","useFilterStateListener","useRowSelectionListener","useSettingsStateListener","useTableShortcuts","_tableRows$activeRow$","activeRowIndex","original"],"mappings":";;;;;;;;;;;;;;;AA0EA,MAAMA,qBAAqB,GAAG,CAAC;SAEfC,QAAQA,CAAcC,QAAwB,EAAEC,KAAyB,EAAEC,GAAoC;;EAC3H,MAAM;IACFC,aAAa,GAAG,EAAE;IAClBC,mBAAmB,GAAGN,qBAAqB;IAC3CO,IAAI;IACJC,qBAAqB;IACrBC,sBAAsB,GAAG,KAAK;IAC9BC,mBAAmB,GAAG,KAAK;IAC3BC,qBAAqB,GAAG,KAAK;IAC7BC,uBAAuB,GAAG,KAAK;IAC/BC,qBAAqB,GAAG,KAAK;IAC7BC,iBAAiB,GAAG,KAAK;IACzBC,mBAAmB,GAAG,KAAK;IAC3BC,mBAAmB,GAAG,KAAK;IAC3BC,2BAA2B,GAAG,KAAK;IACnCC,aAAa,GAAG,KAAK;IACrBC,cAAc,GAAG,KAAK;IACtBC,mBAAmB;IACnBC,qBAAqB,GAAG,KAAK;IAC7BC,YAAY,GAAG,KAAK;IACpBC,aAAa,GAAG,KAAK;IACrBC,gBAAgB;IAChBC,UAAU;IACVC,SAAS;IACTC,WAAW;IACXC,MAAM;IACNC,QAAQ,GAAG,EAAE;IACbC,SAAS;;IAETC;GACH,GAAG5B,KAAK;EAET,MAAM6B,kBAAkB,GAAG,CAACjB,mBAAmB,IAAI,CAAC,CAACK,mBAAmB;EACxE,MAAMa,kBAAkB,GAAG,CAACjB,mBAAmB,KAAK,CAAC,CAACW,WAAW,IAAI,CAAC,EAACI,4BAA4B,aAA5BA,4BAA4B,eAA5BA,4BAA4B,CAAEG,MAAM,EAAC;EAC5G,MAAMC,0BAA0B,GAAG,CAAClB,2BAA2B,IAAIgB,kBAAkB;EAErF,MAAM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;QACpC,IAAI,CAACtC,uBAAuB,CAACoC,OAAO,CAACG,QAAQ,CAACD,KAAK,CAAC,EAAE;UAClDtC,uBAAuB,CAACoC,OAAO,GAAG,CAAC,GAAGpC,uBAAuB,CAACoC,OAAO,EAAEE,KAAK,CAAC,CAACE,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,GAAGC,CAAC,CAAC;;OAE1G;MACDC,4BAA4B,EAAEA;QAC1B3C,uBAAuB,CAACoC,OAAO,GAAG,EAAE;OACvC;;MAEDQ,QAAQ,EAAErI,GAAG;;MAEb0C;;GAEP,CAAC;EAEF,MAAM4F,SAAS,GAAGhB,KAAK,CAACiB,WAAW,EAAE,CAACC,IAAI;EAE1C,IAAI,CAACrD,8BAA8B,EAAE;IACjCzC,wBAAwB,CAACmF,OAAO,GAAGS,SAAS;;EAGhD,MAAME,IAAI,GAAGrD,8BAA8B,GAAGzC,wBAAwB,CAACmF,OAAO,GAAGS,SAAS;;EAG1FG,yBAAyB,CAAQnB,KAAK,EAAEkB,IAAI,EAAEpE,SAAS,CAAC;EACxDsE,4BAA4B,CAACpB,KAAK,EAAE1C,gBAAgB,CAAC;EACrD+D,sBAAsB,CAAQrB,KAAK,EAAE/F,WAAW,CAAC;EACjDqH,uBAAuB,CAAQtB,KAAK,EAAE/F,WAAW,CAAC;EAClDsH,wBAAwB,CAACvB,KAAK,EAAElG,gBAAgB,CAAC;EAEjD0H,iBAAiB,CAACpH,SAAS,GAAAqH,qBAAA,GAAET,SAAS,CAAClE,SAAS,CAAC4E,cAAc,CAAC,cAAAD,qBAAA,uBAAnCA,qBAAA,CAAqCE,QAAQ,CAAC;EAE3E,OAAO;IAAET,IAAI;IAAElB,KAAK;IAAEjF;GAAS;AACnC;;;;"}
|
@@ -1,46 +0,0 @@
|
|
1
|
-
import React__default from 'react';
|
2
|
-
import { createShortcutKeyDownHandler } from '../../../utils/keyboard.js';
|
3
|
-
|
4
|
-
function useTableShortcuts(shortcuts, activeRow) {
|
5
|
-
React__default.useEffect(() => {
|
6
|
-
const shortcutKeys = Object.keys(shortcuts !== null && shortcuts !== void 0 ? shortcuts : {});
|
7
|
-
const globalHandlers = [];
|
8
|
-
// convert the shortcut into the correct format to register it
|
9
|
-
if (shortcuts && shortcutKeys.length) {
|
10
|
-
shortcutKeys.forEach(key => {
|
11
|
-
const handler = shortcuts[key];
|
12
|
-
let keyDownHandler;
|
13
|
-
let keyDownHandlerOptions;
|
14
|
-
if (typeof handler === 'function') {
|
15
|
-
keyDownHandler = handler;
|
16
|
-
keyDownHandlerOptions = {
|
17
|
-
key
|
18
|
-
};
|
19
|
-
} else {
|
20
|
-
const handlerObject = handler;
|
21
|
-
keyDownHandler = handlerObject.handler;
|
22
|
-
keyDownHandlerOptions = {
|
23
|
-
key,
|
24
|
-
meta: handlerObject.meta,
|
25
|
-
shift: handlerObject.shift
|
26
|
-
};
|
27
|
-
}
|
28
|
-
globalHandlers.push(createShortcutKeyDownHandler(keyDownHandlerOptions, event => {
|
29
|
-
event.preventDefault();
|
30
|
-
keyDownHandler(activeRow);
|
31
|
-
}));
|
32
|
-
});
|
33
|
-
}
|
34
|
-
globalHandlers.forEach(handler => {
|
35
|
-
document.addEventListener('keydown', handler);
|
36
|
-
});
|
37
|
-
return () => {
|
38
|
-
globalHandlers.forEach(handler => {
|
39
|
-
document.removeEventListener('keydown', handler);
|
40
|
-
});
|
41
|
-
};
|
42
|
-
}, [shortcuts, activeRow]);
|
43
|
-
}
|
44
|
-
|
45
|
-
export { useTableShortcuts };
|
46
|
-
//# sourceMappingURL=useTableShortcuts.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useTableShortcuts.js","sources":["../../../../../../../../src/components/Table2/hooks/useTableShortcuts.ts"],"sourcesContent":["import React from 'react';\nimport { Table2ShortcutHandlerObject, Table2Shortcuts } from '../types';\nimport { KeyDownHandlerOptions, createShortcutKeyDownHandler } from '../../../utils/keyboard';\n\nexport function useTableShortcuts<TType = any>(shortcuts: Table2Shortcuts<TType> | undefined, activeRow: TType) {\n React.useEffect(() => {\n const shortcutKeys = Object.keys(shortcuts ?? {});\n\n const globalHandlers: Array<(event: KeyboardEvent) => void> = [];\n\n // convert the shortcut into the correct format to register it\n if (shortcuts && shortcutKeys.length) {\n shortcutKeys.forEach(key => {\n const handler = shortcuts[key];\n\n let keyDownHandler;\n let keyDownHandlerOptions: KeyDownHandlerOptions;\n\n if (typeof handler === 'function') {\n keyDownHandler = handler;\n keyDownHandlerOptions = {\n key,\n };\n } else {\n const handlerObject = handler as Table2ShortcutHandlerObject<TType>;\n keyDownHandler = handlerObject.handler;\n keyDownHandlerOptions = {\n key,\n meta: handlerObject.meta,\n shift: handlerObject.shift,\n };\n }\n\n globalHandlers.push(\n createShortcutKeyDownHandler(keyDownHandlerOptions, event => {\n event.preventDefault();\n keyDownHandler(activeRow);\n })\n );\n });\n }\n\n globalHandlers.forEach(handler => {\n document.addEventListener('keydown', handler);\n });\n\n return () => {\n globalHandlers.forEach(handler => {\n document.removeEventListener('keydown', handler);\n });\n };\n }, [shortcuts, activeRow]);\n}\n"],"names":["useTableShortcuts","shortcuts","activeRow","React","useEffect","shortcutKeys","Object","keys","globalHandlers","length","forEach","key","handler","keyDownHandler","keyDownHandlerOptions","handlerObject","meta","shift","push","createShortcutKeyDownHandler","event","preventDefault","document","addEventListener","removeEventListener"],"mappings":";;;SAIgBA,iBAAiBA,CAAcC,SAA6C,EAAEC,SAAgB;EAC1GC,cAAK,CAACC,SAAS,CAAC;IACZ,MAAMC,YAAY,GAAGC,MAAM,CAACC,IAAI,CAACN,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE,CAAC;IAEjD,MAAMO,cAAc,GAA0C,EAAE;;IAGhE,IAAIP,SAAS,IAAII,YAAY,CAACI,MAAM,EAAE;MAClCJ,YAAY,CAACK,OAAO,CAACC,GAAG;QACpB,MAAMC,OAAO,GAAGX,SAAS,CAACU,GAAG,CAAC;QAE9B,IAAIE,cAAc;QAClB,IAAIC,qBAA4C;QAEhD,IAAI,OAAOF,OAAO,KAAK,UAAU,EAAE;UAC/BC,cAAc,GAAGD,OAAO;UACxBE,qBAAqB,GAAG;YACpBH;WACH;SACJ,MAAM;UACH,MAAMI,aAAa,GAAGH,OAA6C;UACnEC,cAAc,GAAGE,aAAa,CAACH,OAAO;UACtCE,qBAAqB,GAAG;YACpBH,GAAG;YACHK,IAAI,EAAED,aAAa,CAACC,IAAI;YACxBC,KAAK,EAAEF,aAAa,CAACE;WACxB;;QAGLT,cAAc,CAACU,IAAI,CACfC,4BAA4B,CAACL,qBAAqB,EAAEM,KAAK;UACrDA,KAAK,CAACC,cAAc,EAAE;UACtBR,cAAc,CAACX,SAAS,CAAC;SAC5B,CAAC,CACL;OACJ,CAAC;;IAGNM,cAAc,CAACE,OAAO,CAACE,OAAO;MAC1BU,QAAQ,CAACC,gBAAgB,CAAC,SAAS,EAAEX,OAAO,CAAC;KAChD,CAAC;IAEF,OAAO;MACHJ,cAAc,CAACE,OAAO,CAACE,OAAO;QAC1BU,QAAQ,CAACE,mBAAmB,CAAC,SAAS,EAAEZ,OAAO,CAAC;OACnD,CAAC;KACL;GACJ,EAAE,CAACX,SAAS,EAAEC,SAAS,CAAC,CAAC;AAC9B;;;;"}
|
@@ -1,48 +0,0 @@
|
|
1
|
-
import React__default from 'react';
|
2
|
-
import { useVirtual } from 'react-virtual';
|
3
|
-
|
4
|
-
const densitySizeEstimates = {
|
5
|
-
compact: 33,
|
6
|
-
normal: 41,
|
7
|
-
comfortable: 49,
|
8
|
-
spacious: 57
|
9
|
-
};
|
10
|
-
const useVirtualiser = ({
|
11
|
-
rows,
|
12
|
-
table
|
13
|
-
}, tableRef) => {
|
14
|
-
var _virtualiser$virtualI, _virtualiser$virtualI2, _virtualiser$virtualI3, _virtualiser$virtualI4;
|
15
|
-
const [expandedRowSizes, setExpandedRowSizes] = React__default.useState({});
|
16
|
-
const firstAvailableExpandedRowHeight = React__default.useMemo(() => {
|
17
|
-
const values = Object.values(expandedRowSizes);
|
18
|
-
return values.length ? values.reduce((a, b) => a + b, 0) / values.length : 0;
|
19
|
-
}, [expandedRowSizes]);
|
20
|
-
const meta = table.options.meta;
|
21
|
-
const estimateSize = React__default.useCallback(index => {
|
22
|
-
var _table$getState$expan;
|
23
|
-
const rowHeight = meta.rowDensity ? densitySizeEstimates[meta.rowDensity] : densitySizeEstimates.normal;
|
24
|
-
if (table.getState().expanded === true || (_table$getState$expan = table.getState().expanded) !== null && _table$getState$expan !== void 0 && _table$getState$expan[index]) {
|
25
|
-
var _ref, _expandedRowSizes$ind;
|
26
|
-
return rowHeight + ((_ref = (_expandedRowSizes$ind = expandedRowSizes[index]) !== null && _expandedRowSizes$ind !== void 0 ? _expandedRowSizes$ind : firstAvailableExpandedRowHeight) !== null && _ref !== void 0 ? _ref : 0);
|
27
|
-
}
|
28
|
-
return rowHeight;
|
29
|
-
}, [meta.rowDensity, expandedRowSizes, table.getState().expanded]);
|
30
|
-
const virtualiser = useVirtual({
|
31
|
-
parentRef: tableRef,
|
32
|
-
size: rows.length,
|
33
|
-
estimateSize
|
34
|
-
});
|
35
|
-
const paddingTop = virtualiser.virtualItems.length > 0 ? ((_virtualiser$virtualI = virtualiser.virtualItems) === null || _virtualiser$virtualI === void 0 ? void 0 : (_virtualiser$virtualI2 = _virtualiser$virtualI[0]) === null || _virtualiser$virtualI2 === void 0 ? void 0 : _virtualiser$virtualI2.start) || 0 : 0;
|
36
|
-
const paddingBottom = virtualiser.virtualItems.length > 0 ? virtualiser.totalSize - (((_virtualiser$virtualI3 = virtualiser.virtualItems) === null || _virtualiser$virtualI3 === void 0 ? void 0 : (_virtualiser$virtualI4 = _virtualiser$virtualI3[virtualiser.virtualItems.length - 1]) === null || _virtualiser$virtualI4 === void 0 ? void 0 : _virtualiser$virtualI4.end) || 0) : 0;
|
37
|
-
return {
|
38
|
-
virtualiser,
|
39
|
-
virtualiserOffsets: {
|
40
|
-
top: paddingTop,
|
41
|
-
bottom: paddingBottom
|
42
|
-
},
|
43
|
-
setExpandedRowSizes
|
44
|
-
};
|
45
|
-
};
|
46
|
-
|
47
|
-
export { useVirtualiser };
|
48
|
-
//# sourceMappingURL=useVirtualiser.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useVirtualiser.js","sources":["../../../../../../../../src/components/Table2/hooks/useVirtualiser.ts"],"sourcesContent":["import React from 'react';\nimport { OnChangeFn, TableMeta } from '@tanstack/react-table';\nimport { useVirtual, VirtualItem } from 'react-virtual';\n\ntype ExpandedRowSizeState = Record<string, number>;\ntype useVirtualiser = {\n virtualiser: {\n virtualItems: VirtualItem[];\n totalSize: number;\n scrollToOffset: (index: number, options?: any) => void;\n scrollToIndex: (index: number, options?: any) => void;\n measure: () => void;\n };\n virtualiserOffsets: {\n top: number;\n bottom: number;\n };\n setExpandedRowSizes: OnChangeFn<ExpandedRowSizeState>;\n};\n\nconst densitySizeEstimates = {\n compact: 33,\n normal: 41,\n comfortable: 49,\n spacious: 57,\n};\n\nexport const useVirtualiser = ({ rows, table }, tableRef: React.RefObject<HTMLElement>): useVirtualiser => {\n const [expandedRowSizes, setExpandedRowSizes] = React.useState({});\n const firstAvailableExpandedRowHeight = React.useMemo(() => {\n const values: number[] = Object.values(expandedRowSizes);\n return values.length ? values.reduce((a, b) => a + b, 0) / values.length : 0;\n }, [expandedRowSizes]);\n const meta = table.options.meta as TableMeta<any>;\n\n const estimateSize = React.useCallback(\n index => {\n const rowHeight = meta.rowDensity ? densitySizeEstimates[meta.rowDensity] : densitySizeEstimates.normal;\n\n if (table.getState().expanded === true || table.getState().expanded?.[index]) {\n return rowHeight + (expandedRowSizes[index] ?? firstAvailableExpandedRowHeight ?? 0);\n }\n\n return rowHeight;\n },\n\n [meta.rowDensity, expandedRowSizes, table.getState().expanded]\n );\n\n const virtualiser = useVirtual({\n parentRef: tableRef,\n size: rows.length,\n estimateSize,\n });\n\n const paddingTop = virtualiser.virtualItems.length > 0 ? virtualiser.virtualItems?.[0]?.start || 0 : 0;\n const paddingBottom =\n virtualiser.virtualItems.length > 0\n ? virtualiser.totalSize - (virtualiser.virtualItems?.[virtualiser.virtualItems.length - 1]?.end || 0)\n : 0;\n\n return { virtualiser, virtualiserOffsets: { top: paddingTop, bottom: paddingBottom }, setExpandedRowSizes };\n};\n"],"names":["densitySizeEstimates","compact","normal","comfortable","spacious","useVirtualiser","rows","table","tableRef","expandedRowSizes","setExpandedRowSizes","React","useState","firstAvailableExpandedRowHeight","useMemo","values","Object","length","reduce","a","b","meta","options","estimateSize","useCallback","index","rowHeight","rowDensity","getState","expanded","_table$getState$expan","_ref","_expandedRowSizes$ind","virtualiser","useVirtual","parentRef","size","paddingTop","virtualItems","_virtualiser$virtualI","_virtualiser$virtualI2","start","paddingBottom","totalSize","_virtualiser$virtualI3","_virtualiser$virtualI4","end","virtualiserOffsets","top","bottom"],"mappings":";;;AAoBA,MAAMA,oBAAoB,GAAG;EACzBC,OAAO,EAAE,EAAE;EACXC,MAAM,EAAE,EAAE;EACVC,WAAW,EAAE,EAAE;EACfC,QAAQ,EAAE;CACb;MAEYC,cAAc,GAAGA,CAAC;EAAEC,IAAI;EAAEC;CAAO,EAAEC,QAAsC;;EAClF,MAAM,CAACC,gBAAgB,EAAEC,mBAAmB,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,EAAE,CAAC;EAClE,MAAMC,+BAA+B,GAAGF,cAAK,CAACG,OAAO,CAAC;IAClD,MAAMC,MAAM,GAAaC,MAAM,CAACD,MAAM,CAACN,gBAAgB,CAAC;IACxD,OAAOM,MAAM,CAACE,MAAM,GAAGF,MAAM,CAACG,MAAM,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,GAAGC,CAAC,EAAE,CAAC,CAAC,GAAGL,MAAM,CAACE,MAAM,GAAG,CAAC;GAC/E,EAAE,CAACR,gBAAgB,CAAC,CAAC;EACtB,MAAMY,IAAI,GAAGd,KAAK,CAACe,OAAO,CAACD,IAAsB;EAEjD,MAAME,YA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sBAAA,GAAxBD,sBAAA,CAA2BX,WAAW,CAACK,YAAY,CAACrB,MAAM,GAAG,CAAC,CAAC,cAAA4B,sBAAA,uBAA/DA,sBAAA,CAAiEC,GAAG,KAAI,CAAC,CAAC,GACnG,CAAC;EAEX,OAAO;IAAEb,WAAW;IAAEc,kBAAkB,EAAE;MAAEC,GAAG,EAAEX,UAAU;MAAEY,MAAM,EAAEP;KAAe;IAAEhC;GAAqB;AAC/G;;;;"}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
var Table2FilterComparator;
|
2
|
-
(function (Table2FilterComparator) {
|
3
|
-
Table2FilterComparator[Table2FilterComparator["Contains"] = 0] = "Contains";
|
4
|
-
Table2FilterComparator[Table2FilterComparator["DoesNotContain"] = 1] = "DoesNotContain";
|
5
|
-
Table2FilterComparator[Table2FilterComparator["IsEqualTo"] = 2] = "IsEqualTo";
|
6
|
-
Table2FilterComparator[Table2FilterComparator["IsNotEqualTo"] = 3] = "IsNotEqualTo";
|
7
|
-
Table2FilterComparator[Table2FilterComparator["IsGreaterThan"] = 4] = "IsGreaterThan";
|
8
|
-
Table2FilterComparator[Table2FilterComparator["IsLessThan"] = 5] = "IsLessThan";
|
9
|
-
Table2FilterComparator[Table2FilterComparator["IsBetween"] = 6] = "IsBetween";
|
10
|
-
Table2FilterComparator[Table2FilterComparator["IsOneOf"] = 7] = "IsOneOf";
|
11
|
-
Table2FilterComparator[Table2FilterComparator["IsNoneOf"] = 8] = "IsNoneOf";
|
12
|
-
Table2FilterComparator[Table2FilterComparator["IsAllOf"] = 9] = "IsAllOf";
|
13
|
-
Table2FilterComparator[Table2FilterComparator["IsEmpty"] = 10] = "IsEmpty";
|
14
|
-
Table2FilterComparator[Table2FilterComparator["IsNotEmpty"] = 11] = "IsNotEmpty";
|
15
|
-
})(Table2FilterComparator || (Table2FilterComparator = {}));
|
16
|
-
|
17
|
-
export { Table2FilterComparator };
|
18
|
-
//# sourceMappingURL=types.js.map
|