@economic/taco 2.45.4 → 2.46.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. package/dist/components/Provider/Localization.d.ts +2 -0
  2. package/dist/components/Report/Report.d.ts +1 -1
  3. package/dist/components/Table3/Table3.d.ts +2 -14
  4. package/dist/components/Table3/components/Columns/Internal/EditingActionsMenu.d.ts +1 -2
  5. package/dist/components/Table3/components/Editing/DiscardChangesConfirmationDialog.d.ts +7 -0
  6. package/dist/components/Table3/components/Row/Editing/CreateNewRow.d.ts +14 -0
  7. package/dist/components/Table3/components/Row/Editing/TemporaryRow.d.ts +11 -0
  8. package/dist/components/Table3/features/useEditingState.d.ts +29 -0
  9. package/dist/components/Table3/features/useTableEditing.d.ts +26 -36
  10. package/dist/components/Table3/listeners/useTableEditingListener.d.ts +1 -1
  11. package/dist/components/Table3/types.d.ts +24 -8
  12. package/dist/components/Table3/useTable3.d.ts +6 -0
  13. package/dist/components/Table3/util/editing.d.ts +7 -1
  14. package/dist/esm/index.css +28 -4
  15. package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js +2 -2
  16. package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js.map +1 -1
  17. package/dist/esm/packages/taco/src/components/Provider/Localization.js +5 -3
  18. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  19. package/dist/esm/packages/taco/src/components/Select2/Select2.js +1 -1
  20. package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
  21. package/dist/esm/packages/taco/src/components/Switch/Switch.js +1 -1
  22. package/dist/esm/packages/taco/src/components/Switch/Switch.js.map +1 -1
  23. package/dist/esm/packages/taco/src/components/Table3/Table3.js +14 -6
  24. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  25. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.js +1 -2
  26. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.js.map +1 -1
  27. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +25 -11
  28. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
  29. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js +5 -37
  30. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js.map +1 -1
  31. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +17 -12
  32. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
  33. package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js +34 -0
  34. package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js.map +1 -0
  35. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +103 -0
  36. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js.map +1 -0
  37. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js +2 -14
  38. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js.map +1 -1
  39. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js +96 -0
  40. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js.map +1 -0
  41. package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js +39 -6
  42. package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js.map +1 -1
  43. package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js +4 -17
  44. package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js.map +1 -1
  45. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js +519 -0
  46. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js.map +1 -0
  47. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +29 -406
  48. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
  49. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +44 -33
  50. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
  51. package/dist/esm/packages/taco/src/components/Table3/useTable3.js +34 -13
  52. package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
  53. package/dist/esm/packages/taco/src/components/Table3/util/editing.js +11 -23
  54. package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
  55. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +1 -3
  56. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
  57. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js +9 -3
  58. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js.map +1 -1
  59. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +9 -7
  60. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
  61. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
  62. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +1 -1
  63. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
  64. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js +4 -2
  65. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js.map +1 -1
  66. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js +2 -1
  67. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js.map +1 -1
  68. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +29 -7
  69. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  70. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js +2 -2
  71. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
  72. package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
  73. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +1 -1
  74. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
  75. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +11 -0
  76. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  77. package/dist/esm/packages/taco/src/utils/dom.js +7 -4
  78. package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
  79. package/dist/index.css +28 -4
  80. package/dist/primitives/Table/Core/components/Columns/Internal/Actions.d.ts +3 -1
  81. package/dist/primitives/Table/Core/components/Footer/Footer.d.ts +2 -2
  82. package/dist/primitives/Table/Core/components/Row/RowContext.d.ts +1 -0
  83. package/dist/primitives/Table/Core/features/useTableRenderer.d.ts +2 -2
  84. package/dist/primitives/Table/Core/types.d.ts +4 -0
  85. package/dist/primitives/Table/Core/useTable.d.ts +2 -2
  86. package/dist/primitives/Table/types.d.ts +1 -1
  87. package/dist/primitives/Table/useTableManager/useTableManager.d.ts +1 -1
  88. package/dist/taco.cjs.development.js +987 -660
  89. package/dist/taco.cjs.development.js.map +1 -1
  90. package/dist/taco.cjs.production.min.js +1 -1
  91. package/dist/taco.cjs.production.min.js.map +1 -1
  92. package/dist/utils/dom.d.ts +1 -0
  93. package/package.json +2 -2
  94. package/dist/components/Table3/components/Row/Editing/CreateRowButton.d.ts +0 -11
  95. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js +0 -90
  96. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js.map +0 -1
@@ -1,38 +1,23 @@
1
1
  import React__default from 'react';
2
2
  import { isElementInsideOrTriggeredFromContainer } from '../../../utils/dom.js';
3
+ import { useGlobalKeyDown } from '../../../hooks/useGlobalKeyDown.js';
3
4
  import { useLocalization } from '../../Provider/Localization.js';
4
5
  import { resetHighlightedColumnIndexes } from '../../../primitives/Table/useTableManager/util/search.js';
5
6
  import { useLazyEffect } from '../../../hooks/useLazyEffect.js';
7
+ import { shortcut } from '../util/editing.js';
6
8
 
7
- function useTableEditingListener(table, tableRef) {
9
+ function useTableEditingListener(table, tableRef, scrollToIndex) {
8
10
  const tableMeta = table.options.meta;
9
- const completedRowsCount = tableMeta.editing.getCompletedRowsCount();
10
11
  const localization = useLocalization();
11
- const saveChanges = () => {
12
- requestAnimationFrame(() => {
13
- tableMeta.editing.saveChanges();
14
- });
15
- };
16
12
  // save when the row changes
13
+ // store the last row active index, otherwise everytime tableMeta.editing.saveChanges changes the hook runs again
14
+ const lastRowActiveIndexRef = React__default.useRef(tableMeta.rowActive.rowActiveIndex);
17
15
  useLazyEffect(() => {
18
- if (tableMeta.editing.isEditing) {
19
- saveChanges();
16
+ if (tableMeta.editing.isEditing && lastRowActiveIndexRef.current !== undefined && tableMeta.rowActive.rowActiveIndex !== lastRowActiveIndexRef.current) {
17
+ lastRowActiveIndexRef.current = tableMeta.rowActive.rowActiveIndex;
18
+ tableMeta.editing.saveChanges(table);
20
19
  }
21
- }, [tableMeta.rowActive.rowActiveIndex]);
22
- useLazyEffect(() => {
23
- if (tableMeta.editing.isEditing) {
24
- if (tableMeta.rowActive.rowActiveIndex === undefined) {
25
- tableMeta.rowActive.setRowActiveIndex(0);
26
- }
27
- } else {
28
- // save
29
- saveChanges();
30
- // reset detailed mode
31
- tableMeta.editing.toggleDetailedMode(false);
32
- // reset the last index back to the first focusable element, when editing gets turned off
33
- tableMeta.editing.setLastFocusedCellIndex(undefined);
34
- }
35
- }, [tableMeta.editing.isEditing]);
20
+ }, [tableMeta.rowActive.rowActiveIndex, tableMeta.editing.saveChanges]);
36
21
  // show a warning if the user navigates away without triggering save, such as using the browser back/forward button
37
22
  const hasChanges = tableMeta.editing.hasChanges();
38
23
  React__default.useEffect(() => {
@@ -48,25 +33,51 @@ function useTableEditingListener(table, tableRef) {
48
33
  window.removeEventListener('beforeunload', showUnsavedChangesWarning);
49
34
  };
50
35
  }, [tableMeta.editing.isEditing, hasChanges]);
51
- React__default.useEffect(() => {
52
- if (completedRowsCount > 0) {
36
+ const hasSavedChanges = tableMeta.editing.hasSaved();
37
+ useLazyEffect(() => {
38
+ if (hasSavedChanges) {
53
39
  resetHighlightedColumnIndexes(table.getState().globalFilter, table, localization);
54
40
  }
55
- }, [completedRowsCount]);
41
+ }, [hasSavedChanges]);
56
42
  React__default.useEffect(() => {
57
43
  const onClickOutside = event => {
58
44
  if (tableMeta.editing.isEditing) {
59
- var _event$target$getAttr, _event$target;
60
- const element = (_event$target$getAttr = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.getAttribute('data-taco')) !== null && _event$target$getAttr !== void 0 ? _event$target$getAttr : '';
61
- const insideTable = isElementInsideOrTriggeredFromContainer(event.target, tableRef.current) || element === 'backdrop';
62
- if (!insideTable) {
63
- saveChanges();
45
+ const element = event.target;
46
+ const insideTable = element.getAttribute('data-taco') === 'backdrop' || element.getAttribute('data-table') === 'editing-toggle' || isElementInsideOrTriggeredFromContainer(element, tableRef.current);
47
+ // users can click the white space below rows which could be inside the table, but a valid scenario to save
48
+ if (!insideTable || element.tagName === 'TABLE' || element.tagName === 'TBODY') {
49
+ tableMeta.editing.saveChanges(table);
64
50
  }
65
51
  }
66
52
  };
67
53
  document.addEventListener('click', onClickOutside);
68
54
  return () => document.removeEventListener('click', onClickOutside);
69
- }, [saveChanges, tableMeta.editing.isEditing]);
55
+ }, [tableMeta.editing.isEditing, tableMeta.editing.saveChanges]);
56
+ const rows = table.getRowModel().rows;
57
+ // make sure pending changes are removed for rows that no longer exist
58
+ useLazyEffect(() => {
59
+ const pendingChanges = tableMeta.editing.getErrorsShownInAlert();
60
+ pendingChanges.forEach(pendingChange => {
61
+ try {
62
+ table.getRow(pendingChange.rowId);
63
+ } catch {
64
+ tableMeta.editing.discardChanges(pendingChange.rowId, table);
65
+ }
66
+ });
67
+ }, [rows.length]);
68
+ // shortcuts
69
+ useGlobalKeyDown(tableMeta.editing.isEnabled ? shortcut : undefined, event => {
70
+ event.preventDefault();
71
+ tableMeta.editing.toggleEditing(!tableMeta.editing.isEditing, table, scrollToIndex);
72
+ });
73
+ useGlobalKeyDown(tableMeta.editing.isEditing ? {
74
+ key: 's',
75
+ meta: true,
76
+ shift: false
77
+ } : undefined, event => {
78
+ event.preventDefault();
79
+ tableMeta.editing.saveChanges(table);
80
+ });
70
81
  }
71
82
 
72
83
  export { useTableEditingListener };
