@economic/taco 2.54.0 → 2.55.0-EC-64018.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/components/Checkbox/Checkbox.d.ts +7 -2
  2. package/dist/components/List/List.d.ts +2 -2
  3. package/dist/components/List/components/Toggle.d.ts +2 -2
  4. package/dist/components/ModeSwitch/ModeSwitch.d.ts +6 -3
  5. package/dist/components/Switch/Switch.d.ts +6 -4
  6. package/dist/esm/index.css +76 -5
  7. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js +41 -63
  8. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js.map +1 -1
  9. package/dist/esm/packages/taco/src/components/List/components/Toggle.js +14 -4
  10. package/dist/esm/packages/taco/src/components/List/components/Toggle.js.map +1 -1
  11. package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js +6 -3
  12. package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js.map +1 -1
  13. package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js +34 -12
  14. package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js.map +1 -1
  15. package/dist/esm/packages/taco/src/components/Switch/Switch.js +37 -35
  16. package/dist/esm/packages/taco/src/components/Switch/Switch.js.map +1 -1
  17. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
  18. package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js.map +1 -1
  19. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js +1 -0
  20. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js.map +1 -1
  21. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader2.js +2 -2
  22. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader2.js.map +1 -1
  23. package/dist/index.css +76 -5
  24. package/dist/taco.cjs.development.js +135 -121
  25. package/dist/taco.cjs.development.js.map +1 -1
  26. package/dist/taco.cjs.production.min.js +1 -1
  27. package/dist/taco.cjs.production.min.js.map +1 -1
  28. package/package.json +3 -3
