@economic/taco 2.53.0-virtualiser.4 → 2.53.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/components/Dialog/components/DialogDrawer.d.ts +2 -2
  2. package/dist/components/Input/util.d.ts +7 -1
  3. package/dist/components/Listbox/util.d.ts +1 -1
  4. package/dist/components/Menu/components/Item.d.ts +7 -7
  5. package/dist/components/Popover/Popover.d.ts +1 -1
  6. package/dist/esm/packages/taco/src/charts/components/Donut/DonutChart.js.map +1 -1
  7. package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js.map +1 -1
  8. package/dist/esm/packages/taco/src/charts/components/Legend.js.map +1 -1
  9. package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js.map +1 -1
  10. package/dist/esm/packages/taco/src/components/Dialog/Dialog.js.map +1 -1
  11. package/dist/esm/packages/taco/src/components/Dialog/components/DialogDrawer.js.map +1 -1
  12. package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js +1 -1
  13. package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js.map +1 -1
  14. package/dist/esm/packages/taco/src/components/Input/util.js.map +1 -1
  15. package/dist/esm/packages/taco/src/components/Listbox/util.js.map +1 -1
  16. package/dist/esm/packages/taco/src/components/Menu/components/Item.js.map +1 -1
  17. package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js.map +1 -1
  18. package/dist/esm/packages/taco/src/components/Popover/Popover.js.map +1 -1
  19. package/dist/esm/packages/taco/src/components/ScrollArea/ScrollArea.js +4 -4
  20. package/dist/esm/packages/taco/src/components/ScrollArea/ScrollArea.js.map +1 -1
  21. package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
  22. package/dist/esm/packages/taco/src/components/Select2/components/Create.js.map +1 -1
  23. package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +0 -2
  24. package/dist/esm/packages/taco/src/components/Select2/components/Edit.js.map +1 -1
  25. package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
  26. package/dist/esm/packages/taco/src/components/Select2/components/Search.js.map +1 -1
  27. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
  28. package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowEditing.js.map +1 -1
  29. package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowSelect.js.map +1 -1
  30. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.js.map +1 -1
  31. package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js +4 -1
  32. package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js.map +1 -1
  33. package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
  34. package/dist/esm/packages/taco/src/primitives/Sortable/components/Item.js.map +1 -1
  35. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/util.js +4 -4
  36. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/util.js.map +1 -1
  37. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js +2 -2
  38. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js.map +1 -1
  39. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Resizer.js.map +1 -1
  40. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/SortIndicator.js.map +1 -1
  41. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +11 -5
  42. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
  43. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/Filters.js.map +1 -1
  44. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js.map +1 -1
  45. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js.map +1 -1
  46. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Settings/HideOrOrderPopover.js.map +1 -1
  47. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Settings/Settings.js.map +1 -1
  48. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +7 -2
  49. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  50. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js.map +1 -1
  51. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader2.js.map +1 -1
  52. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSettings.js.map +1 -1
  53. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableShortcutsListener.js.map +1 -1
  54. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  55. package/dist/primitives/Sortable/components/Item.d.ts +2 -1
  56. package/dist/primitives/Table/Core/components/Header/components/SortIndicator.d.ts +3 -3
  57. package/dist/primitives/Table/Core/types.d.ts +1 -1
  58. package/dist/taco.cjs.development.js +33 -21
  59. package/dist/taco.cjs.development.js.map +1 -1
  60. package/dist/taco.cjs.production.min.js +1 -1
  61. package/dist/taco.cjs.production.min.js.map +1 -1
  62. package/package.json +3 -3
