@economic/taco 2.35.1 → 2.36.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. package/dist/components/Dialog/components/Content.d.ts +5 -0
  2. package/dist/components/Icon/components/index.d.ts +1 -1
  3. package/dist/components/Input/Input.d.ts +1 -1
  4. package/dist/components/Menu/Menu.d.ts +2 -1
  5. package/dist/components/Menu/components/Item.d.ts +1 -1
  6. package/dist/components/Menu/components/Link.d.ts +1 -1
  7. package/dist/components/Menu/components/Separator.d.ts +3 -2
  8. package/dist/components/Navigation2/components/Link.d.ts +1 -1
  9. package/dist/components/Provider/Localization.d.ts +6 -0
  10. package/dist/components/Report/Report.d.ts +1 -1
  11. package/dist/components/Select2/components/Option.d.ts +2 -2
  12. package/dist/components/Select2/components/Search.d.ts +1 -7
  13. package/dist/components/Table3/Table3.d.ts +29 -1
  14. package/dist/components/Table3/components/Row/Editing/CreateRowButton.d.ts +11 -0
  15. package/dist/components/Table3/features/useTableEditing.d.ts +1 -0
  16. package/dist/components/Table3/types.d.ts +16 -1
  17. package/dist/components/Table3/util/editing.d.ts +1 -0
  18. package/dist/components/Tag/Tag.d.ts +1 -1
  19. package/dist/esm/index.css +41 -21
  20. package/dist/esm/node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js +161 -1
  21. package/dist/esm/node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js.map +1 -1
  22. package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js +1 -1
  23. package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js.map +1 -1
  24. package/dist/esm/packages/taco/src/components/Dialog/components/Content.js.map +1 -1
  25. package/dist/esm/packages/taco/src/components/Icon/components/{ESignature.js → DocumentSignedSolid.js} +4 -4
  26. package/dist/esm/packages/taco/src/components/Icon/components/DocumentSignedSolid.js.map +1 -0
  27. package/dist/esm/packages/taco/src/components/Icon/components/{Home2.js → House.js} +4 -4
  28. package/dist/esm/packages/taco/src/components/Icon/components/{Home2.js.map → House.js.map} +1 -1
  29. package/dist/esm/packages/taco/src/components/Icon/components/{Home.js → HouseSolid.js} +4 -4
  30. package/dist/esm/packages/taco/src/components/Icon/components/HouseSolid.js.map +1 -0
  31. package/dist/esm/packages/taco/src/components/Icon/components/index.js +6 -6
  32. package/dist/esm/packages/taco/src/components/Icon/components/index.js.map +1 -1
  33. package/dist/esm/packages/taco/src/components/Menu/Menu.js.map +1 -1
  34. package/dist/esm/packages/taco/src/components/Menu/components/Separator.js +7 -5
  35. package/dist/esm/packages/taco/src/components/Menu/components/Separator.js.map +1 -1
  36. package/dist/esm/packages/taco/src/components/Provider/Localization.js +7 -1
  37. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  38. package/dist/esm/packages/taco/src/components/Select2/Select2.js +7 -16
  39. package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
  40. package/dist/esm/packages/taco/src/components/Select2/components/Search.js +2 -12
  41. package/dist/esm/packages/taco/src/components/Select2/components/Search.js.map +1 -1
  42. package/dist/esm/packages/taco/src/components/Table3/Table3.js +8 -1
  43. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  44. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/util.js +3 -2
  45. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/util.js.map +1 -1
  46. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +24 -3
  47. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
  48. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js +90 -0
  49. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js.map +1 -0
  50. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +53 -15
  51. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
  52. package/dist/esm/packages/taco/src/components/Table3/useTable3.js +2 -1
  53. package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
  54. package/dist/esm/packages/taco/src/components/Table3/util/editing.js +20 -1
  55. package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
  56. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +5 -2
  57. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
  58. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js +2 -1
  59. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js.map +1 -1
  60. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js +2 -4
  61. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js.map +1 -1
  62. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +2 -3
  63. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
  64. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js +5 -4
  65. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js.map +1 -1
  66. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.js +3 -2
  67. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.js.map +1 -1
  68. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +1 -1
  69. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  70. package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
  71. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js +6 -1
  72. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js.map +1 -1
  73. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowClick.js +11 -8
  74. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowClick.js.map +1 -1
  75. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +2 -1
  76. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
  77. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/presets.js +3 -1
  78. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/presets.js.map +1 -1
  79. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +9 -0
  80. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  81. package/dist/esm/packages/taco/src/utils/dom.js +2 -2
  82. package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
  83. package/dist/index.css +41 -21
  84. package/dist/primitives/Table/Core/components/Header/components/Menu.d.ts +1 -0
  85. package/dist/primitives/Table/types.d.ts +8 -6
  86. package/dist/primitives/Table/useTableManager/features/useTableRowClick.d.ts +4 -4
  87. package/dist/primitives/Table/useTableManager/useTableManager.d.ts +1 -1
  88. package/dist/primitives/Table/useTableManager/util/presets.d.ts +1 -1
  89. package/dist/primitives/Table/useTableManager/util/setup.d.ts +2 -2
  90. package/dist/taco.cjs.development.js +454 -113
  91. package/dist/taco.cjs.development.js.map +1 -1
  92. package/dist/taco.cjs.production.min.js +1 -1
  93. package/dist/taco.cjs.production.min.js.map +1 -1
  94. package/dist/utils/dom.d.ts +1 -1
  95. package/package.json +2 -2
  96. package/dist/components/Table/Table.storyexample.d.ts +0 -9
  97. package/dist/esm/packages/taco/src/components/Icon/components/ESignature.js.map +0 -1
  98. package/dist/esm/packages/taco/src/components/Icon/components/Home.js.map +0 -1
  99. /package/dist/components/Icon/components/{ESignature.d.ts → DocumentSignedSolid.d.ts} +0 -0
  100. /package/dist/components/Icon/components/{Home.d.ts → House.d.ts} +0 -0
  101. /package/dist/components/Icon/components/{Home2.d.ts → HouseSolid.d.ts} +0 -0
