@economic/taco 2.54.0 → 2.55.0-settings.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Checkbox/Checkbox.d.ts +7 -2
- package/dist/components/List/List.d.ts +2 -2
- package/dist/components/List/components/Toggle.d.ts +2 -2
- package/dist/components/ModeSwitch/ModeSwitch.d.ts +6 -3
- package/dist/components/Provider/Provider.d.ts +7 -6
- package/dist/components/Provider/TacoContext.d.ts +7 -0
- package/dist/components/Provider/useTacoSettings.d.ts +8 -0
- package/dist/components/Report/Report.d.ts +1 -1
- package/dist/components/Switch/Switch.d.ts +6 -4
- package/dist/esm/index.css +76 -5
- package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js +41 -63
- package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/esm/packages/taco/src/components/List/components/Toggle.js +14 -4
- package/dist/esm/packages/taco/src/components/List/components/Toggle.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js +6 -3
- package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js.map +1 -1
- package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js +34 -12
- package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Provider/Provider.js +14 -7
- package/dist/esm/packages/taco/src/components/Provider/Provider.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Provider/TacoContext.js +6 -0
- package/dist/esm/packages/taco/src/components/Provider/TacoContext.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Provider/useTacoSettings.js +39 -0
- package/dist/esm/packages/taco/src/components/Provider/useTacoSettings.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/Report.js +8 -0
- package/dist/esm/packages/taco/src/components/Report/Report.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Switch/Switch.js +37 -35
- package/dist/esm/packages/taco/src/components/Switch/Switch.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +8 -0
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js.map +1 -1
- package/dist/esm/packages/taco/src/hooks/useTaco.js +9 -0
- package/dist/esm/packages/taco/src/hooks/useTaco.js.map +1 -0
- package/dist/esm/packages/taco/src/index.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/Toolbar.js +6 -4
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +9 -5
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTablePrinting.js +18 -21
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTablePrinting.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActive.js +2 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActive.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSettingsListener.js +57 -9
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSettingsListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +7 -5
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableSettingsPreloader.js +44 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableSettingsPreloader.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/settings.js +3 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/settings.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +5 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
- package/dist/hooks/useTaco.d.ts +1 -0
- package/dist/index.css +76 -5
- package/dist/primitives/Table/Core/features/useTableRenderer.d.ts +2 -2
- package/dist/primitives/Table/Core/useTable.d.ts +4 -4
- package/dist/primitives/Table/types.d.ts +16 -6
- package/dist/primitives/Table/useTableManager/features/useTablePrinting.d.ts +2 -8
- package/dist/primitives/Table/useTableManager/features/useTableRowActive.d.ts +2 -2
- package/dist/primitives/Table/useTableManager/listeners/useTableSettingsListener.d.ts +2 -2
- package/dist/primitives/Table/useTableManager/useTableSettingsPreloader.d.ts +3 -0
- package/dist/primitives/Table/useTableManager/util/settings.d.ts +2 -0
- package/dist/taco.cjs.development.js +328 -272
- 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 +3 -3
- package/dist/esm/packages/taco/src/hooks/useLocalStorage.js +0 -44
- package/dist/esm/packages/taco/src/hooks/useLocalStorage.js.map +0 -1
- package/dist/esm/packages/taco/src/hooks/useTacoSettings.js +0 -9
- package/dist/esm/packages/taco/src/hooks/useTacoSettings.js.map +0 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSettings.js +0 -69
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSettings.js.map +0 -1
- package/dist/hooks/useLocalStorage.d.ts +0 -2
- package/dist/hooks/useTacoSettings.d.ts +0 -1
- package/dist/primitives/Table/useTableManager/features/useTableSettings.d.ts +0 -3
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableManager.js","sources":["../../../../../../../../src/primitives/Table/useTableManager/useTableManager.ts"],"sourcesContent":["import { useReactTable, TableMeta as ReactTableMeta, RowData, getCoreRowModel } from '@tanstack/react-table';\nimport {\n TableColumnAlignment,\n TableColumnClassNameHandler,\n TableColumnDataType,\n TableColumnMenu,\n TableColumnRenderer,\n TableColumnRendererControl,\n TableEventHandler,\n TableFilterComparator,\n TableProps,\n} from '../types';\nimport { useReactTableInitialState, configureReactTableOptions, mapTableChildrenToColumns } from './util/setup';\nimport { getTableFeaturePreset } from './util/presets';\nimport { useTableColumnFreezing } from './features/useTableColumnFreezing';\nimport { useTableColumnOrdering } from './features/useTableColumnOrdering';\nimport { useTableFooter } from './features/useTableFooter';\nimport { useTableFontSize } from './features/useTableFontSize';\nimport { useTablePrinting } from './features/useTablePrinting';\nimport { useTableRowActions } from './features/useTableRowActions';\nimport { useTableRowActive } from './features/useTableRowActive';\nimport { useTableRowClick } from './features/useTableRowClick';\nimport { useTableRowExpansion } from './features/useTableRowExpansion';\nimport { useTableRowGoto } from './features/useTableRowGoto';\nimport { useTableRowGroups } from './features/useTableRowGroups';\nimport { useTableRowHeight } from './features/useTableRowHeight';\nimport { useTableRowSelection } from './features/useTableRowSelection';\nimport { useTableSearch } from './features/useTableSearch';\nimport { useTableServerLoading } from './features/useTableServerLoading';\nimport { useTableSettings } from './features/useTableSettings';\nimport { useTableDataListener } from './listeners/useTableDataListener';\nimport { useTableFilterListener } from './listeners/useTableFilterListener';\nimport { useTableFontSizeListener } from './listeners/useTableFontSizeListener';\nimport { useTableRowHeightListener } from './listeners/useTableRowHeightListener';\nimport { useTableRowSelectionListener } from './listeners/useTableRowSelectionListener';\nimport { useTableSearchListener } from './listeners/useTableSearchListener';\nimport { useTableSettingsListener } from './listeners/useTableSettingsListener';\nimport { useTableShortcutsListener } from './listeners/useTableShortcutsListener';\nimport { useTableSortingListener } from './listeners/useTableSortingListener';\nimport { useTableServerLoadingListener } from './listeners/useTableServerLoadingListener';\nimport { useTableManagerInternalColumns } from './types';\nimport { useTableRowDrag } from './features/useTableRowDrag';\nimport { useTableRowDrop } from './features/useTableRowDrop';\nimport { useLocalization } from '../../../components/Provider/Localization';\n\n/*\n EDITING THIS FILE? READ ME FIRST!\n\n This is a shared, common hook for multiple tables. It's feature set is specifically chosen to support features\n common across those tables. If you are adding a new feature or changing an existing one, before writing any code\n in this file ask yourself the question - is this specific to a given table, or is it common to all of them.\n If you are unsure, ask your team first.\n*/\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useTableColumnFreezing>;\n columnOrdering: ReturnType<typeof useTableColumnOrdering>;\n fontSize: ReturnType<typeof useTableFontSize>;\n footer: ReturnType<typeof useTableFooter>;\n length: number;\n onEvent: TableEventHandler;\n printing: ReturnType<typeof useTablePrinting>;\n rowActions: ReturnType<typeof useTableRowActions>;\n rowActive: ReturnType<typeof useTableRowActive>;\n rowClick: ReturnType<typeof useTableRowClick>;\n rowDrag: ReturnType<typeof useTableRowDrag>;\n rowDrop: ReturnType<typeof useTableRowDrop>;\n rowExpansion: ReturnType<typeof useTableRowExpansion>;\n rowGoto: ReturnType<typeof useTableRowGoto>;\n rowGroups: ReturnType<typeof useTableRowGroups>;\n rowHeight: ReturnType<typeof useTableRowHeight>;\n rowIdentityAccessor: keyof TData;\n rowSelection: ReturnType<typeof useTableRowSelection>;\n search: ReturnType<typeof useTableSearch>;\n server: ReturnType<typeof useTableServerLoading>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TData>;\n control?: TableColumnRendererControl<TData>;\n dataType?: TableColumnDataType;\n defaultWidth?: number;\n enableEditing?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableSearch?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n header: string;\n headerClassName?: string;\n menu?: TableColumnMenu;\n renderer?: TableColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n}\n\n// Placed this array outside the hook to avoid creating a new array reference on each hook re-render\nconst DEFAULT_EMPTY_ARRAY = [];\n\nexport function useTableManager<TType = unknown, TMeta = {}>(\n props: TableProps<TType>,\n meta?: Partial<ReactTableMeta<TType>> & TMeta,\n internalColumns?: useTableManagerInternalColumns<TType>\n) {\n const localization = useLocalization();\n // CSS.escape would be best here, but it doesn't seem to work very well\n const safeId = props.id.replace('.', '_');\n // configure table options, merging props with presets\n const options = getTableFeaturePreset(props);\n\n // load any persisted table settings and merge them with any defaults\n const [settings, setSettings] = useTableSettings(\n options.enableSaveSettings,\n safeId,\n props.defaultSettings,\n props.onChangeSettings\n );\n\n // ensure data is always valid\n const data = props.data ?? DEFAULT_EMPTY_ARRAY;\n const length = props.length ?? data.length;\n\n // configure common custom features\n const columnFreezing = useTableColumnFreezing(options.enableColumnFreezing);\n const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);\n const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);\n const footer = useTableFooter(options.enableFooter);\n const printing = useTablePrinting(options.enablePrinting, safeId);\n const rowActive = useTableRowActive(options.enableRowActive, props.defaultRowActiveIndex);\n const rowActions = useTableRowActions<TType>(options.enableRowActions, props.rowActions, props.rowActionsLength);\n const rowClick = useTableRowClick<TType>(options.enableRowClick, props.onRowClick);\n const rowDrag = useTableRowDrag<TType>(options.enableRowDrag && !meta?.editing?.isEditing, props.onRowDrag);\n const rowDrop = useTableRowDrop<TType>(options.enableRowDrop, props.onRowDrop);\n const rowExpansion = useTableRowExpansion<TType>(\n options.enableRowExpansion,\n options.enableRowExpansionAll,\n props.rowExpansionRenderer\n );\n const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowGroups = useTableRowGroups(props.rowActionsForGroup);\n const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);\n const rowSelection = useTableRowSelection(!!options.enableRowSelection);\n const search = useTableSearch(options.enableSearch, props.onChangeSearch, settings.excludeUnmatchedRecordsInSearch);\n const server = useTableServerLoading(\n length,\n data,\n props.loadPage,\n props.loadAll,\n props.pages,\n props.pageSize,\n props._experimentalDataLoader2\n );\n\n // TODO: memoise\n // convert jsx column components into valid table columns\n const { columns, ...defaultState } = mapTableChildrenToColumns<TType>(\n props,\n settings,\n options,\n internalColumns,\n localization\n );\n\n // configure initial table state\n const initialState = useReactTableInitialState<TType>(props, columns, settings, defaultState);\n\n // create a react-table instance\n const instance = useReactTable<TType>({\n data,\n columns,\n // configure initial table state\n initialState,\n getCoreRowModel: getCoreRowModel<TType>(),\n // configure react-table built-in features\n ...configureReactTableOptions<TType>(options, props, localization),\n // settings that can be toggled by the user, and therefore require our own state\n enableGlobalFilter: search.enableGlobalFilter,\n // custom context\n meta: {\n // spread features from specific implementations\n ...meta,\n columnFreezing,\n columnOrdering,\n fontSize,\n footer,\n length,\n onEvent: props.onEvent,\n printing,\n rowActions: rowActions as any, // no other way around ReturnType<typeof X> not supporting generics\n rowActive,\n rowClick: rowClick as any, // no other way around ReturnType<typeof X> not supporting generics\n rowDrag,\n rowDrop: rowDrop as any, // no other way around ReturnType<typeof X> not supporting generics\n rowExpansion: rowExpansion as any, // no other way around ReturnType<typeof X> not supporting generics\n rowIdentityAccessor: props.rowIdentityAccessor,\n rowGoto,\n rowGroups: rowGroups as any, // no other way around ReturnType<typeof X> not supporting generics\n rowHeight,\n rowSelection,\n search,\n server,\n } as ReactTableMeta<TType> & TMeta,\n });\n\n // state listeners - we have these so that we don't have to control state outside the table\n useTableDataListener(instance, length);\n useTableFilterListener(instance, props.onChangeFilter);\n useTableFontSizeListener(instance);\n useTableRowHeightListener(instance);\n useTableRowSelectionListener(instance, props.onRowSelect);\n useTableSearchListener(instance);\n useTableServerLoadingListener(instance, server.loadPage);\n useTableSettingsListener(instance, setSettings);\n useTableShortcutsListener(instance, props.shortcuts);\n useTableSortingListener(instance, props.onChangeSort);\n\n return {\n id: safeId,\n instance,\n meta: (instance.options.meta ?? {}) as ReactTableMeta<TType> & TMeta,\n state: instance.getState(),\n };\n}\n"],"names":["DEFAULT_EMPTY_ARRAY","useTableManager","props","meta","internalColumns","localization","useLocalization","safeId","id","replace","options","getTableFeaturePreset","settings","setSettings","useTableSettings","enableSaveSettings","defaultSettings","onChangeSettings","data","_props$data","length","_props$length","columnFreezing","useTableColumnFreezing","enableColumnFreezing","columnOrdering","useTableColumnOrdering","enableColumnOrdering","fontSize","useTableFontSize","enableFontSize","footer","useTableFooter","enableFooter","printing","useTablePrinting","enablePrinting","rowActive","useTableRowActive","enableRowActive","defaultRowActiveIndex","rowActions","useTableRowActions","enableRowActions","rowActionsLength","rowClick","useTableRowClick","enableRowClick","onRowClick","rowDrag","useTableRowDrag","enableRowDrag","_meta$editing","editing","isEditing","onRowDrag","rowDrop","useTableRowDrop","enableRowDrop","onRowDrop","rowExpansion","useTableRowExpansion","enableRowExpansion","enableRowExpansionAll","rowExpansionRenderer","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowGroups","useTableRowGroups","rowActionsForGroup","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","search","useTableSearch","enableSearch","onChangeSearch","excludeUnmatchedRecordsInSearch","server","useTableServerLoading","loadPage","loadAll","pages","pageSize","_experimentalDataLoader2","columns","defaultState","mapTableChildrenToColumns","initialState","useReactTableInitialState","instance","useReactTable","getCoreRowModel","configureReactTableOptions","enableGlobalFilter","onEvent","rowIdentityAccessor","useTableDataListener","useTableFilterListener","onChangeFilter","useTableFontSizeListener","useTableRowHeightListener","useTableRowSelectionListener","onRowSelect","useTableSearchListener","useTableServerLoadingListener","useTableSettingsListener","useTableShortcutsListener","shortcuts","useTableSortingListener","onChangeSort","_instance$options$met","state","getState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkGA;AACA,MAAMA,mBAAmB,GAAG,EAAE;SAEdC,eAAeA,CAC3BC,KAAwB,EACxBC,IAA6C,EAC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AQ,EAAElF,WAAW,CAAC;EAC/CmG,yBAAyB,CAACjB,QAAQ,EAAE7F,KAAK,CAAC+G,SAAS,CAAC;EACpDC,uBAAuB,CAACnB,QAAQ,EAAE7F,KAAK,CAACiH,YAAY,CAAC;EAErD,OAAO;IACH3G,EAAE,EAAED,MAAM;IACVwF,QAAQ;IACR5F,IAAI,GAAAiH,qBAAA,GAAGrB,QAAQ,CAACrF,OAAO,CAACP,IAAI,cAAAiH,qBAAA,cAAAA,qBAAA,GAAI,EAAoC;IACpEC,KAAK,EAAEtB,QAAQ,CAACuB,QAAQ;GAC3B;AACL;;;;"}
|
1
|
+
{"version":3,"file":"useTableManager.js","sources":["../../../../../../../../src/primitives/Table/useTableManager/useTableManager.ts"],"sourcesContent":["import { useReactTable, TableMeta as ReactTableMeta, RowData, getCoreRowModel } from '@tanstack/react-table';\nimport {\n TableColumnAlignment,\n TableColumnClassNameHandler,\n TableColumnDataType,\n TableColumnMenu,\n TableColumnRenderer,\n TableColumnRendererControl,\n TableEventHandler,\n TableFilterComparator,\n TableProps,\n TableSettings,\n} from '../types';\nimport { useReactTableInitialState, configureReactTableOptions, mapTableChildrenToColumns } from './util/setup';\nimport { getTableFeaturePreset } from './util/presets';\nimport { useTableColumnFreezing } from './features/useTableColumnFreezing';\nimport { useTableColumnOrdering } from './features/useTableColumnOrdering';\nimport { useTableFooter } from './features/useTableFooter';\nimport { useTableFontSize } from './features/useTableFontSize';\nimport { useTablePrinting } from './features/useTablePrinting';\nimport { useTableRowActions } from './features/useTableRowActions';\nimport { useTableRowActive } from './features/useTableRowActive';\nimport { useTableRowClick } from './features/useTableRowClick';\nimport { useTableRowExpansion } from './features/useTableRowExpansion';\nimport { useTableRowGoto } from './features/useTableRowGoto';\nimport { useTableRowGroups } from './features/useTableRowGroups';\nimport { useTableRowHeight } from './features/useTableRowHeight';\nimport { useTableRowSelection } from './features/useTableRowSelection';\nimport { useTableSearch } from './features/useTableSearch';\nimport { useTableServerLoading } from './features/useTableServerLoading';\nimport { useTableDataListener } from './listeners/useTableDataListener';\nimport { useTableFilterListener } from './listeners/useTableFilterListener';\nimport { useTableFontSizeListener } from './listeners/useTableFontSizeListener';\nimport { useTableRowHeightListener } from './listeners/useTableRowHeightListener';\nimport { useTableRowSelectionListener } from './listeners/useTableRowSelectionListener';\nimport { useTableSearchListener } from './listeners/useTableSearchListener';\nimport { useTableSettingsListener } from './listeners/useTableSettingsListener';\nimport { useTableShortcutsListener } from './listeners/useTableShortcutsListener';\nimport { useTableSortingListener } from './listeners/useTableSortingListener';\nimport { useTableServerLoadingListener } from './listeners/useTableServerLoadingListener';\nimport { useTableManagerInternalColumns } from './types';\nimport { useTableRowDrag } from './features/useTableRowDrag';\nimport { useTableRowDrop } from './features/useTableRowDrop';\nimport { useLocalization } from '../../../components/Provider/Localization';\nimport { useTaco } from '../../../hooks/useTaco';\nimport { getSettingsId } from './util/settings';\n\n/*\n EDITING THIS FILE? READ ME FIRST!\n\n This is a shared, common hook for multiple tables. It's feature set is specifically chosen to support features\n common across those tables. If you are adding a new feature or changing an existing one, before writing any code\n in this file ask yourself the question - is this specific to a given table, or is it common to all of them.\n If you are unsure, ask your team first.\n*/\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useTableColumnFreezing>;\n columnOrdering: ReturnType<typeof useTableColumnOrdering>;\n fontSize: ReturnType<typeof useTableFontSize>;\n footer: ReturnType<typeof useTableFooter>;\n length: number;\n onEvent: TableEventHandler;\n printing: ReturnType<typeof useTablePrinting>;\n rowActions: ReturnType<typeof useTableRowActions>;\n rowActive: ReturnType<typeof useTableRowActive>;\n rowClick: ReturnType<typeof useTableRowClick>;\n rowDrag: ReturnType<typeof useTableRowDrag>;\n rowDrop: ReturnType<typeof useTableRowDrop>;\n rowExpansion: ReturnType<typeof useTableRowExpansion>;\n rowGoto: ReturnType<typeof useTableRowGoto>;\n rowGroups: ReturnType<typeof useTableRowGroups>;\n rowHeight: ReturnType<typeof useTableRowHeight>;\n rowIdentityAccessor: keyof TData;\n rowSelection: ReturnType<typeof useTableRowSelection>;\n search: ReturnType<typeof useTableSearch>;\n server: ReturnType<typeof useTableServerLoading>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TData>;\n control?: TableColumnRendererControl<TData>;\n dataType?: TableColumnDataType;\n defaultWidth?: number;\n enableEditing?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableSearch?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n header: string;\n headerClassName?: string;\n menu?: TableColumnMenu;\n renderer?: TableColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n}\n\n// Placed this array outside the hook to avoid creating a new array reference on each hook re-render\nconst DEFAULT_EMPTY_ARRAY = [];\n\nexport function useTableManager<TType = unknown, TMeta = {}>(\n props: TableProps<TType>,\n meta?: Partial<ReactTableMeta<TType>> & TMeta,\n internalColumns?: useTableManagerInternalColumns<TType>\n) {\n const taco = useTaco();\n const localization = useLocalization();\n // CSS.escape would be best here, but it doesn't seem to work very well\n const safeId = props.id.replace('.', '_');\n // configure table options, merging props with presets\n const options = getTableFeaturePreset(props);\n\n // load any persisted table settings and merge them with any defaults\n const settings = taco.settings.getSetting<TableSettings>(getSettingsId(safeId)) ?? props.defaultSettings ?? {};\n\n // ensure data is always valid\n const data = props.data ?? DEFAULT_EMPTY_ARRAY;\n const length = props.length ?? data.length;\n\n // configure common custom features\n const columnFreezing = useTableColumnFreezing(options.enableColumnFreezing);\n const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);\n const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);\n const footer = useTableFooter(options.enableFooter);\n const printing = useTablePrinting(options.enablePrinting, safeId);\n const rowActive = useTableRowActive(options.enableRowActive, settings, props.defaultRowActiveIndex);\n const rowActions = useTableRowActions<TType>(options.enableRowActions, props.rowActions, props.rowActionsLength);\n const rowClick = useTableRowClick<TType>(options.enableRowClick, props.onRowClick);\n const rowDrag = useTableRowDrag<TType>(options.enableRowDrag && !meta?.editing?.isEditing, props.onRowDrag);\n const rowDrop = useTableRowDrop<TType>(options.enableRowDrop, props.onRowDrop);\n const rowExpansion = useTableRowExpansion<TType>(\n options.enableRowExpansion,\n options.enableRowExpansionAll,\n props.rowExpansionRenderer\n );\n const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowGroups = useTableRowGroups(props.rowActionsForGroup);\n const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);\n const rowSelection = useTableRowSelection(!!options.enableRowSelection);\n const search = useTableSearch(options.enableSearch, props.onChangeSearch, settings.excludeUnmatchedRecordsInSearch);\n const server = useTableServerLoading(\n length,\n data,\n props.loadPage,\n props.loadAll,\n props.pages,\n props.pageSize,\n props._experimentalDataLoader2\n );\n\n // TODO: memoise\n // convert jsx column components into valid table columns\n const { columns, ...defaultState } = mapTableChildrenToColumns<TType>(\n props,\n settings,\n options,\n internalColumns,\n localization\n );\n\n // configure initial table state\n const initialState = useReactTableInitialState<TType>(props, columns, settings, defaultState);\n\n // create a react-table instance\n const instance = useReactTable<TType>({\n data,\n columns,\n // configure initial table state\n initialState,\n getCoreRowModel: getCoreRowModel<TType>(),\n // configure react-table built-in features\n ...configureReactTableOptions<TType>(options, props, localization),\n // settings that can be toggled by the user, and therefore require our own state\n enableGlobalFilter: search.enableGlobalFilter,\n // custom context\n meta: {\n // spread features from specific implementations\n ...meta,\n columnFreezing,\n columnOrdering,\n fontSize,\n footer,\n length,\n onEvent: props.onEvent,\n printing,\n rowActions: rowActions as any, // no other way around ReturnType<typeof X> not supporting generics\n rowActive,\n rowClick: rowClick as any, // no other way around ReturnType<typeof X> not supporting generics\n rowDrag,\n rowDrop: rowDrop as any, // no other way around ReturnType<typeof X> not supporting generics\n rowExpansion: rowExpansion as any, // no other way around ReturnType<typeof X> not supporting generics\n rowIdentityAccessor: props.rowIdentityAccessor,\n rowGoto,\n rowGroups: rowGroups as any, // no other way around ReturnType<typeof X> not supporting generics\n rowHeight,\n rowSelection,\n search,\n server,\n } as ReactTableMeta<TType> & TMeta,\n });\n\n // state listeners - we have these so that we don't have to control state outside the table\n useTableDataListener(instance, length);\n useTableFilterListener(instance, props.onChangeFilter);\n useTableFontSizeListener(instance);\n useTableRowHeightListener(instance);\n useTableRowSelectionListener(instance, props.onRowSelect);\n useTableSearchListener(instance);\n useTableServerLoadingListener(instance, server.loadPage);\n useTableSettingsListener(instance, safeId, props._DEPRECATED_DO_NOT_USE_onChangeSettings, options.enableSaveSettings);\n useTableShortcutsListener(instance, props.shortcuts);\n useTableSortingListener(instance, props.onChangeSort);\n\n return {\n id: safeId,\n instance,\n meta: (instance.options.meta ?? {}) as ReactTableMeta<TType> & TMeta,\n state: instance.getState(),\n };\n}\n"],"names":["DEFAULT_EMPTY_ARRAY","useTableManager","props","meta","internalColumns","taco","useTaco","localization","useLocalization","safeId","id","replace","options","getTableFeaturePreset","settings","_ref","_taco$settings$getSet","getSetting","getSettingsId","defaultSettings","data","_props$data","length","_props$length","columnFreezing","useTableColumnFreezing","enableColumnFreezing","columnOrdering","useTableColumnOrdering","enableColumnOrdering","fontSize","useTableFontSize","enableFontSize","footer","useTableFooter","enableFooter","printing","useTablePrinting","enablePrinting","rowActive","useTableRowActive","enableRowActive","defaultRowActiveIndex","rowActions","useTableRowActions","enableRowActions","rowActionsLength","rowClick","useTableRowClick","enableRowClick","onRowClick","rowDrag","useTableRowDrag","enableRowDrag","_meta$editing","editing","isEditing","onRowDrag","rowDrop","useTableRowDrop","enableRowDrop","onRowDrop","rowExpansion","useTableRowExpansion","enableRowExpansion","enableRowExpansionAll","rowExpansionRenderer","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowGroups","useTableRowGroups","rowActionsForGroup","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","search","useTableSearch","enableSearch","onChangeSearch","excludeUnmatchedRecordsInSearch","server","useTableServerLoading","loadPage","loadAll","pages","pageSize","_experimentalDataLoader2","columns","defaultState","mapTableChildrenToColumns","initialState","useReactTableInitialState","instance","useReactTable","getCoreRowModel","configureReactTableOptions","enableGlobalFilter","onEvent","rowIdentityAccessor","useTableDataListener","useTableFilterListener","onChangeFilter","useTableFontSizeListener","useTableRowHeightListener","useTableRowSelectionListener","onRowSelect","useTableSearchListener","useTableServerLoadingListener","useTableSettingsListener","_DEPRECATED_DO_NOT_USE_onChangeSettings","enableSaveSettings","useTableShortcutsListener","shortcuts","useTableSortingListener","onChangeSort","_instance$options$met","state","getState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGA;AACA,MAAMA,mBAAmB,GAAG,EAAE;SAEdC,eAAeA,CAC3BC,KAAwB,EACxBC,IAA6C,EAC7CC,eAAuD;;EAEvD,MAAMC,IAAI,GAAGC,OAAO,EAAE;EACtB,MAAMC,YAAY,GAAGC,eAAe,EAAE;;EAEtC,MAAMC,MAAM,GAAGP,KAAK,CAACQ,EAAE,CAACC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;;EAEzC,MAAMC,OAAO,GAAGC,qBAAqB,CAACX,KAAK,CAAC;;EAG5C,MAAMY,QAAQ,IAAAC,IAAA,IAAAC,qBAAA,GAAGX,IAAI,CAACS,QAAQ,CAACG,UAAU,CAAgBC,aAAa,CAACT,MAAM,CAAC,CAAC,cAAAO,qBAAA,cAAAA,qBAAA,GAAId,KAAK,CAACiB,eAAe,cAAAJ,IAAA,cAAAA,IAAA,GAAI,EAAE;;EAG9G,MAAMK,IAAI,IAAAC,WAAA,GAAGnB,KAAK,CAACkB,IAAI,cAAAC,WAAA,cAAAA,WAAA,GAAIrB,mBAAmB;EAC9C,MAAMsB,MAAM,IAAAC,aAAA,GAAGrB,KAAK,CAACoB,MAAM,cAAAC,aAAA,cAAAA,aAAA,GAAIH,IAAI,CAACE,MAAM;;EAG1C,MAAME,cAAc,GAAGC,sBAAsB,CAACb,OAAO,CAAC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AS;MACTQ,QAAQ,EAAEA,QAAe;MACzBI,OAAO;MACPO,OAAO,EAAEA,OAAc;MACvBI,YAAY,EAAEA,YAAmB;MACjCyC,mBAAmB,EAAErG,KAAK,CAACqG,mBAAmB;MAC9CpC,OAAO;MACPI,SAAS,EAAEA,SAAgB;MAC3BG,SAAS;MACTG,YAAY;MACZG,MAAM;MACNK;;GAEP,CAAC;;EAGFmB,oBAAoB,CAACP,QAAQ,EAAE3E,MAAM,CAAC;EACtCmF,sBAAsB,CAACR,QAAQ,EAAE/F,KAAK,CAACwG,cAAc,CAAC;EACtDC,wBAAwB,CAACV,QAAQ,CAAC;EAClCW,yBAAyB,CAACX,QAAQ,CAAC;EACnCY,4BAA4B,CAACZ,QAAQ,EAAE/F,KAAK,CAAC4G,WAAW,CAAC;EACzDC,sBAAsB,CAACd,QAAQ,CAAC;EAChCe,6BAA6B,CAACf,QAAQ,EAAEZ,MAAM,CAACE,QAAQ,CAAC;EACxD0B,wBAAwB,CAAChB,QAAQ,EAAExF,MAAM,EAAEP,KAAK,CAACgH,uCAAuC,EAAEtG,OAAO,CAACuG,kBAAkB,CAAC;EACrHC,yBAAyB,CAACnB,QAAQ,EAAE/F,KAAK,CAACmH,SAAS,CAAC;EACpDC,uBAAuB,CAACrB,QAAQ,EAAE/F,KAAK,CAACqH,YAAY,CAAC;EAErD,OAAO;IACH7G,EAAE,EAAED,MAAM;IACVwF,QAAQ;IACR9F,IAAI,GAAAqH,qBAAA,GAAGvB,QAAQ,CAACrF,OAAO,CAACT,IAAI,cAAAqH,qBAAA,cAAAA,qBAAA,GAAI,EAAoC;IACpEC,KAAK,EAAExB,QAAQ,CAACyB,QAAQ;GAC3B;AACL;;;;"}
|
package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableSettingsPreloader.js
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
import React__default from 'react';
|
2
|
+
import { getSettingsId } from './util/settings.js';
|
3
|
+
import { useTaco } from '../../../hooks/useTaco.js';
|
4
|
+
|
5
|
+
function getLegacySetting(currentKey) {
|
6
|
+
try {
|
7
|
+
const localStorageValue = localStorage.getItem(currentKey);
|
8
|
+
if (localStorageValue) {
|
9
|
+
const value = JSON.parse(localStorageValue || 'null');
|
10
|
+
if (value !== null) {
|
11
|
+
localStorage.removeItem(currentKey);
|
12
|
+
return value;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
} catch {
|
16
|
+
// If user is in private mode or has storage restriction
|
17
|
+
// localStorage can throw. JSON.parse can throw, too.
|
18
|
+
}
|
19
|
+
return undefined;
|
20
|
+
}
|
21
|
+
function useTableSettingsPreloader(tableId) {
|
22
|
+
const taco = useTaco();
|
23
|
+
const [loading, setLoading] = React__default.useState(true);
|
24
|
+
React__default.useLayoutEffect(() => {
|
25
|
+
const key = getSettingsId(tableId);
|
26
|
+
// migrate legacy settings if they exist, can be removed in the future
|
27
|
+
const legacySettings = getLegacySetting(`taco.${taco.userId}.table.${tableId}.settings`);
|
28
|
+
if (legacySettings) {
|
29
|
+
const legacyPrintSettings = getLegacySetting(`taco.${taco.userId}.table.${tableId}.print.settings`);
|
30
|
+
taco.settings.saveSetting(key, {
|
31
|
+
...legacySettings,
|
32
|
+
print: legacyPrintSettings !== null && legacyPrintSettings !== void 0 ? legacyPrintSettings : {}
|
33
|
+
}).finally(() => setLoading(false));
|
34
|
+
} else {
|
35
|
+
taco.settings.loadSetting(key).finally(() => setLoading(false));
|
36
|
+
}
|
37
|
+
}, []);
|
38
|
+
return {
|
39
|
+
loading
|
40
|
+
};
|
41
|
+
}
|
42
|
+
|
43
|
+
export { useTableSettingsPreloader };
|
44
|
+
//# sourceMappingURL=useTableSettingsPreloader.js.map
|
package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableSettingsPreloader.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useTableSettingsPreloader.js","sources":["../../../../../../../../src/primitives/Table/useTableManager/useTableSettingsPreloader.ts"],"sourcesContent":["import React from 'react';\nimport { useTaco } from '../../../hooks/useTaco';\nimport { TablePrintSettings, TableSettings } from '../types';\nimport { getSettingsId } from './util/settings';\n\nfunction getLegacySetting<TType = unknown>(currentKey: string): TType | undefined {\n try {\n const localStorageValue = localStorage.getItem(currentKey);\n\n if (localStorageValue) {\n const value = JSON.parse(localStorageValue || 'null');\n\n if (value !== null) {\n localStorage.removeItem(currentKey);\n return value;\n }\n }\n } catch {\n // If user is in private mode or has storage restriction\n // localStorage can throw. JSON.parse can throw, too.\n }\n\n return undefined;\n}\n\nexport function useTableSettingsPreloader(tableId: string) {\n const taco = useTaco();\n const [loading, setLoading] = React.useState(true);\n\n React.useLayoutEffect(() => {\n const key = getSettingsId(tableId);\n\n // migrate legacy settings if they exist, can be removed in the future\n const legacySettings = getLegacySetting<TableSettings>(`taco.${taco.userId}.table.${tableId}.settings`);\n\n if (legacySettings) {\n const legacyPrintSettings = getLegacySetting<TablePrintSettings>(\n `taco.${taco.userId}.table.${tableId}.print.settings`\n );\n\n taco.settings\n .saveSetting(key, {\n ...legacySettings,\n print: legacyPrintSettings ?? {},\n })\n .finally(() => setLoading(false));\n } else {\n taco.settings.loadSetting<TableSettings>(key).finally(() => setLoading(false));\n }\n }, []);\n\n return { loading };\n}\n"],"names":["getLegacySetting","currentKey","localStorageValue","localStorage","getItem","value","JSON","parse","removeItem","undefined","useTableSettingsPreloader","tableId","taco","useTaco","loading","setLoading","React","useState","useLayoutEffect","key","getSettingsId","legacySettings","userId","legacyPrintSettings","settings","saveSetting","print","finally","loadSetting"],"mappings":";;;;AAKA,SAASA,gBAAgBA,CAAkBC,UAAkB;EACzD,IAAI;IACA,MAAMC,iBAAiB,GAAGC,YAAY,CAACC,OAAO,CAACH,UAAU,CAAC;IAE1D,IAAIC,iBAAiB,EAAE;MACnB,MAAMG,KAAK,GAAGC,IAAI,CAACC,KAAK,CAACL,iBAAiB,IAAI,MAAM,CAAC;MAErD,IAAIG,KAAK,KAAK,IAAI,EAAE;QAChBF,YAAY,CAACK,UAAU,CAACP,UAAU,CAAC;QACnC,OAAOI,KAAK;;;GAGvB,CAAC,MAAM;;;;EAKR,OAAOI,SAAS;AACpB;SAEgBC,yBAAyBA,CAACC,OAAe;EACrD,MAAMC,IAAI,GAAGC,OAAO,EAAE;EACtB,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,IAAI,CAAC;EAElDD,cAAK,CAACE,eAAe,CAAC;IAClB,MAAMC,GAAG,GAAGC,aAAa,CAACT,OAAO,CAAC;;IAGlC,MAAMU,cAAc,GAAGrB,gBAAgB,CAAgB,QAAQY,IAAI,CAACU,MAAM,UAAUX,OAAO,WAAW,CAAC;IAEvG,IAAIU,cAAc,EAAE;MAChB,MAAME,mBAAmB,GAAGvB,gBAAgB,CACxC,QAAQY,IAAI,CAACU,MAAM,UAAUX,OAAO,iBAAiB,CACxD;MAEDC,IAAI,CAACY,QAAQ,CACRC,WAAW,CAACN,GAAG,EAAE;QACd,GAAGE,cAAc;QACjBK,KAAK,EAAEH,mBAAmB,aAAnBA,mBAAmB,cAAnBA,mBAAmB,GAAI;OACjC,CAAC,CACDI,OAAO,CAAC,MAAMZ,UAAU,CAAC,KAAK,CAAC,CAAC;KACxC,MAAM;MACHH,IAAI,CAACY,QAAQ,CAACI,WAAW,CAAgBT,GAAG,CAAC,CAACQ,OAAO,CAAC,MAAMZ,UAAU,CAAC,KAAK,CAAC,CAAC;;GAErF,EAAE,EAAE,CAAC;EAEN,OAAO;IAAED;GAAS;AACtB;;;;"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { isInternalColumn } from './columns.js';
|
2
2
|
|
3
|
+
const getSettingsId = tableId => `table.${tableId.replace('.', '_')}`;
|
3
4
|
function getSettings(table) {
|
4
5
|
const meta = table.options.meta;
|
5
6
|
const state = table.getState();
|
@@ -13,6 +14,7 @@ function getSettings(table) {
|
|
13
14
|
excludeUnmatchedRecordsInSearch: table.options.enableGlobalFilter,
|
14
15
|
fontSize: meta.fontSize.isEnabled ? meta.fontSize.size : undefined,
|
15
16
|
//grouping: table.options.enableGrouping ? state.grouping : undefined,
|
17
|
+
print: meta.printing.settings,
|
16
18
|
rowHeight: meta.rowHeight.isEnabled ? meta.rowHeight.height : undefined,
|
17
19
|
//searchQuery: table.options.enableGlobalFilter ? state.globalFilter : undefined,
|
18
20
|
sorting: state.sorting
|
@@ -30,5 +32,5 @@ function ignoreInternalColumns(data) {
|
|
30
32
|
}, {});
|
31
33
|
}
|
32
34
|
|
33
|
-
export { getSettings, ignoreInternalColumns };
|
35
|
+
export { getSettings, getSettingsId, ignoreInternalColumns };
|
34
36
|
//# sourceMappingURL=settings.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"settings.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/settings.ts"],"sourcesContent":["import { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { isInternalColumn } from './columns';\n\nexport function getSettings<TType = unknown>(table: ReactTable<TType>) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const state = table.getState();\n\n return {\n // commented out properties are here to highlight things we explicitly don't want them saved\n //columnFilters: table.options.enableColumnFilters ? state.columnFilters : undefined,\n columnOrder: meta.columnOrdering.isEnabled ? state.columnOrder : undefined,\n columnPinning: state.columnPinning,\n columnSizing: ignoreInternalColumns(state.columnSizing),\n columnVisibility: table.options.enableHiding ? state.columnVisibility : undefined,\n excludeUnmatchedRecordsInSearch: table.options.enableGlobalFilter,\n fontSize: meta.fontSize.isEnabled ? meta.fontSize.size : undefined,\n //grouping: table.options.enableGrouping ? state.grouping : undefined,\n rowHeight: meta.rowHeight.isEnabled ? meta.rowHeight.height : undefined,\n //searchQuery: table.options.enableGlobalFilter ? state.globalFilter : undefined,\n sorting: state.sorting,\n };\n}\n\nexport function ignoreInternalColumns(data: object) {\n return Object.keys(data).reduce((accum, key) => {\n if (isInternalColumn(key)) {\n return accum;\n }\n\n return {\n ...accum,\n [key]: data[key],\n };\n }, {});\n}\n"],"names":["getSettings","table","meta","options","state","getState","columnOrder","columnOrdering","isEnabled","undefined","columnPinning","columnSizing","ignoreInternalColumns","columnVisibility","enableHiding","excludeUnmatchedRecordsInSearch","enableGlobalFilter","fontSize","size","rowHeight","height","sorting","data","Object","keys","reduce","accum","key","isInternalColumn"],"mappings":";;
|
1
|
+
{"version":3,"file":"settings.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/settings.ts"],"sourcesContent":["import { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { isInternalColumn } from './columns';\n\nexport const getSettingsId = (tableId: string) => `table.${tableId.replace('.', '_')}`;\n\nexport function getSettings<TType = unknown>(table: ReactTable<TType>) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const state = table.getState();\n\n return {\n // commented out properties are here to highlight things we explicitly don't want them saved\n //columnFilters: table.options.enableColumnFilters ? state.columnFilters : undefined,\n columnOrder: meta.columnOrdering.isEnabled ? state.columnOrder : undefined,\n columnPinning: state.columnPinning,\n columnSizing: ignoreInternalColumns(state.columnSizing),\n columnVisibility: table.options.enableHiding ? state.columnVisibility : undefined,\n excludeUnmatchedRecordsInSearch: table.options.enableGlobalFilter,\n fontSize: meta.fontSize.isEnabled ? meta.fontSize.size : undefined,\n //grouping: table.options.enableGrouping ? state.grouping : undefined,\n print: meta.printing.settings,\n rowHeight: meta.rowHeight.isEnabled ? meta.rowHeight.height : undefined,\n //searchQuery: table.options.enableGlobalFilter ? state.globalFilter : undefined,\n sorting: state.sorting,\n };\n}\n\nexport function ignoreInternalColumns(data: object) {\n return Object.keys(data).reduce((accum, key) => {\n if (isInternalColumn(key)) {\n return accum;\n }\n\n return {\n ...accum,\n [key]: data[key],\n };\n }, {});\n}\n"],"names":["getSettingsId","tableId","replace","getSettings","table","meta","options","state","getState","columnOrder","columnOrdering","isEnabled","undefined","columnPinning","columnSizing","ignoreInternalColumns","columnVisibility","enableHiding","excludeUnmatchedRecordsInSearch","enableGlobalFilter","fontSize","size","print","printing","settings","rowHeight","height","sorting","data","Object","keys","reduce","accum","key","isInternalColumn"],"mappings":";;MAGaA,aAAa,GAAIC,OAAe,IAAK,SAASA,OAAO,CAACC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;SAEpEC,WAAWA,CAAkBC,KAAwB;EACjE,MAAMC,IAAI,GAAGD,KAAK,CAACE,OAAO,CAACD,IAA6B;EACxD,MAAME,KAAK,GAAGH,KAAK,CAACI,QAAQ,EAAE;EAE9B,OAAO;;;IAGHC,WAAW,EAAEJ,IAAI,CAACK,cAAc,CAACC,SAAS,GAAGJ,KAAK,CAACE,WAAW,GAAGG,SAAS;IAC1EC,aAAa,EAAEN,KAAK,CAACM,aAAa;IAClCC,YAAY,EAAEC,qBAAqB,CAACR,KAAK,CAACO,YAAY,CAAC;IACvDE,gBAAgB,EAAEZ,KAAK,CAACE,OAAO,CAACW,YAAY,GAAGV,KAAK,CAACS,gBAAgB,GAAGJ,SAAS;IACjFM,+BAA+B,EAAEd,KAAK,CAACE,OAAO,CAACa,kBAAkB;IACjEC,QAAQ,EAAEf,IAAI,CAACe,QAAQ,CAACT,SAAS,GAAGN,IAAI,CAACe,QAAQ,CAACC,IAAI,GAAGT,SAAS;;IAElEU,KAAK,EAAEjB,IAAI,CAACkB,QAAQ,CAACC,QAAQ;IAC7BC,SAAS,EAAEpB,IAAI,CAACoB,SAAS,CAACd,SAAS,GAAGN,IAAI,CAACoB,SAAS,CAACC,MAAM,GAAGd,SAAS;;IAEvEe,OAAO,EAAEpB,KAAK,CAACoB;GAClB;AACL;SAEgBZ,qBAAqBA,CAACa,IAAY;EAC9C,OAAOC,MAAM,CAACC,IAAI,CAACF,IAAI,CAAC,CAACG,MAAM,CAAC,CAACC,KAAK,EAAEC,GAAG;IACvC,IAAIC,gBAAgB,CAACD,GAAG,CAAC,EAAE;MACvB,OAAOD,KAAK;;IAGhB,OAAO;MACH,GAAGA,KAAK;MACR,CAACC,GAAG,GAAGL,IAAI,CAACK,GAAG;KAClB;GACJ,EAAE,EAAE,CAAC;AACV;;;;"}
|
@@ -297,8 +297,11 @@ function useReactTableInitialState(props, columns, persistedSettings, defaults)
|
|
297
297
|
if (columnPinning !== null && columnPinning !== void 0 && (_columnPinning$left = columnPinning.left) !== null && _columnPinning$left !== void 0 && _columnPinning$left.length) {
|
298
298
|
columnPinning.left = freezeUptoExternalColumn(columnOrder.indexOf(columnPinning.left[columnPinning.left.length - 1]), columnOrder);
|
299
299
|
} else {
|
300
|
-
if (props.defaultColumnFreezingIndex) {
|
301
|
-
|
300
|
+
if (props.defaultColumnFreezingIndex !== undefined) {
|
301
|
+
const index = typeof props.defaultColumnFreezingIndex === 'function' ? props.defaultColumnFreezingIndex(persistedSettings) : props.defaultColumnFreezingIndex;
|
302
|
+
if (index !== undefined) {
|
303
|
+
columnPinning.left = freezeUptoExternalColumn(index, columnOrder);
|
304
|
+
}
|
302
305
|
} else {
|
303
306
|
columnPinning.left = unfreezeAllExternalColumns(columnOrder);
|
304
307
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"setup.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/setup.ts"],"sourcesContent":["import React from 'react';\nimport {\n createColumnHelper,\n getExpandedRowModel,\n getFilteredRowModel,\n getGroupedRowModel,\n getSortedRowModel,\n TableOptions as ReactTableOptions,\n Row as ReactTableRow,\n Column as ReactTableColumn,\n ColumnDef as ReactTableColumnDef,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSizingState as ReactTableColumnSizingState,\n ColumnSort as ReactTableColumnSort,\n TableState as ReactTableState,\n VisibilityState as ReactTableVisibilityState,\n} from '@tanstack/react-table';\nimport get from 'lodash/get';\nimport { useTableManagerInternalColumns, useTableManagerInternalColumn } from '../types';\nimport { TableColumnProps, TableFeatureProps, TableGroupProps, TableProps, TableSettings } from '../../types';\nimport { getSortingFn } from './sorting';\nimport { ensureOrdering, freezeUptoExternalColumn, getCellMinWidth, unfreezeAllExternalColumns } from './columns';\nimport { columnFilterFn } from './filtering';\nimport { globalFilterFn } from './search';\nimport { ignoreInternalColumns } from './settings';\nimport { getDataTypeProperties } from './dataTypes';\nimport { Localization } from '../../../../components/Provider/Localization';\n\n// mapping children to react-table columns\nfunction processChildren<TType>(\n child: React.ReactChild | React.ReactFragment | React.ReactPortal,\n columns: ReactTableColumnDef<TType>[],\n defaultSizing: ReactTableColumnSizingState,\n defaultSorting: ReactTableColumnSort[],\n defaultVisibility: ReactTableVisibilityState,\n settings: TableSettings,\n defaultRowGroupColumnId: keyof TType | undefined,\n localization: Localization\n): ReactTableColumnDef<TType>[] {\n const columnHelper = createColumnHelper<TType>();\n\n if (React.isValidElement<TableGroupProps>(child) && child.props.children) {\n const { children, id, header } = child.props;\n\n columns.push(\n columnHelper.group({\n id,\n header,\n columns: React.Children.toArray(children).reduce(\n (columns: ReactTableColumnDef<TType>[], child) =>\n processChildren<TType>(\n child,\n columns,\n defaultSizing,\n defaultSorting,\n defaultVisibility,\n settings,\n defaultRowGroupColumnId,\n localization\n ),\n []\n ),\n // we don't want to let column groups be grouped/aggregrated\n enableGrouping: false,\n })\n );\n } else if (React.isValidElement<TableColumnProps<TType>>(child) && (child.props.accessor || child.props.id)) {\n const {\n id: untypedId,\n accessor: accessorKey = untypedId,\n // renderers\n renderer,\n aggregate,\n footer,\n header,\n // options\n aggregationFn,\n defaultHidden,\n defaultWidth,\n enableEditing = !!child.props.control,\n enableFiltering: enableColumnFilter = true,\n enableGrouping = false,\n enableHiding = true,\n enableOrdering = true,\n enablePrinting = true,\n enableResizing = true,\n enableSearch: enableGlobalFilter = true,\n enableSorting = true,\n enableTruncate = false,\n minWidth: minSize = getCellMinWidth(settings.fontSize),\n sort,\n sortFn,\n ...meta\n } = child.props;\n const id = untypedId as string;\n const dataTypeProperties = getDataTypeProperties<TType>(child.props.dataType);\n\n if (defaultHidden && enableHiding) {\n defaultVisibility[id] = false;\n }\n\n if (defaultWidth) {\n defaultSizing[id] = defaultWidth as any;\n }\n\n const isGrouped = defaultRowGroupColumnId === id;\n\n if (child.props.sort !== undefined || isGrouped) {\n defaultSorting.push({\n id,\n desc: sort === 'desc',\n });\n }\n\n const column: ReactTableColumnDef<TType, any> = {\n id,\n accessorKey,\n // To avoid errors caused by undefined row data values, we pass accessorFn as a preventive measure\n // accessorKey can be dot notated strings, so we use lodash.get to access deeply nested children\n accessorFn: row => get(row, accessorKey),\n // The header can be either a string or a JSX.Element, but react-table expects it to be a string or a\n // renderer function, so `() => header` ensures compatibility when header is a JSX.Element.\n // If we just pass `() => header`, then we will loose truncation for string headers.\n header: typeof header === 'string' ? header : () => header,\n // features\n enableColumnFilter,\n enableGlobalFilter,\n enableGrouping,\n enableHiding: isGrouped ? false : enableHiding,\n enableResizing,\n enableSorting,\n // config - sizing\n minSize,\n // meta\n meta: {\n ...(meta as any),\n align: meta.align ?? dataTypeProperties.align,\n defaultWidth,\n enableOrdering: isGrouped ? false : enableOrdering,\n enablePrinting,\n enableTruncate,\n enableEditing,\n header,\n renderer,\n },\n };\n\n // renderers - use defined renderers first, then fall back to data type renderers (if there is one)\n if (typeof renderer === 'function') {\n column.cell = info => renderer(info.getValue(), info.row.original);\n } else if (dataTypeProperties.getDisplayValue) {\n const dataTypeRenderer = (value: any) => {\n const displayValue = dataTypeProperties.getDisplayValue?.(value, { localization });\n\n if (Array.isArray(displayValue)) {\n return displayValue[0] ?? value;\n }\n\n return displayValue ?? value;\n };\n column.cell = info => dataTypeRenderer(info.getValue());\n (column.meta as any).renderer = dataTypeRenderer;\n }\n\n if (typeof footer === 'function') {\n column.footer = info =>\n footer(info.table.getRowModel().rows.flatMap(row => (row.original !== undefined ? row.original : [])));\n }\n\n // config - filtering\n if (enableColumnFilter) {\n column.filterFn = 'tacoFilter' as any;\n }\n\n // config - grouping/aggregation\n if (enableGrouping) {\n column.aggregationFn = aggregationFn;\n\n if (typeof aggregate === 'function') {\n column.aggregatedCell = info => aggregate(info.getValue(), info.row.original);\n }\n }\n\n // config - sorting\n if (enableSorting) {\n column.sortingFn = getSortingFn<TType>(child.props.dataType, sortFn);\n column.sortDescFirst = false;\n column.sortUndefined = 1;\n }\n\n columns.push(column);\n }\n\n return columns;\n}\n\nfunction createInternalColumn<TType = unknown>(\n id: string,\n column: useTableManagerInternalColumn<TType>,\n defaultSizing: ReactTableColumnSizingState\n) {\n if (column.size) {\n defaultSizing[id] = column.size;\n }\n\n return {\n id,\n accessorKey: id,\n header: column.header,\n cell: column.renderer,\n // features\n enableColumnFilter: false,\n enableGlobalFilter: false,\n enableGrouping: false,\n enableHiding: false,\n enableResizing: false,\n enableSorting: false,\n // config - sizing\n size: column.size,\n minSize: column.size,\n // meta\n meta: {\n ...(column.meta as any),\n enableOrdering: false,\n enablePrinting: false,\n enableTruncate: false,\n },\n } as ReactTableColumnDef<TType, any>;\n}\n\nexport function mapTableChildrenToColumns<TType = unknown>(\n props: TableProps<TType>,\n settings: TableSettings,\n options: TableFeatureProps<TType>,\n internalColumns: useTableManagerInternalColumns<TType> | undefined,\n localization: Localization\n) {\n const { children, defaultRowGroupColumnId } = props;\n const defaultSizing: ReactTableColumnSizingState = {};\n const defaultSorting: ReactTableColumnSort[] = [];\n const defaultVisibility: ReactTableVisibilityState = {};\n\n const columns = React.Children.toArray(children).reduce(\n (columns: ReactTableColumnDef<TType>[], child) =>\n processChildren<TType>(\n child,\n columns,\n defaultSizing,\n defaultSorting,\n defaultVisibility,\n settings,\n defaultRowGroupColumnId,\n localization\n ),\n\n []\n );\n\n if (internalColumns) {\n if (options.enableRowExpansion && props.rowExpansionRenderer && internalColumns.rowExpansion) {\n const column = createInternalColumn<TType>('__expansion', internalColumns.rowExpansion, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowSelection && internalColumns.rowSelection) {\n const column = createInternalColumn<TType>('__select', internalColumns.rowSelection, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowDrag && props.onRowDrag && internalColumns.rowDrag) {\n const column = createInternalColumn<TType>('__drag', internalColumns.rowDrag, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowActions && props.rowActions?.length && internalColumns.rowActions) {\n const column = createInternalColumn<TType>('__actions', internalColumns.rowActions, defaultSizing);\n columns.push(column);\n }\n }\n\n return { columns, defaultSizing, defaultSorting, defaultVisibility };\n}\n\nexport function configureReactTableOptions<TType = unknown>(\n options: TableFeatureProps<TType>,\n props: TableProps<TType>,\n localization: Localization\n) {\n // We don't want to expose internal Tanstack Table row, so we need to wrap enableRowSelection callback into additional function,\n // which receives the React Table Row object and passes row.original to a callback.\n const reactTableEnableRowSelection =\n typeof options.enableRowSelection === 'function'\n ? (row: ReactTableRow<TType>) => (options.enableRowSelection as (row: TType) => boolean)(row.original)\n : options.enableRowSelection;\n\n let getRowId;\n\n if (props.rowIdentityAccessor) {\n getRowId = (originalRow: TType | undefined, index: number) => {\n if (originalRow) {\n return String(originalRow[props.rowIdentityAccessor as keyof TType]);\n }\n\n return String(index);\n };\n }\n\n const tableOptions: Partial<ReactTableOptions<TType>> = {\n defaultColumn: {\n enableColumnFilter: options.enableFiltering || true,\n enableGrouping: false,\n enableHiding: options.enableColumnHiding || true,\n enableResizing: options.enableColumnResizing || true,\n enableGlobalFilter: options.enableSearch || true,\n enableSorting: options.enableSorting || true,\n minSize: 1,\n // the default is 150, which is a bit random\n size: 1,\n },\n enableColumnFilters: options.enableFiltering ?? false,\n enableColumnResizing: options.enableColumnResizing ?? false,\n enableExpanding: options.enableRowExpansion ?? false,\n enableGrouping: true, // users can't customise row grouping, so it can just be always enabled and left to the defaultRowGroupColumnId prop\n enableHiding: options.enableColumnHiding ?? false,\n enablePinning: options.enableColumnFreezing ?? false,\n enableRowPinning: true, // users can't customise row pinning, so it can just be always enabled\n enableRowSelection: reactTableEnableRowSelection ?? false,\n enableSorting: options.enableSorting ?? false,\n // models for default features\n getExpandedRowModel: getExpandedRowModel<TType>(),\n getGroupedRowModel: getGroupedRowModel<TType>(),\n getRowId,\n groupedColumnMode: false,\n keepPinnedRows: false,\n };\n\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n if (tableOptions.enableColumnFilters) {\n // enter controlled filter mode (controlled could be local state, but usually the server)\n if (props.onChangeFilter) {\n // tableOptions.manualFiltering = true;\n // we don't set it because it breaks global filtering (used for search, which is fully client side)\n //\n // tableOptions.onColumnFiltersChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onFilter\n } else {\n tableOptions.getFilteredRowModel = getFilteredRowModel<TType>();\n tableOptions.filterFns = {\n tacoFilter: (row: ReactTableRow<TType>, columnId: string, filter: any) =>\n columnFilterFn(row.getValue(columnId), filter),\n };\n }\n }\n\n if (options.enableSearch) {\n // always set these because enableGlobalFilter can be toggled on and off by the user\n tableOptions.getFilteredRowModel = getFilteredRowModel<TType>();\n tableOptions.globalFilterFn = (row: ReactTableRow<TType>, columnId: string, searchQuery: any) =>\n globalFilterFn(row, columnId, searchQuery, localization);\n tableOptions.getColumnCanGlobalFilter = (column: ReactTableColumn<TType>) =>\n column.columnDef.meta?.enableSearch !== false && column.getIsVisible();\n\n // enter controlled search mode (controlled could be local state, but usually the server)\n if (props.onChangeSearch) {\n if (props._experimentalDataLoader2) {\n tableOptions.manualFiltering = true;\n } else {\n // tableOptions.manualFiltering = true;\n // we don't set this because controlled search is not currently supported, search is always client side\n //\n // tableOptions.onGlobalFilterChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onSearch.\n //\n // we also don't always filter when searching, we have the highlight functionality as the default\n // and filtering can be toggled by the user\n }\n }\n }\n\n if (tableOptions.enableSorting) {\n // enter controlled sort mode (controlled could be local state, but usually the server)\n if (props.onChangeSort) {\n tableOptions.manualSorting = true;\n\n // tableOptions.onSortingChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onSort\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n return tableOptions;\n}\n\nexport function useReactTableInitialState<TType = unknown>(\n props: TableProps<TType>,\n columns: ReactTableColumnDef<TType>[],\n persistedSettings: TableSettings,\n defaults: {\n defaultSizing: ReactTableColumnSizingState;\n defaultSorting: ReactTableColumnSort[];\n defaultVisibility: ReactTableVisibilityState;\n }\n): Partial<ReactTableState> {\n return React.useMemo(() => {\n const ignoreNotDefinedColumns = (column: ReactTableColumnDef<TType>) =>\n columns.find(definedColumn => definedColumn.id === column.id);\n\n const columnPinning: ReactTableColumnPinningState =\n persistedSettings.columnPinning ?? props.defaultSettings?.columnPinning ?? {};\n\n const columnOrder = ensureOrdering<TType>(\n columns,\n persistedSettings.columnOrder ?? props.defaultSettings?.columnOrder,\n columnPinning.left\n );\n\n // ensure internal columns are pinned, and are pinned in the correct order\n if (columnPinning?.left?.length) {\n columnPinning.left = freezeUptoExternalColumn(\n columnOrder.indexOf(columnPinning.left[columnPinning.left.length - 1]),\n columnOrder\n );\n } else {\n if (props.defaultColumnFreezingIndex) {\n columnPinning.left = freezeUptoExternalColumn(props.defaultColumnFreezingIndex, columnOrder);\n } else {\n columnPinning.left = unfreezeAllExternalColumns(columnOrder);\n }\n }\n\n const state: Partial<ReactTableState> = {\n columnFilters: persistedSettings.columnFilters ?? props.defaultSettings?.columnFilters ?? [],\n columnOrder,\n columnPinning,\n columnSizing: ignoreInternalColumns(\n persistedSettings.columnSizing ?? props.defaultSettings?.columnSizing ?? defaults.defaultSizing ?? {}\n ),\n columnVisibility:\n persistedSettings.columnVisibility ?? props.defaultSettings?.columnVisibility ?? defaults.defaultVisibility ?? {},\n globalFilter: persistedSettings.searchQuery ?? props.defaultSettings?.searchQuery,\n sorting: persistedSettings.sorting\n ? persistedSettings.sorting.filter(ignoreNotDefinedColumns)\n : props.defaultSettings?.sorting ?? defaults.defaultSorting,\n };\n\n if (props.defaultRowGroupColumnId) {\n state.grouping = [props.defaultRowGroupColumnId as string];\n // row groups should (all) always be expanded by default\n state.expanded = true;\n }\n\n return state;\n }, []);\n}\n"],"names":["processChildren","child","columns","defaultSizing","defaultSorting","defaultVisibility","settings","defaultRowGroupColumnId","localization","columnHelper","createColumnHelper","React","isValidElement","props","children","id","header","push","group","Children","toArray","reduce","enableGrouping","accessor","_meta$align","untypedId","accessorKey","renderer","aggregate","footer","aggregationFn","defaultHidden","defaultWidth","enableEditing","control","enableFiltering","enableColumnFilter","enableHiding","enableOrdering","enablePrinting","enableResizing","enableSearch","enableGlobalFilter","enableSorting","enableTruncate","minWidth","minSize","getCellMinWidth","fontSize","sort","sortFn","meta","dataTypeProperties","getDataTypeProperties","dataType","isGrouped","undefined","desc","column","accessorFn","row","get","align","cell","info","getValue","original","getDisplayValue","dataTypeRenderer","value","displayValue","_dataTypeProperties$g","call","Array","isArray","_displayValue$","table","getRowModel","rows","flatMap","filterFn","aggregatedCell","sortingFn","getSortingFn","sortDescFirst","sortUndefined","createInternalColumn","size","mapTableChildrenToColumns","options","internalColumns","_props$rowActions","enableRowExpansion","rowExpansionRenderer","rowExpansion","unshift","enableRowSelection","rowSelection","enableRowDrag","onRowDrag","rowDrag","enableRowActions","rowActions","length","configureReactTableOptions","reactTableEnableRowSelection","getRowId","rowIdentityAccessor","originalRow","index","String","tableOptions","defaultColumn","enableColumnHiding","enableColumnResizing","enableColumnFilters","_options$enableFilter","_options$enableColumn","enableExpanding","_options$enableRowExp","_options$enableColumn2","enablePinning","_options$enableColumn3","enableColumnFreezing","enableRowPinning","_options$enableSortin","getExpandedRowModel","getGroupedRowModel","groupedColumnMode","keepPinnedRows","columnResizeMode","onChangeFilter","getFilteredRowModel","filterFns","tacoFilter","columnId","filter","columnFilterFn","globalFilterFn","searchQuery","getColumnCanGlobalFilter","_column$columnDef$met","columnDef","getIsVisible","onChangeSearch","_experimentalDataLoader2","manualFiltering","onChangeSort","manualSorting","getSortedRowModel","useReactTableInitialState","persistedSettings","defaults","useMemo","ignoreNotDefinedColumns","find","definedColumn","columnPinning","_ref","_persistedSettings$co","_props$defaultSetting","defaultSettings","columnOrder","ensureOrdering","_persistedSettings$co2","_props$defaultSetting2","left","_columnPinning$left","freezeUptoExternalColumn","indexOf","defaultColumnFreezingIndex","unfreezeAllExternalColumns","state","columnFilters","_ref2","_persistedSettings$co3","_props$defaultSetting3","columnSizing","ignoreInternalColumns","_ref3","_ref4","_persistedSettings$co4","_props$defaultSetting4","columnVisibility","_ref5","_ref6","_persistedSettings$co5","_props$defaultSetting5","globalFilter","_persistedSettings$se","_props$defaultSetting6","sorting","_props$defaultSetting7","_props$defaultSetting8","grouping","expanded"],"mappings":";;;;;;;;;;AA4BA;AACA,SAASA,eAAeA,CACpBC,KAAiE,EACjEC,OAAqC,EACrCC,aAA0C,EAC1CC,cAAsC,EACtCC,iBAA4C,EAC5CC,QAAuB,EACvBC,uBAAgD,EAChDC,YAA0B;EAE1B,MAAMC,YAAY,GAAGC,kBAAkB,EAAS;EAEhD,iBAAIC,cAAK,CAACC,cAAc,CAAkBX,KAAK,CAAC,IAAIA,KAAK,CAACY,KAAK,CAACC,QAAQ,EAAE;IACtE,MAAM;MAAEA,QAAQ;MAAEC,EAAE;MAAEC;KAAQ,GAAGf,KAAK,CAACY,KAAK;IAE5CX,OAAO,CAACe,IAAI,CACRR,YAAY,CAACS,KAAK,CAAC;MACfH,EAAE;MACFC,MAAM;MACNd,OAAO,EAAES,cAAK,CAACQ,QAAQ,CAACC,OAAO,CAACN,QAAQ,CAAC,CAACO,MAAM,CAC5C,CAACnB,OAAqC,EAAED,KAAK,KACzCD,eAAe,CACXC,KAAK,EACLC,OAAO,EACPC,aAAa,EACbC,cAAc,EACdC,iBAAiB,EACjBC,QAAQ,EACRC,uBAAuB,EACvBC,YAAY,CACf,EACL,EAAE,CACL;;MAEDc,cAAc,EAAE;KACnB,CAAC,CACL;GACJ,MAAM,iBAAIX,cAAK,CAACC,cAAc,CAA0BX,KAAK,CAAC,KAAKA,KAAK,CAACY,KAAK,CAACU,QAAQ,IAAItB,KAAK,CAACY,KAAK,CAACE,EAAE,CAAC,E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AAC,sBAAA,GAAIjL,KAAK,CAACoJ,eAAe,cAAA6B,sBAAA,uBAArBA,sBAAA,CAAuBnD,WAAW;MACjFoD,OAAO,EAAExC,iBAAiB,CAACwC,OAAO,GAC5BxC,iBAAiB,CAACwC,OAAO,CAACvD,MAAM,CAACkB,uBAAuB,CAAC,IAAAsC,sBAAA,IAAAC,sBAAA,GACzDpL,KAAK,CAACoJ,eAAe,cAAAgC,sBAAA,uBAArBA,sBAAA,CAAuBF,OAAO,cAAAC,sBAAA,cAAAA,sBAAA,GAAIxC,QAAQ,CAACpJ;KACpD;IAED,IAAIS,KAAK,CAACN,uBAAuB,EAAE;MAC/BqK,KAAK,CAACsB,QAAQ,GAAG,CAACrL,KAAK,CAACN,uBAAiC,CAAC;;MAE1DqK,KAAK,CAACuB,QAAQ,GAAG,IAAI;;IAGzB,OAAOvB,KAAK;GACf,EAAE,EAAE,CAAC;AACV;;;;"}
|
1
|
+
{"version":3,"file":"setup.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/setup.ts"],"sourcesContent":["import React from 'react';\nimport {\n createColumnHelper,\n getExpandedRowModel,\n getFilteredRowModel,\n getGroupedRowModel,\n getSortedRowModel,\n TableOptions as ReactTableOptions,\n Row as ReactTableRow,\n Column as ReactTableColumn,\n ColumnDef as ReactTableColumnDef,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSizingState as ReactTableColumnSizingState,\n ColumnSort as ReactTableColumnSort,\n TableState as ReactTableState,\n VisibilityState as ReactTableVisibilityState,\n} from '@tanstack/react-table';\nimport get from 'lodash/get';\nimport { useTableManagerInternalColumns, useTableManagerInternalColumn } from '../types';\nimport { TableColumnProps, TableFeatureProps, TableGroupProps, TableProps, TableSettings } from '../../types';\nimport { getSortingFn } from './sorting';\nimport { ensureOrdering, freezeUptoExternalColumn, getCellMinWidth, unfreezeAllExternalColumns } from './columns';\nimport { columnFilterFn } from './filtering';\nimport { globalFilterFn } from './search';\nimport { ignoreInternalColumns } from './settings';\nimport { getDataTypeProperties } from './dataTypes';\nimport { Localization } from '../../../../components/Provider/Localization';\n\n// mapping children to react-table columns\nfunction processChildren<TType>(\n child: React.ReactChild | React.ReactFragment | React.ReactPortal,\n columns: ReactTableColumnDef<TType>[],\n defaultSizing: ReactTableColumnSizingState,\n defaultSorting: ReactTableColumnSort[],\n defaultVisibility: ReactTableVisibilityState,\n settings: TableSettings,\n defaultRowGroupColumnId: keyof TType | undefined,\n localization: Localization\n): ReactTableColumnDef<TType>[] {\n const columnHelper = createColumnHelper<TType>();\n\n if (React.isValidElement<TableGroupProps>(child) && child.props.children) {\n const { children, id, header } = child.props;\n\n columns.push(\n columnHelper.group({\n id,\n header,\n columns: React.Children.toArray(children).reduce(\n (columns: ReactTableColumnDef<TType>[], child) =>\n processChildren<TType>(\n child,\n columns,\n defaultSizing,\n defaultSorting,\n defaultVisibility,\n settings,\n defaultRowGroupColumnId,\n localization\n ),\n []\n ),\n // we don't want to let column groups be grouped/aggregrated\n enableGrouping: false,\n })\n );\n } else if (React.isValidElement<TableColumnProps<TType>>(child) && (child.props.accessor || child.props.id)) {\n const {\n id: untypedId,\n accessor: accessorKey = untypedId,\n // renderers\n renderer,\n aggregate,\n footer,\n header,\n // options\n aggregationFn,\n defaultHidden,\n defaultWidth,\n enableEditing = !!child.props.control,\n enableFiltering: enableColumnFilter = true,\n enableGrouping = false,\n enableHiding = true,\n enableOrdering = true,\n enablePrinting = true,\n enableResizing = true,\n enableSearch: enableGlobalFilter = true,\n enableSorting = true,\n enableTruncate = false,\n minWidth: minSize = getCellMinWidth(settings.fontSize),\n sort,\n sortFn,\n ...meta\n } = child.props;\n const id = untypedId as string;\n const dataTypeProperties = getDataTypeProperties<TType>(child.props.dataType);\n\n if (defaultHidden && enableHiding) {\n defaultVisibility[id] = false;\n }\n\n if (defaultWidth) {\n defaultSizing[id] = defaultWidth as any;\n }\n\n const isGrouped = defaultRowGroupColumnId === id;\n\n if (child.props.sort !== undefined || isGrouped) {\n defaultSorting.push({\n id,\n desc: sort === 'desc',\n });\n }\n\n const column: ReactTableColumnDef<TType, any> = {\n id,\n accessorKey,\n // To avoid errors caused by undefined row data values, we pass accessorFn as a preventive measure\n // accessorKey can be dot notated strings, so we use lodash.get to access deeply nested children\n accessorFn: row => get(row, accessorKey),\n // The header can be either a string or a JSX.Element, but react-table expects it to be a string or a\n // renderer function, so `() => header` ensures compatibility when header is a JSX.Element.\n // If we just pass `() => header`, then we will loose truncation for string headers.\n header: typeof header === 'string' ? header : () => header,\n // features\n enableColumnFilter,\n enableGlobalFilter,\n enableGrouping,\n enableHiding: isGrouped ? false : enableHiding,\n enableResizing,\n enableSorting,\n // config - sizing\n minSize,\n // meta\n meta: {\n ...(meta as any),\n align: meta.align ?? dataTypeProperties.align,\n defaultWidth,\n enableOrdering: isGrouped ? false : enableOrdering,\n enablePrinting,\n enableTruncate,\n enableEditing,\n header,\n renderer,\n },\n };\n\n // renderers - use defined renderers first, then fall back to data type renderers (if there is one)\n if (typeof renderer === 'function') {\n column.cell = info => renderer(info.getValue(), info.row.original);\n } else if (dataTypeProperties.getDisplayValue) {\n const dataTypeRenderer = (value: any) => {\n const displayValue = dataTypeProperties.getDisplayValue?.(value, { localization });\n\n if (Array.isArray(displayValue)) {\n return displayValue[0] ?? value;\n }\n\n return displayValue ?? value;\n };\n column.cell = info => dataTypeRenderer(info.getValue());\n (column.meta as any).renderer = dataTypeRenderer;\n }\n\n if (typeof footer === 'function') {\n column.footer = info =>\n footer(info.table.getRowModel().rows.flatMap(row => (row.original !== undefined ? row.original : [])));\n }\n\n // config - filtering\n if (enableColumnFilter) {\n column.filterFn = 'tacoFilter' as any;\n }\n\n // config - grouping/aggregation\n if (enableGrouping) {\n column.aggregationFn = aggregationFn;\n\n if (typeof aggregate === 'function') {\n column.aggregatedCell = info => aggregate(info.getValue(), info.row.original);\n }\n }\n\n // config - sorting\n if (enableSorting) {\n column.sortingFn = getSortingFn<TType>(child.props.dataType, sortFn);\n column.sortDescFirst = false;\n column.sortUndefined = 1;\n }\n\n columns.push(column);\n }\n\n return columns;\n}\n\nfunction createInternalColumn<TType = unknown>(\n id: string,\n column: useTableManagerInternalColumn<TType>,\n defaultSizing: ReactTableColumnSizingState\n) {\n if (column.size) {\n defaultSizing[id] = column.size;\n }\n\n return {\n id,\n accessorKey: id,\n header: column.header,\n cell: column.renderer,\n // features\n enableColumnFilter: false,\n enableGlobalFilter: false,\n enableGrouping: false,\n enableHiding: false,\n enableResizing: false,\n enableSorting: false,\n // config - sizing\n size: column.size,\n minSize: column.size,\n // meta\n meta: {\n ...(column.meta as any),\n enableOrdering: false,\n enablePrinting: false,\n enableTruncate: false,\n },\n } as ReactTableColumnDef<TType, any>;\n}\n\nexport function mapTableChildrenToColumns<TType = unknown>(\n props: TableProps<TType>,\n settings: TableSettings,\n options: TableFeatureProps<TType>,\n internalColumns: useTableManagerInternalColumns<TType> | undefined,\n localization: Localization\n) {\n const { children, defaultRowGroupColumnId } = props;\n const defaultSizing: ReactTableColumnSizingState = {};\n const defaultSorting: ReactTableColumnSort[] = [];\n const defaultVisibility: ReactTableVisibilityState = {};\n\n const columns = React.Children.toArray(children).reduce(\n (columns: ReactTableColumnDef<TType>[], child) =>\n processChildren<TType>(\n child,\n columns,\n defaultSizing,\n defaultSorting,\n defaultVisibility,\n settings,\n defaultRowGroupColumnId,\n localization\n ),\n\n []\n );\n\n if (internalColumns) {\n if (options.enableRowExpansion && props.rowExpansionRenderer && internalColumns.rowExpansion) {\n const column = createInternalColumn<TType>('__expansion', internalColumns.rowExpansion, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowSelection && internalColumns.rowSelection) {\n const column = createInternalColumn<TType>('__select', internalColumns.rowSelection, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowDrag && props.onRowDrag && internalColumns.rowDrag) {\n const column = createInternalColumn<TType>('__drag', internalColumns.rowDrag, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowActions && props.rowActions?.length && internalColumns.rowActions) {\n const column = createInternalColumn<TType>('__actions', internalColumns.rowActions, defaultSizing);\n columns.push(column);\n }\n }\n\n return { columns, defaultSizing, defaultSorting, defaultVisibility };\n}\n\nexport function configureReactTableOptions<TType = unknown>(\n options: TableFeatureProps<TType>,\n props: TableProps<TType>,\n localization: Localization\n) {\n // We don't want to expose internal Tanstack Table row, so we need to wrap enableRowSelection callback into additional function,\n // which receives the React Table Row object and passes row.original to a callback.\n const reactTableEnableRowSelection =\n typeof options.enableRowSelection === 'function'\n ? (row: ReactTableRow<TType>) => (options.enableRowSelection as (row: TType) => boolean)(row.original)\n : options.enableRowSelection;\n\n let getRowId;\n\n if (props.rowIdentityAccessor) {\n getRowId = (originalRow: TType | undefined, index: number) => {\n if (originalRow) {\n return String(originalRow[props.rowIdentityAccessor as keyof TType]);\n }\n\n return String(index);\n };\n }\n\n const tableOptions: Partial<ReactTableOptions<TType>> = {\n defaultColumn: {\n enableColumnFilter: options.enableFiltering || true,\n enableGrouping: false,\n enableHiding: options.enableColumnHiding || true,\n enableResizing: options.enableColumnResizing || true,\n enableGlobalFilter: options.enableSearch || true,\n enableSorting: options.enableSorting || true,\n minSize: 1,\n // the default is 150, which is a bit random\n size: 1,\n },\n enableColumnFilters: options.enableFiltering ?? false,\n enableColumnResizing: options.enableColumnResizing ?? false,\n enableExpanding: options.enableRowExpansion ?? false,\n enableGrouping: true, // users can't customise row grouping, so it can just be always enabled and left to the defaultRowGroupColumnId prop\n enableHiding: options.enableColumnHiding ?? false,\n enablePinning: options.enableColumnFreezing ?? false,\n enableRowPinning: true, // users can't customise row pinning, so it can just be always enabled\n enableRowSelection: reactTableEnableRowSelection ?? false,\n enableSorting: options.enableSorting ?? false,\n // models for default features\n getExpandedRowModel: getExpandedRowModel<TType>(),\n getGroupedRowModel: getGroupedRowModel<TType>(),\n getRowId,\n groupedColumnMode: false,\n keepPinnedRows: false,\n };\n\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n if (tableOptions.enableColumnFilters) {\n // enter controlled filter mode (controlled could be local state, but usually the server)\n if (props.onChangeFilter) {\n // tableOptions.manualFiltering = true;\n // we don't set it because it breaks global filtering (used for search, which is fully client side)\n //\n // tableOptions.onColumnFiltersChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onFilter\n } else {\n tableOptions.getFilteredRowModel = getFilteredRowModel<TType>();\n tableOptions.filterFns = {\n tacoFilter: (row: ReactTableRow<TType>, columnId: string, filter: any) =>\n columnFilterFn(row.getValue(columnId), filter),\n };\n }\n }\n\n if (options.enableSearch) {\n // always set these because enableGlobalFilter can be toggled on and off by the user\n tableOptions.getFilteredRowModel = getFilteredRowModel<TType>();\n tableOptions.globalFilterFn = (row: ReactTableRow<TType>, columnId: string, searchQuery: any) =>\n globalFilterFn(row, columnId, searchQuery, localization);\n tableOptions.getColumnCanGlobalFilter = (column: ReactTableColumn<TType>) =>\n column.columnDef.meta?.enableSearch !== false && column.getIsVisible();\n\n // enter controlled search mode (controlled could be local state, but usually the server)\n if (props.onChangeSearch) {\n if (props._experimentalDataLoader2) {\n tableOptions.manualFiltering = true;\n } else {\n // tableOptions.manualFiltering = true;\n // we don't set this because controlled search is not currently supported, search is always client side\n //\n // tableOptions.onGlobalFilterChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onSearch.\n //\n // we also don't always filter when searching, we have the highlight functionality as the default\n // and filtering can be toggled by the user\n }\n }\n }\n\n if (tableOptions.enableSorting) {\n // enter controlled sort mode (controlled could be local state, but usually the server)\n if (props.onChangeSort) {\n tableOptions.manualSorting = true;\n\n // tableOptions.onSortingChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onSort\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n return tableOptions;\n}\n\nexport function useReactTableInitialState<TType = unknown>(\n props: TableProps<TType>,\n columns: ReactTableColumnDef<TType>[],\n persistedSettings: TableSettings,\n defaults: {\n defaultSizing: ReactTableColumnSizingState;\n defaultSorting: ReactTableColumnSort[];\n defaultVisibility: ReactTableVisibilityState;\n }\n): Partial<ReactTableState> {\n return React.useMemo(() => {\n const ignoreNotDefinedColumns = (column: ReactTableColumnDef<TType>) =>\n columns.find(definedColumn => definedColumn.id === column.id);\n\n const columnPinning: ReactTableColumnPinningState =\n persistedSettings.columnPinning ?? props.defaultSettings?.columnPinning ?? {};\n\n const columnOrder = ensureOrdering<TType>(\n columns,\n persistedSettings.columnOrder ?? props.defaultSettings?.columnOrder,\n columnPinning.left\n );\n\n // ensure internal columns are pinned, and are pinned in the correct order\n if (columnPinning?.left?.length) {\n columnPinning.left = freezeUptoExternalColumn(\n columnOrder.indexOf(columnPinning.left[columnPinning.left.length - 1]),\n columnOrder\n );\n } else {\n if (props.defaultColumnFreezingIndex !== undefined) {\n const index =\n typeof props.defaultColumnFreezingIndex === 'function'\n ? props.defaultColumnFreezingIndex(persistedSettings)\n : props.defaultColumnFreezingIndex;\n\n if (index !== undefined) {\n columnPinning.left = freezeUptoExternalColumn(index, columnOrder);\n }\n } else {\n columnPinning.left = unfreezeAllExternalColumns(columnOrder);\n }\n }\n\n const state: Partial<ReactTableState> = {\n columnFilters: persistedSettings.columnFilters ?? props.defaultSettings?.columnFilters ?? [],\n columnOrder,\n columnPinning,\n columnSizing: ignoreInternalColumns(\n persistedSettings.columnSizing ?? props.defaultSettings?.columnSizing ?? defaults.defaultSizing ?? {}\n ),\n columnVisibility:\n persistedSettings.columnVisibility ?? props.defaultSettings?.columnVisibility ?? defaults.defaultVisibility ?? {},\n globalFilter: persistedSettings.searchQuery ?? props.defaultSettings?.searchQuery,\n sorting: persistedSettings.sorting\n ? persistedSettings.sorting.filter(ignoreNotDefinedColumns)\n : props.defaultSettings?.sorting ?? defaults.defaultSorting,\n };\n\n if (props.defaultRowGroupColumnId) {\n state.grouping = [props.defaultRowGroupColumnId as string];\n // row groups should (all) always be expanded by default\n state.expanded = true;\n }\n\n return state;\n }, []);\n}\n"],"names":["processChildren","child","columns","defaultSizing","defaultSorting","defaultVisibility","settings","defaultRowGroupColumnId","localization","columnHelper","createColumnHelper","React","isValidElement","props","children","id","header","push","group","Children","toArray","reduce","enableGrouping","accessor","_meta$align","untypedId","accessorKey","renderer","aggregate","footer","aggregationFn","defaultHidden","defaultWidth","enableEditing","control","enableFiltering","enableColumnFilter","enableHiding","enableOrdering","enablePrinting","enableResizing","enableSearch","enableGlobalFilter","enableSorting","enableTruncate","minWidth","minSize","getCellMinWidth","fontSize","sort","sortFn","meta","dataTypeProperties","getDataTypeProperties","dataType","isGrouped","undefined","desc","column","accessorFn","row","get","align","cell","info","getValue","original","getDisplayValue","dataTypeRenderer","value","displayValue","_dataTypeProperties$g","call","Array","isArray","_displayValue$","table","getRowModel","rows","flatMap","filterFn","aggregatedCell","sortingFn","getSortingFn","sortDescFirst","sortUndefined","createInternalColumn","size","mapTableChildrenToColumns","options","internalColumns","_props$rowActions","enableRowExpansion","rowExpansionRenderer","rowExpansion","unshift","enableRowSelection","rowSelection","enableRowDrag","onRowDrag","rowDrag","enableRowActions","rowActions","length","configureReactTableOptions","reactTableEnableRowSelection","getRowId","rowIdentityAccessor","originalRow","index","String","tableOptions","defaultColumn","enableColumnHiding","enableColumnResizing","enableColumnFilters","_options$enableFilter","_options$enableColumn","enableExpanding","_options$enableRowExp","_options$enableColumn2","enablePinning","_options$enableColumn3","enableColumnFreezing","enableRowPinning","_options$enableSortin","getExpandedRowModel","getGroupedRowModel","groupedColumnMode","keepPinnedRows","columnResizeMode","onChangeFilter","getFilteredRowModel","filterFns","tacoFilter","columnId","filter","columnFilterFn","globalFilterFn","searchQuery","getColumnCanGlobalFilter","_column$columnDef$met","columnDef","getIsVisible","onChangeSearch","_experimentalDataLoader2","manualFiltering","onChangeSort","manualSorting","getSortedRowModel","useReactTableInitialState","persistedSettings","defaults","useMemo","ignoreNotDefinedColumns","find","definedColumn","columnPinning","_ref","_persistedSettings$co","_props$defaultSetting","defaultSettings","columnOrder","ensureOrdering","_persistedSettings$co2","_props$defaultSetting2","left","_columnPinning$left","freezeUptoExternalColumn","indexOf","defaultColumnFreezingIndex","unfreezeAllExternalColumns","state","columnFilters","_ref2","_persistedSettings$co3","_props$defaultSetting3","columnSizing","ignoreInternalColumns","_ref3","_ref4","_persistedSettings$co4","_props$defaultSetting4","columnVisibility","_ref5","_ref6","_persistedSettings$co5","_props$defaultSetting5","globalFilter","_persistedSettings$se","_props$defaultSetting6","sorting","_props$defaultSetting7","_props$defaultSetting8","grouping","expanded"],"mappings":";;;;;;;;;;AA4BA;AACA,SAASA,eAAeA,CACpBC,KAAiE,EACjEC,OAAqC,EACrCC,aAA0C,EAC1CC,cAAsC,EACtCC,iBAA4C,EAC5CC,QAAuB,EACvBC,uBAAgD,EAChDC,YAA0B;EAE1B,MAAMC,YAAY,GAAGC,kBAAkB,EAAS;EAEhD,iBAAIC,cAAK,CAACC,cAAc,CAAkBX,KAAK,CAAC,IAAIA,KAAK,CAACY,KAAK,CAACC,QAAQ,EAAE;IACtE,MAAM;MAAEA,QAAQ;MAAEC,EAAE;MAAEC;KAAQ,GAAGf,KAAK,CAACY,KAAK;IAE5CX,OAAO,CAACe,IAAI,CACRR,YAAY,CAACS,KAAK,CAAC;MACfH,EAAE;MACFC,MAAM;MACNd,OAAO,EAAES,cAAK,CAACQ,QAAQ,CAACC,OAAO,CAACN,QAAQ,CAAC,CAACO,MAAM,CAC5C,CAACnB,OAAqC,EAAED,KAAK,KACzCD,eAAe,CACXC,KAAK,EACLC,OAAO,EACPC,aAAa,EACbC,cAAc,EACdC,iBAAiB,EACjBC,QAAQ,EACRC,uBAAuB,EACvBC,YAAY,CACf,EACL,EAAE,CACL;;MAEDc,cAAc,EAAE;KACnB,CAAC,CACL;GACJ,MAAM,iBAAIX,cAAK,CAACC,cAAc,CAA0BX,KAAK,CAAC,KAAKA,KAAK,CAACY,KAAK,CAACU,QAAQ,IAAItB,KAAK,CAAC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,uBAArBA,sBAAA,CAAuBJ,gBAAgB,cAAAE,KAAA,cAAAA,KAAA,GAAIjC,QAAQ,CAACnJ,iBAAiB,cAAAmL,KAAA,cAAAA,KAAA,GAAI,EAAE;MACrHI,YAAY,GAAAC,qBAAA,GAAEtC,iBAAiB,CAACZ,WAAW,cAAAkD,qBAAA,cAAAA,qBAAA,IAAAC,sBAAA,GAAIjL,KAAK,CAACoJ,eAAe,cAAA6B,sBAAA,uBAArBA,sBAAA,CAAuBnD,WAAW;MACjFoD,OAAO,EAAExC,iBAAiB,CAACwC,OAAO,GAC5BxC,iBAAiB,CAACwC,OAAO,CAACvD,MAAM,CAACkB,uBAAuB,CAAC,IAAAsC,sBAAA,IAAAC,sBAAA,GACzDpL,KAAK,CAACoJ,eAAe,cAAAgC,sBAAA,uBAArBA,sBAAA,CAAuBF,OAAO,cAAAC,sBAAA,cAAAA,sBAAA,GAAIxC,QAAQ,CAACpJ;KACpD;IAED,IAAIS,KAAK,CAACN,uBAAuB,EAAE;MAC/BqK,KAAK,CAACsB,QAAQ,GAAG,CAACrL,KAAK,CAACN,uBAAiC,CAAC;;MAE1DqK,KAAK,CAACuB,QAAQ,GAAG,IAAI;;IAGzB,OAAOvB,KAAK;GACf,EAAE,EAAE,CAAC;AACV;;;;"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function useTaco(): import("../components/Provider/TacoContext").Taco;
|
package/dist/index.css
CHANGED
@@ -350,6 +350,77 @@
|
|
350
350
|
stroke: currentColor;
|
351
351
|
}
|
352
352
|
|
353
|
+
/* Base styles */
|
354
|
+
[data-taco='checkbox-container'] [data-taco='checkbox'] {
|
355
|
+
@apply border-grey-500;
|
356
|
+
}
|
357
|
+
|
358
|
+
[data-taco='checkbox-container'][data-focus-visible] [data-taco='checkbox'] {
|
359
|
+
@apply yt-focus;
|
360
|
+
}
|
361
|
+
|
362
|
+
/* Readonly state */
|
363
|
+
[data-taco='checkbox-container'][data-readonly] [data-taco='checkbox'] {
|
364
|
+
@apply cursor-default;
|
365
|
+
}
|
366
|
+
|
367
|
+
/* Invalid state */
|
368
|
+
[data-taco='checkbox-container'][data-invalid] [data-taco='checkbox'] {
|
369
|
+
@apply border-red-500;
|
370
|
+
}
|
371
|
+
|
372
|
+
/* Selected or indeterminate state */
|
373
|
+
[data-taco='checkbox-container'][data-selected] [data-taco='checkbox'],
|
374
|
+
[data-taco='checkbox-container'][data-indeterminate] [data-taco='checkbox'] {
|
375
|
+
@apply border-blue-500 bg-blue-500;
|
376
|
+
}
|
377
|
+
|
378
|
+
/* Selected or indeterminate AND invalid state */
|
379
|
+
[data-taco='checkbox-container'][data-selected][data-invalid] [data-taco='checkbox'],
|
380
|
+
[data-taco='checkbox-container'][data-indeterminate][data-invalid] [data-taco='checkbox'] {
|
381
|
+
@apply !border-red-500 !bg-red-500;
|
382
|
+
}
|
383
|
+
|
384
|
+
/* Disabled state */
|
385
|
+
[data-taco='checkbox-container'][data-disabled] [data-taco='checkbox'] {
|
386
|
+
@apply border-grey-500/50 cursor-not-allowed;
|
387
|
+
}
|
388
|
+
|
389
|
+
[data-taco='checkbox-container'][data-disabled][data-invalid] [data-taco='checkbox'] {
|
390
|
+
@apply !border-red-500/50 !bg-red-500/50;
|
391
|
+
}
|
392
|
+
|
393
|
+
[data-taco='checkbox-container'][data-disabled][data-selected] [data-taco='checkbox'],
|
394
|
+
[data-taco='checkbox-container'][data-disabled][data-indeterminate] [data-taco='checkbox'] {
|
395
|
+
@apply !bg-blue-500/50;
|
396
|
+
}
|
397
|
+
|
398
|
+
[data-taco='checkbox-container'][data-disabled][data-selected][data-invalid] [data-taco='checkbox'],
|
399
|
+
[data-taco='checkbox-container'][data-disabled][data-indeterminate][data-invalid] [data-taco='checkbox'] {
|
400
|
+
@apply !bg-red-500/50 text-white;
|
401
|
+
}
|
402
|
+
|
403
|
+
/* Hover states (separate rules for clarity) */
|
404
|
+
[data-taco='checkbox-container']:hover:not([data-disabled]):not([data-readonly]) [data-taco='checkbox'] {
|
405
|
+
@apply border-grey-700;
|
406
|
+
}
|
407
|
+
|
408
|
+
[data-taco='checkbox-container']:hover[data-selected]:not([data-disabled]):not([data-readonly]) [data-taco='checkbox'],
|
409
|
+
[data-taco='checkbox-container']:hover[data-indeterminate]:not([data-disabled]):not([data-readonly]) [data-taco='checkbox'] {
|
410
|
+
@apply !border-blue-700 !bg-blue-700;
|
411
|
+
}
|
412
|
+
|
413
|
+
[data-taco='checkbox-container']:hover[data-invalid]:not([data-disabled]):not([data-readonly]) [data-taco='checkbox'] {
|
414
|
+
@apply !border-red-700;
|
415
|
+
}
|
416
|
+
|
417
|
+
[data-taco='checkbox-container']:hover[data-invalid][data-selected]:not([data-disabled]):not([data-readonly])
|
418
|
+
[data-taco='checkbox'],
|
419
|
+
[data-taco='checkbox-container']:hover[data-invalid][data-indeterminate]:not([data-disabled]):not([data-readonly])
|
420
|
+
[data-taco='checkbox'] {
|
421
|
+
@apply !border-red-700 !bg-red-700;
|
422
|
+
}
|
423
|
+
|
353
424
|
[data-taco='scrollable-list'].yt-list--multiselect li:first-child {
|
354
425
|
@apply border-grey-100 border-b-2 pl-4; /* Listbox max-height is dependant on this border-bottom-width value! */
|
355
426
|
}
|
@@ -824,7 +895,7 @@ table[data-taco^='table'] td[data-cell-truncate='true'] [data-taco='textarea'] {
|
|
824
895
|
@apply focus:absolute focus:overflow-y-auto;
|
825
896
|
}
|
826
897
|
|
827
|
-
table[data-taco^='table'] td label {
|
898
|
+
table[data-taco^='table'] td label:not([data-taco='checkbox-label']) {
|
828
899
|
@apply h-fit !min-h-fit w-full !pb-0;
|
829
900
|
}
|
830
901
|
|
@@ -863,14 +934,14 @@ table[data-taco^='table'][data-table-font-size='small'] td [data-taco='spinner']
|
|
863
934
|
@apply !h-4 !w-4;
|
864
935
|
}
|
865
936
|
|
866
|
-
table[data-taco^='table'][data-table-font-size='small'] td [data-taco='icon'],
|
937
|
+
table[data-taco^='table'][data-table-font-size='small'] td [data-taco='icon']:not([data-taco='checkbox'] *),
|
867
938
|
table[data-taco^='table'][data-table-font-size='small'] td [data-taco='spinner'] {
|
868
939
|
@apply !-my-[3px];
|
869
940
|
}
|
870
941
|
|
871
942
|
table[data-taco^='table'][data-table-font-size='small'] td [data-taco='badge'],
|
872
943
|
table[data-taco^='table'][data-table-font-size='small'] td [data-taco='badge-icon'],
|
873
|
-
table[data-taco^='table'][data-table-font-size='small'] td [data-taco='icon'],
|
944
|
+
table[data-taco^='table'][data-table-font-size='small'] td [data-taco='icon']:not([data-taco='checkbox'] *),
|
874
945
|
table[data-taco^='table'][data-table-font-size='small'] td [data-taco='spinner'] {
|
875
946
|
@apply !-my-0.5 !text-xs;
|
876
947
|
}
|
@@ -999,7 +1070,7 @@ table[data-taco^='table'][data-table-font-size='medium'] td [data-taco='icon-but
|
|
999
1070
|
@apply !-my-1.5;
|
1000
1071
|
}
|
1001
1072
|
|
1002
|
-
table[data-taco^='table'][data-table-font-size='medium'] td [data-taco='icon'] {
|
1073
|
+
table[data-taco^='table'][data-table-font-size='medium'] td [data-taco='icon']:not([data-taco='checkbox'] *) {
|
1003
1074
|
@apply !-my-0.5;
|
1004
1075
|
}
|
1005
1076
|
|
@@ -1084,7 +1155,7 @@ table[data-taco^='table'][data-table-font-size='large'] td [data-taco='icon-butt
|
|
1084
1155
|
@apply !-my-1;
|
1085
1156
|
}
|
1086
1157
|
|
1087
|
-
table[data-taco^='table'][data-table-font-size='large'] td [data-taco='icon'] {
|
1158
|
+
table[data-taco^='table'][data-table-font-size='large'] td [data-taco='icon']:not([data-taco='checkbox'] *) {
|
1088
1159
|
@apply !-my-0.5;
|
1089
1160
|
}
|
1090
1161
|
|
@@ -2,8 +2,8 @@ import React from 'react';
|
|
2
2
|
import { Table as ReactTable } from '@tanstack/react-table';
|
3
3
|
import { ScrollToOptions as ReactVirtualScrollToOptions } from '@tanstack/react-virtual';
|
4
4
|
import { useTableRenderers, useTableRenderOptions } from '../types';
|
5
|
-
import { TableRef } from '../../types';
|
6
|
-
export declare function useTableRenderer<TType = unknown>(renderers: useTableRenderers<TType>, table: ReactTable<TType>, tableRef: React.RefObject<TableRef>, length: number, defaultRowActiveIndex?:
|
5
|
+
import { TableRef, TableDefaultRowActiveIndex } from '../../types';
|
6
|
+
export declare function useTableRenderer<TType = unknown>(renderers: useTableRenderers<TType>, table: ReactTable<TType>, tableRef: React.RefObject<TableRef>, length: number, defaultRowActiveIndex?: TableDefaultRowActiveIndex | undefined, options?: useTableRenderOptions): {
|
7
7
|
rows: (JSX.Element | null)[] | null;
|
8
8
|
style: React.CSSProperties;
|
9
9
|
scrollToIndex: (index: number, options?: ReactVirtualScrollToOptions) => void;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { Table as ReactTable, TableMeta as ReactTableMeta, TableState as ReactTableState } from '@tanstack/react-table';
|
3
3
|
import { ScrollToOptions as ReactVirtualScrollToOptions } from '@tanstack/react-virtual';
|
4
|
-
import { TableCustomSettingsRenderer, TableEmptyStateRenderer, TableProps } from '../types';
|
4
|
+
import { TableCustomSettingsRenderer, TableEmptyStateRenderer, TableProps, TableToolbarRenderer } from '../types';
|
5
5
|
import { TableRef } from '../types';
|
6
6
|
import { useTableRenderers, useTableRenderOptions } from './types';
|
7
7
|
export declare type useTableReturnValue<TType = unknown> = {
|
@@ -11,9 +11,9 @@ export declare type useTableReturnValue<TType = unknown> = {
|
|
11
11
|
props: {
|
12
12
|
customSettings: TableCustomSettingsRenderer | undefined;
|
13
13
|
emptyState: TableEmptyStateRenderer | undefined;
|
14
|
-
toolbarLeft:
|
15
|
-
toolbarPanel:
|
16
|
-
toolbarRight:
|
14
|
+
toolbarLeft: TableToolbarRenderer | undefined;
|
15
|
+
toolbarPanel: TableToolbarRenderer | undefined;
|
16
|
+
toolbarRight: TableToolbarRenderer | undefined;
|
17
17
|
};
|
18
18
|
ref: React.RefObject<TableRef>;
|
19
19
|
renderer: {
|
@@ -102,6 +102,12 @@ export declare type TableEmptyStateRenderer = (props: {
|
|
102
102
|
}) => JSX.Element | null;
|
103
103
|
export declare type TableEvent = 'editing-mode';
|
104
104
|
export declare type TableEventHandler = (event: TableEvent, data?: object) => void;
|
105
|
+
export declare type TablePrintSettings = {
|
106
|
+
allRows: boolean;
|
107
|
+
orientation: 'portrait' | 'landscape';
|
108
|
+
size: 'A3' | 'A4' | 'A5' | 'letter' | 'legal';
|
109
|
+
splitGroups: boolean;
|
110
|
+
};
|
105
111
|
export declare type TableSettings = {
|
106
112
|
columnFilters?: ReactTableColumnFilterState;
|
107
113
|
columnOrder?: ReactTableColumnOrderState;
|
@@ -110,6 +116,7 @@ export declare type TableSettings = {
|
|
110
116
|
columnVisibility?: ReactTableColumnVisibilityState;
|
111
117
|
excludeUnmatchedRecordsInSearch?: boolean;
|
112
118
|
fontSize?: TableFontSize;
|
119
|
+
print?: TablePrintSettings;
|
113
120
|
rowHeight?: TableRowHeight;
|
114
121
|
searchQuery?: string;
|
115
122
|
sorting?: ReactTableSortingState;
|
@@ -150,13 +157,16 @@ export declare type TableFeatureProps<TType = unknown> = {
|
|
150
157
|
enableSaveSettings?: boolean | Partial<TableEnableSettingsOptions>;
|
151
158
|
};
|
152
159
|
export declare type TableChild = JSX.Element | boolean | null | undefined;
|
160
|
+
export declare type TableToolbarRenderer = JSX.Element | ((settings: TableSettings) => JSX.Element);
|
161
|
+
export declare type TableDefaultColumnFreezingIndex = number | ((settings: TableSettings) => number | undefined);
|
162
|
+
export declare type TableDefaultRowActiveIndex = number | ((settings: TableSettings) => number | undefined);
|
153
163
|
export declare type TableCommonProps<TType = unknown> = TableFeatureProps<TType> & {
|
154
164
|
children: TableChild | TableChild[];
|
155
165
|
data: TType[];
|
156
166
|
id: string;
|
157
167
|
customSettings?: TableCustomSettingsRenderer;
|
158
|
-
defaultColumnFreezingIndex?:
|
159
|
-
defaultRowActiveIndex?:
|
168
|
+
defaultColumnFreezingIndex?: TableDefaultColumnFreezingIndex;
|
169
|
+
defaultRowActiveIndex?: TableDefaultRowActiveIndex;
|
160
170
|
defaultRowGroupColumnId?: keyof TType;
|
161
171
|
defaultSettings?: TableSettings;
|
162
172
|
emptyState?: TableEmptyStateRenderer;
|
@@ -167,9 +177,9 @@ export declare type TableCommonProps<TType = unknown> = TableFeatureProps<TType>
|
|
167
177
|
rowExpansionRenderer?: TableRowExpansionRenderer<TType>;
|
168
178
|
rowIdentityAccessor?: keyof TType;
|
169
179
|
shortcuts?: TableShortcuts<TType>;
|
170
|
-
toolbarLeft?:
|
171
|
-
toolbarRight?:
|
172
|
-
toolbarPanel?:
|
180
|
+
toolbarLeft?: TableToolbarRenderer;
|
181
|
+
toolbarRight?: TableToolbarRenderer;
|
182
|
+
toolbarPanel?: TableToolbarRenderer;
|
173
183
|
onEvent?: TableEventHandler;
|
174
184
|
onRowClick?: TableRowClickHandler<TType>;
|
175
185
|
onRowDrag?: TableRowDragHandler<TType>;
|
@@ -178,8 +188,8 @@ export declare type TableCommonProps<TType = unknown> = TableFeatureProps<TType>
|
|
178
188
|
onRowSelect?: TableRowSelectHandler<TType>;
|
179
189
|
onChangeFilter?: TableFilterHandler;
|
180
190
|
onChangeSearch?: TableSearchHandler;
|
181
|
-
onChangeSettings?: TableSettingsHandler;
|
182
191
|
onChangeSort?: TableSortHandler;
|
192
|
+
_DEPRECATED_DO_NOT_USE_onChangeSettings?: TableSettingsHandler;
|
183
193
|
};
|
184
194
|
export interface TableClientProps<TType = unknown> extends TableCommonProps<TType> {
|
185
195
|
length?: never;
|
@@ -1,15 +1,9 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
|
3
|
-
allRows: boolean;
|
4
|
-
orientation: 'portrait' | 'landscape';
|
5
|
-
size: 'A3' | 'A4' | 'A5' | 'letter' | 'legal';
|
6
|
-
splitGroups: boolean;
|
7
|
-
};
|
2
|
+
import { TablePrintSettings } from '../../types';
|
8
3
|
export declare function useTablePrinting(isEnabled: boolean | undefined, tableId: string): {
|
9
4
|
isEnabled: boolean;
|
10
5
|
isPrinting: boolean;
|
11
6
|
setIsPrinting: React.Dispatch<React.SetStateAction<boolean>>;
|
12
7
|
settings: TablePrintSettings;
|
13
|
-
setSetting: (
|
8
|
+
setSetting: (path: keyof TablePrintSettings, value: any) => void;
|
14
9
|
};
|
15
|
-
export {};
|