@@ -1 +1 @@
1
- {"version":3,"file":"useTableEditingListener.js","sources":["../../../../../../../../src/components/Table3/listeners/useTableEditingListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useLazyEffect } from '../../../hooks/useLazyEffect';\nimport { isElementInsideOrTriggeredFromContainer } from '../../../utils/dom';\nimport { TableRef } from '../../../primitives/Table/types';\nimport { resetHighlightedColumnIndexes } from '../../../primitives/Table/useTableManager/util/search';\nimport { useLocalization } from '../../Provider/Localization';\n\nexport function useTableEditingListener<TType = unknown>(table: ReactTable<TType>, tableRef: React.RefObject<TableRef>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const completedRowsCount = tableMeta.editing.getCompletedRowsCount();\n const localization = useLocalization();\n\n const saveChanges = () => {\n requestAnimationFrame(() => {\n tableMeta.editing.saveChanges();\n });\n };\n\n // save when the row changes\n useLazyEffect(() => {\n if (tableMeta.editing.isEditing) {\n saveChanges();\n }\n }, [tableMeta.rowActive.rowActiveIndex]);\n\n useLazyEffect(() => {\n if (tableMeta.editing.isEditing) {\n if (tableMeta.rowActive.rowActiveIndex === undefined) {\n tableMeta.rowActive.setRowActiveIndex(0);\n }\n } else {\n // save\n saveChanges();\n // reset detailed mode\n tableMeta.editing.toggleDetailedMode(false);\n // reset the last index back to the first focusable element, when editing gets turned off\n tableMeta.editing.setLastFocusedCellIndex(undefined);\n }\n }, [tableMeta.editing.isEditing]);\n\n // show a warning if the user navigates away without triggering save, such as using the browser back/forward button\n const hasChanges = tableMeta.editing.hasChanges();\n\n React.useEffect(() => {\n function showUnsavedChangesWarning(event: BeforeUnloadEvent) {\n if (tableMeta.editing.isEditing && hasChanges) {\n event.returnValue = true;\n return true;\n }\n\n return false;\n }\n\n window.addEventListener('beforeunload', showUnsavedChangesWarning);\n\n return () => {\n window.removeEventListener('beforeunload', showUnsavedChangesWarning);\n };\n }, [tableMeta.editing.isEditing, hasChanges]);\n\n React.useEffect(() => {\n if (completedRowsCount > 0) {\n resetHighlightedColumnIndexes(table.getState().globalFilter, table, localization);\n }\n }, [completedRowsCount]);\n\n React.useEffect(() => {\n const onClickOutside = (event: MouseEvent) => {\n if (tableMeta.editing.isEditing) {\n const element = (event.target as Element)?.getAttribute('data-taco') ?? '';\n\n const insideTable =\n isElementInsideOrTriggeredFromContainer(event.target as Element, tableRef.current) || element === 'backdrop';\n\n if (!insideTable) {\n saveChanges();\n }\n }\n };\n\n document.addEventListener('click', onClickOutside);\n\n return () => document.removeEventListener('click', onClickOutside);\n }, [saveChanges, tableMeta.editing.isEditing]);\n}\n"],"names":["useTableEditingListener","table","tableRef","tableMeta","options","meta","completedRowsCount","editing","getCompletedRowsCount","localization","useLocalization","saveChanges","requestAnimationFrame","useLazyEffect","isEditing","rowActive","rowActiveIndex","undefined","setRowActiveIndex","toggleDetailedMode","setLastFocusedCellIndex","hasChanges","React","useEffect","showUnsavedChangesWarning","event","returnValue","window","addEventListener","removeEventListener","resetHighlightedColumnIndexes","getState","globalFilter","onClickOutside","_event$target$getAttr","_event$target","element","target","getAttribute","insideTable","isElementInsideOrTriggeredFromContainer","current","document"],"mappings":";;;;;;SAQgBA,uBAAuBA,CAAkBC,KAAwB,EAAEC,QAAmC;EAClH,MAAMC,SAAS,GAAGF,KAAK,CAACG,OAAO,CAACC,IAA6B;EAC7D,MAAMC,kBAA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,CAAC,CAAC;EAE7CC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIjB,kBAAkB,GAAG,CAAC,EAAE;MACxBwB,6BAA6B,CAAC7B,KAAK,CAAC8B,QAAQ,EAAE,CAACC,YAAY,EAAE/B,KAAK,EAAEQ,YAAY,CAAC;;GAExF,EAAE,CAACH,kBAAkB,CAAC,CAAC;EAExBgB,cAAK,CAACC,SAAS,CAAC;IACZ,MAAMU,cAAc,GAAIR,KAAiB;MACrC,IAAItB,SAAS,CAACI,OAAO,CAACO,SAAS,EAAE;QAAA,IAAAoB,qBAAA,EAAAC,aAAA;QAC7B,MAAMC,OAAO,IAAAF,qBAAA,IAAAC,aAAA,GAAIV,KAAK,CAACY,MAAkB,cAAAF,aAAA,uBAAxBA,aAAA,CAA0BG,YAAY,CAAC,WAAW,CAAC,cAAAJ,qBAAA,cAAAA,qBAAA,GAAI,EAAE;QAE1E,MAAMK,WAAW,GACbC,uCAAuC,CAACf,KAAK,CAACY,MAAiB,EAAEnC,QAAQ,CAACuC,OAAO,CAAC,IAAIL,OAAO,KAAK,UAAU;QAEhH,IAAI,CAACG,WAAW,EAAE;UACd5B,WAAW,EAAE;;;KAGxB;IAED+B,QAAQ,CAACd,gBAAgB,CAAC,OAAO,EAAEK,cAAc,CAAC;IAElD,OAAO,MAAMS,QAAQ,CAACb,mBAAmB,CAAC,OAAO,EAAEI,cAAc,CAAC;GACrE,EAAE,CAACtB,WAAW,EAAER,SAAS,CAACI,OAAO,CAACO,SAAS,CAAC,CAAC;AAClD;;;;"}
1
+ {"version":3,"file":"useTableEditingListener.js","sources":["../../../../../../../../src/components/Table3/listeners/useTableEditingListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useLazyEffect } from '../../../hooks/useLazyEffect';\nimport { isElementInsideOrTriggeredFromContainer } from '../../../utils/dom';\nimport { TableRef } from '../../../primitives/Table/types';\nimport { resetHighlightedColumnIndexes } from '../../../primitives/Table/useTableManager/util/search';\nimport { useLocalization } from '../../Provider/Localization';\nimport { useGlobalKeyDown } from '../../../hooks/useGlobalKeyDown';\nimport { shortcut } from '../util/editing';\n\nexport function useTableEditingListener<TType = unknown>(\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n scrollToIndex: (index: number) => void\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const localization = useLocalization();\n\n // save when the row changes\n // store the last row active index, otherwise everytime tableMeta.editing.saveChanges changes the hook runs again\n const lastRowActiveIndexRef = React.useRef<number | undefined>(tableMeta.rowActive.rowActiveIndex);\n\n useLazyEffect(() => {\n if (\n tableMeta.editing.isEditing &&\n lastRowActiveIndexRef.current !== undefined &&\n tableMeta.rowActive.rowActiveIndex !== lastRowActiveIndexRef.current\n ) {\n lastRowActiveIndexRef.current = tableMeta.rowActive.rowActiveIndex;\n tableMeta.editing.saveChanges(table);\n }\n }, [tableMeta.rowActive.rowActiveIndex, tableMeta.editing.saveChanges]);\n\n // show a warning if the user navigates away without triggering save, such as using the browser back/forward button\n const hasChanges = tableMeta.editing.hasChanges();\n\n React.useEffect(() => {\n function showUnsavedChangesWarning(event: BeforeUnloadEvent) {\n if (tableMeta.editing.isEditing && hasChanges) {\n event.returnValue = true;\n return true;\n }\n\n return false;\n }\n\n window.addEventListener('beforeunload', showUnsavedChangesWarning);\n\n return () => {\n window.removeEventListener('beforeunload', showUnsavedChangesWarning);\n };\n }, [tableMeta.editing.isEditing, hasChanges]);\n\n const hasSavedChanges = tableMeta.editing.hasSaved();\n\n useLazyEffect(() => {\n if (hasSavedChanges) {\n resetHighlightedColumnIndexes(table.getState().globalFilter, table, localization);\n }\n }, [hasSavedChanges]);\n\n React.useEffect(() => {\n const onClickOutside = (event: MouseEvent) => {\n if (tableMeta.editing.isEditing) {\n const element = event.target as Element;\n const insideTable =\n element.getAttribute('data-taco') === 'backdrop' ||\n element.getAttribute('data-table') === 'editing-toggle' ||\n isElementInsideOrTriggeredFromContainer(element, tableRef.current);\n\n // users can click the white space below rows which could be inside the table, but a valid scenario to save\n if (!insideTable || element.tagName === 'TABLE' || element.tagName === 'TBODY') {\n tableMeta.editing.saveChanges(table);\n }\n }\n };\n\n document.addEventListener('click', onClickOutside);\n\n return () => document.removeEventListener('click', onClickOutside);\n }, [tableMeta.editing.isEditing, tableMeta.editing.saveChanges]);\n\n const rows = table.getRowModel().rows;\n\n // make sure pending changes are removed for rows that no longer exist\n useLazyEffect(() => {\n const pendingChanges = tableMeta.editing.getErrorsShownInAlert();\n\n pendingChanges.forEach(pendingChange => {\n try {\n table.getRow(pendingChange.rowId);\n } catch {\n tableMeta.editing.discardChanges(pendingChange.rowId, table);\n }\n });\n }, [rows.length]);\n\n // shortcuts\n useGlobalKeyDown(tableMeta.editing.isEnabled ? shortcut : undefined, (event: KeyboardEvent) => {\n event.preventDefault();\n tableMeta.editing.toggleEditing(!tableMeta.editing.isEditing, table, scrollToIndex);\n });\n\n useGlobalKeyDown(tableMeta.editing.isEditing ? { key: 's', meta: true, shift: false } : undefined, event => {\n event.preventDefault();\n tableMeta.editing.saveChanges(table);\n });\n}\n"],"names":["useTableEditingListener","table","tableRef","scrollToIndex","tableMeta","options","meta","localization","useLocalization","lastRowActiveIndexRef","React","useRef","rowActive","rowActiveIndex","useLazyEffect","editing","isEditing","current","undefined","saveChanges","hasChanges","useEffect","showUnsavedChangesWarning","event","returnValue","window","addEventListener","removeEventListener","hasSavedChanges","hasSaved","resetHighlightedColumnIndexes","getState","globalFilter","onClickOutside","element","target","insideTable","getAttribute","isElementInsideOrTriggeredFromContainer","tagName","document","rows","getRowModel","pendingChanges","getErrorsShownInAlert","forEach","pendingChange","getRow","rowId","discardChanges","length","useGlobalKeyDown","isEnabled","shortcut","preventDefault","toggleEditing","key","shift"],"mappings":";;;;;;;;SAUgBA,uBAAuBA,CACnCC,KAAwB,EACxBC,QAAmC,EACnCC,aAAsC;EAEtC,MAAMC,SAAS,GAAGH,KAAK,CAACI,OAAO,CAAC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AAM,CAAC,CAAC;;EAGjBC,gBAAgB,CAAC/C,SAAS,CAACW,OAAO,CAACqC,SAAS,GAAGC,QAAQ,GAAGnC,SAAS,EAAGK,KAAoB;IACtFA,KAAK,CAAC+B,cAAc,EAAE;IACtBlD,SAAS,CAACW,OAAO,CAACwC,aAAa,CAAC,CAACnD,SAAS,CAACW,OAAO,CAACC,SAAS,EAAEf,KAAK,EAAEE,aAAa,CAAC;GACtF,CAAC;EAEFgD,gBAAgB,CAAC/C,SAAS,CAACW,OAAO,CAACC,SAAS,GAAG;IAAEwC,GAAG,EAAE,GAAG;IAAElD,IAAI,EAAE,IAAI;IAAEmD,KAAK,EAAE;GAAO,GAAGvC,SAAS,EAAEK,KAAK;IACpGA,KAAK,CAAC+B,cAAc,EAAE;IACtBlD,SAAS,CAACW,OAAO,CAACI,WAAW,CAAClB,KAAK,CAAC;GACvC,CAAC;AACN;;;;"}
@@ -11,33 +11,54 @@ const RENDERERS = {
11
11
  cell: Cell
12
12
  };
