@economic/taco 2.46.9 → 2.47.0-server-1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. package/dist/components/Report/Report.d.ts +1 -1
  2. package/dist/components/SearchInput2/SearchInput2.d.ts +2 -0
  3. package/dist/components/Table3/components/Row/Editing/CreateNewRow.d.ts +1 -2
  4. package/dist/components/Table3/components/Row/Editing/TemporaryRow.d.ts +1 -0
  5. package/dist/components/Table3/features/useEditingState.d.ts +11 -11
  6. package/dist/components/Table3/features/useTableEditing.d.ts +13 -13
  7. package/dist/components/Table3/util/editing.d.ts +3 -0
  8. package/dist/esm/index.css +2 -2
  9. package/dist/esm/node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js +17 -17
  10. package/dist/esm/node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js.map +1 -1
  11. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js +6 -3
  12. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js.map +1 -1
  13. package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowActions.js +1 -1
  14. package/dist/esm/packages/taco/src/components/Table3/Table3.js +14 -4
  15. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  16. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +1 -1
  17. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
  18. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +14 -9
  19. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
  20. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +2 -4
  21. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js.map +1 -1
  22. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js +5 -4
  23. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js.map +1 -1
  24. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js +32 -51
  25. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js.map +1 -1
  26. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +5 -3
  27. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
  28. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +15 -12
  29. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
  30. package/dist/esm/packages/taco/src/components/Table3/util/editing.js +9 -1
  31. package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
  32. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +2 -1
  33. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
  34. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js +4 -0
  35. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js.map +1 -1
  36. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js +7 -4
  37. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js.map +1 -1
  38. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js +7 -2
  39. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
  40. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Summary.js +7 -5
  41. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Summary.js.map +1 -1
  42. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js +24 -22
  43. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js.map +1 -1
  44. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js +41 -4
  45. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js.map +1 -1
  46. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js +3 -1
  47. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js.map +1 -1
  48. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Search/Search.js +26 -3
  49. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Search/Search.js.map +1 -1
  50. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableGlobalShortcuts.js +1 -1
  51. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableGlobalShortcuts.js.map +1 -1
  52. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +36 -9
  53. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  54. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js +1 -1
  55. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
  56. package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
  57. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js +5 -7
  58. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js.map +1 -1
  59. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActive.js +1 -1
  60. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActive.js.map +1 -1
  61. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowExpansion.js +2 -1
  62. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowExpansion.js.map +1 -1
  63. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSearch.js +3 -2
  64. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSearch.js.map +1 -1
  65. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableServerLoading.js +4 -2
  66. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableServerLoading.js.map +1 -1
  67. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableFilterListener.js +3 -1
  68. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableFilterListener.js.map +1 -1
  69. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableRowSelectionListener.js +4 -4
  70. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableRowSelectionListener.js.map +1 -1
  71. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js +14 -13
  72. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js.map +1 -1
  73. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableServerLoadingListener.js +7 -3
  74. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableServerLoadingListener.js.map +1 -1
  75. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +4 -4
  76. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
  77. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/columns.js +4 -1
  78. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/columns.js.map +1 -1
  79. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/presets.js +7 -1
  80. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/presets.js.map +1 -1
  81. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +6 -0
  82. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  83. package/dist/hooks/useLazyDebouncedEffect.d.ts +2 -0
  84. package/dist/index.css +2 -2
  85. package/dist/primitives/Table/Core/Table.d.ts +1 -0
  86. package/dist/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.d.ts +2 -2
  87. package/dist/primitives/Table/Core/components/Row/Row.d.ts +2 -0
  88. package/dist/primitives/Table/Core/features/useTableRenderer.d.ts +1 -1
  89. package/dist/primitives/Table/types.d.ts +11 -6
  90. package/dist/primitives/Table/useTableDataLoader2.d.ts +24 -0
  91. package/dist/primitives/Table/useTableManager/features/useTableRowExpansion.d.ts +2 -1
  92. package/dist/primitives/Table/useTableManager/features/useTableSearch.d.ts +4 -2
  93. package/dist/primitives/Table/useTableManager/features/useTableServerLoading.d.ts +3 -1
  94. package/dist/primitives/Table/useTableManager/listeners/useTableSearchListener.d.ts +1 -2
  95. package/dist/primitives/Table/useTableManager/util/columns.d.ts +2 -1
  96. package/dist/taco.cjs.development.js +363 -229
  97. package/dist/taco.cjs.development.js.map +1 -1
  98. package/dist/taco.cjs.production.min.js +1 -1
  99. package/dist/taco.cjs.production.min.js.map +1 -1
  100. package/package.json +2 -3
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../../../../../src/primitives/Table/types.ts"],"sourcesContent":["import {\n ColumnFilter as ReactTableColumnFilter,\n ColumnFiltersState as ReactTableColumnFilterState,\n ColumnOrderState as ReactTableColumnOrderState,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSort as ReactTableColumnSort,\n ColumnSizingState as ReactTableColumnSizingState,\n VisibilityState as ReactTableColumnVisibilityState,\n SortingState as ReactTableSortingState,\n BuiltInAggregationFn as ReactTableBuiltInAggregationFn,\n BuiltInSortingFn as ReactTableBuiltInSortingFn,\n} from '@tanstack/react-table';\nimport { FontSize, FontSizes, StringWithAutocompleteOptions, ValueOf } from '../../types';\nimport { MenuItemProps } from '../../components/Menu/components/Item';\n\nexport type TableRef = HTMLTableElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n };\n};\n\n// filtering\nexport enum TableFilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\nexport type TableFilterValue = {\n comparator: TableFilterComparator;\n value: any;\n};\nexport type TableFilter = {\n id: string;\n value: TableFilterValue;\n};\n\n// columns\nexport type TableColumnAlignment = 'left' | 'center' | 'right';\nexport type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type TableColumnDataType =\n // base\n | 'text'\n | 'number'\n | 'datetime'\n | 'boolean'\n // advanced\n | 'amount';\nexport type TableColumnFilter = ReactTableColumnFilter;\nexport type TableColumnMenu = ((columnId: string) => React.ReactNode | null)[];\nexport type TableColumnRenderer<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererAggregate<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererControl<TType = unknown> =\n | ((props: TableColumnRendererControlProps, row?: TType) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'checkbox'\n | 'textarea';\nexport type TableColumnRendererControlProps = {\n className?: string;\n disabled?: boolean;\n fontSize?: FontSize;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: any) => void;\n value: any;\n};\nexport type TableColumnRendererHeader = string;\nexport type TableColumnRendererFooter<TType> = (rows: TType[]) => JSX.Element | string | number | null;\nexport type TableColumnSort = ReactTableColumnSort;\nexport type TableColumnSortDirection = 'asc' | 'desc';\nexport type TableColumnSortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | ReactTableBuiltInSortingFn\n | 'auto';\nexport type TableColumnWidth = number | 'grow';\n\n// rows\nexport type TableRowActionRenderer<TType = unknown> = (row: TType, internalRowId: string) => JSX.Element | null;\nexport type TableRowActionGroupRenderer<TType = unknown> = (rows: TType[]) => JSX.Element | null;\nexport type TableRowClickHandler<TType = unknown> = (row: TType) => void;\nexport type TableRowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type TableRowDropHandler<TType = unknown> = (event: React.DragEvent, row: TType) => void;\nexport type TableRowGotoHandler = (\n column: string,\n query: string,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type TableRowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type TableRowSelectHandler<TType = unknown> = (rows: TType[]) => void;\nexport type TableRowWithMetaData<TType = unknown> = TType & {\n _meta?: {\n layout?: 'heading' | 'summary' | 'item';\n };\n};\n\n// shortcuts\nexport type TableShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type TableShortcutHandlerObject<TType = unknown> = {\n handler: TableShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\n\n// table\nexport type TableFilterHandler = (filters: TableColumnFilter[]) => void | Promise<void>;\nexport type TableFontSize = keyof typeof FontSizes;\nexport type TablePreset = 'complex' | 'list' | 'simple';\nexport type TableRowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type TableScrollToIndexHandler = (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\nexport type TableSearchHandler = (search: string | undefined) => void | Promise<void>;\nexport type TableServerLoadPageHandler = (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[]\n) => Promise<void>;\nexport type TableServerLoadAllHandler = (sorting: TableColumnSort[], filters: TableColumnFilter[]) => Promise<void>;\nexport enum TableServerLoadAllState {\n Incomplete,\n Loading,\n Completed,\n}\nexport type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;\nexport type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;\nexport type TableSortHandler = (sorting: TableColumnSort[]) => void | Promise<void>;\nexport type TableCustomSettingsRenderer = (props: TableSettings) => React.ReactElement<MenuItemProps>[];\nexport type TableEmptyStateReason = 'empty' | 'filtering' | 'searching';\nexport type TableEmptyStateRenderer = (props: { reason: TableEmptyStateReason }) => JSX.Element | null;\n\n// settings\nexport type TableSettings = {\n columnFilters?: ReactTableColumnFilterState;\n columnOrder?: ReactTableColumnOrderState;\n columnPinning?: ReactTableColumnPinningState;\n columnSizing?: ReactTableColumnSizingState;\n columnVisibility?: ReactTableColumnVisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: TableFontSize;\n rowHeight?: TableRowHeight;\n searchQuery?: string;\n sorting?: ReactTableSortingState;\n};\nexport type TableEnableSettingsOptions = {\n columnOrder: boolean;\n columnPinning: boolean;\n columnSizing: boolean;\n columnVisibility: boolean;\n excludeUnmatchedRecordsInSearch: boolean;\n fontSize: boolean;\n grouping: boolean;\n rowHeight: boolean;\n sorting: boolean;\n};\n\n// props\nexport type TableConditionalRowProp<TType = unknown> = boolean | ((row: TType) => boolean);\nexport type TableFeatureProps<TType = unknown> = {\n // react-table built-in\n enableFiltering?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableColumnFreezing?: boolean;\n enableColumnHiding?: boolean;\n enableColumnResizing?: boolean;\n enableRowExpansion?: boolean;\n enableRowSelection?: TableConditionalRowProp<TType>;\n\n // custom -- common between all table types\n enableColumnOrdering?: boolean;\n enableFontSize?: boolean;\n enableFooter?: boolean;\n enablePrinting?: boolean;\n enableRowActions?: boolean;\n enableRowActive?: boolean;\n enableRowClick?: TableConditionalRowProp<TType>;\n enableRowDrag?: boolean;\n enableRowDrop?: boolean;\n enableRowGoto?: boolean;\n enableRowHeight?: boolean;\n enableSaveSettings?: boolean | Partial<TableEnableSettingsOptions>;\n};\n\nexport type TableChild = JSX.Element | boolean | null | undefined;\n\nexport type TableCommonProps<TType = unknown> = TableFeatureProps<TType> & {\n children: TableChild | TableChild[];\n data: TType[];\n id: string;\n\n // misc\n customSettings?: TableCustomSettingsRenderer;\n defaultColumnFreezingIndex?: number;\n defaultRowActiveIndex?: number;\n defaultRowGroupColumnId?: keyof TType;\n defaultSettings?: TableSettings;\n emptyState?: TableEmptyStateRenderer;\n preset?: TablePreset;\n rowActions?: TableRowActionRenderer<TType>[];\n rowActionsForGroup?: TableRowActionGroupRenderer<TType>[];\n rowActionsLength?: number;\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>;\n rowIdentityAccessor?: keyof TType;\n shortcuts?: TableShortcuts<TType>;\n toolbarLeft?: JSX.Element;\n toolbarRight?: JSX.Element;\n toolbarPanel?: JSX.Element;\n\n // handlers\n onRowClick?: TableRowClickHandler<TType>;\n onRowDrag?: TableRowDragHandler<TType>;\n onRowDrop?: TableRowDropHandler<TType>;\n onRowGoto?: TableRowGotoHandler;\n onRowSelect?: TableRowSelectHandler<TType>;\n\n // state change handlers\n onChangeFilter?: TableFilterHandler;\n onChangeSearch?: TableSearchHandler;\n onChangeSettings?: TableSettingsHandler;\n onChangeSort?: TableSortHandler;\n};\n\nexport interface TableClientProps<TType = unknown> extends TableCommonProps<TType> {\n length?: never;\n loadAll?: never;\n loadPage?: never;\n pageSize?: never;\n}\n\nexport interface TableServerProps<TType = unknown> extends TableCommonProps<TType> {\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n pageSize?: number;\n}\n\nexport type TableProps<TType = unknown> = TableClientProps<TType> | TableServerProps<TType>;\n\nexport type TableColumnProps<TType = unknown> = ValueOf<{\n [Key in keyof TType]: {\n accessor?: Key;\n id: StringWithAutocompleteOptions<Key>;\n // renderers\n renderer?: TableColumnRenderer<TType, TType[Key]>;\n /** Renderer to use if the cell is an aggregate cell and part of a grouped row */\n aggregate?: TableColumnRendererAggregate<TType, TType[Key]>;\n control?: TableColumnRendererControl<TType>;\n footer?: TableColumnRendererFooter<TType>;\n header: TableColumnRendererHeader;\n // options\n /** Aggregation function to be used when the column is part of a grouped row */\n aggregationFn?: 'auto' | ReactTableBuiltInAggregationFn;\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TType>;\n dataType?: TableColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: TableColumnWidth;\n enableEditing?: boolean;\n enableFiltering?: boolean;\n enableGrouping?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n headerClassName?: string;\n menu?: TableColumnMenu;\n minWidth?: number;\n sort?: TableColumnSortDirection;\n sortFn?: TableColumnSortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type TableGroupProps = {\n children: (JSX.Element | boolean | null | undefined)[];\n header: string;\n id: string;\n};\n\nexport type TableTexts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n editFilter: string;\n filter: string;\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n cancel: string;\n clear: string;\n apply: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n hiddenColumn: string;\n hiddenGroupedColumn: string;\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n settingsDialog: {\n title: string;\n size: string;\n sizeA5: string;\n sizeA4: string;\n sizeA3: string;\n sizeLetter: string;\n sizeLegal: string;\n orientation: string;\n orientationLandscape: string;\n orientationPortrait: string;\n rows: string;\n rowsAll: string;\n rowsSelected: string;\n layout: string;\n layoutSplitGroups: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n};\n"],"names":["TableFilterComparator","TableServerLoadAllState"],"mappings":"AAwBA;IACYA;AAAZ,WAAYA,qBAAqB;EAC7BA,yEAAQ;EACRA,qFAAc;EACdA,2EAAS;EACTA,iFAAY;EACZA,mFAAa;EACbA,6EAAU;EACVA,2EAAS;EACTA,uEAAO;EACPA,6EAAU;EACVA,+FAAmB;EACnBA,sGAAsB;EACtBA,0EAAQ;EACRA,0EAAQ;EACRA,4EAAS;AACb,CAAC,EAfWA,qBAAqB,KAArBA,qBAAqB;IAmHrBC;AAAZ,WAAYA,uBAAuB;EAC/BA,iFAAU;EACVA,2EAAO;EACPA,+EAAS;AACb,CAAC,EAJWA,uBAAuB,KAAvBA,uBAAuB;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../../../../../src/primitives/Table/types.ts"],"sourcesContent":["import {\n ColumnFilter as ReactTableColumnFilter,\n ColumnFiltersState as ReactTableColumnFilterState,\n ColumnOrderState as ReactTableColumnOrderState,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSort as ReactTableColumnSort,\n ColumnSizingState as ReactTableColumnSizingState,\n VisibilityState as ReactTableColumnVisibilityState,\n SortingState as ReactTableSortingState,\n BuiltInAggregationFn as ReactTableBuiltInAggregationFn,\n BuiltInSortingFn as ReactTableBuiltInSortingFn,\n} from '@tanstack/react-table';\nimport { FontSize, FontSizes, StringWithAutocompleteOptions, ValueOf } from '../../types';\nimport { MenuItemProps } from '../../components/Menu/components/Item';\n\nexport type TableRef = HTMLTableElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n };\n};\n\n// filtering\nexport enum TableFilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\nexport type TableFilterValue = {\n comparator: TableFilterComparator;\n value: any;\n};\nexport type TableFilter = {\n id: string;\n value: TableFilterValue;\n};\n\n// columns\nexport type TableColumnAlignment = 'left' | 'center' | 'right';\nexport type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type TableColumnDataType =\n // base\n | 'text'\n | 'number'\n | 'datetime'\n | 'boolean'\n // advanced\n | 'amount';\nexport type TableColumnFilter = ReactTableColumnFilter;\nexport type TableColumnMenu = ((columnId: string) => React.ReactNode | null)[];\nexport type TableColumnRenderer<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererAggregate<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererControl<TType = unknown> =\n | ((props: TableColumnRendererControlProps, row?: TType) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'checkbox'\n | 'textarea';\nexport type TableColumnRendererControlProps = {\n className?: string;\n disabled?: boolean;\n fontSize?: FontSize;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: any) => void;\n value: any;\n};\nexport type TableColumnRendererHeader = string;\nexport type TableColumnRendererFooter<TType> = (rows: TType[]) => JSX.Element | string | number | null;\nexport type TableColumnSort = ReactTableColumnSort;\nexport type TableColumnSortDirection = 'asc' | 'desc';\nexport type TableColumnSortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | ReactTableBuiltInSortingFn\n | 'auto';\nexport type TableColumnWidth = number | 'grow';\n\n// rows\nexport type TableRowActionRenderer<TType = unknown> = (row: TType, internalRowId: string) => JSX.Element | null;\nexport type TableRowActionGroupRenderer<TType = unknown> = (rows: TType[]) => JSX.Element | null;\nexport type TableRowClickHandler<TType = unknown> = (row: TType) => void;\nexport type TableRowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type TableRowDropHandler<TType = unknown> = (event: React.DragEvent, row: TType) => void;\nexport type TableRowGotoHandler = (\n column: string,\n query: string,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type TableRowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type TableRowSelectHandler<TType = unknown> = (rows: TType[], ids: (keyof TType)[]) => void;\nexport type TableRowWithMetaData<TType = unknown> = TType & {\n _meta?: {\n layout?: 'heading' | 'summary' | 'item';\n };\n};\n\n// shortcuts\nexport type TableShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type TableShortcutHandlerObject<TType = unknown> = {\n handler: TableShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\n\n// table\nexport type TableSortHandler = (sorting: TableColumnSort[]) => Promise<void>;\nexport type TableFilterHandler = (filters: TableColumnFilter[], hiddenColumns: string[]) => Promise<void>;\nexport type TableSearchHandler = (search: string | undefined, hiddenColumns: string[]) => Promise<void>;\nexport type TableFontSize = keyof typeof FontSizes;\nexport type TablePreset = 'complex' | 'list' | 'simple';\nexport type TableRowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type TableScrollToIndexHandler = (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\nexport type TableServerLoadPageHandler = (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined,\n hiddenColumns: string[]\n) => Promise<void>;\nexport type TableServerLoadAllHandler = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined,\n hiddenColumns: string[]\n) => Promise<void>;\nexport enum TableServerLoadAllState {\n Incomplete,\n Loading,\n Completed,\n}\nexport type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;\nexport type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;\nexport type TableCustomSettingsRenderer = (props: TableSettings) => React.ReactElement<MenuItemProps>[];\nexport type TableEmptyStateReason = 'empty' | 'filtering' | 'searching';\nexport type TableEmptyStateRenderer = (props: { reason: TableEmptyStateReason }) => JSX.Element | null;\n\n// settings\nexport type TableSettings = {\n columnFilters?: ReactTableColumnFilterState;\n columnOrder?: ReactTableColumnOrderState;\n columnPinning?: ReactTableColumnPinningState;\n columnSizing?: ReactTableColumnSizingState;\n columnVisibility?: ReactTableColumnVisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: TableFontSize;\n rowHeight?: TableRowHeight;\n searchQuery?: string;\n sorting?: ReactTableSortingState;\n};\nexport type TableEnableSettingsOptions = {\n columnOrder: boolean;\n columnPinning: boolean;\n columnSizing: boolean;\n columnVisibility: boolean;\n excludeUnmatchedRecordsInSearch: boolean;\n fontSize: boolean;\n grouping: boolean;\n rowHeight: boolean;\n sorting: boolean;\n};\n\n// props\nexport type TableConditionalRowProp<TType = unknown> = boolean | ((row: TType) => boolean);\nexport type TableFeatureProps<TType = unknown> = {\n // react-table built-in\n enableFiltering?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableColumnFreezing?: boolean;\n enableColumnHiding?: boolean;\n enableColumnResizing?: boolean;\n enableRowExpansion?: boolean;\n enableRowExpansionAll?: boolean;\n enableRowSelection?: TableConditionalRowProp<TType>;\n\n // custom -- common between all table types\n enableColumnOrdering?: boolean;\n enableFontSize?: boolean;\n enableFooter?: boolean;\n enablePrinting?: boolean;\n enableRowActions?: boolean;\n enableRowActive?: boolean;\n enableRowClick?: TableConditionalRowProp<TType>;\n enableRowDrag?: boolean;\n enableRowDrop?: boolean;\n enableRowGoto?: boolean;\n enableRowHeight?: boolean;\n enableSaveSettings?: boolean | Partial<TableEnableSettingsOptions>;\n};\n\nexport type TableChild = JSX.Element | boolean | null | undefined;\n\nexport type TableCommonProps<TType = unknown> = TableFeatureProps<TType> & {\n children: TableChild | TableChild[];\n data: TType[];\n id: string;\n\n // misc\n customSettings?: TableCustomSettingsRenderer;\n defaultColumnFreezingIndex?: number;\n defaultRowActiveIndex?: number;\n defaultRowGroupColumnId?: keyof TType;\n defaultSettings?: TableSettings;\n emptyState?: TableEmptyStateRenderer;\n preset?: TablePreset;\n rowActions?: TableRowActionRenderer<TType>[];\n rowActionsForGroup?: TableRowActionGroupRenderer<TType>[];\n rowActionsLength?: number;\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>;\n rowIdentityAccessor?: keyof TType;\n shortcuts?: TableShortcuts<TType>;\n toolbarLeft?: JSX.Element;\n toolbarRight?: JSX.Element;\n toolbarPanel?: JSX.Element;\n\n // handlers\n onRowClick?: TableRowClickHandler<TType>;\n onRowDrag?: TableRowDragHandler<TType>;\n onRowDrop?: TableRowDropHandler<TType>;\n onRowGoto?: TableRowGotoHandler;\n onRowSelect?: TableRowSelectHandler<TType>;\n\n // state change handlers\n onChangeFilter?: TableFilterHandler;\n onChangeSearch?: TableSearchHandler;\n onChangeSettings?: TableSettingsHandler;\n onChangeSort?: TableSortHandler;\n};\n\nexport interface TableClientProps<TType = unknown> extends TableCommonProps<TType> {\n length?: never;\n loadAll?: never;\n loadPage?: never;\n pageSize?: never;\n pages?: never;\n\n // experimental\n _experimentalDataLoader2?: never;\n}\n\nexport interface TableServerProps<TType = unknown> extends TableCommonProps<TType> {\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n pageSize?: number;\n pages?: number[];\n\n // experimental\n _experimentalDataLoader2?: boolean;\n}\n\nexport type TableProps<TType = unknown> = TableClientProps<TType> | TableServerProps<TType>;\n\nexport type TableColumnProps<TType = unknown> = ValueOf<{\n [Key in keyof TType]: {\n accessor?: Key;\n id: StringWithAutocompleteOptions<Key>;\n // renderers\n renderer?: TableColumnRenderer<TType, TType[Key]>;\n /** Renderer to use if the cell is an aggregate cell and part of a grouped row */\n aggregate?: TableColumnRendererAggregate<TType, TType[Key]>;\n control?: TableColumnRendererControl<TType>;\n footer?: TableColumnRendererFooter<TType>;\n header: TableColumnRendererHeader;\n // options\n /** Aggregation function to be used when the column is part of a grouped row */\n aggregationFn?: 'auto' | ReactTableBuiltInAggregationFn;\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TType>;\n dataType?: TableColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: TableColumnWidth;\n enableEditing?: boolean;\n enableFiltering?: boolean;\n enableGrouping?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n headerClassName?: string;\n menu?: TableColumnMenu;\n minWidth?: number;\n sort?: TableColumnSortDirection;\n sortFn?: TableColumnSortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type TableGroupProps = {\n children: (JSX.Element | boolean | null | undefined)[];\n header: string;\n id: string;\n};\n\nexport type TableTexts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n editFilter: string;\n filter: string;\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n cancel: string;\n clear: string;\n apply: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n hiddenColumn: string;\n hiddenGroupedColumn: string;\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n settingsDialog: {\n title: string;\n size: string;\n sizeA5: string;\n sizeA4: string;\n sizeA3: string;\n sizeLetter: string;\n sizeLegal: string;\n orientation: string;\n orientationLandscape: string;\n orientationPortrait: string;\n rows: string;\n rowsAll: string;\n rowsSelected: string;\n layout: string;\n layoutSplitGroups: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n};\n"],"names":["TableFilterComparator","TableServerLoadAllState"],"mappings":"AAwBA;IACYA;AAAZ,WAAYA,qBAAqB;EAC7BA,yEAAQ;EACRA,qFAAc;EACdA,2EAAS;EACTA,iFAAY;EACZA,mFAAa;EACbA,6EAAU;EACVA,2EAAS;EACTA,uEAAO;EACPA,6EAAU;EACVA,+FAAmB;EACnBA,sGAAsB;EACtBA,0EAAQ;EACRA,0EAAQ;EACRA,4EAAS;AACb,CAAC,EAfWA,qBAAqB,KAArBA,qBAAqB;IA2HrBC;AAAZ,WAAYA,uBAAuB;EAC/BA,iFAAU;EACVA,2EAAO;EACPA,+EAAS;AACb,CAAC,EAJWA,uBAAuB,KAAvBA,uBAAuB;;;;"}
@@ -54,7 +54,7 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
54
54
  length.current = response.length;
