@economic/taco 2.45.0-alpha.2 → 2.45.0-alpha.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. package/dist/charts/components/Area/AreaChart.d.ts +19 -0
  2. package/dist/charts/components/Bar/BarChart.d.ts +20 -0
  3. package/dist/charts/components/Donut/ActiveShape.d.ts +8 -0
  4. package/dist/charts/components/Donut/CenteredLabel.d.ts +11 -0
  5. package/dist/charts/components/Donut/DonutChart.d.ts +21 -0
  6. package/dist/charts/components/Donut/Legend.d.ts +13 -0
  7. package/dist/charts/components/Donut/util.d.ts +2 -0
  8. package/dist/charts/components/Legend.d.ts +16 -0
  9. package/dist/charts/components/Line/LineChart.d.ts +18 -0
  10. package/dist/charts/components/ResponsiveContainer.d.ts +5 -0
  11. package/dist/charts/components/Tooltip.d.ts +10 -0
  12. package/dist/charts/components/types.d.ts +5 -0
  13. package/dist/charts/utils/color.d.ts +3 -0
  14. package/dist/charts/utils/common.d.ts +37 -0
  15. package/dist/components/RadioGroup/RadioGroup.d.ts +3 -3
  16. package/dist/components/Table3/components/Columns/Internal/EditingActionsMenu.d.ts +2 -2
  17. package/dist/components/Table3/features/useEditingState.d.ts +1 -1
  18. package/dist/components/Table3/features/useTableEditing.d.ts +4 -3
  19. package/dist/esm/index.css +18 -0
  20. package/dist/esm/packages/taco/src/charts/components/Area/AreaChart.js +67 -0
  21. package/dist/esm/packages/taco/src/charts/components/Area/AreaChart.js.map +1 -0
  22. package/dist/esm/packages/taco/src/charts/components/Bar/BarChart.js +120 -0
  23. package/dist/esm/packages/taco/src/charts/components/Bar/BarChart.js.map +1 -0
  24. package/dist/esm/packages/taco/src/charts/components/Donut/ActiveShape.js +47 -0
  25. package/dist/esm/packages/taco/src/charts/components/Donut/ActiveShape.js.map +1 -0
  26. package/dist/esm/packages/taco/src/charts/components/Donut/CenteredLabel.js +27 -0
  27. package/dist/esm/packages/taco/src/charts/components/Donut/CenteredLabel.js.map +1 -0
  28. package/dist/esm/packages/taco/src/charts/components/Donut/DonutChart.js +170 -0
  29. package/dist/esm/packages/taco/src/charts/components/Donut/DonutChart.js.map +1 -0
  30. package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js +164 -0
  31. package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js.map +1 -0
  32. package/dist/esm/packages/taco/src/charts/components/Donut/util.js +5 -0
  33. package/dist/esm/packages/taco/src/charts/components/Donut/util.js.map +1 -0
  34. package/dist/esm/packages/taco/src/charts/components/Legend.js +145 -0
  35. package/dist/esm/packages/taco/src/charts/components/Legend.js.map +1 -0
  36. package/dist/esm/packages/taco/src/charts/components/Line/LineChart.js +65 -0
  37. package/dist/esm/packages/taco/src/charts/components/Line/LineChart.js.map +1 -0
  38. package/dist/esm/packages/taco/src/charts/components/ResponsiveContainer.js +10 -0
  39. package/dist/esm/packages/taco/src/charts/components/ResponsiveContainer.js.map +1 -0
  40. package/dist/esm/packages/taco/src/charts/components/Tooltip.js +44 -0
  41. package/dist/esm/packages/taco/src/charts/components/Tooltip.js.map +1 -0
  42. package/dist/esm/packages/taco/src/charts/utils/color.js +24 -0
  43. package/dist/esm/packages/taco/src/charts/utils/color.js.map +1 -0
  44. package/dist/esm/packages/taco/src/charts/utils/common.js +34 -0
  45. package/dist/esm/packages/taco/src/charts/utils/common.js.map +1 -0
  46. package/dist/esm/packages/taco/src/components/Accordion/Accordion.js +6 -14
  47. package/dist/esm/packages/taco/src/components/Accordion/Accordion.js.map +1 -1
  48. package/dist/esm/packages/taco/src/components/Button/util.js +1 -1
  49. package/dist/esm/packages/taco/src/components/Button/util.js.map +1 -1
  50. package/dist/esm/packages/taco/src/components/Dialog/Dialog.js.map +1 -1
  51. package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js +2 -4
  52. package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js.map +1 -1
  53. package/dist/esm/packages/taco/src/components/Input/util.js +1 -1
  54. package/dist/esm/packages/taco/src/components/Input/util.js.map +1 -1
  55. package/dist/esm/packages/taco/src/components/Listbox/util.js +1 -7
  56. package/dist/esm/packages/taco/src/components/Listbox/util.js.map +1 -1
  57. package/dist/esm/packages/taco/src/components/RadioGroup/RadioGroup.js.map +1 -1
  58. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
  59. package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowSelect.js.map +1 -1
  60. package/dist/esm/packages/taco/src/components/Table3/Table3.js +0 -1
  61. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  62. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
  63. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js +2 -2
  64. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js.map +1 -1
  65. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +4 -32
  66. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js.map +1 -1
  67. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js +1 -1
  68. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js.map +1 -1
  69. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js +4 -4
  70. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js.map +1 -1
  71. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +32 -1
  72. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
  73. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +7 -5
  74. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
  75. package/dist/esm/packages/taco/src/components/Table3/useTable3.js +16 -4
  76. package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
  77. package/dist/esm/packages/taco/src/index.js +4 -0
  78. package/dist/esm/packages/taco/src/index.js.map +1 -1
  79. package/dist/esm/packages/taco/src/primitives/Sortable/components/Item.js.map +1 -1
  80. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +10 -5
  81. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
  82. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js +6 -0
  83. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js.map +1 -1
  84. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js +23 -16
  85. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js.map +1 -1
  86. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +4 -3
  87. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
  88. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Drag.js +7 -0
  89. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Drag.js.map +1 -1
  90. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js +7 -0
  91. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js.map +1 -1
  92. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js +2 -1
  93. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js.map +1 -1
  94. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +4 -1
  95. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
  96. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js +3 -1
  97. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js.map +1 -1
  98. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js +3 -2
  99. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js.map +1 -1
  100. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +5 -1
  101. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  102. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
  103. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js.map +1 -1
  104. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/sorting.js.map +1 -1
  105. package/dist/esm/packages/taco/tailwind.colors.js +122 -0
  106. package/dist/esm/packages/taco/tailwind.colors.js.map +1 -0
  107. package/dist/index.css +18 -0
  108. package/dist/index.d.ts +5 -0
  109. package/dist/primitives/Table/Core/components/Body/EmptyStateBody.d.ts +1 -0
  110. package/dist/primitives/Table/Core/components/Row/RowContext.d.ts +2 -1
  111. package/dist/primitives/Table/Core/types.d.ts +1 -0
  112. package/dist/taco.cjs.development.js +942 -105
  113. package/dist/taco.cjs.development.js.map +1 -1
  114. package/dist/taco.cjs.production.min.js +1 -1
  115. package/dist/taco.cjs.production.min.js.map +1 -1
  116. package/package.json +18 -16
  117. package/tailwind.colors.js +121 -0
  118. package/tailwind.config.js +3 -2
  119. package/dist/components/Table3/components/Row/Editing/CreateRowButton.d.ts +0 -11