13
13
  function useTable3(props, ref) {
14
- const editing = useTableEditing(props.enableEditing, props.onEditingSave, props.onEditingChange, props.validator);
14
+ const editing = useTableEditing(props.enableEditing, props.onEditingSave, props.onEditingChange, props.rowIdentityAccessor, props.validator);
15
15
  const creationEnabled = editing.isEnabled && !!props.onEditingCreate;
16
+ // this gives me the performance heeby jeebies, but can't think of a better way to internalise the state
17
+ const data = React__default.useMemo(() => {
18
+ if (editing.temporaryRows.length) {
19
+ var _props$data;
20
+ return ((_props$data = props.data) !== null && _props$data !== void 0 ? _props$data : []).concat(editing.temporaryRows);
21
+ }
22
+ return props.data;
23
+ }, [JSON.stringify(props.data), editing.temporaryRows.length]);
16
24
  const extendedProps = {
17
25
  ...props,
26
+ data,
18
27
  enableRowActions: editing.isEditing ? true : props.enableRowActions,
19
- rowActions: editing.isEditing ? [(_, rowId) => (/*#__PURE__*/React__default.createElement(EditingActionMenu, {
20
- hasChanges: editing.hasChanges(rowId),
21
- hasErrors: editing.hasRowErrors(rowId),
22
- onClear: () => editing.resetChanges(rowId),
23
- onEditingSave: () => editing.saveChanges(rowId),
24
- onExit: () => editing.toggleEditing(false),
25
- isLastRow: !creationEnabled && table.meta.rowActive.rowActiveIndex === table.meta.length - 1
26
- }))] : props.rowActions
28
+ // Display EditingActionMenu instead of row actions while editing
29
+ rowActions: editing.isEditing ? [(_, rowId, table) => {
30
+ const tableMeta = table.options.meta;
31
+ return /*#__PURE__*/React__default.createElement(EditingActionMenu, {
32
+ hasChanges: editing.hasChanges(rowId),
33
+ hasErrors: editing.hasRowErrors(rowId),
34
+ onDiscard: () => editing.discardChanges(rowId, table),
35
+ onEditingSave: function () {
36
+ try {
37
+ return Promise.resolve(editing.saveChanges(table, rowId)).then(function () {});
38
+ } catch (e) {
39
+ return Promise.reject(e);
40
+ }
41
+ },
42
+ isLastRow: !creationEnabled && tableMeta.rowActive.rowActiveIndex === tableMeta.length - 1
43
+ });
44
+ }] : props.rowActions
27
45
  };
28
46
  const meta = {
29
47
  editing
30
48
  };
31
- const table = useTable(extendedProps, ref, RENDERERS, meta);
49
+ const options = {
50
+ virtualiserPaddingEndOffset: props.enableEditing && props.onEditingCreate ? editing.hasTemporaryRowErrors() ? 1.4 : 1 : 0
51
+ };
52
+ const table = useTable(extendedProps, ref, RENDERERS, meta, options);
32
53
  // listeners
33
- useTableEditingListener(table.instance, table.ref);
54
+ useTableEditingListener(table.instance, table.ref, table.renderer.scrollToIndex);
34
55
  React__default.useEffect(() => {
35
56
  if (table.ref.current) {
36
- table.ref.current.instance.toggleEditing = enabled => table.meta.editing.toggleEditing(enabled !== null && enabled !== void 0 ? enabled : editing => !editing);
57
+ table.ref.current.instance.toggleEditing = enabled => table.meta.editing.toggleEditing(enabled !== null && enabled !== void 0 ? enabled : editing => !editing, table.instance, table.renderer.scrollToIndex);
37
58
  }
38
59
  }, [table.ref.current]);
39
60
  return table;
40
61
  }
41
62
 
42
- export { useTable3 };
63
+ export { RENDERERS, useTable3 };
43
64
  //# sourceMappingURL=useTable3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTable3.js","sources":["../../../../../../../src/components/Table3/useTable3.tsx"],"sourcesContent":["import React from 'react';\nimport { RowData } from '@tanstack/react-table';\nimport { useTable } from '../../primitives/Table/Core/useTable';\nimport { useTableEditingListener } from './listeners/useTableEditingListener';\nimport { useTableEditing } from './features/useTableEditing';\nimport { Table3Props, Table3Ref } from './types';\nimport { TableRowActionRenderer } from '../../primitives/Table/types';\nimport { Cell } from './components/Columns/Cell/Cell';\nimport { EditingActionMenu } from './components/Columns/Internal/EditingActionsMenu';\nimport { Row } from './components/Row/Row';\n\nconst RENDERERS = {\n row: Row,\n cell: Cell,\n};\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n editing: ReturnType<typeof useTableEditing>;\n }\n}\n\ntype Table3Meta = {\n editing: ReturnType<typeof useTableEditing>;\n};\n\nexport function useTable3<TType>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const editing = useTableEditing(props.enableEditing, props.onEditingSave, props.onEditingChange, props.validator);\n const creationEnabled = editing.isEnabled && !!props.onEditingCreate;\n\n const extendedProps: Table3Props<TType> = {\n ...props,\n enableRowActions: editing.isEditing ? true : props.enableRowActions,\n rowActions: editing.isEditing\n ? ([\n (_, rowId) => (\n <EditingActionMenu\n hasChanges={editing.hasChanges(rowId)}\n hasErrors={editing.hasRowErrors(rowId)}\n onClear={() => editing.resetChanges(rowId)}\n onEditingSave={() => editing.saveChanges(rowId)}\n onExit={() => editing.toggleEditing(false)}\n isLastRow={!creationEnabled && table.meta.rowActive.rowActiveIndex === table.meta.length - 1}\n />\n ),\n ] as TableRowActionRenderer<TType>[])\n : props.rowActions,\n };\n const meta = { editing };\n const table = useTable<TType, Table3Meta>(extendedProps, ref, RENDERERS, meta);\n\n // listeners\n useTableEditingListener<TType>(table.instance, table.ref);\n\n React.useEffect(() => {\n if (table.ref.current) {\n (table.ref.current as Table3Ref).instance.toggleEditing = (enabled: boolean | undefined) =>\n table.meta.editing.toggleEditing(enabled ?? (editing => !editing));\n }\n }, [table.ref.current]);\n\n return table;\n}\n"],"names":["RENDERERS","row","Row","cell","Cell","useTable3","props","ref","editing","useTableEditing","enableEditing","onEditingSave","onEditingChange","validator","creationEnabled","isEnabled","onEditingCreate","extendedProps","enableRowActions","isEditing","rowActions","_","rowId","React","EditingActionMenu","hasChanges","hasErrors","hasRowErrors","onClear","resetChanges","saveChanges","onExit","toggleEditing","isLastRow","table","meta","rowActive","rowActiveIndex","length","useTable","useTableEditingListener","instance","useEffect","current","enabled"],"mappings":";;;;;;;;AAWA,MAAMA,SAAS,GAAG;EACdC,GAAG,EAAEC,GAAG;EACRC,IAAI,EAAEC;CACT;SAYeC,SAASA,CAAQC,KAAyB,EAAEC,GAAyB;EACjF,MAAMC,OAAO,GAAGC,eAAe,CAACH,KAAK,CAACI,aAAa,EAAEJ,KAAK,CAACK,aAAa,EAAEL,KAAK,CAACM,eAAe,EAAEN,KAAK,CAACO,SAAS,CAAC;EACjH,MAAMC,eAAe,GAAGN,OAAO,CAACO,SAAS,IAAI,CAAC,CAACT,KAAK,CAACU,eAAe;EAEpE,MAAMC,aAAa,GAAuB;IACtC,GAAGX,KAAK;IACRY,gBAAgB,EAAEV,OAAO,CAACW,SAAS,GAAG,IAAI,GAAGb,KAAK,CAACY,gBAAgB;IACnEE,UAAU,EAAEZ,OAAO,CAACW,SAAS,GACtB,CACG,CAACE,CAAC,EAAEC,KAAK,mBACLC,6BAACC,iBAAiB;MACdC,UAAU,EAAEjB,OAAO,CAACiB,UAAU,CAACH,KAAK,CAAC;MACrCI,SAAS,EAAElB,OAAO,CAACmB,YAAY,CAACL,KAAK,CAAC;MACtCM,OAAO,EAAEA,MAAMpB,OAAO,CAACqB,YAAY,CAACP,KAAK,CAAC;MAC1CX,aAAa,EAAEA,MAAMH,OAAO,CAACsB,WAAW,CAACR,KAAK,CAAC;MAC/CS,MAAM,EAAEA,MAAMvB,OAAO,CAACwB,aAAa,CAAC,KAAK,CAAC;MAC1CC,SAAS,EAAE,CAACnB,eAAe,IAAIoB,KAAK,CAACC,IAAI,CAACC,SAAS,CAACC,cAAc,KAAKH,KAAK,CAACC,IAAI,CAACG,MAAM,GAAG;MAC7F,CACL,CACgC,GACrChC,KAAK,CAACc;GACf;EACD,MAAMe,IAAI,GAAG;IAAE3B;GAAS;EACxB,MAAM0B,KAAK,GAAGK,QAAQ,CAAoBtB,aAAa,EAAEV,GAAG,EAAEP,SAAS,EAAEmC,IAAI,CAAC;;EAG9EK,uBAAuB,CAAQN,KAAK,CAACO,QAAQ,EAAEP,KAAK,CAAC3B,GAAG,CAAC;EAEzDgB,cAAK,CAACmB,SAAS,CAAC;IACZ,IAAIR,KAAK,CAAC3B,GAAG,CAACoC,OAAO,EAAE;MAClBT,KAAK,CAAC3B,GAAG,CAACoC,OAAqB,CAACF,QAAQ,CAACT,aAAa,GAAIY,OAA4B,IACnFV,KAAK,CAACC,IAAI,CAAC3B,OAAO,CAACwB,aAAa,CAACY,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAKpC,OAAO,IAAI,CAACA,OAAQ,CAAC;;GAE7E,EAAE,CAAC0B,KAAK,CAAC3B,GAAG,CAACoC,OAAO,CAAC,CAAC;EAEvB,OAAOT,KAAK;AAChB;;;;"}