55
55
  nextData = Array(length.current).fill(undefined);
56
56
  } else {
57
- nextData = [...currentData];
57
+ nextData = [].concat(currentData);
58
58
  }
59
59
  const startIndex = pageIndex * pageSize;
60
60
  nextData.splice(startIndex, pageSize, ...response.data);
@@ -120,13 +120,12 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
120
120
  try {
121
121
  if (_lastUsedSearch.current) {
122
122
  // we're searching, which means we need to refetch all with the correct sorting applied
123
- loadAll(sorting, _lastUsedFilters.current);
123
+ return loadAll(sorting, _lastUsedFilters.current);
124
124
  } else {
125
125
  var _lastUsedPageIndex$cu2;
126
126
  // load the last page that we scrolled to
127
- loadPage((_lastUsedPageIndex$cu2 = _lastUsedPageIndex.current) !== null && _lastUsedPageIndex$cu2 !== void 0 ? _lastUsedPageIndex$cu2 : 0, sorting, _lastUsedFilters.current);
127
+ return loadPage((_lastUsedPageIndex$cu2 = _lastUsedPageIndex.current) !== null && _lastUsedPageIndex$cu2 !== void 0 ? _lastUsedPageIndex$cu2 : 0, sorting, _lastUsedFilters.current);
128
128
  }
129
- return Promise.resolve();
130
129
  } catch (e) {
131
130
  return Promise.reject(e);
132
131
  }
