@economic/taco 2.27.2 → 2.27.3
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/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js +2 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Search/Search.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Search/Search.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/useTableDataLoader.js +12 -45
- package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js +3 -7
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableServerLoadingListener.js +2 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableServerLoadingListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
- package/dist/primitives/Table/types.d.ts +7 -6
- package/dist/primitives/Table/useTableDataLoader.d.ts +4 -5
- package/dist/primitives/Table/useTableManager/listeners/useTableSearchListener.d.ts +1 -2
- package/dist/taco.cjs.development.js +23 -59
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +2 -2
|
@@ -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 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';\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 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 rowIdentityColumnId?: string;\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 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\nexport function useTableManager<TType = unknown, TMeta = {}>(\n props: TableProps<TType>,\n meta?: Partial<ReactTableMeta<TType>> & TMeta,\n internalColumns?: useTableManagerInternalColumns<TType>\n) {\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 // 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, props.onRowDrag);\n const rowDrop = useTableRowDrop<TType>(options.enableRowDrop, props.onRowDrop);\n const rowExpansion = useTableRowExpansion<TType>(options.enableRowExpansion, props.rowExpansionRenderer);\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, settings.excludeUnmatchedRecordsInSearch);\n const server = useTableServerLoading(props.loadPage, props.loadAll, props.pageSize);\n\n // TODO: memoise\n // convert jsx column components into valid table columns\n const { columns, ...defaultState } = mapTableChildrenToColumns<TType>(props, settings, options, internalColumns);\n\n // configure initial table state\n const initialState = useReactTableInitialState<TType>(props, columns, settings, defaultState);\n\n // ensure data is always valid\n const data = props.data ?? [];\n const length = props.length ?? data.length;\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),\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 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 rowIdentityColumnId: props.rowIdentityColumnId,\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);\n useTableFilterListener(instance, props.onChangeFilter);\n useTableFontSizeListener(instance);\n useTableRowHeightListener(instance);\n useTableRowSelectionListener(instance, props.onRowSelect);\n useTableSearchListener(instance, props.onChangeSearch);\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":["useTableManager","props","meta","internalColumns","safeId","id","replace","options","getTableFeaturePreset","settings","setSettings","useTableSettings","enableSaveSettings","defaultSettings","onChangeSettings","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","onRowDrag","rowDrop","useTableRowDrop","enableRowDrop","onRowDrop","rowExpansion","useTableRowExpansion","enableRowExpansion","rowExpansionRenderer","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowGroups","useTableRowGroups","rowActionsForGroup","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","search","useTableSearch","enableSearch","excludeUnmatchedRecordsInSearch","server","useTableServerLoading","loadPage","loadAll","pageSize","columns","defaultState","mapTableChildrenToColumns","initialState","useReactTableInitialState","data","_props$data","length","_props$length","instance","useReactTable","getCoreRowModel","configureReactTableOptions","enableGlobalFilter","rowIdentityColumnId","useTableDataListener","useTableFilterListener","onChangeFilter","useTableFontSizeListener","useTableRowHeightListener","useTableRowSelectionListener","onRowSelect","useTableSearchListener","onChangeSearch","useTableServerLoadingListener","useTableSettingsListener","useTableShortcutsListener","shortcuts","useTableSortingListener","onChangeSort","_instance$options$met","state","getState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA8FgBA,eAAeA,CAC3BC,KAAwB,EACxBC,IAA6C,EAC7CC,eAAuD;;;EAGvD,MAAMC,MAAM,GAAGH,KAAK,CAACI,EAAE,CAACC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;;EAEzC,MAAMC,OAAO,GAAGC,qBAAqB,CAACP,KAAK,CAAC;;EAG5C,MAAM,CAACQ,QAAQ,EAAEC,WAAW,CAAC,GAAGC,gBAAgB,CAC5CJ,OAAO,CAACK,kBAAkB,EAC1BR,MAAM,EACNH,KAAK,CAACY,eAAe,EACrBZ,KAAK,CAACa,gBAAg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,OAAc;MACvBI,YAAY,EAAEA,YAAmB;MACjCwC,mBAAmB,EAAEzF,KAAK,CAACyF,mBAAmB;MAC9CpC,OAAO;MACPI,SAAS,EAAEA,SAAgB;MAC3BG,SAAS;MACTG,YAAY;MACZG,MAAM;MACNI;;GAEP,CAAC;;EAGFoB,oBAAoB,CAACN,QAAQ,CAAC;EAC9BO,sBAAsB,CAACP,QAAQ,EAAEpF,KAAK,CAAC4F,cAAc,CAAC;EACtDC,wBAAwB,CAACT,QAAQ,CAAC;EAClCU,yBAAyB,CAACV,QAAQ,CAAC;EACnCW,4BAA4B,CAACX,QAAQ,EAAEpF,KAAK,CAACgG,WAAW,CAAC;EACzDC,sBAAsB,CAACb,QAAQ,EAAEpF,KAAK,CAACkG,cAAc,CAAC;EACtDC,6BAA6B,CAACf,QAAQ,EAAEd,MAAM,CAACE,QAAQ,CAAC;EACxD4B,wBAAwB,CAAChB,QAAQ,EAAE3E,WAAW,CAAC;EAC/C4F,yBAAyB,CAACjB,QAAQ,EAAEpF,KAAK,CAACsG,SAAS,CAAC;EACpDC,uBAAuB,CAACnB,QAAQ,EAAEpF,KAAK,CAACwG,YAAY,CAAC;EAErD,OAAO;IACHpG,EAAE,EAAED,MAAM;IACViF,QAAQ;IACRnF,IAAI,GAAAwG,qBAAA,GAAGrB,QAAQ,CAAC9E,OAAO,CAACL,IAAI,cAAAwG,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 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';\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 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 rowIdentityColumnId?: string;\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 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\nexport function useTableManager<TType = unknown, TMeta = {}>(\n props: TableProps<TType>,\n meta?: Partial<ReactTableMeta<TType>> & TMeta,\n internalColumns?: useTableManagerInternalColumns<TType>\n) {\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 // 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, props.onRowDrag);\n const rowDrop = useTableRowDrop<TType>(options.enableRowDrop, props.onRowDrop);\n const rowExpansion = useTableRowExpansion<TType>(options.enableRowExpansion, props.rowExpansionRenderer);\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, settings.excludeUnmatchedRecordsInSearch);\n const server = useTableServerLoading(props.loadPage, props.loadAll, props.pageSize);\n\n // TODO: memoise\n // convert jsx column components into valid table columns\n const { columns, ...defaultState } = mapTableChildrenToColumns<TType>(props, settings, options, internalColumns);\n\n // configure initial table state\n const initialState = useReactTableInitialState<TType>(props, columns, settings, defaultState);\n\n // ensure data is always valid\n const data = props.data ?? [];\n const length = props.length ?? data.length;\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),\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 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 rowIdentityColumnId: props.rowIdentityColumnId,\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);\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":["useTableManager","props","meta","internalColumns","safeId","id","replace","options","getTableFeaturePreset","settings","setSettings","useTableSettings","enableSaveSettings","defaultSettings","onChangeSettings","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","onRowDrag","rowDrop","useTableRowDrop","enableRowDrop","onRowDrop","rowExpansion","useTableRowExpansion","enableRowExpansion","rowExpansionRenderer","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowGroups","useTableRowGroups","rowActionsForGroup","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","search","useTableSearch","enableSearch","excludeUnmatchedRecordsInSearch","server","useTableServerLoading","loadPage","loadAll","pageSize","columns","defaultState","mapTableChildrenToColumns","initialState","useReactTableInitialState","data","_props$data","length","_props$length","instance","useReactTable","getCoreRowModel","configureReactTableOptions","enableGlobalFilter","rowIdentityColumnId","useTableDataListener","useTableFilterListener","onChangeFilter","useTableFontSizeListener","useTableRowHeightListener","useTableRowSelectionListener","onRowSelect","useTableSearchListener","useTableServerLoadingListener","useTableSettingsListener","useTableShortcutsListener","shortcuts","useTableSortingListener","onChangeSort","_instance$options$met","state","getState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA8FgBA,eAAeA,CAC3BC,KAAwB,EACxBC,IAA6C,EAC7CC,eAAuD;;;EAGvD,MAAMC,MAAM,GAAGH,KAAK,CAACI,EAAE,CAACC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;;EAEzC,MAAMC,OAAO,GAAGC,qBAAqB,CAACP,KAAK,CAAC;;EAG5C,MAAM,CAACQ,QAAQ,EAAEC,WAAW,CAAC,GAAGC,gBAAgB,CAC5CJ,OAAO,CAACK,kBAAkB,EAC1BR,MAAM,EACNH,KAAK,CAACY,eAAe,EACrBZ,KAAK,CAACa,gBAAgB,CACzB;;EAGD,MAAMC,cAAc,GAAGC,sBAAsB,CAACT,OAAO,CAACU,oBAAoB,CAAC;EAC3E,MAAMC,cAAc,GAAGC,sBAAsB,CAACZ,OAAO,CAACa,oBAAoB,CAAC;EAC3E,MAAMC,QAAQ,GAAGC,gBAAgB,CAACf,OAAO,CAACgB,cAAc,EAAEd,QAAQ,CAACY,QAAQ,CAAC;EAC5E,MAAMG,MAAM,GAAGC,cAAc,CAAClB,OAAO,CAACmB,YAAY,CAAC;EACnD,MAAMC,QAAQ,GAAGC,gBAAgB,CAACrB,OAAO,CAACsB,cAAc,EAAEzB,MAAM,CAAC;EACjE,MAAM0B,SAAS,GAAGC,iBAAiB,CAACxB,OAAO,CA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,CAAC;EAChCc,6BAA6B,CAACd,QAAQ,EAAEd,MAAM,CAACE,QAAQ,CAAC;EACxD2B,wBAAwB,CAACf,QAAQ,EAAE3E,WAAW,CAAC;EAC/C2F,yBAAyB,CAAChB,QAAQ,EAAEpF,KAAK,CAACqG,SAAS,CAAC;EACpDC,uBAAuB,CAAClB,QAAQ,EAAEpF,KAAK,CAACuG,YAAY,CAAC;EAErD,OAAO;IACHnG,EAAE,EAAED,MAAM;IACViF,QAAQ;IACRnF,IAAI,GAAAuG,qBAAA,GAAGpB,QAAQ,CAAC9E,OAAO,CAACL,IAAI,cAAAuG,qBAAA,cAAAA,qBAAA,GAAI,EAAoC;IACpEC,KAAK,EAAErB,QAAQ,CAACsB,QAAQ;GAC3B;AACL;;;;"}
|
|
@@ -3,6 +3,7 @@ import { ColumnFilter as ReactTableColumnFilter, ColumnFiltersState as ReactTabl
|
|
|
3
3
|
import { FontSize, FontSizes, ValueOf } from '../../types';
|
|
4
4
|
import { MenuProps } from '../../components/Menu/Menu';
|
|
5
5
|
import { MenuItemProps } from '../../components/Menu/components/Item';
|
|
6
|
+
declare type TODO = any;
|
|
6
7
|
export declare type TableRef = HTMLTableElement & {
|
|
7
8
|
instance: {
|
|
8
9
|
resetFiltering: () => void;
|
|
@@ -80,16 +81,15 @@ export declare type TableShortcutHandlerObject<TType = unknown> = {
|
|
|
80
81
|
meta?: boolean;
|
|
81
82
|
shift?: boolean;
|
|
82
83
|
};
|
|
83
|
-
export declare type TableFilterHandler = (filters: TableColumnFilter[]) => void
|
|
84
|
+
export declare type TableFilterHandler = (filters: TableColumnFilter[]) => void;
|
|
84
85
|
export declare type TableFontSize = keyof typeof FontSizes;
|
|
85
86
|
export declare type TablePreset = 'complex' | 'list' | 'simple';
|
|
86
87
|
export declare type TableRowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;
|
|
87
88
|
export declare type TableScrollToIndexHandler = (index: number, options?: {
|
|
88
89
|
align: 'start' | 'center' | 'end' | 'auto';
|
|
89
90
|
}) => void;
|
|
90
|
-
export declare type
|
|
91
|
-
export declare type
|
|
92
|
-
export declare type TableServerLoadAllHandler = (sorting: TableColumnSort[], filters: TableColumnFilter[]) => Promise<void>;
|
|
91
|
+
export declare type TableServerLoadPageHandler = (pageIndex: number, sorting: TableColumnSort[], filters: TableColumnFilter[], search: string | undefined) => Promise<void>;
|
|
92
|
+
export declare type TableServerLoadAllHandler = (sorting: TableColumnSort[], filters: TableColumnFilter[], search: string | undefined) => Promise<void>;
|
|
93
93
|
export declare enum TableServerLoadAllState {
|
|
94
94
|
Incomplete = 0,
|
|
95
95
|
Loading = 1,
|
|
@@ -97,7 +97,7 @@ export declare enum TableServerLoadAllState {
|
|
|
97
97
|
}
|
|
98
98
|
export declare type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;
|
|
99
99
|
export declare type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;
|
|
100
|
-
export declare type TableSortHandler = (sorting: TableColumnSort[]) => void
|
|
100
|
+
export declare type TableSortHandler = (sorting: TableColumnSort[]) => void;
|
|
101
101
|
export declare type TableCustomSettingsRenderer = (props: TableSettings) => React.ReactElement<MenuItemProps>[];
|
|
102
102
|
export declare type TableEmptyStateRenderer = () => JSX.Element | null;
|
|
103
103
|
export declare type TableSettings = {
|
|
@@ -172,7 +172,7 @@ export declare type TableCommonProps<TType = unknown> = TableFeatureProps & {
|
|
|
172
172
|
onRowGoto?: TableRowGotoHandler;
|
|
173
173
|
onRowSelect?: TableRowSelectHandler<TType>;
|
|
174
174
|
onChangeFilter?: TableFilterHandler;
|
|
175
|
-
onChangeSearch?:
|
|
175
|
+
onChangeSearch?: TODO;
|
|
176
176
|
onChangeSettings?: TableSettingsHandler;
|
|
177
177
|
onChangeSort?: TableSortHandler;
|
|
178
178
|
};
|
|
@@ -374,3 +374,4 @@ export declare type TableTexts = {
|
|
|
374
374
|
tooltip: string;
|
|
375
375
|
};
|
|
376
376
|
};
|
|
377
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { TableColumnFilter, TableColumnSort, TableFilterHandler, TableServerLoadPageHandler, TableServerLoadAllHandler, TableSortHandler
|
|
1
|
+
import { TableColumnFilter, TableColumnSort, TableFilterHandler, TableServerLoadPageHandler, TableServerLoadAllHandler, TableSortHandler } from './types';
|
|
2
2
|
export declare const DEFAULT_PAGE_SIZE = 100;
|
|
3
|
-
export declare type useTableDataPageFetcher<TType = unknown> = (pageIndex: number, pageSize: number, sorting: TableColumnSort[], filters: TableColumnFilter[]) => Promise<{
|
|
3
|
+
export declare type useTableDataPageFetcher<TType = unknown> = (pageIndex: number, pageSize: number, sorting: TableColumnSort[], filters: TableColumnFilter[], search: string | undefined) => Promise<{
|
|
4
4
|
data: TType[];
|
|
5
5
|
length: number;
|
|
6
6
|
}>;
|
|
7
|
-
export declare type useTableDataAllFetcher<TType = unknown> = (sorting: TableColumnSort[], filters: TableColumnFilter[]) => Promise<{
|
|
7
|
+
export declare type useTableDataAllFetcher<TType = unknown> = (sorting: TableColumnSort[], filters: TableColumnFilter[], search: string | undefined) => Promise<{
|
|
8
8
|
data: TType[];
|
|
9
9
|
length: number;
|
|
10
10
|
}>;
|
|
@@ -17,8 +17,7 @@ export declare type useTableDataLoaderValues<TType = unknown> = {
|
|
|
17
17
|
loadAll: TableServerLoadAllHandler;
|
|
18
18
|
loadPage: TableServerLoadPageHandler;
|
|
19
19
|
onChangeFilter: TableFilterHandler;
|
|
20
|
-
onChangeSearch: TableSearchHandler;
|
|
21
20
|
onChangeSort: TableSortHandler;
|
|
22
21
|
pageSize: number;
|
|
23
22
|
};
|
|
24
|
-
export declare function useTableDataLoader<TType = unknown>(
|
|
23
|
+
export declare function useTableDataLoader<TType = unknown>(fetch: useTableDataPageFetcher<TType>, fetchAll: useTableDataAllFetcher<TType>, options?: useTableDataLoaderOptions): [useTableDataLoaderValues<TType>, () => void];
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { Table as ReactTable } from '@tanstack/react-table';
|
|
2
|
-
|
|
3
|
-
export declare function useTableSearchListener<TType = unknown>(table: ReactTable<TType>, onChangeSearch?: TableSearchHandler): void;
|
|
2
|
+
export declare function useTableSearchListener<TType = unknown>(table: ReactTable<TType>): void;
|
|
@@ -10325,7 +10325,7 @@ function _finallyRethrows(body, finalizer) {
|
|
|
10325
10325
|
}
|
|
10326
10326
|
|
|
10327
10327
|
const DEFAULT_PAGE_SIZE = 100;
|
|
10328
|
-
function useTableDataLoader(
|
|
10328
|
+
function useTableDataLoader(fetch, fetchAll, options = {
|
|
10329
10329
|
pageSize: DEFAULT_PAGE_SIZE
|
|
10330
10330
|
}) {
|
|
10331
10331
|
const {
|
|
@@ -10341,11 +10341,11 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
|
|
|
10341
10341
|
const _lastUsedFilters = React__default.useRef([]);
|
|
10342
10342
|
const _lastUsedSearch = React__default.useRef();
|
|
10343
10343
|
const _forceReset = React__default.useRef(false);
|
|
10344
|
-
const loadPage = function (pageIndex, sorting, filters) {
|
|
10344
|
+
const loadPage = function (pageIndex, sorting, filters, search) {
|
|
10345
10345
|
try {
|
|
10346
10346
|
let reset = false;
|
|
10347
10347
|
// sorting or filters changed, reset everything
|
|
10348
|
-
if (_forceReset.current || JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) || JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current)) {
|
|
10348
|
+
if (_forceReset.current || search !== _lastUsedSearch.current || JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) || JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current)) {
|
|
10349
10349
|
_pendingPageRequests.current = {};
|
|
10350
10350
|
// nuke the dataset so that we "start again" after sorting
|
|
10351
10351
|
reset = true;
|
|
@@ -10361,9 +10361,11 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
|
|
|
10361
10361
|
_lastUsedSorting.current = sorting;
|
|
10362
10362
|
// set the filters so we can track if it changed between loads
|
|
10363
10363
|
_lastUsedFilters.current = filters;
|
|
10364
|
+
// set the search so we can track if it changed between loads
|
|
10365
|
+
_lastUsedSearch.current = search;
|
|
10364
10366
|
const _temp = _finallyRethrows(function () {
|
|
10365
10367
|
return _catch(function () {
|
|
10366
|
-
return Promise.resolve(
|
|
10368
|
+
return Promise.resolve(fetch(pageIndex, pageSize, sorting, filters, search)).then(function (response) {
|
|
10367
10369
|
// update state, here we do some "magic" to support "load in place"
|
|
10368
10370
|
setData(currentData => {
|
|
10369
10371
|
let nextData;
|
|
@@ -10392,14 +10394,10 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
|
|
|
10392
10394
|
return Promise.reject(e);
|
|
10393
10395
|
}
|
|
10394
10396
|
};
|
|
10395
|
-
const loadAll = function (sorting, filters) {
|
|
10397
|
+
const loadAll = function (sorting, filters, search) {
|
|
10396
10398
|
try {
|
|
10397
|
-
// set the sorting so we can track if it changed between loads
|
|
10398
|
-
_lastUsedSorting.current = sorting;
|
|
10399
|
-
// set the filters so we can track if it changed between loads
|
|
10400
|
-
_lastUsedFilters.current = filters;
|
|
10401
10399
|
const _temp2 = _catch(function () {
|
|
10402
|
-
return Promise.resolve(fetchAll(sorting, filters)).then(function (response) {
|
|
10400
|
+
return Promise.resolve(fetchAll(sorting, filters, search)).then(function (response) {
|
|
10403
10401
|
length.current = response.length;
|
|
10404
10402
|
setData(() => {
|
|
10405
10403
|
let nextData;
|
|
@@ -10421,52 +10419,22 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
|
|
|
10421
10419
|
const invalidate = function () {
|
|
10422
10420
|
try {
|
|
10423
10421
|
_forceReset.current = true;
|
|
10424
|
-
return loadPage(0, _lastUsedSorting.current, _lastUsedFilters.current);
|
|
10422
|
+
return loadPage(0, _lastUsedSorting.current, _lastUsedFilters.current, _lastUsedSearch.current);
|
|
10425
10423
|
} catch (e) {
|
|
10426
10424
|
return Promise.reject(e);
|
|
10427
10425
|
}
|
|
10428
10426
|
};
|
|
10429
|
-
//
|
|
10430
|
-
// if a search is currently "active", we need to re load all because
|
|
10427
|
+
// we reset the page to 0 whenever sorting, filtering or search changes
|
|
10431
10428
|
const handleSort = function (sorting) {
|
|
10432
10429
|
try {
|
|
10433
|
-
|
|
10434
|
-
_lastUsedSorting.current = sorting;
|
|
10435
|
-
if (_lastUsedSearch.current) {
|
|
10436
|
-
// we're searching, which means we need to refetch all with the correct sorting applied
|
|
10437
|
-
loadAll(sorting, _lastUsedFilters.current);
|
|
10438
|
-
} else {
|
|
10439
|
-
// reset the page to 0 whenever sorting
|
|
10440
|
-
loadPage(0, sorting, _lastUsedFilters.current);
|
|
10441
|
-
}
|
|
10442
|
-
return Promise.resolve();
|
|
10430
|
+
return loadPage(0, sorting, _lastUsedFilters.current, _lastUsedSearch.current);
|
|
10443
10431
|
} catch (e) {
|
|
10444
10432
|
return Promise.reject(e);
|
|
10445
10433
|
}
|
|
10446
10434
|
};
|
|
10447
10435
|
const handleFilter = function (filters) {
|
|
10448
10436
|
try {
|
|
10449
|
-
|
|
10450
|
-
_lastUsedFilters.current = filters;
|
|
10451
|
-
if (_lastUsedSearch.current) {
|
|
10452
|
-
// we're searching, which means we need to refetch all with the correct sorting applied
|
|
10453
|
-
loadAll(_lastUsedSorting.current, filters);
|
|
10454
|
-
} else {
|
|
10455
|
-
// reset the page to 0 whenever sorting
|
|
10456
|
-
loadPage(0, _lastUsedSorting.current, filters);
|
|
10457
|
-
}
|
|
10458
|
-
return Promise.resolve();
|
|
10459
|
-
} catch (e) {
|
|
10460
|
-
return Promise.reject(e);
|
|
10461
|
-
}
|
|
10462
|
-
};
|
|
10463
|
-
const handleSearch = function (search) {
|
|
10464
|
-
try {
|
|
10465
|
-
// set the search so we can track if it changed between loads
|
|
10466
|
-
_lastUsedSearch.current = search || undefined;
|
|
10467
|
-
// search works client side, and focusing the search field triggers a load of all so we don't actually
|
|
10468
|
-
// want to load anything when search gets changed, we just store the value for other handlers
|
|
10469
|
-
return Promise.resolve();
|
|
10437
|
+
return loadPage(0, _lastUsedSorting.current, filters, _lastUsedSearch.current);
|
|
10470
10438
|
} catch (e) {
|
|
10471
10439
|
return Promise.reject(e);
|
|
10472
10440
|
}
|
|
@@ -10477,7 +10445,6 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
|
|
|
10477
10445
|
loadAll,
|
|
10478
10446
|
loadPage,
|
|
10479
10447
|
onChangeFilter: handleFilter,
|
|
10480
|
-
onChangeSearch: handleSearch,
|
|
10481
10448
|
onChangeSort: handleSort,
|
|
10482
10449
|
pageSize
|
|
10483
10450
|
}, invalidate];
|
|
@@ -10768,18 +10735,14 @@ function resetHighlightedColumnIndexes(value, table) {
|
|
|
10768
10735
|
return firstRowIndex;
|
|
10769
10736
|
}
|
|
10770
10737
|
|
|
10771
|
-
function useTableSearchListener(table
|
|
10738
|
+
function useTableSearchListener(table) {
|
|
10772
10739
|
const meta = table.options.meta;
|
|
10773
10740
|
// recalculates highlighted indexes whenever something important changes
|
|
10774
10741
|
React__default.useEffect(() => {
|
|
10775
10742
|
if (meta.search.isEnabled) {
|
|
10776
|
-
|
|
10777
|
-
resetHighlightedColumnIndexes(query, table);
|
|
10778
|
-
if (typeof onChangeSearch === 'function') {
|
|
10779
|
-
onChangeSearch(query);
|
|
10780
|
-
}
|
|
10743
|
+
resetHighlightedColumnIndexes(table.getState().globalFilter, table);
|
|
10781
10744
|
}
|
|
10782
|
-
}, [meta.server.loadAllStatus, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length, table.getState().globalFilter, JSON.stringify(table.getState().sorting), JSON.stringify(table.getState().columnVisibility)
|
|
10745
|
+
}, [meta.server.loadAllStatus, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length, table.getState().globalFilter, JSON.stringify(table.getState().sorting), JSON.stringify(table.getState().columnVisibility)]);
|
|
10783
10746
|
}
|
|
10784
10747
|
|
|
10785
10748
|
function useTableSettingsListener(table, onChangeSettings) {
|
|
@@ -10865,10 +10828,11 @@ function useTableSortingListener(table, onSort) {
|
|
|
10865
10828
|
function useTableServerLoadingListener(table, loadPage) {
|
|
10866
10829
|
const sorting = table.getState().sorting;
|
|
10867
10830
|
const columnFilters = table.getState().columnFilters;
|
|
10831
|
+
const search = table.getState().globalFilter;
|
|
10868
10832
|
// trigger load of the first page on mount
|
|
10869
10833
|
React__default.useEffect(() => {
|
|
10870
10834
|
if (loadPage) {
|
|
10871
|
-
loadPage(0, sorting, columnFilters);
|
|
10835
|
+
loadPage(0, sorting, columnFilters, search);
|
|
10872
10836
|
}
|
|
10873
10837
|
}, []);
|
|
10874
10838
|
}
|
|
@@ -10969,7 +10933,7 @@ function useTableManager(props, meta, internalColumns) {
|
|
|
10969
10933
|
useTableFontSizeListener(instance);
|
|
10970
10934
|
useTableRowHeightListener(instance);
|
|
10971
10935
|
useTableRowSelectionListener(instance, props.onRowSelect);
|
|
10972
|
-
useTableSearchListener(instance
|
|
10936
|
+
useTableSearchListener(instance);
|
|
10973
10937
|
useTableServerLoadingListener(instance, server.loadPage);
|
|
10974
10938
|
useTableSettingsListener(instance, setSettings);
|
|
10975
10939
|
useTableShortcutsListener(instance, props.shortcuts);
|
|
@@ -11265,7 +11229,7 @@ function RowWithServerLoading(props) {
|
|
|
11265
11229
|
React__default.useEffect(() => {
|
|
11266
11230
|
if (inView) {
|
|
11267
11231
|
var _tableMeta$server$loa, _tableMeta$server;
|
|
11268
|
-
(_tableMeta$server$loa = (_tableMeta$server = tableMeta.server).loadPage) === null || _tableMeta$server$loa === void 0 ? void 0 : _tableMeta$server$loa.call(_tableMeta$server, pageIndex, table.getState().sorting, table.getState().columnFilters);
|
|
11232
|
+
(_tableMeta$server$loa = (_tableMeta$server = tableMeta.server).loadPage) === null || _tableMeta$server$loa === void 0 ? void 0 : _tableMeta$server$loa.call(_tableMeta$server, pageIndex, table.getState().sorting, table.getState().columnFilters, table.getState().globalFilter);
|
|
11269
11233
|
}
|
|
11270
11234
|
}, [inView]);
|
|
11271
11235
|
return /*#__PURE__*/React__default.createElement(Skeleton, {
|
|
@@ -11739,7 +11703,7 @@ function Header$4(context) {
|
|
|
11739
11703
|
const _temp = function () {
|
|
11740
11704
|
if (tableMeta.server.loadAllIfNeeded) {
|
|
11741
11705
|
// don't pass the search query because we need all data - not filtered data
|
|
11742
|
-
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters)).then(function () {});
|
|
11706
|
+
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters, undefined)).then(function () {});
|
|
11743
11707
|
}
|
|
11744
11708
|
}();
|
|
11745
11709
|
// load all data if that is possible
|
|
@@ -11813,7 +11777,7 @@ function Cell$3(context) {
|
|
|
11813
11777
|
const _temp3 = function () {
|
|
11814
11778
|
if (tableMeta.server.loadAllIfNeeded && selectedRows.some(row => row.original === undefined)) {
|
|
11815
11779
|
// don't pass the search query because we need all data - not filtered data
|
|
11816
|
-
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters)).then(function () {});
|
|
11780
|
+
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters, undefined)).then(function () {});
|
|
11817
11781
|
}
|
|
11818
11782
|
}();
|
|
11819
11783
|
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
|
|
@@ -13201,7 +13165,7 @@ function Search$1(props) {
|
|
|
13201
13165
|
const _temp = function () {
|
|
13202
13166
|
if (tableMeta.server.loadAllIfNeeded) {
|
|
13203
13167
|
// don't pass the search query because we need all data - not filtered data
|
|
13204
|
-
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters)).then(function () {});
|
|
13168
|
+
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters, undefined)).then(function () {});
|
|
13205
13169
|
}
|
|
13206
13170
|
}();
|
|
13207
13171
|
// load all data if that is possible
|
|
@@ -15249,7 +15213,7 @@ function Print$1(props) {
|
|
|
15249
15213
|
const _temp2 = function () {
|
|
15250
15214
|
if (tableMeta.server.isEnabled && tableMeta.server.loadAllIfNeeded) {
|
|
15251
15215
|
const _temp = _catch(function () {
|
|
15252
|
-
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters)).then(function () {});
|
|
15216
|
+
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters, undefined)).then(function () {});
|
|
15253
15217
|
}, function (error) {
|
|
15254
15218
|
const errorMessage = `${texts.table.print.error}: ${error}`;
|
|
15255
15219
|
console.error(errorMessage);
|