1
+ {"version":3,"file":"useTable3.js","sources":["../../../../../../../src/components/Table3/useTable3.tsx"],"sourcesContent":["import React from 'react';\nimport { RowData, Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useTable } from '../../primitives/Table/Core/useTable';\nimport { useTableEditingListener } from './listeners/useTableEditingListener';\nimport { useTableEditing } from './features/useTableEditing';\nimport { Table3Props, Table3Ref } from './types';\nimport { TableRowActionRenderer } from '../../primitives/Table/types';\nimport { Cell } from './components/Columns/Cell/Cell';\nimport { EditingActionMenu } from './components/Columns/Internal/EditingActionsMenu';\nimport { Row } from './components/Row/Row';\nimport { useTableRenderOptions } from '../../primitives/Table/Core/types';\n\nexport const RENDERERS = {\n row: Row,\n cell: Cell,\n};\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n editing: ReturnType<typeof useTableEditing>;\n }\n}\n\ntype Table3Meta = {\n editing: ReturnType<typeof useTableEditing>;\n};\n\nexport function useTable3<TType>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const editing = useTableEditing(\n props.enableEditing,\n props.onEditingSave,\n props.onEditingChange,\n props.rowIdentityAccessor,\n props.validator\n );\n const creationEnabled = editing.isEnabled && !!props.onEditingCreate;\n\n // this gives me the performance heeby jeebies, but can't think of a better way to internalise the state\n const data: TType[] = React.useMemo(() => {\n if (editing.temporaryRows.length) {\n return (props.data ?? []).concat(editing.temporaryRows as TType[]);\n }\n\n return props.data;\n }, [JSON.stringify(props.data), editing.temporaryRows.length]);\n\n const extendedProps: Table3Props<TType> = {\n ...props,\n data,\n enableRowActions: editing.isEditing ? true : props.enableRowActions,\n // Display EditingActionMenu instead of row actions while editing\n rowActions: editing.isEditing\n ? ([\n (_, rowId, table: ReactTable<TType>) => {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n return (\n <EditingActionMenu\n hasChanges={editing.hasChanges(rowId)}\n hasErrors={editing.hasRowErrors(rowId)}\n onDiscard={() => editing.discardChanges(rowId, table)}\n onEditingSave={async () => {\n await editing.saveChanges(table, rowId);\n }}\n isLastRow={!creationEnabled && tableMeta.rowActive.rowActiveIndex === tableMeta.length - 1}\n />\n );\n },\n ] as TableRowActionRenderer<TType>[])\n : props.rowActions,\n };\n const meta = { editing };\n\n const options: useTableRenderOptions = {\n virtualiserPaddingEndOffset:\n props.enableEditing && props.onEditingCreate ? (editing.hasTemporaryRowErrors() ? 1.4 : 1) : 0,\n };\n\n const table = useTable<TType, Table3Meta>(extendedProps, ref, RENDERERS, meta, options);\n\n // listeners\n useTableEditingListener<TType>(table.instance, table.ref, table.renderer.scrollToIndex);\n\n React.useEffect(() => {\n if (table.ref.current) {\n (table.ref.current as Table3Ref).instance.toggleEditing = (enabled: boolean | undefined) =>\n table.meta.editing.toggleEditing(enabled ?? (editing => !editing), table.instance, table.renderer.scrollToIndex);\n }\n }, [table.ref.current]);\n\n return table;\n}\n"],"names":["RENDERERS","row","Row","cell","Cell","useTable3","props","ref","editing","useTableEditing","enableEditing","onEditingSave","onEditingChange","rowIdentityAccessor","validator","creationEnabled","isEnabled","onEditingCreate","data","React","useMemo","temporaryRows","length","_props$data","concat","JSON","stringify","extendedProps","enableRowActions","isEditing","rowActions","_","rowId","table","tableMeta","options","meta","EditingActionMenu","hasChanges","hasErrors","hasRowErrors","onDiscard","discardChanges","saveChanges","then","e","Promise","reject","isLastRow","rowActive","rowActiveIndex","virtualiserPaddingEndOffset","hasTemporaryRowErrors","useTable","useTableEditingListener","instance","renderer","scrollToIndex","useEffect","current","toggleEditing","enabled"],"mappings":";;;;;;;;MAYaA,SAAS,GAAG;EACrBC,GAAG,EAAEC,GAAG;EACRC,IAAI,EAAEC;;SAaMC,SAASA,CAAQC,KAAyB,EAAEC,GAAyB;EACjF,MAAMC,OAAO,GAAGC,eAAe,CAC3BH,KAAK,CAACI,aAAa,EACnBJ,KAAK,CAACK,aAAa,EACnBL,KAAK,CAACM,eAAe,EACrBN,KAAK,CAACO,mBAAmB,EACzBP,KAAK,CAACQ,SAAS,CAClB;EACD,MAAMC,eAAe,GAAGP,OAAO,CAACQ,SAAS,IAAI,CAAC,CAACV,KAAK,CAACW,eAAe;;EAGpE,MAAMC,IAAI,GAAYC,cAAK,CAACC,OAAO,CAAC;IAChC,IAAIZ,OAAO,CAACa,aAAa,CAACC,MAAM,EAAE;MAAA,IAAAC,WAAA;MAC9B,OAAO,EAAAA,WAAA,GAACjB,KAAK,CAACY,IAAI,cAAAK,WAAA,cAAAA,WAAA,GAAI,EAAE,EAAEC,MAAM,CAAChB,OAAO,CAACa,aAAwB,CAAC;;IAGtE,OAAOf,KAAK,CAACY,IAAI;GACpB,EAAE,CAACO,IAAI,CAACC,SAAS,CAACpB,KAA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BAAuB,CAAQrB,KAAK,CAACsB,QAAQ,EAAEtB,KAAK,CAAC1B,GAAG,EAAE0B,KAAK,CAACuB,QAAQ,CAACC,aAAa,CAAC;EAEvFtC,cAAK,CAACuC,SAAS,CAAC;IACZ,IAAIzB,KAAK,CAAC1B,GAAG,CAACoD,OAAO,EAAE;MAClB1B,KAAK,CAAC1B,GAAG,CAACoD,OAAqB,CAACJ,QAAQ,CAACK,aAAa,GAAIC,OAA4B,IACnF5B,KAAK,CAACG,IAAI,CAAC5B,OAAO,CAACoD,aAAa,CAACC,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAKrD,OAAO,IAAI,CAACA,OAAO,EAAGyB,KAAK,CAACsB,QAAQ,EAAEtB,KAAK,CAACuB,QAAQ,CAACC,aAAa,CAAC;;GAE3H,EAAE,CAACxB,KAAK,CAAC1B,GAAG,CAACoD,OAAO,CAAC,CAAC;EAEvB,OAAO1B,KAAK;AAChB;;;;"}
@@ -1,4 +1,3 @@
1
- import { setDataFocusAttribute } from '../../../utils/dom.js';
2
1
  import { columnFilterFn } from '../../../primitives/Table/useTableManager/util/filtering.js';
3
2
  import { globalFilterFn } from '../../../primitives/Table/useTableManager/util/search.js';
4
3
 
@@ -81,29 +80,18 @@ function willRowMoveAfterSorting(cell, change, rowIndex) {
81
80
  }
82
81
  return ((_resortedRows$index = resortedRows[index]) === null || _resortedRows$index === void 0 ? void 0 : _resortedRows$index.id) !== cell.row.id;
83
82
  }