@@ -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 hiddenColumns: string[]\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataAllFetcher<TType = unknown> = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[]\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 _lastUsedHiddenColumns = React.useRef<string[]>([]);\n const _lastUsedPageIndex = React.useRef<number>();\n const _forceReset = React.useRef(false);\n\n const loadPage = async (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[]\n ) => {\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 _lastUsedHiddenColumns.current = hiddenColumns;\n\n try {\n const response = await fetchPage(pageIndex, pageSize, sorting, filters, hiddenColumns);\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[], hiddenColumns: string[]) => {\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 _lastUsedHiddenColumns.current = hiddenColumns;\n\n try {\n const response = await fetchAll(sorting, filters, hiddenColumns);\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, _lastUsedHiddenColumns.current);\n } else {\n // load the last page that we scrolled to\n return loadPage(\n _lastUsedPageIndex.current ?? 0,\n _lastUsedSorting.current,\n _lastUsedFilters.current,\n _lastUsedHiddenColumns.current\n );\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, _lastUsedHiddenColumns.current);\n } else {\n // load the last page that we scrolled to\n return loadPage(_lastUsedPageIndex.current ?? 0, sorting, _lastUsedFilters.current, _lastUsedHiddenColumns.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, _lastUsedHiddenColumns.current);\n } else {\n // load the last page that we scrolled to\n return loadPage(_lastUsedPageIndex.current ?? 0, _lastUsedSorting.current, filters, _lastUsedHiddenColumns.current);\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","_lastUsedHiddenColumns","_lastUsedPageIndex","_forceReset","loadPage","pageIndex","sorting","filters","hiddenColumns","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;SA6BjBC,kBAAkBA,CAC9BC,SAAyC,EACzCC,Q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H,OAAO,EAAEN,sBAAsB,CAACS,OAAO,CAAC;;KAE1H,QAAAkB,CAAA;MAAA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;EACD,MAAMU,YAAY,aAAUC,MAA0B;IAAA;;MAElDvC,eAAe,CAACU,OAAO,GAAG6B,MAAM,IAAI9C,SAAS;;;MAE7C,OAAAoB,OAAA,CAAAC,OAAA;KACH,QAAAc,CAAA;MAAA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;EAED,OAAO,CACH;IACIlC,IAAI;IACJJ,MAAM,EAAEA,MAAM,CAACoB,OAAO;IACtBoB,OAAO;IACP1B,QAAQ;IACRoC,cAAc,EAAEJ,YAAY;IAC5BK,cAAc,EAAEH,YAAY;IAC5BI,YAAY,EAAER,UAAU;IACxB7C;GACH,EACD2C,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 hiddenColumns: string[]\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataAllFetcher<TType = unknown> = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[]\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<Record<number, boolean>>({});\n const _lastUsedSorting = React.useRef<TableColumnSort[]>([]);\n const _lastUsedFilters = React.useRef<TableColumnFilter[]>([]);\n const _lastUsedSearch = React.useRef<string>();\n const _lastUsedHiddenColumns = React.useRef<string[]>([]);\n const _lastUsedPageIndex = React.useRef<number>();\n const _forceReset = React.useRef(false);\n\n const loadPage = async (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[]\n ) => {\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 _lastUsedHiddenColumns.current = hiddenColumns;\n\n try {\n const response = await fetchPage(pageIndex, pageSize, sorting, filters, hiddenColumns);\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[], hiddenColumns: string[]) => {\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 _lastUsedHiddenColumns.current = hiddenColumns;\n\n try {\n const response = await fetchAll(sorting, filters, hiddenColumns);\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, _lastUsedHiddenColumns.current);\n } else {\n // load the last page that we scrolled to\n return loadPage(\n _lastUsedPageIndex.current ?? 0,\n _lastUsedSorting.current,\n _lastUsedFilters.current,\n _lastUsedHiddenColumns.current\n );\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, _lastUsedHiddenColumns.current);\n } else {\n // load the last page that we scrolled to\n return loadPage(_lastUsedPageIndex.current ?? 0, sorting, _lastUsedFilters.current, _lastUsedHiddenColumns.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, _lastUsedHiddenColumns.current);\n } else {\n // load the last page that we scrolled to\n return loadPage(_lastUsedPageIndex.current ?? 0, _lastUsedSorting.current, filters, _lastUsedHiddenColumns.current);\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","_lastUsedHiddenColumns","_lastUsedPageIndex","_forceReset","loadPage","pageIndex","sorting","filters","hiddenColumns","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;SA6BjBC,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;;EAEj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AAc,CAAA;MAAA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;EAED,OAAO,CACH;IACIlC,IAAI;IACJJ,MAAM,EAAEA,MAAM,CAACoB,OAAO;IACtBoB,OAAO;IACP1B,QAAQ;IACRoC,cAAc,EAAEJ,YAAY;IAC5BK,cAAc,EAAEH,YAAY;IAC5BI,YAAY,EAAER,UAAU;IACxB7C;GACH,EACD2C,UAAU,CACb;AACL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useTableDataLoader2.js","sources":["../../../../../../../src/primitives/Table/useTableDataLoader2.ts"],"sourcesContent":["import React from 'react';\nimport { v4 as uuid } from 'uuid';\nimport {\n TableColumnFilter,\n TableColumnSort,\n TableFilterHandler,\n TableServerLoadPageHandler,\n TableServerLoadAllHandler,\n TableSortHandler,\n TableSearchHandler,\n} from './types';\nimport { DEFAULT_PAGE_SIZE, useTableDataLoaderOptions } from './useTableDataLoader';\n\nconst DATASET_SIZE_MULTIPLIER = 15;\n\nexport type useTableDataPageFetcher2<TType = unknown> = (\n pageIndex: number,\n pageSize: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataAllFetcher2<TType = unknown> = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataLoaderValues2<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 pages: number[];\n _experimentalDataLoader2: boolean;\n};\n\ntype Data<TType = unknown> = {\n rows: TType[];\n pages: number[];\n cache: Record<number, TType[]>;\n lastFetchedPage: number | undefined;\n};\ntype Direction = 'forward' | 'backward' | undefined;\n\nexport function useTableDataLoader2<TType = unknown>(\n fetchPage: useTableDataPageFetcher2<TType>,\n fetchAll: useTableDataAllFetcher2<TType>,\n options: useTableDataLoaderOptions = { pageSize: DEFAULT_PAGE_SIZE }\n): [useTableDataLoaderValues2<TType>, () => void] {\n const { pageSize } = options;\n const DATASET_SIZE = DATASET_SIZE_MULTIPLIER * pageSize;\n\n // track the data length, we don't know it until the first request\n const length = React.useRef<number>(0);\n // data will be filled after the first request\n const [data, setData] = React.useState<Data<TType>>({ rows: [], pages: [], cache: {}, lastFetchedPage: undefined });\n // track which pages have been loaded to dedupe requests\n const _pendingPageRequests = React.useRef({});\n // it's possible to spam updates, e.g. sort, so we don't set state if the last request wasn't the current oen\n const _lastRequestId = React.useRef<string | undefined>();\n // store last used properties\n const _lastUsedSorting = React.useRef<TableColumnSort[]>([]);\n const _lastUsedFilters = React.useRef<TableColumnFilter[]>([]);\n const _lastUsedSearch = React.useRef<string | undefined>();\n const _lastUsedHiddenColumns = React.useRef<string[]>([]);\n\n async function loadPage(\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined,\n reset = false\n ) {\n // if a request is already pending for this page (and it's not a reset), skip it\n if (_pendingPageRequests.current[pageIndex] && !reset) {\n return;\n }\n\n const hasChangedData =\n JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) ||\n JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current) ||\n search !== _lastUsedSearch.current;\n\n // if the page is already loaded and has actual rows, abort\n if (data.cache[pageIndex] && data.cache[pageIndex][0] && !hasChangedData && !reset) {\n return;\n }\n\n // create an id to track the update\n const requestId = uuid();\n\n // set the page as loading, so that subsequent requests don't retrigger it\n _pendingPageRequests.current[pageIndex] = true;\n\n try {\n _lastRequestId.current = requestId;\n const response = await fetchPage(pageIndex, pageSize, sorting, filters, hiddenColumns, search);\n length.current = response.length;\n\n // update state, here we do some \"magic\" to support \"load in place\"\n setData(currentData => {\n // if this request wasn't the last one, just return the current state to prevent weird updates\n if (_lastRequestId.current !== requestId) {\n return currentData;\n }\n\n const direction = getDirection(pageIndex, currentData.pages);\n const nextPages = getPages(pageIndex, currentData.lastFetchedPage, reset ? [] : currentData.pages, direction);\n\n // set values so we can track if they changed between loads\n _lastUsedSorting.current = sorting;\n _lastUsedFilters.current = filters;\n _lastUsedSearch.current = search;\n _lastUsedHiddenColumns.current = hiddenColumns;\n\n // cache data as an object to prevent any duplicates for pages\n let nextCache: Record<number, TType[]>;\n\n if (reset || hasChangedData || !direction) {\n nextCache = nextPages.reduce((acc, p) => ({ ...acc, [p]: Array(pageSize).fill(undefined) }), {});\n } else {\n nextCache = { ...currentData.cache };\n }\n\n nextCache[pageIndex] = response.data;\n\n // cleanup \"unloaded\" pages\n if (direction === 'forward' && currentData.rows.length >= DATASET_SIZE) {\n delete nextCache[currentData.pages[0]];\n } else if (direction === 'backward' && currentData.rows.length >= DATASET_SIZE) {\n delete nextCache[currentData.pages[currentData.pages.length - 1]];\n }\n\n // remap rows from the cached data - do it here and not in render to save some performance\n const rows = Object.values(nextCache).reduce((acc, p) => acc.concat(p), []);\n\n return {\n cache: nextCache,\n pages: nextPages,\n rows: rows,\n lastFetchedPage: pageIndex,\n };\n });\n\n // reset pending requests\n delete _pendingPageRequests.current[pageIndex];\n } catch {\n //\n }\n }\n\n const loadAll = async (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n ) => {\n // set values so we can track if they changed between loads\n _lastUsedSorting.current = sorting;\n _lastUsedFilters.current = filters;\n _lastUsedSearch.current = search;\n _lastUsedHiddenColumns.current = hiddenColumns;\n\n try {\n const response = await fetchAll(sorting, filters, hiddenColumns, search);\n length.current = response.length;\n\n const pages: number[] = [];\n const cache = {};\n const pageCount = Math.ceil(response.length / pageSize);\n\n Array.from(Array(pageCount).keys()).forEach(index => {\n pages.push(index);\n const startIndex = index * pageSize;\n cache[index] = response.data.slice(startIndex, startIndex + pageSize);\n });\n\n setData({\n cache,\n pages,\n rows: response.data,\n lastFetchedPage: undefined,\n });\n } catch {\n //\n } finally {\n // reset pending requests\n _pendingPageRequests.current = {};\n }\n };\n\n const invalidate = async () => {\n // reset stuff\n _pendingPageRequests.current = {};\n\n // load the current page again\n return loadPage(\n getCurrentPage(data.pages),\n _lastUsedSorting.current,\n _lastUsedFilters.current,\n _lastUsedHiddenColumns.current,\n _lastUsedSearch.current,\n true\n );\n };\n\n const handleSort = async (sorting: TableColumnSort[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n\n return loadPage(\n getCurrentPage(data.pages),\n sorting,\n _lastUsedFilters.current,\n _lastUsedHiddenColumns.current,\n _lastUsedSearch.current,\n true\n );\n };\n const handleFilter = async (filters: TableColumnFilter[], hiddenColumns: string[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n return loadPage(0, _lastUsedSorting.current, filters, hiddenColumns, _lastUsedSearch.current, true);\n };\n const handleSearch = async (search: string | undefined, hiddenColumns: string[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n return loadPage(0, _lastUsedSorting.current, _lastUsedFilters.current, hiddenColumns, search, true);\n };\n\n return [\n {\n data: data.rows,\n pages: data.pages,\n length: length.current,\n loadAll,\n loadPage,\n onChangeFilter: handleFilter,\n onChangeSearch: handleSearch,\n onChangeSort: handleSort,\n pageSize,\n _experimentalDataLoader2: true,\n },\n invalidate,\n ];\n}\n\nfunction getCurrentPage(currentPages: number[]): number {\n if (currentPages.length <= 2) {\n return currentPages[0];\n }\n\n // for even page lengths we can't know which is the current visible page - it could even be both\n // so we load one of them and rely on the \"load next/previous page\" functionality in row\n const middle = Math.floor(currentPages.length / 2);\n return currentPages[middle];\n}\n\nfunction getDirection(pageIndex: number, currentPages: number[]): Direction {\n if (currentPages.length) {\n if (pageIndex === currentPages[currentPages.length - 1] + 1) {\n return 'forward';\n } else if (\n pageIndex === currentPages[0] - 1 ||\n (currentPages.length === 2 && currentPages[0] !== 0 && pageIndex === currentPages[0])\n ) {\n return 'backward';\n }\n }\n\n return undefined;\n}\n\nfunction getPages(pageIndex: number, lastUsedPageIndex: number | undefined, currentPages: number[], direction: Direction) {\n if (currentPages.length && (pageIndex === lastUsedPageIndex || currentPages.includes(pageIndex))) {\n return currentPages;\n }\n\n if (direction === 'forward') {\n const nextPages = currentPages.length === DATASET_SIZE_MULTIPLIER ? currentPages.slice(1) : currentPages;\n return nextPages.concat(pageIndex);\n }\n\n if (direction === 'backward') {\n const nextPages = currentPages.length === DATASET_SIZE_MULTIPLIER ? currentPages.slice(0, -1) : currentPages;\n return [pageIndex].concat(nextPages);\n }\n\n return [pageIndex];\n}\n"],"names":["DATASET_SIZE_MULTIPLIER","useTableDataLoader2","fetchPage","fetchAll","options","pageSize","DEFAULT_PAGE_SIZE","loadPage","pageIndex","sorting","filters","hiddenColumns","search","reset","_pendingPageRequests","current","Promise","resolve","hasChangedData","JSON","stringify","_lastUsedSorting","_lastUsedFilters","_lastUsedSearch","data","cache","requestId","uuid","_temp2","_catch","_lastRequestId","then","response","length","setData","currentData","direction","getDirection","pages","nextPages","getPages","lastFetchedPage","_lastUsedHiddenColumns","nextCache","reduce","acc","p","Array","fill","undefined","rows","DATASET_SIZE","Object","values","concat","e","reject","React","useRef","useState","loadAll","_temp","_finallyRethrows","pageCount","Math","ceil","from","keys","forEach","index","push","startIndex","slice","_wasThrown","_result","invalidate","getCurrentPage","handleSort","handleFilter","handleSearch","onChangeFilter","onChangeSearch","onChangeSort","_experimentalDataLoader2","currentPages","middle","floor","lastUsedPageIndex","includes"],"mappings":";;;;;AAaA,MAAMA,uBAAuB,GAAG,EAAE;SAuClBC,mBAAmBA,CAC/BC,SAA0C,EAC1CC,QAAwC,EACxCC,UAAqC;EAAEC,QAAQ,EAAEC;CAAmB;QAmBrDC,QAAQ,aACnBC,SAAiB,EACjBC,OAA0B,EAC1BC,OAA4B,EAC5BC,aAAuB,EACvBC,MAA0B,EAC1BC,KAAK,GAAG,KAAK;IAAA;;MAGb,I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YAAY,CAACI,QAAQ,CAAChF,SAAS,CAAC,CAAC,EAAE;IAC9F,OAAO4E,YAAY;;EAGvB,IAAIhD,SAAS,KAAK,SAAS,EAAE;IACzB,MAAMG,SAAS,GAAG6C,YAAY,CAACnD,MAAM,KAAKjC,uBAAuB,GAAGoF,YAAY,CAACZ,KAAK,CAAC,CAAC,CAAC,GAAGY,YAAY;IACxG,OAAO7C,SAAS,CAACe,MAAM,CAAC9C,SAAS,CAAC;;EAGtC,IAAI4B,SAAS,KAAK,UAAU,EAAE;IAC1B,MAAMG,SAAS,GAAG6C,YAAY,CAACnD,MAAM,KAAKjC,uBAAuB,GAAGoF,YAAY,CAACZ,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAGY,YAAY;IAC5G,OAAO,CAAC5E,SAAS,CAAC,CAAC8C,MAAM,CAACf,SAAS,CAAC;;EAGxC,OAAO,CAAC/B,SAAS,CAAC;AACtB;;;;"}
1
+ {"version":3,"file":"useTableDataLoader2.js","sources":["../../../../../../../src/primitives/Table/useTableDataLoader2.ts"],"sourcesContent":["import React from 'react';\nimport { v4 as uuid } from 'uuid';\nimport {\n TableColumnFilter,\n TableColumnSort,\n TableFilterHandler,\n TableServerLoadPageHandler,\n TableServerLoadAllHandler,\n TableSortHandler,\n TableSearchHandler,\n} from './types';\nimport { DEFAULT_PAGE_SIZE, useTableDataLoaderOptions } from './useTableDataLoader';\n\nconst DATASET_SIZE_MULTIPLIER = 15;\n\nexport type useTableDataPageFetcher2<TType = unknown> = (\n pageIndex: number,\n pageSize: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataAllFetcher2<TType = unknown> = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataLoaderValues2<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 pages: number[];\n _experimentalDataLoader2: boolean;\n};\n\ntype Data<TType = unknown> = {\n rows: TType[];\n pages: number[];\n cache: Record<number, TType[]>;\n lastFetchedPage: number | undefined;\n};\ntype Direction = 'forward' | 'backward' | undefined;\n\nexport function useTableDataLoader2<TType = unknown>(\n fetchPage: useTableDataPageFetcher2<TType>,\n fetchAll: useTableDataAllFetcher2<TType>,\n options: useTableDataLoaderOptions = { pageSize: DEFAULT_PAGE_SIZE }\n): [useTableDataLoaderValues2<TType>, () => void] {\n const { pageSize } = options;\n const DATASET_SIZE = DATASET_SIZE_MULTIPLIER * pageSize;\n\n // track the data length, we don't know it until the first request\n const length = React.useRef<number>(0);\n // data will be filled after the first request\n const [data, setData] = React.useState<Data<TType>>({ rows: [], pages: [], cache: {}, lastFetchedPage: undefined });\n // track which pages have been loaded to dedupe requests\n const _pendingPageRequests = React.useRef<Record<number, boolean>>({});\n // it's possible to spam updates, e.g. sort, so we don't set state if the last request wasn't the current oen\n const _lastRequestId = React.useRef<string | undefined>();\n // store last used properties\n const _lastUsedSorting = React.useRef<TableColumnSort[]>([]);\n const _lastUsedFilters = React.useRef<TableColumnFilter[]>([]);\n const _lastUsedSearch = React.useRef<string | undefined>();\n const _lastUsedHiddenColumns = React.useRef<string[]>([]);\n\n async function loadPage(\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined,\n reset = false\n ) {\n // if a request is already pending for this page (and it's not a reset), skip it\n if (_pendingPageRequests.current[pageIndex] && !reset) {\n return;\n }\n\n const hasChangedData =\n JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) ||\n JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current) ||\n search !== _lastUsedSearch.current;\n\n // if the page is already loaded and has actual rows, abort\n if (data.cache[pageIndex] && data.cache[pageIndex][0] && !hasChangedData && !reset) {\n return;\n }\n\n // create an id to track the update\n const requestId = uuid();\n\n // set the page as loading, so that subsequent requests don't retrigger it\n _pendingPageRequests.current[pageIndex] = true;\n\n try {\n _lastRequestId.current = requestId;\n const response = await fetchPage(pageIndex, pageSize, sorting, filters, hiddenColumns, search);\n length.current = response.length;\n\n // update state, here we do some \"magic\" to support \"load in place\"\n setData(currentData => {\n // if this request wasn't the last one, just return the current state to prevent weird updates\n if (_lastRequestId.current !== requestId) {\n return currentData;\n }\n\n const direction = getDirection(pageIndex, currentData.pages);\n const nextPages = getPages(pageIndex, currentData.lastFetchedPage, reset ? [] : currentData.pages, direction);\n\n // set values so we can track if they changed between loads\n _lastUsedSorting.current = sorting;\n _lastUsedFilters.current = filters;\n _lastUsedSearch.current = search;\n _lastUsedHiddenColumns.current = hiddenColumns;\n\n // cache data as an object to prevent any duplicates for pages\n let nextCache: Record<number, TType[]>;\n\n if (reset || hasChangedData || !direction) {\n nextCache = nextPages.reduce((acc, p) => ({ ...acc, [p]: Array(pageSize).fill(undefined) }), {});\n } else {\n nextCache = { ...currentData.cache };\n }\n\n nextCache[pageIndex] = response.data;\n\n // cleanup \"unloaded\" pages\n if (direction === 'forward' && currentData.rows.length >= DATASET_SIZE) {\n delete nextCache[currentData.pages[0]];\n } else if (direction === 'backward' && currentData.rows.length >= DATASET_SIZE) {\n delete nextCache[currentData.pages[currentData.pages.length - 1]];\n }\n\n // remap rows from the cached data - do it here and not in render to save some performance\n const rows = Object.values(nextCache).reduce((acc, p) => acc.concat(p), []);\n\n return {\n cache: nextCache,\n pages: nextPages,\n rows: rows,\n lastFetchedPage: pageIndex,\n };\n });\n\n // reset pending requests\n delete _pendingPageRequests.current[pageIndex];\n } catch {\n //\n }\n }\n\n const loadAll = async (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n ) => {\n // set values so we can track if they changed between loads\n _lastUsedSorting.current = sorting;\n _lastUsedFilters.current = filters;\n _lastUsedSearch.current = search;\n _lastUsedHiddenColumns.current = hiddenColumns;\n\n try {\n const response = await fetchAll(sorting, filters, hiddenColumns, search);\n length.current = response.length;\n\n const pages: number[] = [];\n const cache = {};\n const pageCount = Math.ceil(response.length / pageSize);\n\n Array.from(Array(pageCount).keys()).forEach(index => {\n pages.push(index);\n const startIndex = index * pageSize;\n cache[index] = response.data.slice(startIndex, startIndex + pageSize);\n });\n\n setData({\n cache,\n pages,\n rows: response.data,\n lastFetchedPage: undefined,\n });\n } catch {\n //\n } finally {\n // reset pending requests\n _pendingPageRequests.current = {};\n }\n };\n\n const invalidate = async () => {\n // reset stuff\n _pendingPageRequests.current = {};\n\n // load the current page again\n return loadPage(\n getCurrentPage(data.pages),\n _lastUsedSorting.current,\n _lastUsedFilters.current,\n _lastUsedHiddenColumns.current,\n _lastUsedSearch.current,\n true\n );\n };\n\n const handleSort = async (sorting: TableColumnSort[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n\n return loadPage(\n getCurrentPage(data.pages),\n sorting,\n _lastUsedFilters.current,\n _lastUsedHiddenColumns.current,\n _lastUsedSearch.current,\n true\n );\n };\n const handleFilter = async (filters: TableColumnFilter[], hiddenColumns: string[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n return loadPage(0, _lastUsedSorting.current, filters, hiddenColumns, _lastUsedSearch.current, true);\n };\n const handleSearch = async (search: string | undefined, hiddenColumns: string[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n return loadPage(0, _lastUsedSorting.current, _lastUsedFilters.current, hiddenColumns, search, true);\n };\n\n return [\n {\n data: data.rows,\n pages: data.pages,\n length: length.current,\n loadAll,\n loadPage,\n onChangeFilter: handleFilter,\n onChangeSearch: handleSearch,\n onChangeSort: handleSort,\n pageSize,\n _experimentalDataLoader2: true,\n },\n invalidate,\n ];\n}\n\nfunction getCurrentPage(currentPages: number[]): number {\n if (currentPages.length <= 2) {\n return currentPages[0];\n }\n\n // for even page lengths we can't know which is the current visible page - it could even be both\n // so we load one of them and rely on the \"load next/previous page\" functionality in row\n const middle = Math.floor(currentPages.length / 2);\n return currentPages[middle];\n}\n\nfunction getDirection(pageIndex: number, currentPages: number[]): Direction {\n if (currentPages.length) {\n if (pageIndex === currentPages[currentPages.length - 1] + 1) {\n return 'forward';\n } else if (\n pageIndex === currentPages[0] - 1 ||\n (currentPages.length === 2 && currentPages[0] !== 0 && pageIndex === currentPages[0])\n ) {\n return 'backward';\n }\n }\n\n return undefined;\n}\n\nfunction getPages(pageIndex: number, lastUsedPageIndex: number | undefined, currentPages: number[], direction: Direction) {\n if (currentPages.length && (pageIndex === lastUsedPageIndex || currentPages.includes(pageIndex))) {\n return currentPages;\n }\n\n if (direction === 'forward') {\n const nextPages = currentPages.length === DATASET_SIZE_MULTIPLIER ? currentPages.slice(1) : currentPages;\n return nextPages.concat(pageIndex);\n }\n\n if (direction === 'backward') {\n const nextPages = currentPages.length === DATASET_SIZE_MULTIPLIER ? currentPages.slice(0, -1) : currentPages;\n return [pageIndex].concat(nextPages);\n }\n\n return [pageIndex];\n}\n"],"names":["DATASET_SIZE_MULTIPLIER","useTableDataLoader2","fetchPage","fetchAll","options","pageSize","DEFAULT_PAGE_SIZE","loadPage","pageIndex","sorting","filters","hiddenColumns","search","reset","_pendingPageRequests","current","Promise","resolve","hasChangedData","JSON","stringify","_lastUsedSorting","_lastUsedFilters","_lastUsedSearch","data","cache","requestId","uuid","_temp2","_catch","_lastRequestId","then","response","length","setData","currentData","direction","getDirection","pages","nextPages","getPages","lastFetchedPage","_lastUsedHiddenColumns","nextCache","reduce","acc","p","Array","fill","undefined","rows","DATASET_SIZE","Object","values","concat","e","reject","React","useRef","useState","loadAll","_temp","_finallyRethrows","pageCount","Math","ceil","from","keys","forEach","index","push","startIndex","slice","_wasThrown","_result","invalidate","getCurrentPage","handleSort","handleFilter","handleSearch","onChangeFilter","onChangeSearch","onChangeSort","_experimentalDataLoader2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K,CAAC,IAAImD,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI5E,SAAS,KAAK4E,YAAY,CAAC,CAAC,CAAE,EACvF;MACE,OAAO,UAAU;;;EAIzB,OAAOnC,SAAS;AACpB;AAEA,SAAST,QAAQA,CAAChC,SAAiB,EAAE+E,iBAAqC,EAAEH,YAAsB,EAAEhD,SAAoB;EACpH,IAAIgD,YAAY,CAACnD,MAAM,KAAKzB,SAAS,KAAK+E,iBAAiB,IAAIH,YAAY,CAACI,QAAQ,CAAChF,SAAS,CAAC,CAAC,EAAE;IAC9F,OAAO4E,YAAY;;EAGvB,IAAIhD,SAAS,KAAK,SAAS,EAAE;IACzB,MAAMG,SAAS,GAAG6C,YAAY,CAACnD,MAAM,KAAKjC,uBAAuB,GAAGoF,YAAY,CAACZ,KAAK,CAAC,CAAC,CAAC,GAAGY,YAAY;IACxG,OAAO7C,SAAS,CAACe,MAAM,CAAC9C,SAAS,CAAC;;EAGtC,IAAI4B,SAAS,KAAK,UAAU,EAAE;IAC1B,MAAMG,SAAS,GAAG6C,YAAY,CAACnD,MAAM,KAAKjC,uBAAuB,GAAGoF,YAAY,CAACZ,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAGY,YAAY;IAC5G,OAAO,CAAC5E,SAAS,CAAC,CAAC8C,MAAM,CAACf,SAAS,CAAC;;EAGxC,OAAO,CAAC/B,SAAS,CAAC;AACtB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useTableSettings.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableSettings.ts"],"sourcesContent":["import React from 'react';\nimport { useLocalStorage } from '../../../../hooks/useLocalStorage';\nimport { useTacoSettings } from '../../../../hooks/useTacoSettings';\nimport { TableEnableSettingsOptions, TableSettings, TableSettingsHandler } from '../../types';\n\nconst DEFAULT_ENABLED_OPTIONS = {\n columnOrder: true,\n columnPinning: true,\n columnSizing: true,\n columnVisibility: true,\n excludeUnmatchedRecordsInSearch: true,\n fontSize: true,\n grouping: true,\n rowHeight: true,\n sorting: true,\n};\n\nexport function useUniqueTableId(tableId: string) {\n const tacoSettings = useTacoSettings();\n return `taco.${tacoSettings.uniqueUserIdentifier}.table.${tableId}.settings`;\n}\n\nfunction useEnabledSettings(isEnabled: boolean | Partial<TableEnableSettingsOptions>): [TableEnableSettingsOptions, boolean] {\n return React.useMemo(() => {\n if (isEnabled === false) {\n return [\n Object.keys(DEFAULT_ENABLED_OPTIONS).reduce(\n (o, key) => ({ ...o, [key]: false }),\n {}\n ) as TableEnableSettingsOptions,\n false,\n ];\n } else if (isEnabled === true) {\n return [DEFAULT_ENABLED_OPTIONS, true];\n }\n\n const options = { ...DEFAULT_ENABLED_OPTIONS, ...isEnabled };\n return [options, Object.values(options).some(o => o === true)];\n }, [isEnabled]);\n}\n\nexport function useTableSettings(\n isEnabled: boolean | Partial<TableEnableSettingsOptions> = false,\n id: string,\n defaultSettings: TableSettings | undefined = {},\n onChangeSettings: TableSettingsHandler | undefined\n): [TableSettings, TableSettingsHandler] {\n const uniqueId = useUniqueTableId(id);\n const [enabledSettings, hasSomeEnabledSettings] = useEnabledSettings(isEnabled);\n\n const [persistedSettings, _setPersistedSettings] = useLocalStorage<TableSettings>(\n hasSomeEnabledSettings ? uniqueId : undefined,\n removeDisabledSettings(defaultSettings, enabledSettings)\n );\n\n const setPersistedSettings = React.useCallback(\n (value: TableSettings) => {\n if (!hasSomeEnabledSettings) {\n return;\n }\n\n const sanitizedSettings = removeDisabledSettings(value, enabledSettings);\n _setPersistedSettings(sanitizedSettings);\n\n if (typeof onChangeSettings === 'function') {\n onChangeSettings(sanitizedSettings);\n }\n },\n [hasSomeEnabledSettings, onChangeSettings, JSON.stringify(enabledSettings)]\n );\n\n if (!hasSomeEnabledSettings) {\n return [defaultSettings, () => undefined];\n }\n\n return [persistedSettings, setPersistedSettings];\n}\n\nfunction removeDisabledSettings(settings: TableSettings, enabledSettings: TableEnableSettingsOptions) {\n const sanitizedSettings: TableSettings = { ...settings };\n\n Object.keys(enabledSettings).forEach(setting => {\n if (!enabledSettings[setting]) {\n delete sanitizedSettings[setting];\n }\n });\n\n return sanitizedSettings;\n}\n"],"names":["DEFAULT_ENABLED_OPTIONS","columnOrder","columnPinning","columnSizing","columnVisibility","excludeUnmatchedRecordsInSearch","fontSize","grouping","rowHeight","sorting","useUniqueTableId","tableId","tacoSettings","useTacoSettings","uniqueUserIdentifier","useEnabledSettings","isEnabled","React","useMemo","Object","keys","reduce","o","key","options","values","some","useTableSettings","id","defaultSettings","onChangeSettings","uniqueId","enabledSettings","hasSomeEnabledSettings","persistedSettings","_setPersistedSettings","useLocalStorage","undefined","removeDisabledSettings","setPersistedSettings","useCallback","value","sanitizedSettings","JSON","stringify","settings","forEach","setting"],"mappings":";;;;AAKA,MAAMA,uBAAuB,GAAG;EAC5BC,WAAW,EAAE,IAAI;EACjBC,aAAa,EAAE,IAAI;EACnBC,YAAY,EAAE,IAAI;EAClBC,gBAAgB,EAAE,IAAI;EACtBC,+BAA+B,EAAE,IAAI;EACrCC,QAAQ,EAAE,IAAI;EACdC,QAAQ,EAAE,IAAI;EACdC,SAAS,EAAE,IAAI;EACfC,OAAO,EAAE;CACZ;SAEeC,gBAAgBA,CAACC,OAAe;EAC5C,MAAMC,YAAY,GAAGC,eAAe,EAAE;EACtC,OAAO,QAAQD,YAAY,CAACE,oBAAoB,UAAUH,OAAO,WAAW;AAChF;AAEA,SAASI,kBAAkBA,CAACC,SAAwD;EAChF,OAAOC,cAAK,CAACC,OAAO,CAAC;IACjB,IAAIF,SAAS,KAAK,KAAK,EAAE;MACrB,OAAO,CACHG,MAAM,CAACC,IAAI,CAACpB,uBAAuB,CAAC,CAACqB,MAAM,CACvC,CAACC,CAAC,EAAEC,GAAG,MAAM;QAAE,GAAGD,CAAC;QAAE,CAACC,GAAG,GAAG;OAAO,CAAC,EACpC,EAAE,CACyB,EAC/B,KAAK,CACR;KACJ,MAAM,IAAIP,SAAS,KAAK,IAAI,EAAE;MAC3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,CAACO,QAAuB,EAAEb,eAA2C;EAChG,MAAMU,iBAAiB,GAAkB;IAAE,GAAGG;GAAU;EAExD1B,MAAM,CAACC,IAAI,CAACY,eAAe,CAAC,CAACc,OAAO,CAACC,OAAO;IACxC,IAAI,CAACf,eAAe,CAACe,OAAO,CAAC,EAAE;MAC3B,OAAOL,iBAAiB,CAACK,OAAO,CAAC;;GAExC,CAAC;EAEF,OAAOL,iBAAiB;AAC5B;;;;"}
1
+ {"version":3,"file":"useTableSettings.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableSettings.ts"],"sourcesContent":["import React from 'react';\nimport { useLocalStorage } from '../../../../hooks/useLocalStorage';\nimport { useTacoSettings } from '../../../../hooks/useTacoSettings';\nimport { TableEnableSettingsOptions, TableSettings, TableSettingsHandler } from '../../types';\n\nconst DEFAULT_ENABLED_OPTIONS = {\n columnOrder: true,\n columnPinning: true,\n columnSizing: true,\n columnVisibility: true,\n excludeUnmatchedRecordsInSearch: true,\n fontSize: true,\n grouping: true,\n rowHeight: true,\n sorting: true,\n};\n\nexport function useUniqueTableId(tableId: string) {\n const tacoSettings = useTacoSettings();\n return `taco.${tacoSettings.uniqueUserIdentifier}.table.${tableId}.settings`;\n}\n\nfunction useEnabledSettings(isEnabled: boolean | Partial<TableEnableSettingsOptions>): [TableEnableSettingsOptions, boolean] {\n return React.useMemo(() => {\n if (isEnabled === false) {\n return [\n Object.keys(DEFAULT_ENABLED_OPTIONS).reduce(\n (o, key) => ({ ...o, [key]: false }),\n {}\n ) as TableEnableSettingsOptions,\n false,\n ];\n } else if (isEnabled === true) {\n return [DEFAULT_ENABLED_OPTIONS, true];\n }\n\n const options = { ...DEFAULT_ENABLED_OPTIONS, ...isEnabled };\n return [options, Object.values(options).some(o => o === true)];\n }, [isEnabled]);\n}\n\nexport function useTableSettings(\n isEnabled: boolean | Partial<TableEnableSettingsOptions> = false,\n id: string,\n defaultSettings: TableSettings | undefined = {},\n onChangeSettings: TableSettingsHandler | undefined\n): [TableSettings, TableSettingsHandler] {\n const uniqueId = useUniqueTableId(id);\n const [enabledSettings, hasSomeEnabledSettings] = useEnabledSettings(isEnabled);\n\n const [persistedSettings, _setPersistedSettings] = useLocalStorage<TableSettings>(\n hasSomeEnabledSettings ? uniqueId : undefined,\n removeDisabledSettings(defaultSettings, enabledSettings)\n );\n\n const setPersistedSettings = React.useCallback(\n (value: TableSettings) => {\n if (!hasSomeEnabledSettings) {\n return;\n }\n\n const sanitizedSettings = removeDisabledSettings(value, enabledSettings);\n _setPersistedSettings(sanitizedSettings);\n\n if (typeof onChangeSettings === 'function') {\n onChangeSettings(sanitizedSettings);\n }\n },\n [hasSomeEnabledSettings, onChangeSettings, JSON.stringify(enabledSettings)]\n );\n\n if (!hasSomeEnabledSettings) {\n return [defaultSettings, () => undefined];\n }\n\n return [persistedSettings, setPersistedSettings];\n}\n\nfunction removeDisabledSettings(settings: TableSettings, enabledSettings: TableEnableSettingsOptions) {\n const sanitizedSettings: TableSettings = { ...settings };\n\n Object.keys(enabledSettings).forEach(setting => {\n if (!enabledSettings[setting as keyof TableEnableSettingsOptions]) {\n delete sanitizedSettings[setting as keyof TableSettings];\n }\n });\n\n return sanitizedSettings;\n}\n"],"names":["DEFAULT_ENABLED_OPTIONS","columnOrder","columnPinning","columnSizing","columnVisibility","excludeUnmatchedRecordsInSearch","fontSize","grouping","rowHeight","sorting","useUniqueTableId","tableId","tacoSettings","useTacoSettings","uniqueUserIdentifier","useEnabledSettings","isEnabled","React","useMemo","Object","keys","reduce","o","key","options","values","some","useTableSettings","id","defaultSettings","onChangeSettings","uniqueId","enabledSettings","hasSomeEnabledSettings","persistedSettings","_setPersistedSettings","useLocalStorage","undefined","removeDisabledSettings","setPersistedSettings","useCallback","value","sanitizedSettings","JSON","stringify","settings","forEach","setting"],"mappings":";;;;AAKA,MAAMA,uBAAuB,GAAG;EAC5BC,WAAW,EAAE,IAAI;EACjBC,aAAa,EAAE,IAAI;EACnBC,YAAY,EAAE,IAAI;EACl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BAAsB,GAAGF,QAAQ,GAAGM,SAAS,EAC7CC,sBAAsB,CAACT,eAAe,EAAEG,eAAe,CAAC,CAC3D;EAED,MAAMO,oBAAoB,GAAGtB,cAAK,CAACuB,WAAW,CACzCC,KAAoB;IACjB,IAAI,CAACR,sBAAsB,EAAE;MACzB;;IAGJ,MAAMS,iBAAiB,GAAGJ,sBAAsB,CAACG,KAAK,EAAET,eAAe,CAAC;IACxEG,qBAAqB,CAACO,iBAAiB,CAAC;IAExC,IAAI,OAAOZ,gBAAgB,KAAK,UAAU,EAAE;MACxCA,gBAAgB,CAACY,iBAAiB,CAAC;;GAE1C,EACD,CAACT,sBAAsB,EAAEH,gBAAgB,EAAEa,IAAI,CAACC,SAAS,CAACZ,eAAe,CAAC,CAAC,CAC9E;EAED,IAAI,CAACC,sBAAsB,EAAE;IACzB,OAAO,CAACJ,eAAe,EAAE,MAAMQ,SAAS,CAAC;;EAG7C,OAAO,CAACH,iBAAiB,EAAEK,oBAAoB,CAAC;AACpD;AAEA,SAASD,sBAAsBA,CAACO,QAAuB,EAAEb,eAA2C;EAChG,MAAMU,iBAAiB,GAAkB;IAAE,GAAGG;GAAU;EAExD1B,MAAM,CAACC,IAAI,CAACY,eAAe,CAAC,CAACc,OAAO,CAACC,OAAO;IACxC,IAAI,CAACf,eAAe,CAACe,OAA2C,CAAC,EAAE;MAC/D,OAAOL,iBAAiB,CAACK,OAA8B,CAAC;;GAE/D,CAAC;EAEF,OAAOL,iBAAiB;AAC5B;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useTableShortcutsListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableShortcutsListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { KeyDownHandlerOptions, createShortcutKeyDownHandler } from '../../../../utils/keyboard';\nimport { TableShortcutHandlerObject, TableShortcuts } from '../../types';\n\nexport function useTableShortcutsListener<TType = unknown>(\n table: ReactTable<TType>,\n shortcuts: TableShortcuts<TType> | undefined\n) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(() => {\n const shortcutKeys = Object.keys(shortcuts ?? {});\n const globalHandlers: Array<(event: KeyboardEvent) => void> = [];\n\n // convert the shortcut into the correct format to register it\n if (shortcuts && shortcutKeys.length && meta.rowActive.rowActiveIndex !== undefined) {\n const rowActive = rows[meta.rowActive.rowActiveIndex];\n\n shortcutKeys.forEach(key => {\n const handler = shortcuts[key];\n\n let keyDownHandler;\n let keyDownHandlerOptions: KeyDownHandlerOptions;\n\n if (typeof handler === 'function') {\n keyDownHandler = handler;\n keyDownHandlerOptions = {\n key,\n };\n } else {\n const handlerObject = handler as TableShortcutHandlerObject<TType>;\n keyDownHandler = handlerObject.handler;\n keyDownHandlerOptions = {\n key,\n meta: handlerObject.meta,\n shift: handlerObject.shift,\n };\n }\n\n globalHandlers.push(\n createShortcutKeyDownHandler(keyDownHandlerOptions, event => {\n event.preventDefault();\n keyDownHandler(rowActive?.original);\n })\n );\n });\n }\n\n globalHandlers.forEach(handler => {\n document.addEventListener('keydown', handler);\n });\n\n return () => {\n globalHandlers.forEach(handler => {\n document.removeEventListener('keydown', handler);\n });\n };\n }, [shortcuts, meta.rowActive.rowActiveIndex, rows.length]);\n}\n"],"names":["useTableShortcutsListener","table","shortcuts","meta","options","rows","getRowModel","React","useEffect","shortcutKeys","Object","keys","globalHandlers","length","rowActive","rowActiveIndex","undefined","forEach","key","handler","keyDownHandler","keyDownHandlerOptions","handlerObject","shift","push","createShortcutKeyDownHandler","event","preventDefault","original","document","addEventListener","removeEventListener"],"mappings":";;;SAKgBA,yBAAyBA,CACrCC,KAAwB,EACxBC,SAA4C;EAE5C,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAA6B;EACxD,MAAME,IAAI,GAAGJ,KAAK,CAACK,WAAW,EAAE,CAACD,IAAI;EAErCE,cAAK,CAACC,SAAS,CAA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,SAAS,CAACC,cAAc,EAAEV,IAAI,CAACQ,MAAM,CAAC,CAAC;AAC/D;;;;"}
1
+ {"version":3,"file":"useTableShortcutsListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableShortcutsListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { KeyDownHandlerOptions, createShortcutKeyDownHandler } from '../../../../utils/keyboard';\nimport { TableShortcutHandlerFn, TableShortcutHandlerObject, TableShortcuts } from '../../types';\n\nexport function useTableShortcutsListener<TType = unknown>(\n table: ReactTable<TType>,\n shortcuts: TableShortcuts<TType> | undefined\n) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(() => {\n const shortcutKeys = Object.keys(shortcuts ?? {});\n const globalHandlers: Array<(event: KeyboardEvent) => void> = [];\n\n // convert the shortcut into the correct format to register it\n if (shortcuts && shortcutKeys.length && meta.rowActive.rowActiveIndex !== undefined) {\n const rowActive = rows[meta.rowActive.rowActiveIndex];\n\n shortcutKeys.forEach(key => {\n const handler = shortcuts[key];\n\n let keyDownHandler: TableShortcutHandlerFn<TType>;\n let keyDownHandlerOptions: KeyDownHandlerOptions;\n\n if (typeof handler === 'function') {\n keyDownHandler = handler;\n keyDownHandlerOptions = {\n key,\n };\n } else {\n const handlerObject = handler as TableShortcutHandlerObject<TType>;\n keyDownHandler = handlerObject.handler;\n keyDownHandlerOptions = {\n key,\n meta: handlerObject.meta,\n shift: handlerObject.shift,\n };\n }\n\n globalHandlers.push(\n createShortcutKeyDownHandler(keyDownHandlerOptions, event => {\n event.preventDefault();\n keyDownHandler(rowActive?.original);\n })\n );\n });\n }\n\n globalHandlers.forEach(handler => {\n document.addEventListener('keydown', handler);\n });\n\n return () => {\n globalHandlers.forEach(handler => {\n document.removeEventListener('keydown', handler);\n });\n };\n }, [shortcuts, meta.rowActive.rowActiveIndex, rows.length]);\n}\n"],"names":["useTableShortcutsListener","table","shortcuts","meta","options","rows","getRowModel","React","useEffect","shortcutKeys","Object","keys","globalHandlers","length","rowActive","rowActiveIndex","undefined","forEach","key","handler","keyDownHandler","keyDownHandlerOptions","handlerObject","shift","push","createShortcutKeyDownHandler","event","preventDefault","original","document","addEventListener","removeEventListener"],"mappings":";;;SAKgBA,yBAAyBA,CACrCC,KAAwB,EACxBC,SAA4C;EAE5C,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAA6B;EACxD,MAAME,IAAI,GAAGJ,KAAK,CAACK,WAAW,EAAE,CAACD,IAAI;EAErCE,cAAK,CAACC,SAAS,CAAC;IACZ,MAAMC,YAAY,GAAGC,MAAM,CAACC,IAAI,CAACT,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE,CAAC;IACjD,MAAMU,cAAc,GAA0C,EAAE;;IAGhE,IAAIV,SAAS,IAAIO,YAAY,CAACI,MAAM,IAAIV,IAAI,CAACW,SAAS,CAACC,cAAc,KAAKC,SAAS,EAAE;MACjF,MAAMF,SAAS,GAAGT,IAAI,CAACF,IAAI,CAACW,SAAS,CAACC,cAAc,CAAC;MAErDN,YAAY,CAACQ,OAAO,CAACC,GAAG;QACpB,MAAMC,OAAO,GAAGjB,SAAS,CAACgB,GAAG,CAAC;QAE9B,IAAIE,cAA6C;QACjD,IAAIC,qBAA4C;QAEhD,IAAI,OAAOF,OAAO,KAAK,UAAU,EAAE;UAC/BC,cAAc,GAAGD,OAAO;UACxBE,qBAAqB,GAAG;YACpBH;WACH;SACJ,MAAM;UACH,MAAMI,aAAa,GAAGH,OAA4C;UAClEC,cAAc,GAAGE,aAAa,CAACH,OAAO;UACtCE,qBAAqB,GAAG;YACpBH,GAAG;YACHf,IAAI,EAAEmB,aAAa,CAACnB,IAAI;YACxBoB,KAAK,EAAED,aAAa,CAACC;WACxB;;QAGLX,cAAc,CAACY,IAAI,CACfC,4BAA4B,CAACJ,qBAAqB,EAAEK,KAAK;UACrDA,KAAK,CAACC,cAAc,EAAE;UACtBP,cAAc,CAACN,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEc,QAAQ,CAAC;SACtC,CAAC,CACL;OACJ,CAAC;;IAGNhB,cAAc,CAACK,OAAO,CAACE,OAAO;MAC1BU,QAAQ,CAACC,gBAAgB,CAAC,SAAS,EAAEX,OAAO,CAAC;KAChD,CAAC;IAEF,OAAO;MACHP,cAAc,CAACK,OAAO,CAACE,OAAO;QAC1BU,QAAQ,CAACE,mBAAmB,CAAC,SAAS,EAAEZ,OAAO,CAAC;OACnD,CAAC;KACL;GACJ,EAAE,CAACjB,SAAS,EAAEC,IAAI,CAACW,SAAS,CAACC,cAAc,EAAEV,IAAI,CAACQ,MAAM,CAAC,CAAC;AAC/D;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"setup.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/setup.ts"],"sourcesContent":["import React from 'react';\nimport {\n createColumnHelper,\n getExpandedRowModel,\n getFilteredRowModel,\n getGroupedRowModel,\n getSortedRowModel,\n TableOptions as ReactTableOptions,\n Row as ReactTableRow,\n Column as ReactTableColumn,\n ColumnDef as ReactTableColumnDef,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSizingState as ReactTableColumnSizingState,\n ColumnSort as ReactTableColumnSort,\n TableState as ReactTableState,\n VisibilityState as ReactTableVisibilityState,\n} from '@tanstack/react-table';\nimport get from 'lodash/get';\nimport { useTableManagerInternalColumns, useTableManagerInternalColumn } from '../types';\nimport { TableColumnProps, TableFeatureProps, TableGroupProps, TableProps, TableSettings } from '../../types';\nimport { getSortingFn } from './sorting';\nimport { ensureOrdering, freezeUptoExternalColumn, getCellMinWidth, unfreezeAllExternalColumns } from './columns';\nimport { columnFilterFn } from './filtering';\nimport { globalFilterFn } from './search';\nimport { ignoreInternalColumns } from './settings';\nimport { getDataTypeProperties } from './dataTypes';\nimport { Localization } from '../../../../components/Provider/Localization';\n\n// mapping children to react-table columns\nfunction processChildren<TType>(\n child: React.ReactChild | React.ReactFragment | React.ReactPortal,\n columns: ReactTableColumnDef<TType>[],\n defaultSizing: ReactTableColumnSizingState,\n defaultSorting: ReactTableColumnSort[],\n defaultVisibility: ReactTableVisibilityState,\n settings: TableSettings,\n defaultRowGroupColumnId: keyof TType | undefined,\n localization: Localization\n): ReactTableColumnDef<TType>[] {\n const columnHelper = createColumnHelper<TType>();\n\n if (React.isValidElement<TableGroupProps>(child) && child.props.children) {\n const { children, id, header } = child.props;\n\n columns.push(\n columnHelper.group({\n id,\n header,\n columns: React.Children.toArray(children).reduce(\n (columns: ReactTableColumnDef<TType>[], child) =>\n processChildren<TType>(\n child,\n columns,\n defaultSizing,\n defaultSorting,\n defaultVisibility,\n settings,\n defaultRowGroupColumnId,\n localization\n ),\n []\n ),\n // we don't want to let column groups be grouped/aggregrated\n enableGrouping: false,\n })\n );\n } else if (React.isValidElement<TableColumnProps<TType>>(child) && (child.props.accessor || child.props.id)) {\n const {\n id: untypedId,\n accessor: accessorKey = untypedId,\n // renderers\n renderer,\n aggregate,\n footer,\n header,\n // options\n aggregationFn,\n defaultHidden,\n defaultWidth,\n enableEditing = !!child.props.control,\n enableFiltering: enableColumnFilter = true,\n enableGrouping = false,\n enableHiding = true,\n enableOrdering = true,\n enablePrinting = true,\n enableResizing = true,\n enableSearch: enableGlobalFilter = true,\n enableSorting = true,\n enableTruncate = false,\n minWidth: minSize = getCellMinWidth(settings.fontSize),\n sort,\n sortFn,\n ...meta\n } = child.props;\n const id = untypedId as string;\n const dataTypeProperties = getDataTypeProperties<TType>(child.props.dataType);\n\n if (defaultHidden && enableHiding) {\n defaultVisibility[id] = false;\n }\n\n if (defaultWidth) {\n defaultSizing[id] = defaultWidth as any;\n }\n\n const isGrouped = defaultRowGroupColumnId === id;\n\n if (child.props.sort !== undefined || isGrouped) {\n defaultSorting.push({\n id,\n desc: sort === 'desc',\n });\n }\n\n const column: ReactTableColumnDef<TType, any> = {\n id,\n accessorKey,\n // To avoid errors caused by undefined row data values, we pass accessorFn as a preventive measure\n // accessorKey can be dot notated strings, so we use lodash.get to access deeply nested children\n accessorFn: row => get(row, accessorKey),\n // The header can be either a string or a JSX.Element, but react-table expects it to be a string or a\n // renderer function, so `() => header` ensures compatibility when header is a JSX.Element.\n // If we just pass `() => header`, then we will loose truncation for string headers.\n header: typeof header === 'string' ? header : () => header,\n // features\n enableColumnFilter,\n enableGlobalFilter,\n enableGrouping,\n enableHiding: isGrouped ? false : enableHiding,\n enableResizing,\n enableSorting,\n // config - sizing\n minSize,\n // meta\n meta: {\n ...(meta as any),\n align: meta.align ?? dataTypeProperties.align,\n defaultWidth,\n enableOrdering: isGrouped ? false : enableOrdering,\n enablePrinting,\n enableTruncate,\n enableEditing,\n header,\n renderer,\n },\n };\n\n // renderers - use defined renderers first, then fall back to data type renderers (if there is one)\n if (typeof renderer === 'function') {\n column.cell = info => renderer(info.getValue(), info.row.original);\n } else if (dataTypeProperties.getDisplayValue) {\n const dataTypeRenderer = (value: any) => {\n const displayValue = dataTypeProperties.getDisplayValue?.(value, { localization });\n\n if (Array.isArray(displayValue)) {\n return displayValue[0] ?? value;\n }\n\n return displayValue ?? value;\n };\n column.cell = info => dataTypeRenderer(info.getValue());\n (column.meta as any).renderer = dataTypeRenderer;\n }\n\n if (typeof footer === 'function') {\n column.footer = info =>\n footer(info.table.getRowModel().rows.flatMap(row => (row.original !== undefined ? row.original : [])));\n }\n\n // config - filtering\n if (enableColumnFilter) {\n column.filterFn = 'tacoFilter' as any;\n }\n\n // config - grouping/aggregation\n if (enableGrouping) {\n column.aggregationFn = aggregationFn;\n\n if (typeof aggregate === 'function') {\n column.aggregatedCell = info => aggregate(info.getValue(), info.row.original);\n }\n }\n\n // config - sorting\n if (enableSorting) {\n column.sortingFn = getSortingFn<TType>(child.props.dataType, sortFn);\n column.sortDescFirst = false;\n column.sortUndefined = 1;\n }\n\n columns.push(column);\n }\n\n return columns;\n}\n\nfunction createInternalColumn<TType = unknown>(\n id: string,\n column: useTableManagerInternalColumn<TType>,\n defaultSizing: ReactTableColumnSizingState\n) {\n if (column.size) {\n defaultSizing[id] = column.size;\n }\n\n return {\n id,\n accessorKey: id,\n header: column.header,\n cell: column.renderer,\n // features\n enableColumnFilter: false,\n enableGlobalFilter: false,\n enableGrouping: false,\n enableHiding: false,\n enableResizing: false,\n enableSorting: false,\n // config - sizing\n size: column.size,\n minSize: column.size,\n // meta\n meta: {\n ...(column.meta as any),\n enableOrdering: false,\n enablePrinting: false,\n enableTruncate: false,\n },\n } as ReactTableColumnDef<TType, any>;\n}\n\nexport function mapTableChildrenToColumns<TType = unknown>(\n props: TableProps<TType>,\n settings: TableSettings,\n options: TableFeatureProps<TType>,\n internalColumns: useTableManagerInternalColumns<TType> | undefined,\n localization: Localization\n) {\n const { children, defaultRowGroupColumnId } = props;\n const defaultSizing: ReactTableColumnSizingState = {};\n const defaultSorting: ReactTableColumnSort[] = [];\n const defaultVisibility: ReactTableVisibilityState = {};\n\n const columns = React.Children.toArray(children).reduce(\n (columns: ReactTableColumnDef<TType>[], child) =>\n processChildren<TType>(\n child,\n columns,\n defaultSizing,\n defaultSorting,\n defaultVisibility,\n settings,\n defaultRowGroupColumnId,\n localization\n ),\n\n []\n );\n\n if (internalColumns) {\n if (options.enableRowExpansion && props.rowExpansionRenderer && internalColumns.rowExpansion) {\n const column = createInternalColumn<TType>('__expansion', internalColumns.rowExpansion, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowSelection && internalColumns.rowSelection) {\n const column = createInternalColumn<TType>('__select', internalColumns.rowSelection, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowDrag && props.onRowDrag && internalColumns.rowDrag) {\n const column = createInternalColumn<TType>('__drag', internalColumns.rowDrag, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowActions && props.rowActions?.length && internalColumns.rowActions) {\n const column = createInternalColumn<TType>('__actions', internalColumns.rowActions, defaultSizing);\n columns.push(column);\n }\n }\n\n return { columns, defaultSizing, defaultSorting, defaultVisibility };\n}\n\nexport function configureReactTableOptions<TType = unknown>(\n options: TableFeatureProps<TType>,\n props: TableProps<TType>,\n localization: Localization\n) {\n // We don't want to expose internal Tanstack Table row, so we need to wrap enableRowSelection callback into additional function,\n // which receives the React Table Row object and passes row.original to a callback.\n const reactTableEnableRowSelection =\n typeof options.enableRowSelection === 'function'\n ? (row: ReactTableRow<TType>) => (options.enableRowSelection as (row: TType) => boolean)(row.original)\n : options.enableRowSelection;\n\n let getRowId;\n\n if (props.rowIdentityAccessor) {\n getRowId = (originalRow: TType | undefined, index: number) => {\n if (originalRow) {\n return String(originalRow[props.rowIdentityAccessor as string]);\n }\n\n return String(index);\n };\n }\n\n const tableOptions: Partial<ReactTableOptions<TType>> = {\n defaultColumn: {\n enableColumnFilter: options.enableFiltering || true,\n enableGrouping: false,\n enableHiding: options.enableColumnHiding || true,\n enableResizing: options.enableColumnResizing || true,\n enableGlobalFilter: options.enableSearch || true,\n enableSorting: options.enableSorting || true,\n minSize: 1,\n // the default is 150, which is a bit random\n size: 1,\n },\n enableColumnFilters: options.enableFiltering ?? false,\n enableColumnResizing: options.enableColumnResizing ?? false,\n enableExpanding: options.enableRowExpansion ?? false,\n enableGrouping: true, // users can't customise row grouping, so it can just be always enabled and left to the defaultRowGroupColumnId prop\n enableHiding: options.enableColumnHiding ?? false,\n enablePinning: options.enableColumnFreezing ?? false,\n enableRowPinning: true, // users can't customise row pinning, so it can just be always enabled\n enableRowSelection: reactTableEnableRowSelection ?? false,\n enableSorting: options.enableSorting ?? false,\n // models for default features\n getExpandedRowModel: getExpandedRowModel<TType>(),\n getGroupedRowModel: getGroupedRowModel<TType>(),\n getRowId,\n groupedColumnMode: false,\n keepPinnedRows: false,\n };\n\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n if (tableOptions.enableColumnFilters) {\n // enter controlled filter mode (controlled could be local state, but usually the server)\n if (props.onChangeFilter) {\n // tableOptions.manualFiltering = true;\n // we don't set it because it breaks global filtering (used for search, which is fully client side)\n //\n // tableOptions.onColumnFiltersChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onFilter\n } else {\n tableOptions.getFilteredRowModel = getFilteredRowModel<TType>();\n tableOptions.filterFns = {\n tacoFilter: (row: ReactTableRow<TType>, columnId: string, filter: any) =>\n columnFilterFn(row.getValue(columnId), filter),\n };\n }\n }\n\n if (options.enableSearch) {\n // always set these because enableGlobalFilter can be toggled on and off by the user\n tableOptions.getFilteredRowModel = getFilteredRowModel<TType>();\n tableOptions.globalFilterFn = (row: ReactTableRow<TType>, columnId: string, searchQuery: any) =>\n globalFilterFn(row, columnId, searchQuery, localization);\n tableOptions.getColumnCanGlobalFilter = (column: ReactTableColumn<TType>) =>\n column.columnDef.meta?.enableSearch !== false && column.getIsVisible();\n\n // enter controlled search mode (controlled could be local state, but usually the server)\n if (props.onChangeSearch) {\n if (props._experimentalDataLoader2) {\n tableOptions.manualFiltering = true;\n } else {\n // tableOptions.manualFiltering = true;\n // we don't set this because controlled search is not currently supported, search is always client side\n //\n // tableOptions.onGlobalFilterChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onSearch.\n //\n // we also don't always filter when searching, we have the highlight functionality as the default\n // and filtering can be toggled by the user\n }\n }\n }\n\n if (tableOptions.enableSorting) {\n // enter controlled sort mode (controlled could be local state, but usually the server)\n if (props.onChangeSort) {\n tableOptions.manualSorting = true;\n\n // tableOptions.onSortingChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onSort\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n return tableOptions;\n}\n\nexport function useReactTableInitialState<TType = unknown>(\n props: TableProps<TType>,\n columns: ReactTableColumnDef<TType>[],\n persistedSettings: TableSettings,\n defaults: {\n defaultSizing: ReactTableColumnSizingState;\n defaultSorting: ReactTableColumnSort[];\n defaultVisibility: ReactTableVisibilityState;\n }\n): Partial<ReactTableState> {\n return React.useMemo(() => {\n const ignoreNotDefinedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);\n\n const columnPinning: ReactTableColumnPinningState =\n persistedSettings.columnPinning ?? props.defaultSettings?.columnPinning ?? {};\n\n const columnOrder = ensureOrdering<TType>(\n columns,\n persistedSettings.columnOrder ?? props.defaultSettings?.columnOrder,\n columnPinning.left\n );\n\n // ensure internal columns are pinned, and are pinned in the correct order\n if (columnPinning?.left?.length) {\n columnPinning.left = freezeUptoExternalColumn(\n columnOrder.indexOf(columnPinning.left[columnPinning.left.length - 1]),\n columnOrder\n );\n } else {\n if (props.defaultColumnFreezingIndex) {\n columnPinning.left = freezeUptoExternalColumn(props.defaultColumnFreezingIndex, columnOrder);\n } else {\n columnPinning.left = unfreezeAllExternalColumns(columnOrder);\n }\n }\n\n const state: Partial<ReactTableState> = {\n columnFilters: persistedSettings.columnFilters ?? props.defaultSettings?.columnFilters ?? [],\n columnOrder,\n columnPinning,\n columnSizing: ignoreInternalColumns(\n persistedSettings.columnSizing ?? props.defaultSettings?.columnSizing ?? defaults.defaultSizing ?? {}\n ),\n columnVisibility:\n persistedSettings.columnVisibility ?? props.defaultSettings?.columnVisibility ?? defaults.defaultVisibility ?? {},\n globalFilter: persistedSettings.searchQuery ?? props.defaultSettings?.searchQuery,\n sorting: persistedSettings.sorting\n ? persistedSettings.sorting.filter(ignoreNotDefinedColumns)\n : props.defaultSettings?.sorting ?? defaults.defaultSorting,\n };\n\n if (props.defaultRowGroupColumnId) {\n state.grouping = [props.defaultRowGroupColumnId as string];\n // row groups should (all) always be expanded by default\n state.expanded = true;\n }\n\n return state;\n }, []);\n}\n"],"names":["processChildren","child","columns","defaultSizing","defaultSorting","defaultVisibility","settings","defaultRowGroupColumnId","localization","columnHelper","createColumnHelper","React","isValidElement","props","children","id","header","push","group","Children","toArray","reduce","enableGrouping","accessor","_meta$align","untypedId","accessorKey","renderer","aggregate","footer","aggregationFn","defaultHidden","defaultWidth","enableEditing","control","enableFiltering","enableColumnFilter","enableHiding","enableOrdering","enablePrinting","enableResizing","enableSearch","enableGlobalFilter","enableSorting","enableTruncate","minWidth","minSize","getCellMinWidth","fontSize","sort","sortFn","meta","dataTypeProperties","getDataTypeProperties","dataType","isGrouped","undefined","desc","column","accessorFn","row","get","align","cell","info","getValue","original","getDisplayValue","dataTypeRenderer","value","displayValue","_dataTypeProperties$g","call","Array","isArray","_displayValue$","table","getRowModel","rows","flatMap","filterFn","aggregatedCell","sortingFn","getSortingFn","sortDescFirst","sortUndefined","createInternalColumn","size","mapTableChildrenToColumns","options","internalColumns","_props$rowActions","enableRowExpansion","rowExpansionRenderer","rowExpansion","unshift","enableRowSelection","rowSelection","enableRowDrag","onRowDrag","rowDrag","enableRowActions","rowActions","length","configureReactTableOptions","reactTableEnableRowSelection","getRowId","rowIdentityAccessor","originalRow","index","String","tableOptions","defaultColumn","enableColumnHiding","enableColumnResizing","enableColumnFilters","_options$enableFilter","_options$enableColumn","enableExpanding","_options$enableRowExp","_options$enableColumn2","enablePinning","_options$enableColumn3","enableColumnFreezing","enableRowPinning","_options$enableSortin","getExpandedRowModel","getGroupedRowModel","groupedColumnMode","keepPinnedRows","columnResizeMode","onChangeFilter","getFilteredRowModel","filterFns","tacoFilter","columnId","filter","columnFilterFn","globalFilterFn","searchQuery","getColumnCanGlobalFilter","_column$columnDef$met","columnDef","getIsVisible","onChangeSearch","_experimentalDataLoader2","manualFiltering","onChangeSort","manualSorting","getSortedRowModel","useReactTableInitialState","persistedSettings","defaults","useMemo","ignoreNotDefinedColumns","find","definedColumn","columnPinning","_ref","_persistedSettings$co","_props$defaultSetting","defaultSettings","columnOrder","ensureOrdering","_persistedSettings$co2","_props$defaultSetting2","left","_columnPinning$left","freezeUptoExternalColumn","indexOf","defaultColumnFreezingIndex","unfreezeAllExternalColumns","state","columnFilters","_ref2","_persistedSettings$co3","_props$defaultSetting3","columnSizing","ignoreInternalColumns","_ref3","_ref4","_persistedSettings$co4","_props$defaultSetting4","columnVisibility","_ref5","_ref6","_persistedSettings$co5","_props$defaultSetting5","globalFilter","_persistedSettings$se","_props$defaultSetting6","sorting","_props$defaultSetting7","_props$defaultSetting8","grouping","expanded"],"mappings":";;;;;;;;;;AA4BA;AACA,SAASA,eAAeA,CACpBC,KAAiE,EACjEC,OAAqC,EACrCC,aAA0C,EAC1CC,cAAsC,EACtCC,iBAA4C,EAC5CC,QAAuB,EACvBC,uBAAgD,EAChDC,YAA0B;EAE1B,MAAMC,YAAY,GAAGC,kBAAkB,EAAS;EAEhD,iBAAIC,cAAK,CAACC,cAAc,CAAkBX,KAAK,CAAC,IAAIA,KAAK,CAACY,KAAK,CAACC,QAAQ,EAAE;IACtE,MAAM;MAAEA,QAAQ;MAAEC,EAAE;MAAEC;KAAQ,GAAGf,KAAK,CAACY,KAAK;IAE5CX,OAAO,CAACe,IAAI,CACRR,YAAY,CAACS,KAAK,CAAC;MACfH,EAAE;MACFC,MAAM;MACNd,OAAO,EAAES,cAAK,CAACQ,QAAQ,CAACC,OAAO,CAACN,QAAQ,CAAC,CAACO,MAAM,CAC5C,CAACnB,OAAqC,EAAED,KAAK,KACzCD,eAAe,CACXC,KAAK,EACLC,OAAO,EACPC,aAAa,EACbC,cAAc,EACdC,iBAAiB,EACjBC,QAAQ,EACRC,uBAAuB,EACvBC,YAAY,CACf,EACL,EAAE,CACL;;MAEDc,cAAc,EAAE;KACnB,CAAC,CACL;GACJ,MAAM,iBAAIX,cAAK,CAACC,cAAc,CAA0BX,KAAK,CAAC,KAAKA,KAAK,CAACY,KAAK,CAACU,QAAQ,IAAItB,KAAK,CAACY,KAAK,CAACE,EAAE,CAAC,EAAE;IAAA,IAAAS,WAAA;IACzG,MAAM;MACFT,EAAE,EAAEU,SAAS;MACbF,QAAQ,EAAEG,WAAW,GAAGD,SAAS;;MAEjCE,QAAQ;MACRC,SAAS;MACTC,MAAM;MACNb,MAAM;;MAENc,aAAa;MACbC,aAAa;MACbC,YAAY;MAC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,IAAAsC,sBAAA,IAAAC,sBAAA,GACzDpL,KAAK,CAACoJ,eAAe,cAAAgC,sBAAA,uBAArBA,sBAAA,CAAuBF,OAAO,cAAAC,sBAAA,cAAAA,sBAAA,GAAIxC,QAAQ,CAACpJ;KACpD;IAED,IAAIS,KAAK,CAACN,uBAAuB,EAAE;MAC/BqK,KAAK,CAACsB,QAAQ,GAAG,CAACrL,KAAK,CAACN,uBAAiC,CAAC;;MAE1DqK,KAAK,CAACuB,QAAQ,GAAG,IAAI;;IAGzB,OAAOvB,KAAK;GACf,EAAE,EAAE,CAAC;AACV;;;;"}
1
+ {"version":3,"file":"setup.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/setup.ts"],"sourcesContent":["import React from 'react';\nimport {\n createColumnHelper,\n getExpandedRowModel,\n getFilteredRowModel,\n getGroupedRowModel,\n getSortedRowModel,\n TableOptions as ReactTableOptions,\n Row as ReactTableRow,\n Column as ReactTableColumn,\n ColumnDef as ReactTableColumnDef,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSizingState as ReactTableColumnSizingState,\n ColumnSort as ReactTableColumnSort,\n TableState as ReactTableState,\n VisibilityState as ReactTableVisibilityState,\n} from '@tanstack/react-table';\nimport get from 'lodash/get';\nimport { useTableManagerInternalColumns, useTableManagerInternalColumn } from '../types';\nimport { TableColumnProps, TableFeatureProps, TableGroupProps, TableProps, TableSettings } from '../../types';\nimport { getSortingFn } from './sorting';\nimport { ensureOrdering, freezeUptoExternalColumn, getCellMinWidth, unfreezeAllExternalColumns } from './columns';\nimport { columnFilterFn } from './filtering';\nimport { globalFilterFn } from './search';\nimport { ignoreInternalColumns } from './settings';\nimport { getDataTypeProperties } from './dataTypes';\nimport { Localization } from '../../../../components/Provider/Localization';\n\n// mapping children to react-table columns\nfunction processChildren<TType>(\n child: React.ReactChild | React.ReactFragment | React.ReactPortal,\n columns: ReactTableColumnDef<TType>[],\n defaultSizing: ReactTableColumnSizingState,\n defaultSorting: ReactTableColumnSort[],\n defaultVisibility: ReactTableVisibilityState,\n settings: TableSettings,\n defaultRowGroupColumnId: keyof TType | undefined,\n localization: Localization\n): ReactTableColumnDef<TType>[] {\n const columnHelper = createColumnHelper<TType>();\n\n if (React.isValidElement<TableGroupProps>(child) && child.props.children) {\n const { children, id, header } = child.props;\n\n columns.push(\n columnHelper.group({\n id,\n header,\n columns: React.Children.toArray(children).reduce(\n (columns: ReactTableColumnDef<TType>[], child) =>\n processChildren<TType>(\n child,\n columns,\n defaultSizing,\n defaultSorting,\n defaultVisibility,\n settings,\n defaultRowGroupColumnId,\n localization\n ),\n []\n ),\n // we don't want to let column groups be grouped/aggregrated\n enableGrouping: false,\n })\n );\n } else if (React.isValidElement<TableColumnProps<TType>>(child) && (child.props.accessor || child.props.id)) {\n const {\n id: untypedId,\n accessor: accessorKey = untypedId,\n // renderers\n renderer,\n aggregate,\n footer,\n header,\n // options\n aggregationFn,\n defaultHidden,\n defaultWidth,\n enableEditing = !!child.props.control,\n enableFiltering: enableColumnFilter = true,\n enableGrouping = false,\n enableHiding = true,\n enableOrdering = true,\n enablePrinting = true,\n enableResizing = true,\n enableSearch: enableGlobalFilter = true,\n enableSorting = true,\n enableTruncate = false,\n minWidth: minSize = getCellMinWidth(settings.fontSize),\n sort,\n sortFn,\n ...meta\n } = child.props;\n const id = untypedId as string;\n const dataTypeProperties = getDataTypeProperties<TType>(child.props.dataType);\n\n if (defaultHidden && enableHiding) {\n defaultVisibility[id] = false;\n }\n\n if (defaultWidth) {\n defaultSizing[id] = defaultWidth as any;\n }\n\n const isGrouped = defaultRowGroupColumnId === id;\n\n if (child.props.sort !== undefined || isGrouped) {\n defaultSorting.push({\n id,\n desc: sort === 'desc',\n });\n }\n\n const column: ReactTableColumnDef<TType, any> = {\n id,\n accessorKey,\n // To avoid errors caused by undefined row data values, we pass accessorFn as a preventive measure\n // accessorKey can be dot notated strings, so we use lodash.get to access deeply nested children\n accessorFn: row => get(row, accessorKey),\n // The header can be either a string or a JSX.Element, but react-table expects it to be a string or a\n // renderer function, so `() => header` ensures compatibility when header is a JSX.Element.\n // If we just pass `() => header`, then we will loose truncation for string headers.\n header: typeof header === 'string' ? header : () => header,\n // features\n enableColumnFilter,\n enableGlobalFilter,\n enableGrouping,\n enableHiding: isGrouped ? false : enableHiding,\n enableResizing,\n enableSorting,\n // config - sizing\n minSize,\n // meta\n meta: {\n ...(meta as any),\n align: meta.align ?? dataTypeProperties.align,\n defaultWidth,\n enableOrdering: isGrouped ? false : enableOrdering,\n enablePrinting,\n enableTruncate,\n enableEditing,\n header,\n renderer,\n },\n };\n\n // renderers - use defined renderers first, then fall back to data type renderers (if there is one)\n if (typeof renderer === 'function') {\n column.cell = info => renderer(info.getValue(), info.row.original);\n } else if (dataTypeProperties.getDisplayValue) {\n const dataTypeRenderer = (value: any) => {\n const displayValue = dataTypeProperties.getDisplayValue?.(value, { localization });\n\n if (Array.isArray(displayValue)) {\n return displayValue[0] ?? value;\n }\n\n return displayValue ?? value;\n };\n column.cell = info => dataTypeRenderer(info.getValue());\n (column.meta as any).renderer = dataTypeRenderer;\n }\n\n if (typeof footer === 'function') {\n column.footer = info =>\n footer(info.table.getRowModel().rows.flatMap(row => (row.original !== undefined ? row.original : [])));\n }\n\n // config - filtering\n if (enableColumnFilter) {\n column.filterFn = 'tacoFilter' as any;\n }\n\n // config - grouping/aggregation\n if (enableGrouping) {\n column.aggregationFn = aggregationFn;\n\n if (typeof aggregate === 'function') {\n column.aggregatedCell = info => aggregate(info.getValue(), info.row.original);\n }\n }\n\n // config - sorting\n if (enableSorting) {\n column.sortingFn = getSortingFn<TType>(child.props.dataType, sortFn);\n column.sortDescFirst = false;\n column.sortUndefined = 1;\n }\n\n columns.push(column);\n }\n\n return columns;\n}\n\nfunction createInternalColumn<TType = unknown>(\n id: string,\n column: useTableManagerInternalColumn<TType>,\n defaultSizing: ReactTableColumnSizingState\n) {\n if (column.size) {\n defaultSizing[id] = column.size;\n }\n\n return {\n id,\n accessorKey: id,\n header: column.header,\n cell: column.renderer,\n // features\n enableColumnFilter: false,\n enableGlobalFilter: false,\n enableGrouping: false,\n enableHiding: false,\n enableResizing: false,\n enableSorting: false,\n // config - sizing\n size: column.size,\n minSize: column.size,\n // meta\n meta: {\n ...(column.meta as any),\n enableOrdering: false,\n enablePrinting: false,\n enableTruncate: false,\n },\n } as ReactTableColumnDef<TType, any>;\n}\n\nexport function mapTableChildrenToColumns<TType = unknown>(\n props: TableProps<TType>,\n settings: TableSettings,\n options: TableFeatureProps<TType>,\n internalColumns: useTableManagerInternalColumns<TType> | undefined,\n localization: Localization\n) {\n const { children, defaultRowGroupColumnId } = props;\n const defaultSizing: ReactTableColumnSizingState = {};\n const defaultSorting: ReactTableColumnSort[] = [];\n const defaultVisibility: ReactTableVisibilityState = {};\n\n const columns = React.Children.toArray(children).reduce(\n (columns: ReactTableColumnDef<TType>[], child) =>\n processChildren<TType>(\n child,\n columns,\n defaultSizing,\n defaultSorting,\n defaultVisibility,\n settings,\n defaultRowGroupColumnId,\n localization\n ),\n\n []\n );\n\n if (internalColumns) {\n if (options.enableRowExpansion && props.rowExpansionRenderer && internalColumns.rowExpansion) {\n const column = createInternalColumn<TType>('__expansion', internalColumns.rowExpansion, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowSelection && internalColumns.rowSelection) {\n const column = createInternalColumn<TType>('__select', internalColumns.rowSelection, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowDrag && props.onRowDrag && internalColumns.rowDrag) {\n const column = createInternalColumn<TType>('__drag', internalColumns.rowDrag, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowActions && props.rowActions?.length && internalColumns.rowActions) {\n const column = createInternalColumn<TType>('__actions', internalColumns.rowActions, defaultSizing);\n columns.push(column);\n }\n }\n\n return { columns, defaultSizing, defaultSorting, defaultVisibility };\n}\n\nexport function configureReactTableOptions<TType = unknown>(\n options: TableFeatureProps<TType>,\n props: TableProps<TType>,\n localization: Localization\n) {\n // We don't want to expose internal Tanstack Table row, so we need to wrap enableRowSelection callback into additional function,\n // which receives the React Table Row object and passes row.original to a callback.\n const reactTableEnableRowSelection =\n typeof options.enableRowSelection === 'function'\n ? (row: ReactTableRow<TType>) => (options.enableRowSelection as (row: TType) => boolean)(row.original)\n : options.enableRowSelection;\n\n let getRowId;\n\n if (props.rowIdentityAccessor) {\n getRowId = (originalRow: TType | undefined, index: number) => {\n if (originalRow) {\n return String(originalRow[props.rowIdentityAccessor as keyof TType]);\n }\n\n return String(index);\n };\n }\n\n const tableOptions: Partial<ReactTableOptions<TType>> = {\n defaultColumn: {\n enableColumnFilter: options.enableFiltering || true,\n enableGrouping: false,\n enableHiding: options.enableColumnHiding || true,\n enableResizing: options.enableColumnResizing || true,\n enableGlobalFilter: options.enableSearch || true,\n enableSorting: options.enableSorting || true,\n minSize: 1,\n // the default is 150, which is a bit random\n size: 1,\n },\n enableColumnFilters: options.enableFiltering ?? false,\n enableColumnResizing: options.enableColumnResizing ?? false,\n enableExpanding: options.enableRowExpansion ?? false,\n enableGrouping: true, // users can't customise row grouping, so it can just be always enabled and left to the defaultRowGroupColumnId prop\n enableHiding: options.enableColumnHiding ?? false,\n enablePinning: options.enableColumnFreezing ?? false,\n enableRowPinning: true, // users can't customise row pinning, so it can just be always enabled\n enableRowSelection: reactTableEnableRowSelection ?? false,\n enableSorting: options.enableSorting ?? false,\n // models for default features\n getExpandedRowModel: getExpandedRowModel<TType>(),\n getGroupedRowModel: getGroupedRowModel<TType>(),\n getRowId,\n groupedColumnMode: false,\n keepPinnedRows: false,\n };\n\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n if (tableOptions.enableColumnFilters) {\n // enter controlled filter mode (controlled could be local state, but usually the server)\n if (props.onChangeFilter) {\n // tableOptions.manualFiltering = true;\n // we don't set it because it breaks global filtering (used for search, which is fully client side)\n //\n // tableOptions.onColumnFiltersChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onFilter\n } else {\n tableOptions.getFilteredRowModel = getFilteredRowModel<TType>();\n tableOptions.filterFns = {\n tacoFilter: (row: ReactTableRow<TType>, columnId: string, filter: any) =>\n columnFilterFn(row.getValue(columnId), filter),\n };\n }\n }\n\n if (options.enableSearch) {\n // always set these because enableGlobalFilter can be toggled on and off by the user\n tableOptions.getFilteredRowModel = getFilteredRowModel<TType>();\n tableOptions.globalFilterFn = (row: ReactTableRow<TType>, columnId: string, searchQuery: any) =>\n globalFilterFn(row, columnId, searchQuery, localization);\n tableOptions.getColumnCanGlobalFilter = (column: ReactTableColumn<TType>) =>\n column.columnDef.meta?.enableSearch !== false && column.getIsVisible();\n\n // enter controlled search mode (controlled could be local state, but usually the server)\n if (props.onChangeSearch) {\n if (props._experimentalDataLoader2) {\n tableOptions.manualFiltering = true;\n } else {\n // tableOptions.manualFiltering = true;\n // we don't set this because controlled search is not currently supported, search is always client side\n //\n // tableOptions.onGlobalFilterChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onSearch.\n //\n // we also don't always filter when searching, we have the highlight functionality as the default\n // and filtering can be toggled by the user\n }\n }\n }\n\n if (tableOptions.enableSorting) {\n // enter controlled sort mode (controlled could be local state, but usually the server)\n if (props.onChangeSort) {\n tableOptions.manualSorting = true;\n\n // tableOptions.onSortingChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onSort\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n return tableOptions;\n}\n\nexport function useReactTableInitialState<TType = unknown>(\n props: TableProps<TType>,\n columns: ReactTableColumnDef<TType>[],\n persistedSettings: TableSettings,\n defaults: {\n defaultSizing: ReactTableColumnSizingState;\n defaultSorting: ReactTableColumnSort[];\n defaultVisibility: ReactTableVisibilityState;\n }\n): Partial<ReactTableState> {\n return React.useMemo(() => {\n const ignoreNotDefinedColumns = (column: ReactTableColumnDef<TType>) =>\n columns.find(definedColumn => definedColumn.id === column.id);\n\n const columnPinning: ReactTableColumnPinningState =\n persistedSettings.columnPinning ?? props.defaultSettings?.columnPinning ?? {};\n\n const columnOrder = ensureOrdering<TType>(\n columns,\n persistedSettings.columnOrder ?? props.defaultSettings?.columnOrder,\n columnPinning.left\n );\n\n // ensure internal columns are pinned, and are pinned in the correct order\n if (columnPinning?.left?.length) {\n columnPinning.left = freezeUptoExternalColumn(\n columnOrder.indexOf(columnPinning.left[columnPinning.left.length - 1]),\n columnOrder\n );\n } else {\n if (props.defaultColumnFreezingIndex) {\n columnPinning.left = freezeUptoExternalColumn(props.defaultColumnFreezingIndex, columnOrder);\n } else {\n columnPinning.left = unfreezeAllExternalColumns(columnOrder);\n }\n }\n\n const state: Partial<ReactTableState> = {\n columnFilters: persistedSettings.columnFilters ?? props.defaultSettings?.columnFilters ?? [],\n columnOrder,\n columnPinning,\n columnSizing: ignoreInternalColumns(\n persistedSettings.columnSizing ?? props.defaultSettings?.columnSizing ?? defaults.defaultSizing ?? {}\n ),\n columnVisibility:\n persistedSettings.columnVisibility ?? props.defaultSettings?.columnVisibility ?? defaults.defaultVisibility ?? {},\n globalFilter: persistedSettings.searchQuery ?? props.defaultSettings?.searchQuery,\n sorting: persistedSettings.sorting\n ? persistedSettings.sorting.filter(ignoreNotDefinedColumns)\n : props.defaultSettings?.sorting ?? defaults.defaultSorting,\n };\n\n if (props.defaultRowGroupColumnId) {\n state.grouping = [props.defaultRowGroupColumnId as string];\n // row groups should (all) always be expanded by default\n state.expanded = true;\n }\n\n return state;\n }, []);\n}\n"],"names":["processChildren","child","columns","defaultSizing","defaultSorting","defaultVisibility","settings","defaultRowGroupColumnId","localization","columnHelper","createColumnHelper","React","isValidElement","props","children","id","header","push","group","Children","toArray","reduce","enableGrouping","accessor","_meta$align","untypedId","accessorKey","renderer","aggregate","footer","aggregationFn","defaultHidden","defaultWidth","enableEditing","control","enableFiltering","enableColumnFilter","enableHiding","enableOrdering","enablePrinting","enableResizing","enableSearch","enableGlobalFilter","enableSorting","enableTruncate","minWidth","minSize","getCellMinWidth","fontSize","sort","sortFn","meta","dataTypeProperties","getDataTypeProperties","dataType","isGrouped","undefined","desc","column","accessorFn","row","get","align","cell","info","getValue","original","getDisplayValue","dataTypeRenderer","value","displayValue","_dataTypeProperties$g","call","Array","isArray","_displayValue$","table","getRowModel","rows","flatMap","filterFn","aggregatedCell","sortingFn","getSortingFn","sortDescFirst","sortUndefined","createInternalColumn","size","mapTableChildrenToColumns","options","internalColumns","_props$rowActions","enableRowExpansion","rowExpansionRenderer","rowExpansion","unshift","enableRowSelection","rowSelection","enableRowDrag","onRowDrag","rowDrag","enableRowActions","rowActions","length","configureReactTableOptions","reactTableEnableRowSelection","getRowId","rowIdentityAccessor","originalRow","index","String","tableOptions","defaultColumn","enableColumnHiding","enableColumnResizing","enableColumnFilters","_options$enableFilter","_options$enableColumn","enableExpanding","_options$enableRowExp","_options$enableColumn2","enablePinning","_options$enableColumn3","enableColumnFreezing","enableRowPinning","_options$enableSortin","getExpandedRowModel","getGroupedRowModel","groupedColumnMode","keepPinnedRows","columnResizeMode","onChangeFilter","getFilteredRowModel","filterFns","tacoFilter","columnId","filter","columnFilterFn","globalFilterFn","searchQuery","getColumnCanGlobalFilter","_column$columnDef$met","columnDef","getIsVisible","onChangeSearch","_experimentalDataLoader2","manualFiltering","onChangeSort","manualSorting","getSortedRowModel","useReactTableInitialState","persistedSettings","defaults","useMemo","ignoreNotDefinedColumns","find","definedColumn","columnPinning","_ref","_persistedSettings$co","_props$defaultSetting","defaultSettings","columnOrder","ensureOrdering","_persistedSettings$co2","_props$defaultSetting2","left","_columnPinning$left","freezeUptoExternalColumn","indexOf","defaultColumnFreezingIndex","unfreezeAllExternalColumns","state","columnFilters","_ref2","_persistedSettings$co3","_props$defaultSetting3","columnSizing","ignoreInternalColumns","_ref3","_ref4","_persistedSettings$co4","_props$defaultSetting4","columnVisibility","_ref5","_ref6","_persistedSettings$co5","_props$defaultSetting5","globalFilter","_persistedSettings$se","_props$defaultSetting6","sorting","_props$defaultSetting7","_props$defaultSetting8","grouping","expanded"],"mappings":";;;;;;;;;;AA4BA;AACA,SAASA,eAAeA,CACpBC,KAAiE,EACjEC,OAAqC,EACrCC,aAA0C,EAC1CC,cAAsC,EACtCC,iBAA4C,EAC5CC,QAAuB,EACvBC,uBAAgD,EAChDC,YAA0B;EAE1B,MAAMC,YAAY,GAAGC,kBAAkB,EAAS;EAEhD,iBAAIC,cAAK,CAACC,cAAc,CAAkBX,KAAK,CAAC,IAAIA,KAAK,CAACY,KAAK,CAACC,QAAQ,EAAE;IACtE,MAAM;MAAEA,QAAQ;MAAEC,EAAE;MAAEC;KAAQ,GAAGf,KAAK,CAACY,KAAK;IAE5CX,OAAO,CAACe,IAAI,CACRR,YAAY,CAACS,KAAK,CAAC;MACfH,EAAE;MACFC,MAAM;MACNd,OAAO,EAAES,cAAK,CAACQ,QAAQ,CAACC,OAAO,CAACN,QAAQ,CAAC,CAACO,MAAM,CAC5C,CAACnB,OAAqC,EAAED,KAAK,KACzCD,eAAe,CACXC,KAAK,EACLC,OAAO,EACPC,aAAa,EACbC,cAAc,EACdC,iBAAiB,EACjBC,QAAQ,EACRC,uBAAuB,EACvBC,YAAY,CACf,EACL,EAAE,CACL;;MAEDc,cAAc,EAAE;KACnB,CAAC,CACL;GACJ,MAAM,iBAAIX,cAAK,CAACC,cAAc,CAA0BX,KAAK,CAAC,KAAKA,KAAK,CAACY,KAAK,CAACU,QAAQ,IAAItB,KAAK,CAACY,KAAK,CAACE,EAAE,CAAC,EAAE;IAAA,IAAAS,WAAA;IACzG,MAAM;MACFT,EAAE,EAAEU,SAAS;MACbF,QAAQ,EAAEG,WAAW,GAAGD,SAAS;;MAEjCE,QAAQ;MACRC,SAAS;MACTC,MAAM;MACNb,MAAM;;MAENc,aAAa;MACbC,aAAa;MACbC,YAAY;MACZC,aAAa,GAAG,CAAC,CAAChC,KAAK,CAACY,KAAK,CAACqB,OAAO;MACrCC,eAAe,EAAEC,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AArBA,sBAAA,CAAuBF,OAAO,cAAAC,sBAAA,cAAAA,sBAAA,GAAIxC,QAAQ,CAACpJ;KACpD;IAED,IAAIS,KAAK,CAACN,uBAAuB,EAAE;MAC/BqK,KAAK,CAACsB,QAAQ,GAAG,CAACrL,KAAK,CAACN,uBAAiC,CAAC;;MAE1DqK,KAAK,CAACuB,QAAQ,GAAG,IAAI;;IAGzB,OAAOvB,KAAK;GACf,EAAE,EAAE,CAAC;AACV;;;;"}
@@ -3,8 +3,9 @@ export declare type SortableItemId = string | number;
3
3
  export declare type SortableListItemProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'id'> & {
4
4
  disabled?: boolean;
5
5
  id: SortableItemId;
6
+ asChild: boolean;
6
7
  };