@@ -203,7 +203,8 @@ const MemoedHeader = /*#__PURE__*/React__default.memo(function MemoedHeader(prop
203
203
  onSortToggle: handleSortToggle,
204
204
  scrollToIndex: scrollToIndex,
205
205
  setRowActiveIndex: setRowActiveIndex,
206
- sortDirection: sortDirection
206
+ sortDirection: sortDirection,
207
+ columnId: id
207
208
  })) : null, canResize ? ( /*#__PURE__*/React__default.createElement(Resizer, {
208
209
  headerRef: ref,
209
210
  id: id,
@@ -1 +1 @@
1
- {"version":3,"file":"Header.js","sources":["../../../../../../../../../../src/primitives/Table/Core/components/Header/Header.tsx"],"sourcesContent":["import React from 'react';\nimport {\n TableMeta as ReactTableMeta,\n ColumnMeta as ReactTableColumnMeta,\n Header as ReactTableHeader,\n ColumnPinningPosition as ReactTableColumnPinningPosition,\n flexRender,\n} from '@tanstack/react-table';\nimport cn from 'clsx';\nimport { freezeUptoExternalColumn, isInternalColumn, unfreezeAllExternalColumns } from '../../../useTableManager/util/columns';\nimport { Tooltip } from '../../../../../components/Tooltip/Tooltip';\nimport { SortIndicator, getSortAttributes } from './components/SortIndicator';\nimport {\n TableColumnAlignment,\n TableColumnMenu,\n TableColumnSortDirection,\n TableColumnWidth,\n TableFilterComparator,\n} from '../../../types';\nimport { Resizer } from './components/Resizer';\nimport { HeaderMenu } from './components/Menu';\nimport { getIsPinned, useSetInitialColumnSizing } from './util';\n\nexport type HeaderProps<TType = unknown> = {\n header: ReactTableHeader<TType, unknown>;\n scrollToIndex: (index: number) => void;\n};\n\nexport function Header<TType = unknown>(props: HeaderProps<TType>) {\n const { header, scrollToIndex } = props;\n\n if (header.column.getIsGrouped()) {\n return null;\n }\n\n const { table } = header.getContext();\n\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const columnMeta = (header.column.columnDef.meta ?? {}) as ReactTableColumnMeta<TType, unknown>;\n\n const isGroup = !!header.subHeaders.length;\n const isPinned = getIsPinned(header);\n\n const canFilter = !header.isPlaceholder && header.column.getCanFilter() && !!table.options.enableColumnFilters;\n const canHide = !header.isPlaceholder && !isGroup && header.column.getCanHide();\n const canMeasureSize = !!table.getRowModel().rows.length;\n const canPin = !header.isPlaceholder && !isGroup && header.column.getCanPin();\n const canResize = !header.isPlaceholder && !isGroup && header.column.getCanResize();\n const canSort = !header.isPlaceholder && !isGroup && header.column.getCanSort();\n const canGoto = canSort && !header.isPlaceholder && !isGroup && tableMeta.rowGoto.isEnabled && !!header.column.getIsSorted();\n\n const hasMenu = !isInternalColumn(header.id) && (canHide || canGoto || canPin || canSort || !!columnMeta.menu);\n\n const sorting = table.getState().sorting;\n const filters = table.getState().columnFilters;\n const search = table.getState().globalFilter;\n\n // passing header or column results in re-renders on scroll, so anything from those objects as memoed props\n const memoedProps: MemoedHeaderProps = {\n align: columnMeta.align,\n canFilter,\n canHide,\n canGoto,\n canMeasureSize,\n canPin,\n canResize,\n canSort,\n className: cn('group/header', columnMeta.headerClassName),\n children: flexRender(header.column.columnDef.header, header.getContext()),\n colSpan: header.colSpan,\n customMenu: columnMeta.menu,\n defaultWidth: columnMeta.defaultWidth,\n hasMenu,\n id: header.id,\n isFiltered: header.column.getIsFiltered(),\n index: header.index,\n isGroup,\n isPinned,\n isPlaceholder: header.isPlaceholder,\n offset: header.column.getStart(isPinned),\n scrollToIndex,\n setRowActiveIndex: tableMeta.rowActive.setRowActiveIndex,\n setColumnSizing: table.setColumnSizing,\n tooltip: columnMeta.tooltip,\n width: table.getState().columnSizing[header.id],\n };\n\n if (header.isPlaceholder) {\n const nextHeader = header.headerGroup.headers[header.index + 1];\n memoedProps.className = cn('!bg-white before:!content-none', memoedProps.className, {\n 'after:!content-none': nextHeader?.isPlaceholder,\n });\n }\n\n if (canFilter) {\n memoedProps.onFilter = () => {\n header.column.setFilterValue({ comparator: TableFilterComparator.Contains });\n };\n }\n\n if (canGoto) {\n memoedProps.onGoto = ((query: string) => tableMeta.rowGoto.handleGoto?.(header.id, query, sorting, filters, search)) as (\n query: string\n ) => Promise<number>;\n }\n\n if (canHide) {\n memoedProps.onHide = header.column.getToggleVisibilityHandler();\n }\n\n if (canPin) {\n memoedProps.onPin = (index: number | undefined) => {\n // TODO: this can probably be moved to a feature hook\n table.setColumnPinning(pinningState => {\n return {\n ...pinningState,\n left:\n index === undefined\n ? unfreezeAllExternalColumns(pinningState.left)\n : freezeUptoExternalColumn(\n index,\n table.getAllLeafColumns().map(column => column.id)\n ),\n };\n });\n };\n }\n\n if (canResize) {\n memoedProps.isResizing = header.column.getIsResizing();\n memoedProps.onResize = header.getResizeHandler();\n }\n\n if (canSort) {\n const handleSortToggle = (sortDirection: TableColumnSortDirection | false) => {\n if (sortDirection === false) {\n header.column.clearSorting();\n } else {\n header.column.toggleSorting(sortDirection === 'desc');\n }\n };\n\n memoedProps.onSort = header.column.getToggleSortingHandler();\n memoedProps.onSortToggle = handleSortToggle;\n memoedProps.sortDirection = header.column.getIsSorted();\n }\n\n return <MemoedHeader key={header.id} {...memoedProps} />;\n}\n\nexport type MemoedHeaderProps = {\n align?: TableColumnAlignment;\n canFilter: boolean;\n canHide: boolean;\n canGoto: boolean;\n canMeasureSize: boolean;\n canPin: boolean;\n canResize: boolean;\n canSort: boolean;\n children: JSX.Element | React.ReactNode;\n className?: string;\n colSpan: number;\n customMenu?: TableColumnMenu;\n defaultWidth?: TableColumnWidth;\n hasMenu: boolean;\n id: string;\n index: number;\n isFiltered: boolean;\n isGroup: boolean;\n isPinned?: ReactTableColumnPinningPosition;\n isPlaceholder: boolean;\n isResizing?: boolean;\n offset?: number;\n onFilter?: () => void;\n onGoto?: (query: string) => Promise<number>;\n onHide?: (event: unknown) => void;\n onPin?: (index: number | undefined) => void;\n onResize?: (event: unknown) => void;\n onSort?: (event: unknown) => void;\n onSortToggle?: (sortDirection: TableColumnSortDirection | false) => void;\n scrollToIndex: (index: number) => void;\n setRowActiveIndex: (index: number) => void;\n setColumnSizing: any;\n sortDirection?: TableColumnSortDirection | false;\n tooltip?: string;\n width?: TableColumnWidth;\n};\n\nconst MemoedHeader = React.memo(function MemoedHeader(props: MemoedHeaderProps) {\n const {\n align,\n canFilter,\n canGoto,\n canHide,\n canMeasureSize,\n canPin,\n canResize,\n canSort,\n children,\n className,\n colSpan,\n customMenu,\n defaultWidth,\n hasMenu,\n id,\n index,\n isFiltered,\n isGroup,\n isPinned,\n isPlaceholder,\n isResizing,\n offset,\n onFilter: handleFilter,\n onGoto: handleGoto,\n onHide: handleHide,\n onPin: handlePin,\n onResize: handleResize,\n onSort: handleSort,\n onSortToggle: handleSortToggle,\n scrollToIndex,\n setRowActiveIndex,\n setColumnSizing,\n sortDirection,\n tooltip,\n width,\n } = props;\n const [ref, setRef] = React.useState<HTMLTableCellElement | null>(null);\n\n // save column width if none is set\n useSetInitialColumnSizing(id, defaultWidth, width, ref, canMeasureSize, setColumnSizing);\n\n // feature specific styles\n const style: React.CSSProperties = {};\n\n // column groups often span multiple columns\n if (colSpan > 1) {\n style.gridColumn = `span ${colSpan}`;\n }\n\n // pinned columns should be offset from either the left or right\n if (isPinned) {\n style[isPinned] = `${offset}px`;\n }\n\n return (\n <th\n {...getSortAttributes(canSort, handleSort, sortDirection)}\n className={className}\n data-cell-align={isGroup ? 'center' : align}\n data-cell-id={id}\n data-cell-pinned={isPinned ? isPinned : undefined}\n style={style}\n ref={setRef}>\n {isPlaceholder ? null : isInternalColumn(id) ? (\n children\n ) : (\n <Tooltip title={String(tooltip ?? children)} placement=\"top\">\n <span className=\"truncate\">{children}</span>\n </Tooltip>\n )}\n {sortDirection ? <SortIndicator direction={sortDirection} /> : null}\n {hasMenu ? (\n <HeaderMenu\n canFilter={canFilter}\n canGoto={canGoto}\n canHide={canHide}\n canPin={canPin}\n canSort={canSort}\n className={cn({\n 'ml-auto': align !== 'right',\n 'ml-0': align === 'right',\n })}\n customMenu={customMenu}\n index={index}\n isFiltered={isFiltered}\n onFilter={handleFilter}\n onGoto={handleGoto}\n onHide={handleHide}\n onPin={handlePin}\n onSortToggle={handleSortToggle}\n scrollToIndex={scrollToIndex}\n setRowActiveIndex={setRowActiveIndex}\n sortDirection={sortDirection}\n />\n ) : null}\n {canResize ? (\n <Resizer\n headerRef={ref}\n id={id}\n isResizing={isResizing as boolean}\n onResize={handleResize as (event: unknown) => void}\n setColumnSizing={setColumnSizing}\n width={width}\n />\n ) : null}\n </th>\n );\n});\n"],"names":["Header","props","header","scrollToIndex","column","getIsGrouped","table","getContext","tableMeta","options","meta","columnMeta","_header$column$column","columnDef","isGroup","subHeaders","length","isPinned","getIsPinned","canFilter","isPlaceholder","getCanFilter","enableColumnFilters","canHide","getCanHide","canMeasureSize","getRowModel","rows","canPin","getCanPin","canResize","getCanResize","canSort","getCanSort","canGoto","rowGoto","isEnabled","getIsSorted","hasMenu","isInternalColumn","id","menu","sorting","getState","filters","columnFilters","search","globalFilter","memoedProps","align","className","cn","headerClassName","children","flexRender","colSpan","customMenu","defaultWidth","isFiltered","getIsFiltered","index","offset","getStart","setRowActiveIndex","rowActive","setColumnSizing","tooltip","width","columnSizing","nextHeader","headerGroup","headers","onFilter","setFilterValue","comparator","TableFilterComparator","Contains","onGoto","query","_tableMeta$rowGoto$ha","_tableMeta$rowGoto","handleGoto","call","onHide","getToggleVisibilityHandler","onPin","setColumnPinning","pinningState","left","undefined","unfreezeAllExternalColumns","freezeUptoExternalColumn","getAllLeafColumns","map","isResizing","getIsResizing","onResize","getResizeHandler","handleSortToggle","sortDirection","clearSorting","toggleSorting","onSort","getToggleSortingHandler","onSortToggle","React","MemoedHeader","key","memo","handleFilter","handleHide","handlePin","handleResize","handleSort","ref","setRef","useState","useSetInitialColumnSizing","style","gridColumn","getSortAttributes","Tooltip","title","String","placement","SortIndicator","direction","HeaderMenu","Resizer","headerRef"],"mappings":";;;;;;;;;;;SA4BgBA,MAAMA,CAAkBC,KAAyB;;EAC7D,MAAM;IAAEC,MAAM;IAAEC;GAAe,GAAGF,KAAK;EAEvC,IAAIC,MAAM,CAACE,MAAM,CAACC,YAAY,EAAE,EAAE;IAC9B,OAAO,IAAI;;EAGf,MAAM;IAAEC;GAAO,GAAGJ,MAAM,CAACK,UAAU,EAAE;EAErC,MAAMC,SAAS,GAAGF,KAAK,CAACG,OAAO,CAACC,IAA6B;EAC7D,MAAMC,UAAU,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AAO,kBACJmE,6BAACsB,UAAU;IACP5G,SAAS,EAAEA,SAAS;IACpBe,OAAO,EAAEA,OAAO;IAChBX,OAAO,EAAEA,OAAO;IAChBK,MAAM,EAAEA,MAAM;IACdI,OAAO,EAAEA,OAAO;IAChBkB,SAAS,EAAEC,EAAE,CAAC;MACV,SAAS,EAAEF,KAAK,KAAK,OAAO;MAC5B,MAAM,EAAEA,KAAK,KAAK;KACrB,CAAC;IACFO,UAAU,EAAEA,UAAU;IACtBI,KAAK,EAAEA,KAAK;IACZF,UAAU,EAAEA,UAAU;IACtBc,QAAQ,EAAEqC,YAAY;IACtBhC,MAAM,EAAEI,UAAU;IAClBE,MAAM,EAAE2B,UAAU;IAClBzB,KAAK,EAAE0B,SAAS;IAChBP,YAAY,EAAEN,gBAAgB;IAC9B/F,aAAa,EAAEA,aAAa;IAC5B4D,iBAAiB,EAAEA,iBAAiB;IACpCoC,aAAa,EAAEA;IACjB,IACF,IAAI,EACPrE,SAAS,kBACN2E,6BAACuB,OAAO;IACJC,SAAS,EAAEf,GAAG;IACd1E,EAAE,EAAEA,EAAE;IACNsD,UAAU,EAAEA,UAAqB;IACjCE,QAAQ,EAAEgB,YAAwC;IAClD/C,eAAe,EAAEA,eAAe;IAChCE,KAAK,EAAEA;IACT,IACF,IAAI,CACP;AAEb,CAAC,CAAC;;;;"}
1
+ {"version":3,"file":"Header.js","sources":["../../../../../../../../../../src/primitives/Table/Core/components/Header/Header.tsx"],"sourcesContent":["import React from 'react';\nimport {\n TableMeta as ReactTableMeta,\n ColumnMeta as ReactTableColumnMeta,\n Header as ReactTableHeader,\n ColumnPinningPosition as ReactTableColumnPinningPosition,\n flexRender,\n} from '@tanstack/react-table';\nimport cn from 'clsx';\nimport { freezeUptoExternalColumn, isInternalColumn, unfreezeAllExternalColumns } from '../../../useTableManager/util/columns';\nimport { Tooltip } from '../../../../../components/Tooltip/Tooltip';\nimport { SortIndicator, getSortAttributes } from './components/SortIndicator';\nimport {\n TableColumnAlignment,\n TableColumnMenu,\n TableColumnSortDirection,\n TableColumnWidth,\n TableFilterComparator,\n} from '../../../types';\nimport { Resizer } from './components/Resizer';\nimport { HeaderMenu } from './components/Menu';\nimport { getIsPinned, useSetInitialColumnSizing } from './util';\n\nexport type HeaderProps<TType = unknown> = {\n header: ReactTableHeader<TType, unknown>;\n scrollToIndex: (index: number) => void;\n};\n\nexport function Header<TType = unknown>(props: HeaderProps<TType>) {\n const { header, scrollToIndex } = props;\n\n if (header.column.getIsGrouped()) {\n return null;\n }\n\n const { table } = header.getContext();\n\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const columnMeta = (header.column.columnDef.meta ?? {}) as ReactTableColumnMeta<TType, unknown>;\n\n const isGroup = !!header.subHeaders.length;\n const isPinned = getIsPinned(header);\n\n const canFilter = !header.isPlaceholder && header.column.getCanFilter() && !!table.options.enableColumnFilters;\n const canHide = !header.isPlaceholder && !isGroup && header.column.getCanHide();\n const canMeasureSize = !!table.getRowModel().rows.length;\n const canPin = !header.isPlaceholder && !isGroup && header.column.getCanPin();\n const canResize = !header.isPlaceholder && !isGroup && header.column.getCanResize();\n const canSort = !header.isPlaceholder && !isGroup && header.column.getCanSort();\n const canGoto = canSort && !header.isPlaceholder && !isGroup && tableMeta.rowGoto.isEnabled && !!header.column.getIsSorted();\n\n const hasMenu = !isInternalColumn(header.id) && (canHide || canGoto || canPin || canSort || !!columnMeta.menu);\n\n const sorting = table.getState().sorting;\n const filters = table.getState().columnFilters;\n const search = table.getState().globalFilter;\n\n // passing header or column results in re-renders on scroll, so anything from those objects as memoed props\n const memoedProps: MemoedHeaderProps = {\n align: columnMeta.align,\n canFilter,\n canHide,\n canGoto,\n canMeasureSize,\n canPin,\n canResize,\n canSort,\n className: cn('group/header', columnMeta.headerClassName),\n children: flexRender(header.column.columnDef.header, header.getContext()),\n colSpan: header.colSpan,\n customMenu: columnMeta.menu,\n defaultWidth: columnMeta.defaultWidth,\n hasMenu,\n id: header.id,\n isFiltered: header.column.getIsFiltered(),\n index: header.index,\n isGroup,\n isPinned,\n isPlaceholder: header.isPlaceholder,\n offset: header.column.getStart(isPinned),\n scrollToIndex,\n setRowActiveIndex: tableMeta.rowActive.setRowActiveIndex,\n setColumnSizing: table.setColumnSizing,\n tooltip: columnMeta.tooltip,\n width: table.getState().columnSizing[header.id],\n };\n\n if (header.isPlaceholder) {\n const nextHeader = header.headerGroup.headers[header.index + 1];\n memoedProps.className = cn('!bg-white before:!content-none', memoedProps.className, {\n 'after:!content-none': nextHeader?.isPlaceholder,\n });\n }\n\n if (canFilter) {\n memoedProps.onFilter = () => {\n header.column.setFilterValue({ comparator: TableFilterComparator.Contains });\n };\n }\n\n if (canGoto) {\n memoedProps.onGoto = ((query: string) => tableMeta.rowGoto.handleGoto?.(header.id, query, sorting, filters, search)) as (\n query: string\n ) => Promise<number>;\n }\n\n if (canHide) {\n memoedProps.onHide = header.column.getToggleVisibilityHandler();\n }\n\n if (canPin) {\n memoedProps.onPin = (index: number | undefined) => {\n // TODO: this can probably be moved to a feature hook\n table.setColumnPinning(pinningState => {\n return {\n ...pinningState,\n left:\n index === undefined\n ? unfreezeAllExternalColumns(pinningState.left)\n : freezeUptoExternalColumn(\n index,\n table.getAllLeafColumns().map(column => column.id)\n ),\n };\n });\n };\n }\n\n if (canResize) {\n memoedProps.isResizing = header.column.getIsResizing();\n memoedProps.onResize = header.getResizeHandler();\n }\n\n if (canSort) {\n const handleSortToggle = (sortDirection: TableColumnSortDirection | false) => {\n if (sortDirection === false) {\n header.column.clearSorting();\n } else {\n header.column.toggleSorting(sortDirection === 'desc');\n }\n };\n\n memoedProps.onSort = header.column.getToggleSortingHandler();\n memoedProps.onSortToggle = handleSortToggle;\n memoedProps.sortDirection = header.column.getIsSorted();\n }\n\n return <MemoedHeader key={header.id} {...memoedProps} />;\n}\n\nexport type MemoedHeaderProps = {\n align?: TableColumnAlignment;\n canFilter: boolean;\n canHide: boolean;\n canGoto: boolean;\n canMeasureSize: boolean;\n canPin: boolean;\n canResize: boolean;\n canSort: boolean;\n children: JSX.Element | React.ReactNode;\n className?: string;\n colSpan: number;\n customMenu?: TableColumnMenu;\n defaultWidth?: TableColumnWidth;\n hasMenu: boolean;\n id: string;\n index: number;\n isFiltered: boolean;\n isGroup: boolean;\n isPinned?: ReactTableColumnPinningPosition;\n isPlaceholder: boolean;\n isResizing?: boolean;\n offset?: number;\n onFilter?: () => void;\n onGoto?: (query: string) => Promise<number>;\n onHide?: (event: unknown) => void;\n onPin?: (index: number | undefined) => void;\n onResize?: (event: unknown) => void;\n onSort?: (event: unknown) => void;\n onSortToggle?: (sortDirection: TableColumnSortDirection | false) => void;\n scrollToIndex: (index: number) => void;\n setRowActiveIndex: (index: number) => void;\n setColumnSizing: any;\n sortDirection?: TableColumnSortDirection | false;\n tooltip?: string;\n width?: TableColumnWidth;\n};\n\nconst MemoedHeader = React.memo(function MemoedHeader(props: MemoedHeaderProps) {\n const {\n align,\n canFilter,\n canGoto,\n canHide,\n canMeasureSize,\n canPin,\n canResize,\n canSort,\n children,\n className,\n colSpan,\n customMenu,\n defaultWidth,\n hasMenu,\n id,\n index,\n isFiltered,\n isGroup,\n isPinned,\n isPlaceholder,\n isResizing,\n offset,\n onFilter: handleFilter,\n onGoto: handleGoto,\n onHide: handleHide,\n onPin: handlePin,\n onResize: handleResize,\n onSort: handleSort,\n onSortToggle: handleSortToggle,\n scrollToIndex,\n setRowActiveIndex,\n setColumnSizing,\n sortDirection,\n tooltip,\n width,\n } = props;\n const [ref, setRef] = React.useState<HTMLTableCellElement | null>(null);\n\n // save column width if none is set\n useSetInitialColumnSizing(id, defaultWidth, width, ref, canMeasureSize, setColumnSizing);\n\n // feature specific styles\n const style: React.CSSProperties = {};\n\n // column groups often span multiple columns\n if (colSpan > 1) {\n style.gridColumn = `span ${colSpan}`;\n }\n\n // pinned columns should be offset from either the left or right\n if (isPinned) {\n style[isPinned] = `${offset}px`;\n }\n\n return (\n <th\n {...getSortAttributes(canSort, handleSort, sortDirection)}\n className={className}\n data-cell-align={isGroup ? 'center' : align}\n data-cell-id={id}\n data-cell-pinned={isPinned ? isPinned : undefined}\n style={style}\n ref={setRef}>\n {isPlaceholder ? null : isInternalColumn(id) ? (\n children\n ) : (\n <Tooltip title={String(tooltip ?? children)} placement=\"top\">\n <span className=\"truncate\">{children}</span>\n </Tooltip>\n )}\n {sortDirection ? <SortIndicator direction={sortDirection} /> : null}\n {hasMenu ? (\n <HeaderMenu\n canFilter={canFilter}\n canGoto={canGoto}\n canHide={canHide}\n canPin={canPin}\n canSort={canSort}\n className={cn({\n 'ml-auto': align !== 'right',\n 'ml-0': align === 'right',\n })}\n customMenu={customMenu}\n index={index}\n isFiltered={isFiltered}\n onFilter={handleFilter}\n onGoto={handleGoto}\n onHide={handleHide}\n onPin={handlePin}\n onSortToggle={handleSortToggle}\n scrollToIndex={scrollToIndex}\n setRowActiveIndex={setRowActiveIndex}\n sortDirection={sortDirection}\n columnId={id}\n />\n ) : null}\n {canResize ? (\n <Resizer\n headerRef={ref}\n id={id}\n isResizing={isResizing as boolean}\n onResize={handleResize as (event: unknown) => void}\n setColumnSizing={setColumnSizing}\n width={width}\n />\n ) : null}\n </th>\n );\n});\n"],"names":["Header","props","header","scrollToIndex","column","getIsGrouped","table","getContext","tableMeta","options","meta","columnMeta","_header$column$column","columnDef","isGroup","subHeaders","length","isPinned","getIsPinned","canFilter","isPlaceholder","getCanFilter","enableColumnFilters","canHide","getCanHide","canMeasureSize","getRowModel","rows","canPin","getCanPin","canResize","getCanResize","canSort","getCanSort","canGoto","rowGoto","isEnabled","getIsSorted","hasMenu","isInternalColumn","id","menu","sorting","getState","filters","columnFilters","search","globalFilter","memoedProps","align","className","cn","headerClassName","children","flexRender","colSpan","customMenu","defaultWidth","isFiltered","getIsFiltered","index","offset","getStart","setRowActiveIndex","rowActive","setColumnSizing","tooltip","width","columnSizing","nextHeader","headerGroup","headers","onFilter","setFilterValue","comparator","TableFilterComparator","Contains","onGoto","query","_tableMeta$rowGoto$ha","_tableMeta$rowGoto","handleGoto","call","onHide","getToggleVisibilityHandler","onPin","setColumnPinning","pinningState","left","undefined","unfreezeAllExternalColumns","freezeUptoExternalColumn","getAllLeafColumns","map","isResizing","getIsResizing","onResize","getResizeHandler","handleSortToggle","sortDirection","clearSorting","toggleSorting","onSort","getToggleSortingHandler","onSortToggle","React","MemoedHeader","key","memo","handleFilter","handleHide","handlePin","handleResize","handleSort","ref","setRef","useState","useSetInitialColumnSizing","style","gridColumn","getSortAttributes","Tooltip","title","String","placement","SortIndicator","direction","HeaderMenu","columnId","Resizer","headerRef"],"mappings":";;;;;;;;;;;SA4BgBA,MAAMA,CAAkBC,KAAyB;;EAC7D,MAAM;IAAEC,MAAM;IAAEC;GAAe,GAAGF,KAAK;EAEvC,IAAIC,MAAM,CAACE,MAAM,CAACC,YAAY,EAAE,EAAE;IAC9B,OAAO,IAAI;;EAGf,MAAM;IAAEC;GAAO,GAAGJ,MAAM,CAACK,UAAU,EAAE;EAErC,MAAMC,SAAS,GAAGF,KAAK,CAACG,OAAO,CAACC,IAA6B;EAC7D,MAAMC,UAAU,IAAAC,qBAAA,GAAIV,MAAM,CAACE,MAAM,CAACS,SAAS,CAACH,IAAI,cAAAE,qBAAA,cAAAA,qBAAA,GAAI,EAA2C;EAE/F,MAAME,OAAO,GAAG,CAAC,CAACZ,MAAM,CAACa,UAAU,CAACC,MAAM;EAC1C,MAAMC,QAAQ,GAAGC,WAAW,CAAChB,MAAM,CAAC;EAEpC,MAAMiB,SAAS,GAAG,CAACjB,MAAM,CAACkB,aAAa,IAAIlB,MAAM,CAACE,MAAM,CAACiB,YAAY,EAAE,IAAI,CAAC,CAACf,KAAK,CAACG,OAAO,CAACa,mBAAmB;EAC9G,MAAMC,OAAO,GAAG,CAACrB,MAAM,CAACkB,aAAa,IAAI,CAACN,OAAO,IAAIZ,MAAM,CAACE,MAAM,CAACoB,UAAU,EAAE;EAC/E,MAAMC,cAAc,GAAG,CAAC,CAACnB,KAAK,CAACoB,WAAW,EAAE,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C,aAAa,EAAEA,aAAa;IAC5B6B,QAAQ,EAAExF;IACZ,IACF,IAAI,EACPV,SAAS,kBACN2E,6BAACwB,OAAO;IACJC,SAAS,EAAEhB,GAAG;IACd1E,EAAE,EAAEA,EAAE;IACNsD,UAAU,EAAEA,UAAqB;IACjCE,QAAQ,EAAEgB,YAAwC;IAClD/C,eAAe,EAAEA,eAAe;IAChCE,KAAK,EAAEA;IACT,IACF,IAAI,CACP;AAEb,CAAC,CAAC;;;;"}
@@ -13,6 +13,7 @@ function HeaderMenu(props) {
13
13
  canHide,
14
14
  canPin,
15
15
  canSort,
16
+ columnId,
16
17
  customMenu,
17
18
  index,
18
19
  isFiltered,
@@ -116,10 +117,7 @@ function HeaderMenu(props) {
116
117
  }, isFiltered ? texts.table.columns.menu.editFilter : texts.table.columns.menu.filter));
117
118
  }
118
119
  if (customMenu) {
119
- const menu = customMenu({
120
- trigger: undefined
121
- });
122
- const customItems = React__default.Children.toArray(menu.props.children.props.children);
120
+ const customItems = customMenu.map(menuItem => menuItem(columnId)).filter(action => !!action);
123
121
  if (customItems.length) {
124
122
  if (menuItems.length) {
125
123
  menuItems.push( /*#__PURE__*/React__default.createElement(Menu.Separator, null));
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.js","sources":["../../../../../../../../../../../src/primitives/Table/Core/components/Header/components/Menu.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { IconButton } from '../../../../../../components/IconButton/IconButton';\nimport { Menu as MenuPrimitive } from '../../../../../../components/Menu/Menu';\nimport { useLocalization } from '../../../../../../components/Provider/Localization';\nimport { GotoPopover } from './Goto';\nimport { TableColumnMenu, TableColumnSortDirection } from '../../../../types';\n\nexport type HeaderMenuProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {\n canFilter: boolean;\n canGoto: boolean;\n canHide: boolean;\n canPin: boolean;\n canSort: boolean;\n customMenu?: TableColumnMenu;\n index: number;\n isFiltered: boolean;\n onFilter?: () => void;\n onGoto?: (query: string) => Promise<number>;\n onHide?: (event: unknown) => void;\n onPin?: (index: number | undefined) => void;\n onSortToggle?: (sortDirection: TableColumnSortDirection | false) => void;\n scrollToIndex: (index: number) => void;\n setRowActiveIndex: (index: number) => void;\n sortDirection?: TableColumnSortDirection | false;\n};\n\nexport function HeaderMenu(props: HeaderMenuProps) {\n const {\n canFilter,\n canGoto,\n canHide,\n canPin,\n canSort,\n customMenu,\n index,\n isFiltered,\n onFilter: handleFilter,\n onGoto: handleGoto,\n onHide: handleHide,\n onPin: handlePin,\n onSortToggle: handleSortToggle,\n scrollToIndex,\n setRowActiveIndex,\n sortDirection,\n } = props;\n const { texts } = useLocalization();\n const [popover, setPopover] = React.useState<string | undefined>(undefined);\n\n let popoverElement;\n\n if (popover) {\n const handleClosePopover = () => setPopover(undefined);\n\n switch (popover) {\n case 'goto': {\n if (handleGoto) {\n const goto = async (query: string) => {\n try {\n const index = await handleGoto(query);\n setRowActiveIndex(index);\n scrollToIndex(index);\n } catch (e) {\n console.error(e);\n //\n } finally {\n handleClosePopover();\n }\n };\n popoverElement = props => <GotoPopover {...props} open onChange={handleClosePopover} onGoto={goto} />;\n }\n }\n }\n }\n\n const memoedMenuItems = React.useMemo(() => {\n const menuItems: JSX.Element[] = [];\n\n if (canHide && handleHide) {\n // we do this in the next tick, otherwise the menu closes and react throws a \"state update on unmounted component\" error\n const handleClick = event => setTimeout(() => handleHide(event), 1);\n\n menuItems.push(\n <MenuPrimitive.Item icon=\"eye-off\" onClick={handleClick}>\n {texts.table.columns.menu.hideColumn}\n </MenuPrimitive.Item>\n );\n }\n\n if (canSort) {\n menuItems.push(\n <MenuPrimitive.Item\n icon=\"sort-by\"\n subMenu={() => (\n <MenuPrimitive.SubMenu>\n <MenuPrimitive.RadioGroup onChange={handleSortToggle as any} value={sortDirection}>\n <MenuPrimitive.RadioGroup.Item value=\"asc\">\n {texts.table.columns.menu.sortingOrder.ascending}\n </MenuPrimitive.RadioGroup.Item>\n <MenuPrimitive.RadioGroup.Item value=\"desc\">\n {texts.table.columns.menu.sortingOrder.descending}\n </MenuPrimitive.RadioGroup.Item>\n <MenuPrimitive.RadioGroup.Item value={false}>\n {texts.table.columns.menu.sortingOrder.unsorted}\n </MenuPrimitive.RadioGroup.Item>\n </MenuPrimitive.RadioGroup>\n </MenuPrimitive.SubMenu>\n )}>\n {texts.table.columns.menu.sorting}\n </MenuPrimitive.Item>\n );\n }\n\n if (canGoto) {\n menuItems.push(\n <MenuPrimitive.Item icon=\"move\" onClick={() => setPopover('goto')} shortcut=\"g\">\n {texts.table.columns.menu.gotoRow}...\n </MenuPrimitive.Item>\n );\n }\n\n if (canPin && handlePin) {\n menuItems.push(\n <MenuPrimitive.Item icon=\"column-freeze\" onClick={() => handlePin(index)}>\n {index === 0\n ? texts.table.columns.menu.freezeFirstColumn\n : texts.table.columns.menu.freezeUptoColumn.replace('[TOTAL]', String(index + 1))}\n </MenuPrimitive.Item>\n );\n\n menuItems.push(\n <MenuPrimitive.Item icon=\"column-unfreeze\" onClick={() => handlePin(undefined)}>\n {texts.table.columns.menu.unfreezeColumns}\n </MenuPrimitive.Item>\n );\n }\n if (canFilter && handleFilter) {\n menuItems.push(\n <MenuPrimitive.Item icon={isFiltered ? 'filter-solid' : 'filter'} onClick={() => handleFilter()}>\n {isFiltered ? texts.table.columns.menu.editFilter : texts.table.columns.menu.filter}\n </MenuPrimitive.Item>\n );\n }\n\n if (customMenu) {\n const menu = customMenu({ trigger: undefined });\n const customItems = React.Children.toArray(menu.props.children.props.children) as JSX.Element[];\n\n if (customItems.length) {\n if (menuItems.length) {\n menuItems.push(<MenuPrimitive.Separator />);\n }\n\n menuItems.push(...customItems);\n }\n }\n\n return menuItems.map((item, key) => React.cloneElement(item, { key }));\n }, [\n canFilter,\n canGoto,\n canHide,\n canPin,\n canSort,\n customMenu,\n handleGoto,\n handleSortToggle,\n index,\n isFiltered,\n sortDirection,\n ]);\n\n // can't use display: none because the button needs to be focusable\n const className = cn(\n // positioning\n 'justify-end overflow-hidden',\n // sizing\n '!h-6 !w-0 !min-h-[theme(spacing.6)] !min-w-0',\n // visible - hover\n 'group-hover/header:!w-6 group-hover/header:!min-w-[theme(spacing.6)] group-hover/header:-mr-1',\n // visible - expanded\n 'aria-expanded:!w-6 aria-expanded:!min-w-[theme(spacing.6)]',\n // visible - focus\n 'focus:!w-6 focus:!min-w-[theme(spacing.6)]',\n {\n '!w-6 !min-w-[theme(spacing.6)]': !!popoverElement,\n },\n props.className\n );\n\n return (\n <IconButton\n className={className}\n icon=\"more\"\n menu={\n popoverElement\n ? undefined\n : menuProps => (\n <MenuPrimitive {...menuProps}>\n <MenuPrimitive.Content>{memoedMenuItems}</MenuPrimitive.Content>\n </MenuPrimitive>\n )\n }\n popover={popoverElement}\n onClickCapture={event => event.preventDefault()}\n onKeyDown={event => {\n // Removes focus from the column header menu button so that active row shortcuts execute when Tab,\n // Shift+Tab, or any other keydown event occurs.\n if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {\n event.currentTarget?.blur();\n }\n }}\n />\n );\n}\n"],"names":["HeaderMenu","props","canFilter","canGoto","canHide","canPin","canSort","customMenu","index","isFiltered","onFilter","handleFilter","onGoto","handleGoto","onHide","handleHide","onPin","handlePin","onSortToggle","handleSortToggle","scrollToIndex","setRowActiveIndex","sortDirection","texts","useLocalization","popover","setPopover","React","useState","undefined","popoverElement","handleClosePopover","goto","query","Promise","resolve","then","e","console","error","_wasThrown","_result","_temp","reject","GotoPopover","open","onChange","memoedMenuItems","useMemo","menuItems","handleClick","event","setTimeout","push","MenuPrimitive","Item","icon","onClick","table","columns","menu","hideColumn","subMenu","SubMenu","RadioGroup","value","sortingOrder","ascending","descending","unsorted","sorting","shortcut","gotoRow","freezeFirstColumn","freezeUptoColumn","replace","String","unfreezeColumns","editFilter","filter","trigger","customItems","Children","toArray","children","length","Separator","map","item","key","cloneElement","className","cn","IconButton","menuProps","Content","onClickCapture","preventDefault","onKeyDown","_event$currentTarget","currentTarget","blur"],"mappings":";;;;;;;;SA2B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,CAACyC,OAAO,QAAEhD,eAAe,CAAyB,CACpD,CACnB;IAEXtB,OAAO,EAAEK,cAAc;IACvBkE,cAAc,EAAE7C,KAAK,IAAIA,KAAK,CAAC8C,cAAc,EAAE;IAC/CC,SAAS,EAAE/C,KAAK;;;MAGZ,IAAIA,KAAK,CAACsC,GAAG,KAAK,SAAS,IAAItC,KAAK,CAACsC,GAAG,KAAK,WAAW,EAAE;QAAA,IAAAU,oBAAA;QACtD,CAAAA,oBAAA,GAAAhD,KAAK,CAACiD,aAAa,cAAAD,oBAAA,uBAAnBA,oBAAA,CAAqBE,IAAI,EAAE;;;IAGrC;AAEV;;;;"}
1
+ {"version":3,"file":"Menu.js","sources":["../../../../../../../../../../../src/primitives/Table/Core/components/Header/components/Menu.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { IconButton } from '../../../../../../components/IconButton/IconButton';\nimport { Menu as MenuPrimitive } from '../../../../../../components/Menu/Menu';\nimport { useLocalization } from '../../../../../../components/Provider/Localization';\nimport { GotoPopover } from './Goto';\nimport { TableColumnMenu, TableColumnSortDirection } from '../../../../types';\n\nexport type HeaderMenuProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {\n canFilter: boolean;\n canGoto: boolean;\n canHide: boolean;\n canPin: boolean;\n canSort: boolean;\n columnId: string;\n customMenu?: TableColumnMenu;\n index: number;\n isFiltered: boolean;\n onFilter?: () => void;\n onGoto?: (query: string) => Promise<number>;\n onHide?: (event: unknown) => void;\n onPin?: (index: number | undefined) => void;\n onSortToggle?: (sortDirection: TableColumnSortDirection | false) => void;\n scrollToIndex: (index: number) => void;\n setRowActiveIndex: (index: number) => void;\n sortDirection?: TableColumnSortDirection | false;\n};\n\nexport function HeaderMenu(props: HeaderMenuProps) {\n const {\n canFilter,\n canGoto,\n canHide,\n canPin,\n canSort,\n columnId,\n customMenu,\n index,\n isFiltered,\n onFilter: handleFilter,\n onGoto: handleGoto,\n onHide: handleHide,\n onPin: handlePin,\n onSortToggle: handleSortToggle,\n scrollToIndex,\n setRowActiveIndex,\n sortDirection,\n } = props;\n const { texts } = useLocalization();\n const [popover, setPopover] = React.useState<string | undefined>(undefined);\n\n let popoverElement;\n\n if (popover) {\n const handleClosePopover = () => setPopover(undefined);\n\n switch (popover) {\n case 'goto': {\n if (handleGoto) {\n const goto = async (query: string) => {\n try {\n const index = await handleGoto(query);\n setRowActiveIndex(index);\n scrollToIndex(index);\n } catch (e) {\n console.error(e);\n //\n } finally {\n handleClosePopover();\n }\n };\n popoverElement = props => <GotoPopover {...props} open onChange={handleClosePopover} onGoto={goto} />;\n }\n }\n }\n }\n\n const memoedMenuItems = React.useMemo(() => {\n const menuItems: JSX.Element[] = [];\n\n if (canHide && handleHide) {\n // we do this in the next tick, otherwise the menu closes and react throws a \"state update on unmounted component\" error\n const handleClick = event => setTimeout(() => handleHide(event), 1);\n\n menuItems.push(\n <MenuPrimitive.Item icon=\"eye-off\" onClick={handleClick}>\n {texts.table.columns.menu.hideColumn}\n </MenuPrimitive.Item>\n );\n }\n\n if (canSort) {\n menuItems.push(\n <MenuPrimitive.Item\n icon=\"sort-by\"\n subMenu={() => (\n <MenuPrimitive.SubMenu>\n <MenuPrimitive.RadioGroup onChange={handleSortToggle as any} value={sortDirection}>\n <MenuPrimitive.RadioGroup.Item value=\"asc\">\n {texts.table.columns.menu.sortingOrder.ascending}\n </MenuPrimitive.RadioGroup.Item>\n <MenuPrimitive.RadioGroup.Item value=\"desc\">\n {texts.table.columns.menu.sortingOrder.descending}\n </MenuPrimitive.RadioGroup.Item>\n <MenuPrimitive.RadioGroup.Item value={false}>\n {texts.table.columns.menu.sortingOrder.unsorted}\n </MenuPrimitive.RadioGroup.Item>\n </MenuPrimitive.RadioGroup>\n </MenuPrimitive.SubMenu>\n )}>\n {texts.table.columns.menu.sorting}\n </MenuPrimitive.Item>\n );\n }\n\n if (canGoto) {\n menuItems.push(\n <MenuPrimitive.Item icon=\"move\" onClick={() => setPopover('goto')} shortcut=\"g\">\n {texts.table.columns.menu.gotoRow}...\n </MenuPrimitive.Item>\n );\n }\n\n if (canPin && handlePin) {\n menuItems.push(\n <MenuPrimitive.Item icon=\"column-freeze\" onClick={() => handlePin(index)}>\n {index === 0\n ? texts.table.columns.menu.freezeFirstColumn\n : texts.table.columns.menu.freezeUptoColumn.replace('[TOTAL]', String(index + 1))}\n </MenuPrimitive.Item>\n );\n\n menuItems.push(\n <MenuPrimitive.Item icon=\"column-unfreeze\" onClick={() => handlePin(undefined)}>\n {texts.table.columns.menu.unfreezeColumns}\n </MenuPrimitive.Item>\n );\n }\n if (canFilter && handleFilter) {\n menuItems.push(\n <MenuPrimitive.Item icon={isFiltered ? 'filter-solid' : 'filter'} onClick={() => handleFilter()}>\n {isFiltered ? texts.table.columns.menu.editFilter : texts.table.columns.menu.filter}\n </MenuPrimitive.Item>\n );\n }\n\n if (customMenu) {\n const customItems = customMenu.map(menuItem => menuItem(columnId)).filter(action => !!action) as JSX.Element[];\n\n if (customItems.length) {\n if (menuItems.length) {\n menuItems.push(<MenuPrimitive.Separator />);\n }\n\n menuItems.push(...customItems);\n }\n }\n\n return menuItems.map((item, key) => React.cloneElement(item, { key }));\n }, [\n canFilter,\n canGoto,\n canHide,\n canPin,\n canSort,\n customMenu,\n handleGoto,\n handleSortToggle,\n index,\n isFiltered,\n sortDirection,\n ]);\n\n // can't use display: none because the button needs to be focusable\n const className = cn(\n // positioning\n 'justify-end overflow-hidden',\n // sizing\n '!h-6 !w-0 !min-h-[theme(spacing.6)] !min-w-0',\n // visible - hover\n 'group-hover/header:!w-6 group-hover/header:!min-w-[theme(spacing.6)] group-hover/header:-mr-1',\n // visible - expanded\n 'aria-expanded:!w-6 aria-expanded:!min-w-[theme(spacing.6)]',\n // visible - focus\n 'focus:!w-6 focus:!min-w-[theme(spacing.6)]',\n {\n '!w-6 !min-w-[theme(spacing.6)]': !!popoverElement,\n },\n props.className\n );\n\n return (\n <IconButton\n className={className}\n icon=\"more\"\n menu={\n popoverElement\n ? undefined\n : menuProps => (\n <MenuPrimitive {...menuProps}>\n <MenuPrimitive.Content>{memoedMenuItems}</MenuPrimitive.Content>\n </MenuPrimitive>\n )\n }\n popover={popoverElement}\n onClickCapture={event => event.preventDefault()}\n onKeyDown={event => {\n // Removes focus from the column header menu button so that active row shortcuts execute when Tab,\n // Shift+Tab, or any other keydown event occurs.\n if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {\n event.currentTarget?.blur();\n }\n }}\n />\n );\n}\n"],"names":["HeaderMenu","props","canFilter","canGoto","canHide","canPin","canSort","columnId","customMenu","index","isFiltered","onFilter","handleFilter","onGoto","handleGoto","onHide","handleHide","onPin","handlePin","onSortToggle","handleSortToggle","scrollToIndex","setRowActiveIndex","sortDirection","texts","useLocalization","popover","setPopover","React","useState","undefined","popoverElement","handleClosePopover","goto","query","Promise","resolve","then","e","console","error","_wasThrown","_result","_temp","reject","GotoPopover","open","onChange","memoedMenuItems","useMemo","menuItems","handleClick","event","setTimeout","push","MenuPrimitive","Item","icon","onClick","table","columns","menu","hideColumn","subMenu","SubMenu","RadioGroup","value","sortingOrder","ascending","descending","unsorted","sorting","shortcut","gotoRow","freezeFirstColumn","freezeUptoColumn","replace","String","unfreezeColumns","editFilter","filter","customItems","map","menuItem","action","length","Separator","item","key","cloneElement","className","cn","IconButton","menuProps","Content","onClickCapture","preventDefault","onKeyDown","_event$currentTarget","currentTarget","blur"],"mappings":";;;;;;;;SA4BgBA,UAAUA,CAACC,KAAsB;EAC7C,MAAM;IACFC,SAAS;IACTC,OAAO;IACPC,OAAO;IACPC,MAAM;IACNC,OAAO;IACPC,QAAQ;IACRC,UAAU;IACVC,KAAK;IACLC,UAAU;IACVC,QAAQ,EAAEC,YAAY;IACtBC,MAAM,EAAEC,UAAU;IAClBC,MAAM,EAAEC,UAAU;IAClBC,KAAK,EAAEC,SAAS;IAChBC,YAAY,EAAEC,gBAAgB;IAC9BC,aAAa;IACbC,iBAAiB;IACjBC;GACH,GAAGtB,KAAK;EACT,MAAM;I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C;AAEV;;;;"}
@@ -30,8 +30,7 @@ const DisplayRow = /*#__PURE__*/React__default.memo(function DisplayRow(props) {
30
30
  tableMeta.rowClick.handleClick(event, row.original);
31
31
  }, [row.original]);
32
32
  const handleClickCapture = React__default.useCallback(() => {
33
- // do this in the next frame, otherwise it remounts the row and prevents row actions on hover from being clickable
34
- requestAnimationFrame(() => tableMeta.rowActive.setRowActiveIndex(index));
33
+ tableMeta.rowActive.setRowActiveIndex(index);
35
34
  }, [index]);
36
35
  // row active
37
36
  if (tableMeta.rowActive.isEnabled) {
@@ -40,7 +39,7 @@ const DisplayRow = /*#__PURE__*/React__default.memo(function DisplayRow(props) {
40
39
  attributes.onClickCapture = handleClickCapture;
41
40
  }
42
41
  // row click
43
- if (tableMeta.rowClick.isEnabled) {
42
+ if (tableMeta.rowClick.isEnabled(row.original)) {
44
43
  attributes.onClick = handleClick;
45
44
  }
46
45
  // row drag
@@ -1 +1 @@
1
- {"version":3,"file":"DisplayRow.js","sources":["../../../../../../../../../../../src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport cn from 'clsx';\nimport { Cell } from '../../Columns/Cell/Cell';\nimport { TableRowRendererProps } from '../../../types';\nimport { TableRowWithMetaData } from '../../../../types';\nimport { isElementInteractive } from '../../../../../../utils/dom';\nimport { useDropTarget } from '../../../../../../utils/hooks/useDropTarget';\n\nexport type DisplayRowProps<TType = unknown> = React.HTMLAttributes<HTMLTableRowElement> & TableRowRendererProps<TType>;\n\nexport const DisplayRow = React.memo(function DisplayRow<TType = unknown>(props: DisplayRowProps<TType>) {\n const { children, cellRenderer: CellRenderer, index, measureRow, row, table, ...otherAttributes } = props;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const attributes: any = {\n ...otherAttributes,\n 'data-row-id': row.id,\n 'data-row-index': index,\n tabIndex: -1,\n };\n\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLTableRowElement>) => {\n const clickedElement = event.target as HTMLElement;\n\n if (!event.currentTarget?.contains(event.target as HTMLElement) || isElementInteractive(clickedElement)) {\n return;\n }\n\n tableMeta.rowClick.handleClick(event, row.original);\n },\n [row.original]\n );\n const handleClickCapture = React.useCallback(() => {\n // do this in the next frame, otherwise it remounts the row and prevents row actions on hover from being clickable\n requestAnimationFrame(() => tableMeta.rowActive.setRowActiveIndex(index));\n }, [index]);\n\n // row active\n if (tableMeta.rowActive.isEnabled) {\n attributes['data-row-active'] = tableMeta.rowActive.rowActiveIndex === index ? true : undefined;\n // we use capture because it let's us picks up clicks on components inside the row, e.g. checkboxes\n attributes.onClickCapture = handleClickCapture;\n }\n\n // row click\n if (tableMeta.rowClick.isEnabled) {\n attributes.onClick = handleClick;\n }\n\n // row drag\n if (tableMeta.rowDrag.isEnabled) {\n attributes['aria-grabbed'] = !!tableMeta.rowDrag.dragging[row.id];\n }\n\n // row drop\n const [isDraggedOver, dropTargetProps] = useDropTarget(event => tableMeta.rowDrop.handleDrop?.(event, row.original));\n\n if (tableMeta.rowDrop.isEnabled) {\n attributes.onDragEnter = dropTargetProps?.onDragEnter;\n attributes.onDragLeave = dropTargetProps?.onDragLeave;\n attributes.onDragOver = dropTargetProps?.onDragOver;\n attributes.onDrop = dropTargetProps?.onDrop;\n attributes['data-row-dragged-over'] = isDraggedOver;\n }\n\n // row grouping\n if (table.options.enableGrouping) {\n attributes['data-row-group'] = row.getIsGrouped() ? true : undefined;\n }\n\n // row selection\n if (table.options.enableRowSelection) {\n attributes['data-row-selected'] = row.getIsSelected() || row.getIsAllSubRowsSelected() ? true : undefined;\n }\n\n // row expansion\n let expandedRow;\n\n if (tableMeta.rowExpansion.isEnabled && row.getIsExpanded()) {\n attributes['data-row-expanded'] = true;\n expandedRow = tableMeta.rowExpansion.rowExpansionRenderer?.(row.original)?.();\n }\n\n const rowMeta = (row.original as TableRowWithMetaData<TType>)._meta;\n\n if (rowMeta) {\n if (rowMeta.layout) {\n attributes['data-row-meta-layout'] = rowMeta.layout;\n }\n }\n\n const ref = React.useRef<HTMLTableRowElement>(null);\n const expansionRef = React.useRef<HTMLTableRowElement>(null);\n const isExpanded = !!attributes['data-row-expanded'];\n\n useSetVirtualisedRowHeight(measureRow, ref.current, expansionRef.current, isExpanded);\n\n const className = cn('group/row', {\n 'hover:cursor-pointer': typeof attributes.onClick === 'function',\n });\n\n return (\n <>\n <tr {...attributes} className={className} ref={ref}>\n {children}\n {row.getVisibleCells().map((cell, cellIndex) => (\n <Cell key={cell.id} cell={cell} index={cellIndex} renderer={CellRenderer} />\n ))}\n </tr>\n {expandedRow ? (\n <tr data-row-parent-id={row.id} ref={expansionRef}>\n <td className=\"col-span-full\">{expandedRow}</td>\n </tr>\n ) : null}\n </>\n );\n}) as <TType = unknown>(props: TableRowRendererProps<TType>) => JSX.Element;\n\nfunction useSetVirtualisedRowHeight(\n measureRow: (size: number, expansionHeight?: number) => void,\n rowEl: HTMLTableRowElement | null,\n expansionEl: HTMLTableRowElement | null,\n isExpanded: boolean\n) {\n React.useEffect(() => {\n if (rowEl) {\n const height = rowEl.getBoundingClientRect().height;\n\n if (isExpanded && expansionEl) {\n measureRow(height, expansionEl.getBoundingClientRect().height);\n } else {\n measureRow(height);\n }\n }\n }, [isExpanded, rowEl, expansionEl]);\n}\n"],"names":["DisplayRow","React","memo","props","children","cellRenderer","CellRenderer","index","measureRow","row","table","otherAttributes","tableMeta","options","meta","attributes","id","tabIndex","handleClick","useCallback","event","clickedElement","target","_event$currentTarget","currentTarget","contains","isElementInteractive","rowClick","original","handleClickCapture","requestAnimationFrame","rowActive","setRowActiveIndex","isEnabled","rowActiveIndex","undefined","onClickCapture","onClick","rowDrag","dragging","isDraggedOver","dropTargetProps","useDropTarget","_tableMeta$rowDrop$ha","_tableMeta$rowDrop","rowDrop","handleDrop","call","onDragEnter","onDragLeave","onDragOver","onDrop","enableGrouping","getIsGrouped","enableRowSelection","getIsSelected","getIsAllSubRowsSelected","expandedRow","rowExpansion","getIsExpanded","_tableMeta$rowExpansi","_tableMeta$rowExpansi2","_tableMeta$rowExpansi3","rowExpansionRenderer","rowMeta","_meta","layout","ref","useRef","expansionRef","isExpanded","useSetVirtualisedRowHeight","current","className","cn","getVisibleCells","map","cell","cellIndex","Cell","key","renderer","rowEl","expansionEl","useEffect","height","getBoundingClientRect"],"mappings":";;;;;;MAWaA,UAAU,gBAAGC,cAAK,CAACC,IAAI,CAAC,SAASF,UAAUA,CAAkBG,KAA6B;EACnG,MAAM;IAAEC,QAAQ;IAAEC,YAAY,EAAEC,YAAY;IAAEC,KAAK;IAAEC,UAAU;IAAEC,GAAG;IAAEC,KAAK;IAAE,GAAGC;GAAiB,GAAGR,KAAK;EACzG,MAAMS,SAAS,GAAGF,KAAK,CAACG,OAAO,CAACC,IAA6B;EAE7D,MAAMC,UAAU,GAAQ;IACpB,GAAGJ,eAAe;IAClB,aAAa,EAAEF,GAAG,CAACO,EAAE;IACrB,gBAAgB,EAAET,KAAK;IACvBU,QAAQ,EAAE,CAAC;GACd;EAED,MAAMC,WAAW,GAAGjB,cAAK,CAACkB,WAAW,CAChCC,KAA4C;;IACzC,MAAMC,cAAc,GAAGD,KAAK,CAACE,MAAqB;IAElD,IAAI,GAAAC,oBAAA,GAACH,KAAK,CAACI,aAAa,cAAAD,oBAAA,eAAnBA,oBAAA,CAAqBE,QAAQ,CAACL,KAAK,CAACE,MAAqB,CAAC,KAAII,oBAAoB,CAACL,cAAc,CAAC,EAAE;MACrG;;IAGJT,SAAS,CAACe,QAAQ,CAACT,WAAW,CAACE,KAAK,EAAEX,GAAG,CAACmB,QAAQ,CAAC;GACtD,EACD,CAACnB,GAAG,CAACmB,QAAQ,CAAC,CACjB;EACD,MAAMC,kBAAkB,GAAG5B,cAAK,CAACkB,WAAW,CAAC;;IAEzCW,qBAAqB,CAAC,MAAMlB,SAAS,CAACmB,SAAS,CAACC,iBAAiB,CAACzB,KAAK,CAAC,CAAC;GAC5E,EAAE,CAACA,KA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CAACK,OAAO,EAAEH,YAAY,CAACG,OAAO,EAAEF,UAAU,CAAC;EAErF,MAAMG,SAAS,GAAGC,EAAE,CAAC,WAAW,EAAE;IAC9B,sBAAsB,EAAE,OAAO3D,UAAU,CAACsB,OAAO,KAAK;GACzD,CAAC;EAEF,oBACIpC,yEACIA,qDAAQc,UAAU;IAAE0D,SAAS,EAAEA,SAAS;IAAEN,GAAG,EAAEA;MAC1C/D,QAAQ,EACRK,GAAG,CAACkE,eAAe,EAAE,CAACC,GAAG,CAAC,CAACC,IAAI,EAAEC,SAAS,oBACvC7E,6BAAC8E,IAAI;IAACC,GAAG,EAAEH,IAAI,CAAC7D,EAAE;IAAE6D,IAAI,EAAEA,IAAI;IAAEtE,KAAK,EAAEuE,SAAS;IAAEG,QAAQ,EAAE3E;IAAgB,CAC/E,CAAC,CACD,EACJmD,WAAW,kBACRxD;0BAAwBQ,GAAG,CAACO,EAAE;IAAEmD,GAAG,EAAEE;kBACjCpE;IAAIwE,SAAS,EAAC;KAAiBhB,WAAW,CAAM,CAC/C,IACL,IAAI,CACT;AAEX,CAAC;AAED,SAASc,0BAA0BA,CAC/B/D,UAA4D,EAC5D0E,KAAiC,EACjCC,WAAuC,EACvCb,UAAmB;EAEnBrE,cAAK,CAACmF,SAAS,CAAC;IACZ,IAAIF,KAAK,EAAE;MACP,MAAMG,MAAM,GAAGH,KAAK,CAACI,qBAAqB,EAAE,CAACD,MAAM;MAEnD,IAAIf,UAAU,IAAIa,WAAW,EAAE;QAC3B3E,UAAU,CAAC6E,MAAM,EAAEF,WAAW,CAACG,qBAAqB,EAAE,CAACD,MAAM,CAAC;OACjE,MAAM;QACH7E,UAAU,CAAC6E,MAAM,CAAC;;;GAG7B,EAAE,CAACf,UAAU,EAAEY,KAAK,EAAEC,WAAW,CAAC,CAAC;AACxC;;;;"}
1
+ {"version":3,"file":"DisplayRow.js","sources":["../../../../../../../../../../../src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport cn from 'clsx';\nimport { Cell } from '../../Columns/Cell/Cell';\nimport { TableRowRendererProps } from '../../../types';\nimport { TableRowWithMetaData } from '../../../../types';\nimport { isElementInteractive } from '../../../../../../utils/dom';\nimport { useDropTarget } from '../../../../../../utils/hooks/useDropTarget';\n\nexport type DisplayRowProps<TType = unknown> = React.HTMLAttributes<HTMLTableRowElement> & TableRowRendererProps<TType>;\n\nexport const DisplayRow = React.memo(function DisplayRow<TType = unknown>(props: DisplayRowProps<TType>) {\n const { children, cellRenderer: CellRenderer, index, measureRow, row, table, ...otherAttributes } = props;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const attributes: any = {\n ...otherAttributes,\n 'data-row-id': row.id,\n 'data-row-index': index,\n tabIndex: -1,\n };\n\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLTableRowElement>) => {\n const clickedElement = event.target as HTMLElement;\n\n if (!event.currentTarget?.contains(event.target as HTMLElement) || isElementInteractive(clickedElement)) {\n return;\n }\n\n tableMeta.rowClick.handleClick(event, row.original);\n },\n [row.original]\n );\n const handleClickCapture = React.useCallback(() => {\n tableMeta.rowActive.setRowActiveIndex(index);\n }, [index]);\n\n // row active\n if (tableMeta.rowActive.isEnabled) {\n attributes['data-row-active'] = tableMeta.rowActive.rowActiveIndex === index ? true : undefined;\n // we use capture because it let's us picks up clicks on components inside the row, e.g. checkboxes\n attributes.onClickCapture = handleClickCapture;\n }\n\n // row click\n if (tableMeta.rowClick.isEnabled(row.original)) {\n attributes.onClick = handleClick;\n }\n\n // row drag\n if (tableMeta.rowDrag.isEnabled) {\n attributes['aria-grabbed'] = !!tableMeta.rowDrag.dragging[row.id];\n }\n\n // row drop\n const [isDraggedOver, dropTargetProps] = useDropTarget(event => tableMeta.rowDrop.handleDrop?.(event, row.original));\n\n if (tableMeta.rowDrop.isEnabled) {\n attributes.onDragEnter = dropTargetProps?.onDragEnter;\n attributes.onDragLeave = dropTargetProps?.onDragLeave;\n attributes.onDragOver = dropTargetProps?.onDragOver;\n attributes.onDrop = dropTargetProps?.onDrop;\n attributes['data-row-dragged-over'] = isDraggedOver;\n }\n\n // row grouping\n if (table.options.enableGrouping) {\n attributes['data-row-group'] = row.getIsGrouped() ? true : undefined;\n }\n\n // row selection\n if (table.options.enableRowSelection) {\n attributes['data-row-selected'] = row.getIsSelected() || row.getIsAllSubRowsSelected() ? true : undefined;\n }\n\n // row expansion\n let expandedRow;\n\n if (tableMeta.rowExpansion.isEnabled && row.getIsExpanded()) {\n attributes['data-row-expanded'] = true;\n expandedRow = tableMeta.rowExpansion.rowExpansionRenderer?.(row.original)?.();\n }\n\n const rowMeta = (row.original as TableRowWithMetaData<TType>)._meta;\n\n if (rowMeta) {\n if (rowMeta.layout) {\n attributes['data-row-meta-layout'] = rowMeta.layout;\n }\n }\n\n const ref = React.useRef<HTMLTableRowElement>(null);\n const expansionRef = React.useRef<HTMLTableRowElement>(null);\n const isExpanded = !!attributes['data-row-expanded'];\n\n useSetVirtualisedRowHeight(measureRow, ref.current, expansionRef.current, isExpanded);\n\n const className = cn('group/row', {\n 'hover:cursor-pointer': typeof attributes.onClick === 'function',\n });\n\n return (\n <>\n <tr {...attributes} className={className} ref={ref}>\n {children}\n {row.getVisibleCells().map((cell, cellIndex) => (\n <Cell key={cell.id} cell={cell} index={cellIndex} renderer={CellRenderer} />\n ))}\n </tr>\n {expandedRow ? (\n <tr data-row-parent-id={row.id} ref={expansionRef}>\n <td className=\"col-span-full\">{expandedRow}</td>\n </tr>\n ) : null}\n </>\n );\n}) as <TType = unknown>(props: TableRowRendererProps<TType>) => JSX.Element;\n\nfunction useSetVirtualisedRowHeight(\n measureRow: (size: number, expansionHeight?: number) => void,\n rowEl: HTMLTableRowElement | null,\n expansionEl: HTMLTableRowElement | null,\n isExpanded: boolean\n) {\n React.useEffect(() => {\n if (rowEl) {\n const height = rowEl.getBoundingClientRect().height;\n\n if (isExpanded && expansionEl) {\n measureRow(height, expansionEl.getBoundingClientRect().height);\n } else {\n measureRow(height);\n }\n }\n }, [isExpanded, rowEl, expansionEl]);\n}\n"],"names":["DisplayRow","React","memo","props","children","cellRenderer","CellRenderer","index","measureRow","row","table","otherAttributes","tableMeta","options","meta","attributes","id","tabIndex","handleClick","useCallback","event","clickedElement","target","_event$currentTarget","currentTarget","contains","isElementInteractive","rowClick","original","handleClickCapture","rowActive","setRowActiveIndex","isEnabled","rowActiveIndex","undefined","onClickCapture","onClick","rowDrag","dragging","isDraggedOver","dropTargetProps","useDropTarget","_tableMeta$rowDrop$ha","_tableMeta$rowDrop","rowDrop","handleDrop","call","onDragEnter","onDragLeave","onDragOver","onDrop","enableGrouping","getIsGrouped","enableRowSelection","getIsSelected","getIsAllSubRowsSelected","expandedRow","rowExpansion","getIsExpanded","_tableMeta$rowExpansi","_tableMeta$rowExpansi2","_tableMeta$rowExpansi3","rowExpansionRenderer","rowMeta","_meta","layout","ref","useRef","expansionRef","isExpanded","useSetVirtualisedRowHeight","current","className","cn","getVisibleCells","map","cell","cellIndex","Cell","key","renderer","rowEl","expansionEl","useEffect","height","getBoundingClientRect"],"mappings":";;;;;;MAWaA,UAAU,gBAAGC,cAAK,CAACC,IAAI,CAAC,SAASF,UAAUA,CAAkBG,KAA6B;EACnG,MAAM;IAAEC,QAAQ;IAAEC,YAAY,EAAEC,YAAY;IAAEC,KAAK;IAAEC,UAAU;IAAEC,GAAG;IAAEC,KAAK;IAAE,GAAGC;GAAiB,GAAGR,KAAK;EACzG,MAAMS,SAAS,GAAGF,KAAK,CAACG,OAAO,CAACC,IAA6B;EAE7D,MAAMC,UAAU,GAAQ;IACpB,GAAGJ,eAAe;IAClB,aAAa,EAAEF,GAAG,CAACO,EAAE;IACrB,gBAAgB,EAAET,KAAK;IACvBU,QAAQ,EAAE,CAAC;GACd;EAED,MAAMC,WAAW,GAAGjB,cAAK,CAACkB,WAAW,CAChCC,KAA4C;;IACzC,MAAMC,cAAc,GAAGD,KAAK,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EACvCb,UAAmB;EAEnBpE,cAAK,CAACkF,SAAS,CAAC;IACZ,IAAIF,KAAK,EAAE;MACP,MAAMG,MAAM,GAAGH,KAAK,CAACI,qBAAqB,EAAE,CAACD,MAAM;MAEnD,IAAIf,UAAU,IAAIa,WAAW,EAAE;QAC3B1E,UAAU,CAAC4E,MAAM,EAAEF,WAAW,CAACG,qBAAqB,EAAE,CAACD,MAAM,CAAC;OACjE,MAAM;QACH5E,UAAU,CAAC4E,MAAM,CAAC;;;GAG7B,EAAE,CAACf,UAAU,EAAEY,KAAK,EAAEC,WAAW,CAAC,CAAC;AACxC;;;;"}
@@ -72,7 +72,8 @@ function ManageFiltersPopover(props) {
72
72
  if (f.value.comparator === TableFilterComparator.IsEmpty || f.value.comparator === TableFilterComparator.IsNotEmpty || controlRenderer === 'switch') {
73
73
  return true;
74
74
  }
75
- return !!f.value.value;
75
+ const value = f.value.value;
76
+ return value !== undefined && value !== null && value !== '';
76
77
  });
77
78
  return newFilters;
78
79
  });
@@ -117,12 +118,12 @@ function ManageFiltersPopover(props) {
117
118
  onClick: handleCreate
118
119
  }, "+ ", texts.table.filters.buttons.addFilter))), /*#__PURE__*/React__default.createElement(Group, {
119
120
  className: "ml-auto"
120
- }, /*#__PURE__*/React__default.createElement(Popover.Close, null, /*#__PURE__*/React__default.createElement(Button, null, "Cancel")), /*#__PURE__*/React__default.createElement(Button, {
121
+ }, /*#__PURE__*/React__default.createElement(Popover.Close, null, /*#__PURE__*/React__default.createElement(Button, null, texts.table.filters.buttons.cancel)), /*#__PURE__*/React__default.createElement(Button, {
121
122
  onClick: handleClear
122
- }, "Clear"), /*#__PURE__*/React__default.createElement(Button, {
123
+ }, texts.table.filters.buttons.clear), /*#__PURE__*/React__default.createElement(Button, {
123
124
  appearance: "primary",
124
125
  onClick: handleApply
125
- }, "Apply")))));
126
+ }, texts.table.filters.buttons.apply)))));
126
127
  }