84
- function animateCreateRow(id) {
85
- const templateRow = document.querySelector(`[data-row-id="${id}"]`);
86
- if (templateRow) {
87
- const firstCell = templateRow.querySelector(':first-child');
88
- const checkbox = firstCell === null || firstCell === void 0 ? void 0 : firstCell.querySelector('[data-taco="checkbox"]');
89
- firstCell === null || firstCell === void 0 ? void 0 : firstCell.focus();
90
- if (checkbox) {
91
- setDataFocusAttribute(checkbox);
92
- }
93
- templateRow.scrollIntoView();
94
- const keyframes = [{
95
- background: '#b2c7ef'
96
- }, {
97
- background: '#ebebeb'
98
- }];
99
- for (const child of templateRow.children) {
100
- child.animate(keyframes, {
101
- duration: 1000,
102
- easing: 'ease-out'
103
- });
104
- }
83
+ const TEMPORARY_ROW_ID_PREFIX = 'temp-';
84
+ function isTemporaryRow(rowId) {
85
+ if (rowId === undefined) {
86
+ return false;
105
87
  }
88
+ return String(rowId).startsWith(TEMPORARY_ROW_ID_PREFIX);
106
89
  }
90
+ const shortcut = {
91
+ key: 'e',
92
+ meta: true,
93
+ shift: false
94
+ };
107
95
 
108
- export { animateCreateRow, willRowMove };
96
+ export { TEMPORARY_ROW_ID_PREFIX, isTemporaryRow, shortcut, willRowMove };
109
97
  //# sourceMappingURL=editing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"editing.js","sources":["../../../../../../../../src/components/Table3/util/editing.ts"],"sourcesContent":["import { Cell as ReactTableCell, Row as ReactTableRow, Table as ReactTable } from '@tanstack/react-table';\nimport { TableFilterValue } from '../../../primitives/Table/types';\nimport { setDataFocusAttribute } from '../../../utils/dom';\nimport { columnFilterFn } from '../../../primitives/Table/useTableManager/util/filtering';\nimport { globalFilterFn } from '../../../primitives/Table/useTableManager/util/search';\nimport { Localization } from '../../Provider/Localization';\n\nexport function willRowMove<TType = unknown>(\n cell: ReactTableCell<TType, unknown>,\n change: unknown,\n rowIndex: number,\n localization: Localization\n) {\n const { table } = cell.getContext();\n\n if (willRowMoveAfterSearch<TType>(cell, change, table, localization)) {\n return 'search';\n } else if (willRowMoveAfterFilter<TType>(cell, change)) {\n return 'filter';\n } else if (willRowMoveAfterSorting<TType>(cell, change, rowIndex)) {\n return 'sorting';\n }\n\n return undefined;\n}\n\nfunction willRowMoveAfterSearch<TType = unknown>(\n cell: ReactTableCell<TType, unknown>,\n change: unknown,\n table: ReactTable<TType>,\n localization: Localization\n) {\n const searchQuery = table.getState().globalFilter;\n\n if (!table.options.enableGlobalFilter || !searchQuery) {\n return false;\n }\n\n const rowWithChange = { ...cell.row, original: { ...cell.row.original, [cell.column.id]: change } };\n return !globalFilterFn(rowWithChange, cell.column.id, searchQuery, localization);\n}\n\nfunction willRowMoveAfterFilter<TType = unknown>(cell: ReactTableCell<TType, unknown>, change: unknown) {\n if (!cell.column.getIsFiltered()) {\n return false;\n }\n\n return !columnFilterFn(change, cell.column.getFilterValue() as TableFilterValue);\n}\n\nfunction willRowMoveAfterSorting<TType = unknown>(cell: ReactTableCell<TType, unknown>, change: unknown, rowIndex: number) {\n if (!cell.column.getIsSorted()) {\n return false;\n }\n\n const { table } = cell.getContext();\n const rows = table.getRowModel().rows;\n\n const miniSortRows: ReactTableRow<TType>[] = [\n {\n ...cell.row,\n original: {\n ...cell.row.original,\n [cell.column.id]: change,\n },\n getValue: () => change as any,\n },\n ];\n\n let index = 0;\n\n if (rowIndex > 0) {\n miniSortRows.unshift(rows[rowIndex - 1]);\n index = 1;\n }\n\n if (rowIndex < rows.length - 1) {\n miniSortRows.push(rows[rowIndex + 1]);\n }\n\n const resortedRows = [...miniSortRows].sort((rowA, rowB) => {\n const sortFn = cell.column.getSortingFn();\n const sortUndefined = cell.column.columnDef.sortUndefined;\n\n if (!table.options.manualSorting && sortUndefined) {\n const aValue = rowA.getValue(cell.column.id);\n const bValue = rowB.getValue(cell.column.id);\n\n const aUndefined = aValue === undefined;\n const bUndefined = bValue === undefined;\n\n if (aUndefined || bUndefined) {\n if (sortUndefined === 'first') return aUndefined ? -1 : 1;\n if (sortUndefined === 'last') return aUndefined ? 1 : -1;\n\n return aUndefined && bUndefined ? 0 : aUndefined ? sortUndefined : -sortUndefined;\n }\n }\n\n return sortFn(rowA, rowB, cell.column.id);\n });\n\n if (cell.column.getIsSorted() === 'desc') {\n resortedRows.reverse();\n }\n\n return resortedRows[index]?.id !== cell.row.id;\n}\n\nexport function animateCreateRow(id) {\n const templateRow = document.querySelector(`[data-row-id=\"${id}\"]`);\n\n if (templateRow) {\n const firstCell = templateRow.querySelector(':first-child') as HTMLElement;\n const checkbox = firstCell?.querySelector('[data-taco=\"checkbox\"]');\n firstCell?.focus();\n\n if (checkbox) {\n setDataFocusAttribute(checkbox);\n }\n\n templateRow.scrollIntoView();\n\n const keyframes = [{ background: '#b2c7ef' }, { background: '#ebebeb' }];\n\n for (const child of templateRow.children) {\n child.animate(keyframes, { duration: 1000, easing: 'ease-out' });\n }\n }\n}\n"],"names":["willRowMove","cell","change","rowIndex","localization","table","getContext","willRowMoveAfterSearch","willRowMoveAfterFilter","willRowMoveAfterSorting","undefined","searchQuery","getState","globalFilter","options","enableGlobalFilter","rowWithChange","row","original","column","id","globalFilterFn","getIsFiltered","columnFilterFn","getFilterValue","getIsSorted","rows","getRowModel","miniSortRows","getValue","index","unshift","length","push","resortedRows","sort","rowA","rowB","sortFn","getSortingFn","sortUndefined","columnDef","manualSorting","aValue","bValue","aUndefined","bUndefined","reverse","_resortedRows$index","animateCreateRow","templateRow","document","querySelector","firstCell","checkbox","focus","setDataFocusAttribute","scrollIntoView","keyframes","background","child","children","animate","duration","easing"],"mappings":";;;;SAOgBA,WAAWA,CACvBC,IAAoC,EACpCC,MAAe,EACfC,QAAgB,EAChBC,YAA0B;EAE1B,MAAM;IAAEC;GAAO,GAAGJ,IAAI,CAACK,UAAU,EAAE;EAEnC,IAAIC,sBAAsB,CAAQN,IAAI,EAAEC,MAAM,EAAEG,KAAK,EAAED,YAAY,CAAC,EAAE;IAClE,OAAO,QAAQ;GAClB,MAAM,IAAII,sBAAsB,CAAQP,IAAI,EAAEC,MAAM,CAAC,EAAE;IACpD,OAAO,QAAQ;GAClB,MAAM,IAAIO,uBAAuB,CAAQR,IAAI,EAAEC,MAAM,EAAEC,QAAQ,CAAC,EAAE;IAC/D,OAAO,SAAS;;EAGpB,OAAOO,SAAS;AACpB;AAEA,SAASH,sBAAsBA,CAC3BN,IAAoC,EACpCC,MAAe,EACfG,KAAwB,EACxBD,YAA0B;EAE1B,MAAMO,WAAW,GAAGN,KAAK,CAACO,QAAQ,EAAE,CAACC,YAAY;EAEjD,IAAI,CAACR,KAAK,CAACS,OAAO,C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E;IACtCS,YAAY,CAACa,OAAO,EAAE;;EAG1B,OAAO,EAAAC,mBAAA,GAAAd,YAAY,CAACJ,KAAK,CAAC,cAAAkB,mBAAA,uBAAnBA,mBAAA,CAAqB5B,EAAE,MAAKnB,IAAI,CAACgB,GAAG,CAACG,EAAE;AAClD;SAEgB6B,gBAAgBA,CAAC7B,EAAE;EAC/B,MAAM8B,WAAW,GAAGC,QAAQ,CAACC,aAAa,CAAC,iBAAiBhC,EAAE,IAAI,CAAC;EAEnE,IAAI8B,WAAW,EAAE;IACb,MAAMG,SAAS,GAAGH,WAAW,CAACE,aAAa,CAAC,cAAc,CAAgB;IAC1E,MAAME,QAAQ,GAAGD,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAED,aAAa,CAAC,wBAAwB,CAAC;IACnEC,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEE,KAAK,EAAE;IAElB,IAAID,QAAQ,EAAE;MACVE,qBAAqB,CAACF,QAAQ,CAAC;;IAGnCJ,WAAW,CAACO,cAAc,EAAE;IAE5B,MAAMC,SAAS,GAAG,CAAC;MAAEC,UAAU,EAAE;KAAW,EAAE;MAAEA,UAAU,EAAE;KAAW,CAAC;IAExE,KAAK,MAAMC,KAAK,IAAIV,WAAW,CAACW,QAAQ,EAAE;MACtCD,KAAK,CAACE,OAAO,CAACJ,SAAS,EAAE;QAAEK,QAAQ,EAAE,IAAI;QAAEC,MAAM,EAAE;OAAY,CAAC;;;AAG5E;;;;"}
1
+ {"version":3,"file":"editing.js","sources":["../../../../../../../../src/components/Table3/util/editing.ts"],"sourcesContent":["import { Cell as ReactTableCell, Row as ReactTableRow, Table as ReactTable } from '@tanstack/react-table';\nimport { TableFilterValue } from '../../../primitives/Table/types';\nimport { columnFilterFn } from '../../../primitives/Table/useTableManager/util/filtering';\nimport { globalFilterFn } from '../../../primitives/Table/useTableManager/util/search';\nimport { Localization } from '../../Provider/Localization';\n\nexport function willRowMove<TType = unknown>(\n cell: ReactTableCell<TType, unknown>,\n change: unknown,\n rowIndex: number,\n localization: Localization\n) {\n const { table } = cell.getContext();\n\n if (willRowMoveAfterSearch<TType>(cell, change, table, localization)) {\n return 'search';\n } else if (willRowMoveAfterFilter<TType>(cell, change)) {\n return 'filter';\n } else if (willRowMoveAfterSorting<TType>(cell, change, rowIndex)) {\n return 'sorting';\n }\n\n return undefined;\n}\n\nfunction willRowMoveAfterSearch<TType = unknown>(\n cell: ReactTableCell<TType, unknown>,\n change: unknown,\n table: ReactTable<TType>,\n localization: Localization\n) {\n const searchQuery = table.getState().globalFilter;\n\n if (!table.options.enableGlobalFilter || !searchQuery) {\n return false;\n }\n\n const rowWithChange = { ...cell.row, original: { ...cell.row.original, [cell.column.id]: change } };\n return !globalFilterFn(rowWithChange, cell.column.id, searchQuery, localization);\n}\n\nfunction willRowMoveAfterFilter<TType = unknown>(cell: ReactTableCell<TType, unknown>, change: unknown) {\n if (!cell.column.getIsFiltered()) {\n return false;\n }\n\n return !columnFilterFn(change, cell.column.getFilterValue() as TableFilterValue);\n}\n\nfunction willRowMoveAfterSorting<TType = unknown>(cell: ReactTableCell<TType, unknown>, change: unknown, rowIndex: number) {\n if (!cell.column.getIsSorted()) {\n return false;\n }\n\n const { table } = cell.getContext();\n const rows = table.getRowModel().rows;\n\n const miniSortRows: ReactTableRow<TType>[] = [\n {\n ...cell.row,\n original: {\n ...cell.row.original,\n [cell.column.id]: change,\n },\n getValue: () => change as any,\n },\n ];\n\n let index = 0;\n\n if (rowIndex > 0) {\n miniSortRows.unshift(rows[rowIndex - 1]);\n index = 1;\n }\n\n if (rowIndex < rows.length - 1) {\n miniSortRows.push(rows[rowIndex + 1]);\n }\n\n const resortedRows = [...miniSortRows].sort((rowA, rowB) => {\n const sortFn = cell.column.getSortingFn();\n const sortUndefined = cell.column.columnDef.sortUndefined;\n\n if (!table.options.manualSorting && sortUndefined) {\n const aValue = rowA.getValue(cell.column.id);\n const bValue = rowB.getValue(cell.column.id);\n\n const aUndefined = aValue === undefined;\n const bUndefined = bValue === undefined;\n\n if (aUndefined || bUndefined) {\n if (sortUndefined === 'first') return aUndefined ? -1 : 1;\n if (sortUndefined === 'last') return aUndefined ? 1 : -1;\n\n return aUndefined && bUndefined ? 0 : aUndefined ? sortUndefined : -sortUndefined;\n }\n }\n\n return sortFn(rowA, rowB, cell.column.id);\n });\n\n if (cell.column.getIsSorted() === 'desc') {\n resortedRows.reverse();\n }\n\n return resortedRows[index]?.id !== cell.row.id;\n}\n\nexport const TEMPORARY_ROW_ID_PREFIX = 'temp-';\n\nexport function isTemporaryRow(rowId: string) {\n if (rowId === undefined) {\n return false;\n }\n\n return String(rowId).startsWith(TEMPORARY_ROW_ID_PREFIX);\n}\n\nexport const shortcut = { key: 'e', meta: true, shift: false };\n"],"names":["willRowMove","cell","change","rowIndex","localization","table","getContext","willRowMoveAfterSearch","willRowMoveAfterFilter","willRowMoveAfterSorting","undefined","searchQuery","getState","globalFilter","options","enableGlobalFilter","rowWithChange","row","original","column","id","globalFilterFn","getIsFiltered","columnFilterFn","getFilterValue","getIsSorted","rows","getRowModel","miniSortRows","getValue","index","unshift","length","push","resortedRows","sort","rowA","rowB","sortFn","getSortingFn","sortUndefined","columnDef","manualSorting","aValue","bValue","aUndefined","bUndefined","reverse","_resortedRows$index","TEMPORARY_ROW_ID_PREFIX","isTemporaryRow","rowId","String","startsWith","shortcut","key","meta","shift"],"mappings":";;;SAMgBA,WAAWA,CACvBC,IAAoC,EACpCC,MAAe,EACfC,QAAgB,EAChBC,YAA0B;EAE1B,MAAM;IAAEC;GAAO,GAAGJ,IAAI,CAACK,UAAU,EAAE;EAEnC,IAAIC,sBAAsB,CAAQN,IAAI,EAAEC,MAAM,EAAEG,KAAK,EAAED,YAAY,CAAC,EAAE;IAClE,OAAO,QAAQ;GAClB,MAAM,IAAII,sBAAsB,CAAQP,IAAI,EAAEC,MAAM,CAAC,EAAE;IACpD,OAAO,QAAQ;GAClB,MAAM,IAAIO,uBAAuB,CAAQR,IAAI,EAAEC,MAAM,EA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OA,UAAU,IAAIC,UAAU,GAAG,CAAC,GAAGD,UAAU,GAAGL,aAAa,GAAG,CAACA,aAAa;;;IAIzF,OAAOF,MAAM,CAACF,IAAI,EAAEC,IAAI,EAAEpC,IAAI,CAACkB,MAAM,CAACC,EAAE,CAAC;GAC5C,CAAC;EAEF,IAAInB,IAAI,CAACkB,MAAM,CAACM,WAAW,EAAE,KAAK,MAAM,EAAE;IACtCS,YAAY,CAACa,OAAO,EAAE;;EAG1B,OAAO,EAAAC,mBAAA,GAAAd,YAAY,CAACJ,KAAK,CAAC,cAAAkB,mBAAA,uBAAnBA,mBAAA,CAAqB5B,EAAE,MAAKnB,IAAI,CAACgB,GAAG,CAACG,EAAE;AAClD;MAEa6B,uBAAuB,GAAG;SAEvBC,cAAcA,CAACC,KAAa;EACxC,IAAIA,KAAK,KAAKzC,SAAS,EAAE;IACrB,OAAO,KAAK;;EAGhB,OAAO0C,MAAM,CAACD,KAAK,CAAC,CAACE,UAAU,CAACJ,uBAAuB,CAAC;AAC5D;MAEaK,QAAQ,GAAG;EAAEC,GAAG,EAAE,GAAG;EAAEC,IAAI,EAAE,IAAI;EAAEC,KAAK,EAAE;;;;;"}
@@ -36,8 +36,6 @@ function TableGrid(props) {
36
36
  table.meta.rowActive.handleFocus(event, table.meta.length, table.renderer.scrollToIndex);
37
37
  } : undefined;
38
38
  const filterReason = getFilterReason(table);
39
- const searchNotApplied = !table.state.globalFilter || table.state.globalFilter === '';
40
- const filtersNotApplied = !table.state.columnFilters || table.state.columnFilters.length === 0;
41
39
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("style", null, table.stylesheet), /*#__PURE__*/React__default.createElement(FocusScope, null, /*#__PURE__*/React__default.createElement("table", Object.assign({}, attributes, {
42
40
  id: table.id,
43
41
  "data-table-font-size": table.meta.fontSize.size,
@@ -70,7 +68,7 @@ function TableGrid(props) {
70
68
  ...table.renderer.style,
71
69
  height: table.renderer.style.height + ROW_HEIGHT_ESTIMATES[table.meta.rowHeight.height]
72
70
  } : table.renderer.style
73
- }, table.renderer.rows, searchNotApplied && filtersNotApplied && props.children), table.meta.footer.isEnabled ? /*#__PURE__*/React__default.createElement(Foot, {
71
+ }, table.renderer.rows, props.children), table.meta.footer.isEnabled ? /*#__PURE__*/React__default.createElement(Foot, {
74
72
  table: table.instance
75
73
  }) : null)))));