7
- export declare function Item(props: any): JSX.Element;
8
+ export declare function Item(props: SortableListItemProps): JSX.Element;
8
9
  export declare namespace Item {
9
10
  var displayName: string;
10
11
  }
@@ -3,13 +3,13 @@ import { TableColumnSortDirection } from '../../../../types';
3
3
  declare type SortIndicatorProps = {
4
4
  direction: false | TableColumnSortDirection;
5
5
  };
6
- export declare function SortIndicator(props: SortIndicatorProps): any;
7
- export declare const getAriaSort: (direction: any) => any;
6
+ export declare function SortIndicator(props: SortIndicatorProps): JSX.Element;
7
+ export declare const getAriaSort: (direction: TableColumnSortDirection) => "ascending" | "descending";
8
8
  export declare function getSortAttributes(canSort: boolean, toggleSorting?: (event: unknown) => void, sortDirection?: false | TableColumnSortDirection): {
9
9
  'aria-sort'?: undefined;
10
10
  onClick?: undefined;
11
11
  } | {
12
- 'aria-sort': any;
12
+ 'aria-sort': "ascending" | "descending";
13
13
  onClick: (event: React.MouseEvent) => void;
14
14
  };
15
15
  export {};
@@ -12,7 +12,7 @@ export declare type TableRowRendererProps<TType = unknown> = {
12
12
  hideInternalColumns?: boolean;
13
13
  hideRowActions?: boolean;
14
14
  index: number;
15
- measureRow: (index: number, size: number) => void;
15
+ measureRow: (size: number) => void;
16
16
  row: ReactTableRow<TType>;
17
17
  table: ReactTable<TType>;
18
18
  };
