@economic/taco 2.26.12 → 2.26.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -607,7 +607,7 @@ table[data-taco^='table'] tr:last-child th:before {
607
607
  /* row groups */
608
608
 
609
609
  table[data-taco^='table'] tr[data-row-group] {
610
- @apply bg-grey-100 sticky top-[calc(var(--table-header-group-depth)_*_42px)] z-20 mt-10 print:mt-0;
610
+ @apply bg-grey-100 sticky top-[calc(var(--table-header-group-depth)_*_42px)] z-30 mt-10 print:mt-0;
611
611
  }
612
612
 
613
613
  table[data-taco^='table'] tr[data-row-group]:first-child {
@@ -50,6 +50,7 @@ function Header(props) {
50
50
  children: flexRender(header.column.columnDef.header, header.getContext()),
51
51
  colSpan: header.colSpan,
52
52
  customMenu: columnMeta.menu,
53
+ defaultWidth: columnMeta.defaultWidth,
53
54
  hasMenu,
54
55
  id: header.id,
55
56
  isFiltered: header.column.getIsFiltered(),
@@ -131,6 +132,7 @@ const MemoedHeader = /*#__PURE__*/React__default.memo(function MemoedHeader(prop
131
132
  className,
132
133
  colSpan,
133
134
  customMenu,
135
+ defaultWidth,
134
136
  hasMenu,
135
137
  id,
136
138
  index,
@@ -156,7 +158,7 @@ const MemoedHeader = /*#__PURE__*/React__default.memo(function MemoedHeader(prop
156
158
  } = props;
157
159
  const [ref, setRef] = React__default.useState(null);
158
160
  // save column width if none is set
159
- useSetInitialColumnSizing(id, width, ref, canMeasureSize, setColumnSizing);
161
+ useSetInitialColumnSizing(id, defaultWidth, width, ref, canMeasureSize, setColumnSizing);
160
162
  // feature specific styles
161
163
  const style = {};
162
164
  // column groups often span multiple columns
@@ -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 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 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, 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","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,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,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AAEA,iBAAiB;IACpCoC,aAAa,EAAEA;IACjB,IACF,IAAI,EACPpE,SAAS,kBACN0E,6BAACuB,OAAO;IACJC,SAAS,EAAEf,GAAG;IACdzE,EAAE,EAAEA,EAAE;IACNqD,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 />\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;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AAYG,QAAQ,CAAQ,CACtC,CACb,EACA8C,aAAa,gBAAGM,6BAACoB,aAAa;IAACC,SAAS,EAAE3B;IAAiB,GAAG,IAAI,EAClE7D,OAAO,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,16 +1,22 @@
1
1
  import React__default from 'react';
2
2
  import { isInternalColumn } from '../../../useTableManager/util/columns.js';
3
3
 
4
- function useSetInitialColumnSizing(id, width, element, canMeasureSize, setColumnSizing) {
5
- React__default.useEffect(() => {
4
+ function useSetInitialColumnSizing(id, defaultWidth, width, element, canMeasureSize, setColumnSizing) {
5
+ React__default.useLayoutEffect(() => {
6
6
  // columns must set a pixel width...
7
7
  // otherwise when scrolling through the table, the column widths adjust based on the content
8
8
  // of the column, this is because to the virtualisation mounting new rows and unmounting old ones
9
9
  if (canMeasureSize && element && !Number.isInteger(width) && !isInternalColumn(id)) {
10
- setColumnSizing(sizes => ({
10
+ const setWidth = () => setColumnSizing(sizes => ({
11
11
  ...sizes,
12
12
  [id]: element.getBoundingClientRect().width
13
13
  }));
14
+ // grow columns need to wait for auto layout to run, otherwise they register the incorrect size
15
+ if (defaultWidth === 'grow') {
16
+ requestAnimationFrame(setWidth);
17
+ } else {
18
+ setWidth();
19
+ }
14
20
  }
15
21
  }, [element, canMeasureSize, width]);
16
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sources":["../../../../../../../../../../src/primitives/Table/Core/components/Header/util.ts"],"sourcesContent":["import React from 'react';\nimport { Header as ReactTableHeader, ColumnPinningPosition as ReactTableColumnPinningPosition } from '@tanstack/react-table';\nimport { TableColumnWidth } from '../../../types';\nimport { isInternalColumn } from '../../../useTableManager/util/columns';\n\nexport function useSetInitialColumnSizing(\n id: string,\n width: TableColumnWidth | undefined,\n element: HTMLTableCellElement | null,\n canMeasureSize: boolean,\n setColumnSizing: any\n) {\n React.useEffect(() => {\n // columns must set a pixel width...\n // otherwise when scrolling through the table, the column widths adjust based on the content\n // of the column, this is because to the virtualisation mounting new rows and unmounting old ones\n if (canMeasureSize && element && !Number.isInteger(width) && !isInternalColumn(id)) {\n setColumnSizing(sizes => ({\n ...sizes,\n [id]: element.getBoundingClientRect().width,\n }));\n }\n }, [element, canMeasureSize, width]);\n}\n\nexport function getIsPinned<TType = unknown>(\n header: ReactTableHeader<TType, unknown>\n): ReactTableColumnPinningPosition | undefined {\n // TODO: Is there a native function that does this check for groups?\n return header.subHeaders?.length\n ? header.subHeaders.find(x => x.column.getIsPinned())?.column.getIsPinned()\n : header.column.getIsPinned();\n}\n"],"names":["useSetInitialColumnSizing","id","width","element","canMeasureSize","setColumnSizing","React","useEffect","Number","isInteger","isInternalColumn","sizes","getBoundingClientRect","getIsPinned","header","_header$subHeaders","subHeaders","length","_header$subHeaders$fi","find","x","column"],"mappings":";;;SAKgBA,yBAAyBA,CACrCC,EAAU,EACVC,KAAmC,EACnCC,OAAoC,EACpCC,cAAuB,EACvBC,eAAoB;EAEpBC,cAAK,CAACC,SAAS,CAAC;;;;IAIZ,IAAIH,cAAc,IAAID,OAAO,IAAI,CAACK,MAAM,CAACC,SAAS,CAACP,KAAK,CAAC,IAAI,CAACQ,gBAAgB,CAACT,EAAE,CAAC,EAAE;MAChFI,eAAe,CAACM,KAAK,KAAK;QACtB,GAAGA,KAAK;QACR,CAACV,EAAE,GAAGE,OAAO,CAACS,qBAAqB,EAAE,CAACV;OACzC,CAAC,CAAC;;GAEV,EAAE,CAACC,OAAO,EAAEC,cAAc,EAAEF,KAAK,CAAC,CAAC;AACxC;SAEgBW,WAAWA,CACvBC,MAAwC;;;EAGxC,OAAO,CAAAC,kBAAA,GAAAD,MAAM,CAACE,UAAU,cAAAD,kBAAA,eAAjBA,kBAAA,CAAmBE,MAAM,IAAAC,qBAAA,GAC1BJ,MAAM,CAACE,UAAU,CAACG,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,MAAM,CAACR,WAAW,EAAE,CAAC,cAAAK,qBAAA,uBAAnDA,qBAAA,CAAqDG,MAAM,CAACR,WAAW,EAAE,GACzEC,MAAM,CAACO,MAAM,CAACR,WAAW,EAAE;AACrC;;;;"}
1
+ {"version":3,"file":"util.js","sources":["../../../../../../../../../../src/primitives/Table/Core/components/Header/util.ts"],"sourcesContent":["import React from 'react';\nimport { Header as ReactTableHeader, ColumnPinningPosition as ReactTableColumnPinningPosition } from '@tanstack/react-table';\nimport { TableColumnWidth } from '../../../types';\nimport { isInternalColumn } from '../../../useTableManager/util/columns';\n\nexport function useSetInitialColumnSizing(\n id: string,\n defaultWidth: TableColumnWidth | undefined,\n width: TableColumnWidth | undefined,\n element: HTMLTableCellElement | null,\n canMeasureSize: boolean,\n setColumnSizing: any\n) {\n React.useLayoutEffect(() => {\n // columns must set a pixel width...\n // otherwise when scrolling through the table, the column widths adjust based on the content\n // of the column, this is because to the virtualisation mounting new rows and unmounting old ones\n if (canMeasureSize && element && !Number.isInteger(width) && !isInternalColumn(id)) {\n const setWidth = () =>\n setColumnSizing(sizes => ({\n ...sizes,\n [id]: element.getBoundingClientRect().width,\n }));\n\n // grow columns need to wait for auto layout to run, otherwise they register the incorrect size\n if (defaultWidth === 'grow') {\n requestAnimationFrame(setWidth);\n } else {\n setWidth();\n }\n }\n }, [element, canMeasureSize, width]);\n}\n\nexport function getIsPinned<TType = unknown>(\n header: ReactTableHeader<TType, unknown>\n): ReactTableColumnPinningPosition | undefined {\n // TODO: Is there a native function that does this check for groups?\n return header.subHeaders?.length\n ? header.subHeaders.find(x => x.column.getIsPinned())?.column.getIsPinned()\n : header.column.getIsPinned();\n}\n"],"names":["useSetInitialColumnSizing","id","defaultWidth","width","element","canMeasureSize","setColumnSizing","React","useLayoutEffect","Number","isInteger","isInternalColumn","setWidth","sizes","getBoundingClientRect","requestAnimationFrame","getIsPinned","header","_header$subHeaders","subHeaders","length","_header$subHeaders$fi","find","x","column"],"mappings":";;;SAKgBA,yBAAyBA,CACrCC,EAAU,EACVC,YAA0C,EAC1CC,KAAmC,EACnCC,OAAoC,EACpCC,cAAuB,EACvBC,eAAoB;EAEpBC,cAAK,CAACC,eAAe,CAAC;;;;IAIlB,IAAIH,cAAc,IAAID,OAAO,IAAI,CAACK,MAAM,CAACC,SAAS,CAACP,KAAK,CAAC,IAAI,CAACQ,gBAAgB,CAACV,EAAE,CAAC,EAAE;MAChF,MAAMW,QAAQ,GAAGA,MACbN,eAAe,CAACO,KAAK,KAAK;QACtB,GAAGA,KAAK;QACR,CAACZ,EAAE,GAAGG,OAAO,CAACU,qBAAqB,EAAE,CAACX;OACzC,CAAC,CAAC;;MAGP,IAAID,YAAY,KAAK,MAAM,EAAE;QACzBa,qBAAqB,CAACH,QAAQ,CAAC;OAClC,MAAM;QACHA,QAAQ,EAAE;;;GAGrB,EAAE,CAACR,OAAO,EAAEC,cAAc,EAAEF,KAAK,CAAC,CAAC;AACxC;SAEgBa,WAAWA,CACvBC,MAAwC;;;EAGxC,OAAO,CAAAC,kBAAA,GAAAD,MAAM,CAACE,UAAU,cAAAD,kBAAA,eAAjBA,kBAAA,CAAmBE,MAAM,IAAAC,qBAAA,GAC1BJ,MAAM,CAACE,UAAU,CAACG,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,MAAM,CAACR,WAAW,EAAE,CAAC,cAAAK,qBAAA,uBAAnDA,qBAAA,CAAqDG,MAAM,CAACR,WAAW,EAAE,GACzEC,MAAM,CAACO,MAAM,CAACR,WAAW,EAAE;AACrC;;;;"}
package/dist/index.css CHANGED
@@ -607,7 +607,7 @@ table[data-taco^='table'] tr:last-child th:before {
607
607
  /* row groups */
608
608
 
609
609
  table[data-taco^='table'] tr[data-row-group] {
610
- @apply bg-grey-100 sticky top-[calc(var(--table-header-group-depth)_*_42px)] z-20 mt-10 print:mt-0;
610
+ @apply bg-grey-100 sticky top-[calc(var(--table-header-group-depth)_*_42px)] z-30 mt-10 print:mt-0;
611
611
  }
612
612
 
613
613
  table[data-taco^='table'] tr[data-row-group]:first-child {
@@ -1,4 +1,4 @@
1
1
  import { Header as ReactTableHeader, ColumnPinningPosition as ReactTableColumnPinningPosition } from '@tanstack/react-table';
2
2
  import { TableColumnWidth } from '../../../types';
3
- export declare function useSetInitialColumnSizing(id: string, width: TableColumnWidth | undefined, element: HTMLTableCellElement | null, canMeasureSize: boolean, setColumnSizing: any): void;
3
+ export declare function useSetInitialColumnSizing(id: string, defaultWidth: TableColumnWidth | undefined, width: TableColumnWidth | undefined, element: HTMLTableCellElement | null, canMeasureSize: boolean, setColumnSizing: any): void;
4
4
  export declare function getIsPinned<TType = unknown>(header: ReactTableHeader<TType, unknown>): ReactTableColumnPinningPosition | undefined;
@@ -12467,16 +12467,22 @@ function HeaderMenu(props) {
12467
12467
  });
12468
12468
  }
12469
12469
 
12470
- function useSetInitialColumnSizing(id, width, element, canMeasureSize, setColumnSizing) {
12471
- React__default.useEffect(() => {
12470
+ function useSetInitialColumnSizing(id, defaultWidth, width, element, canMeasureSize, setColumnSizing) {
12471
+ React__default.useLayoutEffect(() => {
12472
12472
  // columns must set a pixel width...
12473
12473
  // otherwise when scrolling through the table, the column widths adjust based on the content
12474
12474
  // of the column, this is because to the virtualisation mounting new rows and unmounting old ones
12475
12475
  if (canMeasureSize && element && !Number.isInteger(width) && !isInternalColumn(id)) {
12476
- setColumnSizing(sizes => ({
12476
+ const setWidth = () => setColumnSizing(sizes => ({
12477
12477
  ...sizes,
12478
12478
  [id]: element.getBoundingClientRect().width
12479
12479
  }));
12480
+ // grow columns need to wait for auto layout to run, otherwise they register the incorrect size
12481
+ if (defaultWidth === 'grow') {
12482
+ requestAnimationFrame(setWidth);
12483
+ } else {
12484
+ setWidth();
12485
+ }
12480
12486
  }
12481
12487
  }, [element, canMeasureSize, width]);
12482
12488
  }
@@ -12527,6 +12533,7 @@ function Header$5(props) {
12527
12533
  children: reactTable.flexRender(header.column.columnDef.header, header.getContext()),
12528
12534
  colSpan: header.colSpan,
12529
12535
  customMenu: columnMeta.menu,
12536
+ defaultWidth: columnMeta.defaultWidth,
12530
12537
  hasMenu,
12531
12538
  id: header.id,
12532
12539
  isFiltered: header.column.getIsFiltered(),
@@ -12608,6 +12615,7 @@ const MemoedHeader = /*#__PURE__*/React__default.memo(function MemoedHeader(prop
12608
12615
  className,
12609
12616
  colSpan,
12610
12617
  customMenu,
12618
+ defaultWidth,
12611
12619
  hasMenu,
12612
12620
  id,
12613
12621
  index,
@@ -12633,7 +12641,7 @@ const MemoedHeader = /*#__PURE__*/React__default.memo(function MemoedHeader(prop
12633
12641
  } = props;
12634
12642
  const [ref, setRef] = React__default.useState(null);
12635
12643
  // save column width if none is set
12636
- useSetInitialColumnSizing(id, width, ref, canMeasureSize, setColumnSizing);
12644
+ useSetInitialColumnSizing(id, defaultWidth, width, ref, canMeasureSize, setColumnSizing);
12637
12645
  // feature specific styles
12638
12646
  const style = {};
12639
12647
  // column groups often span multiple columns