@@ -135,13 +134,12 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
135
134
  try {
136
135
  if (_lastUsedSearch.current) {
137
136
  // we're searching, which means we need to refetch all with the correct sorting applied
138
- loadAll(_lastUsedSorting.current, filters);
137
+ return loadAll(_lastUsedSorting.current, filters);
139
138
  } else {
140
139
  var _lastUsedPageIndex$cu3;
141
140
  // load the last page that we scrolled to
142
- loadPage((_lastUsedPageIndex$cu3 = _lastUsedPageIndex.current) !== null && _lastUsedPageIndex$cu3 !== void 0 ? _lastUsedPageIndex$cu3 : 0, _lastUsedSorting.current, filters);
141
+ return loadPage((_lastUsedPageIndex$cu3 = _lastUsedPageIndex.current) !== null && _lastUsedPageIndex$cu3 !== void 0 ? _lastUsedPageIndex$cu3 : 0, _lastUsedSorting.current, filters);
143
142
  }
144
- return Promise.resolve();
145
143
  } catch (e) {
146
144
  return Promise.reject(e);
147
145
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useTableDataLoader.js","sources":["../../../../../../../src/primitives/Table/useTableDataLoader.ts"],"sourcesContent":["import React from 'react';\nimport {\n TableColumnFilter,\n TableColumnSort,\n TableFilterHandler,\n TableServerLoadPageHandler,\n TableServerLoadAllHandler,\n TableSortHandler,\n TableSearchHandler,\n} from './types';\n\nexport const DEFAULT_PAGE_SIZE = 100;\n\nexport type useTableDataPageFetcher<TType = unknown> = (\n pageIndex: number,\n pageSize: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[]\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataAllFetcher<TType = unknown> = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[]\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataLoaderOptions = { pageSize: number };\n\nexport type useTableDataLoaderValues<TType = unknown> = {\n data: TType[];\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n onChangeFilter: TableFilterHandler;\n onChangeSearch: TableSearchHandler;\n onChangeSort: TableSortHandler;\n pageSize: number;\n};\n\nexport function useTableDataLoader<TType = unknown>(\n fetchPage: useTableDataPageFetcher<TType>,\n fetchAll: useTableDataAllFetcher<TType>,\n options: useTableDataLoaderOptions = { pageSize: DEFAULT_PAGE_SIZE }\n): [useTableDataLoaderValues<TType>, () => void] {\n const { pageSize } = options;\n\n // track the data length, we don't know it until the first request\n const length = React.useRef<number | undefined>(undefined);\n // data will be filled after the first request, then we'll update values in place\n const [data, setData] = React.useState<any[]>([]);\n // track which pages have been loaded to dedupe requests\n const _pendingPageRequests = React.useRef({});\n const _lastUsedSorting = React.useRef<TableColumnSort[]>([]);\n const _lastUsedFilters = React.useRef<TableColumnFilter[]>([]);\n const _lastUsedSearch = React.useRef<string>();\n const _lastUsedPageIndex = React.useRef<number>();\n const _forceReset = React.useRef(false);\n\n const loadPage = async (pageIndex: number, sorting: TableColumnSort[], filters: TableColumnFilter[]) => {\n let reset = false;\n\n // sorting or filters changed, reset everything\n if (\n _forceReset.current ||\n JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) ||\n JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current)\n ) {\n _pendingPageRequests.current = {};\n // nuke the dataset so that we \"start again\" after sorting\n reset = true;\n }\n\n if (_pendingPageRequests.current[pageIndex]) {\n // if page is already loaded/loading, abort, otherwise mark it as loading\n return;\n } else {\n _pendingPageRequests.current[pageIndex] = true;\n }\n\n _forceReset.current = false;\n // set the last page loaded (or tried to load), so that we can load it back again after resets\n _lastUsedPageIndex.current = pageIndex;\n // set the sorting so we can track if it changed between loads\n _lastUsedSorting.current = sorting;\n // set the filters so we can track if it changed between loads\n _lastUsedFilters.current = filters;\n\n try {\n const response = await fetchPage(pageIndex, pageSize, sorting, filters);\n\n // update state, here we do some \"magic\" to support \"load in place\"\n setData(currentData => {\n let nextData;\n\n // reset table state if:\n // - the length isn't set at all (first load)\n // - the client length and server length are different (the data changed)\n if (reset || length.current !== response.length) {\n length.current = response.length;\n nextData = Array(length.current).fill(undefined);\n } else {\n nextData = [...currentData];\n }\n\n const startIndex = pageIndex * pageSize;\n nextData.splice(startIndex, pageSize, ...response.data);\n return nextData;\n });\n } catch {\n //\n } finally {\n _pendingPageRequests.current[pageIndex] = false;\n }\n };\n\n const loadAll = async (sorting: TableColumnSort[], filters: TableColumnFilter[]) => {\n // set the sorting so we can track if it changed between loads\n _lastUsedSorting.current = sorting;\n // set the filters so we can track if it changed between loads\n _lastUsedFilters.current = filters;\n\n try {\n const response = await fetchAll(sorting, filters);\n length.current = response.length;\n\n setData(() => {\n let nextData;\n\n if (response.data.length !== response.length) {\n nextData = Array(response.length).fill(undefined);\n nextData.splice(0, response.data.length, ...response.data);\n } else {\n nextData = [...response.data];\n }\n\n return nextData;\n });\n } catch {\n //\n }\n };\n\n const invalidate = async () => {\n // empties the entire data array\n _forceReset.current = true;\n\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n return loadAll(_lastUsedSorting.current, _lastUsedFilters.current);\n } else {\n // load the last page that we scrolled to\n return loadPage(_lastUsedPageIndex.current ?? 0, _lastUsedSorting.current, _lastUsedFilters.current);\n }\n };\n\n // search works client side - it fetches all then works client side - so these handlers are a little \"weird\"\n // if a search is currently \"active\", we need to re load all because\n const handleSort = async (sorting: TableColumnSort[]) => {\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n loadAll(sorting, _lastUsedFilters.current);\n } else {\n // load the last page that we scrolled to\n loadPage(_lastUsedPageIndex.current ?? 0, sorting, _lastUsedFilters.current);\n }\n };\n const handleFilter = async (filters: TableColumnFilter[]) => {\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n loadAll(_lastUsedSorting.current, filters);\n } else {\n // load the last page that we scrolled to\n loadPage(_lastUsedPageIndex.current ?? 0, _lastUsedSorting.current, filters);\n }\n };\n const handleSearch = async (search: string | undefined) => {\n // set the search so we can track if it changed between loads\n _lastUsedSearch.current = search || undefined;\n // search works client side, and focusing the search field triggers a load of all so we don't actually\n // want to load anything when search gets changed, we just store the value for other handlers\n };\n\n return [\n {\n data,\n length: length.current,\n loadAll,\n loadPage,\n onChangeFilter: handleFilter,\n onChangeSearch: handleSearch,\n onChangeSort: handleSort,\n pageSize,\n },\n invalidate,\n ];\n}\n"],"names":["DEFAULT_PAGE_SIZE","useTableDataLoader","fetchPage","fetchAll","options","pageSize","length","React","useRef","undefined","data","setData","useState","_pendingPageRequests","_lastUsedSorting","_lastUsedFilters","_lastUsedSearch","_lastUsedPageIndex","_forceReset","loadPage","pageIndex","sorting","filters","reset","current","JSON","stringify","Promise","resolve","_temp","_finallyRethrows","_catch","then","response","currentData","nextData","Array","fill","startIndex","splice","_wasThrown","_result","e","reject","loadAll","_temp2","invalidate","_lastUsedPageIndex$cu","handleSort","_lastUsedPageIndex$cu2","handleFilter","_lastUsedPageIndex$cu3","handleSearch","search","onChangeFilter","onChangeSearch","onChangeSort"],"mappings":";;;MAWaA,iBAAiB,GAAG;SA2BjBC,kBAAkBA,CAC9BC,SAAyC,EACzCC,QAAuC,EACvCC,UAAqC;EAAEC,QAAQ,EAAEL;CAAmB;EAEpE,MAAM;IAAEK;GAAU,GAAGD,OAAO;;EAG5B,MAAME,MAAM,GAAGC,cAAK,CAACC,MAAM,CAAqBC,SAAS,CAAC;;EAE1D,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGJ,cAAK,CAACK,QAAQ,CAAQ,EAAE,CAAC;;EAEjD,MAAMC,oBAAoB,GAAGN,cAAK,CAACC,MAAM,CAAC,EAAE,CAAC;EAC7C,MAAMM,gBAAgB,GAAGP,cAAK,CAACC,MAAM,CAAoB,EAAE,CAAC;EAC5D,MAAMO,gBAAgB,GAAGR,cAAK,CAACC,MAAM,CAAsB,EAAE,CAAC;EAC9D,MAAMQ,eAAe,GAAGT,cAAK,CAACC,MAAM,EAAU;EAC9C,MAAMS,kBAAkB,GAAGV,cAA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AAA;MAAA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;EACD,MAAMQ,YAAY,aAAU5B,OAA4B;IAAA;MACpD,IAAIN,eAAe,CAACQ,OAAO,EAAE;;QAEzBoB,OAAO,CAAC9B,gBAAgB,CAACU,OAAO,EAAEF,OAAO,CAAC;OAC7C,MAAM;QAAA,IAAA6B,sBAAA;;QAEHhC,QAAQ,EAAAgC,sBAAA,GAAClC,kBAAkB,CAACO,OAAO,cAAA2B,sBAAA,cAAAA,sBAAA,GAAI,CAAC,EAAErC,gBAAgB,CAACU,OAAO,EAAEF,OAAO,CAAC;;MAC/E,OAAAK,OAAA,CAAAC,OAAA;KACJ,QAAAc,CAAA;MAAA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;EACD,MAAMU,YAAY,aAAUC,MAA0B;IAAA;;MAElDrC,eAAe,CAACQ,OAAO,GAAG6B,MAAM,IAAI5C,SAAS;;;MAE7C,OAAAkB,OAAA,CAAAC,OAAA;KACH,QAAAc,CAAA;MAAA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;EAED,OAAO,CACH;IACIhC,IAAI;IACJJ,MAAM,EAAEA,MAAM,CAACkB,OAAO;IACtBoB,OAAO;IACPzB,QAAQ;IACRmC,cAAc,EAAEJ,YAAY;IAC5BK,cAAc,EAAEH,YAAY;IAC5BI,YAAY,EAAER,UAAU;IACxB3C;GACH,EACDyC,UAAU,CACb;AACL;;;;"}
1
+ {"version":3,"file":"useTableDataLoader.js","sources":["../../../../../../../src/primitives/Table/useTableDataLoader.ts"],"sourcesContent":["import React from 'react';\nimport {\n TableColumnFilter,\n TableColumnSort,\n TableFilterHandler,\n TableServerLoadPageHandler,\n TableServerLoadAllHandler,\n TableSortHandler,\n TableSearchHandler,\n} from './types';\n\nexport const DEFAULT_PAGE_SIZE = 100;\n\nexport type useTableDataPageFetcher<TType = unknown> = (\n pageIndex: number,\n pageSize: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[]\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataAllFetcher<TType = unknown> = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[]\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataLoaderOptions = { pageSize: number };\n\nexport type useTableDataLoaderValues<TType = unknown> = {\n data: TType[];\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n onChangeFilter: TableFilterHandler;\n onChangeSearch: TableSearchHandler;\n onChangeSort: TableSortHandler;\n pageSize: number;\n};\n\nexport function useTableDataLoader<TType = unknown>(\n fetchPage: useTableDataPageFetcher<TType>,\n fetchAll: useTableDataAllFetcher<TType>,\n options: useTableDataLoaderOptions = { pageSize: DEFAULT_PAGE_SIZE }\n): [useTableDataLoaderValues<TType>, () => void] {\n const { pageSize } = options;\n\n // track the data length, we don't know it until the first request\n const length = React.useRef<number | undefined>(undefined);\n // data will be filled after the first request, then we'll update values in place\n const [data, setData] = React.useState<TType[]>([]);\n // track which pages have been loaded to dedupe requests\n const _pendingPageRequests = React.useRef({});\n const _lastUsedSorting = React.useRef<TableColumnSort[]>([]);\n const _lastUsedFilters = React.useRef<TableColumnFilter[]>([]);\n const _lastUsedSearch = React.useRef<string>();\n const _lastUsedPageIndex = React.useRef<number>();\n const _forceReset = React.useRef(false);\n\n const loadPage = async (pageIndex: number, sorting: TableColumnSort[], filters: TableColumnFilter[]) => {\n let reset = false;\n\n // sorting or filters changed, reset everything\n if (\n _forceReset.current ||\n JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) ||\n JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current)\n ) {\n _pendingPageRequests.current = {};\n // nuke the dataset so that we \"start again\" after sorting\n reset = true;\n }\n\n if (_pendingPageRequests.current[pageIndex]) {\n // if page is already loaded/loading, abort, otherwise mark it as loading\n return;\n } else {\n _pendingPageRequests.current[pageIndex] = true;\n }\n\n _forceReset.current = false;\n // set the last page loaded (or tried to load), so that we can load it back again after resets\n _lastUsedPageIndex.current = pageIndex;\n // set the sorting so we can track if it changed between loads\n _lastUsedSorting.current = sorting;\n // set the filters so we can track if it changed between loads\n _lastUsedFilters.current = filters;\n\n try {\n const response = await fetchPage(pageIndex, pageSize, sorting, filters);\n\n // update state, here we do some \"magic\" to support \"load in place\"\n setData(currentData => {\n let nextData;\n\n // reset table state if:\n // - the length isn't set at all (first load)\n // - the client length and server length are different (the data changed)\n if (reset || length.current !== response.length) {\n length.current = response.length;\n nextData = Array(length.current).fill(undefined);\n } else {\n nextData = ([] as TType[]).concat(currentData);\n }\n\n const startIndex = pageIndex * pageSize;\n nextData.splice(startIndex, pageSize, ...response.data);\n return nextData;\n });\n } catch {\n //\n } finally {\n _pendingPageRequests.current[pageIndex] = false;\n }\n };\n\n const loadAll = async (sorting: TableColumnSort[], filters: TableColumnFilter[]) => {\n // set the sorting so we can track if it changed between loads\n _lastUsedSorting.current = sorting;\n // set the filters so we can track if it changed between loads\n _lastUsedFilters.current = filters;\n\n try {\n const response = await fetchAll(sorting, filters);\n length.current = response.length;\n\n setData(() => {\n let nextData;\n\n if (response.data.length !== response.length) {\n nextData = Array(response.length).fill(undefined);\n nextData.splice(0, response.data.length, ...response.data);\n } else {\n nextData = [...response.data];\n }\n\n return nextData;\n });\n } catch {\n //\n }\n };\n\n const invalidate = async () => {\n // empties the entire data array\n _forceReset.current = true;\n\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n return loadAll(_lastUsedSorting.current, _lastUsedFilters.current);\n } else {\n // load the last page that we scrolled to\n return loadPage(_lastUsedPageIndex.current ?? 0, _lastUsedSorting.current, _lastUsedFilters.current);\n }\n };\n\n // search works client side - it fetches all then works client side - so these handlers are a little \"weird\"\n // if a search is currently \"active\", we need to re load all because\n const handleSort = async (sorting: TableColumnSort[]) => {\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n return loadAll(sorting, _lastUsedFilters.current);\n } else {\n // load the last page that we scrolled to\n return loadPage(_lastUsedPageIndex.current ?? 0, sorting, _lastUsedFilters.current);\n }\n };\n const handleFilter = async (filters: TableColumnFilter[]) => {\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n return loadAll(_lastUsedSorting.current, filters);\n } else {\n // load the last page that we scrolled to\n return loadPage(_lastUsedPageIndex.current ?? 0, _lastUsedSorting.current, filters);\n }\n };\n const handleSearch = async (search: string | undefined) => {\n // set the search so we can track if it changed between loads\n _lastUsedSearch.current = search || undefined;\n // search works client side, and focusing the search field triggers a load of all so we don't actually\n // want to load anything when search gets changed, we just store the value for other handlers\n };\n\n return [\n {\n data,\n length: length.current,\n loadAll,\n loadPage,\n onChangeFilter: handleFilter,\n onChangeSearch: handleSearch,\n onChangeSort: handleSort,\n pageSize,\n },\n invalidate,\n ];\n}\n"],"names":["DEFAULT_PAGE_SIZE","useTableDataLoader","fetchPage","fetchAll","options","pageSize","length","React","useRef","undefined","data","setData","useState","_pendingPageRequests","_lastUsedSorting","_lastUsedFilters","_lastUsedSearch","_lastUsedPageIndex","_forceReset","loadPage","pageIndex","sorting","filters","reset","current","JSON","stringify","Promise","resolve","_temp","_finallyRethrows","_catch","then","response","currentData","nextData","Array","fill","concat","startIndex","splice","_wasThrown","_result","e","reject","loadAll","_temp2","invalidate","_lastUsedPageIndex$cu","handleSort","_lastUsedPageIndex$cu2","handleFilter","_lastUsedPageIndex$cu3","handleSearch","search","onChangeFilter","onChangeSearch","onChangeSort"],"mappings":";;;MAWaA,iBAAiB,GAAG;SA2BjBC,kBAAkBA,CAC9BC,SAAyC,EACzCC,QAAuC,EACvCC,UAAqC;EAAEC,QAAQ,EAAEL;CAAmB;EAEpE,MAAM;IAAEK;GAAU,GAAGD,OAAO;;EAG5B,MAAME,MAAM,GAAGC,cAAK,CAACC,MAAM,CAAqBC,SAAS,CAAC;;EAE1D,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGJ,cAAK,CAACK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isEnabled = false, initialRowActiveIndex) {
56
56
  return index;
57
57
  });
58
58
  }
59
- }, [rowActiveIndex, length, isEnabled]);
59
+ }, [rowActiveIndex, isEnabled]);
60
60
  return {
61
61
  isEnabled,
62
62
  rowActiveIndex,
@@ -1 +1 @@
1
- {"version":3,"file":"useTableRowActive.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableRowActive.ts"],"sourcesContent":["import React from 'react';\nimport { TableScrollToIndexHandler } from '../../types';\nimport { useIsHoverStatePaused } from '../../../../hooks/useIsHoverStatePaused';\nimport { isElementInsideOrTriggeredFromContainer } from '../../../../utils/dom';\n\nexport function useTableRowActive(isEnabled = false, initialRowActiveIndex?: number) {\n const [rowActiveIndex, setRowActiveIndex] = React.useState<number | undefined>(initialRowActiveIndex);\n const [rowHoverIndex, setRowHoverIndex] = React.useState<number | undefined>(undefined);\n const [isHoverStatePaused, setHoverStatePaused] = useIsHoverStatePaused();\n\n const move = (direction: -1 | 1, length: number, scrollToIndex: TableScrollToIndexHandler) => {\n const nextIndex = rowActiveIndex !== undefined ? getNextIndex(direction, rowActiveIndex, length) : 0;\n scrollToIndex(nextIndex);\n setTimeout(() => setRowActiveIndex(nextIndex), 50);\n };\n\n const onKeyDown = React.useCallback(\n (event: KeyboardEvent, length: number, scrollToIndex: TableScrollToIndexHandler) => {\n if (!isEnabled || event.defaultPrevented) {\n return;\n }\n\n if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {\n setHoverStatePaused(true);\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n\n if (event.ctrlKey || event.metaKey) {\n const newIndex = 0;\n scrollToIndex(newIndex);\n setRowActiveIndex(newIndex);\n } else {\n move(-1, length, scrollToIndex);\n }\n\n return;\n } else if (event.key === 'ArrowDown') {\n event.preventDefault();\n\n if (event.ctrlKey || event.metaKey) {\n const newIndex = length - 1;\n scrollToIndex(newIndex);\n setRowActiveIndex(newIndex);\n } else {\n move(+1, length, scrollToIndex);\n }\n return;\n }\n },\n [isEnabled, rowActiveIndex]\n );\n\n const onFocus = React.useCallback(\n (event: React.FocusEvent, length: number, scrollToIndex: TableScrollToIndexHandler) => {\n if (!isEnabled || event.isDefaultPrevented()) {\n return;\n }\n\n if (event.target.closest('tbody') || isElementInsideOrTriggeredFromContainer(event.target, event.currentTarget)) {\n return;\n }\n\n if (rowActiveIndex === undefined && length > 0) {\n setRowActiveIndex(index => {\n if (index === undefined) {\n scrollToIndex(0);\n return 0;\n }\n return index;\n });\n }\n },\n [rowActiveIndex, length, isEnabled]\n );\n\n return {\n isEnabled,\n rowActiveIndex,\n setRowActiveIndex: isEnabled ? setRowActiveIndex : () => undefined,\n rowHoverIndex,\n setRowHoverIndex,\n isHoverStatePaused,\n setHoverStatePaused: isEnabled ? setHoverStatePaused : () => undefined,\n handleFocus: isEnabled ? onFocus : () => undefined,\n handleKeyDown: isEnabled ? onKeyDown : () => undefined,\n };\n}\n\nfunction getNextIndex(direction: -1 | 1, currentIndex: number, length: number) {\n if (direction === -1) {\n return currentIndex - 1 > 0 ? currentIndex - 1 : 0;\n }\n\n return currentIndex + 1 < length ? currentIndex + 1 : currentIndex;\n}\n"],"names":["useTableRowActive","isEnabled","initialRowActiveIndex","rowActiveIndex","setRowActiveIndex","React","useState","rowHoverIndex","setRowHoverIndex","undefined","isHoverStatePaused","setHoverStatePaused","useIsHoverStatePaused","move","direction","length","scrollToIndex","nextIndex","getNextIndex","setTimeout","onKeyDown","useCallback","event","defaultPrevented","key","preventDefault","ctrlKey","metaKey","newIndex","onFocus","isDefaultPrevented","target","closest","isElementInsideOrTriggeredFromContainer","currentTarget","index","handleFocus","handleKeyDown","currentIndex"],"mappings":";;;;SAKgBA,iBAAiBA,CAACC,SAAS,GAAG,KAAK,EAAEC,qBAA8B;EAC/E,MAAM,CAACC,cAAc,EAAEC,iBAAiB,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAqBJ,qBAAqB,CAAC;EACrG,MAAM,CAACK,aAAa,EAAEC,gBAAgB,CAA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C,EAAE;IAClB,OAAOwB,YAAY,GAAG,CAAC,GAAG,CAAC,GAAGA,YAAY,GAAG,CAAC,GAAG,CAAC;;EAGtD,OAAOA,YAAY,GAAG,CAAC,GAAGvB,MAAM,GAAGuB,YAAY,GAAG,CAAC,GAAGA,YAAY;AACtE;;;;"}
1
+ {"version":3,"file":"useTableRowActive.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableRowActive.ts"],"sourcesContent":["import React from 'react';\nimport { TableScrollToIndexHandler } from '../../types';\nimport { useIsHoverStatePaused } from '../../../../hooks/useIsHoverStatePaused';\nimport { isElementInsideOrTriggeredFromContainer } from '../../../../utils/dom';\n\nexport function useTableRowActive(isEnabled = false, initialRowActiveIndex?: number) {\n const [rowActiveIndex, setRowActiveIndex] = React.useState<number | undefined>(initialRowActiveIndex);\n const [rowHoverIndex, setRowHoverIndex] = React.useState<number | undefined>(undefined);\n const [isHoverStatePaused, setHoverStatePaused] = useIsHoverStatePaused();\n\n const move = (direction: -1 | 1, length: number, scrollToIndex: TableScrollToIndexHandler) => {\n const nextIndex = rowActiveIndex !== undefined ? getNextIndex(direction, rowActiveIndex, length) : 0;\n scrollToIndex(nextIndex);\n setTimeout(() => setRowActiveIndex(nextIndex), 50);\n };\n\n const onKeyDown = React.useCallback(\n (event: KeyboardEvent, length: number, scrollToIndex: TableScrollToIndexHandler) => {\n if (!isEnabled || event.defaultPrevented) {\n return;\n }\n\n if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {\n setHoverStatePaused(true);\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n\n if (event.ctrlKey || event.metaKey) {\n const newIndex = 0;\n scrollToIndex(newIndex);\n setRowActiveIndex(newIndex);\n } else {\n move(-1, length, scrollToIndex);\n }\n\n return;\n } else if (event.key === 'ArrowDown') {\n event.preventDefault();\n\n if (event.ctrlKey || event.metaKey) {\n const newIndex = length - 1;\n scrollToIndex(newIndex);\n setRowActiveIndex(newIndex);\n } else {\n move(+1, length, scrollToIndex);\n }\n return;\n }\n },\n [isEnabled, rowActiveIndex]\n );\n\n const onFocus = React.useCallback(\n (event: React.FocusEvent, length: number, scrollToIndex: TableScrollToIndexHandler) => {\n if (!isEnabled || event.isDefaultPrevented()) {\n return;\n }\n\n if (event.target.closest('tbody') || isElementInsideOrTriggeredFromContainer(event.target, event.currentTarget)) {\n return;\n }\n\n if (rowActiveIndex === undefined && length > 0) {\n setRowActiveIndex(index => {\n if (index === undefined) {\n scrollToIndex(0);\n return 0;\n }\n return index;\n });\n }\n },\n [rowActiveIndex, isEnabled]\n );\n\n return {\n isEnabled,\n rowActiveIndex,\n setRowActiveIndex: isEnabled ? setRowActiveIndex : () => undefined,\n rowHoverIndex,\n setRowHoverIndex,\n isHoverStatePaused,\n setHoverStatePaused: isEnabled ? setHoverStatePaused : () => undefined,\n handleFocus: isEnabled ? onFocus : () => undefined,\n handleKeyDown: isEnabled ? onKeyDown : () => undefined,\n };\n}\n\nfunction getNextIndex(direction: -1 | 1, currentIndex: number, length: number) {\n if (direction === -1) {\n return currentIndex - 1 > 0 ? currentIndex - 1 : 0;\n }\n\n return currentIndex + 1 < length ? currentIndex + 1 : currentIndex;\n}\n"],"names":["useTableRowActive","isEnabled","initialRowActiveIndex","rowActiveIndex","setRowActiveIndex","React","useState","rowHoverIndex","setRowHoverIndex","undefined","isHoverStatePaused","setHoverStatePaused","useIsHoverStatePaused","move","direction","length","scrollToIndex","nextIndex","getNextIndex","setTimeout","onKeyDown","useCallback","event","defaultPrevented","key","preventDefault","ctrlKey","metaKey","newIndex","onFocus","isDefaultPrevented","target","closest","isElementInsideOrTriggeredFromContainer","currentTarget","index","handleFocus","handleKeyDown","currentIndex"],"mappings":";;;;SAKgBA,iBAAiBA,CAACC,SAAS,GAAG,KAAK,EAAEC,qBAA8B;EAC/E,MAAM,CAACC,cAAc,EAAEC,iBAAiB,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAqBJ,qBAAqB,CAAC;EACrG,MAAM,CAACK,aAA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CAAC,CAAC,EAAE;IAClB,OAAOwB,YAAY,GAAG,CAAC,GAAG,CAAC,GAAGA,YAAY,GAAG,CAAC,GAAG,CAAC;;EAGtD,OAAOA,YAAY,GAAG,CAAC,GAAGvB,MAAM,GAAGuB,YAAY,GAAG,CAAC,GAAGA,YAAY;AACtE;;;;"}
@@ -1,6 +1,7 @@
1
- function useTableRowExpansion(isEnabled = false, rowExpansionRenderer) {
1
+ function useTableRowExpansion(isEnabled = false, canExpandAll = true, rowExpansionRenderer) {
2
2
  return {
3
3
  isEnabled,
4
+ canExpandAll,
4
5
  rowExpansionRenderer: isEnabled ? rowExpansionRenderer : undefined
5
6
  };
6
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useTableRowExpansion.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableRowExpansion.ts"],"sourcesContent":["import { TableRowExpansionRenderer } from '../../types';\n\nexport function useTableRowExpansion<TType = unknown>(\n isEnabled = false,\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>\n) {\n return {\n isEnabled,\n rowExpansionRenderer: isEnabled ? rowExpansionRenderer : undefined,\n };\n}\n"],"names":["useTableRowExpansion","isEnabled","rowExpansionRenderer","undefined"],"mappings":"SAEgBA,oBAAoBA,CAChCC,SAAS,GAAG,KAAK,EACjBC,oBAAuD;EAEvD,OAAO;IACHD,SAAS;IACTC,oBAAoB,EAAED,SAAS,GAAGC,oBAAoB,GAAGC;GAC5D;AACL;;;;"}
1
+ {"version":3,"file":"useTableRowExpansion.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableRowExpansion.ts"],"sourcesContent":["import { TableRowExpansionRenderer } from '../../types';\n\nexport function useTableRowExpansion<TType = unknown>(\n isEnabled = false,\n canExpandAll = true,\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>\n) {\n return {\n isEnabled,\n canExpandAll,\n rowExpansionRenderer: isEnabled ? rowExpansionRenderer : undefined,\n };\n}\n"],"names":["useTableRowExpansion","isEnabled","canExpandAll","rowExpansionRenderer","undefined"],"mappings":"SAEgBA,oBAAoBA,CAChCC,SAAS,GAAG,KAAK,EACjBC,YAAY,GAAG,IAAI,EACnBC,oBAAuD;EAEvD,OAAO;IACHF,SAAS;IACTC,YAAY;IACZC,oBAAoB,EAAEF,SAAS,GAAGE,oBAAoB,GAAGC;GAC5D;AACL;;;;"}
@@ -5,7 +5,7 @@ import React__default from 'react';
5
5
  - Highlighting search results, this is custom and only uses the state part of globalFilter (to store the search query)
6
6
  - Filtering of results, this is essentially the built in filtering, and relies on enableGlobalFilter being on or off
7
7
  */
8
- function useTableSearch(isEnabled = false, defaultEnableGlobalFilter = false) {
8
+ function useTableSearch(isEnabled = false, onChangeSearch, defaultEnableGlobalFilter = false) {
9
9
  const [enableGlobalFilter, _setEnableGlobalFilter] = React__default.useState(defaultEnableGlobalFilter);
10
10
  function setEnableGlobalFilter(enabled, instance) {
11
11
  _setEnableGlobalFilter(enabled);
@@ -30,7 +30,8 @@ function useTableSearch(isEnabled = false, defaultEnableGlobalFilter = false) {
30
30
  highlightedColumnIndexes,
31
31
  setHighlightedColumnIndexes,
32
32
  currentHighlightColumnIndex,
33
- setCurrentHighlightColumnIndex
33
+ setCurrentHighlightColumnIndex,
34
+ handleSearch: isEnabled && typeof onChangeSearch === 'function' ? onChangeSearch : undefined
34
35
  };
35
36
  }
36
37
 
@@ -1 +1 @@
1
- {"version":3,"file":"useTableSearch.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableSearch.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable } from '@tanstack/react-table';\n\n/*\n Search has two behaviours:\n - Highlighting search results, this is custom and only uses the state part of globalFilter (to store the search query)\n - Filtering of results, this is essentially the built in filtering, and relies on enableGlobalFilter being on or off\n*/\nexport function useTableSearch(isEnabled = false, defaultEnableGlobalFilter = false) {\n const [enableGlobalFilter, _setEnableGlobalFilter] = React.useState<boolean>(defaultEnableGlobalFilter);\n\n function setEnableGlobalFilter<TType = unknown>(enabled: boolean, instance: ReactTable<TType>) {\n _setEnableGlobalFilter(enabled);\n\n // react-table doesn't re-render when options.enableGlobalFilter changes, so for now we force it\n const currentFilter = instance.getState().globalFilter;\n\n if (currentFilter) {\n setTimeout(() => {\n instance.setGlobalFilter('');\n instance.setGlobalFilter(currentFilter);\n }, 1);\n }\n }\n\n // highlighting\n const [highlightedColumnIndexes, setHighlightedColumnIndexes] = React.useState<number[][]>([]);\n const [currentHighlightColumnIndex, setCurrentHighlightColumnIndex] = React.useState<number | undefined>(undefined);\n\n return {\n isEnabled,\n // filtering - built-in\n enableGlobalFilter,\n setEnableGlobalFilter,\n // highlighting - custom\n highlightedColumnIndexes,\n setHighlightedColumnIndexes,\n currentHighlightColumnIndex,\n setCurrentHighlightColumnIndex,\n };\n}\n"],"names":["useTableSearch","isEnabled","defaultEnableGlobalFilter","enableGlobalFilter","_setEnableGlobalFilter","React","useState","setEnableGlobalFilter","enabled","instance","currentFilter","getState","globalFilter","setTimeout","setGlobalFilter","highlightedColumnIndexes","setHighlightedColumnIndexes","currentHighlightColumnIndex","setCurrentHighlightColumnIndex","undefined"],"mappings":";;AAGA;;;;;SAKgBA,cAAcA,CAACC,SAAS,GAAG,KAAK,EAAEC,yBAAyB,GAAG,KAAK;EAC/E,MAAM,CAACC,kBAAkB,EAAEC,sBAAsB,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAUJ,yBAAyB,CAAC;EAEvG,SAASK,qBAAqBA,CAAkBC,OAAgB,EAAEC,QAA2B;IACzFL,sBAAsB,CAACI,OAAO,CAAC;;IAG/B,MAAME,aAAa,GAAGD,QAAQ,CAACE,QAAQ,EAAE,CAACC,YAAY;IAEtD,IAAIF,aAAa,EAAE;MACfG,UAAU,CAAC;QACPJ,QAAQ,CAACK,eAAe,CAAC,EAAE,CAAC;QAC5BL,QAAQ,CAACK,eAAe,CAACJ,aAAa,CAAC;OAC1C,EAAE,CAAC,CAAC;;;;EAKb,MAAM,CAACK,wBAAwB,EAAEC,2BAA2B,CAAC,GAAGX,cAAK,CAACC,QAAQ,CAAa,EAAE,CAAC;EAC9F,MAAM,CAACW,2BAA2B,EAAEC,8BAA8B,CAAC,GAAGb,cAAK,CAACC,QAAQ,CAAqBa,SAAS,CAAC;EAEnH,OAAO;IACHlB,SAAS;;IAETE,kBAAkB;IAClBI,qBAAqB;;IAErBQ,wBAAwB;IACxBC,2BAA2B;IAC3BC,2BAA2B;IAC3BC;GACH;AACL;;;;"}
1
+ {"version":3,"file":"useTableSearch.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableSearch.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable } from '@tanstack/react-table';\nimport { TableSearchHandler } from '../../types';\n\n/*\n Search has two behaviours:\n - Highlighting search results, this is custom and only uses the state part of globalFilter (to store the search query)\n - Filtering of results, this is essentially the built in filtering, and relies on enableGlobalFilter being on or off\n*/\nexport function useTableSearch<TType = unknown>(\n isEnabled = false,\n onChangeSearch: TableSearchHandler | undefined,\n defaultEnableGlobalFilter = false\n) {\n const [enableGlobalFilter, _setEnableGlobalFilter] = React.useState<boolean>(defaultEnableGlobalFilter);\n\n function setEnableGlobalFilter<T extends TType>(enabled: boolean, instance: ReactTable<T>) {\n _setEnableGlobalFilter(enabled);\n\n // react-table doesn't re-render when options.enableGlobalFilter changes, so for now we force it\n const currentFilter = instance.getState().globalFilter;\n\n if (currentFilter) {\n setTimeout(() => {\n instance.setGlobalFilter('');\n instance.setGlobalFilter(currentFilter);\n }, 1);\n }\n }\n\n // highlighting\n const [highlightedColumnIndexes, setHighlightedColumnIndexes] = React.useState<number[][]>([]);\n const [currentHighlightColumnIndex, setCurrentHighlightColumnIndex] = React.useState<number | undefined>(undefined);\n\n return {\n isEnabled,\n // filtering - built-in\n enableGlobalFilter,\n setEnableGlobalFilter,\n // highlighting - custom\n highlightedColumnIndexes,\n setHighlightedColumnIndexes,\n currentHighlightColumnIndex,\n setCurrentHighlightColumnIndex,\n handleSearch: isEnabled && typeof onChangeSearch === 'function' ? onChangeSearch : undefined,\n };\n}\n"],"names":["useTableSearch","isEnabled","onChangeSearch","defaultEnableGlobalFilter","enableGlobalFilter","_setEnableGlobalFilter","React","useState","setEnableGlobalFilter","enabled","instance","currentFilter","getState","globalFilter","setTimeout","setGlobalFilter","highlightedColumnIndexes","setHighlightedColumnIndexes","currentHighlightColumnIndex","setCurrentHighlightColumnIndex","undefined","handleSearch"],"mappings":";;AAIA;;;;;SAKgBA,cAAcA,CAC1BC,SAAS,GAAG,KAAK,EACjBC,cAA8C,EAC9CC,yBAAyB,GAAG,KAAK;EAEjC,MAAM,CAACC,kBAAkB,EAAEC,sBAAsB,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAUJ,yBAAyB,CAAC;EAEvG,SAASK,qBAAqBA,CAAkBC,OAAgB,EAAEC,QAAuB;IACrFL,sBAAsB,CAACI,OAAO,CAAC;;IAG/B,MAAME,aAAa,GAAGD,QAAQ,CAACE,QAAQ,EAAE,CAACC,YAAY;IAEtD,IAAIF,aAAa,EAAE;MACfG,UAAU,CAAC;QACPJ,QAAQ,CAACK,eAAe,CAAC,EAAE,CAAC;QAC5BL,QAAQ,CAACK,eAAe,CAACJ,aAAa,CAAC;OAC1C,EAAE,CAAC,CAAC;;;;EAKb,MAAM,CAACK,wBAAwB,EAAEC,2BAA2B,CAAC,GAAGX,cAAK,CAACC,QAAQ,CAAa,EAAE,CAAC;EAC9F,MAAM,CAACW,2BAA2B,EAAEC,8BAA8B,CAAC,GAAGb,cAAK,CAACC,QAAQ,CAAqBa,SAAS,CAAC;EAEnH,OAAO;IACHnB,SAAS;;IAETG,kBAAkB;IAClBI,qBAAqB;;IAErBQ,wBAAwB;IACxBC,2BAA2B;IAC3BC,2BAA2B;IAC3BC,8BAA8B;IAC9BE,YAAY,EAAEpB,SAAS,IAAI,OAAOC,cAAc,KAAK,UAAU,GAAGA,cAAc,GAAGkB;GACtF;AACL;;;;"}
@@ -2,7 +2,7 @@ import React__default from 'react';
2
2
  import { TableServerLoadAllState } from '../../types.js';
3
3
  import { DEFAULT_PAGE_SIZE } from '../../useTableDataLoader.js';
4
4
 
5
- function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE) {
5
+ function useTableServerLoading(loadPage, loadAll, pages, pageSize = DEFAULT_PAGE_SIZE, _experimentalDataLoader2 = false) {
6
6
  const isEnabled = !!loadPage && !!loadAll;
7
7
  const [isReady, setReady] = React__default.useState(false);
8
8
  const [loadAllStatus, setLoadedStatus] = React__default.useState(TableServerLoadAllState.Incomplete);
@@ -57,13 +57,15 @@ function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE)
57
57
  };
