@economic/taco 2.9.2 → 2.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. package/dist/components/Button/Button.d.ts +1 -1
  2. package/dist/components/IconButton/IconButton.d.ts +2 -2
  3. package/dist/components/Provider/Localization.d.ts +6 -0
  4. package/dist/components/Table3/components/columns/header/Header.d.ts +6 -1
  5. package/dist/components/Table3/components/columns/header/Menu.d.ts +4 -0
  6. package/dist/components/Table3/hooks/features/useCurrentRow.d.ts +6 -5
  7. package/dist/components/Table3/hooks/useCssVars.d.ts +2 -1
  8. package/dist/components/Table3/hooks/useTable.d.ts +1 -0
  9. package/dist/components/Table3/types.d.ts +7 -0
  10. package/dist/esm/index.css +92 -16
  11. package/dist/esm/packages/taco/src/components/Button/util.js +5 -1
  12. package/dist/esm/packages/taco/src/components/Button/util.js.map +1 -1
  13. package/dist/esm/packages/taco/src/components/Menu/components/Content.js +1 -1
  14. package/dist/esm/packages/taco/src/components/Menu/components/Content.js.map +1 -1
  15. package/dist/esm/packages/taco/src/components/Provider/Localization.js +7 -1
  16. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  17. package/dist/esm/packages/taco/src/components/Table3/Table3.js +13 -6
  18. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  19. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js +3 -2
  20. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js.map +1 -1
  21. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +5 -3
  22. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map +1 -1
  23. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +5 -3
  24. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
  25. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js +0 -1
  26. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js.map +1 -1
  27. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextareaControl.js +1 -1
  28. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextareaControl.js.map +1 -1
  29. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Header.js +30 -6
  30. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Header.js.map +1 -1
  31. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js +36 -10
  32. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js.map +1 -1
  33. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js +3 -3
  34. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js.map +1 -1
  35. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Drag.js +1 -1
  36. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Drag.js.map +1 -1
  37. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js +1 -1
  38. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js.map +1 -1
  39. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Expansion.js +2 -2
  40. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Expansion.js.map +1 -1
  41. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js +1 -1
  42. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js.map +1 -1
  43. package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js +87 -40
  44. package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js.map +1 -1
  45. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js +10 -0
  46. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js.map +1 -1
  47. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useCurrentRow.js +28 -2
  48. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useCurrentRow.js.map +1 -1
  49. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowClick.js +1 -1
  50. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowClick.js.map +1 -1
  51. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowSelection.js +5 -2
  52. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowSelection.js.map +1 -1
  53. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useCurrentRowListener.js +2 -1
  54. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useCurrentRowListener.js.map +1 -1
  55. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useEditingStateListener.js +8 -4
  56. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useEditingStateListener.js.map +1 -1
  57. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useShortcutsListener.js +1 -1
  58. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useShortcutsListener.js.map +1 -1
  59. package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js +2 -1
  60. package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js.map +1 -1
  61. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js +15 -2
  62. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js.map +1 -1
  63. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js +1 -0
  64. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
  65. package/dist/esm/packages/taco/src/components/Table3/types.js.map +1 -1
  66. package/dist/index.css +92 -16
  67. package/dist/taco.cjs.development.js +272 -96
  68. package/dist/taco.cjs.development.js.map +1 -1
  69. package/dist/taco.cjs.production.min.js +1 -1
  70. package/dist/taco.cjs.production.min.js.map +1 -1
  71. package/dist/types.d.ts +1 -1
  72. package/package.json +2 -2
  73. package/types.json +5803 -5242
@@ -43,8 +43,18 @@ function PrintButton(props) {
43
43
  columnFilters: state.columnFilters,
44
44
  globalFilter: state.globalFilter
45
45
  }), [tableMeta.columnFreezing.frozenColumnIndex, state.columnOrder, state.columnSizing, state.columnVisibility, excludeUnmatchedResults, tableMeta.fontSize.size, tableMeta.rowHeight.height, state.sorting, state.columnFilters, state.globalFilter]);