@@ -1 +1 @@
1
- {"version":3,"file":"useTableRenderer.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableRenderer.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport {\n useVirtualizer,\n defaultRangeExtractor,\n ScrollToOptions as ReactVirtualScrollToOptions,\n VirtualItem,\n Range,\n} from '@tanstack/react-virtual';\nimport { ROW_HEIGHT_ESTIMATES } from '../util/rows';\nimport { Row } from '../components/Row/Row';\nimport { useTableRenderers, useTableRenderOptions } from '../types';\nimport { TableRef } from '../../types';\n\n// scroll padding end is designed to always show half of the next row\nfunction getScrollPaddingEndOffset<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n let offset = 2;\n\n if (tableMeta.footer.isEnabled) {\n offset += 1;\n }\n\n if (table.getHeaderGroups().length > 1) {\n offset += table.getHeaderGroups().length - 1;\n }\n\n let height = ROW_HEIGHT_ESTIMATES.medium * offset;\n\n const bottomRows = table.getBottomRows();\n\n if (bottomRows.length) {\n // 1.4 offsets for half rows and also accounts for increased row heights (which is likely in pinned rows)\n height += ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] * 1.4 * bottomRows.length;\n }\n\n return height;\n}\n\n// scroll padding end is designed to always show half of the next row\nfunction getPaddingEndOffset<TType = unknown>(table: ReactTable<TType>, options?: useTableRenderOptions) {\n const bottomRows = table.getBottomRows() ?? [];\n return ROW_HEIGHT_ESTIMATES.medium * (options?.virtualiserPaddingEndOffset ?? 1) * bottomRows.length;\n}\n\nexport function useTableRenderer<TType = unknown>(\n renderers: useTableRenderers<TType>,\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n defaultRowActiveIndex?: number | undefined,\n options?: useTableRenderOptions\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isTableRowGrouped = !!table.getState().grouping?.length;\n\n const rows = table.getCenterRows() ?? [];\n\n // expanded rows\n const { createRowMeasurer, estimateSize } = useRowHeightVirtualisation<TType>(table);\n\n // row groups\n const rangeExtractor = useRowGroupVirtualisation<TType>(table);\n\n // account for thead and tfoot in the scroll area - both are always medium row height\n const scrollPaddingStart = ROW_HEIGHT_ESTIMATES.medium;\n\n const virtualiser = useVirtualizer({\n count: rows.length,\n estimateSize,\n getScrollElement: () => tableRef.current,\n overscan: tableMeta.printing.isPrinting ? rows.length : undefined,\n rangeExtractor,\n // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list\n scrollPaddingStart,\n scrollPaddingEnd: getScrollPaddingEndOffset(table),\n paddingEnd: getPaddingEndOffset(table, options),\n });\n\n const totalSize = virtualiser.getTotalSize();\n const virtualItems = virtualiser.getVirtualItems();\n\n const scrollToIndex = React.useCallback(\n (index: number, options: ReactVirtualScrollToOptions = { align: 'auto', behavior: 'smooth' }) => {\n const notSmooth: ReactVirtualScrollToOptions = { ...options, behavior: 'auto' };\n\n if (tableRef.current) {\n if (index === 0) {\n virtualiser.scrollToOffset(0, notSmooth);\n } else if (index === rows.length - 1) {\n // sometimes the last row doesn't fully show, so we just force scroll to the bottom\n tableRef.current.scrollTop = tableRef.current.scrollHeight;\n } else {\n virtualiser.scrollToIndex(index, options);\n }\n }\n },\n [virtualItems.length, tableRef.current, totalSize, rows.length]\n );\n\n // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0\n const paddingStartIndex = isTableRowGrouped && rows.length > 1 ? 1 : 0;\n\n const startValue = isTableRowGrouped\n ? virtualItems[paddingStartIndex]?.start - virtualItems[paddingStartIndex]?.size\n : virtualItems[paddingStartIndex]?.start;\n\n // styling for offsetting rows - this \"is\" the virtualisation\n const [paddingTop, paddingBottom] =\n virtualItems.length > 0\n ? [Math.max(0, startValue ?? 0), Math.max(0, totalSize - virtualItems[virtualItems.length - 1]?.end ?? 0)]\n : [0, 0];\n\n // ensure default active rows are scrolled to\n React.useEffect(() => {\n if (defaultRowActiveIndex) {\n scrollToIndex(defaultRowActiveIndex, { align: 'center', behavior: 'auto' });\n }\n }, []);\n\n // rendered output\n let style: CSSProperties = {};\n let content: (JSX.Element | null)[] | null = null;\n\n if (rows.length) {\n style = {\n height: totalSize,\n paddingBottom,\n paddingTop,\n };\n content = virtualItems.map(virtualRow => {\n // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here\n if (!virtualRow) {\n return null;\n }\n const row = rows[virtualRow.index];\n const measureRow = createRowMeasurer(virtualiser.resizeItem, virtualRow);\n return (\n <Row\n key={row.id}\n row={row}\n index={virtualRow.index}\n table={table}\n measureRow={measureRow}\n renderer={renderers.row}\n cellRenderer={renderers.cell}\n />\n );\n });\n }\n\n return {\n rows: content,\n style,\n scrollToIndex,\n };\n}\n\n// support varying row heights - variable row heights, row expansion\nfunction useRowHeightVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n const expandedState = table.getState().expanded;\n\n const [expandedRowHeightsCache, setExpandedRowHeightsCache] = React.useState<Record<number, number>>({});\n\n // look at all registered expanded row heights and use them to form a more accurate average size\n // it might be worth considering if taking the max, or an upper bound, would be better\n const averageExpandedRowHeight = React.useMemo(() => {\n const values: number[] = Object.values(expandedRowHeightsCache);\n return values.length ? values.reduce((a, b) => a + b, 0) / values.length : 0;\n }, [expandedRowHeightsCache]);\n\n // row heights\n const estimateSize = React.useCallback(\n (index: number) => {\n const rowHeight = tableMeta.rowHeight.height\n ? ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height]\n : ROW_HEIGHT_ESTIMATES.medium;\n\n if (expandedState === true || rows[index]?.getIsExpanded?.()) {\n return rowHeight + averageExpandedRowHeight;\n }\n\n return rowHeight;\n },\n [tableMeta.rowHeight.height, averageExpandedRowHeight, expandedState]\n );\n\n const createRowMeasurer = React.useCallback(\n (resizeItem: (item: VirtualItem, size: number) => void, virtualRow: VirtualItem) =>\n (rowHeight: number, expansionHeight?: number) => {\n // register the expansion height so that it can be used to determine an average\n if (expansionHeight) {\n setExpandedRowHeightsCache(cache => ({ ...cache, [virtualRow.index]: expansionHeight }));\n }\n\n // update the whole row's size to include the expanded height\n resizeItem(virtualRow, rowHeight + (expansionHeight ?? 0));\n },\n []\n );\n\n return { estimateSize, createRowMeasurer };\n}\n\n// support virtualised row groups (where the row group headers are sticky)\nfunction useRowGroupVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const rows = table.getRowModel().rows;\n const isTableGrouped = !!table.getState().grouping.length;\n\n const rowGroupIndexes = React.useMemo(() => {\n const indexes: number[] = [];\n\n if (isTableGrouped) {\n rows.forEach((row, index) => {\n if (row.getIsGrouped()) {\n indexes.push(index);\n }\n });\n }\n\n return indexes;\n }, [rows]);\n\n // this is taken from the react-virtual docs/examples\n const rangeExtractor = React.useCallback(\n (range: Range) => {\n const activeRowGroupIndex =\n [...rowGroupIndexes].reverse().find(index => range.startIndex >= index) ?? rowGroupIndexes[0];\n\n const next = new Set([activeRowGroupIndex, ...defaultRangeExtractor(range)]);\n return [...next].sort((a, b) => a - b);\n },\n [rowGroupIndexes]\n );\n\n return isTableGrouped ? rangeExtractor : undefined;\n}\n"],"names":["getScrollPaddingEndOffset","table","tableMeta","options","meta","offset","footer","isEnabled","getHeaderGroups","length","height","ROW_HEIGHT_ESTIMATES","medium","bottomRows","getBottomRows","rowHeight","getPaddingEndOffset","_table$getBottomRows","_options$virtualiserP","virtualiserPaddingEndOffset","useTableRenderer","renderers","tableRef","defaultRowActiveIndex","isTableRowGrouped","_table$getState$group","getState","grouping","rows","_table$getCenterRows","getCenterRows","createRowMeasurer","estimateSize","useRowHeightVirtualisation","rangeExtractor","useRowGroupVirtualisation","scrollPaddingStart","virtualiser","useVirtualizer","count","getScrollElement","current","overscan","printing","isPrinting","undefined","scrollPaddingEnd","paddingEnd","totalSize","getTotalSize","virtualItems","getVirtualItems","scrollToIndex","React","useCallback","index","align","behavior","notSmooth","scrollToOffset","scrollTop","scrollHeight","paddingStartIndex","startValue","_virtualItems$padding","start","_virtualItems$padding2","size","_virtualItems$padding3","paddingTop","paddingBottom","Math","max","_ref","_virtualItems","end","useEffect","style","content","map","virtualRow","row","measureRow","resizeItem","Row","key","id","renderer","cellRenderer","cell","getRowModel","expandedState","expanded","expandedRowHeightsCache","setExpandedRowHeightsCache","useState","averageExpandedRowHeight","useMemo","values","Object","reduce","a","b","_rows$index","_rows$index$getIsExpa","getIsExpanded","call","expansionHeight","cache","isTableGrouped","rowGroupIndexes","indexes","forEach","getIsGrouped","push","range","activeRowGroupIndex","_reverse$find","reverse","find","startIndex","next","Set","defaultRangeExtractor","sort"],"mappings":";;;;;AAcA;AACA,SAASA,yBAAyBA,CAAkBC,KAAwB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,cAAc,GAAG3E,cAAc,GAAGW,SAAS;AACtD;;;;"}
1
+ {"version":3,"file":"useTableRenderer.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableRenderer.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport {\n useVirtualizer,\n defaultRangeExtractor,\n ScrollToOptions as ReactVirtualScrollToOptions,\n VirtualItem,\n Range,\n} from '@tanstack/react-virtual';\nimport { ROW_HEIGHT_ESTIMATES } from '../util/rows';\nimport { Row } from '../components/Row/Row';\nimport { useTableRenderers, useTableRenderOptions } from '../types';\nimport { TableRef } from '../../types';\n\n// scroll padding end is designed to always show half of the next row\nfunction getScrollPaddingEndOffset<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n let offset = 2;\n\n if (tableMeta.footer.isEnabled) {\n offset += 1;\n }\n\n if (table.getHeaderGroups().length > 1) {\n offset += table.getHeaderGroups().length - 1;\n }\n\n let height = ROW_HEIGHT_ESTIMATES.medium * offset;\n\n const bottomRows = table.getBottomRows();\n\n if (bottomRows.length) {\n // 1.4 offsets for half rows and also accounts for increased row heights (which is likely in pinned rows)\n height += ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] * 1.4 * bottomRows.length;\n }\n\n return height;\n}\n\n// scroll padding end is designed to always show half of the next row\nfunction getPaddingEndOffset<TType = unknown>(table: ReactTable<TType>, options?: useTableRenderOptions) {\n const bottomRows = table.getBottomRows() ?? [];\n return ROW_HEIGHT_ESTIMATES.medium * (options?.virtualiserPaddingEndOffset ?? 1) * bottomRows.length;\n}\n\nexport function useTableRenderer<TType = unknown>(\n renderers: useTableRenderers<TType>,\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n defaultRowActiveIndex?: number | undefined,\n options?: useTableRenderOptions\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isTableRowGrouped = !!table.getState().grouping?.length;\n\n const rows = table.getCenterRows() ?? [];\n\n // expanded rows\n const { createRowMeasurer, estimateSize } = useRowHeightVirtualisation<TType>(table);\n\n // row groups\n const rangeExtractor = useRowGroupVirtualisation<TType>(table);\n\n // account for thead and tfoot in the scroll area - both are always medium row height\n const scrollPaddingStart = ROW_HEIGHT_ESTIMATES.medium;\n\n const virtualiser = useVirtualizer({\n count: rows.length,\n estimateSize,\n getScrollElement: () => tableRef.current,\n overscan: tableMeta.printing.isPrinting ? rows.length : undefined,\n rangeExtractor,\n // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list\n scrollPaddingStart,\n scrollPaddingEnd: getScrollPaddingEndOffset(table),\n paddingEnd: getPaddingEndOffset(table, options),\n });\n\n const totalSize = virtualiser.getTotalSize();\n const virtualItems = virtualiser.getVirtualItems();\n\n const scrollToIndex = React.useCallback(\n (index: number, options: ReactVirtualScrollToOptions = { align: 'auto', behavior: 'smooth' }) => {\n const notSmooth: ReactVirtualScrollToOptions = { ...options, behavior: 'auto' };\n\n if (tableRef.current) {\n if (index === 0) {\n virtualiser.scrollToOffset(0, notSmooth);\n } else if (index === rows.length - 1) {\n // sometimes the last row doesn't fully show, so we just force scroll to the bottom\n tableRef.current.scrollTop = tableRef.current.scrollHeight;\n } else {\n virtualiser.scrollToIndex(index, options);\n }\n }\n },\n [virtualItems.length, tableRef.current, totalSize, rows.length]\n );\n\n // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0\n const paddingStartIndex = isTableRowGrouped && rows.length > 1 ? 1 : 0;\n\n const startValue = isTableRowGrouped\n ? virtualItems[paddingStartIndex]?.start - virtualItems[paddingStartIndex]?.size\n : virtualItems[paddingStartIndex]?.start;\n\n // styling for offsetting rows - this \"is\" the virtualisation\n const [paddingTop, paddingBottom] =\n virtualItems.length > 0\n ? [Math.max(0, startValue ?? 0), Math.max(0, totalSize - virtualItems[virtualItems.length - 1]?.end ?? 0)]\n : [0, 0];\n\n // ensure default active rows are scrolled to\n React.useEffect(() => {\n if (defaultRowActiveIndex) {\n scrollToIndex(defaultRowActiveIndex, { align: 'center', behavior: 'auto' });\n }\n }, []);\n\n // rendered output\n let style: CSSProperties = {};\n let content: (JSX.Element | null)[] | null = null;\n\n // bottom rows aren't virtualised (they're sticky) but we need to set the height\n if (rows.length || table.getBottomRows().length) {\n style = {\n height: totalSize,\n paddingBottom,\n paddingTop,\n };\n }\n\n // only render non sticky rows\n if (rows.length) {\n content = virtualItems.map(virtualRow => {\n // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here\n if (!virtualRow) {\n return null;\n }\n const row = rows[virtualRow.index];\n const measureRow = createRowMeasurer(virtualiser.resizeItem, virtualRow);\n return (\n <Row\n key={row.id}\n row={row}\n index={virtualRow.index}\n table={table}\n measureRow={measureRow}\n renderer={renderers.row}\n cellRenderer={renderers.cell}\n />\n );\n });\n }\n\n return {\n rows: content,\n style,\n scrollToIndex,\n };\n}\n\n// support varying row heights - variable row heights, row expansion\nfunction useRowHeightVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n const expandedState = table.getState().expanded;\n\n const [expandedRowHeightsCache, setExpandedRowHeightsCache] = React.useState<Record<number, number>>({});\n\n // look at all registered expanded row heights and use them to form a more accurate average size\n // it might be worth considering if taking the max, or an upper bound, would be better\n const averageExpandedRowHeight = React.useMemo(() => {\n const values: number[] = Object.values(expandedRowHeightsCache);\n return values.length ? values.reduce((a, b) => a + b, 0) / values.length : 0;\n }, [expandedRowHeightsCache]);\n\n // row heights\n const estimateSize = React.useCallback(\n (index: number) => {\n const rowHeight = tableMeta.rowHeight.height\n ? ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height]\n : ROW_HEIGHT_ESTIMATES.medium;\n\n if (expandedState === true || rows[index]?.getIsExpanded?.()) {\n return rowHeight + averageExpandedRowHeight;\n }\n\n return rowHeight;\n },\n [tableMeta.rowHeight.height, averageExpandedRowHeight, expandedState]\n );\n\n const createRowMeasurer = React.useCallback(\n (resizeItem: (item: VirtualItem, size: number) => void, virtualRow: VirtualItem) =>\n (rowHeight: number, expansionHeight?: number) => {\n // register the expansion height so that it can be used to determine an average\n if (expansionHeight) {\n setExpandedRowHeightsCache(cache => ({ ...cache, [virtualRow.index]: expansionHeight }));\n }\n\n // update the whole row's size to include the expanded height\n resizeItem(virtualRow, rowHeight + (expansionHeight ?? 0));\n },\n []\n );\n\n return { estimateSize, createRowMeasurer };\n}\n\n// support virtualised row groups (where the row group headers are sticky)\nfunction useRowGroupVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const rows = table.getRowModel().rows;\n const isTableGrouped = !!table.getState().grouping.length;\n\n const rowGroupIndexes = React.useMemo(() => {\n const indexes: number[] = [];\n\n if (isTableGrouped) {\n rows.forEach((row, index) => {\n if (row.getIsGrouped()) {\n indexes.push(index);\n }\n });\n }\n\n return indexes;\n }, [rows]);\n\n // this is taken from the react-virtual docs/examples\n const rangeExtractor = React.useCallback(\n (range: Range) => {\n const activeRowGroupIndex =\n [...rowGroupIndexes].reverse().find(index => range.startIndex >= index) ?? rowGroupIndexes[0];\n\n const next = new Set([activeRowGroupIndex, ...defaultRangeExtractor(range)]);\n return [...next].sort((a, b) => a - b);\n },\n [rowGroupIndexes]\n );\n\n return isTableGrouped ? rangeExtractor : undefined;\n}\n"],"names":["getScrollPaddingEndOffset","table","tableMeta","options","meta","offset","footer","isEnabled","getHeaderGroups","length","height","ROW_HEIGHT_ESTIMATES","medium","bottomRows","getBottomRows","rowHeight","getPaddingEndOffset","_table$getBottomRows","_options$virtualiserP","virtualiserPaddingEndOffset","useTableRenderer","renderers","tableRef","defaultRowActiveIndex","isTableRowGrouped","_table$getState$group","getState","grouping","rows","_table$getCenterRows","getCenterRows","createRowMeasurer","estimateSize","useRowHeightVirtualisation","rangeExtractor","useRowGroupVirtualisation","scrollPaddingStart","virtualiser","useVirtualizer","count","getScrollElement","current","overscan","printing","isPrinting","undefined","scrollPaddingEnd","paddingEnd","totalSize","getTotalSize","virtualItems","getVirtualItems","scrollToIndex","React","useCallback","index","align","behavior","notSmooth","scrollToOffset","scrollTop","scrollHeight","paddingStartIndex","startValue","_virtualItems$padding","start","_virtualItems$padding2","size","_virtualItems$padding3","paddingTop","paddingBottom","Math","max","_ref","_virtualItems","end","useEffect","style","content","map","virtualRow","row","measureRow","resizeItem","Row","key","id","renderer","cellRenderer","cell","getRowModel","expandedState","expanded","expandedRowHeightsCache","setExpandedRowHeightsCache","useState","averageExpandedRowHeight","useMemo","values","Object","reduce","a","b","_rows$index","_rows$index$getIsExpa","getIsExpanded","call","expansionHeight","cache","isTableGrouped","rowGroupIndexes","indexes","forEach","getIsGrouped","push","range","activeRowGroupIndex","_reverse$find","reverse","find","startIndex","next","Set","defaultRangeExtractor","sort"],"mappings":";;;;;AAcA;AACA,SAASA,yBAAyBA,CAAkBC,KAAwB;EACxE,MAAMC,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAA6B;EAC7D,IAAIC,MAAM,GAAG,CAAC;EAEd,IAAIH,SAAS,CAACI,MAAM,CAACC,SAAS,EAAE;IAC5BF,MAAM,IAAI,CAAC;;EAGf,IAAIJ,KAAK,CAACO,eAAe,EAAE,CAACC,MAAM,GAAG,CAAC,EAAE;IACpCJ,MAAM,IAAIJ,KAAK,CAACO,eAAe,EAAE,CAACC,MAAM,GAAG,CAAC;;EAGhD,IAAIC,MAAM,GAAGC,oBAAoB,CAACC,MAAM,GAAGP,MAAM;EAEjD,MAAMQ,UAAU,GAAGZ,KAAK,CAACa,aAAa,EAAE;EAExC,IAAID,UAAU,CAACJ,MAAM,EAAE;;IAEnBC,MAAM,IAAIC,oBAAoB,CAACT,SAAS,CAACa,SAAS,CAACL,MAAM,CAAC,GAAG,GAAG,GAAGG,UAAU,CAACJ,MAAM;;EAGxF,OAAOC,MAAM;AACjB;AAEA;AACA,SAASM,mBAAmBA,CAAkBf,KAAwB,EAAEE,OAA+B;;EACnG,MA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ACG,IAAI,CAAC3D,KAAK,CAAC;;OAE1B,CAAC;;IAGN,OAAOwD,OAAO;GACjB,EAAE,CAACnF,IAAI,CAAC,CAAC;;EAGV,MAAMM,cAAc,GAAGmB,cAAK,CAACC,WAAW,CACnC6D,KAAY;;IACT,MAAMC,mBAAmB,IAAAC,aAAA,GACrB,CAAC,GAAGP,eAAe,CAAC,CAACQ,OAAO,EAAE,CAACC,IAAI,CAAChE,KAAK,IAAI4D,KAAK,CAACK,UAAU,IAAIjE,KAAK,CAAC,cAAA8D,aAAA,cAAAA,aAAA,GAAIP,eAAe,CAAC,CAAC,CAAC;IAEjG,MAAMW,IAAI,GAAG,IAAIC,GAAG,CAAC,CAACN,mBAAmB,EAAE,GAAGO,qBAAqB,CAACR,KAAK,CAAC,CAAC,CAAC;IAC5E,OAAO,CAAC,GAAGM,IAAI,CAAC,CAACG,IAAI,CAAC,CAACvB,CAAC,EAAEC,CAAC,KAAKD,CAAC,GAAGC,CAAC,CAAC;GACzC,EACD,CAACQ,eAAe,CAAC,CACpB;EAED,OAAOD,cAAc,GAAG3E,cAAc,GAAGW,SAAS;AACtD;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useTableManager.js","sources":["../../../../../../../../src/primitives/Table/useTableManager/useTableManager.ts"],"sourcesContent":["import { useReactTable, TableMeta as ReactTableMeta, RowData, getCoreRowModel } from '@tanstack/react-table';\nimport {\n TableColumnAlignment,\n TableColumnClassNameHandler,\n TableColumnDataType,\n TableColumnMenu,\n TableColumnRenderer,\n TableColumnRendererControl,\n TableFilterComparator,\n TableProps,\n} from '../types';\nimport { useReactTableInitialState, configureReactTableOptions, mapTableChildrenToColumns } from './util/setup';\nimport { getTableFeaturePreset } from './util/presets';\nimport { useTableColumnFreezing } from './features/useTableColumnFreezing';\nimport { useTableColumnOrdering } from './features/useTableColumnOrdering';\nimport { useTableFooter } from './features/useTableFooter';\nimport { useTableFontSize } from './features/useTableFontSize';\nimport { useTablePrinting } from './features/useTablePrinting';\nimport { useTableRowActions } from './features/useTableRowActions';\nimport { useTableRowActive } from './features/useTableRowActive';\nimport { useTableRowClick } from './features/useTableRowClick';\nimport { useTableRowExpansion } from './features/useTableRowExpansion';\nimport { useTableRowGoto } from './features/useTableRowGoto';\nimport { useTableRowGroups } from './features/useTableRowGroups';\nimport { useTableRowHeight } from './features/useTableRowHeight';\nimport { useTableRowSelection } from './features/useTableRowSelection';\nimport { useTableSearch } from './features/useTableSearch';\nimport { useTableServerLoading } from './features/useTableServerLoading';\nimport { useTableSettings } from './features/useTableSettings';\nimport { useTableDataListener } from './listeners/useTableDataListener';\nimport { useTableFilterListener } from './listeners/useTableFilterListener';\nimport { useTableFontSizeListener } from './listeners/useTableFontSizeListener';\nimport { useTableRowHeightListener } from './listeners/useTableRowHeightListener';\nimport { useTableRowSelectionListener } from './listeners/useTableRowSelectionListener';\nimport { useTableSearchListener } from './listeners/useTableSearchListener';\nimport { useTableSettingsListener } from './listeners/useTableSettingsListener';\nimport { useTableShortcutsListener } from './listeners/useTableShortcutsListener';\nimport { useTableSortingListener } from './listeners/useTableSortingListener';\nimport { useTableServerLoadingListener } from './listeners/useTableServerLoadingListener';\nimport { useTableManagerInternalColumns } from './types';\nimport { useTableRowDrag } from './features/useTableRowDrag';\nimport { useTableRowDrop } from './features/useTableRowDrop';\nimport { useLocalization } from '../../../components/Provider/Localization';\n\n/*\n EDITING THIS FILE? READ ME FIRST!\n\n This is a shared, common hook for multiple tables. It's feature set is specifically chosen to support features\n common across those tables. If you are adding a new feature or changing an existing one, before writing any code\n in this file ask yourself the question - is this specific to a given table, or is it common to all of them.\n If you are unsure, ask your team first.\n*/\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useTableColumnFreezing>;\n columnOrdering: ReturnType<typeof useTableColumnOrdering>;\n fontSize: ReturnType<typeof useTableFontSize>;\n footer: ReturnType<typeof useTableFooter>;\n length: number;\n printing: ReturnType<typeof useTablePrinting>;\n rowActions: ReturnType<typeof useTableRowActions>;\n rowActive: ReturnType<typeof useTableRowActive>;\n rowClick: ReturnType<typeof useTableRowClick>;\n rowDrag: ReturnType<typeof useTableRowDrag>;\n rowDrop: ReturnType<typeof useTableRowDrop>;\n rowExpansion: ReturnType<typeof useTableRowExpansion>;\n rowGoto: ReturnType<typeof useTableRowGoto>;\n rowGroups: ReturnType<typeof useTableRowGroups>;\n rowHeight: ReturnType<typeof useTableRowHeight>;\n rowIdentityAccessor: keyof TData;\n rowSelection: ReturnType<typeof useTableRowSelection>;\n search: ReturnType<typeof useTableSearch>;\n server: ReturnType<typeof useTableServerLoading>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TData>;\n control?: TableColumnRendererControl<TData>;\n dataType?: TableColumnDataType;\n defaultWidth?: number;\n enableEditing?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableSearch?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n header: string;\n headerClassName?: string;\n menu?: TableColumnMenu;\n renderer?: TableColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n}\n\n// Placed this array outside the hook to avoid creating a new array reference on each hook re-render\nconst DEFAULT_EMPTY_ARRAY: any[] = [];\n\nexport function useTableManager<TType = unknown, TMeta = {}>(\n props: TableProps<TType>,\n meta?: Partial<ReactTableMeta<TType>> & TMeta,\n internalColumns?: useTableManagerInternalColumns<TType>\n) {\n const localization = useLocalization();\n // CSS.escape would be best here, but it doesn't seem to work very well\n const safeId = props.id.replace('.', '_');\n // configure table options, merging props with presets\n const options = getTableFeaturePreset(props);\n\n // load any persisted table settings and merge them with any defaults\n const [settings, setSettings] = useTableSettings(\n options.enableSaveSettings,\n safeId,\n props.defaultSettings,\n props.onChangeSettings\n );\n\n // ensure data is always valid\n const data = props.data ?? DEFAULT_EMPTY_ARRAY;\n const length = props.length ?? data.length;\n\n // configure common custom features\n const columnFreezing = useTableColumnFreezing(options.enableColumnFreezing);\n const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);\n const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);\n const footer = useTableFooter(options.enableFooter);\n const printing = useTablePrinting(options.enablePrinting, safeId);\n const rowActive = useTableRowActive(options.enableRowActive, props.defaultRowActiveIndex);\n const rowActions = useTableRowActions<TType>(options.enableRowActions, props.rowActions, props.rowActionsLength);\n const rowClick = useTableRowClick<TType>(options.enableRowClick, props.onRowClick);\n const rowDrag = useTableRowDrag<TType>(options.enableRowDrag && !meta?.editing?.isEditing, props.onRowDrag);\n const rowDrop = useTableRowDrop<TType>(options.enableRowDrop, props.onRowDrop);\n const rowExpansion = useTableRowExpansion<TType>(options.enableRowExpansion, props.rowExpansionRenderer);\n const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowGroups = useTableRowGroups(props.rowActionsForGroup);\n const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);\n const rowSelection = useTableRowSelection(!!options.enableRowSelection);\n const search = useTableSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);\n const server = useTableServerLoading(props.loadPage, props.loadAll, props.pageSize);\n\n // TODO: memoise\n // convert jsx column components into valid table columns\n const { columns, ...defaultState } = mapTableChildrenToColumns<TType>(\n props,\n settings,\n options,\n internalColumns,\n localization\n );\n\n // configure initial table state\n const initialState = useReactTableInitialState<TType>(props, columns, settings, defaultState);\n\n // create a react-table instance\n const instance = useReactTable<TType>({\n data,\n columns,\n // configure initial table state\n initialState,\n getCoreRowModel: getCoreRowModel<TType>(),\n // configure react-table built-in features\n ...configureReactTableOptions<TType>(options, props, localization),\n // settings that can be toggled by the user, and therefore require our own state\n enableGlobalFilter: search.enableGlobalFilter,\n // custom context\n meta: {\n // spread features from specific implementations\n ...meta,\n columnFreezing,\n columnOrdering,\n fontSize,\n footer,\n length,\n printing,\n rowActions: rowActions as any, // no other way around ReturnType<typeof X> not supporting generics\n rowActive,\n rowClick: rowClick as any, // no other way around ReturnType<typeof X> not supporting generics\n rowDrag,\n rowDrop: rowDrop as any, // no other way around ReturnType<typeof X> not supporting generics\n rowExpansion: rowExpansion as any, // no other way around ReturnType<typeof X> not supporting generics\n rowIdentityAccessor: props.rowIdentityAccessor,\n rowGoto,\n rowGroups: rowGroups as any, // no other way around ReturnType<typeof X> not supporting generics\n rowHeight,\n rowSelection,\n search,\n server,\n } as ReactTableMeta<TType> & TMeta,\n });\n\n // state listeners - we have these so that we don't have to control state outside the table\n useTableDataListener(instance);\n useTableFilterListener(instance, props.onChangeFilter);\n useTableFontSizeListener(instance);\n useTableRowHeightListener(instance);\n useTableRowSelectionListener(instance, props.onRowSelect);\n useTableSearchListener(instance, props.onChangeSearch);\n useTableServerLoadingListener(instance, server.loadPage);\n useTableSettingsListener(instance, setSettings);\n useTableShortcutsListener(instance, props.shortcuts);\n useTableSortingListener(instance, props.onChangeSort);\n\n return {\n id: safeId,\n instance,\n meta: (instance.options.meta ?? {}) as ReactTableMeta<TType> & TMeta,\n state: instance.getState(),\n };\n}\n"],"names":["DEFAULT_EMPTY_ARRAY","useTableManager","props","meta","internalColumns","localization","useLocalization","safeId","id","replace","options","getTableFeaturePreset","settings","setSettings","useTableSettings","enableSaveSettings","defaultSettings","onChangeSettings","data","_props$data","length","_props$length","columnFreezing","useTableColumnFreezing","enableColumnFreezing","columnOrdering","useTableColumnOrdering","enableColumnOrdering","fontSize","useTableFontSize","enableFontSize","footer","useTableFooter","enableFooter","printing","useTablePrinting","enablePrinting","rowActive","useTableRowActive","enableRowActive","defaultRowActiveIndex","rowActions","useTableRowActions","enableRowActions","rowActionsLength","rowClick","useTableRowClick","enableRowClick","onRowClick","rowDrag","useTableRowDrag","enableRowDrag","_meta$editing","editing","isEditing","onRowDrag","rowDrop","useTableRowDrop","enableRowDrop","onRowDrop","rowExpansion","useTableRowExpansion","enableRowExpansion","rowExpansionRenderer","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowGroups","useTableRowGroups","rowActionsForGroup","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","search","useTableSearch","enableSearch","excludeUnmatchedRecordsInSearch","server","useTableServerLoading","loadPage","loadAll","pageSize","columns","defaultState","mapTableChildrenToColumns","initialState","useReactTableInitialState","instance","useReactTable","getCoreRowModel","configureReactTableOptions","enableGlobalFilter","rowIdentityAccessor","useTableDataListener","useTableFilterListener","onChangeFilter","useTableFontSizeListener","useTableRowHeightListener","useTableRowSelectionListener","onRowSelect","useTableSearchListener","onChangeSearch","useTableServerLoadingListener","useTableSettingsListener","useTableShortcutsListener","shortcuts","useTableSortingListener","onChangeSort","_instance$options$met","state","getState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGA;AACA,MAAMA,mBAAmB,GAAU,EAAE;SAErBC,eAAeA,CAC3BC,KAAwB,EACxBC,IAA6C,EAC7CC,eAAuD;;EAEvD,MAAMC,YAAY,GAAGC,eAAe,EAAE;;EAEtC,MAAMC,MAAM,GAAGL,KAAK,CAACM,EAAE,CAACC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;;EAEzC,MAAMC,OAAO,GAAGC,qBAAqB,CAACT,KAAK,CAAC;;EAG5C,MAAM,CAACU,QAAQ,EAAEC,WAAW,CAAC,GAAGC,gBAAgB,CAC5CJ,OAAO,CAACK,kBAAkB,EAC1BR,MAAM,EACNL,KAAK,CAACc,eAAe,EACrBd,KAAK,CAACe,gBAAgB,CACzB;;EAGD,MAAMC,IAAI,IAAAC,WAAA,GAAGjB,KAAK,CAACgB,IAAI,cAAAC,WAAA,cAAAA,WAAA,GAAInB,mBAAmB;EAC9C,MAAMoB,MAAM,IAAAC,aAAA,GAAGnB,KAAK,CAACkB,MAAM,cAAAC,aAAA,cAAAA,aAAA,GAAIH,IAAI,CAACE,MAAM;;EAG1C,MAAME,cAAc,GAAGC,sBAAsB,CAACb,OAAO,CAACc,oBAAoB,CAAC;EAC3E,MAAMC,cAAc,GAAGC,sBAAsB,CA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B,oBAAoB,CAACN,QAAQ,CAAC;EAC9BO,sBAAsB,CAACP,QAAQ,EAAEzF,KAAK,CAACiG,cAAc,CAAC;EACtDC,wBAAwB,CAACT,QAAQ,CAAC;EAClCU,yBAAyB,CAACV,QAAQ,CAAC;EACnCW,4BAA4B,CAACX,QAAQ,EAAEzF,KAAK,CAACqG,WAAW,CAAC;EACzDC,sBAAsB,CAACb,QAAQ,EAAEzF,KAAK,CAACuG,cAAc,CAAC;EACtDC,6BAA6B,CAACf,QAAQ,EAAEV,MAAM,CAACE,QAAQ,CAAC;EACxDwB,wBAAwB,CAAChB,QAAQ,EAAE9E,WAAW,CAAC;EAC/C+F,yBAAyB,CAACjB,QAAQ,EAAEzF,KAAK,CAAC2G,SAAS,CAAC;EACpDC,uBAAuB,CAACnB,QAAQ,EAAEzF,KAAK,CAAC6G,YAAY,CAAC;EAErD,OAAO;IACHvG,EAAE,EAAED,MAAM;IACVoF,QAAQ;IACRxF,IAAI,GAAA6G,qBAAA,GAAGrB,QAAQ,CAACjF,OAAO,CAACP,IAAI,cAAA6G,qBAAA,cAAAA,qBAAA,GAAI,EAAoC;IACpEC,KAAK,EAAEtB,QAAQ,CAACuB,QAAQ;GAC3B;AACL;;;;"}
1
+ {"version":3,"file":"useTableManager.js","sources":["../../../../../../../../src/primitives/Table/useTableManager/useTableManager.ts"],"sourcesContent":["import { useReactTable, TableMeta as ReactTableMeta, RowData, getCoreRowModel } from '@tanstack/react-table';\nimport {\n TableColumnAlignment,\n TableColumnClassNameHandler,\n TableColumnDataType,\n TableColumnMenu,\n TableColumnRenderer,\n TableColumnRendererControl,\n TableFilterComparator,\n TableProps,\n} from '../types';\nimport { useReactTableInitialState, configureReactTableOptions, mapTableChildrenToColumns } from './util/setup';\nimport { getTableFeaturePreset } from './util/presets';\nimport { useTableColumnFreezing } from './features/useTableColumnFreezing';\nimport { useTableColumnOrdering } from './features/useTableColumnOrdering';\nimport { useTableFooter } from './features/useTableFooter';\nimport { useTableFontSize } from './features/useTableFontSize';\nimport { useTablePrinting } from './features/useTablePrinting';\nimport { useTableRowActions } from './features/useTableRowActions';\nimport { useTableRowActive } from './features/useTableRowActive';\nimport { useTableRowClick } from './features/useTableRowClick';\nimport { useTableRowExpansion } from './features/useTableRowExpansion';\nimport { useTableRowGoto } from './features/useTableRowGoto';\nimport { useTableRowGroups } from './features/useTableRowGroups';\nimport { useTableRowHeight } from './features/useTableRowHeight';\nimport { useTableRowSelection } from './features/useTableRowSelection';\nimport { useTableSearch } from './features/useTableSearch';\nimport { useTableServerLoading } from './features/useTableServerLoading';\nimport { useTableSettings } from './features/useTableSettings';\nimport { useTableDataListener } from './listeners/useTableDataListener';\nimport { useTableFilterListener } from './listeners/useTableFilterListener';\nimport { useTableFontSizeListener } from './listeners/useTableFontSizeListener';\nimport { useTableRowHeightListener } from './listeners/useTableRowHeightListener';\nimport { useTableRowSelectionListener } from './listeners/useTableRowSelectionListener';\nimport { useTableSearchListener } from './listeners/useTableSearchListener';\nimport { useTableSettingsListener } from './listeners/useTableSettingsListener';\nimport { useTableShortcutsListener } from './listeners/useTableShortcutsListener';\nimport { useTableSortingListener } from './listeners/useTableSortingListener';\nimport { useTableServerLoadingListener } from './listeners/useTableServerLoadingListener';\nimport { useTableManagerInternalColumns } from './types';\nimport { useTableRowDrag } from './features/useTableRowDrag';\nimport { useTableRowDrop } from './features/useTableRowDrop';\nimport { useLocalization } from '../../../components/Provider/Localization';\n\n/*\n EDITING THIS FILE? READ ME FIRST!\n\n This is a shared, common hook for multiple tables. It's feature set is specifically chosen to support features\n common across those tables. If you are adding a new feature or changing an existing one, before writing any code\n in this file ask yourself the question - is this specific to a given table, or is it common to all of them.\n If you are unsure, ask your team first.\n*/\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useTableColumnFreezing>;\n columnOrdering: ReturnType<typeof useTableColumnOrdering>;\n fontSize: ReturnType<typeof useTableFontSize>;\n footer: ReturnType<typeof useTableFooter>;\n length: number;\n printing: ReturnType<typeof useTablePrinting>;\n rowActions: ReturnType<typeof useTableRowActions>;\n rowActive: ReturnType<typeof useTableRowActive>;\n rowClick: ReturnType<typeof useTableRowClick>;\n rowDrag: ReturnType<typeof useTableRowDrag>;\n rowDrop: ReturnType<typeof useTableRowDrop>;\n rowExpansion: ReturnType<typeof useTableRowExpansion>;\n rowGoto: ReturnType<typeof useTableRowGoto>;\n rowGroups: ReturnType<typeof useTableRowGroups>;\n rowHeight: ReturnType<typeof useTableRowHeight>;\n rowIdentityAccessor: keyof TData;\n rowSelection: ReturnType<typeof useTableRowSelection>;\n search: ReturnType<typeof useTableSearch>;\n server: ReturnType<typeof useTableServerLoading>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TData>;\n control?: TableColumnRendererControl<TData>;\n dataType?: TableColumnDataType;\n defaultWidth?: number;\n enableEditing?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableSearch?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n header: string;\n headerClassName?: string;\n menu?: TableColumnMenu;\n renderer?: TableColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n}\n\n// Placed this array outside the hook to avoid creating a new array reference on each hook re-render\nconst DEFAULT_EMPTY_ARRAY = [];\n\nexport function useTableManager<TType = unknown, TMeta = {}>(\n props: TableProps<TType>,\n meta?: Partial<ReactTableMeta<TType>> & TMeta,\n internalColumns?: useTableManagerInternalColumns<TType>\n) {\n const localization = useLocalization();\n // CSS.escape would be best here, but it doesn't seem to work very well\n const safeId = props.id.replace('.', '_');\n // configure table options, merging props with presets\n const options = getTableFeaturePreset(props);\n\n // load any persisted table settings and merge them with any defaults\n const [settings, setSettings] = useTableSettings(\n options.enableSaveSettings,\n safeId,\n props.defaultSettings,\n props.onChangeSettings\n );\n\n // ensure data is always valid\n const data = props.data ?? DEFAULT_EMPTY_ARRAY;\n const length = props.length ?? data.length;\n\n // configure common custom features\n const columnFreezing = useTableColumnFreezing(options.enableColumnFreezing);\n const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);\n const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);\n const footer = useTableFooter(options.enableFooter);\n const printing = useTablePrinting(options.enablePrinting, safeId);\n const rowActive = useTableRowActive(options.enableRowActive, props.defaultRowActiveIndex);\n const rowActions = useTableRowActions<TType>(options.enableRowActions, props.rowActions, props.rowActionsLength);\n const rowClick = useTableRowClick<TType>(options.enableRowClick, props.onRowClick);\n const rowDrag = useTableRowDrag<TType>(options.enableRowDrag && !meta?.editing?.isEditing, props.onRowDrag);\n const rowDrop = useTableRowDrop<TType>(options.enableRowDrop, props.onRowDrop);\n const rowExpansion = useTableRowExpansion<TType>(options.enableRowExpansion, props.rowExpansionRenderer);\n const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowGroups = useTableRowGroups(props.rowActionsForGroup);\n const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);\n const rowSelection = useTableRowSelection(!!options.enableRowSelection);\n const search = useTableSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);\n const server = useTableServerLoading(props.loadPage, props.loadAll, props.pageSize);\n\n // TODO: memoise\n // convert jsx column components into valid table columns\n const { columns, ...defaultState } = mapTableChildrenToColumns<TType>(\n props,\n settings,\n options,\n internalColumns,\n localization\n );\n\n // configure initial table state\n const initialState = useReactTableInitialState<TType>(props, columns, settings, defaultState);\n\n // create a react-table instance\n const instance = useReactTable<TType>({\n data,\n columns,\n // configure initial table state\n initialState,\n getCoreRowModel: getCoreRowModel<TType>(),\n // configure react-table built-in features\n ...configureReactTableOptions<TType>(options, props, localization),\n // settings that can be toggled by the user, and therefore require our own state\n enableGlobalFilter: search.enableGlobalFilter,\n // custom context\n meta: {\n // spread features from specific implementations\n ...meta,\n columnFreezing,\n columnOrdering,\n fontSize,\n footer,\n length,\n printing,\n rowActions: rowActions as any, // no other way around ReturnType<typeof X> not supporting generics\n rowActive,\n rowClick: rowClick as any, // no other way around ReturnType<typeof X> not supporting generics\n rowDrag,\n rowDrop: rowDrop as any, // no other way around ReturnType<typeof X> not supporting generics\n rowExpansion: rowExpansion as any, // no other way around ReturnType<typeof X> not supporting generics\n rowIdentityAccessor: props.rowIdentityAccessor,\n rowGoto,\n rowGroups: rowGroups as any, // no other way around ReturnType<typeof X> not supporting generics\n rowHeight,\n rowSelection,\n search,\n server,\n } as ReactTableMeta<TType> & TMeta,\n });\n\n // state listeners - we have these so that we don't have to control state outside the table\n useTableDataListener(instance);\n useTableFilterListener(instance, props.onChangeFilter);\n useTableFontSizeListener(instance);\n useTableRowHeightListener(instance);\n useTableRowSelectionListener(instance, props.onRowSelect);\n useTableSearchListener(instance, props.onChangeSearch);\n useTableServerLoadingListener(instance, server.loadPage);\n useTableSettingsListener(instance, setSettings);\n useTableShortcutsListener(instance, props.shortcuts);\n useTableSortingListener(instance, props.onChangeSort);\n\n return {\n id: safeId,\n instance,\n meta: (instance.options.meta ?? {}) as ReactTableMeta<TType> & TMeta,\n state: instance.getState(),\n };\n}\n"],"names":["DEFAULT_EMPTY_ARRAY","useTableManager","props","meta","internalColumns","localization","useLocalization","safeId","id","replace","options","getTableFeaturePreset","settings","setSettings","useTableSettings","enableSaveSettings","defaultSettings","onChangeSettings","data","_props$data","length","_props$length","columnFreezing","useTableColumnFreezing","enableColumnFreezing","columnOrdering","useTableColumnOrdering","enableColumnOrdering","fontSize","useTableFontSize","enableFontSize","footer","useTableFooter","enableFooter","printing","useTablePrinting","enablePrinting","rowActive","useTableRowActive","enableRowActive","defaultRowActiveIndex","rowActions","useTableRowActions","enableRowActions","rowActionsLength","rowClick","useTableRowClick","enableRowClick","onRowClick","rowDrag","useTableRowDrag","enableRowDrag","_meta$editing","editing","isEditing","onRowDrag","rowDrop","useTableRowDrop","enableRowDrop","onRowDrop","rowExpansion","useTableRowExpansion","enableRowExpansion","rowExpansionRenderer","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowGroups","useTableRowGroups","rowActionsForGroup","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","search","useTableSearch","enableSearch","excludeUnmatchedRecordsInSearch","server","useTableServerLoading","loadPage","loadAll","pageSize","columns","defaultState","mapTableChildrenToColumns","initialState","useReactTableInitialState","instance","useReactTable","getCoreRowModel","configureReactTableOptions","enableGlobalFilter","rowIdentityAccessor","useTableDataListener","useTableFilterListener","onChangeFilter","useTableFontSizeListener","useTableRowHeightListener","useTableRowSelectionListener","onRowSelect","useTableSearchListener","onChangeSearch","useTableServerLoadingListener","useTableSettingsListener","useTableShortcutsListener","shortcuts","useTableSortingListener","onChangeSort","_instance$options$met","state","getState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGA;AACA,MAAMA,mBAAmB,GAAG,EAAE;SAEdC,eAAeA,CAC3BC,KAAwB,EACxBC,IAA6C,EAC7CC,eAAuD;;EAEvD,MAAMC,YAAY,GAAGC,eAAe,EAAE;;EAEtC,MAAMC,MAAM,GAAGL,KAAK,CAACM,EAAE,CAACC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;;EAEzC,MAAMC,OAAO,GAAGC,qBAAqB,CAACT,KAAK,CAAC;;EAG5C,MAAM,CAACU,QAAQ,EAAEC,WAAW,CAAC,GAAGC,gBAAgB,CAC5CJ,OAAO,CAACK,kBAAkB,EAC1BR,MAAM,EACNL,KAAK,CAACc,eAAe,EACrBd,KAAK,CAACe,gBAAgB,CACzB;;EAGD,MAAMC,IAAI,IAAAC,WAAA,GAAGjB,KAAK,CAACgB,IAAI,cAAAC,WAAA,cAAAA,WAAA,GAAInB,mBAAmB;EAC9C,MAAMoB,MAAM,IAAAC,aAAA,GAAGnB,KAAK,CAACkB,MAAM,cAAAC,aAAA,cAAAA,aAAA,GAAIH,IAAI,CAACE,MAAM;;EAG1C,MAAME,cAAc,GAAGC,sBAAsB,CAACb,OAAO,CAACc,oBAAoB,CAAC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;MACZG,MAAM;MACNI;;GAEP,CAAC;;EAGFgB,oBAAoB,CAACN,QAAQ,CAAC;EAC9BO,sBAAsB,CAACP,QAAQ,EAAEzF,KAAK,CAACiG,cAAc,CAAC;EACtDC,wBAAwB,CAACT,QAAQ,CAAC;EAClCU,yBAAyB,CAACV,QAAQ,CAAC;EACnCW,4BAA4B,CAACX,QAAQ,EAAEzF,KAAK,CAACqG,WAAW,CAAC;EACzDC,sBAAsB,CAACb,QAAQ,EAAEzF,KAAK,CAACuG,cAAc,CAAC;EACtDC,6BAA6B,CAACf,QAAQ,EAAEV,MAAM,CAACE,QAAQ,CAAC;EACxDwB,wBAAwB,CAAChB,QAAQ,EAAE9E,WAAW,CAAC;EAC/C+F,yBAAyB,CAACjB,QAAQ,EAAEzF,KAAK,CAAC2G,SAAS,CAAC;EACpDC,uBAAuB,CAACnB,QAAQ,EAAEzF,KAAK,CAAC6G,YAAY,CAAC;EAErD,OAAO;IACHvG,EAAE,EAAED,MAAM;IACVoF,QAAQ;IACRxF,IAAI,GAAA6G,qBAAA,GAAGrB,QAAQ,CAACjF,OAAO,CAACP,IAAI,cAAA6G,qBAAA,cAAAA,qBAAA,GAAI,EAAoC;IACpEC,KAAK,EAAEtB,QAAQ,CAACuB,QAAQ;GAC3B;AACL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"search.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/search.ts"],"sourcesContent":["import { Table as ReactTable, TableMeta as ReactTableMeta, Row as ReactTableRow } from '@tanstack/react-table';\nimport get from 'lodash/get';\nimport { isWeakContains } from './filtering';\nimport { getDataTypeProperties } from './dataTypes';\nimport { TableColumnDataType } from '../../types';\nimport { Localization } from '../../../../components/Provider/Localization';\n\nconst flattenCellValue = (cellValue: object | string) => {\n return typeof cellValue === 'object' ? Object.values(cellValue).map(flattenCellValue) : cellValue;\n};\n\nexport function isMatched<TType = unknown>(\n searchQuery: string,\n cellValue: any,\n dataType: TableColumnDataType | undefined,\n localization: Localization\n) {\n if (typeof cellValue === 'object') {\n return flattenCellValue(cellValue)\n .flat(Infinity)\n .find(y => isWeakContains(y, searchQuery));\n } else {\n const cellValueAsString = String(cellValue ?? '');\n\n if (cellValueAsString !== undefined && isWeakContains(cellValueAsString, searchQuery)) {\n return true;\n } else {\n const dataTypeProperties = getDataTypeProperties<TType>(dataType);\n\n if (dataTypeProperties.getDisplayValue) {\n const cellDisplayValue = dataTypeProperties.getDisplayValue(cellValue, { localization });\n\n if (cellDisplayValue !== undefined && isWeakContains(cellDisplayValue, searchQuery)) {\n return true;\n }\n }\n }\n }\n\n return false;\n}\n\nexport function globalFilterFn<TType = unknown>(\n row: ReactTableRow<TType>,\n columnId: string,\n searchQuery: string,\n localization: Localization\n) {\n try {\n if (row.original) {\n const cellValue = (row.original as any)[columnId];\n const dataType = row._getAllCellsByColumnId()[columnId]?.column.columnDef.meta?.dataType;\n return isMatched(searchQuery, cellValue, dataType, localization);\n }\n } catch {\n // we don't care, just fail silently and return no results\n }\n\n return false;\n}\n\nexport function resetHighlightedColumnIndexes<TType = unknown>(\n searchQuery: string | undefined,\n table: ReactTable<TType>,\n localization: Localization\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n let firstRowIndex: undefined | number;\n\n if (searchQuery) {\n const indexes: number[][] = [];\n const columns = table.getVisibleLeafColumns();\n const rowGrouping = table.getState().grouping;\n\n table.getRowModel().rows.forEach((row, rowIndex) => {\n columns.forEach((column, columnIndex) => {\n try {\n let allowSearch = true;\n\n if (rowGrouping?.length) {\n // if it's the grouped row, only allow search of the grouped column - because that's all that's visible\n if (row.getIsGrouped()) {\n allowSearch = column.getIsGrouped();\n }\n // otherwise for other rows, don't search the grouped column - because it isn't visible\n else if (rowGrouping.includes(column.id)) {\n allowSearch = false;\n }\n }\n\n if (column.getIsVisible() && column.columnDef.enableGlobalFilter && allowSearch) {\n const cellValue = get(row.original, column.id);\n const dataType = column.columnDef.meta?.dataType;\n\n if (isMatched(searchQuery, cellValue, dataType, localization)) {\n indexes.push([rowIndex, columnIndex]);\n }\n }\n } catch (e) {\n //\n }\n });\n });\n\n tableMeta.search.setHighlightedColumnIndexes(indexes);\n\n if (indexes.length) {\n firstRowIndex = indexes[0][0];\n tableMeta.search.setCurrentHighlightColumnIndex(0);\n } else {\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n } else {\n tableMeta.search.setHighlightedColumnIndexes([]);\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n\n if (firstRowIndex !== undefined) {\n tableMeta.rowActive.setRowActiveIndex(firstRowIndex);\n }\n\n return firstRowIndex;\n}\n"],"names":["flattenCellValue","cellValue","Object","values","map","isMatched","searchQuery","dataType","localization","flat","Infinity","find","y","isWeakContains","cellValueAsString","String","undefined","dataTypeProperties","getDataTypeProperties","getDisplayValue","cellDisplayValue","globalFilterFn","row","columnId","original","_row$_getAllCellsByCo","_row$_getAllCellsByCo2","_getAllCellsByColumnId","column","columnDef","meta","resetHighlightedColumnIndexes","table","tableMeta","options","firstRowIndex","indexes","columns","getVisibleLeafColumns","rowGrouping","getState","grouping","getRowModel","rows","forEach","rowIndex","columnIndex","allowSearch","length","getIsGrouped","includes","id","getIsVisible","enableGlobalFilter","_column$columnDef$met","get","push","e","search","setHighlightedColumnIndexes","setCurrentHighlightColumnIndex","rowActive","setRowActiveIndex"],"mappings":";;;;AAOA,MAAMA,gBAAgB,GAAIC,SAA0B;EAChD,OAAO,OAAOA,SAAS,KAAK,QAAQ,GAAGC,MAAM,CAACC,MAAM,CAACF,SAAS,CAAC,CAACG,GAAG,CAACJ,gBAAgB,CAAC,GAAGC,SAAS;AACrG,CAAC;SAEeI,SAASA,CACrBC,WAAmB,EACnBL,SAAc,EACdM,QAAyC,EACzCC,YAA0B;EAE1B,IAAI,OAAOP,SAAS,KAAK,QAAQ,EAAE;IAC/B,OAAOD,gBAAgB,CAACC,SAAS,CAAC,CAC7BQ,IAAI,CAACC,QAAQ,CAAC,CACdC,IAAI,CAACC,CAA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GhD,CAAC,OAAOW,CAAC,EAAE;;;OAGf,CAAC;KACL,CAAC;IAEFxB,SAAS,CAACyB,MAAM,CAACC,2BAA2B,CAACvB,OAAO,CAAC;IAErD,IAAIA,OAAO,CAACY,MAAM,EAAE;MAChBb,aAAa,GAAGC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;MAC7BH,SAAS,CAACyB,MAAM,CAACE,8BAA8B,CAAC,CAAC,CAAC;KACrD,MAAM;MACH3B,SAAS,CAACyB,MAAM,CAACE,8BAA8B,CAAC5C,SAAS,CAAC;;GAEjE,MAAM;IACHiB,SAAS,CAACyB,MAAM,CAACC,2BAA2B,CAAC,EAAE,CAAC;IAChD1B,SAAS,CAACyB,MAAM,CAACE,8BAA8B,CAAC5C,SAAS,CAAC;;EAG9D,IAAImB,aAAa,KAAKnB,SAAS,EAAE;IAC7BiB,SAAS,CAAC4B,SAAS,CAACC,iBAAiB,CAAC3B,aAAa,CAAC;;EAGxD,OAAOA,aAAa;AACxB;;;;"}
1
+ {"version":3,"file":"search.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/search.ts"],"sourcesContent":["import { Table as ReactTable, TableMeta as ReactTableMeta, Row as ReactTableRow } from '@tanstack/react-table';\nimport get from 'lodash/get';\nimport { isWeakContains } from './filtering';\nimport { getDataTypeProperties } from './dataTypes';\nimport { TableColumnDataType } from '../../types';\nimport { Localization } from '../../../../components/Provider/Localization';\n\nconst flattenCellValue = (cellValue: object | string) => {\n return typeof cellValue === 'object' ? Object.values(cellValue).map(flattenCellValue) : cellValue;\n};\n\nexport function isMatched<TType = unknown>(\n searchQuery: string,\n cellValue: any,\n dataType: TableColumnDataType | undefined,\n localization: Localization\n) {\n if (typeof cellValue === 'object') {\n return flattenCellValue(cellValue)\n .flat(Infinity)\n .find(y => isWeakContains(y, searchQuery));\n } else {\n const cellValueAsString = String(cellValue ?? '');\n\n if (cellValueAsString !== undefined && isWeakContains(cellValueAsString, searchQuery)) {\n return true;\n } else {\n const dataTypeProperties = getDataTypeProperties<TType>(dataType);\n\n if (dataTypeProperties.getDisplayValue) {\n const cellDisplayValue = dataTypeProperties.getDisplayValue(cellValue, { localization });\n\n if (cellDisplayValue !== undefined && isWeakContains(cellDisplayValue, searchQuery)) {\n return true;\n }\n }\n }\n }\n\n return false;\n}\n\nexport function globalFilterFn<TType = unknown>(\n row: ReactTableRow<TType>,\n columnId: string,\n searchQuery: string,\n localization: Localization\n) {\n try {\n if (row.original) {\n const cellValue = row.original[columnId];\n const dataType = row._getAllCellsByColumnId()[columnId]?.column.columnDef.meta?.dataType;\n return isMatched(searchQuery, cellValue, dataType, localization);\n }\n } catch {\n // we don't care, just fail silently and return no results\n }\n\n return false;\n}\n\nexport function resetHighlightedColumnIndexes<TType = unknown>(\n searchQuery: string | undefined,\n table: ReactTable<TType>,\n localization: Localization\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n let firstRowIndex: undefined | number;\n\n if (searchQuery) {\n const indexes: number[][] = [];\n const columns = table.getVisibleLeafColumns();\n const rowGrouping = table.getState().grouping;\n\n table.getRowModel().rows.forEach((row, rowIndex) => {\n columns.forEach((column, columnIndex) => {\n try {\n let allowSearch = true;\n\n if (rowGrouping?.length) {\n // if it's the grouped row, only allow search of the grouped column - because that's all that's visible\n if (row.getIsGrouped()) {\n allowSearch = column.getIsGrouped();\n }\n // otherwise for other rows, don't search the grouped column - because it isn't visible\n else if (rowGrouping.includes(column.id)) {\n allowSearch = false;\n }\n }\n\n if (column.getIsVisible() && column.columnDef.enableGlobalFilter && allowSearch) {\n const cellValue = get(row.original, column.id);\n const dataType = column.columnDef.meta?.dataType;\n\n if (isMatched(searchQuery, cellValue, dataType, localization)) {\n indexes.push([rowIndex, columnIndex]);\n }\n }\n } catch (e) {\n //\n }\n });\n });\n\n tableMeta.search.setHighlightedColumnIndexes(indexes);\n\n if (indexes.length) {\n firstRowIndex = indexes[0][0];\n tableMeta.search.setCurrentHighlightColumnIndex(0);\n } else {\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n } else {\n tableMeta.search.setHighlightedColumnIndexes([]);\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n\n if (firstRowIndex !== undefined) {\n tableMeta.rowActive.setRowActiveIndex(firstRowIndex);\n }\n\n return firstRowIndex;\n}\n"],"names":["flattenCellValue","cellValue","Object","values","map","isMatched","searchQuery","dataType","localization","flat","Infinity","find","y","isWeakContains","cellValueAsString","String","undefined","dataTypeProperties","getDataTypeProperties","getDisplayValue","cellDisplayValue","globalFilterFn","row","columnId","original","_row$_getAllCellsByCo","_row$_getAllCellsByCo2","_getAllCellsByColumnId","column","columnDef","meta","resetHighlightedColumnIndexes","table","tableMeta","options","firstRowIndex","indexes","columns","getVisibleLeafColumns","rowGrouping","getState","grouping","getRowModel","rows","forEach","rowIndex","columnIndex","allowSearch","length","getIsGrouped","includes","id","getIsVisible","enableGlobalFilter","_column$columnDef$met","get","push","e","search","setHighlightedColumnIndexes","setCurrentHighlightColumnIndex","rowActive","setRowActiveIndex"],"mappings":";;;;AAOA,MAAMA,gBAAgB,GAAIC,SAA0B;EAChD,OAAO,OAAOA,SAAS,KAAK,QAAQ,GAAGC,MAAM,CAACC,MAAM,CAACF,SAAS,CAAC,CAACG,GAAG,CAACJ,gBAAgB,CAAC,GAAGC,SAAS;AACrG,CAAC;SAEeI,SAASA,CACrBC,WAAmB,EACnBL,SAAc,EACdM,QAAyC,EACzCC,YAA0B;EAE1B,IAAI,OAAOP,SAAS,KAAK,QAAQ,EAAE;IAC/B,OAAOD,gBAAgB,CAACC,SAAS,CAAC,CAC7BQ,IAAI,CAACC,QAAQ,CAAC,CACdC,IAAI,CAACC,CAAC,IAAIC,cAAc,CAACD,CAAC,EAAEN,WAAW,CAAC,CAAC;GACjD,MAAM;IACH,MAAMQ,iBAAiB,GAAGC,MAAM,CAACd,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE,CAAC;IAEjD,IAAIa,iBAAiB,KAAKE,SAAS,I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,CAAC,CAAC,CAAC,CAAC;MAC7BH,SAAS,CAACyB,MAAM,CAACE,8BAA8B,CAAC,CAAC,CAAC;KACrD,MAAM;MACH3B,SAAS,CAACyB,MAAM,CAACE,8BAA8B,CAAC5C,SAAS,CAAC;;GAEjE,MAAM;IACHiB,SAAS,CAACyB,MAAM,CAACC,2BAA2B,CAAC,EAAE,CAAC;IAChD1B,SAAS,CAACyB,MAAM,CAACE,8BAA8B,CAAC5C,SAAS,CAAC;;EAG9D,IAAImB,aAAa,KAAKnB,SAAS,EAAE;IAC7BiB,SAAS,CAAC4B,SAAS,CAACC,iBAAiB,CAAC3B,aAAa,CAAC;;EAGxD,OAAOA,aAAa;AACxB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"sorting.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/sorting.ts"],"sourcesContent":["import { SortingFnOption } from '@tanstack/react-table';\nimport { TableColumnDataType, TableColumnSortFn } from '../../types';\nimport { getDataTypeProperties } from './dataTypes';\n\nexport function getSortingFn<TType = unknown>(\n dataType?: TableColumnDataType,\n customFnOrBuiltIn?: TableColumnSortFn<TType>\n): SortingFnOption<TType> | undefined {\n // custom functions should override any that come from dataType\n if (typeof customFnOrBuiltIn === 'function') {\n return (rowA: any, rowB: any, columnId: string) => customFnOrBuiltIn(rowA.original, rowB.original, columnId);\n }\n\n // if a built in is being used, just return that\n if (customFnOrBuiltIn) {\n return customFnOrBuiltIn;\n }\n\n return getDataTypeProperties<TType>(dataType).sortingFn;\n}\n"],"names":["getSortingFn","dataType","customFnOrBuiltIn","rowA","rowB","columnId","original","getDataTypeProperties","sortingFn"],"mappings":";;SAIgBA,YAAYA,CACxBC,QAA8B,EAC9BC,iBAA4C;;EAG5C,IAAI,OAAOA,iBAAiB,KAAK,UAAU,EAAE;IACzC,OAAO,CAACC,IAAS,EAAEC,IAAS,EAAEC,QAAgB,KAAKH,iBAAiB,CAACC,IAAI,CAACG,QAAQ,EAAEF,IAAI,CAACE,QAAQ,EAAED,QAAQ,CAAC;;;EAIhH,IAAIH,iBAAiB,EAAE;IACnB,OAAOA,iBAAiB;;EAG5B,OAAOK,qBAAqB,CAAQN,QAAQ,CAAC,CAACO,SAAS;AAC3D;;;;"}
1
+ {"version":3,"file":"sorting.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/sorting.ts"],"sourcesContent":["import { SortingFnOption } from '@tanstack/react-table';\nimport { TableColumnDataType, TableColumnSortFn } from '../../types';\nimport { getDataTypeProperties } from './dataTypes';\n\nexport function getSortingFn<TType = unknown>(\n dataType?: TableColumnDataType,\n customFnOrBuiltIn?: TableColumnSortFn<TType>\n): SortingFnOption<TType> | undefined {\n // custom functions should override any that come from dataType\n if (typeof customFnOrBuiltIn === 'function') {\n return (rowA, rowB, columnId: string) => customFnOrBuiltIn(rowA.original, rowB.original, columnId);\n }\n\n // if a built in is being used, just return that\n if (customFnOrBuiltIn) {\n return customFnOrBuiltIn;\n }\n\n return getDataTypeProperties<TType>(dataType).sortingFn;\n}\n"],"names":["getSortingFn","dataType","customFnOrBuiltIn","rowA","rowB","columnId","original","getDataTypeProperties","sortingFn"],"mappings":";;SAIgBA,YAAYA,CACxBC,QAA8B,EAC9BC,iBAA4C;;EAG5C,IAAI,OAAOA,iBAAiB,KAAK,UAAU,EAAE;IACzC,OAAO,CAACC,IAAI,EAAEC,IAAI,EAAEC,QAAgB,KAAKH,iBAAiB,CAACC,IAAI,CAACG,QAAQ,EAAEF,IAAI,CAACE,QAAQ,EAAED,QAAQ,CAAC;;;EAItG,IAAIH,iBAAiB,EAAE;IACnB,OAAOA,iBAAiB;;EAG5B,OAAOK,qBAAqB,CAAQN,QAAQ,CAAC,CAACO,SAAS;AAC3D;;;;"}
@@ -0,0 +1,122 @@
1
+ // NOTE: this file is intentianally a js file so that it can be consumed by tailwind.config.js
2
+
3
+ const THEME_COLORS = {
4
+ transparent: 'transparent',
5
+ current: 'currentColor',
6
+ white: '#fff',
7
+ black: '#1c1c1c',
8
+ brand: {
9
+ vismaRed: '#E70641',
10
+ paleOrange: '#FFF5E5',
11
+ sunsetOrange: '#E89C2E',
12
+ midnightBlue: '#29283E',
13
+ coolBlue: '#F5F7F9'
14
+ },
15
+ grey: {
16
+ lightest: '#fafafa',
17
+ light: '#F6F6F6',
18
+ DEFAULT: '#EBEBEB',
19
+ dark: '#DDDDDD',
20
+ darker: '#ACACAC',
21
+ darkest: '#595959',
22
+ darkNew: '#a5a6a9',
23
+ 50: '#fafafa',
24
+ 100: '#F6F6F6',
25
+ 200: '#EBEBEB',
26
+ 300: '#DDDDDD',
27
+ 500: '#ACACAC',
28
+ 700: '#595959',
29
+ 900: '#303030'
30
+ },
31
+ purple: {
32
+ lightest: '#585c74',
33
+ light: '#4b4f64',
34
+ DEFAULT: '#3d4153',
35
+ dark: '#353a48',
36
+ darker: '#29283e',
37
+ darkest: '#212032',
38
+ darkNew_1: '#373647',
39
+ darkNew_2: '#414050',
40
+ 100: '#EEE5FF',
41
+ 200: '#ddd1ff',
42
+ 300: '#CBBCFE',
43
+ 500: '#9270FA',
44
+ 700: '#6542D1',
45
+ 900: '#412970'
46
+ },
47
+ blue: {
48
+ lightest: '#DEEBFF',
49
+ light: '#75A0F5',
50
+ DEFAULT: '#4573D2',
51
+ dark: '#2B57B4',
52
+ 100: '#DEEBFF',
53
+ 200: '#AACCFF',
54
+ 300: '#75A0F5',
55
+ 500: '#4573D2',
56
+ 700: '#2B57B4',
57
+ 900: '#29283E'
58
+ },
59
+ red: {
60
+ lightest: '#FFDAD2',
61
+ light: '#E66568',
62
+ DEFAULT: '#CE3F42',
63
+ dark: '#950027',
64
+ 100: '#FFDAD2',
65
+ 200: '#f3a09d',
66
+ 300: '#E66568',
67
+ 500: '#CE3F42',
68
+ 700: '#950027',
69
+ 900: '#64001B'
70
+ },
71
+ green: {
72
+ lightest: '#cdf0e7',
73
+ light: '#52C7AB',
74
+ DEFAULT: '#08AE87',
75
+ dark: '#028465',
76
+ 100: '#cdf0e7',
77
+ 200: '#9be1ce',
78
+ 300: '#52C7AB',
79
+ 500: '#08AE87',
80
+ 700: '#028465',
81
+ 900: '#14493A'
82
+ },
83
+ yellow: {
84
+ lightest: '#FFF1C3',
85
+ light: '#FFD665',
86
+ DEFAULT: '#FFBD3B',
87
+ dark: '#e89c2e',
88
+ 100: '#FFF1C3',
89
+ 200: '#ffe494',
90
+ 300: '#FFD665',
91
+ 500: '#FFBD3B',
92
+ 700: '#e89c2e',
93
+ 900: '#733700'
94
+ },
95
+ pink: {
96
+ 100: '#FFE3F7',
97
+ 200: '#fcb9e9',
98
+ 300: '#F98EDB',
99
+ 500: '#E165BF',
100
+ 700: '#CF49AA',
101
+ 900: '#870062'
102
+ },
103
+ brown: {
104
+ 100: '#EEE0DA',
105
+ 200: '#DFCCC2',
106
+ 300: '#C4AB9E',
107
+ 500: '#93715D',
108
+ 700: '#73503B',
109
+ 900: '#45291F'
110
+ },
111
+ orange: {
112
+ 100: '#FFE3BB',
113
+ 200: '#FCCB80',
114
+ 300: '#FAB64D',
115
+ 500: '#F99702',
116
+ 700: '#EF7D00',
117
+ 900: '#4A2811'
118
+ }
119
+ };
120
+
121
+ export default THEME_COLORS;
122
+ //# sourceMappingURL=tailwind.colors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind.colors.js","sources":["../../../../tailwind.colors.js"],"sourcesContent":["// NOTE: this file is intentianally a js file so that it can be consumed by tailwind.config.js\n\nconst THEME_COLORS = {\n transparent: 'transparent',\n current: 'currentColor',\n white: '#fff',\n black: '#1c1c1c',\n brand: {\n vismaRed: '#E70641',\n paleOrange: '#FFF5E5',\n sunsetOrange: '#E89C2E',\n midnightBlue: '#29283E',\n coolBlue: '#F5F7F9',\n },\n grey: {\n lightest: '#fafafa',\n light: '#F6F6F6',\n DEFAULT: '#EBEBEB',\n dark: '#DDDDDD',\n darker: '#ACACAC',\n darkest: '#595959',\n darkNew: '#a5a6a9',\n 50: '#fafafa',\n 100: '#F6F6F6',\n 200: '#EBEBEB',\n 300: '#DDDDDD',\n 500: '#ACACAC',\n 700: '#595959',\n 900: '#303030',\n },\n purple: {\n lightest: '#585c74',\n light: '#4b4f64',\n DEFAULT: '#3d4153',\n dark: '#353a48',\n darker: '#29283e',\n darkest: '#212032',\n darkNew_1: '#373647',\n darkNew_2: '#414050',\n 100: '#EEE5FF',\n 200: '#ddd1ff',\n 300: '#CBBCFE',\n 500: '#9270FA',\n 700: '#6542D1',\n 900: '#412970',\n },\n blue: {\n lightest: '#DEEBFF',\n light: '#75A0F5',\n DEFAULT: '#4573D2',\n dark: '#2B57B4',\n 100: '#DEEBFF',\n 200: '#AACCFF',\n 300: '#75A0F5',\n 500: '#4573D2',\n 700: '#2B57B4',\n 900: '#29283E',\n },\n red: {\n lightest: '#FFDAD2',\n light: '#E66568',\n DEFAULT: '#CE3F42',\n dark: '#950027',\n 100: '#FFDAD2',\n 200: '#f3a09d',\n 300: '#E66568',\n 500: '#CE3F42',\n 700: '#950027',\n 900: '#64001B',\n },\n green: {\n lightest: '#cdf0e7',\n light: '#52C7AB',\n DEFAULT: '#08AE87',\n dark: '#028465',\n 100: '#cdf0e7',\n 200: '#9be1ce',\n 300: '#52C7AB',\n 500: '#08AE87',\n 700: '#028465',\n 900: '#14493A',\n },\n yellow: {\n lightest: '#FFF1C3',\n light: '#FFD665',\n DEFAULT: '#FFBD3B',\n dark: '#e89c2e',\n 100: '#FFF1C3',\n 200: '#ffe494',\n 300: '#FFD665',\n 500: '#FFBD3B',\n 700: '#e89c2e',\n 900: '#733700',\n },\n pink: {\n 100: '#FFE3F7',\n 200: '#fcb9e9',\n 300: '#F98EDB',\n 500: '#E165BF',\n 700: '#CF49AA',\n 900: '#870062',\n },\n brown: {\n 100: '#EEE0DA',\n 200: '#DFCCC2',\n 300: '#C4AB9E',\n 500: '#93715D',\n 700: '#73503B',\n 900: '#45291F',\n },\n orange: {\n 100: '#FFE3BB',\n 200: '#FCCB80',\n 300: '#FAB64D',\n 500: '#F99702',\n 700: '#EF7D00',\n 900: '#4A2811',\n },\n};\n\nexport default THEME_COLORS;\n"],"names":["THEME_COLORS","transparent","current","white","black","brand","vismaRed","paleOrange","sunsetOrange","midnightBlue","coolBlue","grey","lightest","light","DEFAULT","dark","darker","darkest","darkNew","purple","darkNew_1","darkNew_2","blue","red","green","yellow","pink","brown","orange"],"mappings":"AAAA;;AAEA,MAAMA,YAAY,GAAG;EACjBC,WAAW,EAAE,aAAa;EAC1BC,OAAO,EAAE,cAAc;EACvBC,KAAK,EAAE,MAAM;EACbC,KAAK,EAAE,SAAS;EAChBC,KAAK,EAAE;IACHC,QAAQ,EAAE,SAAS;IACnBC,UAAU,EAAE,SAAS;IACrBC,YAAY,EAAE,SAAS;IACvBC,YAAY,EAAE,SAAS;IACvBC,QAAQ,EAAE;GACb;EACDC,IAAI,EAAE;IACFC,QAAQ,EAAE,SAAS;IACnBC,KAAK,EAAE,SAAS;IAChBC,OAAO,EAAE,SAAS;IAClBC,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE,SAAS;IACjBC,OAAO,EAAE,SAAS;IAClBC,OAAO,EAAE,SAAS;IAClB,EAAE,EAAE,SAAS;IACb,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE;GACR;EACDC,MAAM,EAAE;IACJP,QAAQ,EAAE,SAAS;IACnBC,KAAK,EAAE,SAAS;IAChBC,OAAO,EAAE,SAAS;IAClBC,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE,SAAS;IACjBC,OAAO,EAAE,SAAS;IAClBG,SAAS,EAAE,SAAS;IACpBC,SAAS,EAAE,SAAS;IACpB,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE;GACR;EACDC,IAAI,EAAE;IACFV,QAAQ,EAAE,SA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G,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE;GACR;EACDC,MAAM,EAAE;IACJ,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,GAAG,EAAE;;AAEb,CAAC;;;;"}
package/dist/index.css CHANGED
@@ -180,6 +180,24 @@
180
180
  }
181
181
  }
182
182
 
183
+ .recharts-cartesian-axis line,
184
+ .recharts-cartesian-grid-horizontal line {
185
+ stroke: #efefef !important;
186
+ }
187
+
188
+ .recharts-tooltip-cursor {
189
+ fill: transparent !important;
190
+ }
191
+
192
+ .recharts-legend-wrapper {
193
+ left: 0 !important;
194
+ width: 100% !important;
195
+ }
196
+
197
+ .recharts-wrapper > svg g {
198
+ outline: none !important;
199
+ }
200
+
183
201
  [data-taco='badge'] > [data-taco='spinner'] {
184
202
  @apply ml-2 h-3 w-3;
185
203
  }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import './css/global.css';
2
+ import './charts/style.css';
2
3
  export * from './components/Alert/Alert';
3
4
  export * from './components/AlertDialog/AlertDialog';
4
5
  export * from './components/Accordion/Accordion';
@@ -52,6 +53,10 @@ export * from './components/Tooltip/Tooltip';
52
53
  export * from './components/Tour/Tour';
53
54
  export * from './components/Treeview/Treeview';
54
55
  export * from './components/VisuallyHidden/VisuallyHidden';
56
+ export * from './charts/components/Area/AreaChart';
57
+ export * from './charts/components/Bar/BarChart';
58
+ export * from './charts/components/Donut/DonutChart';
59
+ export * from './charts/components/Line/LineChart';
55
60
  export * from './components/Header/Header';
56
61
  export * from './components/Layout/Layout';
57
62
  export * from './components/Navigation2/Navigation2';
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { TableEmptyStateReason, TableEmptyStateRenderer } from '../../../types';
3
3
  declare type EmptyStateProps = React.HTMLAttributes<HTMLTableSectionElement> & {
4
4
  emptyState?: TableEmptyStateRenderer;
5
+ isReady: boolean;
5
6
  reason: TableEmptyStateReason;
6
7
  };
7
8
  export declare function EmptyStateBody(props: EmptyStateProps): React.JSX.Element;
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
  declare type RowContextValue = {
3
+ hideInternalColumns: boolean;
4
+ hideRowActions: boolean;
3
5
  isHovered: boolean;
4
6
  rowIndex: number;
5
- hideRowActions: boolean;
6
7
  };
7
8
  export declare const RowContext: React.Context<RowContextValue>;
8
9
  export {};
@@ -9,6 +9,7 @@ export declare type useTableRenderers<TType = unknown> = {
9
9
  };
10
10
  export declare type TableRowRendererProps<TType = unknown> = {
11
11
  cellRenderer: TableCellRenderer<TType>;
12
+ hideInternalColumns?: boolean;
12
13
  hideRowActions?: boolean;
13
14
  index: number;
14
15
  measureRow: (size: number, expansionHeight?: number) => void;