76
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Table.js","sources":["../../../../../../../../src/primitives/Table/Core/Table.tsx"],"sourcesContent":["import React from 'react';\nimport { FocusScope } from '@react-aria/focus';\nimport { Header } from './components/Header/Header';\nimport { Body } from './components/Body/Body';\nimport { Foot } from './components/Footer/Footer';\nimport { EmptyStateBody } from './components/Body/EmptyStateBody';\nimport { useTableReturnValue } from './useTable';\nimport { TableToolbar } from './components/Toolbar/Toolbar';\nimport './style.css';\nimport { TableEmptyStateReason } from '../types';\nimport { ROW_HEIGHT_ESTIMATES } from './util/rows';\n\ntype TableProps = {\n children: JSX.Element | Array<JSX.Element | null>;\n};\n\nexport function Table(props: TableProps) {\n return <>{props.children}</>;\n}\nTable.Toolbar = TableToolbar;\nTable.Grid = TableGrid;\n\nexport type TableGridProps<TType = unknown> = React.TableHTMLAttributes<HTMLTableElement> & {\n 'data-taco': string;\n enableHorizontalArrowKeyNavigation?: boolean;\n table: useTableReturnValue<TType>;\n};\n\nfunction getFilterReason<TType = unknown>(table: useTableReturnValue<TType>): TableEmptyStateReason | null {\n if (table.instance.getFilteredRowModel().rows.length === 0 && table.instance.getCoreRowModel().rows.length !== 0) {\n const state = table.instance.getState();\n\n if (table.meta.search.enableGlobalFilter && !!state.globalFilter) {\n return 'searching';\n }\n\n return 'filtering';\n }\n if (table.instance.getCoreRowModel().rows.length === 0) {\n return 'empty';\n }\n\n return null;\n}\n\nexport function TableGrid<TType = unknown>(props: TableGridProps<TType>) {\n const { enableHorizontalArrowKeyNavigation, table, ...attributes } = props;\n const handleFocus =\n table.meta.rowActive.rowActiveIndex === undefined\n ? (event: React.FocusEvent) => {\n table.meta.rowActive.handleFocus(event, table.meta.length, table.renderer.scrollToIndex);\n }\n : undefined;\n const filterReason = getFilterReason(table);\n\n const searchNotApplied = !table.state.globalFilter || table.state.globalFilter === '';\n const filtersNotApplied = !table.state.columnFilters || table.state.columnFilters.length === 0;\n\n return (\n <>\n <style>{table.stylesheet}</style>\n <FocusScope>\n <table\n {...attributes}\n id={table.id}\n data-table-font-size={table.meta.fontSize.size}\n data-table-grouped={!!table.state.grouping?.length}\n data-table-horizontally-scrolled={table.meta.columnFreezing.isHorizontallyScrolled ? true : undefined}\n data-table-status={table.meta.server.isEnabled ? (table.meta.server.isReady ? 'ready' : undefined) : 'ready'}\n data-table-pause-hover={table.meta.rowActive.isHoverStatePaused ? true : undefined}\n data-table-resizing={table.state.columnSizingInfo.isResizingColumn ? true : undefined}\n data-table-row-height={table.meta.rowHeight.height}\n onFocus={handleFocus}\n onScroll={table.meta.columnFreezing.handleScroll}\n ref={table.ref}\n style={table.style}\n tabIndex={-1}>\n <thead>\n {table.instance.getHeaderGroups().map(headerGroup => (\n <tr key={headerGroup.id}>\n {headerGroup.headers.map(props => (\n <Header key={props.id} header={props} scrollToIndex={table.renderer.scrollToIndex} />\n ))}\n </tr>\n ))}\n </thead>\n {filterReason ? (\n <EmptyStateBody emptyState={props.table.props.emptyState} reason={filterReason} />\n ) : (\n <>\n <Body\n enableHorizontalArrowKeyNavigation={enableHorizontalArrowKeyNavigation}\n table={table.instance}\n tableElement={table.ref.current}\n scrollToIndex={table.renderer.scrollToIndex}\n style={\n props.children\n ? {\n ...table.renderer.style,\n height:\n (table.renderer.style.height as number) +\n ROW_HEIGHT_ESTIMATES[table.meta.rowHeight.height],\n }\n : table.renderer.style\n }>\n {table.renderer.rows}\n {searchNotApplied && filtersNotApplied && props.children}\n </Body>\n {table.meta.footer.isEnabled ? <Foot table={table.instance} /> : null}\n </>\n )}\n </table>\n </FocusScope>\n </>\n );\n}\n"],"names":["Table","props","React","children","Toolbar","TableToolbar","Grid","TableGrid","getFilterReason","table","instance","getFilteredRowModel","rows","length","getCoreRowModel","state","getState","meta","search","enableGlobalFilter","globalFilter","enableHorizontalArrowKeyNavigation","attributes","handleFocus","rowActive","rowActiveIndex","undefined","event","renderer","scrollToIndex","filterReason","searchNotApplied","filtersNotApplied","columnFilters","stylesheet","FocusScope","id","fontSize","size","_table$state$grouping","grouping","columnFreezing","isHorizontallyScrolled","server","isEnabled","isReady","isHoverStatePaused","columnSizingInfo","isResizingColumn","rowHeight","height","onFocus","onScroll","handleScroll","ref","style","tabIndex","getHeaderGroups","map","headerGroup","key","headers","Header","header","EmptyStateBody","emptyState","reason","Body","tableElement","current","ROW_HEIGHT_ESTIMATES","footer","Foot"],"mappings":";;;;;;;;;SAgBgBA,KAAKA,CAACC,KAAiB;EACnC,oBAAOC,4DAAGD,KAAK,CAACE,QAAQ,CAAI;AAChC;AACAH,KAAK,CAACI,OAAO,GAAGC,YAAY;AAC5BL,KAAK,CAACM,IAAI,GAAGC,SAAS;AAQtB,SAASC,eAAeA,CAAkBC,KAAiC;EACvE,IAAIA,KAAK,CAACC,QAAQ,CAACC,mBAAmB,EAAE,CAACC,IAAI,CAACC,MAAM,KAAK,CAAC,IAAIJ,KAAK,CAACC,QAAQ,CAACI,eAAe,EAAE,CAACF,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;IAC9G,MAAME,KAAK,GAAGN,KAAK,CAACC,QAAQ,CAACM,QAAQ,EAAE;IAEvC,IAAIP,KAAK,CAACQ,IAAI,CAACC,MAAM,CAACC,kBAAkB,IAAI,CAAC,CAACJ,KAAK,CAACK,YAAY,EAAE;MAC9D,OAAO,WAAW;;IAGtB,OAAO,WAAW;;EAEtB,IAAIX,KAAK,CAACC,QAAQ,CAACI,eAAe,EAAE,CAACF,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;IACpD,OAAO,OAAO;;EAGlB,OAAO,IAAI;AACf;SAEgBN,SAASA,CAAkBN,KAA4B;;EACnE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AACL,MAAiB,GACvCoB,oBAAoB,CAAC7D,KAAK,CAACQ,IAAI,CAACgC,SAAS,CAACC,MAAM;KACvD,GACDzC,KAAK,CAACmB,QAAQ,CAAC2B;KAExB9C,KAAK,CAACmB,QAAQ,CAAChB,IAAI,EACnBmB,gBAAgB,IAAIC,iBAAiB,IAAI/B,KAAK,CAACE,QAAQ,CACrD,EACNM,KAAK,CAACQ,IAAI,CAACsD,MAAM,CAAC3B,SAAS,gBAAG1C,6BAACsE,IAAI;IAAC/D,KAAK,EAAEA,KAAK,CAACC;IAAY,GAAG,IAAI,CACtE,CACN,CACG,CACC,CACd;AAEX;;;;"}
1
+ {"version":3,"file":"Table.js","sources":["../../../../../../../../src/primitives/Table/Core/Table.tsx"],"sourcesContent":["import React from 'react';\nimport { FocusScope } from '@react-aria/focus';\nimport { Header } from './components/Header/Header';\nimport { Body } from './components/Body/Body';\nimport { Foot } from './components/Footer/Footer';\nimport { EmptyStateBody } from './components/Body/EmptyStateBody';\nimport { useTableReturnValue } from './useTable';\nimport { TableToolbar } from './components/Toolbar/Toolbar';\nimport { TableEmptyStateReason } from '../types';\nimport { ROW_HEIGHT_ESTIMATES } from './util/rows';\nimport './style.css';\n\ntype TableProps = {\n children: JSX.Element | Array<JSX.Element | null>;\n};\n\nexport function Table(props: TableProps) {\n return <>{props.children}</>;\n}\nTable.Toolbar = TableToolbar;\nTable.Grid = TableGrid;\n\nexport type TableGridProps<TType = unknown> = React.TableHTMLAttributes<HTMLTableElement> & {\n 'data-taco': string;\n enableHorizontalArrowKeyNavigation?: boolean;\n table: useTableReturnValue<TType>;\n};\n\nfunction getFilterReason<TType = unknown>(table: useTableReturnValue<TType>): TableEmptyStateReason | null {\n if (table.instance.getFilteredRowModel().rows.length === 0 && table.instance.getCoreRowModel().rows.length !== 0) {\n const state = table.instance.getState();\n\n if (table.meta.search.enableGlobalFilter && !!state.globalFilter) {\n return 'searching';\n }\n\n return 'filtering';\n }\n if (table.instance.getCoreRowModel().rows.length === 0) {\n return 'empty';\n }\n\n return null;\n}\n\nexport function TableGrid<TType = unknown>(props: TableGridProps<TType>) {\n const { enableHorizontalArrowKeyNavigation, table, ...attributes } = props;\n const handleFocus =\n table.meta.rowActive.rowActiveIndex === undefined\n ? (event: React.FocusEvent) => {\n table.meta.rowActive.handleFocus(event, table.meta.length, table.renderer.scrollToIndex);\n }\n : undefined;\n const filterReason = getFilterReason(table);\n\n return (\n <>\n <style>{table.stylesheet}</style>\n <FocusScope>\n <table\n {...attributes}\n id={table.id}\n data-table-font-size={table.meta.fontSize.size}\n data-table-grouped={!!table.state.grouping?.length}\n data-table-horizontally-scrolled={table.meta.columnFreezing.isHorizontallyScrolled ? true : undefined}\n data-table-status={table.meta.server.isEnabled ? (table.meta.server.isReady ? 'ready' : undefined) : 'ready'}\n data-table-pause-hover={table.meta.rowActive.isHoverStatePaused ? true : undefined}\n data-table-resizing={table.state.columnSizingInfo.isResizingColumn ? true : undefined}\n data-table-row-height={table.meta.rowHeight.height}\n onFocus={handleFocus}\n onScroll={table.meta.columnFreezing.handleScroll}\n ref={table.ref}\n style={table.style}\n tabIndex={-1}>\n <thead>\n {table.instance.getHeaderGroups().map(headerGroup => (\n <tr key={headerGroup.id}>\n {headerGroup.headers.map(props => (\n <Header key={props.id} header={props} scrollToIndex={table.renderer.scrollToIndex} />\n ))}\n </tr>\n ))}\n </thead>\n {filterReason ? (\n <EmptyStateBody emptyState={props.table.props.emptyState} reason={filterReason} />\n ) : (\n <>\n <Body\n enableHorizontalArrowKeyNavigation={enableHorizontalArrowKeyNavigation}\n table={table.instance}\n tableElement={table.ref.current}\n scrollToIndex={table.renderer.scrollToIndex}\n style={\n props.children\n ? {\n ...table.renderer.style,\n height:\n (table.renderer.style.height as number) +\n ROW_HEIGHT_ESTIMATES[table.meta.rowHeight.height],\n }\n : table.renderer.style\n }>\n {table.renderer.rows}\n {props.children}\n </Body>\n {table.meta.footer.isEnabled ? <Foot table={table.instance} /> : null}\n </>\n )}\n </table>\n </FocusScope>\n </>\n );\n}\n"],"names":["Table","props","React","children","Toolbar","TableToolbar","Grid","TableGrid","getFilterReason","table","instance","getFilteredRowModel","rows","length","getCoreRowModel","state","getState","meta","search","enableGlobalFilter","globalFilter","enableHorizontalArrowKeyNavigation","attributes","handleFocus","rowActive","rowActiveIndex","undefined","event","renderer","scrollToIndex","filterReason","stylesheet","FocusScope","id","fontSize","size","_table$state$grouping","grouping","columnFreezing","isHorizontallyScrolled","server","isEnabled","isReady","isHoverStatePaused","columnSizingInfo","isResizingColumn","rowHeight","height","onFocus","onScroll","handleScroll","ref","style","tabIndex","getHeaderGroups","map","headerGroup","key","headers","Header","header","EmptyStateBody","emptyState","reason","Body","tableElement","current","ROW_HEIGHT_ESTIMATES","footer","Foot"],"mappings":";;;;;;;;;SAgBgBA,KAAKA,CAACC,KAAiB;EACnC,oBAAOC,4DAAGD,KAAK,CAACE,QAAQ,CAAI;AAChC;AACAH,KAAK,CAACI,OAAO,GAAGC,YAAY;AAC5BL,KAAK,CAACM,IAAI,GAAGC,SAAS;AAQtB,SAASC,eAAeA,CAAkBC,KAAiC;EACvE,IAAIA,KAAK,CAACC,QAAQ,CAACC,mBAAmB,EAAE,CAACC,IAAI,CAACC,MAAM,KAAK,CAAC,IAAIJ,KAAK,CAACC,QAAQ,CAACI,eAAe,EAAE,CAACF,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;IAC9G,MAAME,KAAK,GAAGN,KAAK,CAACC,QAAQ,CAACM,QAAQ,EAAE;IAEvC,IAAIP,KAAK,CAACQ,IAAI,CAACC,MAAM,CAACC,kBAAkB,IAAI,CAAC,CAACJ,KAAK,CAACK,YAAY,EAAE;MAC9D,OAAO,WAAW;;IAGtB,OAAO,WAAW;;EAEtB,IAAIX,KAAK,CAACC,QAAQ,CAACI,eAAe,EAAE,CAACF,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;IACpD,OAAO,OAAO;;EAGlB,OAAO,IAAI;AACf;SAEgBN,SAASA,CAAkBN,KAA4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,SAAS,gBAAGvC,6BAACmE,IAAI;IAAC5D,KAAK,EAAEA,KAAK,CAACC;IAAY,GAAG,IAAI,CACtE,CACN,CACG,CACC,CACd;AAEX;;;;"}
@@ -12,7 +12,10 @@ function GroupedCell(props) {
12
12
  index,
13
13
  isHighlighted
14
14
  } = props;