@@ -191,6 +191,7 @@ const MemoedHeader = /*#__PURE__*/React__default.memo(function MemoedHeader(prop
191
191
  "data-cell-align": isGroup ? 'center' : align,
192
192
  "data-cell-id": id,
193
193
  "data-cell-pinned": isPinned ? isPinned : undefined,
194
+ "data-taco": isGroup ? 'grouped-column-header' : 'column-header',
194
195
  style: style,
195
196
  ref: setRef
196
197
  }), !isPlaceholder ? (/*#__PURE__*/React__default.createElement(HeaderContent, {
@@ -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\ninterface HeaderContentProps {\n children: React.ReactNode;\n tooltip?: React.ReactNode;\n isInternalColumnHeader: boolean;\n}\n\nconst HeaderContent = ({ children, tooltip, isInternalColumnHeader }: HeaderContentProps) => {\n if (isInternalColumnHeader || typeof children !== 'string') {\n return <>{children}</>;\n }\n\n return (\n <Tooltip title={String(tooltip ?? children)} placement=\"top\">\n <span className=\"truncate\">{children}</span>\n </Tooltip>\n );\n};\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 memoedProps.resetSize = header.column.resetSize;\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 resetSize?: () => 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 resetSize: handleResetSize,\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 ? (\n <HeaderContent children={children} tooltip={tooltip} isInternalColumnHeader={!!isInternalColumn(id)} />\n ) : null}\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 onResetSize={handleResetSize as () => void}\n setColumnSizing={setColumnSizing}\n width={width}\n />\n ) : null}\n </th>\n );\n});\n"],"names":["HeaderContent","children","tooltip","isInternalColumnHeader","React","Tooltip","title","String","placement","className","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","cn","headerClassName","flexRender","colSpan","customMenu","defaultWidth","isFiltered","getIsFiltered","index","offset","getStart","setRowActiveIndex","rowActive","setColumnSizing","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","resetSize","handleSortToggle","sortDirection","clearSorting","toggleSorting","onSort","getToggleSortingHandler","onSortToggle","MemoedHeader","key","memo","handleFilter","handleHide","handlePin","handleResize","handleSort","handleResetSize","ref","setRef","useState","useSetInitialColumnSizing","style","gridColumn","getSortAttributes","SortIndicator","direction","HeaderMenu","columnId","Resizer","headerRef","onResetSize"],"mappings":";;;;;;;;;;;AA6BA,MAAMA,aAAa,GAAGA,CAAC;EAAEC,QAAQ;EAAEC,OAAO;EAAEC;CAA4C;EACpF,IAAIA,sBAAsB,IAAI,OAAOF,QAAQ,KAAK,QAAQ,EAAE;IACxD,oBAAOG,4DAAGH,QAAQ,CAAI;;EAG1B,oBACIG,6BAACC,OAAO;IAACC,KAAK,EAAEC,MAAM,CAACL,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAID,QAAQ,CAAC;IAAEO,SAAS,EAAC;kBACnDJ;IAAMK,SAAS,EAAC;KAAYR,QAAQ,CAAQ,CACtC;AAElB,CAAC;SAOeS,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,M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AAM,EAAEA,KAAK,KAAK;KACrB,CAAC;IACFK,UAAU,EAAEA,UAAU;IACtBI,KAAK,EAAEA,KAAK;IACZF,UAAU,EAAEA,UAAU;IACtBa,QAAQ,EAAEqC,YAAY;IACtBhC,MAAM,EAAEI,UAAU;IAClBE,MAAM,EAAE2B,UAAU;IAClBzB,KAAK,EAAE0B,SAAS;IAChBN,YAAY,EAAEN,gBAAgB;IAC9B7F,aAAa,EAAEA,aAAa;IAC5B0D,iBAAiB,EAAEA,iBAAiB;IACpCoC,aAAa,EAAEA,aAAa;IAC5ByB,QAAQ,EAAElF;IACZ,IACF,IAAI,EACPV,SAAS,iBACNpC,6BAACiI,OAAO;IACJC,SAAS,EAAEZ,GAAG;IACdxE,EAAE,EAAEA,EAAE;IACNmD,UAAU,EAAEA,UAAqB;IACjCE,QAAQ,EAAEgB,YAAwC;IAClDgB,WAAW,EAAEd,eAA6B;IAC1ChD,eAAe,EAAEA,eAAe;IAChCC,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\ninterface HeaderContentProps {\n children: React.ReactNode;\n tooltip?: React.ReactNode;\n isInternalColumnHeader: boolean;\n}\n\nconst HeaderContent = ({ children, tooltip, isInternalColumnHeader }: HeaderContentProps) => {\n if (isInternalColumnHeader || typeof children !== 'string') {\n return <>{children}</>;\n }\n\n return (\n <Tooltip title={String(tooltip ?? children)} placement=\"top\">\n <span className=\"truncate\">{children}</span>\n </Tooltip>\n );\n};\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 memoedProps.resetSize = header.column.resetSize;\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 resetSize?: () => 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 resetSize: handleResetSize,\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 data-taco={isGroup ? 'grouped-column-header' : 'column-header'}\n style={style}\n ref={setRef}>\n {!isPlaceholder ? (\n <HeaderContent children={children} tooltip={tooltip} isInternalColumnHeader={!!isInternalColumn(id)} />\n ) : null}\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 onResetSize={handleResetSize as () => void}\n setColumnSizing={setColumnSizing}\n width={width}\n />\n ) : null}\n </th>\n );\n});\n"],"names":["HeaderContent","children","tooltip","isInternalColumnHeader","React","Tooltip","title","String","placement","className","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","cn","headerClassName","flexRender","colSpan","customMenu","defaultWidth","isFiltered","getIsFiltered","index","offset","getStart","setRowActiveIndex","rowActive","setColumnSizing","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","resetSize","handleSortToggle","sortDirection","clearSorting","toggleSorting","onSort","getToggleSortingHandler","onSortToggle","MemoedHeader","key","memo","handleFilter","handleHide","handlePin","handleResize","handleSort","handleResetSize","ref","setRef","useState","useSetInitialColumnSizing","style","gridColumn","getSortAttributes","SortIndicator","direction","HeaderMenu","columnId","Resizer","headerRef","onResetSize"],"mappings":";;;;;;;;;;;AA6BA,MAAMA,aAAa,GAAGA,CAAC;EAAEC,QAAQ;EAAEC,OAAO;EAAEC;CAA4C;EACpF,IAAIA,sBAAsB,IAAI,OAAOF,QAAQ,KAAK,QAAQ,EAAE;IACxD,oBAAOG,4DAAGH,QAAQ,CAAI;;EAG1B,oBACIG,6BAACC,OAAO;IAACC,KAAK,EAAEC,MAAM,CAACL,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAID,QAAQ,CAAC;IAAEO,SAAS,EAAC;kBACnDJ;IAAMK,SAAS,EAAC;KAAYR,QAAQ,CAAQ,CACtC;AAElB,CAAC;SAOeS,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,IAA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B,CAACC,EAAE;IAAK,IACvG,IAAI,EACPyD,aAAa,gBAAGvG,6BAAC6H,aAAa;IAACC,SAAS,EAAEvB;IAAiB,GAAG,IAAI,EAClE3D,OAAO,iBACJ5C,6BAAC+H,UAAU;IACPtG,SAAS,EAAEA,SAAS;IACpBe,OAAO,EAAEA,OAAO;IAChBX,OAAO,EAAEA,OAAO;IAChBK,MAAM,EAAEA,MAAM;IACdI,OAAO,EAAEA,OAAO;IAChBjC,SAAS,EAAEmD,EAAE,CAAC;MACV,SAAS,EAAED,KAAK,KAAK,OAAO;MAC5B,MAAM,EAAEA,KAAK,KAAK;KACrB,CAAC;IACFK,UAAU,EAAEA,UAAU;IACtBI,KAAK,EAAEA,KAAK;IACZF,UAAU,EAAEA,UAAU;IACtBa,QAAQ,EAAEqC,YAAY;IACtBhC,MAAM,EAAEI,UAAU;IAClBE,MAAM,EAAE2B,UAAU;IAClBzB,KAAK,EAAE0B,SAAS;IAChBN,YAAY,EAAEN,gBAAgB;IAC9B7F,aAAa,EAAEA,aAAa;IAC5B0D,iBAAiB,EAAEA,iBAAiB;IACpCoC,aAAa,EAAEA,aAAa;IAC5ByB,QAAQ,EAAElF;IACZ,IACF,IAAI,EACPV,SAAS,iBACNpC,6BAACiI,OAAO;IACJC,SAAS,EAAEZ,GAAG;IACdxE,EAAE,EAAEA,EAAE;IACNmD,UAAU,EAAEA,UAAqB;IACjCE,QAAQ,EAAEgB,YAAwC;IAClDgB,WAAW,EAAEd,eAA6B;IAC1ChD,eAAe,EAAEA,eAAe;IAChCC,KAAK,EAAEA;IACT,IACF,IAAI,CACP;AAEb,CAAC,CAAC;;;;"}
@@ -9,11 +9,11 @@ function useTableDataLoader2(fetchPage, fetchAll, options = {
9
9
  }) {
10
10
  const loadPage = function (pageIndex, sorting, filters, hiddenColumns, search, reset = false) {
11
11
  try {
12
+ const hasChangedData = JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) || JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current) || search !== _lastUsedSearch.current;
12
13
  // if a request is already pending for this page (and it's not a reset), skip it
13
- if (_pendingPageRequests.current[pageIndex] && !reset) {
14
+ if (_pendingPageRequests.current[pageIndex] && !hasChangedData && !reset) {
14
15
  return Promise.resolve();
15
16
  }
16
- const hasChangedData = JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) || JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current) || search !== _lastUsedSearch.current;
17
17
  // if the page is already loaded and has actual rows, abort
18
18
  if (data.cache[pageIndex] && data.cache[pageIndex][0] && !hasChangedData && !reset) {
19
19
  return Promise.resolve();
@@ -1 +1 @@
1
- {"version":3,"file":"useTableDataLoader2.js","sources":["../../../../../../../src/primitives/Table/useTableDataLoader2.ts"],"sourcesContent":["import React from 'react';\nimport { v4 as uuid } from 'uuid';\nimport {\n TableColumnFilter,\n TableColumnSort,\n TableFilterHandler,\n TableServerLoadPageHandler,\n TableServerLoadAllHandler,\n TableSortHandler,\n TableSearchHandler,\n} from './types';\nimport { DEFAULT_PAGE_SIZE, useTableDataLoaderOptions } from './useTableDataLoader';\n\nconst DATASET_SIZE_MULTIPLIER = 15;\n\nexport type useTableDataPageFetcher2<TType = unknown> = (\n pageIndex: number,\n pageSize: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataAllFetcher2<TType = unknown> = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataLoaderValues2<TType = unknown> = {\n data: TType[];\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n onChangeFilter: TableFilterHandler;\n onChangeSearch: TableSearchHandler;\n onChangeSort: TableSortHandler;\n pageSize: number;\n pages: number[];\n _experimentalDataLoader2: boolean;\n};\n\ntype Data<TType = unknown> = {\n rows: TType[];\n pages: number[];\n cache: Record<number, TType[]>;\n lastFetchedPage: number | undefined;\n};\ntype Direction = 'forward' | 'backward' | undefined;\n\nexport function useTableDataLoader2<TType = unknown>(\n fetchPage: useTableDataPageFetcher2<TType>,\n fetchAll: useTableDataAllFetcher2<TType>,\n options: useTableDataLoaderOptions = { pageSize: DEFAULT_PAGE_SIZE }\n): [useTableDataLoaderValues2<TType>, () => void] {\n const { pageSize } = options;\n const DATASET_SIZE = DATASET_SIZE_MULTIPLIER * pageSize;\n\n // track the data length, we don't know it until the first request\n const length = React.useRef<number>(0);\n // data will be filled after the first request\n const [data, setData] = React.useState<Data<TType>>({ rows: [], pages: [], cache: {}, lastFetchedPage: undefined });\n // track which pages have been loaded to dedupe requests\n const _pendingPageRequests = React.useRef<Record<number, boolean>>({});\n // it's possible to spam updates, e.g. sort, so we don't set state if the last request wasn't the current oen\n const _lastRequestId = React.useRef<string | undefined>();\n // store last used properties\n const _lastUsedSorting = React.useRef<TableColumnSort[]>([]);\n const _lastUsedFilters = React.useRef<TableColumnFilter[]>([]);\n const _lastUsedSearch = React.useRef<string | undefined>();\n const _lastUsedHiddenColumns = React.useRef<string[]>([]);\n\n async function loadPage(\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined,\n reset = false\n ) {\n // if a request is already pending for this page (and it's not a reset), skip it\n if (_pendingPageRequests.current[pageIndex] && !reset) {\n return;\n }\n\n const hasChangedData =\n JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) ||\n JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current) ||\n search !== _lastUsedSearch.current;\n\n // if the page is already loaded and has actual rows, abort\n if (data.cache[pageIndex] && data.cache[pageIndex][0] && !hasChangedData && !reset) {\n return;\n }\n\n // create an id to track the update\n const requestId = uuid();\n\n // set the page as loading, so that subsequent requests don't retrigger it\n _pendingPageRequests.current[pageIndex] = true;\n\n try {\n _lastRequestId.current = requestId;\n const response = await fetchPage(pageIndex, pageSize, sorting, filters, hiddenColumns, search);\n length.current = response.length;\n\n // update state, here we do some \"magic\" to support \"load in place\"\n setData(currentData => {\n // if this request wasn't the last one, just return the current state to prevent weird updates\n if (_lastRequestId.current !== requestId) {\n return currentData;\n }\n\n const direction = getDirection(pageIndex, currentData.pages);\n const nextPages = getPages(pageIndex, currentData.lastFetchedPage, reset ? [] : currentData.pages, direction);\n\n // set values so we can track if they changed between loads\n _lastUsedSorting.current = sorting;\n _lastUsedFilters.current = filters;\n _lastUsedSearch.current = search;\n _lastUsedHiddenColumns.current = hiddenColumns;\n\n // cache data as an object to prevent any duplicates for pages\n let nextCache: Record<number, TType[]>;\n\n if (reset || hasChangedData || !direction) {\n nextCache = nextPages.reduce((acc, p) => ({ ...acc, [p]: Array(pageSize).fill(undefined) }), {});\n } else {\n nextCache = { ...currentData.cache };\n }\n\n nextCache[pageIndex] = response.data;\n\n // cleanup \"unloaded\" pages\n if (direction === 'forward' && currentData.rows.length >= DATASET_SIZE) {\n delete nextCache[currentData.pages[0]];\n } else if (direction === 'backward' && currentData.rows.length >= DATASET_SIZE) {\n delete nextCache[currentData.pages[currentData.pages.length - 1]];\n }\n\n // remap rows from the cached data - do it here and not in render to save some performance\n const rows = Object.values(nextCache).reduce((acc, p) => acc.concat(p), []);\n\n return {\n cache: nextCache,\n pages: nextPages,\n rows: rows,\n lastFetchedPage: pageIndex,\n };\n });\n\n // reset pending requests\n delete _pendingPageRequests.current[pageIndex];\n } catch {\n //\n }\n }\n\n const loadAll = async (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n ) => {\n // set values so we can track if they changed between loads\n _lastUsedSorting.current = sorting;\n _lastUsedFilters.current = filters;\n _lastUsedSearch.current = search;\n _lastUsedHiddenColumns.current = hiddenColumns;\n\n try {\n const response = await fetchAll(sorting, filters, hiddenColumns, search);\n length.current = response.length;\n\n const pages: number[] = [];\n const cache = {};\n const pageCount = Math.ceil(response.length / pageSize);\n\n Array.from(Array(pageCount).keys()).forEach(index => {\n pages.push(index);\n const startIndex = index * pageSize;\n cache[index] = response.data.slice(startIndex, startIndex + pageSize);\n });\n\n setData({\n cache,\n pages,\n rows: response.data,\n lastFetchedPage: undefined,\n });\n } catch {\n //\n } finally {\n // reset pending requests\n _pendingPageRequests.current = {};\n }\n };\n\n const invalidate = async () => {\n // reset stuff\n _pendingPageRequests.current = {};\n\n // load the current page again\n return loadPage(\n getCurrentPage(data.pages),\n _lastUsedSorting.current,\n _lastUsedFilters.current,\n _lastUsedHiddenColumns.current,\n _lastUsedSearch.current,\n true\n );\n };\n\n const handleSort = async (sorting: TableColumnSort[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n\n return loadPage(\n getCurrentPage(data.pages),\n sorting,\n _lastUsedFilters.current,\n _lastUsedHiddenColumns.current,\n _lastUsedSearch.current,\n true\n );\n };\n const handleFilter = async (filters: TableColumnFilter[], hiddenColumns: string[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n return loadPage(0, _lastUsedSorting.current, filters, hiddenColumns, _lastUsedSearch.current, true);\n };\n const handleSearch = async (search: string | undefined, hiddenColumns: string[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n return loadPage(0, _lastUsedSorting.current, _lastUsedFilters.current, hiddenColumns, search, true);\n };\n\n return [\n {\n data: data.rows,\n pages: data.pages,\n length: length.current,\n loadAll,\n loadPage,\n onChangeFilter: handleFilter,\n onChangeSearch: handleSearch,\n onChangeSort: handleSort,\n pageSize,\n _experimentalDataLoader2: true,\n },\n invalidate,\n ];\n}\n\nfunction getCurrentPage(currentPages: number[]): number {\n if (currentPages.length <= 2) {\n return currentPages[0];\n }\n\n // for even page lengths we can't know which is the current visible page - it could even be both\n // so we load one of them and rely on the \"load next/previous page\" functionality in row\n const middle = Math.floor(currentPages.length / 2);\n return currentPages[middle];\n}\n\nfunction getDirection(pageIndex: number, currentPages: number[]): Direction {\n if (currentPages.length) {\n if (pageIndex === currentPages[currentPages.length - 1] + 1) {\n return 'forward';\n } else if (\n pageIndex === currentPages[0] - 1 ||\n (currentPages.length === 2 && currentPages[0] !== 0 && pageIndex === currentPages[0])\n ) {\n return 'backward';\n }\n }\n\n return undefined;\n}\n\nfunction getPages(pageIndex: number, lastUsedPageIndex: number | undefined, currentPages: number[], direction: Direction) {\n if (currentPages.length && (pageIndex === lastUsedPageIndex || currentPages.includes(pageIndex))) {\n return currentPages;\n }\n\n if (direction === 'forward') {\n const nextPages = currentPages.length === DATASET_SIZE_MULTIPLIER ? currentPages.slice(1) : currentPages;\n return nextPages.concat(pageIndex);\n }\n\n if (direction === 'backward') {\n const nextPages = currentPages.length === DATASET_SIZE_MULTIPLIER ? currentPages.slice(0, -1) : currentPages;\n return [pageIndex].concat(nextPages);\n }\n\n return [pageIndex];\n}\n"],"names":["DATASET_SIZE_MULTIPLIER","useTableDataLoader2","fetchPage","fetchAll","options","pageSize","DEFAULT_PAGE_SIZE","loadPage","pageIndex","sorting","filters","hiddenColumns","search","reset","_pendingPageRequests","current","Promise","resolve","hasChangedData","JSON","stringify","_lastUsedSorting","_lastUsedFilters","_lastUsedSearch","data","cache","requestId","uuid","_temp2","_catch","_lastRequestId","then","response","length","setData","currentData","direction","getDirection","pages","nextPages","getPages","lastFetchedPage","_lastUsedHiddenColumns","nextCache","reduce","acc","p","Array","fill","undefined","rows","DATASET_SIZE","Object","values","concat","e","reject","React","useRef","useState","loadAll","_temp","_finallyRethrows","pageCount","Math","ceil","from","keys","forEach","index","push","startIndex","slice","_wasThrown","_result","invalidate","getCurrentPage","handleSort","handleFilter","handleSearch","onChangeFilter","onChangeSearch","onChangeSort","_experimentalDataLoader2","currentPages","middle","floor","lastUsedPageIndex","includes"],"mappings":";;;;;AAaA,MAAMA,uBAAuB,GAAG,EAAE;SAuClBC,mBAAmBA,CAC/BC,SAA0C,EAC1CC,QAAwC,EACxCC,UAAqC;EAAEC,QAAQ,EAAEC;CAAmB;QAmBrDC,QAAQ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EAAE+E,iBAAqC,EAAEH,YAAsB,EAAEhD,SAAoB;EACpH,IAAIgD,YAAY,CAACnD,MAAM,KAAKzB,SAAS,KAAK+E,iBAAiB,IAAIH,YAAY,CAACI,QAAQ,CAAChF,SAAS,CAAC,CAAC,EAAE;IAC9F,OAAO4E,YAAY;;EAGvB,IAAIhD,SAAS,KAAK,SAAS,EAAE;IACzB,MAAMG,SAAS,GAAG6C,YAAY,CAACnD,MAAM,KAAKjC,uBAAuB,GAAGoF,YAAY,CAACZ,KAAK,CAAC,CAAC,CAAC,GAAGY,YAAY;IACxG,OAAO7C,SAAS,CAACe,MAAM,CAAC9C,SAAS,CAAC;;EAGtC,IAAI4B,SAAS,KAAK,UAAU,EAAE;IAC1B,MAAMG,SAAS,GAAG6C,YAAY,CAACnD,MAAM,KAAKjC,uBAAuB,GAAGoF,YAAY,CAACZ,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAGY,YAAY;IAC5G,OAAO,CAAC5E,SAAS,CAAC,CAAC8C,MAAM,CAACf,SAAS,CAAC;;EAGxC,OAAO,CAAC/B,SAAS,CAAC;AACtB;;;;"}
1
+ {"version":3,"file":"useTableDataLoader2.js","sources":["../../../../../../../src/primitives/Table/useTableDataLoader2.ts"],"sourcesContent":["import React from 'react';\nimport { v4 as uuid } from 'uuid';\nimport {\n TableColumnFilter,\n TableColumnSort,\n TableFilterHandler,\n TableServerLoadPageHandler,\n TableServerLoadAllHandler,\n TableSortHandler,\n TableSearchHandler,\n} from './types';\nimport { DEFAULT_PAGE_SIZE, useTableDataLoaderOptions } from './useTableDataLoader';\n\nconst DATASET_SIZE_MULTIPLIER = 15;\n\nexport type useTableDataPageFetcher2<TType = unknown> = (\n pageIndex: number,\n pageSize: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataAllFetcher2<TType = unknown> = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataLoaderValues2<TType = unknown> = {\n data: TType[];\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n onChangeFilter: TableFilterHandler;\n onChangeSearch: TableSearchHandler;\n onChangeSort: TableSortHandler;\n pageSize: number;\n pages: number[];\n _experimentalDataLoader2: boolean;\n};\n\ntype Data<TType = unknown> = {\n rows: TType[];\n pages: number[];\n cache: Record<number, TType[]>;\n lastFetchedPage: number | undefined;\n};\ntype Direction = 'forward' | 'backward' | undefined;\n\nexport function useTableDataLoader2<TType = unknown>(\n fetchPage: useTableDataPageFetcher2<TType>,\n fetchAll: useTableDataAllFetcher2<TType>,\n options: useTableDataLoaderOptions = { pageSize: DEFAULT_PAGE_SIZE }\n): [useTableDataLoaderValues2<TType>, () => void] {\n const { pageSize } = options;\n const DATASET_SIZE = DATASET_SIZE_MULTIPLIER * pageSize;\n\n // track the data length, we don't know it until the first request\n const length = React.useRef<number>(0);\n // data will be filled after the first request\n const [data, setData] = React.useState<Data<TType>>({ rows: [], pages: [], cache: {}, lastFetchedPage: undefined });\n // track which pages have been loaded to dedupe requests\n const _pendingPageRequests = React.useRef<Record<number, boolean>>({});\n // it's possible to spam updates, e.g. sort, so we don't set state if the last request wasn't the current oen\n const _lastRequestId = React.useRef<string | undefined>();\n // store last used properties\n const _lastUsedSorting = React.useRef<TableColumnSort[]>([]);\n const _lastUsedFilters = React.useRef<TableColumnFilter[]>([]);\n const _lastUsedSearch = React.useRef<string | undefined>();\n const _lastUsedHiddenColumns = React.useRef<string[]>([]);\n\n async function loadPage(\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined,\n reset = false\n ) {\n const hasChangedData =\n JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) ||\n JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current) ||\n search !== _lastUsedSearch.current;\n\n // if a request is already pending for this page (and it's not a reset), skip it\n if (_pendingPageRequests.current[pageIndex] && !hasChangedData && !reset) {\n return;\n }\n\n // if the page is already loaded and has actual rows, abort\n if (data.cache[pageIndex] && data.cache[pageIndex][0] && !hasChangedData && !reset) {\n return;\n }\n\n // create an id to track the update\n const requestId = uuid();\n\n // set the page as loading, so that subsequent requests don't retrigger it\n _pendingPageRequests.current[pageIndex] = true;\n\n try {\n _lastRequestId.current = requestId;\n const response = await fetchPage(pageIndex, pageSize, sorting, filters, hiddenColumns, search);\n length.current = response.length;\n\n // update state, here we do some \"magic\" to support \"load in place\"\n setData(currentData => {\n // if this request wasn't the last one, just return the current state to prevent weird updates\n if (_lastRequestId.current !== requestId) {\n return currentData;\n }\n\n const direction = getDirection(pageIndex, currentData.pages);\n const nextPages = getPages(pageIndex, currentData.lastFetchedPage, reset ? [] : currentData.pages, direction);\n\n // set values so we can track if they changed between loads\n _lastUsedSorting.current = sorting;\n _lastUsedFilters.current = filters;\n _lastUsedSearch.current = search;\n _lastUsedHiddenColumns.current = hiddenColumns;\n\n // cache data as an object to prevent any duplicates for pages\n let nextCache: Record<number, TType[]>;\n\n if (reset || hasChangedData || !direction) {\n nextCache = nextPages.reduce((acc, p) => ({ ...acc, [p]: Array(pageSize).fill(undefined) }), {});\n } else {\n nextCache = { ...currentData.cache };\n }\n\n nextCache[pageIndex] = response.data;\n\n // cleanup \"unloaded\" pages\n if (direction === 'forward' && currentData.rows.length >= DATASET_SIZE) {\n delete nextCache[currentData.pages[0]];\n } else if (direction === 'backward' && currentData.rows.length >= DATASET_SIZE) {\n delete nextCache[currentData.pages[currentData.pages.length - 1]];\n }\n\n // remap rows from the cached data - do it here and not in render to save some performance\n const rows = Object.values(nextCache).reduce((acc, p) => acc.concat(p), []);\n\n return {\n cache: nextCache,\n pages: nextPages,\n rows: rows,\n lastFetchedPage: pageIndex,\n };\n });\n\n // reset pending requests\n delete _pendingPageRequests.current[pageIndex];\n } catch {\n //\n }\n }\n\n const loadAll = async (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n ) => {\n // set values so we can track if they changed between loads\n _lastUsedSorting.current = sorting;\n _lastUsedFilters.current = filters;\n _lastUsedSearch.current = search;\n _lastUsedHiddenColumns.current = hiddenColumns;\n\n try {\n const response = await fetchAll(sorting, filters, hiddenColumns, search);\n length.current = response.length;\n\n const pages: number[] = [];\n const cache = {};\n const pageCount = Math.ceil(response.length / pageSize);\n\n Array.from(Array(pageCount).keys()).forEach(index => {\n pages.push(index);\n const startIndex = index * pageSize;\n cache[index] = response.data.slice(startIndex, startIndex + pageSize);\n });\n\n setData({\n cache,\n pages,\n rows: response.data,\n lastFetchedPage: undefined,\n });\n } catch {\n //\n } finally {\n // reset pending requests\n _pendingPageRequests.current = {};\n }\n };\n\n const invalidate = async () => {\n // reset stuff\n _pendingPageRequests.current = {};\n\n // load the current page again\n return loadPage(\n getCurrentPage(data.pages),\n _lastUsedSorting.current,\n _lastUsedFilters.current,\n _lastUsedHiddenColumns.current,\n _lastUsedSearch.current,\n true\n );\n };\n\n const handleSort = async (sorting: TableColumnSort[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n\n return loadPage(\n getCurrentPage(data.pages),\n sorting,\n _lastUsedFilters.current,\n _lastUsedHiddenColumns.current,\n _lastUsedSearch.current,\n true\n );\n };\n const handleFilter = async (filters: TableColumnFilter[], hiddenColumns: string[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n return loadPage(0, _lastUsedSorting.current, filters, hiddenColumns, _lastUsedSearch.current, true);\n };\n const handleSearch = async (search: string | undefined, hiddenColumns: string[]) => {\n // reset before loading the current page\n _pendingPageRequests.current = {};\n return loadPage(0, _lastUsedSorting.current, _lastUsedFilters.current, hiddenColumns, search, true);\n };\n\n return [\n {\n data: data.rows,\n pages: data.pages,\n length: length.current,\n loadAll,\n loadPage,\n onChangeFilter: handleFilter,\n onChangeSearch: handleSearch,\n onChangeSort: handleSort,\n pageSize,\n _experimentalDataLoader2: true,\n },\n invalidate,\n ];\n}\n\nfunction getCurrentPage(currentPages: number[]): number {\n if (currentPages.length <= 2) {\n return currentPages[0];\n }\n\n // for even page lengths we can't know which is the current visible page - it could even be both\n // so we load one of them and rely on the \"load next/previous page\" functionality in row\n const middle = Math.floor(currentPages.length / 2);\n return currentPages[middle];\n}\n\nfunction getDirection(pageIndex: number, currentPages: number[]): Direction {\n if (currentPages.length) {\n if (pageIndex === currentPages[currentPages.length - 1] + 1) {\n return 'forward';\n } else if (\n pageIndex === currentPages[0] - 1 ||\n (currentPages.length === 2 && currentPages[0] !== 0 && pageIndex === currentPages[0])\n ) {\n return 'backward';\n }\n }\n\n return undefined;\n}\n\nfunction getPages(pageIndex: number, lastUsedPageIndex: number | undefined, currentPages: number[], direction: Direction) {\n if (currentPages.length && (pageIndex === lastUsedPageIndex || currentPages.includes(pageIndex))) {\n return currentPages;\n }\n\n if (direction === 'forward') {\n const nextPages = currentPages.length === DATASET_SIZE_MULTIPLIER ? currentPages.slice(1) : currentPages;\n return nextPages.concat(pageIndex);\n }\n\n if (direction === 'backward') {\n const nextPages = currentPages.length === DATASET_SIZE_MULTIPLIER ? currentPages.slice(0, -1) : currentPages;\n return [pageIndex].concat(nextPages);\n }\n\n return [pageIndex];\n}\n"],"names":["DATASET_SIZE_MULTIPLIER","useTableDataLoader2","fetchPage","fetchAll","options","pageSize","DEFAULT_PAGE_SIZE","loadPage","pageIndex","sorting","filters","hiddenColumns","search","reset","hasChangedData","JSON","stringify","_lastUsedSorting","current","_lastUsedFilters","_lastUsedSearch","_pendingPageRequests","Promise","resolve","data","cache","requestId","uuid","_temp2","_catch","_lastRequestId","then","response","length","setData","currentData","direction","getDirection","pages","nextPages","getPages","lastFetchedPage","_lastUsedHiddenColumns","nextCache","reduce","acc","p","Array","fill","undefined","rows","DATASET_SIZE","Object","values","concat","e","reject","React","useRef","useState","loadAll","_temp","_finallyRethrows","pageCount","Math","ceil","from","keys","forEach","index","push","startIndex","slice","_wasThrown","_result","invalidate","getCurrentPage","handleSort","handleFilter","handleSearch","onChangeFilter","onChangeSearch","onChangeSort","_experimentalDataLoader2","currentPages","middle","floor","lastUsedPageIndex","includes"],"mappings":";;;;;AAaA,MAAMA,uBAAuB,GAAG,EAAE;SAuClBC,mBAAmBA,CAC/BC,SAA0C,EAC1CC,QAAwC,EACxCC,UAAqC;EAAEC,QAAQ,EAAEC;CAAmB;QAmBrDC,QAAQ,aACnBC,SAAiB,EACjBC,OAA0B,EAC1BC,OAA4B,EAC5BC,aAAuB,EACvBC,MAA0B,EAC1BC,KAAK,GAAG,KAAK;IAAA;MAEb,MAAMC,cAAc,GAChBC,IAAI,CAACC,SAAS,CAACP,OAAO,CAAC,KAAKM,IAAI,CAACC,SAAS,CAACC,gBAAgB,CAACC,OAAO,CAAC,IACpEH,IAAI,CAACC,SAAS,CAACN,OAAO,CAAC,KAAKK,IAAI,CAACC,SAAS,CAACG,gBAAgB,CAACD,OAAO,CAAC,IACpEN,MAAM,KAAKQ,eAAe,CAACF,OAAO;;MAGtC,IAAIG,oBAAoB,CAACH,OAAO,CAACV,SAAS,CAAC,IAAI,CAACM,cAAc,IAAI,CAACD,KAAK,EAAE;QACtE,OAAAS,OAAA,CAAAC,OAAA;;;MAIJ,IAAIC,IAAI,CAACC,KAAK,CAACjB,SAAS,CAAC,IAAIgB,IAAI,CAACC,KAAK,CAACjB,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAACM,cAAc,IAAI,CAACD,KAAK,EAAE;QAChF,OAAAS,OAAA,CAAAC,OAAA;;;MAIJ,MAAMG,SAAS,GAAGC,EAAI,EAAE;;MAGxBN,oBAAoB,CAACH,OAAO,CAACV,SAAS,CAAC,GAAG,IAAI;MAAC,MAAAoB,MAAA,GAAAC,MAAA,aAE3C;QACAC,cAAc,CAACZ,OAAO,GAAGQ,SAAS;QAAC,OAAAJ,OAAA,CAAAC,OAAA,CACZrB,SA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AG,CAAC,EAAE;MACzD,OAAO,SAAS;KACnB,MAAM,IACHzB,SAAS,KAAK4E,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,IAChCA,YAAY,CAACnD,MAAM,KAAK,CAAC,IAAImD,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI5E,SAAS,KAAK4E,YAAY,CAAC,CAAC,CAAE,EACvF;MACE,OAAO,UAAU;;;EAIzB,OAAOnC,SAAS;AACpB;AAEA,SAAST,QAAQA,CAAChC,SAAiB,EAAE+E,iBAAqC,EAAEH,YAAsB,EAAEhD,SAAoB;EACpH,IAAIgD,YAAY,CAACnD,MAAM,KAAKzB,SAAS,KAAK+E,iBAAiB,IAAIH,YAAY,CAACI,QAAQ,CAAChF,SAAS,CAAC,CAAC,EAAE;IAC9F,OAAO4E,YAAY;;EAGvB,IAAIhD,SAAS,KAAK,SAAS,EAAE;IACzB,MAAMG,SAAS,GAAG6C,YAAY,CAACnD,MAAM,KAAKjC,uBAAuB,GAAGoF,YAAY,CAACZ,KAAK,CAAC,CAAC,CAAC,GAAGY,YAAY;IACxG,OAAO7C,SAAS,CAACe,MAAM,CAAC9C,SAAS,CAAC;;EAGtC,IAAI4B,SAAS,KAAK,UAAU,EAAE;IAC1B,MAAMG,SAAS,GAAG6C,YAAY,CAACnD,MAAM,KAAKjC,uBAAuB,GAAGoF,YAAY,CAACZ,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAGY,YAAY;IAC5G,OAAO,CAAC5E,SAAS,CAAC,CAAC8C,MAAM,CAACf,SAAS,CAAC;;EAGxC,OAAO,CAAC/B,SAAS,CAAC;AACtB;;;;"}
package/dist/index.css CHANGED
@@ -350,6 +350,77 @@
350
350
  stroke: currentColor;
351
351
  }
352
352
 
353
+ /* Base styles */
354
+ [data-taco='checkbox-container'] [data-taco='checkbox'] {
355
+ @apply border-grey-500;
356
+ }
357
+
358
+ [data-taco='checkbox-container'][data-focus-visible] [data-taco='checkbox'] {
359
+ @apply yt-focus;
360
+ }
361
+
362
+ /* Readonly state */
363
+ [data-taco='checkbox-container'][data-readonly] [data-taco='checkbox'] {
364
+ @apply cursor-default;
365
+ }
366
+
367
+ /* Invalid state */
368
+ [data-taco='checkbox-container'][data-invalid] [data-taco='checkbox'] {
369
+ @apply border-red-500;
370
+ }
371
+
372
+ /* Selected or indeterminate state */
373
+ [data-taco='checkbox-container'][data-selected] [data-taco='checkbox'],
374
+ [data-taco='checkbox-container'][data-indeterminate] [data-taco='checkbox'] {
375
+ @apply border-blue-500 bg-blue-500;
376
+ }
377
+
378
+ /* Selected or indeterminate AND invalid state */
379
+ [data-taco='checkbox-container'][data-selected][data-invalid] [data-taco='checkbox'],
380
+ [data-taco='checkbox-container'][data-indeterminate][data-invalid] [data-taco='checkbox'] {
381
+ @apply !border-red-500 !bg-red-500;
382
+ }
383
+
384
+ /* Disabled state */
385
+ [data-taco='checkbox-container'][data-disabled] [data-taco='checkbox'] {
386
+ @apply border-grey-500/50 cursor-not-allowed;
387
+ }
388
+
389
+ [data-taco='checkbox-container'][data-disabled][data-invalid] [data-taco='checkbox'] {
390
+ @apply !border-red-500/50 !bg-red-500/50;
391
+ }
392
+
393
+ [data-taco='checkbox-container'][data-disabled][data-selected] [data-taco='checkbox'],
394
+ [data-taco='checkbox-container'][data-disabled][data-indeterminate] [data-taco='checkbox'] {
395
+ @apply !bg-blue-500/50;
396
+ }
397
+
398
+ [data-taco='checkbox-container'][data-disabled][data-selected][data-invalid] [data-taco='checkbox'],
399
+ [data-taco='checkbox-container'][data-disabled][data-indeterminate][data-invalid] [data-taco='checkbox'] {
400
+ @apply !bg-red-500/50 text-white;
401
+ }
402
+
403
+ /* Hover states (separate rules for clarity) */
404
+ [data-taco='checkbox-container']:hover:not([data-disabled]):not([data-readonly]) [data-taco='checkbox'] {
405
+ @apply border-grey-700;
406
+ }
407
+
408
+ [data-taco='checkbox-container']:hover[data-selected]:not([data-disabled]):not([data-readonly]) [data-taco='checkbox'],
409
+ [data-taco='checkbox-container']:hover[data-indeterminate]:not([data-disabled]):not([data-readonly]) [data-taco='checkbox'] {
410
+ @apply !border-blue-700 !bg-blue-700;
411
+ }
412
+
413
+ [data-taco='checkbox-container']:hover[data-invalid]:not([data-disabled]):not([data-readonly]) [data-taco='checkbox'] {
414
+ @apply !border-red-700;
415
+ }
416
+
417
+ [data-taco='checkbox-container']:hover[data-invalid][data-selected]:not([data-disabled]):not([data-readonly])
418
+ [data-taco='checkbox'],
419
+ [data-taco='checkbox-container']:hover[data-invalid][data-indeterminate]:not([data-disabled]):not([data-readonly])
420
+ [data-taco='checkbox'] {
421
+ @apply !border-red-700 !bg-red-700;
422
+ }
423
+
353
424
  [data-taco='scrollable-list'].yt-list--multiselect li:first-child {
354
425
  @apply border-grey-100 border-b-2 pl-4; /* Listbox max-height is dependant on this border-bottom-width value! */
355
426
  }
@@ -824,7 +895,7 @@ table[data-taco^='table'] td[data-cell-truncate='true'] [data-taco='textarea'] {
824
895
  @apply focus:absolute focus:overflow-y-auto;
825
896
  }
826
897
 
827
- table[data-taco^='table'] td label {
898
+ table[data-taco^='table'] td label:not([data-taco='checkbox-label']) {
828
899
  @apply h-fit !min-h-fit w-full !pb-0;
829
900
  }
830
901
 
@@ -863,14 +934,14 @@ table[data-taco^='table'][data-table-font-size='small'] td [data-taco='spinner']
863
934
  @apply !h-4 !w-4;
864
935
  }
865
936
 
866
- table[data-taco^='table'][data-table-font-size='small'] td [data-taco='icon'],
937
+ table[data-taco^='table'][data-table-font-size='small'] td [data-taco='icon']:not([data-taco='checkbox'] *),
867
938
  table[data-taco^='table'][data-table-font-size='small'] td [data-taco='spinner'] {
868
939
  @apply !-my-[3px];
869
940
  }
870
941
 
871
942
  table[data-taco^='table'][data-table-font-size='small'] td [data-taco='badge'],
872
943
  table[data-taco^='table'][data-table-font-size='small'] td [data-taco='badge-icon'],
873
- table[data-taco^='table'][data-table-font-size='small'] td [data-taco='icon'],
944
+ table[data-taco^='table'][data-table-font-size='small'] td [data-taco='icon']:not([data-taco='checkbox'] *),
874
945
  table[data-taco^='table'][data-table-font-size='small'] td [data-taco='spinner'] {
875
946
  @apply !-my-0.5 !text-xs;
876
947
  }
@@ -999,7 +1070,7 @@ table[data-taco^='table'][data-table-font-size='medium'] td [data-taco='icon-but
999
1070
  @apply !-my-1.5;
1000
1071
  }
1001
1072
 
1002
- table[data-taco^='table'][data-table-font-size='medium'] td [data-taco='icon'] {
1073
+ table[data-taco^='table'][data-table-font-size='medium'] td [data-taco='icon']:not([data-taco='checkbox'] *) {
1003
1074
  @apply !-my-0.5;
1004
1075
  }
1005
1076
 
@@ -1084,7 +1155,7 @@ table[data-taco^='table'][data-table-font-size='large'] td [data-taco='icon-butt
1084
1155
  @apply !-my-1;
1085
1156
  }
1086
1157
 
1087
- table[data-taco^='table'][data-table-font-size='large'] td [data-taco='icon'] {
1158
+ table[data-taco^='table'][data-table-font-size='large'] td [data-taco='icon']:not([data-taco='checkbox'] *) {
1088
1159
  @apply !-my-0.5;
1089
1160
  }
1090
1161