46
+ const iframeTableChildren = React__default.useMemo(() => React__default.Children.toArray(tableProps.children).filter(child => {
47
+ var _child$props;
48
+ const enableColumnInPrinting = (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.enablePrinting;
49
+ // For table children, only include columns doesn't have 'false' value for enablePrinting prop.
50
+ if ( /*#__PURE__*/React__default.isValidElement(child) && enableColumnInPrinting === false) {
51
+ return false;
52
+ }
53
+ return true;
54
+ }), [tableProps.children]);
46
55
  const iframeTableProps = {
47
56
  ...tableProps,
57
+ children: iframeTableChildren,
48
58
  defaultSettings,
49
59
  id: printTableId
50
60
  };
@@ -1 +1 @@
1
- {"version":3,"file":"PrintButton.js","sources":["../../../../../../../../../../src/components/Table3/components/toolbar/PrintButton/PrintButton.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { ToastReference, useToast } from '../../../../Toast/Toaster';\nimport { PrintIFrame } from './PrintIFrame';\nimport { Table3Props } from '../../../types';\nimport { useGlobalKeyDown } from '../../../../../hooks/useGlobalKeyDown';\nimport { WarningDialog } from './WarningDialog';\n\nconst SAFE_PRINT_CELL_COUNT = 10000;\n\nexport type PrintButtonProps<TType = unknown> = React.HTMLAttributes<HTMLButtonElement> & {\n table: RTable<TType>;\n tableProps: Table3Props<TType>;\n};\n\nexport function PrintButton<TType = unknown>(props: PrintButtonProps<TType>) {\n const { table, tableProps } = props;\n const { texts } = useLocalization();\n const toast = useToast();\n\n const [isPrinting, setIsPrinting] = React.useState(false);\n const [showWarningDialog, setShowWarningDialog] = React.useState(false);\n const loadingToastRef = React.useRef<ToastReference | null>(null);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n\n const tableMeta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n const { printWarningDialogVisibility } = tableMeta.printing;\n\n // When changing printTableId, update packages/taco/src/components/Table3/Table3.tsx file and other usages where\n // printTableId is used to figure out whether the table is a print table or not.\n const printTableId = `${tableProps.id}_print`;\n const excludeUnmatchedResults = tableMeta.search.excludeUnmatchedResults;\n\n const defaultSettings = React.useMemo(\n () => ({\n columnFreezingIndex: tableMeta.columnFreezing.frozenColumnIndex,\n columnOrder: state.columnOrder,\n columnSizing: state.columnSizing,\n columnVisibility: state.columnVisibility,\n excludeUnmatchedRecordsInSearch: excludeUnmatchedResults,\n fontSize: tableMeta.fontSize.size,\n rowHeight: tableMeta.rowHeight.height,\n sorting: state.sorting,\n // we don't save these, but we must pass them to print\n columnFilters: state.columnFilters,\n globalFilter: state.globalFilter,\n }),\n [\n tableMeta.columnFreezing.frozenColumnIndex,\n state.columnOrder,\n state.columnSizing,\n state.columnVisibility,\n excludeUnmatchedResults,\n tableMeta.fontSize.size,\n tableMeta.rowHeight.height,\n state.sorting,\n state.columnFilters,\n state.globalFilter,\n ]\n );\n\n const iframeTableProps = { ...tableProps, defaultSettings, id: printTableId };\n\n useGlobalKeyDown({ key: 'p', meta: true, shift: false }, (event: KeyboardEvent) => {\n event.preventDefault();\n // Starts custom printing\n buttonRef.current?.click();\n });\n\n const handleLoadingError = (error: any) => {\n const errorMessage = `${texts.table3.print.error}: ${error}`;\n\n console.error(errorMessage);\n loadingToastRef.current?.error(errorMessage);\n };\n\n const restoreTableDataWithoutSearch = async () => {\n try {\n await tableMeta.printing.loadAll?.(table.getState().sorting, table.getState().columnFilters, undefined);\n } catch (error) {\n handleLoadingError(error);\n return;\n }\n };\n\n const handleAfterPrint = async () => {\n if (tableMeta.printing.loadAll && excludeUnmatchedResults) {\n await restoreTableDataWithoutSearch();\n }\n setIsPrinting(false);\n loadingToastRef.current?.close();\n };\n\n const handleBeforePrint = () => {\n loadingToastRef.current?.close();\n };\n\n const handlePrint = async () => {\n loadingToastRef.current = toast.loading(texts.table3.print.loading as any);\n\n const getCellCount = (data: TType[]) => (data.length ? data.length * Object.keys(data[0]).length : 0);\n let hasNonSafeCellCount = false;\n\n // if loadAll is not defined, just print with what we've got\n // don't compare length to data.length because the api might be choosing not to return all for performance\n if (!tableMeta.printing.loadAll) {\n const { data } = tableProps;\n const cellCount = getCellCount(data);\n\n hasNonSafeCellCount = cellCount > SAFE_PRINT_CELL_COUNT;\n } else {\n try {\n await tableMeta.printing.loadAll(\n table.getState().sorting,\n table.getState().columnFilters,\n // We need to pass search query to the server when printing, to be able to render correct data set in iFrame,\n // But in \"display\" table, search is performed only on client side, so we'll need to request data again without search query,\n // when printing will be finished.\n excludeUnmatchedResults ? tableMeta.search.query : undefined\n );\n\n // After the loadAll call above, the data changes. Hence, it becomes essential to acquire the data after\n // this call rather than before it.\n const { data } = tableProps;\n const cellCount = getCellCount(data);\n\n hasNonSafeCellCount = cellCount > SAFE_PRINT_CELL_COUNT;\n } catch (error) {\n handleLoadingError(error);\n\n // in case of error, we return early\n return;\n }\n }\n\n if (hasNonSafeCellCount && printWarningDialogVisibility) {\n setShowWarningDialog(true);\n } else {\n // only set printing (mount the iframe) when the data has loaded, it prevents repaint performance slow downs\n setIsPrinting(true);\n }\n };\n\n const handleWarningDialogAccept = () => {\n setIsPrinting(true);\n };\n\n const handleWarningDialogCancel = async () => {\n if (tableMeta.printing.loadAll && excludeUnmatchedResults) {\n await restoreTableDataWithoutSearch();\n }\n };\n\n const handleWarningDialogClose = () => {\n loadingToastRef.current?.close();\n setShowWarningDialog(false);\n };\n\n return (\n <>\n <IconButton\n disabled={isPrinting}\n icon=\"print\"\n onClick={handlePrint}\n aria-label={texts.table3.print.tooltip}\n tooltip={texts.table3.print.tooltip}\n ref={buttonRef}\n />\n {isPrinting && iframeTableProps.data !== null && (\n <PrintIFrame\n onAfterPrint={handleAfterPrint}\n onBeforePrint={handleBeforePrint}\n tableProps={iframeTableProps as Table3Props<TType>}\n />\n )}\n <WarningDialog\n open={showWarningDialog}\n onAccept={handleWarningDialogAccept}\n onClose={handleWarningDialogClose}\n onCancel={handleWarningDialogCancel}\n onVisibilityChange={tableMeta.printing.setPrintWarningDialogVisibility}\n />\n </>\n );\n}\n"],"names":["SAFE_PRINT_CELL_COUNT","PrintButton","props","table","tableProps","texts","useLocalization","toast","useToast","isPrinting","setIsPrinting","React","useState","showWarningDialog","setShowWarningDialog","loadingToastRef","useRef","buttonRef","tableMeta","options","meta","state","getState","printWarningDialogVisibility","printing","printTableId","id","excludeUnmatchedResults","search","defaultSettings","useMemo","columnFreezingIndex","columnFreezing","frozenColumnIndex","columnOrder","columnSizing","columnVisibility","excludeUnmatchedRecordsInSearch","fontSize","size","rowHeight","height","sorting","columnFilters","globalFilter","iframeTableProps","useGlobalKeyDown","key","shift","event","preventDefault","_buttonRef$current","current","click","handleLoadingError","error","errorMessage","table3","print","console","_loadingToastRef$curr","restoreTableDataWithoutSearch","_tableMeta$printing$l","_tableMeta$printing","Promise","resolve","loadAll","call","undefined","then","_temp","e","reject","handleAfterPrint","_loadingToastRef$curr2","close","_temp2","_temp3","handleBeforePrint","_loadingToastRef$curr3","handlePrint","hasNonSafeCellCount","loading","getCellCount","data","length","Object","keys","_temp5","cellCount","_temp4","_catch","query","_exit","_temp6","handleWarningDialogAccept","handleWarningDialogCancel","_temp7","handleWarningDialogClose","_loadingToastRef$curr4","IconButton","disabled","icon","onClick","tooltip","ref","PrintIFrame","onAfterPrint","onBeforePrint","WarningDialog","open","onAccept","onClose","onCancel","onVisibilityChange","setPrintWarningDialogVisibility"],"mappings":";;;;;;;;;AAWA,MAAMA,qBAAqB,GAAG,KAAK;SAOnBC,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,KAAK;IAAEC;GAAY,GAAGF,KAAK;EACnC,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,KAAK,GAAGC,QAAQ,EAAE;EAExB,MAAM,CAACC,UAAU,EAA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,IAAIvC,uBAAuB;UAAA,OAAAqC,OAAA,CAAAC,OAAA,CAC/CJ,6BAA6B,EAAE,EAAAQ,IAAA;;;MAAA,OAAAL,OAAA,CAAAC,OAAA,CAAAgC,MAAA,IAAAA,MAAA,CAAA5B,IAAA,GAAA4B,MAAA,CAAA5B,IAAA;KAE5C,QAAAE,CAAA;MAAA,OAAAP,OAAA,CAAAQ,MAAA,CAAAD,CAAA;;;EAED,MAAM2B,wBAAwB,GAAGA;;IAC7B,CAAAC,sBAAA,GAAApF,eAAe,CAACqC,OAAO,cAAA+C,sBAAA,uBAAvBA,sBAAA,CAAyBxB,KAAK,EAAE;IAChC7D,oBAAoB,CAAC,KAAK,CAAC;GAC9B;EAED,oBACIH,yEACIA,6BAACyF,UAAU;IACPC,QAAQ,EAAE5F,UAAU;IACpB6F,IAAI,EAAC,OAAO;IACZC,OAAO,EAAEvB,WAAW;kBACR3E,KAAK,CAACoD,MAAM,CAACC,KAAK,CAAC8C,OAAO;IACtCA,OAAO,EAAEnG,KAAK,CAACoD,MAAM,CAACC,KAAK,CAAC8C,OAAO;IACnCC,GAAG,EAAExF;IACP,EACDR,UAAU,IAAIoC,gBAAgB,CAACuC,IAAI,KAAK,IAAI,iBACzCzE,6BAAC+F,WAAW;IACRC,YAAY,EAAElC,gBAAgB;IAC9BmC,aAAa,EAAE9B,iBAAiB;IAChC1E,UAAU,EAAEyC;IAEnB,eACDlC,6BAACkG,aAAa;IACVC,IAAI,EAAEjG,iBAAiB;IACvBkG,QAAQ,EAAEhB,yBAAyB;IACnCiB,OAAO,EAAEd,wBAAwB;IACjCe,QAAQ,EAAEjB,yBAAyB;IACnCkB,kBAAkB,EAAEhG,SAAS,CAACM,QAAQ,CAAC2F;IACzC,CACH;AAEX;;;;"}
1
+ {"version":3,"file":"PrintButton.js","sources":["../../../../../../../../../../src/components/Table3/components/toolbar/PrintButton/PrintButton.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { ToastReference, useToast } from '../../../../Toast/Toaster';\nimport { PrintIFrame } from './PrintIFrame';\nimport { Table3ColumnProps, Table3Props } from '../../../types';\nimport { useGlobalKeyDown } from '../../../../../hooks/useGlobalKeyDown';\nimport { WarningDialog } from './WarningDialog';\n\nconst SAFE_PRINT_CELL_COUNT = 10000;\n\nexport type PrintButtonProps<TType = unknown> = React.HTMLAttributes<HTMLButtonElement> & {\n table: RTable<TType>;\n tableProps: Table3Props<TType>;\n};\n\nexport function PrintButton<TType = unknown>(props: PrintButtonProps<TType>) {\n const { table, tableProps } = props;\n const { texts } = useLocalization();\n const toast = useToast();\n\n const [isPrinting, setIsPrinting] = React.useState(false);\n const [showWarningDialog, setShowWarningDialog] = React.useState(false);\n const loadingToastRef = React.useRef<ToastReference | null>(null);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n\n const tableMeta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n const { printWarningDialogVisibility } = tableMeta.printing;\n\n // When changing printTableId, update packages/taco/src/components/Table3/Table3.tsx file and other usages where\n // printTableId is used to figure out whether the table is a print table or not.\n const printTableId = `${tableProps.id}_print`;\n const excludeUnmatchedResults = tableMeta.search.excludeUnmatchedResults;\n\n const defaultSettings = React.useMemo(\n () => ({\n columnFreezingIndex: tableMeta.columnFreezing.frozenColumnIndex,\n columnOrder: state.columnOrder,\n columnSizing: state.columnSizing,\n columnVisibility: state.columnVisibility,\n excludeUnmatchedRecordsInSearch: excludeUnmatchedResults,\n fontSize: tableMeta.fontSize.size,\n rowHeight: tableMeta.rowHeight.height,\n sorting: state.sorting,\n // we don't save these, but we must pass them to print\n columnFilters: state.columnFilters,\n globalFilter: state.globalFilter,\n }),\n [\n tableMeta.columnFreezing.frozenColumnIndex,\n state.columnOrder,\n state.columnSizing,\n state.columnVisibility,\n excludeUnmatchedResults,\n tableMeta.fontSize.size,\n tableMeta.rowHeight.height,\n state.sorting,\n state.columnFilters,\n state.globalFilter,\n ]\n );\n\n const iframeTableChildren = React.useMemo(\n () =>\n (React.Children.toArray(tableProps.children) as React.ReactElement<Table3ColumnProps<TType>>[]).filter(child => {\n const enableColumnInPrinting = child.props?.enablePrinting;\n\n // For table children, only include columns doesn't have 'false' value for enablePrinting prop.\n if (React.isValidElement<Table3ColumnProps<TType>>(child) && enableColumnInPrinting === false) {\n return false;\n }\n\n return true;\n }),\n [tableProps.children]\n );\n\n const iframeTableProps = {\n ...tableProps,\n children: iframeTableChildren,\n defaultSettings,\n id: printTableId,\n };\n\n useGlobalKeyDown({ key: 'p', meta: true, shift: false }, (event: KeyboardEvent) => {\n event.preventDefault();\n // Starts custom printing\n buttonRef.current?.click();\n });\n\n const handleLoadingError = (error: any) => {\n const errorMessage = `${texts.table3.print.error}: ${error}`;\n\n console.error(errorMessage);\n loadingToastRef.current?.error(errorMessage);\n };\n\n const restoreTableDataWithoutSearch = async () => {\n try {\n await tableMeta.printing.loadAll?.(table.getState().sorting, table.getState().columnFilters, undefined);\n } catch (error) {\n handleLoadingError(error);\n return;\n }\n };\n\n const handleAfterPrint = async () => {\n if (tableMeta.printing.loadAll && excludeUnmatchedResults) {\n await restoreTableDataWithoutSearch();\n }\n setIsPrinting(false);\n loadingToastRef.current?.close();\n };\n\n const handleBeforePrint = () => {\n loadingToastRef.current?.close();\n };\n\n const handlePrint = async () => {\n loadingToastRef.current = toast.loading(texts.table3.print.loading as any);\n\n const getCellCount = (data: TType[]) => (data.length ? data.length * Object.keys(data[0]).length : 0);\n let hasNonSafeCellCount = false;\n\n // if loadAll is not defined, just print with what we've got\n // don't compare length to data.length because the api might be choosing not to return all for performance\n if (!tableMeta.printing.loadAll) {\n const { data } = tableProps;\n const cellCount = getCellCount(data);\n\n hasNonSafeCellCount = cellCount > SAFE_PRINT_CELL_COUNT;\n } else {\n try {\n await tableMeta.printing.loadAll(\n table.getState().sorting,\n table.getState().columnFilters,\n // We need to pass search query to the server when printing, to be able to render correct data set in iFrame,\n // But in \"display\" table, search is performed only on client side, so we'll need to request data again without search query,\n // when printing will be finished.\n excludeUnmatchedResults ? tableMeta.search.query : undefined\n );\n\n // After the loadAll call above, the data changes. Hence, it becomes essential to acquire the data after\n // this call rather than before it.\n const { data } = tableProps;\n const cellCount = getCellCount(data);\n\n hasNonSafeCellCount = cellCount > SAFE_PRINT_CELL_COUNT;\n } catch (error) {\n handleLoadingError(error);\n\n // in case of error, we return early\n return;\n }\n }\n\n if (hasNonSafeCellCount && printWarningDialogVisibility) {\n setShowWarningDialog(true);\n } else {\n // only set printing (mount the iframe) when the data has loaded, it prevents repaint performance slow downs\n setIsPrinting(true);\n }\n };\n\n const handleWarningDialogAccept = () => {\n setIsPrinting(true);\n };\n\n const handleWarningDialogCancel = async () => {\n if (tableMeta.printing.loadAll && excludeUnmatchedResults) {\n await restoreTableDataWithoutSearch();\n }\n };\n\n const handleWarningDialogClose = () => {\n loadingToastRef.current?.close();\n setShowWarningDialog(false);\n };\n\n return (\n <>\n <IconButton\n disabled={isPrinting}\n icon=\"print\"\n onClick={handlePrint}\n aria-label={texts.table3.print.tooltip}\n tooltip={texts.table3.print.tooltip}\n ref={buttonRef}\n />\n {isPrinting && iframeTableProps.data !== null && (\n <PrintIFrame\n onAfterPrint={handleAfterPrint}\n onBeforePrint={handleBeforePrint}\n tableProps={iframeTableProps as Table3Props<TType>}\n />\n )}\n <WarningDialog\n open={showWarningDialog}\n onAccept={handleWarningDialogAccept}\n onClose={handleWarningDialogClose}\n onCancel={handleWarningDialogCancel}\n onVisibilityChange={tableMeta.printing.setPrintWarningDialogVisibility}\n />\n </>\n );\n}\n"],"names":["SAFE_PRINT_CELL_COUNT","PrintButton","props","table","tableProps","texts","useLocalization","toast","useToast","isPrinting","setIsPrinting","React","useState","showWarningDialog","setShowWarningDialog","loadingToastRef","useRef","buttonRef","tableMeta","options","meta","state","getState","printWarningDialogVisibility","printing","printTableId","id","excludeUnmatchedResults","search","defaultSettings","useMemo","columnFreezingIndex","columnFreezing","frozenColumnIndex","columnOrder","columnSizing","columnVisibility","excludeUnmatchedRecordsInSearch","fontSize","size","rowHeight","height","sorting","columnFilters","globalFilter","iframeTableChildren","Children","toArray","children","filter","child","enableColumnInPrinting","_child$props","enablePrinting","isValidElement","iframeTableProps","useGlobalKeyDown","key","shift","event","preventDefault","_buttonRef$current","current","click","handleLoadingError","error","errorMessage","table3","print","console","_loadingToastRef$curr","restoreTableDataWithoutSearch","_tableMeta$printing$l","_tableMeta$printing","Promise","resolve","loadAll","call","undefined","then","_temp","e","reject","handleAfterPrint","_loadingToastRef$curr2","close","_temp2","_temp3","handleBeforePrint","_loadingToastRef$curr3","handlePrint","hasNonSafeCellCount","loading","getCellCount","data","length","Object","keys","_temp5","cellCount","_temp4","_catch","query","_exit","_temp6","handleWarningDialogAccept","handleWarningDialogCancel","_temp7","handleWarningDialogClose","_loadingToastRef$curr4","IconButton","disabled","icon","onClick","tooltip","ref","PrintIFrame","onAfterPrint","onBeforePrint","WarningDialog","open","onAccept","onClose","onCancel","onVisibilityChange","setPrintWarningDialogVisibility"],"mappings":";;;;;;;;;AAWA,MAAMA,qBAAqB,GAAG,KAAK;SAOnBC,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,KAAK;IAAEC;GAAY,GAAGF,KAAK;EACnC,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,KAAK,GAAGC,QAAQ,EAAE;EAExB,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EACzD,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGH,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EACvE,MAAMG,eAAe,GAAGJ,cAAK,CAACK,MAAM,CAAwB,IAAI,CAAC;EACjE,MAAMC,SAAS,GAAGN,cAAK,CAACK,MAAM,CAAoB,IAAI,CAAC;EAEvD,MAAME,SAAS,GA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AAQ,CAACqG;IACzC,CACH;AAEX;;;;"}
@@ -1,6 +1,6 @@
1
1
  import React__default from 'react';
2
2
 
3
- function useCurrentRow(defaultCurrentRowIndex = 0) {
3
+ function useCurrentRow(defaultCurrentRowIndex) {
4
4
  const [currentRowIndex, setCurrentRowIndex] = React__default.useState(defaultCurrentRowIndex);
5
5
  const move = (direction, length, scrollToIndex) => setCurrentRowIndex(currentIndex => {
6
6
  const nextIndex = currentIndex !== undefined ? getNextIndex(direction, currentIndex, length) : 0;
@@ -9,7 +9,13 @@ function useCurrentRow(defaultCurrentRowIndex = 0) {
9
9
  });
10
10
  const moveUp = (length, callback) => move(-1, length, callback);
11
11
  const moveDown = (length, callback) => move(1, length, callback);
12
- const onKeyDown = React__default.useCallback((event, length, scrollToIndex) => {
12
+ const focusFirstElementInCurrentRow = tableRef => {
13
+ setTimeout(() => {
14
+ var _tableRef$current, _tableRef$current$que;
15
+ (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : (_tableRef$current$que = _tableRef$current.querySelector('[data-taco="table2-body"] [role="row"] [role="cell"]:first-child')) === null || _tableRef$current$que === void 0 ? void 0 : _tableRef$current$que.focus();
16
+ }, 1);
17
+ };
18
+ const onKeyDown = React__default.useCallback((event, length, scrollToIndex, isEditing, tableRef) => {
13
19
  if (event.defaultPrevented) {
14
20
  return;
15
21
  }
@@ -22,6 +28,9 @@ function useCurrentRow(defaultCurrentRowIndex = 0) {
22
28
  } else {
23
29
  moveUp(length, scrollToIndex);
24
30
  }
31
+ if (!isEditing) {
32
+ focusFirstElementInCurrentRow(tableRef);
33
+ }
25
34
  return;
26
35
  } else if (event.key === 'ArrowDown') {
27
36
  event.preventDefault();
@@ -32,12 +41,29 @@ function useCurrentRow(defaultCurrentRowIndex = 0) {
32
41
  } else {
33
42
  moveDown(length, scrollToIndex);
34
43
  }
44
+ if (!isEditing) {
45
+ focusFirstElementInCurrentRow(tableRef);
46
+ }
35
47
  return;
36
48
  }
37
49
  }, []);
50
+ const onFocus = React__default.useCallback((event, length, scrollToIndex) => {
51
+ if (event.isDefaultPrevented()) {
52
+ return;
53
+ }
54
+ if (currentRowIndex === undefined && length > 0) {
55
+ // do it in the next tick, otherwise it prevents internal focus from working
56
+ // meaning you have to tab twice to get to the first focusable element
57
+ setTimeout(() => {
58
+ setCurrentRowIndex(0);
59
+ scrollToIndex(0);
60
+ }, 1);
61
+ }
62
+ }, [currentRowIndex, length]);
38
63
  return {
39
64
  currentRowIndex,
40
65
  setCurrentRowIndex,
66
+ handleFocus: onFocus,
41
67
  handleKeyDown: onKeyDown
42
68
  };
43
69
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useCurrentRow.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useCurrentRow.ts"],"sourcesContent":["import React from 'react';\nimport { TableStrategy } from '../../types';\n\ntype CurrentRowHandlerCallback = TableStrategy['scrollToIndex'];\n\nexport function useCurrentRow(defaultCurrentRowIndex: number | undefined = 0) {\n const [currentRowIndex, setCurrentRowIndex] = React.useState<number>(defaultCurrentRowIndex);\n\n const move = (direction: -1 | 1, length: number, scrollToIndex: CurrentRowHandlerCallback) =>\n setCurrentRowIndex(currentIndex => {\n const nextIndex = currentIndex !== undefined ? getNextIndex(direction, currentIndex, length) : 0;\n scrollToIndex(direction === -1 ? nextIndex : nextIndex + 3);\n return nextIndex;\n });\n const moveUp = (length: number, callback: CurrentRowHandlerCallback) => move(-1, length, callback);\n const moveDown = (length: number, callback: CurrentRowHandlerCallback) => move(1, length, callback);\n\n const onKeyDown = React.useCallback((event: KeyboardEvent, length: number, scrollToIndex: CurrentRowHandlerCallback) => {\n if (event.defaultPrevented) {\n return;\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n\n if (event.ctrlKey || event.metaKey) {\n const newIndex = 0;\n setCurrentRowIndex(newIndex);\n scrollToIndex(newIndex);\n } else {\n moveUp(length, scrollToIndex);\n }\n\n return;\n } else if (event.key === 'ArrowDown') {\n event.preventDefault();\n\n if (event.ctrlKey || event.metaKey) {\n const newIndex = length - 1;\n setCurrentRowIndex(newIndex);\n scrollToIndex(newIndex);\n } else {\n moveDown(length, scrollToIndex);\n }\n\n return;\n }\n }, []);\n\n return {\n currentRowIndex,\n setCurrentRowIndex,\n handleKeyDown: onKeyDown,\n };\n}\n\nconst getNextIndex = (direction: -1 | 1, currentIndex: number, length: number) => {\n if (direction === -1) {\n return currentIndex - 1 > 0 ? currentIndex - 1 : 0;\n }\n\n return currentIndex + 1 < length ? currentIndex + 1 : currentIndex;\n};\n"],"names":["useCurrentRow","defaultCurrentRowIndex","currentRowIndex","setCurrentRowIndex","React","useState","move","direction","length","scrollToIndex","currentIndex","nextIndex","undefined","getNextIndex","moveUp","callback","moveDown","onKeyDown","useCallback","event","defaultPrevented","key","preventDefault","ctrlKey","metaKey","newIndex","handleKeyDown"],"mappings":";;SAKgBA,aAAaA,CAACC,yBAA6C,CAAC;EACxE,MAAM,CAACC,eAAe,EAAEC,kBAAkB,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAASJ,sBAAsB,CAAC;EAE5F,MAAMK,IAAI,GAAGA,CAACC,SAAiB,EAAEC,MAAc,EAAEC,aAAwC,KACrFN,kBAAkB,CAACO,YAAY;IAC3B,MAAMC,SAAS,GAAGD,YAAY,KAAKE,SAAS,GAAGC,YAAY,CAACN,SAAS,EAAEG,YAAY,EAAEF,MAAM,CAAC,GAAG,CAAC;IAChGC,aAAa,CAACF,SAAS,KAAK,CAAC,CAAC,GAAGI,SAAS,GAAGA,SAAS,GAAG,CAAC,CAAC;IAC3D,OAAOA,SAAS;GACnB,CAAC;EACN,MAAMG,MAAM,GAAGA,CAACN,MAAc,EAAEO,QAAmC,KAAKT,IAAI,CAAC,CAAC,CAAC,EAAEE,MAAM,EAAEO,QAAQ,CAAC;EAClG,MAAMC,QAAQ,GAAGA,CAACR,MAAc,EAAEO,QAAmC,KAAKT,IAAI,CAAC,CAAC,EAAEE,MAAM,EAAEO,QAAQ,CAAC;EAEnG,MAA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features/useCurrentRow.ts"],"sourcesContent":["import React from 'react';\nimport { Table3Ref, TableStrategy } from '../../types';\n\ntype CurrentRowHandlerCallback = TableStrategy['scrollToIndex'];\n\nexport function useCurrentRow(defaultCurrentRowIndex: number | undefined) {\n const [currentRowIndex, setCurrentRowIndex] = React.useState<number | undefined>(defaultCurrentRowIndex);\n\n const move = (direction: -1 | 1, length: number, scrollToIndex: CurrentRowHandlerCallback) =>\n setCurrentRowIndex(currentIndex => {\n const nextIndex = currentIndex !== undefined ? getNextIndex(direction, currentIndex, length) : 0;\n scrollToIndex(direction === -1 ? nextIndex : nextIndex + 3);\n return nextIndex;\n });\n const moveUp = (length: number, callback: CurrentRowHandlerCallback) => move(-1, length, callback);\n const moveDown = (length: number, callback: CurrentRowHandlerCallback) => move(1, length, callback);\n\n const focusFirstElementInCurrentRow = (tableRef: React.RefObject<Table3Ref>) => {\n setTimeout(() => {\n (\n tableRef.current?.querySelector('[data-taco=\"table2-body\"] [role=\"row\"] [role=\"cell\"]:first-child') as HTMLElement\n )?.focus();\n }, 1);\n };\n\n const onKeyDown = React.useCallback(\n (\n event: KeyboardEvent,\n length: number,\n scrollToIndex: CurrentRowHandlerCallback,\n isEditing: boolean,\n tableRef: React.RefObject<Table3Ref>\n ) => {\n if (event.defaultPrevented) {\n return;\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n\n if (event.ctrlKey || event.metaKey) {\n const newIndex = 0;\n setCurrentRowIndex(newIndex);\n scrollToIndex(newIndex);\n } else {\n moveUp(length, scrollToIndex);\n }\n\n if (!isEditing) {\n focusFirstElementInCurrentRow(tableRef);\n }\n\n return;\n } else if (event.key === 'ArrowDown') {\n event.preventDefault();\n\n if (event.ctrlKey || event.metaKey) {\n const newIndex = length - 1;\n setCurrentRowIndex(newIndex);\n scrollToIndex(newIndex);\n } else {\n moveDown(length, scrollToIndex);\n }\n\n if (!isEditing) {\n focusFirstElementInCurrentRow(tableRef);\n }\n\n return;\n }\n },\n []\n );\n\n const onFocus = React.useCallback(\n (event: React.FocusEvent, length: number, scrollToIndex: CurrentRowHandlerCallback) => {\n if (event.isDefaultPrevented()) {\n return;\n }\n\n if (currentRowIndex === undefined && length > 0) {\n // do it in the next tick, otherwise it prevents internal focus from working\n // meaning you have to tab twice to get to the first focusable element\n setTimeout(() => {\n setCurrentRowIndex(0);\n scrollToIndex(0);\n }, 1);\n }\n },\n [currentRowIndex, length]\n );\n\n return {\n currentRowIndex,\n setCurrentRowIndex,\n handleFocus: onFocus,\n handleKeyDown: onKeyDown,\n };\n}\n\nconst getNextIndex = (direction: -1 | 1, currentIndex: number, length: number) => {\n if (direction === -1) {\n return currentIndex - 1 > 0 ? currentIndex - 1 : 0;\n }\n\n return currentIndex + 1 < length ? currentIndex + 1 : currentIndex;\n};\n"],"names":["useCurrentRow","defaultCurrentRowIndex","currentRowIndex","setCurrentRowIndex","React","useState","move","direction","length","scrollToIndex","currentIndex","nextIndex","undefined","getNextIndex","moveUp","callback","moveDown","focusFirstElementInCurrentRow","tableRef","setTimeout","_tableRef$current","current","_tableRef$current$que","querySelector","focus","onKeyDown","useCallback","event","isEditing","defaultPrevented","key","preventDefault","ctrlKey","metaKey","newIndex","onFocus","isDefaultPrevented","handleFocus","handleKeyDown"],"mappings":";;SAKgBA,aAAaA,CAACC,sBAA0C;EACpE,MAAM,CAACC,eAAe,EAAEC,kBAAkB,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAqBJ,sBAAsB,CAAC;EAExG,MAAMK,IAAI,GAAGA,CAACC,SAAiB,EAAEC,MAAc,EAAEC,aAAwC,KACrFN,kBAAkB,CAACO,YAAY;IAC3B,MAAMC,SAAS,GAAGD,YAAY,KAAKE,SAAS,GAAGC,YAAY,CAACN,SAAS,EAAEG,YAAY,EAAEF,MAAM,CAAC,GAAG,CAAC;IAChGC,aAAa,CAACF,SAAS,KAAK,CAAC,CAAC,GAAGI,SAAS,GAAGA,SAAS,GAAG,CAAC,CAAC;IAC3D,OAAOA,SAAS;GACnB,C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MAAM,GAAG,CAAC;QAC3BL,kBAAkB,CAAC+B,QAAQ,CAAC;QAC5BzB,aAAa,CAACyB,QAAQ,CAAC;OAC1B,MAAM;QACHlB,QAAQ,CAACR,MAAM,EAAEC,aAAa,CAAC;;MAGnC,IAAI,CAACmB,SAAS,EAAE;QACZX,6BAA6B,CAACC,QAAQ,CAAC;;MAG3C;;GAEP,EACD,EAAE,CACL;EAED,MAAMiB,OAAO,GAAG/B,cAAK,CAACsB,WAAW,CAC7B,CAACC,KAAuB,EAAEnB,MAAc,EAAEC,aAAwC;IAC9E,IAAIkB,KAAK,CAACS,kBAAkB,EAAE,EAAE;MAC5B;;IAGJ,IAAIlC,eAAe,KAAKU,SAAS,IAAIJ,MAAM,GAAG,CAAC,EAAE;;;MAG7CW,UAAU,CAAC;QACPhB,kBAAkB,CAAC,CAAC,CAAC;QACrBM,aAAa,CAAC,CAAC,CAAC;OACnB,EAAE,CAAC,CAAC;;GAEZ,EACD,CAACP,eAAe,EAAEM,MAAM,CAAC,CAC5B;EAED,OAAO;IACHN,eAAe;IACfC,kBAAkB;IAClBkC,WAAW,EAAEF,OAAO;IACpBG,aAAa,EAAEb;GAClB;AACL;AAEA,MAAMZ,YAAY,GAAGA,CAACN,SAAiB,EAAEG,YAAoB,EAAEF,MAAc;EACzE,IAAID,SAAS,KAAK,CAAC,CAAC,EAAE;IAClB,OAAOG,YAAY,GAAG,CAAC,GAAG,CAAC,GAAGA,YAAY,GAAG,CAAC,GAAG,CAAC;;EAGtD,OAAOA,YAAY,GAAG,CAAC,GAAGF,MAAM,GAAGE,YAAY,GAAG,CAAC,GAAGA,YAAY;AACtE,CAAC;;;;"}
@@ -9,7 +9,7 @@ function useRowClick(onRowClick) {
9
9
  const tableMeta = table.options.meta;
10
10
  if (event.key === 'Enter') {
11
11
  event.preventDefault();
12
- if (onRowClick) {
12
+ if (onRowClick && tableMeta.currentRow.currentRowIndex !== undefined) {
13
13
  onRowClick(rows[tableMeta.currentRow.currentRowIndex].original);
14
14
  }
15
15
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"useRowClick.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useRowClick.ts"],"sourcesContent":["import React from 'react';\nimport { Table3RowClickHandler } from '../../types';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nexport function useRowClick<TType = unknown>(onRowClick?: Table3RowClickHandler<TType>) {\n const onKeyDown = React.useCallback(\n (event: KeyboardEvent, table: RTable<TType>) => {\n if (typeof onRowClick !== 'function' || event.defaultPrevented) {\n return;\n }\n\n const rows = table.getRowModel().rows;\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n if (event.key === 'Enter') {\n event.preventDefault();\n\n if (onRowClick) {\n onRowClick(rows[tableMeta.currentRow.currentRowIndex].original as TType);\n }\n\n return;\n }\n },\n [onRowClick]\n ) as <TType = unknown>(event: KeyboardEvent, table: RTable<TType>) => void;\n\n return {\n handleKeyDown: onKeyDown,\n handleClick: onRowClick,\n };\n}\n"],"names":["useRowClick","onRowClick","onKeyDown","React","useCallback","event","table","defaultPrevented","rows","getRowModel","tableMeta","options","meta","key","preventDefault","currentRow","currentRowIndex","original","handleKeyDown","handleClick"],"mappings":";;SAIgBA,WAAWA,CAAkBC,UAAyC;EAClF,MAAMC,SAAS,GAAGC,cAAK,CAACC,WAAW,CAC/B,CAACC,KAAoB,EAAEC,KAAoB;IACvC,IAAI,OAAOL,UAAU,KAAK,UAAU,IAAII,KAAK,CAACE,gBAAgB,EAAE;MAC5D;;IAGJ,MAAMC,IAAI,GAAGF,KAAK,CAACG,WAAW,EAAE,CAACD,IAAI;IACrC,MAAME,SAAS,GAAGJ,KAAK,CAACK,OAAO,CAACC,IAAwB;IAExD,IAAIP,KAAK,CAACQ,GAAG,KAAK,OAAO,EAAE;MACvBR,KAAK,CAACS,cAAc,EAAE;MAEtB,IAAIb,UAAU,EAAE;QACZA,UAAU,CAACO,IAAI,CAACE,SAAS,CAACK,UAAU,CAACC,eAAe,CAAC,CAACC,QAAiB,CAAC;;MAG5E;;GAEP,EACD,CAAChB,UAAU,CAAC,CAC0D;EAE1E,OAAO;IACHiB,aAAa,EAAEhB,SAAS;IACxBiB,WAAW,EAAElB;GAChB;AACL;;;;"}
1
+ {"version":3,"file":"useRowClick.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useRowClick.ts"],"sourcesContent":["import React from 'react';\nimport { Table3RowClickHandler } from '../../types';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nexport function useRowClick<TType = unknown>(onRowClick?: Table3RowClickHandler<TType>) {\n const onKeyDown = React.useCallback(\n (event: KeyboardEvent, table: RTable<TType>) => {\n if (typeof onRowClick !== 'function' || event.defaultPrevented) {\n return;\n }\n\n const rows = table.getRowModel().rows;\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n if (event.key === 'Enter') {\n event.preventDefault();\n\n if (onRowClick && tableMeta.currentRow.currentRowIndex !== undefined) {\n onRowClick(rows[tableMeta.currentRow.currentRowIndex].original as TType);\n }\n\n return;\n }\n },\n [onRowClick]\n ) as <TType = unknown>(event: KeyboardEvent, table: RTable<TType>) => void;\n\n return {\n handleKeyDown: onKeyDown,\n handleClick: onRowClick,\n };\n}\n"],"names":["useRowClick","onRowClick","onKeyDown","React","useCallback","event","table","defaultPrevented","rows","getRowModel","tableMeta","options","meta","key","preventDefault","currentRow","currentRowIndex","undefined","original","handleKeyDown","handleClick"],"mappings":";;SAIgBA,WAAWA,CAAkBC,UAAyC;EAClF,MAAMC,SAAS,GAAGC,cAAK,CAACC,WAAW,CAC/B,CAACC,KAAoB,EAAEC,KAAoB;IACvC,IAAI,OAAOL,UAAU,KAAK,UAAU,IAAII,KAAK,CAACE,gBAAgB,EAAE;MAC5D;;IAGJ,MAAMC,IAAI,GAAGF,KAAK,CAACG,WAAW,EAAE,CAACD,IAAI;IACrC,MAAME,SAAS,GAAGJ,KAAK,CAACK,OAAO,CAACC,IAAwB;IAExD,IAAIP,KAAK,CAACQ,GAAG,KAAK,OAAO,EAAE;MACvBR,KAAK,CAACS,cAAc,EAAE;MAEtB,IAAIb,UAAU,IAAIS,SAAS,CAACK,UAAU,CAACC,eAAe,KAAKC,SAAS,EAAE;QAClEhB,UAAU,CAACO,IAAI,CAACE,SAAS,CAACK,UAAU,CAACC,eAAe,CAAC,CAACE,QAAiB,CAAC;;MAG5E;;GAEP,EACD,CAACjB,UAAU,CAAC,CAC0D;EAE1E,OAAO;IACHkB,aAAa,EAAEjB,SAAS;IACxBkB,WAAW,EAAEnB;GAChB;AACL;;;;"}
@@ -9,9 +9,12 @@ function useRowSelection() {
9
9
  const rows = table.getRowModel().rows;
10
10
  const tableMeta = table.options.meta;
11
11
  if (event.key === ' ') {
12
- var _rows$tableMeta$curre;
13
12
  event.preventDefault();
14
- (_rows$tableMeta$curre = rows[tableMeta.currentRow.currentRowIndex]) === null || _rows$tableMeta$curre === void 0 ? void 0 : _rows$tableMeta$curre.toggleSelected();
13
+ const currentRowIndex = tableMeta.currentRow.currentRowIndex;
14
+ if (currentRowIndex !== undefined) {
15
+ var _rows$currentRowIndex;
16
+ (_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.toggleSelected();
17
+ }
15
18
  return;
16
19
  } else if ((event.ctrlKey || event.metaKey) && event.key === 'a') {
17
20
  event.preventDefault();
@@ -1 +1 @@
1
- {"version":3,"file":"useRowSelection.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useRowSelection.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nexport function useRowSelection() {\n const lastSelectedRowIndex = React.useRef<number>();\n\n const onKeyDown = React.useCallback(<TType = unknown>(event: KeyboardEvent, table: RTable<TType>) => {\n if (!table.options.enableRowSelection || event.defaultPrevented) {\n return;\n }\n\n const rows = table.getRowModel().rows;\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n if (event.key === ' ') {\n event.preventDefault();\n rows[tableMeta.currentRow.currentRowIndex]?.toggleSelected();\n return;\n } else if ((event.ctrlKey || event.metaKey) && event.key === 'a') {\n event.preventDefault();\n table.toggleAllRowsSelected();\n return;\n }\n }, []) as <TType = unknown>(event: KeyboardEvent, table: RTable<TType>) => void;\n\n return {\n handleKeyDown: onKeyDown,\n lastSelectedRowIndex,\n };\n}\n"],"names":["useRowSelection","lastSelectedRowIndex","React","useRef","onKeyDown","useCallback","event","table","options","enableRowSelection","defaultPrevented","rows","getRowModel","tableMeta","meta","key","_rows$tableMeta$curre","preventDefault","currentRow","currentRowIndex","toggleSelected","ctrlKey","metaKey","toggleAllRowsSelected","handleKeyDown"],"mappings":";;SAGgBA,eAAeA;EAC3B,MAAMC,oBAAoB,GAAGC,cAAK,CAACC,MAAM,EAAU;EAEnD,MAAMC,SAAS,GAAGF,cAAK,CAACG,WAAW,CAAC,CAAkBC,KAAoB,EAAEC,KAAoB;IAC5F,IAAI,CAACA,KAAK,CAACC,OAAO,CAACC,kBAAkB,IAAIH,KAAK,CAACI,gBAAgB,EAAE;MAC7D;;IAGJ,MAAMC,IAAI,GAAGJ,KAAK,CAACK,WAAW,EAAE,CAACD,IAAI;IACrC,MAAME,SAAS,GAAGN,KAAK,CAACC,OAAO,CAACM,IAAwB;IAExD,IAAIR,KAAK,CAACS,GAAG,KAAK,GAAG,EAAE;MAAA,IAAAC,qBAAA;MACnBV,KAAK,CAACW,cAAc,EAAE;MACtB,CAAAD,qBAAA,GAAAL,IAAI,CAACE,SAAS,CAACK,UAAU,CAACC,eAAe,CAAC,cAAAH,qBAAA,uBAA1CA,qBAAA,CAA4CI,cAAc,EAAE;MAC5D;KACH,MAAM,IAAI,CAACd,KAAK,CAACe,OAAO,IAAIf,KAAK,CAACgB,OAAO,KAAKhB,KAAK,CAACS,GAAG,KAAK,GAAG,EAAE;MAC9DT,KAAK,CAACW,cAAc,EAAE;MACtBV,KAAK,CAACgB,qBAAqB,EAAE;MAC7B;;GAEP,EAAE,EAAE,CAA0E;EAE/E,OAAO;IACHC,aAAa,EAAEpB,SAAS;IACxBH;GACH;AACL;;;;"}
1
+ {"version":3,"file":"useRowSelection.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useRowSelection.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nexport function useRowSelection() {\n const lastSelectedRowIndex = React.useRef<number>();\n\n const onKeyDown = React.useCallback(<TType = unknown>(event: KeyboardEvent, table: RTable<TType>) => {\n if (!table.options.enableRowSelection || event.defaultPrevented) {\n return;\n }\n\n const rows = table.getRowModel().rows;\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n if (event.key === ' ') {\n event.preventDefault();\n const currentRowIndex = tableMeta.currentRow.currentRowIndex;\n if (currentRowIndex !== undefined) {\n rows[currentRowIndex]?.toggleSelected();\n }\n return;\n } else if ((event.ctrlKey || event.metaKey) && event.key === 'a') {\n event.preventDefault();\n table.toggleAllRowsSelected();\n return;\n }\n }, []) as <TType = unknown>(event: KeyboardEvent, table: RTable<TType>) => void;\n\n return {\n handleKeyDown: onKeyDown,\n lastSelectedRowIndex,\n };\n}\n"],"names":["useRowSelection","lastSelectedRowIndex","React","useRef","onKeyDown","useCallback","event","table","options","enableRowSelection","defaultPrevented","rows","getRowModel","tableMeta","meta","key","preventDefault","currentRowIndex","currentRow","undefined","_rows$currentRowIndex","toggleSelected","ctrlKey","metaKey","toggleAllRowsSelected","handleKeyDown"],"mappings":";;SAGgBA,eAAeA;EAC3B,MAAMC,oBAAoB,GAAGC,cAAK,CAACC,MAAM,EAAU;EAEnD,MAAMC,SAAS,GAAGF,cAAK,CAACG,WAAW,CAAC,CAAkBC,KAAoB,EAAEC,KAAoB;IAC5F,IAAI,CAACA,KAAK,CAACC,OAAO,CAACC,kBAAkB,IAAIH,KAAK,CAACI,gBAAgB,EAAE;MAC7D;;IAGJ,MAAMC,IAAI,GAAGJ,KAAK,CAACK,WAAW,EAAE,CAACD,IAAI;IACrC,MAAME,SAAS,GAAGN,KAAK,CAACC,OAAO,CAACM,IAAwB;IAExD,IAAIR,KAAK,CAACS,GAAG,KAAK,GAAG,EAAE;MACnBT,KAAK,CAACU,cAAc,EAAE;MACtB,MAAMC,eAAe,GAAGJ,SAAS,CAACK,UAAU,CAACD,eAAe;MAC5D,IAAIA,eAAe,KAAKE,SAAS,EAAE;QAAA,IAAAC,qBAAA;QAC/B,CAAAA,qBAAA,GAAAT,IAAI,CAACM,eAAe,CAAC,cAAAG,qBAAA,uBAArBA,qBAAA,CAAuBC,cAAc,EAAE;;MAE3C;KACH,MAAM,IAAI,CAACf,KAAK,CAACgB,OAAO,IAAIhB,KAAK,CAACiB,OAAO,KAAKjB,KAAK,CAACS,GAAG,KAAK,GAAG,EAAE;MAC9DT,KAAK,CAACU,cAAc,EAAE;MACtBT,KAAK,CAACiB,qBAAqB,EAAE;MAC7B;;GAEP,EAAE,EAAE,CAA0E;EAE/E,OAAO;IACHC,aAAa,EAAErB,SAAS;IACxBH;GACH;AACL;;;;"}
@@ -4,7 +4,8 @@ function useCurrentRowListener(table) {
4
4
  const meta = table.options.meta;
5
5
  const rows = table.getRowModel().rows;
6
6
  React__default.useEffect(() => {
7
- if (meta.currentRow.currentRowIndex > rows.length) {
7
+ const currentRowIndex = meta.currentRow.currentRowIndex;
8
+ if (currentRowIndex !== undefined && currentRowIndex > rows.length) {
8
9
  meta.currentRow.setCurrentRowIndex(0);
9
10
  }
10
11
  }, [rows.length]);
@@ -1 +1 @@
1
- {"version":3,"file":"useCurrentRowListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useCurrentRowListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nexport function useCurrentRowListener<TType = unknown>(table: RTable<TType>) {\n const meta = table.options.meta as TableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(() => {\n if (meta.currentRow.currentRowIndex > rows.length) {\n meta.currentRow.setCurrentRowIndex(0);\n }\n }, [rows.length]);\n}\n"],"names":["useCurrentRowListener","table","meta","options","rows","getRowModel","React","useEffect","currentRow","currentRowIndex","length","setCurrentRowIndex"],"mappings":";;SAGgBA,qBAAqBA,CAAkBC,KAAoB;EACvE,MAAMC,IAAI,GAAGD,KAAK,CAACE,OAAO,CAACD,IAAwB;EACnD,MAAME,IAAI,GAAGH,KAAK,CAACI,WAAW,EAAE,CAACD,IAAI;EAErCE,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIL,IAAI,CAACM,UAAU,CAACC,eAAe,GAAGL,IAAI,CAACM,MAAM,EAAE;MAC/CR,IAAI,CAACM,UAAU,CAACG,kBAAkB,CAAC,CAAC,CAAC;;GAE5C,EAAE,CAACP,IAAI,CAACM,MAAM,CAAC,CAAC;AACrB;;;;"}
1
+ {"version":3,"file":"useCurrentRowListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useCurrentRowListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nexport function useCurrentRowListener<TType = unknown>(table: RTable<TType>) {\n const meta = table.options.meta as TableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(() => {\n const currentRowIndex = meta.currentRow.currentRowIndex;\n if (currentRowIndex !== undefined && currentRowIndex > rows.length) {\n meta.currentRow.setCurrentRowIndex(0);\n }\n }, [rows.length]);\n}\n"],"names":["useCurrentRowListener","table","meta","options","rows","getRowModel","React","useEffect","currentRowIndex","currentRow","undefined","length","setCurrentRowIndex"],"mappings":";;SAGgBA,qBAAqBA,CAAkBC,KAAoB;EACvE,MAAMC,IAAI,GAAGD,KAAK,CAACE,OAAO,CAACD,IAAwB;EACnD,MAAME,IAAI,GAAGH,KAAK,CAACI,WAAW,EAAE,CAACD,IAAI;EAErCE,cAAK,CAACC,SAAS,CAAC;IACZ,MAAMC,eAAe,GAAGN,IAAI,CAACO,UAAU,CAACD,eAAe;IACvD,IAAIA,eAAe,KAAKE,SAAS,IAAIF,eAAe,GAAGJ,IAAI,CAACO,MAAM,EAAE;MAChET,IAAI,CAACO,UAAU,CAACG,kBAAkB,CAAC,CAAC,CAAC;;GAE5C,EAAE,CAACR,IAAI,CAACO,MAAM,CAAC,CAAC;AACrB;;;;"}
@@ -12,10 +12,14 @@ function useEditingStateListener(table) {
12
12
  }, [meta.currentRow.currentRowIndex]);
13
13
  // save if editing gets toggled off
14
14
  React__default.useEffect(() => {
15
- if (meta.editing.isEnabled && !meta.editing.isEditing) {
16
- requestAnimationFrame(() => {
17
- meta.editing.saveChangesIfNeeded();
18
- });
15
+ if (meta.editing.isEnabled) {
16
+ if (!meta.editing.isEditing) {
17
+ requestAnimationFrame(() => {
18
+ meta.editing.saveChangesIfNeeded();
19
+ });
20
+ } else if (meta.currentRow.currentRowIndex === undefined) {
21
+ meta.currentRow.setCurrentRowIndex(0);
22
+ }
19
23
  }
20
24
  }, [meta.editing.isEditing]);
21
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useEditingStateListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useEditingStateListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nexport function useEditingStateListener<TType = unknown>(table: RTable<TType>) {\n const meta = table.options.meta as TableMeta<TType>;\n\n // save when the row changes\n React.useEffect(() => {\n if (meta.editing.isEnabled && meta.editing.isEditing) {\n requestAnimationFrame(() => {\n meta.editing.saveChangesIfNeeded();\n });\n }\n }, [meta.currentRow.currentRowIndex]);\n\n // save if editing gets toggled off\n React.useEffect(() => {\n if (meta.editing.isEnabled && !meta.editing.isEditing) {\n requestAnimationFrame(() => {\n meta.editing.saveChangesIfNeeded();\n });\n }\n }, [meta.editing.isEditing]);\n}\n"],"names":["useEditingStateListener","table","meta","options","React","useEffect","editing","isEnabled","isEditing","requestAnimationFrame","saveChangesIfNeeded","currentRow","currentRowIndex"],"mappings":";;SAGgBA,uBAAuBA,CAAkBC,KAAoB;EACzE,MAAMC,IAAI,GAAGD,KAAK,CAACE,OAAO,CAACD,IAAwB;;EAGnDE,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIH,IAAI,CAACI,OAAO,CAACC,SAAS,IAAIL,IAAI,CAACI,OAAO,CAACE,SAAS,EAAE;MAClDC,qBAAqB,CAAC;QAClBP,IAAI,CAACI,OAAO,CAACI,mBAAmB,EAAE;OACrC,CAAC;;GAET,EAAE,CAACR,IAAI,CAACS,UAAU,CAACC,eAAe,CAAC,CAAC;;EAGrCR,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIH,IAAI,CAACI,OAAO,CAACC,SAAS,IAAI,CAACL,IAAI,CAACI,OAAO,CAACE,SAAS,EAAE;MACnDC,qBAAqB,CAAC;QAClBP,IAAI,CAACI,OAAO,CAACI,mBAAmB,EAAE;OACrC,CAAC;;GAET,EAAE,CAACR,IAAI,CAACI,OAAO,CAACE,SAAS,CAAC,CAAC;AAChC;;;;"}
1
+ {"version":3,"file":"useEditingStateListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useEditingStateListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nexport function useEditingStateListener<TType = unknown>(table: RTable<TType>) {\n const meta = table.options.meta as TableMeta<TType>;\n\n // save when the row changes\n React.useEffect(() => {\n if (meta.editing.isEnabled && meta.editing.isEditing) {\n requestAnimationFrame(() => {\n meta.editing.saveChangesIfNeeded();\n });\n }\n }, [meta.currentRow.currentRowIndex]);\n\n // save if editing gets toggled off\n React.useEffect(() => {\n if (meta.editing.isEnabled) {\n if (!meta.editing.isEditing) {\n requestAnimationFrame(() => {\n meta.editing.saveChangesIfNeeded();\n });\n } else if (meta.currentRow.currentRowIndex === undefined) {\n meta.currentRow.setCurrentRowIndex(0);\n }\n }\n }, [meta.editing.isEditing]);\n}\n"],"names":["useEditingStateListener","table","meta","options","React","useEffect","editing","isEnabled","isEditing","requestAnimationFrame","saveChangesIfNeeded","currentRow","currentRowIndex","undefined","setCurrentRowIndex"],"mappings":";;SAGgBA,uBAAuBA,CAAkBC,KAAoB;EACzE,MAAMC,IAAI,GAAGD,KAAK,CAACE,OAAO,CAACD,IAAwB;;EAGnDE,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIH,IAAI,CAACI,OAAO,CAACC,SAAS,IAAIL,IAAI,CAACI,OAAO,CAACE,SAAS,EAAE;MAClDC,qBAAqB,CAAC;QAClBP,IAAI,CAACI,OAAO,CAACI,mBAAmB,EAAE;OACrC,CAAC;;GAET,EAAE,CAACR,IAAI,CAACS,UAAU,CAACC,eAAe,CAAC,CAAC;;EAGrCR,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIH,IAAI,CAACI,OAAO,CAACC,SAAS,EAAE;MACxB,IAAI,CAACL,IAAI,CAACI,OAAO,CAACE,SAAS,EAAE;QACzBC,qBAAqB,CAAC;UAClBP,IAAI,CAACI,OAAO,CAACI,mBAAmB,EAAE;SACrC,CAAC;OACL,MAAM,IAAIR,IAAI,CAACS,UAAU,CAACC,eAAe,KAAKC,SAAS,EAAE;QACtDX,IAAI,CAACS,UAAU,CAACG,kBAAkB,CAAC,CAAC,CAAC;;;GAGhD,EAAE,CAACZ,IAAI,CAACI,OAAO,CAACE,SAAS,CAAC,CAAC;AAChC;;;;"}
@@ -8,7 +8,7 @@ function useShortcutsListener(table, shortcuts) {
8
8
  const shortcutKeys = Object.keys(shortcuts !== null && shortcuts !== void 0 ? shortcuts : {});
9
9
  const globalHandlers = [];
10
10
  // convert the shortcut into the correct format to register it
11
- if (shortcuts && shortcutKeys.length) {
11
+ if (shortcuts && shortcutKeys.length && meta.currentRow.currentRowIndex !== undefined) {
12
12
  const currentRow = rows[meta.currentRow.currentRowIndex];
13
13
  shortcutKeys.forEach(key => {
14
14
  const handler = shortcuts[key];
@@ -1 +1 @@
1
- {"version":3,"file":"useShortcutsListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useShortcutsListener.ts"],"sourcesContent":["import React from 'react';\nimport { TableMeta, Table as RTable } from '@tanstack/react-table';\nimport { KeyDownHandlerOptions, createShortcutKeyDownHandler } from '../../../../utils/keyboard';\nimport { Table3ShortcutHandlerObject, Table3Shortcuts } from '../../types';\n\nexport function useShortcutsListener<TType = unknown>(table: RTable<TType>, shortcuts: Table3Shortcuts<TType> | undefined) {\n const meta = table.options.meta as TableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(() => {\n const shortcutKeys = Object.keys(shortcuts ?? {});\n const globalHandlers: Array<(event: KeyboardEvent) => void> = [];\n\n // convert the shortcut into the correct format to register it\n if (shortcuts && shortcutKeys.length) {\n const currentRow = rows[meta.currentRow.currentRowIndex];\n\n shortcutKeys.forEach(key => {\n const handler = shortcuts[key];\n\n let keyDownHandler;\n let keyDownHandlerOptions: KeyDownHandlerOptions;\n\n if (typeof handler === 'function') {\n keyDownHandler = handler;\n keyDownHandlerOptions = {\n key,\n };\n } else {\n const handlerObject = handler as Table3ShortcutHandlerObject<TType>;\n keyDownHandler = handlerObject.handler;\n keyDownHandlerOptions = {\n key,\n meta: handlerObject.meta,\n shift: handlerObject.shift,\n };\n }\n\n globalHandlers.push(\n createShortcutKeyDownHandler(keyDownHandlerOptions, event => {\n event.preventDefault();\n keyDownHandler(currentRow?.original);\n })\n );\n });\n }\n\n globalHandlers.forEach(handler => {\n document.addEventListener('keydown', handler);\n });\n\n return () => {\n globalHandlers.forEach(handler => {\n document.removeEventListener('keydown', handler);\n });\n };\n }, [shortcuts, meta.currentRow.currentRowIndex, rows.length]);\n}\n"],"names":["useShortcutsListener","table","shortcuts","meta","options","rows","getRowModel","React","useEffect","shortcutKeys","Object","keys","globalHandlers","length","currentRow","currentRowIndex","forEach","key","handler","keyDownHandler","keyDownHandlerOptions","handlerObject","shift","push","createShortcutKeyDownHandler","event","preventDefault","original","document","addEventListener","removeEventListener"],"mappings":";;;SAKgBA,oBAAoBA,CAAkBC,KAAoB,EAAEC,SAA6C;EACrH,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAAwB;EACnD,MA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CAAChB,SAAS,EAAEC,IAAI,CAACW,UAAU,CAACC,eAAe,EAAEV,IAAI,CAACQ,MAAM,CAAC,CAAC;AACjE;;;;"}
1
+ {"version":3,"file":"useShortcutsListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useShortcutsListener.ts"],"sourcesContent":["import React from 'react';\nimport { TableMeta, Table as RTable } from '@tanstack/react-table';\nimport { KeyDownHandlerOptions, createShortcutKeyDownHandler } from '../../../../utils/keyboard';\nimport { Table3ShortcutHandlerObject, Table3Shortcuts } from '../../types';\n\nexport function useShortcutsListener<TType = unknown>(table: RTable<TType>, shortcuts: Table3Shortcuts<TType> | undefined) {\n const meta = table.options.meta as TableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(() => {\n const shortcutKeys = Object.keys(shortcuts ?? {});\n const globalHandlers: Array<(event: KeyboardEvent) => void> = [];\n\n // convert the shortcut into the correct format to register it\n if (shortcuts && shortcutKeys.length && meta.currentRow.currentRowIndex !== undefined) {\n const currentRow = rows[meta.currentRow.currentRowIndex];\n\n shortcutKeys.forEach(key => {\n const handler = shortcuts[key];\n\n let keyDownHandler;\n let keyDownHandlerOptions: KeyDownHandlerOptions;\n\n if (typeof handler === 'function') {\n keyDownHandler = handler;\n keyDownHandlerOptions = {\n key,\n };\n } else {\n const handlerObject = handler as Table3ShortcutHandlerObject<TType>;\n keyDownHandler = handlerObject.handler;\n keyDownHandlerOptions = {\n key,\n meta: handlerObject.meta,\n shift: handlerObject.shift,\n };\n }\n\n globalHandlers.push(\n createShortcutKeyDownHandler(keyDownHandlerOptions, event => {\n event.preventDefault();\n keyDownHandler(currentRow?.original);\n })\n );\n });\n }\n\n globalHandlers.forEach(handler => {\n document.addEventListener('keydown', handler);\n });\n\n return () => {\n globalHandlers.forEach(handler => {\n document.removeEventListener('keydown', handler);\n });\n };\n }, [shortcuts, meta.currentRow.currentRowIndex, rows.length]);\n}\n"],"names":["useShortcutsListener","table","shortcuts","meta","options","rows","getRowModel","React","useEffect","shortcutKeys","Object","keys","globalHandlers","length","currentRow","currentRowIndex","undefined","forEach","key","handler","keyDownHandler","keyDownHandlerOptions","handlerObject","shift","push","createShortcutKeyDownHandler","event","preventDefault","original","document","addEventListener","removeEventListener"],"mappings":";;;SAKgBA,oBAAoBA,CAAkBC,KAAoB,EAAEC,SAA6C;EACrH,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAAwB;EACnD,MAAME,IAAI,GAAGJ,KAAK,CAACK,WAAW,EAAE,CAACD,IAAI;EAErCE,cAAK,CAACC,SAAS,CAAC;IACZ,MAAMC,YAAY,GAAGC,MAAM,CAACC,IAAI,CAACT,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE,CAAC;IACjD,MAAMU,cAAc,GAA0C,EAAE;;IAGhE,IAAIV,SAAS,IAAIO,YAAY,CAACI,MAAM,IAAIV,IAAI,CAACW,UAAU,CAACC,eAAe,KAAKC,SAAS,EAAE;MACnF,MAAMF,UAAU,GAAGT,IAAI,CAACF,IAAI,CAACW,UAAU,CAACC,eAAe,CAAC;MAExDN,YAAY,CAACQ,OAAO,CAACC,GAAG;QACpB,MAAMC,OAAO,GAAGjB,SAAS,CAACgB,GAAG,CAAC;QAE9B,IAAIE,cAAc;QAClB,IAAIC,qBAA4C;QAEhD,IAAI,OAAOF,OAAO,KAAK,UAAU,EAAE;UAC/BC,cAAc,GAAGD,OAAO;UACxBE,qBAAqB,GAAG;YACpBH;WACH;SACJ,MAAM;UACH,MAAMI,aAAa,GAAGH,OAA6C;UACnEC,cAAc,GAAGE,aAAa,CAACH,OAAO;UACtCE,qBAAqB,GAAG;YACpBH,GAAG;YACHf,IAAI,EAAEmB,aAAa,CAACnB,IAAI;YACxBoB,KAAK,EAAED,aAAa,CAACC;WACxB;;QAGLX,cAAc,CAACY,IAAI,CACfC,4BAA4B,CAACJ,qBAAqB,EAAEK,KAAK;UACrDA,KAAK,CAACC,cAAc,EAAE;UACtBP,cAAc,CAACN,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEc,QAAQ,CAAC;SACvC,CAAC,CACL;OACJ,CAAC;;IAGNhB,cAAc,CAACK,OAAO,CAACE,OAAO;MAC1BU,QAAQ,CAACC,gBAAgB,CAAC,SAAS,EAAEX,OAAO,CAAC;KAChD,CAAC;IAEF,OAAO;MACHP,cAAc,CAACK,OAAO,CAACE,OAAO;QAC1BU,QAAQ,CAACE,mBAAmB,CAAC,SAAS,EAAEZ,OAAO,CAAC;OACnD,CAAC;KACL;GACJ,EAAE,CAACjB,SAAS,EAAEC,IAAI,CAACW,UAAU,CAACC,eAAe,EAAEV,IAAI,CAACQ,MAAM,CAAC,CAAC;AACjE;;;;"}
@@ -38,7 +38,7 @@ function useConvertChildrenToColumns(props, options, editing) {
38
38
  React__default.Children.toArray(props.children).filter(child => !!child) // remove falsey children
39
39
  .forEach(child => {
40
40
  if ( /*#__PURE__*/React__default.isValidElement(child) && child.props.accessor) {
41
- var _child$props$enableRe, _child$props$enableFi, _child$props$enableSo, _child$props$enableHi, _child$props$enableOr, _child$props$enableSe, _child$props$enableTr;
41
+ var _child$props$enableRe, _child$props$enableFi, _child$props$enableSo, _child$props$enableHi, _child$props$enableOr, _child$props$enablePr, _child$props$enableSe, _child$props$enableTr;
42
42
  if (child.props.defaultWidth) {
43
43
  defaultColumnSizing[child.props.accessor] = child.props.defaultWidth === 'grow' ? '1fr' : child.props.defaultWidth;
44
44
  }
@@ -77,6 +77,7 @@ function useConvertChildrenToColumns(props, options, editing) {
77
77
  control: child.props.control,
78
78
  dataType: child.props.dataType,
79
79
  enableOrdering: (_child$props$enableOr = child.props.enableOrdering) !== null && _child$props$enableOr !== void 0 ? _child$props$enableOr : true,
80
+ enablePrinting: (_child$props$enablePr = child.props.enablePrinting) !== null && _child$props$enablePr !== void 0 ? _child$props$enablePr : true,
80
81
  enableSearch: (_child$props$enableSe = child.props.enableSearch) !== null && _child$props$enableSe !== void 0 ? _child$props$enableSe : true,
81
82
  enableTruncate: (_child$props$enableTr = child.props.enableTruncate) !== null && _child$props$enableTr !== void 0 ? _child$props$enableTr : false,
82
83
  filters: child.props.filters,
@@ -1 +1 @@
1
- {"version":3,"file":"useConvertChildrenToColumns.js","sources":["../../../../../../../../src/components/Table3/hooks/useConvertChildrenToColumns.tsx"],"sourcesContent":["import React from 'react';\nimport { ColumnDef, ColumnSizingState, createColumnHelper, ColumnSort, VisibilityState } from '@tanstack/react-table';\nimport { Table3ColumnProps, Table3Props, Table3Options, Table3ColumnDataType, Table3SortFn } from '../types';\nimport { Header } from '../components/columns/header/Header';\nimport { Footer } from '../components/columns/footer/Footer';\nimport { Cell } from '../components/columns/cell/Cell';\nimport { createRowSelectionColumn } from '../components/columns/internal/Selection';\nimport { MIN_COLUMN_SIZE } from '../components/columns/styles';\nimport { createRowActionsColumn } from '../components/columns/internal/Actions';\nimport { createRowExpansionColumn } from '../components/columns/internal/Expansion';\nimport { createRowDragColumn } from '../components/columns/internal/Drag';\nimport { createRowEditingActionsColumn } from '../components/columns/internal/EditingActions';\nimport { useEditing } from './features/useEditing';\n\nfunction getSortingFn<TType = unknown>(dataType?: Table3ColumnDataType, customFnOrBuiltIn?: Table3SortFn<TType>) {\n if (typeof customFnOrBuiltIn === 'function') {\n return (rowA, rowB, columnId) => customFnOrBuiltIn(rowA.original, rowB.original, columnId);\n }\n\n // if a built in is being used, just return that\n if (customFnOrBuiltIn) {\n return customFnOrBuiltIn;\n }\n\n // some times we alias based on the type\n if (dataType && dataType !== 'boolean' && dataType !== 'number') {\n return dataType;\n }\n\n // otherwise fall back to auto\n return 'auto';\n}\n\nexport function useConvertChildrenToColumns<TType = unknown>(\n props: Table3Props<TType>,\n options: Table3Options,\n editing: ReturnType<typeof useEditing>\n) {\n // It's important to memoise column definitions, because it prevents columns like \"Drag column\" to re-render on every state change,\n // and break dragging at the moment it happens.\n return React.useMemo(() => {\n const columnHelper = createColumnHelper<TType>();\n\n const columns: ColumnDef<TType>[] = [];\n const defaultColumnSizing: ColumnSizingState = {};\n const defaultColumnVisibility: VisibilityState = {};\n const defaultSorting: ColumnSort[] = [];\n\n (React.Children.toArray(props.children) as React.ReactElement<Table3ColumnProps<TType>>[])\n .filter(child => !!child) // remove falsey children\n .forEach(child => {\n if (React.isValidElement<Table3ColumnProps<TType>>(child) && child.props.accessor) {\n if (child.props.defaultWidth) {\n defaultColumnSizing[child.props.accessor as string] =\n child.props.defaultWidth === 'grow' ? '1fr' : (child.props.defaultWidth as any);\n }\n\n if (child.props.defaultHidden && options.enableColumnHiding) {\n defaultColumnVisibility[child.props.accessor as string] = false;\n }\n\n if (child.props.sort !== undefined) {\n defaultSorting.push({\n id: child.props.accessor as string,\n desc: child.props.sort === 'desc',\n });\n }\n\n columns.push({\n accessorKey: child.props.accessor,\n id: child.props.accessor as string,\n header: Header,\n cell: Cell,\n footer: Footer,\n // sizing\n minSize: MIN_COLUMN_SIZE,\n enableResizing: child.props.enableResizing ?? true,\n // filtering\n enableColumnFilter: child.props.enableFiltering ?? true,\n filterFn: 'tacoFilter' as any,\n // sorting\n enableSorting: child.props.enableSorting ?? true,\n sortingFn: getSortingFn<TType>(child.props.dataType, child.props.sortFn),\n sortDescFirst: false,\n sortUndefined: 1,\n // visibility\n enableHiding: child.props.enableHiding ?? true,\n // custom options\n meta: {\n align: child.props.align,\n className: child.props.className,\n control: child.props.control,\n dataType: child.props.dataType,\n enableOrdering: child.props.enableOrdering ?? true,\n enableSearch: child.props.enableSearch ?? true,\n enableTruncate: child.props.enableTruncate ?? false,\n filters: child.props.filters,\n footer: child.props.footer,\n header: child.props.header,\n headerClassName: child.props.headerClassName,\n menu: child.props.menu,\n renderer: child.props.renderer,\n tooltip: child.props.tooltip,\n },\n });\n }\n });\n\n if (options.enableRowExpansion && props.expandedRowRenderer) {\n columns.unshift(columnHelper.display(createRowExpansionColumn(props.expandedRowRenderer)));\n }\n\n if (options.enableRowSelection) {\n columns.unshift(\n columnHelper.display(\n createRowSelectionColumn<TType>(!!(options.enableRowDrag && props.onRowDrag), !!props.expandedRowRenderer)\n )\n );\n }\n\n if (options.enableRowDrag && props.onRowDrag) {\n columns.unshift(columnHelper.display(createRowDragColumn(props.onRowDrag)));\n }\n\n if (props.actionsForRow?.length) {\n columns.push(columnHelper.display(createRowActionsColumn<TType>()));\n }\n\n if (editing.isEnabled && editing.isEditing) {\n columns.push(columnHelper.display(createRowEditingActionsColumn<TType>()));\n }\n\n return { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting };\n }, []);\n}\n"],"names":["getSortingFn","dataType","customFnOrBuiltIn","rowA","rowB","columnId","original","useConvertChildrenToColumns","props","options","editing","React","useMemo","columnHelper","createColumnHelper","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","Children","toArray","children","filter","child","forEach","isValidElement","accessor","_child$props$enableRe","_child$props$enableFi","_child$props$enableSo","_child$props$enableHi","_child$props$enableOr","_child$props$enableSe","_child$props$enableTr","defaultWidth","defaultHidden","enableColumnHiding","sort","undefined","push","id","desc","accessorKey","header","Header","cell","Cell","footer","Footer","minSize","MIN_COLUMN_SIZE","enableResizing","enableColumnFilter","enableFiltering","filterFn","enableSorting","sortingFn","sortFn","sortDescFirst","sortUndefined","enableHiding","meta","align","className","control","enableOrdering","enableSearch","enableTruncate","filters","headerClassName","menu","renderer","tooltip","enableRowExpansion","expandedRowRenderer","unshift","display","createRowExpansionColumn","enableRowSelection","createRowSelectionColumn","enableRowDrag","onRowDrag","createRowDragColumn","_props$actionsForRow","actionsForRow","length","createRowActionsColumn","isEnabled","isEditing","createRowEditingActionsColumn"],"mappings":";;;;;;;;;;;;AAcA,SAASA,YAAYA,CAAkBC,QAA+B,EAAEC,iBAAuC;EAC3G,IAAI,OAAOA,iBAAiB,KAAK,UAAU,EAAE;IACzC,OAAO,CAACC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,KAAKH,iBAAiB,CAACC,IAAI,CAACG,QAAQ,EAAEF,IAAI,CAACE,QAAQ,EAAED,QAAQ,CAAC;;;EAI9F,IAAIH,iBAAi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mBAAmB,CAAC,CAC7G,CACJ;;IAGL,IAAIjE,OAAO,CAACuE,aAAa,IAAIxE,KAAK,CAACyE,SAAS,EAAE;MAC1ClE,OAAO,CAAC4D,OAAO,CAAC9D,YAAY,CAAC+D,OAAO,CAACM,mBAAmB,CAAC1E,KAAK,CAACyE,SAAS,CAAC,CAAC,CAAC;;IAG/E,KAAAE,oBAAA,GAAI3E,KAAK,CAAC4E,aAAa,cAAAD,oBAAA,eAAnBA,oBAAA,CAAqBE,MAAM,EAAE;MAC7BtE,OAAO,CAACwB,IAAI,CAAC1B,YAAY,CAAC+D,OAAO,CAACU,sBAAsB,EAAS,CAAC,CAAC;;IAGvE,IAAI5E,OAAO,CAAC6E,SAAS,IAAI7E,OAAO,CAAC8E,SAAS,EAAE;MACxCzE,OAAO,CAACwB,IAAI,CAAC1B,YAAY,CAAC+D,OAAO,CAACa,6BAA6B,EAAS,CAAC,CAAC;;IAG9E,OAAO;MAAE1E,OAAO;MAAEC,mBAAmB;MAAEC,uBAAuB;MAAEC;KAAgB;GACnF,EAAE,EAAE,CAAC;AACV;;;;"}
1
+ {"version":3,"file":"useConvertChildrenToColumns.js","sources":["../../../../../../../../src/components/Table3/hooks/useConvertChildrenToColumns.tsx"],"sourcesContent":["import React from 'react';\nimport { ColumnDef, ColumnSizingState, createColumnHelper, ColumnSort, VisibilityState } from '@tanstack/react-table';\nimport { Table3ColumnProps, Table3Props, Table3Options, Table3ColumnDataType, Table3SortFn } from '../types';\nimport { Header } from '../components/columns/header/Header';\nimport { Footer } from '../components/columns/footer/Footer';\nimport { Cell } from '../components/columns/cell/Cell';\nimport { createRowSelectionColumn } from '../components/columns/internal/Selection';\nimport { MIN_COLUMN_SIZE } from '../components/columns/styles';\nimport { createRowActionsColumn } from '../components/columns/internal/Actions';\nimport { createRowExpansionColumn } from '../components/columns/internal/Expansion';\nimport { createRowDragColumn } from '../components/columns/internal/Drag';\nimport { createRowEditingActionsColumn } from '../components/columns/internal/EditingActions';\nimport { useEditing } from './features/useEditing';\n\nfunction getSortingFn<TType = unknown>(dataType?: Table3ColumnDataType, customFnOrBuiltIn?: Table3SortFn<TType>) {\n if (typeof customFnOrBuiltIn === 'function') {\n return (rowA, rowB, columnId) => customFnOrBuiltIn(rowA.original, rowB.original, columnId);\n }\n\n // if a built in is being used, just return that\n if (customFnOrBuiltIn) {\n return customFnOrBuiltIn;\n }\n\n // some times we alias based on the type\n if (dataType && dataType !== 'boolean' && dataType !== 'number') {\n return dataType;\n }\n\n // otherwise fall back to auto\n return 'auto';\n}\n\nexport function useConvertChildrenToColumns<TType = unknown>(\n props: Table3Props<TType>,\n options: Table3Options,\n editing: ReturnType<typeof useEditing>\n) {\n // It's important to memoise column definitions, because it prevents columns like \"Drag column\" to re-render on every state change,\n // and break dragging at the moment it happens.\n return React.useMemo(() => {\n const columnHelper = createColumnHelper<TType>();\n\n const columns: ColumnDef<TType>[] = [];\n const defaultColumnSizing: ColumnSizingState = {};\n const defaultColumnVisibility: VisibilityState = {};\n const defaultSorting: ColumnSort[] = [];\n\n (React.Children.toArray(props.children) as React.ReactElement<Table3ColumnProps<TType>>[])\n .filter(child => !!child) // remove falsey children\n .forEach(child => {\n if (React.isValidElement<Table3ColumnProps<TType>>(child) && child.props.accessor) {\n if (child.props.defaultWidth) {\n defaultColumnSizing[child.props.accessor as string] =\n child.props.defaultWidth === 'grow' ? '1fr' : (child.props.defaultWidth as any);\n }\n\n if (child.props.defaultHidden && options.enableColumnHiding) {\n defaultColumnVisibility[child.props.accessor as string] = false;\n }\n\n if (child.props.sort !== undefined) {\n defaultSorting.push({\n id: child.props.accessor as string,\n desc: child.props.sort === 'desc',\n });\n }\n\n columns.push({\n accessorKey: child.props.accessor,\n id: child.props.accessor as string,\n header: Header,\n cell: Cell,\n footer: Footer,\n // sizing\n minSize: MIN_COLUMN_SIZE,\n enableResizing: child.props.enableResizing ?? true,\n // filtering\n enableColumnFilter: child.props.enableFiltering ?? true,\n filterFn: 'tacoFilter' as any,\n // sorting\n enableSorting: child.props.enableSorting ?? true,\n sortingFn: getSortingFn<TType>(child.props.dataType, child.props.sortFn),\n sortDescFirst: false,\n sortUndefined: 1,\n // visibility\n enableHiding: child.props.enableHiding ?? true,\n // custom options\n meta: {\n align: child.props.align,\n className: child.props.className,\n control: child.props.control,\n dataType: child.props.dataType,\n enableOrdering: child.props.enableOrdering ?? true,\n enablePrinting: child.props.enablePrinting ?? true,\n enableSearch: child.props.enableSearch ?? true,\n enableTruncate: child.props.enableTruncate ?? false,\n filters: child.props.filters,\n footer: child.props.footer,\n header: child.props.header,\n headerClassName: child.props.headerClassName,\n menu: child.props.menu,\n renderer: child.props.renderer,\n tooltip: child.props.tooltip,\n },\n });\n }\n });\n\n if (options.enableRowExpansion && props.expandedRowRenderer) {\n columns.unshift(columnHelper.display(createRowExpansionColumn(props.expandedRowRenderer)));\n }\n\n if (options.enableRowSelection) {\n columns.unshift(\n columnHelper.display(\n createRowSelectionColumn<TType>(!!(options.enableRowDrag && props.onRowDrag), !!props.expandedRowRenderer)\n )\n );\n }\n\n if (options.enableRowDrag && props.onRowDrag) {\n columns.unshift(columnHelper.display(createRowDragColumn(props.onRowDrag)));\n }\n\n if (props.actionsForRow?.length) {\n columns.push(columnHelper.display(createRowActionsColumn<TType>()));\n }\n\n if (editing.isEnabled && editing.isEditing) {\n columns.push(columnHelper.display(createRowEditingActionsColumn<TType>()));\n }\n\n return { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting };\n }, []);\n}\n"],"names":["getSortingFn","dataType","customFnOrBuiltIn","rowA","rowB","columnId","original","useConvertChildrenToColumns","props","options","editing","React","useMemo","columnHelper","createColumnHelper","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","Children","toArray","children","filter","child","forEach","isValidElement","accessor","_child$props$enableRe","_child$props$enableFi","_child$props$enableSo","_child$props$enableHi","_child$props$enableOr","_child$props$enablePr","_child$props$enableSe","_child$props$enableTr","defaultWidth","defaultHidden","enableColumnHiding","sort","undefined","push","id","desc","accessorKey","header","Header","cell","Cell","footer","Footer","minSize","MIN_COLUMN_SIZE","enableResizing","enableColumnFilter","enableFiltering","filterFn","enableSorting","sortingFn","sortFn","sortDescFirst","sortUndefined","enableHiding","meta","align","className","control","enableOrdering","enablePrinting","enableSearch","enableTruncate","filters","headerClassName","menu","renderer","tooltip","enableRowExpansion","expandedRowRenderer","unshift","display","createRowExpansionColumn","enableRowSelection","createRowSelectionColumn","enableRowDrag","onRowDrag","createRowDragColumn","_props$actionsForRow","actionsForRow","length","createRowActionsColumn","isEnabled","isEditing","createRowEditingActionsColumn"],"mappings":";;;;;;;;;;;;AAcA,SAASA,YAAYA,CAAkBC,QAA+B,EAAEC,iBAAuC;EAC3G,IAAI,OAAOA,iBAAiB,KAAK,UAAU,EAAE;IACzC,OAAO,CAACC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,KAAKH,iBAAiB,CAACC,IAAI,CAACG,QAAQ,EAAEF,IAAI,CAACE,QAAQ,EAAED,QAAQ,CAAC;;;EAI9F,IAAIH,iBAAiB,EAAE;IACnB,OAAOA,iBAAiB;;;EAI5B,IAAID,QAAQ,IAAIA,QAAQ,KAAK,SAAS,IAAIA,QAAQ,KAAK,QAAQ,EAAE;IAC7D,OAAOA,QAAQ;;;EAInB,OAAO,MAAM;AACjB;SAEgBM,2BAA2BA,CACvCC,KAAyB,EACzBC,OAAsB,EACtBC,OAAsC;;;EAItC,OAAOC,cAAK,CAACC,OAAO,CAAC;;IACjB,MAAMC,YAAY,GAAGC,kBAAkB,EAAS;IAEhD,MAAMC,OAAO,GAAuB,EAAE;IACtC,MAAMC,mBAAmB,GAAsB,EAAE;IACjD,MAAMC,uBAAuB,GAAoB,EAAE;IACnD,MAAMC,cAAc,GAAiB,EAAE;IAEtCP,cAAK,CAACQ,QAAQ,CAACC,OAAO,CAACZ,KAAK,CAACa,QAAQ,CAAoD,CACrFC,MAAM,CAACC,KAAK,IAAI,CAAC,CAACA,KAAK,CAAC;KACxBC,OAAO,CAACD,KAAK;MAC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MACxC3E,OAAO,CAACyB,IAAI,CAAC3B,YAAY,CAACiE,OAAO,CAACa,6BAA6B,EAAS,CAAC,CAAC;;IAG9E,OAAO;MAAE5E,OAAO;MAAEC,mBAAmB;MAAEC,uBAAuB;MAAEC;KAAgB;GACnF,EAAE,EAAE,CAAC;AACV;;;;"}
@@ -1,5 +1,5 @@
1
1
  // we cannot just use a fixed height because our rows need to grow in height (images, edit mode validation etc)
2
- const getRowHeightSizing = (height, fontSize) => {
2
+ const getCellHeightPadding = (height, fontSize) => {
3
3
  // TODO: can we get the rem values from tailwind
4
4
  switch (height) {
5
5
  case 'short':
@@ -48,9 +48,22 @@ const getRowHeightSizing = (height, fontSize) => {
48
48
  }
49
49
  }
50
50
  };
51
+ const getCellWidthPadding = fontSize => {
52
+ switch (fontSize) {
53
+ case 'small':
54
+ return '8px';
55
+ case 'medium':
56
+ return '12px';
57
+ default:
58
+ return '16px';
59
+ // py-1.5
60
+ }
61
+ };
62
+
51
63
  const useCssVars = (height, fontSize) => {
52
64
  const style = {
53
- '--table3-row-padding': getRowHeightSizing(height, fontSize)
65
+ '--table3-cell-padding-x': getCellWidthPadding(fontSize),
66
+ '--table3-cell-padding-y': getCellHeightPadding(height, fontSize)
54
67
  };
55
68
  return {
56
69
  style
@@ -1 +1 @@
1
- {"version":3,"file":"useCssVars.js","sources":["../../../../../../../../src/components/Table3/hooks/useCssVars.ts"],"sourcesContent":["import { Table3FontSize, Table3RowHeight } from '../types';\n\n// we cannot just use a fixed height because our rows need to grow in height (images, edit mode validation etc)\nconst getRowHeightSizing = (height: Table3RowHeight, fontSize: Table3FontSize) => {\n // TODO: can we get the rem values from tailwind\n switch (height) {\n case 'short': {\n switch (fontSize) {\n case 'small':\n return '8px';\n\n default:\n return '6px'; // py-1.5\n }\n }\n\n case 'tall': {\n switch (fontSize) {\n case 'small':\n return '16px';\n\n case 'large':\n return '12px';\n\n default:\n return '14px';\n }\n }\n\n case 'extra-tall': {\n switch (fontSize) {\n case 'small':\n return '22px';\n\n case 'large':\n return '18px';\n\n default:\n return '20px';\n }\n }\n\n default: {\n switch (fontSize) {\n case 'small':\n return '12px';\n\n case 'large':\n return '8px';\n\n default:\n return '10px';\n }\n }\n }\n};\n\nexport const useCssVars = (height: Table3RowHeight, fontSize: Table3FontSize) => {\n const style = {\n '--table3-row-padding': getRowHeightSizing(height, fontSize),\n };\n\n return { style };\n};\n"],"names":["getRowHeightSizing","height","fontSize","useCssVars","style"],"mappings":"AAEA;AACA,MAAMA,kBAAkB,GAAGA,CAACC,MAAuB,EAAEC,QAAwB;;EAEzE,QAAQD,MAAM;IACV,KAAK,OAAO;MAAE;QACV,QAAQC,QAAQ;UACZ,KAAK,OAAO;YACR,OAAO,KAAK;UAEhB;YACI,OAAO,KAAK;;;;;IAIxB,KAAK,MAAM;MAAE;QACT,QAAQA,QAAQ;UACZ,KAAK,OAAO;YACR,OAAO,MAAM;UAEjB,KAAK,OAAO;YACR,OAAO,MAAM;UAEjB;YACI,OAAO,MAAM;;;IAIzB,KAAK,YAAY;MAAE;QACf,QAAQA,QAAQ;UACZ,KAAK,OAAO;YACR,OAAO,MAAM;UAEjB,KAAK,OAAO;YACR,OAAO,MAAM;UAEjB;YACI,OAAO,MAAM;;;IAIzB;MAAS;QACL,QAAQA,QAAQ;UACZ,KAAK,OAAO;YACR,OAAO,MAAM;UAEjB,KAAK,OAAO;YACR,OAAO,KAAK;UAEhB;YACI,OAAO,MAAM;;;;AAIjC,CAAC;MAEYC,UAAU,GAAGA,CAACF,MAAuB,EAAEC,QAAwB;EACxE,MAAME,KAAK,GAAG;IACV,sBAAsB,EAAEJ,kBAAkB,CAACC,MAAM,EAAEC,QAAQ;GAC9D;EAED,OAAO;IAAEE;GAAO;AACpB;;;;"}
1
+ {"version":3,"file":"useCssVars.js","sources":["../../../../../../../../src/components/Table3/hooks/useCssVars.ts"],"sourcesContent":["import { Table3FontSize, Table3RowHeight } from '../types';\n\n// we cannot just use a fixed height because our rows need to grow in height (images, edit mode validation etc)\nconst getCellHeightPadding = (height: Table3RowHeight, fontSize: Table3FontSize) => {\n // TODO: can we get the rem values from tailwind\n switch (height) {\n case 'short': {\n switch (fontSize) {\n case 'small':\n return '8px';\n\n default:\n return '6px'; // py-1.5\n }\n }\n\n case 'tall': {\n switch (fontSize) {\n case 'small':\n return '16px';\n\n case 'large':\n return '12px';\n\n default:\n return '14px';\n }\n }\n\n case 'extra-tall': {\n switch (fontSize) {\n case 'small':\n return '22px';\n\n case 'large':\n return '18px';\n\n default:\n return '20px';\n }\n }\n\n default: {\n switch (fontSize) {\n case 'small':\n return '12px';\n\n case 'large':\n return '8px';\n\n default:\n return '10px';\n }\n }\n }\n};\n\nconst getCellWidthPadding = (fontSize: Table3FontSize) => {\n switch (fontSize) {\n case 'small':\n return '8px';\n\n case 'medium':\n return '12px';\n\n default:\n return '16px'; // py-1.5\n }\n};\n\nexport const useCssVars = (height: Table3RowHeight, fontSize: Table3FontSize) => {\n const style = {\n '--table3-cell-padding-x': getCellWidthPadding(fontSize),\n '--table3-cell-padding-y': getCellHeightPadding(height, fontSize),\n };\n\n return { style };\n};\n"],"names":["getCellHeightPadding","height","fontSize","getCellWidthPadding","useCssVars","style"],"mappings":"AAEA;AACA,MAAMA,oBAAoB,GAAGA,CAACC,MAAuB,EAAEC,QAAwB;;EAE3E,QAAQD,MAAM;IACV,KAAK,OAAO;MAAE;QACV,QAAQC,QAAQ;UACZ,KAAK,OAAO;YACR,OAAO,KAAK;UAEhB;YACI,OAAO,KAAK;;;;;IAIxB,KAAK,MAAM;MAAE;QACT,QAAQA,QAAQ;UACZ,KAAK,OAAO;YACR,OAAO,MAAM;UAEjB,KAAK,OAAO;YACR,OAAO,MAAM;UAEjB;YACI,OAAO,MAAM;;;IAIzB,KAAK,YAAY;MAAE;QACf,QAAQA,QAAQ;UACZ,KAAK,OAAO;YACR,OAAO,MAAM;UAEjB,KAAK,OAAO;YACR,OAAO,MAAM;UAEjB;YACI,OAAO,MAAM;;;IAIzB;MAAS;QACL,QAAQA,QAAQ;UACZ,KAAK,OAAO;YACR,OAAO,MAAM;UAEjB,KAAK,OAAO;YACR,OAAO,KAAK;UAEhB;YACI,OAAO,MAAM;;;;AAIjC,CAAC;AAED,MAAMC,mBAAmB,GAAID,QAAwB;EACjD,QAAQA,QAAQ;IACZ,KAAK,OAAO;MACR,OAAO,KAAK;IAEhB,KAAK,QAAQ;MACT,OAAO,MAAM;IAEjB;MACI,OAAO,MAAM;;;AAEzB,CAAC;;MAEYE,UAAU,GAAGA,CAACH,MAAuB,EAAEC,QAAwB;EACxE,MAAMG,KAAK,GAAG;IACV,yBAAyB,EAAEF,mBAAmB,CAACD,QAAQ,CAAC;IACxD,yBAAyB,EAAEF,oBAAoB,CAACC,MAAM,EAAEC,QAAQ;GACnE;EAED,OAAO;IAAEG;GAAO;AACpB;;;;"}
@@ -155,6 +155,7 @@ function useTable(props) {
155
155
  enableFooter: options.enableFooter,
156
156
  fontSize,
157
157
  hoverState,
158
+ isPrinting: props.id.endsWith('_print'),
158
159
  isUsingServer: !!props.loadPage,
159
160
  printing,
160
161
  rowActions: rowActions,