15
- const tableMeta = cell.getContext().table.options.meta;
15
+ const {
16
+ table
17
+ } = cell.getContext();
18
+ const tableMeta = table.options.meta;
16
19
  const columnMeta = cell.column.columnDef.meta;
17
20
  const attributes = getCellAttributes(cell, index, isHighlighted);
18
21
  const {
@@ -30,7 +33,8 @@ function GroupedCell(props) {
30
33
  colSpan: colSpan,
31
34
  rowActions: tableMeta.rowGroups.rowActionsForGroup,
32
35
  rowId: cell.row.id,
33
- subRows: subRows
36
+ subRows: subRows,
37
+ table: table
34
38
  }), content);
35
39
  }
36
40
  const MemoedGroupedCell = /*#__PURE__*/React__default.memo(function MemoedGroupedCell(props) {
@@ -42,6 +46,7 @@ const MemoedGroupedCell = /*#__PURE__*/React__default.memo(function MemoedGroupe
42
46
  rowActions,
43
47
  rowId,
44
48
  subRows,
49
+ table,
45
50
  ...attributes
46
51
  } = props;
47
52
  return /*#__PURE__*/React__default.createElement("td", Object.assign({}, attributes, {
@@ -56,7 +61,8 @@ const MemoedGroupedCell = /*#__PURE__*/React__default.memo(function MemoedGroupe
56
61
  actionsLength: 4,
57
62
  data: subRows,
58
63
  isActiveRow: true,
59
- rowId: rowId
64
+ rowId: rowId,
65
+ table: table
60
66
  })) : null);
61
67
  });
62
68
 