@@ -7055,12 +7055,12 @@ const Bar = props => {
7055
7055
  className: className
7056
7056
  }));
7057
7057
  };
7058
- const Thumb = props => /*#__PURE__*/React__default.createElement(ScrollAreaPrimitive.Thumb, Object.assign({}, props, {
7058
+ const Thumb = () => /*#__PURE__*/React__default.createElement(ScrollAreaPrimitive.Thumb, {
7059
7059
  className: "flex-[1] rounded bg-black opacity-50"
7060
- }));
7061
- const Corner = props => /*#__PURE__*/React__default.createElement(ScrollAreaPrimitive.Corner, Object.assign({}, props, {
7060
+ });
7061
+ const Corner = () => /*#__PURE__*/React__default.createElement(ScrollAreaPrimitive.Corner, {
7062
7062
  className: "bg-grey-500"
7063
- }));
7063
+ });
7064
7064
  const ScrollArea = props => {
7065
7065
  const {
7066
7066
  children,
@@ -12444,6 +12444,8 @@ function getPaddingEndOffset(table, options) {
12444
12444
  const bottomRows = (_table$getBottomRows = table.getBottomRows()) !== null && _table$getBottomRows !== void 0 ? _table$getBottomRows : [];
12445
12445
  return ROW_HEIGHT_ESTIMATES.medium * ((_options$virtualiserP = options === null || options === void 0 ? void 0 : options.virtualiserPaddingEndOffset) !== null && _options$virtualiserP !== void 0 ? _options$virtualiserP : 1) * bottomRows.length;
12446
12446
  }
12447
+ // A higher number ensure less scroll jumping for dynamic row heights, but too high can reduce performance. 8 worked well
12448
+ const OVERSCAN_ROW_COUNT = 8;
12447
12449
  function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIndex, options) {
12448
12450
  var _table$getState$group, _table$getCenterRows, _virtualItems$padding, _virtualItems$padding2, _virtualItems$padding3, _virtualItems$end, _virtualItems;
12449
12451
  const tableMeta = table.options.meta;
@@ -12460,7 +12462,7 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
12460
12462
  return tableMeta.rowHeight.height ? ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] : ROW_HEIGHT_ESTIMATES.medium;
12461
12463
  },