127
128
 
128
129
  export { ManageFiltersPopover };
@@ -1 +1 @@
1
- {"version":3,"file":"ManageFiltersPopover.js","sources":["../../../../../../../../../../../../src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable } from '@tanstack/react-table';\nimport { Popover } from '../../../../../../../components/Popover/Popover';\nimport { useLocalization } from '../../../../../../../components/Provider/Localization';\nimport { Button } from '../../../../../../../components/Button/Button';\nimport { Group } from '../../../../../../../components/Group/Group';\nimport { isEmptyFilter, sortByHeader } from './util';\nimport { isInternalColumn } from '../../../../../useTableManager/util/columns';\nimport { TableFilter, TableFilterComparator, TableFilterValue } from '../../../../../types';\nimport { Filter } from './components/Filter';\n\nexport type ManageFiltersPopoverProps<TType = unknown> = {\n length: number;\n table: ReactTable<TType>;\n};\n\nconst placeholderFilter: TableFilter = { id: '', value: { comparator: TableFilterComparator.Contains, value: undefined } };\n\nexport function ManageFiltersPopover<TType = unknown>(props: ManageFiltersPopoverProps<TType>) {\n const { length, table, ...popoverProps } = props;\n const { locale, texts } = useLocalization();\n\n const allColumns = table\n .getAllLeafColumns()\n .filter(column => !isInternalColumn(column.id))\n .sort(sortByHeader);\n\n const columnFilters = table.getState().columnFilters as TableFilter[];\n\n // state, since we \"apply\" filters - our filter values have a special shape, so we force to our type\n const [filters, setFilters] = React.useState<TableFilter[]>(columnFilters.length ? columnFilters : [placeholderFilter]);\n\n // this runs if filters are set outside (e.g. through column header)\n React.useEffect(() => {\n setFilters(columnFilters.length === 0 ? [placeholderFilter] : columnFilters);\n\n // focus the filter value, as we preset the column/comparator.\n requestAnimationFrame(() => {\n const filterValues = document.querySelectorAll('[data-query-selector=\"filter-value\"]');\n const lastFilter = filterValues.length ? filterValues[filterValues.length - 1] : undefined;\n\n (lastFilter as HTMLElement)?.focus();\n });\n }, [columnFilters]);\n\n // filters\n const handleChangeFilter = (position: number, filter: { id: string; value: TableFilterValue }) => {\n setFilters(currentFilters => {\n return currentFilters.map((current, index) => {\n if (index === position) {\n return filter;\n }\n return current;\n });\n });\n };\n\n const handleRemoveFilter = position => {\n if (filters.length === 1) {\n setFilters([placeholderFilter]);\n return;\n }\n\n setFilters(currentFilters => currentFilters.filter((_, index) => index !== position));\n };\n\n const handleCreate = () => {\n setFilters(filters.concat(placeholderFilter));\n };\n\n //\n const handleApply = () => {\n table.setColumnFilters(() => {\n const newFilters = filters.filter(f => {\n if (f.id === null || f.id === '') {\n return false;\n }\n\n const controlRenderer = allColumns.find(c => c.id === f.id)?.columnDef.meta?.control;\n\n if (\n f.value.comparator === TableFilterComparator.IsEmpty ||\n f.value.comparator === TableFilterComparator.IsNotEmpty ||\n controlRenderer === 'switch'\n ) {\n return true;\n }\n\n return !!f.value.value;\n });\n\n return newFilters;\n });\n };\n\n const handleClear = () => {\n table.resetColumnFilters();\n setFilters([placeholderFilter]);\n };\n\n const handleClose = (open: boolean) => {\n if (!open) {\n const nonEmptyFilters = columnFilters.filter(f => !isEmptyFilter(f));\n table.setColumnFilters(nonEmptyFilters);\n setFilters(nonEmptyFilters.length === 0 ? [placeholderFilter] : nonEmptyFilters);\n }\n };\n\n return (\n <Popover {...popoverProps} onChange={handleClose}>\n <Popover.Content>\n <div className=\"flex w-[40rem] flex-col gap-4\">\n <div className=\"flex h-8\">\n <div className=\"flex w-full items-center gap-2\">\n <h4 className=\"mb-0 inline-flex\">{texts.table.filters.button}</h4>\n <p className=\"text-grey-700 mb-0 mr-auto mt-px inline-flex\">\n {texts.table.filters.total\n .replace(\n '[CURRENT]',\n new Intl.NumberFormat(locale).format(table.getFilteredRowModel().rows.length)\n )\n .replace('[TOTAL]', new Intl.NumberFormat(locale).format(length))}\n </p>\n </div>\n </div>\n <div className=\"flex flex-col gap-2\">\n {filters.map((filter, index) => (\n <Filter\n key={`filter_${index}`}\n allColumns={allColumns}\n filter={filter}\n filters={filters}\n position={index}\n onChange={handleChangeFilter}\n onRemove={\n (filters.length > 0 && filters.some(f => f.id)) || filters.length > 1\n ? handleRemoveFilter\n : undefined\n }\n />\n ))}\n <div className=\"justify-start\">\n <Button appearance=\"discrete\" onClick={handleCreate}>\n + {texts.table.filters.buttons.addFilter}\n </Button>\n </div>\n </div>\n <Group className=\"ml-auto\">\n <Popover.Close>\n <Button>Cancel</Button>\n </Popover.Close>\n <Button onClick={handleClear}>Clear</Button>\n <Button appearance=\"primary\" onClick={handleApply}>\n Apply\n </Button>\n </Group>\n </div>\n </Popover.Content>\n </Popover>\n );\n}\n"],"names":["placeholderFilter","id","value","comparator","TableFilterComparator","Contains","undefined","ManageFiltersPopover","props","length","table","popoverProps","locale","texts","useLocalization","allColumns","getAllLeafColumns","filter","column","isInternalColumn","sort","sortByHeader","columnFilters","getState","filters","setFilters","React","useState","useEffect","requestAnimationFrame","filterValues","document","querySelectorAll","lastFilter","focus","handleChangeFilter","position","currentFilters","map","current","index","handleRemoveFilter","_","handleCreate","concat","handleApply","setColumnFilters","newFilters","f","controlRenderer","_allColumns$find","find","c","_allColumns$find$colu","columnDef","meta","control","IsEmpty","IsNotEmpty","handleClear","resetColumnFilters","handleClose","open","nonEmptyFilters","isEmptyFilter","Popover","onChange","Content","className","button","total","replace","Intl","NumberFormat","format","getFilteredRowModel","rows","Filter","key","onRemove","some","Button","appearance","onClick","buttons","addFilter","Group","Close"],"mappings":";;;;;;;;;;AAgBA,MAAMA,iBAAiB,GAAgB;EAAEC,EAAE,EAAE,EAAE;EAAEC,KAAK,EAAE;IAAEC,UAAU,EAAEC,qBAAqB,CAACC,QAAQ;IAAEH,KAAK,EAAEI;;CAAa;SAE1GC,oBAAoBA,CAAkBC,KAAuC;EACzF,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAE,GAAGC;GAAc,GAAGH,KAAK;EAChD,MAAM;IAAEI,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EAE3C,MAAMC,UAAU,GAAGL,KAAK,CACnBM,iBAAiB,EAAE,CACnBC,MAAM,CAACC,MAAM,IAAI,CAACC,gBAAgB,CAACD,MAAM,CAACjB,EAAE,CAAC,CAAC,CAC9CmB,IAAI,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AAC,eACFoB;IAAK0C,SAAS,EAAC;kBACX1C,6BAACuD,MAAM;IAACC,UAAU,EAAC,UAAU;IAACC,OAAO,EAAExC;WAChC9B,KAAK,CAACH,KAAK,CAACc,OAAO,CAAC4D,OAAO,CAACC,SAAS,CACnC,CACP,CACJ,eACN3D,6BAAC4D,KAAK;IAAClB,SAAS,EAAC;kBACb1C,6BAACuC,OAAO,CAACsB,KAAK,qBACV7D,6BAACuD,MAAM,iBAAgB,CACX,eAChBvD,6BAACuD,MAAM;IAACE,OAAO,EAAExB;aAA2B,eAC5CjC,6BAACuD,MAAM;IAACC,UAAU,EAAC,SAAS;IAACC,OAAO,EAAEtC;aAE7B,CACL,CACN,CACQ,CACZ;AAElB;;;;"}
1
+ {"version":3,"file":"ManageFiltersPopover.js","sources":["../../../../../../../../../../../../src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable } from '@tanstack/react-table';\nimport { Popover } from '../../../../../../../components/Popover/Popover';\nimport { useLocalization } from '../../../../../../../components/Provider/Localization';\nimport { Button } from '../../../../../../../components/Button/Button';\nimport { Group } from '../../../../../../../components/Group/Group';\nimport { isEmptyFilter, sortByHeader } from './util';\nimport { isInternalColumn } from '../../../../../useTableManager/util/columns';\nimport { TableFilter, TableFilterComparator, TableFilterValue } from '../../../../../types';\nimport { Filter } from './components/Filter';\n\nexport type ManageFiltersPopoverProps<TType = unknown> = {\n length: number;\n table: ReactTable<TType>;\n};\n\nconst placeholderFilter: TableFilter = { id: '', value: { comparator: TableFilterComparator.Contains, value: undefined } };\n\nexport function ManageFiltersPopover<TType = unknown>(props: ManageFiltersPopoverProps<TType>) {\n const { length, table, ...popoverProps } = props;\n const { locale, texts } = useLocalization();\n\n const allColumns = table\n .getAllLeafColumns()\n .filter(column => !isInternalColumn(column.id))\n .sort(sortByHeader);\n\n const columnFilters = table.getState().columnFilters as TableFilter[];\n\n // state, since we \"apply\" filters - our filter values have a special shape, so we force to our type\n const [filters, setFilters] = React.useState<TableFilter[]>(columnFilters.length ? columnFilters : [placeholderFilter]);\n\n // this runs if filters are set outside (e.g. through column header)\n React.useEffect(() => {\n setFilters(columnFilters.length === 0 ? [placeholderFilter] : columnFilters);\n\n // focus the filter value, as we preset the column/comparator.\n requestAnimationFrame(() => {\n const filterValues = document.querySelectorAll('[data-query-selector=\"filter-value\"]');\n const lastFilter = filterValues.length ? filterValues[filterValues.length - 1] : undefined;\n\n (lastFilter as HTMLElement)?.focus();\n });\n }, [columnFilters]);\n\n // filters\n const handleChangeFilter = (position: number, filter: { id: string; value: TableFilterValue }) => {\n setFilters(currentFilters => {\n return currentFilters.map((current, index) => {\n if (index === position) {\n return filter;\n }\n return current;\n });\n });\n };\n\n const handleRemoveFilter = position => {\n if (filters.length === 1) {\n setFilters([placeholderFilter]);\n return;\n }\n\n setFilters(currentFilters => currentFilters.filter((_, index) => index !== position));\n };\n\n const handleCreate = () => {\n setFilters(filters.concat(placeholderFilter));\n };\n\n //\n const handleApply = () => {\n table.setColumnFilters(() => {\n const newFilters = filters.filter(f => {\n if (f.id === null || f.id === '') {\n return false;\n }\n\n const controlRenderer = allColumns.find(c => c.id === f.id)?.columnDef.meta?.control;\n\n if (\n f.value.comparator === TableFilterComparator.IsEmpty ||\n f.value.comparator === TableFilterComparator.IsNotEmpty ||\n controlRenderer === 'switch'\n ) {\n return true;\n }\n\n const value = f.value.value;\n\n return value !== undefined && value !== null && value !== '';\n });\n\n return newFilters;\n });\n };\n\n const handleClear = () => {\n table.resetColumnFilters();\n setFilters([placeholderFilter]);\n };\n\n const handleClose = (open: boolean) => {\n if (!open) {\n const nonEmptyFilters = columnFilters.filter(f => !isEmptyFilter(f));\n table.setColumnFilters(nonEmptyFilters);\n setFilters(nonEmptyFilters.length === 0 ? [placeholderFilter] : nonEmptyFilters);\n }\n };\n\n return (\n <Popover {...popoverProps} onChange={handleClose}>\n <Popover.Content>\n <div className=\"flex w-[40rem] flex-col gap-4\">\n <div className=\"flex h-8\">\n <div className=\"flex w-full items-center gap-2\">\n <h4 className=\"mb-0 inline-flex\">{texts.table.filters.button}</h4>\n <p className=\"text-grey-700 mb-0 mr-auto mt-px inline-flex\">\n {texts.table.filters.total\n .replace(\n '[CURRENT]',\n new Intl.NumberFormat(locale).format(table.getFilteredRowModel().rows.length)\n )\n .replace('[TOTAL]', new Intl.NumberFormat(locale).format(length))}\n </p>\n </div>\n </div>\n <div className=\"flex flex-col gap-2\">\n {filters.map((filter, index) => (\n <Filter\n key={`filter_${index}`}\n allColumns={allColumns}\n filter={filter}\n filters={filters}\n position={index}\n onChange={handleChangeFilter}\n onRemove={\n (filters.length > 0 && filters.some(f => f.id)) || filters.length > 1\n ? handleRemoveFilter\n : undefined\n }\n />\n ))}\n <div className=\"justify-start\">\n <Button appearance=\"discrete\" onClick={handleCreate}>\n + {texts.table.filters.buttons.addFilter}\n </Button>\n </div>\n </div>\n <Group className=\"ml-auto\">\n <Popover.Close>\n <Button>{texts.table.filters.buttons.cancel}</Button>\n </Popover.Close>\n <Button onClick={handleClear}>{texts.table.filters.buttons.clear}</Button>\n <Button appearance=\"primary\" onClick={handleApply}>\n {texts.table.filters.buttons.apply}\n </Button>\n </Group>\n </div>\n </Popover.Content>\n </Popover>\n );\n}\n"],"names":["placeholderFilter","id","value","comparator","TableFilterComparator","Contains","undefined","ManageFiltersPopover","props","length","table","popoverProps","locale","texts","useLocalization","allColumns","getAllLeafColumns","filter","column","isInternalColumn","sort","sortByHeader","columnFilters","getState","filters","setFilters","React","useState","useEffect","requestAnimationFrame","filterValues","document","querySelectorAll","lastFilter","focus","handleChangeFilter","position","currentFilters","map","current","index","handleRemoveFilter","_","handleCreate","concat","handleApply","setColumnFilters","newFilters","f","controlRenderer","_allColumns$find","find","c","_allColumns$find$colu","columnDef","meta","control","IsEmpty","IsNotEmpty","handleClear","resetColumnFilters","handleClose","open","nonEmptyFilters","isEmptyFilter","Popover","onChange","Content","className","button","total","replace","Intl","NumberFormat","format","getFilteredRowModel","rows","Filter","key","onRemove","some","Button","appearance","onClick","buttons","addFilter","Group","Close","cancel","clear","apply"],"mappings":";;;;;;;;;;AAgBA,MAAMA,iBAAiB,GAAgB;EAAEC,EAAE,EAAE,EAAE;EAAEC,KAAK,EAAE;IAAEC,UAAU,EAAEC,qBAAqB,CAACC,QAAQ;IAAEH,KAAK,EAAEI;;CAAa;SAE1GC,oBAAoBA,CAAkBC,KAAuC;EACzF,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAE,GAAGC;GAAc,GAAGH,KAAK;EAChD,MAAM;IAAEI,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EAE3C,MAAMC,UAAU,GAAGL,KAAK,CACnBM,iBAAiB,EAAE,CACnBC,MAAM,CAACC,MAAM,IAAI,CAACC,gBAAgB,CAACD,MAAM,CAACjB,EAAE,CAAC,CAAC,CAC9CmB,IAAI,CAACC,YAAY,CAAC;EAEvB,MAAMC,aAAa,GAAGZ,KAAK,CAACa,QAAQ,EAAE,CAACD,aAA8B;;EAGrE,MAAM,CAACE,OAAO,EAAEC,UAAU,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAgBL,aAAa,CAACb,MAAM,GAAGa,aAAa,GAAG,CAACtB,iBAAiB,CAAC,CAAC;;EAGvH0B,cAAK,CAACE,SAAS,CAAC;IACZH,UAAU,CAACH,aAAa,CAACb,MAAM,KAAK,CAAC,GAAG,CAACT,iBAAiB,CAAC,GAAGsB,aAAa,CAAC;;IAG5EO,qBAAqB,CAAC;MAClB,MAAMC,YAAY,GAAGC,QAAQ,CAACC,gBAAgB,CAAC,sCAAsC,CAAC;MACtF,MAAMC,UAAU,GAAGH,YAAY,CAACrB,MAAM,GAAGqB,YAAY,CAACA,YAAY,CAACrB,MAAM,GAAG,CAAC,CAAC,GAAGH,SAAS;MAEzF2B,UAA0B,aAA1BA,UAA0B,uBAA1BA,UAA0B,CAAEC,KAAK,EAAE;KACvC,CAAC;GACL,EAAE,CAACZ,aAAa,C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,OAAO,CAACM,KAAK,CAC7B,CACL,CACN,CACQ,CACZ;AAElB;;;;"}
@@ -83,10 +83,11 @@ function Control(props) {
83
83
  const controlRenderer = column === null || column === void 0 ? void 0 : (_column$columnDef$met2 = column.columnDef.meta) === null || _column$columnDef$met2 === void 0 ? void 0 : _column$columnDef$met2.control;
84
84
  const dataType = column === null || column === void 0 ? void 0 : (_column$columnDef$met3 = column.columnDef.meta) === null || _column$columnDef$met3 === void 0 ? void 0 : _column$columnDef$met3.dataType;
85
85
  useEffect(() => {
86
- if (controlRenderer === 'switch') {
86
+ // Set value to false only after first render of the control (when it's undefined) after setting the FilterColumn value, because we don't want to change then the value every time filter is opened
87
+ if (controlRenderer === 'switch' && value === undefined) {
87
88
  onChange(false);
88
89
  }
89
- }, []);
90
+ }, [controlRenderer]);
90
91
  if (typeof controlRenderer === 'function') {
91
92
  return /*#__PURE__*/React__default.cloneElement(controlRenderer({
92
93
  ...attributes,
@@ -1 +1 @@
1
- {"version":3,"file":"FilterValue.js","sources":["../../../../../../../../../../../../../src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { Column as ReactTableColumn } from '@tanstack/react-table';\nimport { Input } from '../../../../../../../../components/Input/Input';\nimport { Datepicker } from '../../../../../../../../components/Datepicker/Datepicker';\nimport { Switch } from '../../../../../../../../components/Switch/Switch';\nimport { useLocalization } from '../../../../../../../../components/Provider/Localization';\nimport { TableFilterComparator } from '../../../../../../types';\n\nexport type FilterValueProps<TType = unknown> = {\n column?: ReactTableColumn<TType, unknown>;\n comparator: TableFilterComparator;\n onChange: (value: any) => void;\n value: any;\n};\n\nconst querySelector = 'filter-value';\n\nexport function FilterValue<TType = unknown>(props: FilterValueProps<TType>) {\n const { column, comparator, onChange: handleChange, value } = props;\n const { texts } = useLocalization();\n\n if (comparator === TableFilterComparator.IsEmpty || comparator === TableFilterComparator.IsNotEmpty) {\n return null;\n }\n\n if (comparator === TableFilterComparator.IsBetween) {\n const fromValue = Array.isArray(value) ? value[0] : undefined;\n const toValue = Array.isArray(value) ? value[1] : undefined;\n\n if (column === undefined) {\n return (\n <Input\n aria-label={texts.table.filters.emptyFilter.value}\n className=\"flex-grow\"\n data-query-selector={querySelector}\n disabled\n value={texts.table.filters.emptyFilter.value}\n />\n );\n }\n\n if (column.columnDef.meta?.dataType === 'datetime') {\n return (\n <div className=\"flex flex-grow items-center gap-2\">\n <Control\n column={column}\n data-query-selector={querySelector}\n onChange={value => handleChange([value, toValue])}\n value={fromValue}\n />\n <Control\n column={column}\n data-query-selector={querySelector}\n onChange={value => handleChange([fromValue, value])}\n value={toValue}\n />\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-grow items-center gap-2\">\n <Control\n column={column}\n data-query-selector={querySelector}\n onChange={value => handleChange([isNaN(value) ? undefined : value, toValue])}\n placeholder=\"from\"\n value={fromValue ?? ''}\n />\n <Control\n column={column}\n data-query-selector={querySelector}\n onChange={value => handleChange([fromValue, isNaN(value) ? undefined : value])}\n placeholder=\"to\"\n value={toValue ?? ''}\n />\n </div>\n );\n }\n return (\n <Control\n comparator={comparator}\n column={column}\n data-query-selector={querySelector}\n onChange={handleChange}\n value={value}\n />\n );\n}\n\nfunction Control(props) {\n const { column, comparator, onChange, value, ...attributes } = props;\n const controlRenderer = column?.columnDef.meta?.control;\n const dataType = column?.columnDef.meta?.dataType;\n\n useEffect(() => {\n if (controlRenderer === 'switch') {\n onChange(false);\n }\n }, []);\n\n if (typeof controlRenderer === 'function') {\n return React.cloneElement(\n controlRenderer({\n ...attributes,\n setValue: value => onChange(value),\n value,\n }),\n { ['data-query-selector']: querySelector, className: 'focus:yt-focus' }\n );\n } else if (controlRenderer === 'datepicker' || dataType === 'datetime') {\n return <Datepicker {...attributes} onChange={event => onChange((event as any).detail)} value={value as Date} />;\n } else if (controlRenderer === 'switch') {\n return <Switch {...attributes} className=\"m-1.5\" checked={Boolean(value)} onChange={onChange} />;\n } else if ((controlRenderer === 'input' || controlRenderer === undefined) && dataType === 'number') {\n return (\n <Input\n {...attributes}\n className=\"flex-grow\"\n type=\"number\"\n onChange={event => onChange(event.target.valueAsNumber)}\n value={String(value ?? '')}\n />\n );\n }\n\n return (\n <Input\n disabled={!column}\n {...attributes}\n className=\"flex-grow\"\n onChange={event => onChange(event.target.value)}\n value={String(value ?? '')}\n />\n );\n}\n"],"names":["querySelector","FilterValue","props","column","comparator","onChange","handleChange","value","texts","useLocalization","TableFilterComparator","IsEmpty","IsNotEmpty","IsBetween","_column$columnDef$met","fromValue","Array","isArray","undefined","toValue","React","Input","table","filters","emptyFilter","className","disabled","columnDef","meta","dataType","Control","isNaN","placeholder","attributes","controlRenderer","_column$columnDef$met2","control","_column$columnDef$met3","useEffect","cloneElement","setValue","Datepicker","event","detail","Switch","checked","Boolean","type","target","valueAsNumber","String"],"mappings":";;;;;;;AAeA,MAAMA,aAAa,GAAG,cAAc;SAEpBC,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,MAAM;IAAEC,UAAU;IAAEC,QAAQ,EAAEC,YAAY;IAAEC;GAAO,GAAGL,KAAK;EACnE,MAAM;IAAEM;GAAO,GAAGC,eAAe,EAAE;EAEnC,IAAIL,UAAU,KAAKM,qBAAqB,CAACC,OAAO,IAAIP,UAAU,KAAKM,qBAAqB,CAACE,UAAU,EAAE;IACjG,OAAO,IAAI;;EAGf,IAAIR,UAAU,KAAKM,qBAAqB,CAACG,SAAS,EAAE;IAAA,IAAAC,qBAAA;IAChD,MAAMC,SAAS,GAAGC,KAAK,CAACC,OAAO,CAACV,KAAK,CAAC,GAAGA,KAAK,CAAC,CAAC,CAAC,GAAGW,SAAS;IAC7D,MAAMC,OAAO,GAAGH,KAAK,CAACC,OAAO,CAACV,KAAK,CAAC,GAAGA,KAAK,CAAC,CAAC,CAAC,GAAGW,SAAS;IAE3D,IAAIf,MAAM,KAAKe,SAAS,EAAE;MACtB,oBACIE,6BAACC,KAAK;sBACUb,KAAK,CAACc,KAAK,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K,EAAEA;OAAiB;GAClH,MAAM,IAAI2B,eAAe,KAAK,QAAQ,EAAE;IACrC,oBAAOd,6BAACwB,MAAM,oBAAKX,UAAU;MAAER,SAAS,EAAC,OAAO;MAACoB,OAAO,EAAEC,OAAO,CAACvC,KAAK,CAAC;MAAEF,QAAQ,EAAEA;OAAY;GACnG,MAAM,IAAI,CAAC6B,eAAe,KAAK,OAAO,IAAIA,eAAe,KAAKhB,SAAS,KAAKW,QAAQ,KAAK,QAAQ,EAAE;IAChG,oBACIT,6BAACC,KAAK,oBACEY,UAAU;MACdR,SAAS,EAAC,WAAW;MACrBsB,IAAI,EAAC,QAAQ;MACb1C,QAAQ,EAAEqC,KAAK,IAAIrC,QAAQ,CAACqC,KAAK,CAACM,MAAM,CAACC,aAAa,CAAC;MACvD1C,KAAK,EAAE2C,MAAM,CAAC3C,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;OAC3B;;EAIV,oBACIa,6BAACC,KAAK;IACFK,QAAQ,EAAE,CAACvB;KACP8B,UAAU;IACdR,SAAS,EAAC,WAAW;IACrBpB,QAAQ,EAAEqC,KAAK,IAAIrC,QAAQ,CAACqC,KAAK,CAACM,MAAM,CAACzC,KAAK,CAAC;IAC/CA,KAAK,EAAE2C,MAAM,CAAC3C,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;KAC3B;AAEV;;;;"}
1
+ {"version":3,"file":"FilterValue.js","sources":["../../../../../../../../../../../../../src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { Column as ReactTableColumn } from '@tanstack/react-table';\nimport { Input } from '../../../../../../../../components/Input/Input';\nimport { Datepicker } from '../../../../../../../../components/Datepicker/Datepicker';\nimport { Switch } from '../../../../../../../../components/Switch/Switch';\nimport { useLocalization } from '../../../../../../../../components/Provider/Localization';\nimport { TableFilterComparator } from '../../../../../../types';\n\nexport type FilterValueProps<TType = unknown> = {\n column?: ReactTableColumn<TType, unknown>;\n comparator: TableFilterComparator;\n onChange: (value: any) => void;\n value: any;\n};\n\nconst querySelector = 'filter-value';\n\nexport function FilterValue<TType = unknown>(props: FilterValueProps<TType>) {\n const { column, comparator, onChange: handleChange, value } = props;\n const { texts } = useLocalization();\n\n if (comparator === TableFilterComparator.IsEmpty || comparator === TableFilterComparator.IsNotEmpty) {\n return null;\n }\n\n if (comparator === TableFilterComparator.IsBetween) {\n const fromValue = Array.isArray(value) ? value[0] : undefined;\n const toValue = Array.isArray(value) ? value[1] : undefined;\n\n if (column === undefined) {\n return (\n <Input\n aria-label={texts.table.filters.emptyFilter.value}\n className=\"flex-grow\"\n data-query-selector={querySelector}\n disabled\n value={texts.table.filters.emptyFilter.value}\n />\n );\n }\n\n if (column.columnDef.meta?.dataType === 'datetime') {\n return (\n <div className=\"flex flex-grow items-center gap-2\">\n <Control\n column={column}\n data-query-selector={querySelector}\n onChange={value => handleChange([value, toValue])}\n value={fromValue}\n />\n <Control\n column={column}\n data-query-selector={querySelector}\n onChange={value => handleChange([fromValue, value])}\n value={toValue}\n />\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-grow items-center gap-2\">\n <Control\n column={column}\n data-query-selector={querySelector}\n onChange={value => handleChange([isNaN(value) ? undefined : value, toValue])}\n placeholder=\"from\"\n value={fromValue ?? ''}\n />\n <Control\n column={column}\n data-query-selector={querySelector}\n onChange={value => handleChange([fromValue, isNaN(value) ? undefined : value])}\n placeholder=\"to\"\n value={toValue ?? ''}\n />\n </div>\n );\n }\n return (\n <Control\n comparator={comparator}\n column={column}\n data-query-selector={querySelector}\n onChange={handleChange}\n value={value}\n />\n );\n}\n\nfunction Control(props) {\n const { column, comparator, onChange, value, ...attributes } = props;\n const controlRenderer = column?.columnDef.meta?.control;\n const dataType = column?.columnDef.meta?.dataType;\n\n useEffect(() => {\n // Set value to false only after first render of the control (when it's undefined) after setting the FilterColumn value, because we don't want to change then the value every time filter is opened\n if (controlRenderer === 'switch' && value === undefined) {\n onChange(false);\n }\n }, [controlRenderer]);\n\n if (typeof controlRenderer === 'function') {\n return React.cloneElement(\n controlRenderer({\n ...attributes,\n setValue: value => onChange(value),\n value,\n }),\n { ['data-query-selector']: querySelector, className: 'focus:yt-focus' }\n );\n } else if (controlRenderer === 'datepicker' || dataType === 'datetime') {\n return <Datepicker {...attributes} onChange={event => onChange((event as any).detail)} value={value as Date} />;\n } else if (controlRenderer === 'switch') {\n return <Switch {...attributes} className=\"m-1.5\" checked={Boolean(value)} onChange={onChange} />;\n } else if ((controlRenderer === 'input' || controlRenderer === undefined) && dataType === 'number') {\n return (\n <Input\n {...attributes}\n className=\"flex-grow\"\n type=\"number\"\n onChange={event => onChange(event.target.valueAsNumber)}\n value={String(value ?? '')}\n />\n );\n }\n\n return (\n <Input\n disabled={!column}\n {...attributes}\n className=\"flex-grow\"\n onChange={event => onChange(event.target.value)}\n value={String(value ?? '')}\n />\n );\n}\n"],"names":["querySelector","FilterValue","props","column","comparator","onChange","handleChange","value","texts","useLocalization","TableFilterComparator","IsEmpty","IsNotEmpty","IsBetween","_column$columnDef$met","fromValue","Array","isArray","undefined","toValue","React","Input","table","filters","emptyFilter","className","disabled","columnDef","meta","dataType","Control","isNaN","placeholder","attributes","controlRenderer","_column$columnDef$met2","control","_column$columnDef$met3","useEffect","cloneElement","setValue","Datepicker","event","detail","Switch","checked","Boolean","type","target","valueAsNumber","String"],"mappings":";;;;;;;AAeA,MAAMA,aAAa,GAAG,cAAc;SAEpBC,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,MAAM;IAAEC,UAAU;IAAEC,QAAQ,EAAEC,YAAY;IAAEC;GAAO,GAAGL,KAAK;EACnE,MAAM;IAAEM;GAAO,GAAGC,eAAe,EAAE;EAEnC,IAAIL,UAAU,KAAKM,qBAAqB,CAACC,OAAO,IAAIP,UAAU,KAAKM,qBAAqB,CAACE,UAAU,EAAE;IACjG,OAAO,IAAI;;EAGf,IAAIR,UAAU,KAAKM,qBAAqB,CAACG,SA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}
@@ -71,7 +71,7 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex) {
71
71
  let content = null;
72
72
  if (rows.length) {
73
73
  style = {
74
- height: `${totalSize}px`,
74
+ height: totalSize,
75
75
  paddingBottom,
76
76
  paddingTop
77
77
  };
@@ -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} from '@tanstack/react-virtual';\nimport { ROW_HEIGHT_ESTIMATES } from '../util/rows';\nimport { Row } from '../components/Row/Row';\nimport { useTableRenderers } from '../types';\nimport { TableRef } from '../../types';\n\nexport function useTableRenderer<TType = unknown>(\n renderers: useTableRenderers<TType>,\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n defaultRowActiveIndex?: number | undefined\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n const isTableRowGrouped = !!table.getState().grouping?.length;\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 // column groups offset the bottom padding :shrug:, multiplying by 1.5 ensures the bottom padding remains\n // consistent when there are groups and when there aren't. 1.5 is relatively arbitrary, but it gives alignment\n const scrollPaddingEnd = ROW_HEIGHT_ESTIMATES.medium * (table.getHeaderGroups().length > 1 ? 1.5 : 1);\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 top and bottom spacing for the scroll container - very sensitive, don't change\n scrollMargin: isTableRowGrouped ? 0 : scrollPaddingStart,\n // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list\n scrollPaddingStart,\n scrollPaddingEnd: tableMeta.footer.isEnabled ? scrollPaddingEnd * 2 : scrollPaddingEnd,\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 // styling for offsetting rows - this \"is\" the virtualisation\n const [paddingTop, paddingBottom] =\n virtualItems.length > 0\n ? [\n Math.max(0, virtualItems[paddingStartIndex]?.start - virtualItems[paddingStartIndex]?.size ?? 0),\n Math.max(0, totalSize - virtualItems[virtualItems.length - 1]?.end ?? 0),\n ]\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}px`,\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\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 => {\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":["useTableRenderer","renderers","table","tableRef","defaultRowActiveIndex","tableMeta","options","meta","rows","getRowModel","isTableRowGrouped","_table$getState$group","getState","grouping","length","createRowMeasurer","estimateSize","useRowHeightVirtualisation","rangeExtractor","useRowGroupVirtualisation","scrollPaddingStart","ROW_HEIGHT_ESTIMATES","medium","scrollPaddingEnd","getHeaderGroups","virtualiser","useVirtualizer","count","getScrollElement","current","overscan","printing","isPrinting","undefined","scrollMargin","footer","isEnabled","totalSize","getTotalSize","virtualItems","getVirtualItems","scrollToIndex","React","useCallback","index","align","behavior","notSmooth","scrollToOffset","scrollTop","scrollHeight","paddingStartIndex","paddingTop","paddingBottom","Math","max","_ref","_virtualItems$padding","start","_virtualItems$padding2","size","_ref2","_virtualItems","end","useEffect","style","content","height","map","virtualRow","row","measureRow","resizeItem","Row","key","id","renderer","cellRenderer","cell","expandedState","expanded","expandedRowHeightsCache","setExpandedRowHeightsCache","useState","averageExpandedRowHeight","useMemo","values","Object","reduce","a","b","rowHeight","_rows$index","_rows$index$getIsExpa","getIsExpanded","call","expansionHeight","cache","isTableGrouped","rowGroupIndexes","indexes","forEach","getIsGrouped","push","range","activeRowGroupIndex","_reverse$find","reverse","find","startIndex","next","Set","defaultRangeExtract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,IAAI,GAAG,IAAIC,GAAG,CAAC,CAACN,mBAAmB,EAAE,GAAGO,qBAAqB,CAACR,KAAK,CAAC,CAAC,CAAC;IAC5E,OAAO,CAAC,GAAGM,IAAI,CAAC,CAACG,IAAI,CAAC,CAACxB,CAAC,EAAEC,CAAC,KAAKD,CAAC,GAAGC,CAAC,CAAC;GACzC,EACD,CAACS,eAAe,CAAC,CACpB;EAED,OAAOD,cAAc,GAAGhF,cAAc,GAAGe,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} from '@tanstack/react-virtual';\nimport { ROW_HEIGHT_ESTIMATES } from '../util/rows';\nimport { Row } from '../components/Row/Row';\nimport { useTableRenderers } from '../types';\nimport { TableRef } from '../../types';\n\nexport function useTableRenderer<TType = unknown>(\n renderers: useTableRenderers<TType>,\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n defaultRowActiveIndex?: number | undefined\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n const isTableRowGrouped = !!table.getState().grouping?.length;\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 // column groups offset the bottom padding :shrug:, multiplying by 1.5 ensures the bottom padding remains\n // consistent when there are groups and when there aren't. 1.5 is relatively arbitrary, but it gives alignment\n const scrollPaddingEnd = ROW_HEIGHT_ESTIMATES.medium * (table.getHeaderGroups().length > 1 ? 1.5 : 1);\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 top and bottom spacing for the scroll container - very sensitive, don't change\n scrollMargin: isTableRowGrouped ? 0 : scrollPaddingStart,\n // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list\n scrollPaddingStart,\n scrollPaddingEnd: tableMeta.footer.isEnabled ? scrollPaddingEnd * 2 : scrollPaddingEnd,\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 // styling for offsetting rows - this \"is\" the virtualisation\n const [paddingTop, paddingBottom] =\n virtualItems.length > 0\n ? [\n Math.max(0, virtualItems[paddingStartIndex]?.start - virtualItems[paddingStartIndex]?.size ?? 0),\n Math.max(0, totalSize - virtualItems[virtualItems.length - 1]?.end ?? 0),\n ]\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\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 => {\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":["useTableRenderer","renderers","table","tableRef","defaultRowActiveIndex","tableMeta","options","meta","rows","getRowModel","isTableRowGrouped","_table$getState$group","getState","grouping","length","createRowMeasurer","estimateSize","useRowHeightVirtualisation","rangeExtractor","useRowGroupVirtualisation","scrollPaddingStart","ROW_HEIGHT_ESTIMATES","medium","scrollPaddingEnd","getHeaderGroups","virtualiser","useVirtualizer","count","getScrollElement","current","overscan","printing","isPrinting","undefined","scrollMargin","footer","isEnabled","totalSize","getTotalSize","virtualItems","getVirtualItems","scrollToIndex","React","useCallback","index","align","behavior","notSmooth","scrollToOffset","scrollTop","scrollHeight","paddingStartIndex","paddingTop","paddingBottom","Math","max","_ref","_virtualItems$padding","start","_virtualItems$padding2","size","_ref2","_virtualItems","end","useEffect","style","content","height","map","virtualRow","row","measureRow","resizeItem","Row","key","id","renderer","cellRenderer","cell","expandedState","expanded","expandedRowHeightsCache","setExpandedRowHeightsCache","useState","averageExpandedRowHeight","useMemo","values","Object","reduce","a","b","rowHeight","_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":";;;;;SAagBA,gBAAgBA,CAC5BC,SAAmC,EACnCC,KAAwB,EACxBC,QAAmC,EACnCC,qBAA0C;;EAE1C,MAAMC,SAAS,GAAGH,KAAK,CAACI,OAAO,CAACC,IAA6B;EAC7D,MAAMC,IAAI,GAAGN,KAAK,CAACO,WAAW,EAAE,CAACD,IAAI;EACrC,MAAME,iBAAiB,GAAG,CAAC,GAAAC,qBAAA,GAACT,KAAK,CAACU,QAAQ,EAAE,CAACC,QAAQ,cAAAF,qBAAA,eAAzBA,qBAAA,CAA2BG,MAAM;;EAG7D,MAAM;IAAEC,iBAAiB;IAAEC;GAAc,GAAGC,0BAA0B,CAAQf,KAAK,CAAC;;EAGpF,MAAMgB,cAAc,GAAGC,yBAAyB,CAAQjB,KAAK,CAAC;;EAG9D,MAAMkB,kBAAkB,GAAGC,oBAAoB,CAACC,MAAM;;;EAGtD,MAAMC,gBAAgB,GAAGF,oBAAoB,CAACC,MAAM,IAAIpB,KAAK,CAACsB,eAAe,EAAE,CAACV,MAAM,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;EAErG,MAAMW,WAAW,GAAGC,cAAc,CAAC;IAC/BC,KAAK,EAAEnB,IAAI,CAACM,MAAM;IAClBE,YAAY;IACZY,gBAAgB,EAAEA,MAAMzB,QAAQ,CAAC0B,OAAO;IACxCC,QAAQ,EAAEzB,SAAS,CAAC0B,QAAQ,CAACC,UAAU,GAAGxB,IAAI,CAACM,MAAM,GAAGmB,SAAS;IACjEf,cAAc;;IAEdgB,YAAY,EAAExB,iBAAiB,GAAG,CAAC,GAAGU,kBAAkB;;IAExDA,kBAAkB;IAClBG,gBAAgB,EAAElB,SAAS,CAAC8B,MAAM,CAACC,SAAS,GAAGb,gBAAgB,GAAG,CAAC,GAAGA;GACzE,CAA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