58
58
  }
59
59
  return {
60
+ pages,
60
61
  isEnabled,
61
62
  isReady,
62
63
  loadPage: _loadPage,
63
64
  loadAll: _loadAll,
64
65
  loadAllIfNeeded: _loadAllIfNeeded,
65
66
  loadAllStatus,
66
- pageSize
67
+ pageSize,
68
+ _experimentalDataLoader2
67
69
  };
68
70
  }
69
71
 
@@ -1 +1 @@
1
- {"version":3,"file":"useTableServerLoading.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableServerLoading.ts"],"sourcesContent":["import React from 'react';\nimport { TableServerLoadAllHandler, TableServerLoadAllState, TableServerLoadPageHandler } from '../../types';\nimport { DEFAULT_PAGE_SIZE } from '../../useTableDataLoader';\n\nexport function useTableServerLoading(\n loadPage?: TableServerLoadPageHandler,\n loadAll?: TableServerLoadAllHandler,\n pageSize = DEFAULT_PAGE_SIZE\n) {\n const isEnabled = !!loadPage && !!loadAll;\n const [isReady, setReady] = React.useState(false);\n const [loadAllStatus, setLoadedStatus] = React.useState<TableServerLoadAllState>(TableServerLoadAllState.Incomplete);\n\n let _loadPage: TableServerLoadPageHandler | undefined;\n let _loadAll: TableServerLoadAllHandler | undefined;\n let _loadAllIfNeeded: TableServerLoadAllHandler | undefined;\n\n if (typeof loadPage === 'function') {\n _loadPage = async (...args) => {\n if (typeof loadPage === 'function') {\n await loadPage(...args);\n setReady(true);\n }\n };\n }\n\n if (typeof loadAll === 'function') {\n _loadAll = async (...args) => {\n if (typeof loadAll === 'function') {\n setLoadedStatus(TableServerLoadAllState.Loading);\n await loadAll(...args);\n setLoadedStatus(TableServerLoadAllState.Completed);\n setReady(true);\n }\n };\n\n _loadAllIfNeeded = async (...args) => {\n if (loadAllStatus === TableServerLoadAllState.Incomplete) {\n await _loadAll?.(...args);\n }\n };\n }\n\n return {\n isEnabled,\n isReady,\n loadPage: _loadPage,\n loadAll: _loadAll,\n loadAllIfNeeded: _loadAllIfNeeded,\n loadAllStatus,\n pageSize,\n };\n}\n"],"names":["useTableServerLoading","loadPage","loadAll","pageSize","DEFAULT_PAGE_SIZE","isEnabled","isReady","setReady","React","useState","loadAllStatus","setLoadedStatus","TableServerLoadAllState","Incomplete","_loadPage","_loadAll","_loadAllIfNeeded","args","Promise","resolve","then","_temp","e","reject","Loading","Completed","_temp2","_loadAll2","_temp3","loadAllIfNeeded"],"mappings":";;;;SAIgBA,qBAAqBA,CACjCC,QAAqC,EACrCC,OAAmC,EACnCC,QAAQ,GAAGC,iBAAiB;EAE5B,MAAMC,SAAS,GAAG,CAAC,CAACJ,QAAQ,IAAI,CAAC,CAACC,OAAO;EACzC,MAAM,CAACI,OAAO,EAAEC,QAAQ,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EACjD,MAAM,CAACC,aAAa,EAAEC,eAAe,CAAC,GAAGH,cAAK,CAACC,QAAQ,CAA0BG,uBAAuB,CAACC,UAAU,CAAC;EAEpH,IAAIC,SAAiD;EACrD,IAAIC,QAA+C;EACnD,IAAIC,gBAAuD;EAE3D,IAAI,OAAOf,QAAQ,KAAK,UAAU,EAAE;IAChCa,SAAS,aAAU,GAAGG,IAAI;MAAA;;cAClB,OAAOhB,QAAQ,KAAK,UAAU;YAAA,OAAAiB,OAAA,CAAAC,OAAA,CACxBlB,QAAQ,CAAC,GAAGgB,IAAI,CAAC,EAAAG,IAAA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AgB;IACjCN,aAAa;IACbP;GACH;AACL;;;;"}
1
+ {"version":3,"file":"useTableServerLoading.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableServerLoading.ts"],"sourcesContent":["import React from 'react';\nimport { TableServerLoadAllHandler, TableServerLoadAllState, TableServerLoadPageHandler } from '../../types';\nimport { DEFAULT_PAGE_SIZE } from '../../useTableDataLoader';\n\nexport function useTableServerLoading(\n loadPage?: TableServerLoadPageHandler,\n loadAll?: TableServerLoadAllHandler,\n pages?: number[],\n pageSize = DEFAULT_PAGE_SIZE,\n _experimentalDataLoader2 = false\n) {\n const isEnabled = !!loadPage && !!loadAll;\n const [isReady, setReady] = React.useState(false);\n const [loadAllStatus, setLoadedStatus] = React.useState<TableServerLoadAllState>(TableServerLoadAllState.Incomplete);\n\n let _loadPage: TableServerLoadPageHandler | undefined;\n let _loadAll: TableServerLoadAllHandler | undefined;\n let _loadAllIfNeeded: TableServerLoadAllHandler | undefined;\n\n if (typeof loadPage === 'function') {\n _loadPage = async (...args) => {\n if (typeof loadPage === 'function') {\n await loadPage(...args);\n setReady(true);\n }\n };\n }\n\n if (typeof loadAll === 'function') {\n _loadAll = async (...args) => {\n if (typeof loadAll === 'function') {\n setLoadedStatus(TableServerLoadAllState.Loading);\n await loadAll(...args);\n setLoadedStatus(TableServerLoadAllState.Completed);\n setReady(true);\n }\n };\n\n _loadAllIfNeeded = async (...args) => {\n if (loadAllStatus === TableServerLoadAllState.Incomplete) {\n await _loadAll?.(...args);\n }\n };\n }\n\n return {\n pages,\n isEnabled,\n isReady,\n loadPage: _loadPage,\n loadAll: _loadAll,\n loadAllIfNeeded: _loadAllIfNeeded,\n loadAllStatus,\n pageSize,\n _experimentalDataLoader2,\n };\n}\n"],"names":["useTableServerLoading","loadPage","loadAll","pages","pageSize","DEFAULT_PAGE_SIZE","_experimentalDataLoader2","isEnabled","isReady","setReady","React","useState","loadAllStatus","setLoadedStatus","TableServerLoadAllState","Incomplete","_loadPage","_loadAll","_lo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AuB,CAACa,SAAS,CAAC;cAClDlB,QAAQ,CAAC,IAAI,CAAC;;;;QAAC,OAAAW,OAAA,CAAAC,OAAA,CAAAO,MAAA,IAAAA,MAAA,CAAAN,IAAA,GAAAM,MAAA,CAAAN,IAAA;OAEtB,QAAAE,CAAA;QAAA,OAAAJ,OAAA,CAAAK,MAAA,CAAAD,CAAA;;;IAEDN,gBAAgB,aAAU,GAAGC,IAAI;MAAA;;cACzBP,aAAa,KAAKE,uBAAuB,CAACC,UAAU;YAAA,IAAAc,SAAA;YAAA,OAAAT,OAAA,CAAAC,OAAA,EAAAQ,SAAA,GAC9CZ,QAAQ,cAAAY,SAAA,uBAARA,SAAA,CAAW,GAAGV,IAAI,CAAC,EAAAG,IAAA;;;QAAA,OAAAF,OAAA,CAAAC,OAAA,CAAAS,MAAA,IAAAA,MAAA,CAAAR,IAAA,GAAAQ,MAAA,CAAAR,IAAA;OAEhC,QAAAE,CAAA;QAAA,OAAAJ,OAAA,CAAAK,MAAA,CAAAD,CAAA;;;;EAGL,OAAO;IACHrB,KAAK;IACLI,SAAS;IACTC,OAAO;IACPP,QAAQ,EAAEe,SAAS;IACnBd,OAAO,EAAEe,QAAQ;IACjBc,eAAe,EAAEb,gBAAgB;IACjCN,aAAa;IACbR,QAAQ;IACRE;GACH;AACL;;;;"}
@@ -1,3 +1,4 @@
1
+ import { getHiddenColumns } from '../util/columns.js';
1
2
  import { useLazyEffect } from '../../../../hooks/useLazyEffect.js';