12462
12464
  getScrollElement: () => tableRef.current,
12463
- overscan: tableMeta.printing.isPrinting ? count : 8,
12465
+ overscan: tableMeta.printing.isPrinting ? count : OVERSCAN_ROW_COUNT,
12464
12466
  rangeExtractor,
12465
12467
  // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list
12466
12468
  scrollPaddingStart,
@@ -12548,13 +12550,16 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
12548
12550
  table: table
12549
12551
  });
12550
12552
  }
12553
+ const measureRow = rowHeight => {
12554
+ virtualiser.resizeItem(virtualRow, rowHeight);
12555
+ };
12551
12556
  return /*#__PURE__*/React__default.createElement(Row, {
12552
12557
  key: row.id,
12553
12558
  row: row,
12554
12559
  index: virtualRow.index,
12555
12560
  scrollDirection: (_virtualiser$scrollDi2 = virtualiser.scrollDirection) !== null && _virtualiser$scrollDi2 !== void 0 ? _virtualiser$scrollDi2 : undefined,
12556
12561
  table: table,
12557
- measureRow: virtualiser.resizeItem,
12562
+ measureRow: measureRow,
12558
12563
  renderer: renderers.row,
12559
12564
  cellRenderer: renderers.cell
12560
12565
  });
@@ -13252,12 +13257,18 @@ const DisplayRow = /*#__PURE__*/React__default.memo(function DisplayRow(props) {
13252
13257
  }
13253
13258
  const ref = React__default.useRef(null);
13254
13259
  const expansionRef = React__default.useRef(null);
13260
+ const isExpanded = !!attributes['data-row-expanded'];
13255
13261
  React__default.useEffect(() => {
13256
- var _ref$current$getBound, _ref$current, _expansionRef$current, _expansionRef$current2;
13257
- const rowHeight = (_ref$current$getBound = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.getBoundingClientRect().height) !== null && _ref$current$getBound !== void 0 ? _ref$current$getBound : 0;
13258
- const expansionHeight = (_expansionRef$current = (_expansionRef$current2 = expansionRef.current) === null || _expansionRef$current2 === void 0 ? void 0 : _expansionRef$current2.getBoundingClientRect().height) !== null && _expansionRef$current !== void 0 ? _expansionRef$current : 0;
13259
- measureRow(index, rowHeight + expansionHeight);
13260
- }, [expansionRef.current]);
13262
+ if (ref.current) {
13263
+ const height = ref.current.getBoundingClientRect().height;
13264
+ if (isExpanded && expansionRef.current) {
13265
+ var _expansionRef$current;
13266
+ measureRow(height + ((_expansionRef$current = expansionRef.current.getBoundingClientRect().height) !== null && _expansionRef$current !== void 0 ? _expansionRef$current : 0));
13267
+ } else {
13268
+ measureRow(height);
13269
+ }
13270
+ }
13271
+ }, [isExpanded, ref.current, expansionRef.current]);
13261
13272
  const className = cn('group/row', otherAttributes.className, {
13262
13273
  'hover:cursor-grab': tableMeta.rowDrag.isEnabled && typeof attributes.onClick !== 'function',
13263
13274
  'hover:cursor-pointer': typeof attributes.onClick === 'function'
@@ -13555,11 +13566,11 @@ function HeaderMenu(props) {
13555
13566
  return Promise.reject(e);
13556
13567
  }
13557
13568
  };
13558
- popoverElement = props => /*#__PURE__*/React__default.createElement(GotoPopover, Object.assign({}, props, {
13569
+ popoverElement = props => (/*#__PURE__*/React__default.createElement(GotoPopover, Object.assign({}, props, {
13559
13570
  open: true,
13560
13571
  onChange: handleClosePopover,
13561
13572
  onGoto: goto
13562
- }));
13573
+ })));
13563
13574
  }