@@ -1 +1 @@
1
- {"version":3,"file":"GroupedCell.js","sources":["../../../../../../../../../../../../src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta, ColumnMeta as ReactTableColumnMeta } from '@tanstack/react-table';\nimport { getCellAttributes } from '../util';\nimport { Actions as RowGroupActions } from '../../Internal/Actions';\nimport { isInternalColumn } from '../../../../../useTableManager/util/columns';\nimport { RowContext } from '../../../Row/RowContext';\nimport { TableRowActionGroupRenderer } from '../../../../../types';\nimport { TableCellRendererProps } from '../../../../types';\n\nexport function GroupedCell<TType = unknown>(props: TableCellRendererProps<TType>) {\n const { cell, cellRef, index, isHighlighted } = props;\n const tableMeta = cell.getContext().table.options.meta as ReactTableMeta<TType>;\n const columnMeta = cell.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n const attributes = getCellAttributes(cell, index, isHighlighted);\n\n const { isHovered, rowIndex } = React.useContext(RowContext);\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;\n const canShowActions = isActiveRow || (isHovered && !tableMeta.rowActive.isHoverStatePaused);\n\n const colSpan = cell.row.getVisibleCells().filter(c => !isInternalColumn(c.column.id)).length - 1;\n const content = columnMeta.renderer?.(cell.getValue<TType>(), cell.row.original) ?? cell.getValue() ?? null;\n const subRows = cell.getContext().row.subRows.map(row => row.original);\n\n return (\n <MemoedGroupedCell<TType>\n {...attributes}\n canShowActions={canShowActions}\n cellRef={cellRef}\n colSpan={colSpan}\n rowActions={tableMeta.rowGroups.rowActionsForGroup}\n rowId={cell.row.id}\n subRows={subRows}>\n {content}\n </MemoedGroupedCell>\n );\n}\n\ntype MemoedGroupedCellProps<TType = unknown> = React.TdHTMLAttributes<HTMLTableCellElement> & {\n canShowActions: boolean;\n cellRef: React.RefObject<HTMLTableCellElement>;\n colSpan: number;\n rowActions?: TableRowActionGroupRenderer<TType>[];\n rowId: string;\n subRows: TType[];\n};\n\nconst MemoedGroupedCell = React.memo(function MemoedGroupedCell<TType = unknown>(props: MemoedGroupedCellProps<TType>) {\n const { canShowActions, cellRef, children, colSpan, rowActions, rowId, subRows, ...attributes } = props;\n\n return (\n <td {...attributes} ref={cellRef} style={{ gridColumn: `span ${colSpan} / span ${colSpan}` }}>\n <span className=\"grow\">{children}</span>\n {rowActions?.length && canShowActions ? (\n <RowGroupActions actions={rowActions} actionsLength={4} data={subRows} isActiveRow rowId={rowId} />\n ) : null}\n </td>\n );\n}) as <TType = unknown>(props: MemoedGroupedCellProps<TType>) => JSX.Element;\n"],"names":["GroupedCell","props","cell","cellRef","index","isHighlighted","tableMeta","getContext","table","options","meta","columnMeta","column","columnDef","attributes","getCellAttributes","isHovered","rowIndex","React","useContext","RowContext","isActiveRow","rowActive","rowActiveIndex","canShowActions","isHoverStatePaused","colSpan","row","getVisibleCells","filter","c","isInternalColumn","id","length","content","_ref","_columnMeta$renderer","_columnMeta$renderer2","renderer","call","getValue","original","subRows","map","MemoedGroupedCell","rowActions","rowGroups","rowActionsForGroup","rowId","memo","children","ref","style","gridColumn","className","RowGroupActions","actions","actionsLength","data"],"mappings":";;;;;;SASgBA,WAAWA,CAAkBC,KAAoC;;EAC7E,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC,KAAK;IAAEC;GAAe,GAAGJ,KAAK;EACrD,MAAMK,SAAS,GAAGJ,IAAI,CAACK,UAAU,EAAE,CAACC,KAAK,CAACC,OAAO,CAACC,IAA6B;EAC/E,MAAMC,UAAU,GAAGT,IAAI,CAACU,MAAM,CAACC,SAAS,CAACH,IAA4C;EACrF,MAAMI,UAAU,GAAGC,iBAAiB,CAACb,IAAI,EAAEE,KAAK,EAAEC,aAAa,CAAC;EAEhE,MAAM;IAAEW,SAAS;IAAEC;GAAU,GAAGC,cAAK,CAACC,UAAU,CAACC,UAAU,CAAC;EAC5D,MAAMC,WAAW,GAAGf,SAAS,CAACgB,SAAS,CAACC,cAAc,KAAKN,QAAQ;EACnE,MAAMO,cAAc,GAAGH,WAAW,IAAKL,SAAS,IAAI,CAACV,SAAS,CAACgB,SAAS,CAACG,kBAAmB;EAE5F,MAAMC,OAAO,GAAGxB,IAAI,CAACyB,GAAG,CAACC,eAAe,EAAE,CAACC,MAAM,CAACC,CAAC,IAAI,CAACC,gBAAgB,CAACD,CAAC,CAAClB,MAAM,CAACoB,EAAE,CAAC,CAAC,CAACC,MAAM,GAAG,CAAC;EACjG,MAAMC,OA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AACqC,OAAe;IAACC,OAAO,EAAEX,UAAU;IAAEY,aAAa,EAAE,CAAC;IAAEC,IAAI,EAAEhB,OAAO;IAAErB,WAAW;IAAC2B,KAAK,EAAEA;IAAS,IACnG,IAAI,CACP;AAEb,CAAC,CAA2E;;;;"}
1
+ {"version":3,"file":"GroupedCell.js","sources":["../../../../../../../../../../../../src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta, ColumnMeta as ReactTableColumnMeta } from '@tanstack/react-table';\nimport { getCellAttributes } from '../util';\nimport { Actions as RowGroupActions } from '../../Internal/Actions';\nimport { isInternalColumn } from '../../../../../useTableManager/util/columns';\nimport { RowContext } from '../../../Row/RowContext';\nimport { TableRowActionGroupRenderer } from '../../../../../types';\nimport { TableCellRendererProps } from '../../../../types';\n\nexport function GroupedCell<TType = unknown>(props: TableCellRendererProps<TType>) {\n const { cell, cellRef, index, isHighlighted } = props;\n const { table } = cell.getContext();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const columnMeta = cell.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n const attributes = getCellAttributes(cell, index, isHighlighted);\n\n const { isHovered, rowIndex } = React.useContext(RowContext);\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;\n const canShowActions = isActiveRow || (isHovered && !tableMeta.rowActive.isHoverStatePaused);\n\n const colSpan = cell.row.getVisibleCells().filter(c => !isInternalColumn(c.column.id)).length - 1;\n const content = columnMeta.renderer?.(cell.getValue<TType>(), cell.row.original) ?? cell.getValue() ?? null;\n const subRows = cell.getContext().row.subRows.map(row => row.original);\n\n return (\n <MemoedGroupedCell<TType>\n {...attributes}\n canShowActions={canShowActions}\n cellRef={cellRef}\n colSpan={colSpan}\n rowActions={tableMeta.rowGroups.rowActionsForGroup}\n rowId={cell.row.id}\n subRows={subRows}\n table={table}>\n {content}\n </MemoedGroupedCell>\n );\n}\n\ntype MemoedGroupedCellProps<TType = unknown> = React.TdHTMLAttributes<HTMLTableCellElement> & {\n canShowActions: boolean;\n cellRef: React.RefObject<HTMLTableCellElement>;\n colSpan: number;\n rowActions?: TableRowActionGroupRenderer<TType>[];\n rowId: string;\n subRows: TType[];\n table: ReactTable<TType>;\n};\n\nconst MemoedGroupedCell = React.memo(function MemoedGroupedCell<TType = unknown>(props: MemoedGroupedCellProps<TType>) {\n const { canShowActions, cellRef, children, colSpan, rowActions, rowId, subRows, table, ...attributes } = props;\n\n return (\n <td {...attributes} ref={cellRef} style={{ gridColumn: `span ${colSpan} / span ${colSpan}` }}>\n <span className=\"grow\">{children}</span>\n {rowActions?.length && canShowActions ? (\n <RowGroupActions<TType>\n actions={rowActions as any}\n actionsLength={4}\n data={subRows}\n isActiveRow\n rowId={rowId}\n table={table}\n />\n ) : null}\n </td>\n );\n}) as <TType = unknown>(props: MemoedGroupedCellProps<TType>) => JSX.Element;\n"],"names":["GroupedCell","props","cell","cellRef","index","isHighlighted","table","getContext","tableMeta","options","meta","columnMeta","column","columnDef","attributes","getCellAttributes","isHovered","rowIndex","React","useContext","RowContext","isActiveRow","rowActive","rowActiveIndex","canShowActions","isHoverStatePaused","colSpan","row","getVisibleCells","filter","c","isInternalColumn","id","length","content","_ref","_columnMeta$renderer","_columnMeta$renderer2","renderer","call","getValue","original","subRows","map","MemoedGroupedCell","rowActions","rowGroups","rowActionsForGroup","rowId","memo","children","ref","style","gridColumn","className","RowGroupActions","actions","actionsLength","data"],"mappings":";;;;;;SASgBA,WAAWA,CAAkBC,KAAoC;;EAC7E,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC,KAAK;IAAEC;GAAe,GAAGJ,KAAK;EACrD,MAAM;IAAEK;GAAO,GAAGJ,IAAI,CAACK,UAAU,EAAE;EACnC,MAAMC,SAAS,GAAGF,KAAK,CAACG,OAAO,CAACC,IAA6B;EAC7D,MAAMC,UAAU,GAAGT,IAAI,CAACU,MAAM,CAACC,SAAS,CAAC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U,OAAO,EAAEA,OAAO;IAChBpC,KAAK,EAAEA;MACN4B,OAAO,CACQ;AAE5B;AAYA,MAAMU,iBAAiB,gBAAG1B,cAAK,CAAC+B,IAAI,CAAC,SAASL,iBAAiBA,CAAkB3C,KAAoC;EACjH,MAAM;IAAEuB,cAAc;IAAErB,OAAO;IAAE+C,QAAQ;IAAExB,OAAO;IAAEmB,UAAU;IAAEG,KAAK;IAAEN,OAAO;IAAEpC,KAAK;IAAE,GAAGQ;GAAY,GAAGb,KAAK;EAE9G,oBACIiB,qDAAQJ,UAAU;IAAEqC,GAAG,EAAEhD,OAAO;IAAEiD,KAAK,EAAE;MAAEC,UAAU,EAAE,QAAQ3B,OAAO,WAAWA,OAAO;;mBACpFR;IAAMoC,SAAS,EAAC;KAAQJ,QAAQ,CAAQ,EACvCL,UAAU,aAAVA,UAAU,eAAVA,UAAU,CAAEZ,MAAM,IAAIT,cAAc,iBACjCN,6BAACqC,OAAe;IACZC,OAAO,EAAEX,UAAiB;IAC1BY,aAAa,EAAE,CAAC;IAChBC,IAAI,EAAEhB,OAAO;IACbrB,WAAW;IACX2B,KAAK,EAAEA,KAAK;IACZ1C,KAAK,EAAEA;IACT,IACF,IAAI,CACP;AAEb,CAAC,CAA2E;;;;"}
@@ -12,12 +12,14 @@ function Actions(props) {
12
12
  actionsLength,
13
13
  data,
14
14
  isActiveRow,
15
- rowId
15
+ rowId,
16
+ table
16
17
  } = props;
17
18
  const {
18
19
  texts
19
20
  } = useLocalization();
20
- const visibleActions = actions.map(action => action(data, rowId)).filter(action => !!action);
21
+ // we don't want to document passing table, so it isn't on the type
22
+ const visibleActions = actions.map(action => action(data, rowId, table)).filter(action => !!action);
21
23
  const actionsOnRow = visibleActions.length === actionsLength ? visibleActions : visibleActions.slice(0, actionsLength - 1);
22
24
  const actionsInMenu = visibleActions.slice(visibleActions.length === actionsLength ? actionsLength : actionsLength - 1);
23
25
  const className = cn('flex justify-end text-right bg-[inherit] shadow-[-6px_0px_6px_var(--table-row-actions-shadow)] print:hidden');
@@ -57,7 +59,8 @@ const Cell = /*#__PURE__*/React__default.memo(function MemoedCell(context) {
57
59
  } = context;
58
60
  const {
59
61
  isHovered,
60
- rowIndex
62
+ rowIndex,
63
+ hideRowActions
61
64
  } = React__default.useContext(RowContext);
62
65
  const tableMeta = table.options.meta;
63
66
  const actions = tableMeta.rowActions.rowActions;
@@ -65,15 +68,14 @@ const Cell = /*#__PURE__*/React__default.memo(function MemoedCell(context) {
65
68
  const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;
66
69
  const isResizingColumn = !!table.getState().columnSizingInfo.isResizingColumn;
67
70
  const isHoverStatePaused = tableMeta.rowActive.isHoverStatePaused;
68
- // We don't want to show actions in edit mode, since we have editing actions,
69
- // which is shown in edit mode instead.
70
- if (actions !== null && actions !== void 0 && actions.length && (isActiveRow || isHovered && !isHoverStatePaused && !isResizingColumn)) {
71
+ if (!hideRowActions && actions !== null && actions !== void 0 && actions.length && (isActiveRow || isHovered && !isHoverStatePaused && !isResizingColumn)) {
71
72
  return /*#__PURE__*/React__default.createElement(Actions, {
72
73
  actions: actions,
73
74
  actionsLength: actionsLength,
74
75
  data: row.original,
75
76
  isActiveRow: isActiveRow,
76
- rowId: row.id
77
+ rowId: row.id,
78
+ table: table
77
79
  });
78
80
  }
79
81
  return null;