2
3
 
3
4
  // we use a listener, and not the internal "controlled" change handlers because we don't actually want consumers
@@ -7,7 +8,8 @@ function useTableFilterListener(table, onFilter) {
7
8
  const columnFilters = table.getState().columnFilters;
8
9
  useLazyEffect(() => {
9
10
  if (table.options.enableColumnFilters && typeof onFilter === 'function') {
10
- onFilter(columnFilters);
11
+ const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);
12
+ onFilter(columnFilters, hiddenColumns);
11
13
  if (table.options.enableRowSelection) {
12
14
  table.resetRowSelection();
13
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useTableFilterListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableFilterListener.ts"],"sourcesContent":["import { Table as ReactTable } from '@tanstack/react-table';\nimport { useLazyEffect } from '../../../../hooks/useLazyEffect';\nimport { TableFilterHandler } from '../../types';\n\n// we use a listener, and not the internal \"controlled\" change handlers because we don't actually want consumers\n// to control the state outside the table. this listener is really here to let the consumer make a server request\n// and provide the server with the filtering state, so that it can filter server side\nexport function useTableFilterListener<TType = unknown>(table: ReactTable<TType>, onFilter?: TableFilterHandler) {\n const columnFilters = table.getState().columnFilters;\n\n useLazyEffect(() => {\n if (table.options.enableColumnFilters && typeof onFilter === 'function') {\n onFilter(columnFilters);\n\n if (table.options.enableRowSelection) {\n table.resetRowSelection();\n }\n }\n }, [table.options.enableColumnFilters, columnFilters]);\n}\n"],"names":["useTableFilterListener","table","onFilter","columnFilters","getState","useLazyEffect","options","enableColumnFilters","enableRowSelection","resetRowSelection"],"mappings":";;AAIA;AACA;AACA;SACgBA,sBAAsBA,CAAkBC,KAAwB,EAAEC,QAA6B;EAC3G,MAAMC,aAAa,GAAGF,KAAK,CAACG,QAAQ,EAAE,CAACD,aAAa;EAEpDE,aAAa,CAAC;IACV,IAAIJ,KAAK,CAACK,OAAO,CAACC,mBAAmB,IAAI,OAAOL,QAAQ,KAAK,UAAU,EAAE;MACrEA,QAAQ,CAACC,aAAa,CAAC;MAEvB,IAAIF,KAAK,CAACK,OAAO,CAACE,kBAAkB,EAAE;QAClCP,KAAK,CAACQ,iBAAiB,EAAE;;;GAGpC,EAAE,CAACR,KAAK,CAACK,OAAO,CAACC,mBAAmB,EAAEJ,aAAa,CAAC,CAAC;AAC1D;;;;"}
1
+ {"version":3,"file":"useTableFilterListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableFilterListener.ts"],"sourcesContent":["import { Table as ReactTable } from '@tanstack/react-table';\nimport { useLazyEffect } from '../../../../hooks/useLazyEffect';\nimport { TableFilterHandler } from '../../types';\nimport { getHiddenColumns } from '../util/columns';\n\n// we use a listener, and not the internal \"controlled\" change handlers because we don't actually want consumers\n// to control the state outside the table. this listener is really here to let the consumer make a server request\n// and provide the server with the filtering state, so that it can filter server side\nexport function useTableFilterListener<TType = unknown>(table: ReactTable<TType>, onFilter?: TableFilterHandler) {\n const columnFilters = table.getState().columnFilters;\n\n useLazyEffect(() => {\n if (table.options.enableColumnFilters && typeof onFilter === 'function') {\n const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);\n onFilter(columnFilters, hiddenColumns);\n\n if (table.options.enableRowSelection) {\n table.resetRowSelection();\n }\n }\n }, [table.options.enableColumnFilters, columnFilters]);\n}\n"],"names":["useTableFilterListener","table","onFilter","columnFilters","getState","useLazyEffect","options","enableColumnFilters","hiddenColumns","getHiddenColumns","columnVisibility","enableRowSelection","resetRowSelection"],"mappings":";;;AAKA;AACA;AACA;SACgBA,sBAAsBA,CAAkBC,KAAwB,EAAEC,QAA6B;EAC3G,MAAMC,aAAa,GAAGF,KAAK,CAACG,QAAQ,EAAE,CAACD,aAAa;EAEpDE,aAAa,CAAC;IACV,IAAIJ,KAAK,CAACK,OAAO,CAACC,mBAAmB,IAAI,OAAOL,QAAQ,KAAK,UAAU,EAAE;MACrE,MAAMM,aAAa,GAAGC,gBAAgB,CAACR,KAAK,CAACG,QAAQ,EAAE,CAACM,gBAAgB,CAAC;MACzER,QAAQ,CAACC,aAAa,EAAEK,aAAa,CAAC;MAEtC,IAAIP,KAAK,CAACK,OAAO,CAACK,kBAAkB,EAAE;QAClCV,KAAK,CAACW,iBAAiB,EAAE;;;GAGpC,EAAE,CAACX,KAAK,CAACK,OAAO,CAACC,mBAAmB,EAAEJ,aAAa,CAAC,CAAC;AAC1D;;;;"}
@@ -1,12 +1,12 @@
1
- import React__default from 'react';
2
1
  import { useLazyEffect } from '../../../../hooks/useLazyEffect.js';
3
2
 
4
3
  function useTableRowSelectionListener(table, onRowSelect) {
4
+ // note that the selected row model may not contain all rows in state when using server loading
5
5
  const rows = table.getSelectedRowModel().flatRows;
6
- const rowSelection = React__default.useMemo(() => rows.map(row => row.original), [rows]);
6
+ const state = table.getState().rowSelection;
7
7
  useLazyEffect(() => {
8
8
  if (table.options.enableRowSelection && typeof onRowSelect === 'function') {
9
- onRowSelect(rowSelection);
9
+ onRowSelect(rows.map(row => row.original), Object.keys(state));
10
10
  }
11
11
  /**
12
12
  * Casting to a boolean, since enableRowSelection can be a function,
@@ -14,7 +14,7 @@ function useTableRowSelectionListener(table, onRowSelect) {
14
14
  * we only need to know if selection was enabled or disabled, because enableRowSelection function
15
15
  * will be applied directly to particular rows.
16
16
  */
17
- }, [!!table.options.enableRowSelection, JSON.stringify(rowSelection)]);
17
+ }, [!!table.options.enableRowSelection, state]);
18
18
  }
19
19
 
20
20
  export { useTableRowSelectionListener };
@@ -1 +1 @@
1
- {"version":3,"file":"useTableRowSelectionListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableRowSelectionListener.ts"],"sourcesContent":["import { Table as ReactTable } from '@tanstack/react-table';\nimport { useLazyEffect } from '../../../../hooks/useLazyEffect';\nimport { TableRowSelectHandler } from '../../types';\nimport React from 'react';\n\nexport function useTableRowSelectionListener<TType = unknown>(\n table: ReactTable<TType>,\n onRowSelect?: TableRowSelectHandler<TType>\n) {\n const rows = table.getSelectedRowModel().flatRows;\n const rowSelection = React.useMemo(() => rows.map(row => row.original), [rows]);\n\n useLazyEffect(() => {\n if (table.options.enableRowSelection && typeof onRowSelect === 'function') {\n onRowSelect(rowSelection);\n }\n /**\n * Casting to a boolean, since enableRowSelection can be a function,\n * and setting a function as depoendency will lead to infinity loop. And in case of row selection useEffect,\n * we only need to know if selection was enabled or disabled, because enableRowSelection function\n * will be applied directly to particular rows.\n */\n }, [!!table.options.enableRowSelection, JSON.stringify(rowSelection)]);\n}\n"],"names":["useTableRowSelectionListener","table","onRowSelect","rows","getSelectedRowModel","flatRows","rowSelection","React","useMemo","map","row","original","useLazyEffect","options","enableRowSelection","JSON","stringify"],"mappings":";;;SAKgBA,4BAA4BA,CACxCC,KAAwB,EACxBC,WAA0C;EAE1C,MAAMC,IAAI,GAAGF,KAAK,CAACG,mBAAmB,EAAE,CAACC,QAAQ;EACjD,MAAMC,YAAY,GAAGC,cAAK,CAACC,OAAO,CAAC,MAAML,IAAI,CAACM,GAAG,CAACC,GAAG,IAAIA,GAAG,CAACC,QAAQ,CAAC,EAAE,CAACR,IAAI,CAAC,CAAC;EAE/ES,aAAa,CAAC;IACV,IAAIX,KAAK,CAACY,OAAO,CAACC,kBAAkB,IAAI,OAAOZ,WAAW,KAAK,UAAU,EAAE;MACvEA,WAAW,CAACI,YAAY,CAAC;;;;;;;;GAQhC,EAAE,CAAC,CAAC,CAACL,KAAK,CAACY,OAAO,CAACC,kBAAkB,EAAEC,IAAI,CAACC,SAAS,CAACV,YAAY,CAAC,CAAC,CAAC;AAC1E;;;;"}
1
+ {"version":3,"file":"useTableRowSelectionListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableRowSelectionListener.ts"],"sourcesContent":["import { Table as ReactTable } from '@tanstack/react-table';\nimport { useLazyEffect } from '../../../../hooks/useLazyEffect';\nimport { TableRowSelectHandler } from '../../types';\n\nexport function useTableRowSelectionListener<TType = unknown>(\n table: ReactTable<TType>,\n onRowSelect?: TableRowSelectHandler<TType>\n) {\n // note that the selected row model may not contain all rows in state when using server loading\n const rows = table.getSelectedRowModel().flatRows;\n const state = table.getState().rowSelection;\n\n useLazyEffect(() => {\n if (table.options.enableRowSelection && typeof onRowSelect === 'function') {\n onRowSelect(\n rows.map(row => row.original),\n Object.keys(state) as (keyof TType)[]\n );\n }\n /**\n * Casting to a boolean, since enableRowSelection can be a function,\n * and setting a function as depoendency will lead to infinity loop. And in case of row selection useEffect,\n * we only need to know if selection was enabled or disabled, because enableRowSelection function\n * will be applied directly to particular rows.\n */\n }, [!!table.options.enableRowSelection, state]);\n}\n"],"names":["useTableRowSelectionListener","table","onRowSelect","rows","getSelectedRowModel","flatRows","state","getState","rowSelection","useLazyEffect","options","enableRowSelection","map","row","original","Object","keys"],"mappings":";;SAIgBA,4BAA4BA,CACxCC,KAAwB,EACxBC,WAA0C;;EAG1C,MAAMC,IAAI,GAAGF,KAAK,CAACG,mBAAmB,EAAE,CAACC,QAAQ;EACjD,MAAMC,KAAK,GAAGL,KAAK,CAACM,QAAQ,EAAE,CAACC,YAAY;EAE3CC,aAAa,CAAC;IACV,IAAIR,KAAK,CAACS,OAAO,CAACC,kBAAkB,IAAI,OAAOT,WAAW,KAAK,UAAU,EAAE;MACvEA,WAAW,CACPC,IAAI,CAACS,GAAG,CAACC,GAAG,IAAIA,GAAG,CAACC,QAAQ,CAAC,EAC7BC,MAAM,CAACC,IAAI,CAACV,KAAK,CAAoB,CACxC;;;;;;;;GAQR,EAAE,CAAC,CAAC,CAACL,KAAK,CAACS,OAAO,CAACC,kBAAkB,EAAEL,KAAK,CAAC,CAAC;AACnD;;;;"}
@@ -1,31 +1,32 @@
1
- import React__default from 'react';
2
1
  import { useLocalization } from '../../../../components/Provider/Localization.js';