13564
13575
  }
13565
13576
  }
@@ -13916,10 +13927,10 @@ const FOCUS_MANAGER_OPTIONS_ARROW_KEYS = {
13916
13927
  };
13917
13928
  function useAugmentedFocusManager() {
13918
13929
  const focusManager = focus.useFocusManager();
13919
- const focusPrevious = (arrowNavigation = false) => focusManager.focusPrevious(arrowNavigation ? FOCUS_MANAGER_OPTIONS_ARROW_KEYS : FOCUS_MANAGER_OPTIONS_TAB);
13920
- const focusNext = (arrowNavigation = false) => focusManager.focusNext(arrowNavigation ? FOCUS_MANAGER_OPTIONS_ARROW_KEYS : FOCUS_MANAGER_OPTIONS_TAB);
13921
- const focusFirst = () => focusManager.focusFirst(FOCUS_MANAGER_OPTIONS_TAB);
13922
- const focusLast = () => focusManager.focusLast(FOCUS_MANAGER_OPTIONS_TAB);
13930
+ const focusPrevious = (arrowNavigation = false) => focusManager === null || focusManager === void 0 ? void 0 : focusManager.focusPrevious(arrowNavigation ? FOCUS_MANAGER_OPTIONS_ARROW_KEYS : FOCUS_MANAGER_OPTIONS_TAB);
13931
+ const focusNext = (arrowNavigation = false) => focusManager === null || focusManager === void 0 ? void 0 : focusManager.focusNext(arrowNavigation ? FOCUS_MANAGER_OPTIONS_ARROW_KEYS : FOCUS_MANAGER_OPTIONS_TAB);
13932
+ const focusFirst = () => focusManager === null || focusManager === void 0 ? void 0 : focusManager.focusFirst(FOCUS_MANAGER_OPTIONS_TAB);
13933
+ const focusLast = () => focusManager === null || focusManager === void 0 ? void 0 : focusManager.focusLast(FOCUS_MANAGER_OPTIONS_TAB);
13923
13934
  return {
13924
13935
  focusPrevious,
13925
13936
  focusNext,
@@ -15337,7 +15348,6 @@ const Colours = props => {
15337
15348
  const {
15338
15349
  color,
15339
15350
  onChangeColor,
15340
- onClick,
15341
15351
  onKeyDown
15342
15352
  } = props;
15343
15353
  const {
@@ -15346,7 +15356,6 @@ const Colours = props => {
15346
15356
  return /*#__PURE__*/React__default.createElement(RadioGroupPrimitive.Root, {
15347
15357
  "aria-label": texts.select2.chooseColor,
15348
15358
  className: "grid grid-cols-4 gap-2 focus:outline-none",
15349
- onClick: onClick,
15350
15359
  onKeyDown: onKeyDown,
15351
15360
  onValueChange: color => onChangeColor(color),
15352
15361
  value: color
@@ -20179,7 +20188,10 @@ function Row$2(props) {
20179
20188
  const isActiveRow = tableMeta.rowActive.rowActiveIndex === index;
20180
20189
  React__default.useEffect(() => {
20181
20190
  if (tableMeta.editing.isEditing && isActiveRow && tableMeta.editing.lastFocusedCellIndex === undefined) {
20182
- setDataFocusAttribute(focusManager.focusFirst());
20191
+ const element = focusManager.focusFirst();
20192
+ if (element) {
20193
+ setDataFocusAttribute(element);
20194
+ }
20183
20195
  }
20184
20196
  }, [tableMeta.editing.isEditing, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.lastFocusedCellIndex]);
20185
20197
  const handleFocus = React__default.useCallback(event => {
@@ -22042,7 +22054,7 @@ function AgreementSelector(props) {
22042
22054
  }
22043
22055
  return button;
22044
22056
  })), handleAddAgreement ? (/*#__PURE__*/React__default.createElement(Button$1, {
22045
- className: "focus-visible:!yt-focus-dark my-1 mx-2 !h-9 shrink-0 !bg-white/[0.08] !text-white hover:!bg-white/[0.16]",
22057
+ className: "focus-visible:!yt-focus-dark mx-2 my-1 !h-9 shrink-0 !bg-white/[0.08] !text-white hover:!bg-white/[0.16]",
22046
22058
  onClick: handleAddAgreement
22047
22059
  }, texts.header.addAgreement)) : null, /*#__PURE__*/React__default.createElement("hr", {
22048
22060
  className: "my-0 h-px w-full bg-white/[0.08]"