3
2
  import { resetHighlightedColumnIndexes } from '../util/search.js';
3
+ import { getHiddenColumns } from '../util/columns.js';
4
+ import { useLazyEffect } from '../../../../hooks/useLazyEffect.js';
4
5
 
5
- function useTableSearchListener(table, onChangeSearch) {
6
+ function useTableSearchListener(table) {
6
7
  const meta = table.options.meta;
7
8
  const localization = useLocalization();
8
- const visibleColumns = table.getVisibleFlatColumns();
9
+ const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);
10
+ const query = table.getState().globalFilter;
9
11
  // Need to re-run search when columns are getting shown/hidden.
10
- React__default.useEffect(() => {
11
- if (meta.search.isEnabled && visibleColumns.length > 0) {
12
- const currentFilter = table.getState().globalFilter;
12
+ useLazyEffect(() => {
13
+ if (meta.search.isEnabled) {
14
+ const currentFilter = query;
13
15
  requestAnimationFrame(() => {
14
16
  table.resetGlobalFilter();
15
17
  table.setGlobalFilter(currentFilter);
16
18
  });
19
+ if (meta.search.handleSearch && meta.search.enableGlobalFilter && query) {
20
+ meta.search.handleSearch(query, hiddenColumns);
21
+ }
17
22
  }
18
- }, [visibleColumns.length]);
23
+ }, [hiddenColumns.length]);
19
24
  // recalculates highlighted indexes whenever something important changes
20
- React__default.useEffect(() => {
25
+ useLazyEffect(() => {
21
26
  if (meta.search.isEnabled) {
22
- const query = table.getState().globalFilter;
23
27
  resetHighlightedColumnIndexes(query, table, localization);
24
- if (typeof onChangeSearch === 'function') {
25
- onChangeSearch(query);
26
- }
27
28
  }
28
- }, [meta.server.loadAllStatus, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length, table.getState().globalFilter, JSON.stringify(table.getState().sorting), onChangeSearch]);
29
+ }, [meta.server.loadAllStatus, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length, query, JSON.stringify(table.getState().sorting)]);
29
30
  }
30
31
 
31
32
  export { useTableSearchListener };
@@ -1 +1 @@
1
- {"version":3,"file":"useTableSearchListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableSearchListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { resetHighlightedColumnIndexes } from '../util/search';\nimport { TableSearchHandler } from '../../types';\nimport { useLocalization } from '../../../../components/Provider/Localization';\n\nexport function useTableSearchListener<TType = unknown>(table: ReactTable<TType>, onChangeSearch?: TableSearchHandler) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const localization = useLocalization();\n\n const visibleColumns = table.getVisibleFlatColumns();\n\n // Need to re-run search when columns are getting shown/hidden.\n React.useEffect(() => {\n if (meta.search.isEnabled && visibleColumns.length > 0) {\n const currentFilter = table.getState().globalFilter;\n requestAnimationFrame(() => {\n table.resetGlobalFilter();\n table.setGlobalFilter(currentFilter);\n });\n }\n }, [visibleColumns.length]);\n\n // recalculates highlighted indexes whenever something important changes\n React.useEffect(() => {\n if (meta.search.isEnabled) {\n const query = table.getState().globalFilter;\n resetHighlightedColumnIndexes(query, table, localization);\n\n if (typeof onChangeSearch === 'function') {\n onChangeSearch(query);\n }\n }\n }, [\n meta.server.loadAllStatus,\n meta.search.isEnabled,\n meta.search.enableGlobalFilter,\n table.getRowModel().rows.length,\n table.getState().globalFilter,\n JSON.stringify(table.getState().sorting),\n onChangeSearch,\n ]);\n}\n"],"names":["useTableSearchListener","table","onChangeSearch","meta","options","localization","useLocalization","visibleColumns","getVisibleFlatColumns","React","useEffect","search","isEnabled","length","currentFilter","getState","globalFilter","requestAnimationFrame","resetGlobalFilter","setGlobalFilter","query","resetHighlightedColumnIndexes","server","loadAllStatus","enableGlobalFilter","getRowModel","rows","JSON","stringify","sorting"],"mappings":";;;;SAMgBA,sBAAsBA,CAAkBC,KAAwB,EAAEC,cAAmC;EACjH,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAA6B;EACxD,MAAME,YAAY,GAAGC,eAAe,EAAE;EAEtC,MAAMC,cAAc,GAAGN,KAAK,CAACO,qBAAqB,EAAE;;EAGpDC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIP,IAAI,CAACQ,MAAM,CAACC,SAAS,IAAIL,cAAc,CAACM,MAAM,GAAG,CAAC,EAAE;MACpD,MAAMC,aAAa,GAAGb,KAAK,CAACc,QAAQ,EAAE,CAACC,YAAY;MACnDC,qBAAqB,CAAC;QAClBhB,KAAK,CAACiB,iBAAiB,EAAE;QACzBjB,KAAK,CAACkB,eAAe,CAACL,aAAa,CAAC;OACvC,CAAC;;GAET,EAAE,CAACP,cAAc,CAACM,MAAM,CAAC,CAAC;;EAG3BJ,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIP,IAAI,CAACQ,MAAM,CAACC,SAAS,EAAE;MACvB,MAAMQ,KAAK,GAAGnB,KAAK,CAACc,QAAQ,EAAE,CAACC,YAAY;MAC3CK,6BAA6B,CAACD,KAAK,EAAEnB,KAAK,EAAEI,YAAY,CAAC;MAEzD,IAAI,OAAOH,cAAc,KAAK,UAAU,EAAE;QACtCA,cAAc,CAACkB,KAAK,CAAC;;;GAGhC,EAAE,CACCjB,IAAI,CAACmB,MAAM,CAACC,aAAa,EACzBpB,IAAI,CAACQ,MAAM,CAACC,SAAS,EACrBT,IAAI,CAACQ,MAAM,CAACa,kBAAkB,EAC9BvB,KAAK,CAACwB,WAAW,EAAE,CAACC,IAAI,CAACb,MAAM,EAC/BZ,KAAK,CAACc,QAAQ,EAAE,CAACC,YAAY,EAC7BW,IAAI,CAACC,SAAS,CAAC3B,KAAK,CAACc,QAAQ,EAAE,CAACc,OAAO,CAAC,EACxC3B,cAAc,CACjB,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"useTableSearchListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableSearchListener.ts"],"sourcesContent":["import { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { resetHighlightedColumnIndexes } from '../util/search';\nimport { useLocalization } from '../../../../components/Provider/Localization';\nimport { useLazyEffect } from '../../../../hooks/useLazyEffect';\nimport { getHiddenColumns } from '../util/columns';\n\nexport function useTableSearchListener<TType = unknown>(table: ReactTable<TType>) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const localization = useLocalization();\n const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);\n const query = table.getState().globalFilter;\n\n // Need to re-run search when columns are getting shown/hidden.\n useLazyEffect(() => {\n if (meta.search.isEnabled) {\n const currentFilter = query;\n requestAnimationFrame(() => {\n table.resetGlobalFilter();\n table.setGlobalFilter(currentFilter);\n });\n\n if (meta.search.handleSearch && meta.search.enableGlobalFilter && query) {\n meta.search.handleSearch(query, hiddenColumns);\n }\n }\n }, [hiddenColumns.length]);\n\n // recalculates highlighted indexes whenever something important changes\n useLazyEffect(() => {\n if (meta.search.isEnabled) {\n resetHighlightedColumnIndexes(query, table, localization);\n }\n }, [\n meta.server.loadAllStatus,\n meta.search.isEnabled,\n meta.search.enableGlobalFilter,\n table.getRowModel().rows.length,\n query,\n JSON.stringify(table.getState().sorting),\n ]);\n}\n"],"names":["useTableSearchListener","table","meta","options","localization","useLocalization","hiddenColumns","getHiddenColumns","getState","columnVisibility","query","globalFilter","useLazyEffect","search","isEnabled","currentFilter","requestAnimationFrame","resetGlobalFilter","setGlobalFilter","handleSearch","enableGlobalFilter","length","resetHighlightedColumnIndexes","server","loadAllStatus","getRowModel","rows","JSON","stringify","sorting"],"mappings":";;;;;SAMgBA,sBAAsBA,CAAkBC,KAAwB;EAC5E,MAAMC,IAAI,GAAGD,KAAK,CAACE,OAAO,CAACD,IAA6B;EACxD,MAAME,YAAY,GAAGC,eAAe,EAAE;EACtC,MAAMC,aAAa,GAAGC,gBAAgB,CAACN,KAAK,CAACO,QAAQ,EAAE,CAACC,gBAAgB,CAAC;EACzE,MAAMC,KAAK,GAAGT,KAAK,CAACO,QAAQ,EAAE,CAACG,YAAY;;EAG3CC,aAAa,CAAC;IACV,IAAIV,IAAI,CAACW,MAAM,CAACC,SAAS,EAAE;MACvB,MAAMC,aAAa,GAAGL,KAAK;MAC3BM,qBAAqB,CAAC;QAClBf,KAAK,CAACgB,iBAAiB,EAAE;QACzBhB,KAAK,CAACiB,eAAe,CAACH,aAAa,CAAC;OACvC,CAAC;MAEF,IAAIb,IAAI,CAACW,MAAM,CAACM,YAAY,IAAIjB,IAAI,CAACW,MAAM,CAACO,kBAAkB,IAAIV,KAAK,EAAE;QACrER,IAAI,CAACW,MAAM,CAACM,YAAY,CAACT,KAAK,EAAEJ,aAAa,CAAC;;;GAGzD,EAAE,CAACA,aAAa,CAACe,MAAM,CAAC,CAAC;;EAG1BT,aAAa,CAAC;IACV,IAAIV,IAAI,CAACW,MAAM,CAACC,SAAS,EAAE;MACvBQ,6BAA6B,CAACZ,KAAK,EAAET,KAAK,EAAEG,YAAY,CAAC;;GAEhE,EAAE,CACCF,IAAI,CAACqB,MAAM,CAACC,aAAa,EACzBtB,IAAI,CAACW,MAAM,CAACC,SAAS,EACrBZ,IAAI,CAACW,MAAM,CAACO,kBAAkB,EAC9BnB,KAAK,CAACwB,WAAW,EAAE,CAACC,IAAI,CAACL,MAAM,EAC/BX,KAAK,EACLiB,IAAI,CAACC,SAAS,CAAC3B,KAAK,CAACO,QAAQ,EAAE,CAACqB,OAAO,CAAC,CAC3C,CAAC;AACN;;;;"}
@@ -1,12 +1,16 @@
1
1
  import React__default from 'react';
2
+ import { getHiddenColumns } from '../util/columns.js';
2
3
 
3
4
  function useTableServerLoadingListener(table, loadPage) {
4
- const sorting = table.getState().sorting;
5
- const columnFilters = table.getState().columnFilters;
5
+ const meta = table.options.meta;
6
6
  // trigger load of the first page on mount
7
7
  React__default.useEffect(() => {
8
8
  if (loadPage) {
9
- loadPage(0, sorting, columnFilters);
9
+ const sorting = table.getState().sorting;
10
+ const columnFilters = table.getState().columnFilters;
11
+ const search = meta.search.enableGlobalFilter ? table.getState().globalFilter : undefined;
12
+ const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);
13
+ loadPage(0, sorting, columnFilters, search, hiddenColumns);
10
14
  }
11
15
  }, []);
12
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useTableServerLoadingListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableServerLoadingListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable } from '@tanstack/react-table';\nimport { TableServerLoadPageHandler } from '../../types';\n\nexport function useTableServerLoadingListener<TType = unknown>(table: ReactTable<TType>, loadPage?: TableServerLoadPageHandler) {\n const sorting = table.getState().sorting;\n const columnFilters = table.getState().columnFilters;\n\n // trigger load of the first page on mount\n React.useEffect(() => {\n if (loadPage) {\n loadPage(0, sorting, columnFilters);\n }\n }, []);\n}\n"],"names":["useTableServerLoadingListener","table","loadPage","sorting","getState","columnFilters","React","useEffect"],"mappings":";;SAIgBA,6BAA6BA,CAAkBC,KAAwB,EAAEC,QAAqC;EAC1H,MAAMC,OAAO,GAAGF,KAAK,CAACG,QAAQ,EAAE,CAACD,OAAO;EACxC,MAAME,aAAa,GAAGJ,KAAK,CAACG,QAAQ,EAAE,CAACC,aAAa;;EAGpDC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIL,QAAQ,EAAE;MACVA,QAAQ,CAAC,CAAC,EAAEC,OAAO,EAAEE,aAAa,CAAC;;GAE1C,EAAE,EAAE,CAAC;AACV;;;;"}
1
+ {"version":3,"file":"useTableServerLoadingListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableServerLoadingListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { TableServerLoadPageHandler } from '../../types';\nimport { getHiddenColumns } from '../util/columns';\n\nexport function useTableServerLoadingListener<TType = unknown>(table: ReactTable<TType>, loadPage?: TableServerLoadPageHandler) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n\n // trigger load of the first page on mount\n React.useEffect(() => {\n if (loadPage) {\n const sorting = table.getState().sorting;\n const columnFilters = table.getState().columnFilters;\n const search = meta.search.enableGlobalFilter ? table.getState().globalFilter : undefined;\n const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);\n\n loadPage(0, sorting, columnFilters, search, hiddenColumns);\n }\n }, []);\n}\n"],"names":["useTableServerLoadingListener","table","loadPage","meta","options","React","useEffect","sorting","getState","columnFilters","search","enableGlobalFilter","globalFilter","undefined","hiddenColumns","getHiddenColumns","columnVisibility"],"mappings":";;;SAKgBA,6BAA6BA,CAAkBC,KAAwB,EAAEC,QAAqC;EAC1H,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAA6B;;EAGxDE,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIJ,QAAQ,EAAE;MACV,MAAMK,OAAO,GAAGN,KAAK,CAACO,QAAQ,EAAE,CAACD,OAAO;MACxC,MAAME,aAAa,GAAGR,KAAK,CAACO,QAAQ,EAAE,CAACC,aAAa;MACpD,MAAMC,MAAM,GAAGP,IAAI,CAACO,MAAM,CAACC,kBAAkB,GAAGV,KAAK,CAACO,QAAQ,EAAE,CAACI,YAAY,GAAGC,SAAS;MACzF,MAAMC,aAAa,GAAGC,gBAAgB,CAACd,KAAK,CAACO,QAAQ,EAAE,CAACQ,gBAAgB,CAAC;MAEzEd,QAAQ,CAAC,CAAC,EAAEK,OAAO,EAAEE,aAAa,EAAEC,MAAM,EAAEI,aAAa,CAAC;;GAEjE,EAAE,EAAE,CAAC;AACV;;;;"}
@@ -56,13 +56,13 @@ function useTableManager(props, meta, internalColumns) {
56
56
  const rowClick = useTableRowClick(options.enableRowClick, props.onRowClick);
57
57
  const rowDrag = useTableRowDrag(options.enableRowDrag && !(meta !== null && meta !== void 0 && (_meta$editing = meta.editing) !== null && _meta$editing !== void 0 && _meta$editing.isEditing), props.onRowDrag);
58
58
  const rowDrop = useTableRowDrop(options.enableRowDrop, props.onRowDrop);
59
- const rowExpansion = useTableRowExpansion(options.enableRowExpansion, props.rowExpansionRenderer);
59
+ const rowExpansion = useTableRowExpansion(options.enableRowExpansion, options.enableRowExpansionAll, props.rowExpansionRenderer);
60
60
  const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);
61
61
  const rowGroups = useTableRowGroups(props.rowActionsForGroup);
62
62
  const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);
63
63
  const rowSelection = useTableRowSelection(!!options.enableRowSelection);
64
- const search = useTableSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);
65
- const server = useTableServerLoading(props.loadPage, props.loadAll, props.pageSize);
64
+ const search = useTableSearch(options.enableSearch, props.onChangeSearch, settings.excludeUnmatchedRecordsInSearch);
65
+ const server = useTableServerLoading(props.loadPage, props.loadAll, props.pages, props.pageSize, props._experimentalDataLoader2);
66
66
  // TODO: memoise
67
67
  // convert jsx column components into valid table columns
68
68
  const {
@@ -113,7 +113,7 @@ function useTableManager(props, meta, internalColumns) {
113
113
  useTableFontSizeListener(instance);
114
114
  useTableRowHeightListener(instance);
115
115
  useTableRowSelectionListener(instance, props.onRowSelect);
116
- useTableSearchListener(instance, props.onChangeSearch);
116
+ useTableSearchListener(instance);
117
117
  useTableServerLoadingListener(instance, server.loadPage);
118
118
  useTableSettingsListener(instance, setSettings);
119
119
  useTableShortcutsListener(instance, props.shortcuts);