@economic/taco 2.44.5-create.6 → 2.44.5-create.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. package/dist/components/Provider/Localization.d.ts +0 -2
  2. package/dist/components/Report/Report.d.ts +1 -1
  3. package/dist/components/Table3/Table3.d.ts +14 -2
  4. package/dist/components/Table3/components/Columns/Internal/EditingActionsMenu.d.ts +2 -1
  5. package/dist/components/Table3/components/Row/Editing/CreateRowButton.d.ts +11 -0
  6. package/dist/components/Table3/features/useTableEditing.d.ts +36 -25
  7. package/dist/components/Table3/types.d.ts +8 -23
  8. package/dist/components/Table3/useTable3.d.ts +0 -6
  9. package/dist/components/Table3/util/editing.d.ts +1 -2
  10. package/dist/esm/index.css +4 -16
  11. package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js +2 -2
  12. package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js.map +1 -1
  13. package/dist/esm/packages/taco/src/components/Provider/Localization.js +3 -5
  14. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  15. package/dist/esm/packages/taco/src/components/Switch/Switch.js +1 -1
  16. package/dist/esm/packages/taco/src/components/Switch/Switch.js.map +1 -1
  17. package/dist/esm/packages/taco/src/components/Table3/Table3.js +7 -19
  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/EditingControlCell.js +22 -21
  20. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
  21. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js +37 -5
  22. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js.map +1 -1
  23. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +12 -17
  24. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
  25. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js +90 -0
  26. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js.map +1 -0
  27. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js +14 -2
  28. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js.map +1 -1
  29. package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js +6 -39
  30. package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js.map +1 -1
  31. package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js +2 -7
  32. package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js.map +1 -1
  33. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +406 -19
  34. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
  35. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +32 -37
  36. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
  37. package/dist/esm/packages/taco/src/components/Table3/useTable3.js +8 -25
  38. package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
  39. package/dist/esm/packages/taco/src/components/Table3/util/editing.js +24 -4
  40. package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
  41. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +4 -3
  42. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
  43. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js +3 -9
  44. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js.map +1 -1
  45. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +3 -6
  46. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
  47. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js +1 -1
  48. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
  49. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +1 -1
  50. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
  51. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.js +8 -1
  52. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.js.map +1 -1
  53. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +6 -23
  54. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  55. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js +2 -2
  56. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
  57. package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
  58. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +1 -1
  59. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
  60. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +0 -11
  61. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  62. package/dist/esm/packages/taco/src/utils/dom.js +4 -7
  63. package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
  64. package/dist/index.css +4 -16
  65. package/dist/primitives/Table/Core/Table.d.ts +0 -1
  66. package/dist/primitives/Table/Core/components/Columns/Internal/Actions.d.ts +1 -3
  67. package/dist/primitives/Table/Core/components/Footer/Footer.d.ts +2 -2
  68. package/dist/primitives/Table/Core/features/useTableRenderer.d.ts +2 -2
  69. package/dist/primitives/Table/Core/features/useTableStyle.d.ts +1 -1
  70. package/dist/primitives/Table/Core/types.d.ts +0 -3
  71. package/dist/primitives/Table/Core/useTable.d.ts +2 -2
  72. package/dist/primitives/Table/types.d.ts +2 -2
  73. package/dist/primitives/Table/useTableManager/useTableManager.d.ts +1 -1
  74. package/dist/taco.cjs.development.js +627 -904
  75. package/dist/taco.cjs.development.js.map +1 -1
  76. package/dist/taco.cjs.production.min.js +1 -1
  77. package/dist/taco.cjs.production.min.js.map +1 -1
  78. package/dist/utils/dom.d.ts +0 -1
  79. package/package.json +1 -1
  80. package/dist/components/Table3/components/Editing/DiscardChangesConfirmationDialog.d.ts +0 -7
  81. package/dist/components/Table3/components/Row/Editing/CreateNewRow.d.ts +0 -13
  82. package/dist/components/Table3/components/Row/Editing/TemporaryRow.d.ts +0 -11
  83. package/dist/components/Table3/features/useEditingState.d.ts +0 -28
  84. package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js +0 -34
  85. package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js.map +0 -1
  86. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +0 -88
  87. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js.map +0 -1
  88. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js +0 -95
  89. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js.map +0 -1
  90. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js +0 -512
  91. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js.map +0 -1
@@ -5,6 +5,7 @@ import { Tooltip } from '../../../../Tooltip/Tooltip.js';
5
5
  import { useLocalization } from '../../../../Provider/Localization.js';
6
6
  import { Spinner } from '../../../../Spinner/Spinner.js';
7
7
 
8
+ const COMPLETE_INDICATOR_DELAY = 3000;
8
9
  function SaveStatus(props) {
9
10
  const {
10
11
  rowId,
@@ -14,7 +15,18 @@ function SaveStatus(props) {
14
15
  texts
15
16
  } = useLocalization();
16
17
  const tableMeta = table.options.meta;
17
- const status = tableMeta.editing.getRowStatus(rowId);
18
+ const status = tableMeta.editing.getRowSaveStatus(rowId);
19
+ React__default.useEffect(() => {
20
+ let timeout;
21
+ if (status === 'complete') {
22
+ timeout = setTimeout(() => {
23
+ tableMeta.editing.setRowSaveStatus(rowId, undefined);
24
+ }, COMPLETE_INDICATOR_DELAY);
25
+ }
26
+ return () => {
27
+ clearTimeout(timeout);
28
+ };
29
+ }, [status]);
18
30
  const className = cn('col-span-full sticky ml-auto right-0 top-0 -mb-[100%] z-10 h-8 bg-[inherit] flex items-center px-1.5 shadow-[-6px_0px_6px_var(--table-row-actions-shadow)]', {
19
31
  'mt-0.5': tableMeta.rowHeight.height === 'short',
20
32
  'mt-1': tableMeta.rowHeight.height === 'medium',
@@ -25,7 +37,7 @@ function SaveStatus(props) {
25
37
  className: "!contents"
26
38
  }, /*#__PURE__*/React__default.createElement("span", {
27
39
  className: className
28
- }, status === 'saving' ? (/*#__PURE__*/React__default.createElement(Tooltip, {
40
+ }, status === 'pending' ? (/*#__PURE__*/React__default.createElement(Tooltip, {
29
41
  title: texts.table3.editing.saving.progress
30
42
  }, /*#__PURE__*/React__default.createElement(Spinner, {
31
43
  delay: 0,
@@ -1 +1 @@
1
- {"version":3,"file":"SaveStatus.js","sources":["../../../../../../../../../../src/components/Table3/components/Row/Editing/SaveStatus.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport clsx from 'clsx';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { BadgeIcon } from '../../../../BadgeIcon/BadgeIcon';\nimport { Spinner } from '../../../../Spinner/Spinner';\n\ntype SaveStatusProps<TType = unknown> = {\n rowId: string;\n table: ReactTable<TType>;\n};\n\nexport function SaveStatus<TType = unknown>(props: SaveStatusProps<TType>) {\n const { rowId, table } = props;\n const { texts } = useLocalization();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const status = tableMeta.editing.getRowStatus(rowId);\n\n const className = clsx(\n 'col-span-full sticky ml-auto right-0 top-0 -mb-[100%] z-10 h-8 bg-[inherit] flex items-center px-1.5 shadow-[-6px_0px_6px_var(--table-row-actions-shadow)]',\n {\n 'mt-0.5': tableMeta.rowHeight.height === 'short',\n 'mt-1': tableMeta.rowHeight.height === 'medium',\n 'mt-1.5': tableMeta.rowHeight.height === 'tall',\n 'mt-2': tableMeta.rowHeight.height === 'extra-tall',\n }\n );\n\n return (\n <td className=\"!contents\">\n <span className={className}>\n {status === 'saving' ? (\n <Tooltip title={texts.table3.editing.saving.progress}>\n <Spinner delay={0} className=\"mr-1 !h-5 !w-5\" />\n </Tooltip>\n ) : (\n <Tooltip title={texts.table3.editing.saving.complete}>\n <BadgeIcon icon=\"tick\" color=\"green\" subtle className=\"mr-1\" />\n </Tooltip>\n )}\n </span>\n </td>\n );\n}\n"],"names":["SaveStatus","props","rowId","table","texts","useLocalization","tableMeta","options","meta","status","editing","getRowStatus","className","clsx","rowHeight","height","React","Tooltip","title","table3","saving","progress","Spinner","delay","complete","BadgeIcon","icon","color","subtle"],"mappings":";;;;;;;SAagBA,UAAUA,CAAkBC,KAA6B;EACrE,MAAM;IAAEC,KAAK;IAAEC;GAAO,GAAGF,KAAK;EAC9B,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,SAAS,GAAGH,KAAK,CAACI,OAAO,CAACC,IAA6B;EAC7D,MAAMC,MAAM,GAAGH,SAAS,CAACI,OAAO,CAACC,YAAY,CAACT,KAAK,CAAC;EAEpD,MAAMU,SAAS,GAAGC,EAAI,CAClB,4JAA4J,EAC5J;IACI,QAAQ,EAAEP,SAAS,CAACQ,SAAS,CAACC,MAAM,KAAK,OAAO;IAChD,MAAM,EAAET,SAAS,CAACQ,SAAS,CAACC,MAAM,KAAK,QAAQ;IAC/C,QAAQ,EAAET,SAAS,CAACQ,SAAS,CAACC,MAAM,KAAK,MAAM;IAC/C,MAAM,EAAET,SAAS,CAACQ,SAAS,CAACC,MAAM,KAAK;GAC1C,CACJ;EAED,oBACIC;IAAIJ,SAAS,EAAC;kBACVI;IAAMJ,SAAS,EAAEA;KACZH,MAAM,KAAK,QAAQ,iBAChBO,6BAACC,OAAO;IAACC,KAAK,EAAEd,KAAK,CAACe,MAAM,CAACT,OAAO,CAACU,MAAM,CAACC;kBACxCL,6BAACM,OAAO;IAACC,KAAK,EAAE,CAAC;IAAEX,SAAS,EAAC;IAAmB,CAC1C,kBAEVI,6BAACC,OAAO;IAACC,KAAK,EAAEd,KAAK,CAACe,MAAM,CAACT,OAAO,CAACU,MAAM,CAACI;kBACxCR,6BAACS,SAAS;IAACC,IAAI,EAAC,MAAM;IAACC,KAAK,EAAC,OAAO;IAACC,MAAM;IAAChB,SAAS,EAAC;IAAS,CACzD,CACb,CACE,CACN;AAEb;;;;"}
1
+ {"version":3,"file":"SaveStatus.js","sources":["../../../../../../../../../../src/components/Table3/components/Row/Editing/SaveStatus.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport clsx from 'clsx';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { BadgeIcon } from '../../../../BadgeIcon/BadgeIcon';\nimport { Spinner } from '../../../../Spinner/Spinner';\n\nconst COMPLETE_INDICATOR_DELAY = 3000;\n\ntype SaveStatusProps<TType = unknown> = {\n rowId: string;\n table: ReactTable<TType>;\n};\n\nexport function SaveStatus<TType = unknown>(props: SaveStatusProps<TType>) {\n const { rowId, table } = props;\n const { texts } = useLocalization();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const status = tableMeta.editing.getRowSaveStatus(rowId);\n\n React.useEffect(() => {\n let timeout;\n\n if (status === 'complete') {\n timeout = setTimeout(() => {\n tableMeta.editing.setRowSaveStatus(rowId, undefined);\n }, COMPLETE_INDICATOR_DELAY);\n }\n\n return () => {\n clearTimeout(timeout);\n };\n }, [status]);\n\n const className = clsx(\n 'col-span-full sticky ml-auto right-0 top-0 -mb-[100%] z-10 h-8 bg-[inherit] flex items-center px-1.5 shadow-[-6px_0px_6px_var(--table-row-actions-shadow)]',\n {\n 'mt-0.5': tableMeta.rowHeight.height === 'short',\n 'mt-1': tableMeta.rowHeight.height === 'medium',\n 'mt-1.5': tableMeta.rowHeight.height === 'tall',\n 'mt-2': tableMeta.rowHeight.height === 'extra-tall',\n }\n );\n\n return (\n <td className=\"!contents\">\n <span className={className}>\n {status === 'pending' ? (\n <Tooltip title={texts.table3.editing.saving.progress}>\n <Spinner delay={0} className=\"mr-1 !h-5 !w-5\" />\n </Tooltip>\n ) : (\n <Tooltip title={texts.table3.editing.saving.complete}>\n <BadgeIcon icon=\"tick\" color=\"green\" subtle className=\"mr-1\" />\n </Tooltip>\n )}\n </span>\n </td>\n );\n}\n"],"names":["COMPLETE_INDICATOR_DELAY","SaveStatus","props","rowId","table","texts","useLocalization","tableMeta","options","meta","status","editing","getRowSaveStatus","React","useEffect","timeout","setTimeout","setRowSaveStatus","undefined","clearTimeout","className","clsx","rowHeight","height","Tooltip","title","table3","saving","progress","Spinner","delay","complete","BadgeIcon","icon","color","subtle"],"mappings":";;;;;;;AAQA,MAAMA,wBAAwB,GAAG,IAAI;SAOrBC,UAAUA,CAAkBC,KAA6B;EACrE,MAAM;IAAEC,KAAK;IAAEC;GAAO,GAAGF,KAAK;EAC9B,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,SAAS,GAAGH,KAAK,CAACI,OAAO,CAACC,IAA6B;EAC7D,MAAMC,MAAM,GAAGH,SAAS,CAACI,OAAO,CAACC,gBAAgB,CAACT,KAAK,CAAC;EAExDU,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIC,OAAO;IAEX,IAAIL,MAAM,KAAK,UAAU,EAAE;MACvBK,OAAO,GAAGC,UAAU,CAAC;QACjBT,SAAS,CAACI,OAAO,CAACM,gBAAgB,CAACd,KAAK,EAAEe,SAAS,CAAC;OACvD,EAAElB,wBAAwB,CAAC;;IAGhC,OAAO;MACHmB,YAAY,CAACJ,OAAO,CAAC;KACxB;GACJ,EAAE,CAACL,MAAM,CAAC,CAAC;EAEZ,MAAMU,SAAS,GAAGC,EAAI,CAClB,4JAA4J,EAC5J;IACI,QAAQ,EAAEd,SAAS,CAACe,SAAS,CAACC,MAAM,KAAK,OAAO;IAChD,MAAM,EAAEhB,SAAS,CAACe,SAAS,CAACC,MAAM,KAAK,QAAQ;IAC/C,QAAQ,EAAEhB,SAAS,CAACe,SAAS,CAACC,MAAM,KAAK,MAAM;IAC/C,MAAM,EAAEhB,SAAS,CAACe,SAAS,CAACC,MAAM,KAAK;GAC1C,CACJ;EAED,oBACIV;IAAIO,SAAS,EAAC;kBACVP;IAAMO,SAAS,EAAEA;KACZV,MAAM,KAAK,SAAS,iBACjBG,6BAACW,OAAO;IAACC,KAAK,EAAEpB,KAAK,CAACqB,MAAM,CAACf,OAAO,CAACgB,MAAM,CAACC;kBACxCf,6BAACgB,OAAO;IAACC,KAAK,EAAE,CAAC;IAAEV,SAAS,EAAC;IAAmB,CAC1C,kBAEVP,6BAACW,OAAO;IAACC,KAAK,EAAEpB,KAAK,CAACqB,MAAM,CAACf,OAAO,CAACgB,MAAM,CAACI;kBACxClB,6BAACmB,SAAS;IAACC,IAAI,EAAC,MAAM;IAACC,KAAK,EAAC,OAAO;IAACC,MAAM;IAACf,SAAS,EAAC;IAAS,CACzD,CACb,CACE,CACN;AAEb;;;;"}
@@ -1,9 +1,7 @@
1
1
  import React__default from 'react';
2
- import { setDataFocusAttribute, isElementTriggeredFromContainer } from '../../../../utils/dom.js';
2
+ import { setDataFocusAttribute } from '../../../../utils/dom.js';
3
3
  import { DisplayRow } from '../../../../primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js';
4
4
  import { useAugmentedFocusManager } from '../../../../primitives/Table/Core/components/Body/util.js';
5
- import { isTemporaryRow } from '../../util/editing.js';
6
- import { DiscardChangesConfirmationDialog } from '../Editing/DiscardChangesConfirmationDialog.js';
7
5
  import { SaveStatus } from './Editing/SaveStatus.js';
8
6
 
9
7
  function Row(props) {
@@ -29,46 +27,15 @@ function Row(props) {
29
27
  }
30
28
  }
31
29
  }, [tableMeta.editing.isEditing, isActiveRow]);
32
- const rowStatus = tableMeta.editing.getRowStatus(row.id);
33
- // discard new row
34
- const [showDiscardDialog, setShowDiscardDialog] = React__default.useState(false);
35
- function handleDiscard() {
36
- tableMeta.editing.discardChanges(row.id, table);
37
- requestAnimationFrame(() => {
38
- if (isTemporaryRow(row.id)) {
39
- var _tableMeta$editing$cr;
40
- (_tableMeta$editing$cr = tableMeta.editing.createRowButtonRef.current) === null || _tableMeta$editing$cr === void 0 ? void 0 : _tableMeta$editing$cr.focus();
41
- } else {
42
- focusManager.focusFirst();
43
- }
44
- });
45
- }
46
- function handleKeyDown(event) {
47
- if (props.onKeyDown) {
48
- props.onKeyDown(event);
49
- }
50
- if (event.isDefaultPrevented() || event.isPropagationStopped()) {
51
- return;
52
- }
53
- if (event.key === 'Escape' && tableMeta.editing.hasChanges(row.id) && !isElementTriggeredFromContainer(event.target, event.currentTarget)) {
54
- event.preventDefault();
55
- setShowDiscardDialog(true);
56
- }
57
- }
58
30
  const attributes = {
59
- 'data-row-editing-invalid': tableMeta.editing.hasRowErrors(row.id) ? !tableMeta.editing.hasRowErrorsShownInAlert(row.id) ? 'unseen' : true : undefined,
60
- 'data-row-editing-status': rowStatus,
61
- onFocus: handleFocus,
62
- onKeyDown: handleKeyDown
31
+ 'data-row-editing-invalid': tableMeta.editing.isEnabled && tableMeta.editing.hasRowErrors(row.id) ? !tableMeta.editing.hasRowErrorsSeen(row.id) ? 'unseen' : true : undefined,
32
+ 'data-row-editing-status': tableMeta.editing.isEnabled && tableMeta.editing.getRowSaveStatus(row.id) ? tableMeta.editing.getRowSaveStatus(row.id) : undefined,
33
+ onFocus: handleFocus
63
34
  };
64
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(DisplayRow, Object.assign({}, props, attributes), rowStatus === 'saving' || rowStatus === 'saved' ? /*#__PURE__*/React__default.createElement(SaveStatus, {
35
+ return /*#__PURE__*/React__default.createElement(DisplayRow, Object.assign({}, props, attributes), tableMeta.editing.getRowSaveStatus(row.id) ? /*#__PURE__*/React__default.createElement(SaveStatus, {
65
36
  rowId: row.id,
66
37
  table: table
67
- }) : null), /*#__PURE__*/React__default.createElement(DiscardChangesConfirmationDialog, {
68
- open: showDiscardDialog,
69
- onChange: setShowDiscardDialog,
70
- onDiscard: handleDiscard
71
- }));
38
+ }) : null);
72
39
  }
73
40
 
74
41
  export { Row };
@@ -1 +1 @@
1
- {"version":3,"file":"Row.js","sources":["../../../../../../../../../src/components/Table3/components/Row/Row.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { DisplayRow, DisplayRowProps } from '../../../../primitives/Table/Core/components/Row/BuiltIns/DisplayRow';\nimport { SaveStatus } from './Editing/SaveStatus';\nimport { useAugmentedFocusManager } from '../../../../primitives/Table/Core/components/Body/util';\nimport { isElementTriggeredFromContainer, setDataFocusAttribute } from '../../../../utils/dom';\nimport { DiscardChangesConfirmationDialog } from '../Editing/DiscardChangesConfirmationDialog';\nimport { isTemporaryRow } from '../../util/editing';\n\nexport function Row<TType = unknown>(props: DisplayRowProps<TType>) {\n const { row, index, table } = props;\n const focusManager = useAugmentedFocusManager();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === index;\n\n React.useEffect(() => {\n if (tableMeta.editing.isEditing && isActiveRow && tableMeta.editing.lastFocusedCellIndex === undefined) {\n setDataFocusAttribute(focusManager.focusFirst());\n }\n }, [tableMeta.editing.isEditing, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.lastFocusedCellIndex]);\n\n const handleFocus = React.useCallback(\n (event: React.FocusEvent<HTMLTableRowElement>) => {\n if (tableMeta.editing.isEditing) {\n const cellIndex = Number(event.target.closest('td')?.getAttribute('data-cell-index') ?? undefined);\n\n if (!isNaN(cellIndex)) {\n tableMeta.editing.setLastFocusedCellIndex(Number(cellIndex));\n }\n }\n },\n [tableMeta.editing.isEditing, isActiveRow]\n );\n\n const rowStatus = tableMeta.editing.getRowStatus(row.id);\n\n // discard new row\n const [showDiscardDialog, setShowDiscardDialog] = React.useState(false);\n\n function handleDiscard() {\n tableMeta.editing.discardChanges(row.id, table);\n requestAnimationFrame(() => {\n if (isTemporaryRow(row.id)) {\n tableMeta.editing.createRowButtonRef.current?.focus();\n } else {\n focusManager.focusFirst();\n }\n });\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLTableRowElement>) {\n if (props.onKeyDown) {\n props.onKeyDown(event);\n }\n\n if (event.isDefaultPrevented() || event.isPropagationStopped()) {\n return;\n }\n\n if (\n event.key === 'Escape' &&\n tableMeta.editing.hasChanges(row.id) &&\n !isElementTriggeredFromContainer(event.target as HTMLElement, event.currentTarget)\n ) {\n event.preventDefault();\n setShowDiscardDialog(true);\n }\n }\n\n const attributes = {\n 'data-row-editing-invalid': tableMeta.editing.hasRowErrors(row.id)\n ? !tableMeta.editing.hasRowErrorsShownInAlert(row.id)\n ? 'unseen'\n : true\n : undefined,\n 'data-row-editing-status': rowStatus,\n onFocus: handleFocus,\n onKeyDown: handleKeyDown,\n };\n\n return (\n <>\n <DisplayRow<TType> {...props} {...attributes}>\n {rowStatus === 'saving' || rowStatus === 'saved' ? <SaveStatus rowId={row.id} table={table} /> : null}\n </DisplayRow>\n <DiscardChangesConfirmationDialog\n open={showDiscardDialog}\n onChange={setShowDiscardDialog}\n onDiscard={handleDiscard}\n />\n </>\n );\n}\n"],"names":["Row","props","row","index","table","focusManager","useAugmentedFocusManager","tableMeta","options","meta","isActiveRow","rowActive","rowActiveIndex","React","useEffect","editing","isEditing","lastFocusedCellIndex","undefined","setDataFocusAttribute","focusFirst","handleFocus","useCallback","event","_event$target$closest","_event$target$closest2","cellIndex","Number","target","closest","getAttribute","isNaN","setLastFocusedCellIndex","rowStatus","getRowStatus","id","showDiscardDialog","setShowDiscardDialog","useState","handleDiscard","discardChanges","requestAnimationFrame","isTemporaryRow","_tableMeta$editing$cr","createRowButtonRef","current","focus","handleKeyDown","onKeyDown","isDefaultPrevented","isPropagationStopped","key","hasChanges","isElementTriggeredFromContainer","currentTarget","preventDefault","attributes","hasRowErrors","hasRowErrorsShownInAlert","onFocus","DisplayRow","SaveStatus","rowId","DiscardChangesConfirmationDialog","open","onChange","onDiscard"],"mappings":"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"}
1
+ {"version":3,"file":"Row.js","sources":["../../../../../../../../../src/components/Table3/components/Row/Row.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { DisplayRow, DisplayRowProps } from '../../../../primitives/Table/Core/components/Row/BuiltIns/DisplayRow';\nimport { SaveStatus } from './Editing/SaveStatus';\nimport { useAugmentedFocusManager } from '../../../../primitives/Table/Core/components/Body/util';\nimport { setDataFocusAttribute } from '../../../../utils/dom';\n\nexport function Row<TType = unknown>(props: DisplayRowProps<TType>) {\n const { row, index, table } = props;\n const focusManager = useAugmentedFocusManager();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === index;\n\n React.useEffect(() => {\n if (tableMeta.editing.isEditing && isActiveRow && tableMeta.editing.lastFocusedCellIndex === undefined) {\n setDataFocusAttribute(focusManager.focusFirst());\n }\n }, [tableMeta.editing.isEditing, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.lastFocusedCellIndex]);\n\n const handleFocus = React.useCallback(\n (event: React.FocusEvent<HTMLTableRowElement>) => {\n if (tableMeta.editing.isEditing) {\n const cellIndex = Number(event.target.closest('td')?.getAttribute('data-cell-index') ?? undefined);\n\n if (!isNaN(cellIndex)) {\n tableMeta.editing.setLastFocusedCellIndex(Number(cellIndex));\n }\n }\n },\n [tableMeta.editing.isEditing, isActiveRow]\n );\n\n const attributes = {\n 'data-row-editing-invalid':\n tableMeta.editing.isEnabled && tableMeta.editing.hasRowErrors(row.id)\n ? !tableMeta.editing.hasRowErrorsSeen(row.id)\n ? 'unseen'\n : true\n : undefined,\n 'data-row-editing-status':\n tableMeta.editing.isEnabled && tableMeta.editing.getRowSaveStatus(row.id)\n ? tableMeta.editing.getRowSaveStatus(row.id)\n : undefined,\n onFocus: handleFocus,\n };\n\n return (\n <DisplayRow<TType> {...props} {...attributes}>\n {tableMeta.editing.getRowSaveStatus(row.id) ? <SaveStatus rowId={row.id} table={table} /> : null}\n </DisplayRow>\n );\n}\n"],"names":["Row","props","row","index","table","focusManager","useAugmentedFocusManager","tableMeta","options","meta","isActiveRow","rowActive","rowActiveIndex","React","useEffect","editing","isEditing","lastFocusedCellIndex","undefined","setDataFocusAttribute","focusFirst","handleFocus","useCallback","event","_event$target$closest","_event$target$closest2","cellIndex","Number","target","closest","getAttribute","isNaN","setLastFocusedCellIndex","attributes","isEnabled","hasRowErrors","id","hasRowErrorsSeen","getRowSaveStatus","onFocus","DisplayRow","SaveStatus","rowId"],"mappings":";;;;;;SAOgBA,GAAGA,CAAkBC,KAA6B;EAC9D,MAAM;IAAEC,GAAG;IAAEC,KAAK;IAAEC;GAAO,GAAGH,KAAK;EACnC,MAAMI,YAAY,GAAGC,wBAAwB,EAAE;EAC/C,MAAMC,SAAS,GAAGH,KAAK,CAACI,OAAO,CAACC,IAA6B;EAC7D,MAAMC,WAAW,GAAGH,SAAS,CAACI,SAAS,CAACC,cAAc,KAAKT,KAAK;EAEhEU,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIP,SAAS,CAACQ,OAAO,CAACC,SAAS,IAAIN,WAAW,IAAIH,SAAS,CAACQ,OAAO,CAACE,oBAAoB,KAAKC,SAAS,EAAE;MACpGC,qBAAqB,CAACd,YAAY,CAACe,UAAU,EAAE,CAAC;;GAEvD,EAAE,CAACb,SAAS,CAACQ,OAAO,CAACC,SAAS,EAAET,SAAS,CAACI,SAAS,CAACC,cAAc,EAAEL,SAAS,CAACQ,OAAO,CAACE,oBAAoB,CAAC,CAAC;EAE7G,MAAMI,WAAW,GAAGR,cAAK,CAACS,WAAW,CAChCC,KAA4C;IACzC,IAAIhB,SAAS,CAACQ,OAAO,CAACC,SAAS,EAAE;MAAA,IAAAQ,qBAAA,EAAAC,sBAAA;MAC7B,MAAMC,SAAS,GAAGC,MAAM,EAAAH,qBAAA,IAAAC,sBAAA,GAACF,KAAK,CAACK,MAAM,CAACC,OAAO,CAAC,IAAI,CAAC,cAAAJ,sBAAA,uBAA1BA,sBAAA,CAA4BK,YAAY,CAAC,iBAAiB,CAAC,cAAAN,qBAAA,cAAAA,qBAAA,GAAIN,SAAS,CAAC;MAElG,IAAI,CAACa,KAAK,CAACL,SAAS,CAAC,EAAE;QACnBnB,SAAS,CAACQ,OAAO,CAACiB,uBAAuB,CAACL,MAAM,CAACD,SAAS,CAAC,CAAC;;;GAGvE,EACD,CAACnB,SAAS,CAACQ,OAAO,CAACC,SAAS,EAAEN,WAAW,CAAC,CAC7C;EAED,MAAMuB,UAAU,GAAG;IACf,0BAA0B,EACtB1B,SAAS,CAACQ,OAAO,CAACmB,SAAS,IAAI3B,SAAS,CAACQ,OAAO,CAACoB,YAAY,CAACjC,GAAG,CAACkC,EAAE,CAAC,GAC/D,CAAC7B,SAAS,CAACQ,OAAO,CAACsB,gBAAgB,CAACnC,GAAG,CAACkC,EAAE,CAAC,GACvC,QAAQ,GACR,IAAI,GACRlB,SAAS;IACnB,yBAAyB,EACrBX,SAAS,CAACQ,OAAO,CAACmB,SAAS,IAAI3B,SAAS,CAACQ,OAAO,CAACuB,gBAAgB,CAACpC,GAAG,CAACkC,EAAE,CAAC,GACnE7B,SAAS,CAACQ,OAAO,CAACuB,gBAAgB,CAACpC,GAAG,CAACkC,EAAE,CAAC,GAC1ClB,SAAS;IACnBqB,OAAO,EAAElB;GACZ;EAED,oBACIR,6BAAC2B,UAAU,oBAAYvC,KAAK,EAAMgC,UAAU,GACvC1B,SAAS,CAACQ,OAAO,CAACuB,gBAAgB,CAACpC,GAAG,CAACkC,EAAE,CAAC,gBAAGvB,6BAAC4B,UAAU;IAACC,KAAK,EAAExC,GAAG,CAACkC,EAAE;IAAEhC,KAAK,EAAEA;IAAS,GAAG,IAAI,CACvF;AAErB;;;;"}
@@ -30,20 +30,15 @@ function Editing(props) {
30
30
  (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.click();
31
31
  });
32
32
  const handleChange = enabled => {
33
- if (enabled && tableMeta.rowActive.rowActiveIndex === undefined) {
34
- tableMeta.rowActive.setRowActiveIndex(0);
35
- }
33
+ tableMeta.editing.toggleEditing(enabled);
36
34
  requestAnimationFrame(() => {
37
35
  var _tableMeta$rowActive$;
38
- // wait for an active row to be set so that we don't trigger save
39
- tableMeta.editing.toggleEditing(enabled, table);
40
- scrollToIndex((_tableMeta$rowActive$ = tableMeta.rowActive.rowActiveIndex) !== null && _tableMeta$rowActive$ !== void 0 ? _tableMeta$rowActive$ : 0);
36
+ return scrollToIndex((_tableMeta$rowActive$ = tableMeta.rowActive.rowActiveIndex) !== null && _tableMeta$rowActive$ !== void 0 ? _tableMeta$rowActive$ : 0);
41
37
  });
42
38
  };
43
39
  return /*#__PURE__*/React__default.createElement(Tooltip, {
44
40
  title: tooltip
45
41
  }, /*#__PURE__*/React__default.createElement(ModeSwitch, {
46
- "data-table": "editing-toggle",
47
42
  checked: tableMeta.editing.isEditing,
48
43
  onChange: handleChange,
49
44
  ref: ref
@@ -1 +1 @@
1
- {"version":3,"file":"Editing.js","sources":["../../../../../../../../../../src/components/Table3/components/Toolbar/Editing/Editing.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\nimport { ModeSwitch } from '../../../../ModeSwitch/ModeSwitch';\nimport { useGlobalKeyDown } from '../../../../../hooks/useGlobalKeyDown';\nimport { Shortcut } from '../../../../Shortcut/Shortcut';\n\ntype EditingProps<TType = unknown> = React.HTMLAttributes<HTMLButtonElement> & {\n scrollToIndex: any;\n table: ReactTable<TType>;\n};\n\nexport function Editing<TType = unknown>(props: EditingProps<TType>) {\n const { scrollToIndex, table } = props;\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLButtonElement>(null);\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const shortcut = { key: 'e', meta: true, shift: false };\n const tooltip = (\n <>\n {texts.table3.editing.buttons.edit.tooltip}\n <Shortcut className=\"ml-2\" keys={shortcut} />\n </>\n );\n\n useGlobalKeyDown(shortcut, (event: KeyboardEvent) => {\n event.preventDefault();\n ref.current?.click();\n });\n\n const handleChange = (enabled: boolean) => {\n if (enabled && tableMeta.rowActive.rowActiveIndex === undefined) {\n tableMeta.rowActive.setRowActiveIndex(0);\n }\n\n requestAnimationFrame(() => {\n // wait for an active row to be set so that we don't trigger save\n tableMeta.editing.toggleEditing(enabled, table);\n scrollToIndex(tableMeta.rowActive.rowActiveIndex ?? 0);\n });\n };\n\n return (\n <Tooltip title={tooltip}>\n <ModeSwitch data-table=\"editing-toggle\" checked={tableMeta.editing.isEditing} onChange={handleChange} ref={ref} />\n </Tooltip>\n );\n}\n"],"names":["Editing","props","scrollToIndex","table","texts","useLocalization","ref","React","useRef","tableMeta","options","meta","shortcut","key","shift","tooltip","table3","editing","buttons","edit","Shortcut","className","keys","useGlobalKeyDown","event","preventDefault","_ref$current","current","click","handleChange","enabled","rowActive","rowActiveIndex","undefined","setRowActiveIndex","requestAnimationFrame","toggleEditing","_tableMeta$rowActive$","Tooltip","title","ModeSwitch","checked","isEditing","onChange"],"mappings":";;;;;;;SAagBA,OAAOA,CAAkBC,KAA0B;EAC/D,MAAM;IAAEC,aAAa;IAAEC;GAAO,GAAGF,KAAK;EACtC,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAoB,IAAI,CAAC;EACjD,MAAMC,SAAS,GAAGN,KAAK,CAACO,OAAO,CAACC,IAA6B;EAE7D,MAAMC,QAAQ,GAAG;IAAEC,GAAG,EAAE,GAAG;IAAEF,IAAI,EAAE,IAAI;IAAEG,KAAK,EAAE;GAAO;EACvD,MAAMC,OAAO,gBACTR,4DACKH,KAAK,CAACY,MAAM,CAACC,OAAO,CAACC,OAAO,CAACC,IAAI,CAACJ,OAAO,eAC1CR,6BAACa,QAAQ;IAACC,SAAS,EAAC,MAAM;IAACC,IAAI,EAAEV;IAAY,CAEpD;EAEDW,gBAAgB,CAACX,QAAQ,EAAGY,KAAoB;;IAC5CA,KAAK,CAACC,cAAc,EAAE;IACtB,CAAAC,YAAA,GAAApB,GAAG,CAACqB,OAAO,cAAAD,YAAA,uBAAXA,YAAA,CAAaE,KAAK,EAAE;GACvB,CAAC;EAEF,MAAMC,YAAY,GAAIC,OAAgB;IAClC,IAAIA,OAAO,IAAIrB,SAAS,CAACsB,SAAS,CAACC,cAAc,KAAKC,SAAS,EAAE;MAC7DxB,SAAS,CAACsB,SAAS,CAACG,iBAAiB,CAAC,CAAC,CAAC;;IAG5CC,qBAAqB,CAAC;;;MAElB1B,SAAS,CAACQ,OAAO,CAACmB,aAAa,CAACN,OAAO,EAAE3B,KAAK,CAAC;MAC/CD,aAAa,EAAAmC,qBAAA,GAAC5B,SAAS,CAACsB,SAAS,CAACC,cAAc,cAAAK,qBAAA,cAAAA,qBAAA,GAAI,CAAC,CAAC;KACzD,CAAC;GACL;EAED,oBACI9B,6BAAC+B,OAAO;IAACC,KAAK,EAAExB;kBACZR,6BAACiC,UAAU;kBAAY,gBAAgB;IAACC,OAAO,EAAEhC,SAAS,CAACQ,OAAO,CAACyB,SAAS;IAAEC,QAAQ,EAAEd,YAAY;IAAEvB,GAAG,EAAEA;IAAO,CAC5G;AAElB;;;;"}
1
+ {"version":3,"file":"Editing.js","sources":["../../../../../../../../../../src/components/Table3/components/Toolbar/Editing/Editing.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\nimport { ModeSwitch } from '../../../../ModeSwitch/ModeSwitch';\nimport { useGlobalKeyDown } from '../../../../../hooks/useGlobalKeyDown';\nimport { Shortcut } from '../../../../Shortcut/Shortcut';\n\ntype EditingProps<TType = unknown> = React.HTMLAttributes<HTMLButtonElement> & {\n scrollToIndex: any;\n table: ReactTable<TType>;\n};\n\nexport function Editing<TType = unknown>(props: EditingProps<TType>) {\n const { scrollToIndex, table } = props;\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLButtonElement>(null);\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const shortcut = { key: 'e', meta: true, shift: false };\n const tooltip = (\n <>\n {texts.table3.editing.buttons.edit.tooltip}\n <Shortcut className=\"ml-2\" keys={shortcut} />\n </>\n );\n\n useGlobalKeyDown(shortcut, (event: KeyboardEvent) => {\n event.preventDefault();\n ref.current?.click();\n });\n\n const handleChange = (enabled: boolean) => {\n tableMeta.editing.toggleEditing(enabled);\n requestAnimationFrame(() => scrollToIndex(tableMeta.rowActive.rowActiveIndex ?? 0));\n };\n\n return (\n <Tooltip title={tooltip}>\n <ModeSwitch checked={tableMeta.editing.isEditing} onChange={handleChange} ref={ref} />\n </Tooltip>\n );\n}\n"],"names":["Editing","props","scrollToIndex","table","texts","useLocalization","ref","React","useRef","tableMeta","options","meta","shortcut","key","shift","tooltip","table3","editing","buttons","edit","Shortcut","className","keys","useGlobalKeyDown","event","preventDefault","_ref$current","current","click","handleChange","enabled","toggleEditing","requestAnimationFrame","_tableMeta$rowActive$","rowActive","rowActiveIndex","Tooltip","title","ModeSwitch","checked","isEditing","onChange"],"mappings":";;;;;;;SAagBA,OAAOA,CAAkBC,KAA0B;EAC/D,MAAM;IAAEC,aAAa;IAAEC;GAAO,GAAGF,KAAK;EACtC,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAoB,IAAI,CAAC;EACjD,MAAMC,SAAS,GAAGN,KAAK,CAACO,OAAO,CAACC,IAA6B;EAE7D,MAAMC,QAAQ,GAAG;IAAEC,GAAG,EAAE,GAAG;IAAEF,IAAI,EAAE,IAAI;IAAEG,KAAK,EAAE;GAAO;EACvD,MAAMC,OAAO,gBACTR,4DACKH,KAAK,CAACY,MAAM,CAACC,OAAO,CAACC,OAAO,CAACC,IAAI,CAACJ,OAAO,eAC1CR,6BAACa,QAAQ;IAACC,SAAS,EAAC,MAAM;IAACC,IAAI,EAAEV;IAAY,CAEpD;EAEDW,gBAAgB,CAACX,QAAQ,EAAGY,KAAoB;;IAC5CA,KAAK,CAACC,cAAc,EAAE;IACtB,CAAAC,YAAA,GAAApB,GAAG,CAACqB,OAAO,cAAAD,YAAA,uBAAXA,YAAA,CAAaE,KAAK,EAAE;GACvB,CAAC;EAEF,MAAMC,YAAY,GAAIC,OAAgB;IAClCrB,SAAS,CAACQ,OAAO,CAACc,aAAa,CAACD,OAAO,CAAC;IACxCE,qBAAqB,CAAC;MAAA,IAAAC,qBAAA;MAAA,OAAM/B,aAAa,EAAA+B,qBAAA,GAACxB,SAAS,CAACyB,SAAS,CAACC,cAAc,cAAAF,qBAAA,cAAAA,qBAAA,GAAI,CAAC,CAAC;MAAC;GACtF;EAED,oBACI1B,6BAAC6B,OAAO;IAACC,KAAK,EAAEtB;kBACZR,6BAAC+B,UAAU;IAACC,OAAO,EAAE9B,SAAS,CAACQ,OAAO,CAACuB,SAAS;IAAEC,QAAQ,EAAEZ,YAAY;IAAEvB,GAAG,EAAEA;IAAO,CAChF;AAElB;;;;"}
@@ -1,27 +1,29 @@
1
1
  import React__default from 'react';
2
- import { usePendingChangesState } from './useEditingState.js';
2
+ import { useGlobalKeyDown } from '../../../hooks/useGlobalKeyDown.js';
3
+ import { useLocalization } from '../../Provider/Localization.js';
4
+ import { _forOf, _catch } from '../../../../../../node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js';
5
+ import { willRowMove } from '../util/editing.js';
6
+ import { debounce } from 'lodash-es';
3
7
 
4
- function useTableEditing(isEnabled = false, handleSave, handleChange, rowIdentityAccessor, validator) {
8
+ function useTableEditing(isEnabled = false, handleSave, handleChange, validator) {
5
9
  // used to switch the table into editing mode
6
- const [isEditing, setEditing] = React__default.useState(false);
10
+ const [isEditing, toggleEditing] = React__default.useState(false);
7
11
  // used to switch the editing between "detailed" mode
8
12
  const [isDetailedMode, toggleDetailedMode] = React__default.useState(false);
9
- // used to contain ref to the create button
10
- const createRowButtonRef = React__default.useRef(null);
11
13
  // store the last focused cell, so that up/down arrow key navigation remains in the same column
12
- const [lastFocusedCellIndex, setLastFocusedCellIndex] = React__default.useState(undefined);
13
- const pendingChangesFns = usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, validator);
14
- function toggleEditing(enabled, table) {
15
- if (!enabled) {
16
- // save
17
- pendingChangesFns.saveChanges(table);
18
- // reset detailed mode
19
- toggleDetailedMode(false);
20
- // reset the last index back to the first focusable element, when editing gets turned off
21
- setLastFocusedCellIndex(undefined);
22
- }
23
- setEditing(enabled);
24
- }
14
+ const [lastFocusedCellIndex, setLastFocusedCellIndex] = useLastFocusedCellIndex();
15
+ // store pending changes for each row
16
+ // changes are saved as soon as the active row changes, so in most cases this will only contain the active row's changes
17
+ // but not always - if validation or server requests fail when saving, those rows remain until the failure is resolved
18
+ const pendingChangesFns = usePendingChanges(isEnabled, handleSave, handleChange, validator);
19
+ useGlobalKeyDown(isEnabled && isEditing ? {
20
+ key: 's',
21
+ meta: true,
22
+ shift: false
23
+ } : undefined, event => {
24
+ event.preventDefault();
25
+ pendingChangesFns.saveChanges();
26
+ });
25
27
  return {
26
28
  isEnabled,
27
29
  isEditing,
@@ -30,10 +32,395 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, rowIdentit
30
32
  toggleEditing: isEnabled ? toggleEditing : () => undefined,
31
33
  lastFocusedCellIndex,
32
34
  setLastFocusedCellIndex,
33
- createRowButtonRef,
34
35
  ...pendingChangesFns
35
36
  };
36
37
  }
38
+ function usePendingChanges(isEnabled, handleSave, handleChange, validator) {
39
+ const saveChanges = function (rowId = undefined) {
40
+ try {
41
+ let _exit = false;
42
+ if (!handleSave) {
43
+ console.warn('Tried to save, but Table has no onEditingSave handler');
44
+ return Promise.resolve();
45
+ }
46
+ // we save back to pendingChanges, so make a copy of it's state when save was triggered
47
+ const changesToSave = rowId ? {
48
+ [rowId]: pendingChanges[rowId]
49
+ } : {
50
+ ...pendingChanges
51
+ };
52
+ const changes = Object.keys(changesToSave);
53
+ return Promise.resolve(function () {
54
+ if (changes.length) {
55
+ return _forOf(changes, function (rowId) {
56
+ const pendingChange = changesToSave[rowId];
57
+ const changeSet = getChangesetFromChanges(pendingChange);
58
+ return _catch(function () {
59
+ function _temp3(_result) {
60
+ return _exit ? _result : Promise.resolve(handleSave(changeSet)).then(function () {
61
+ // cleanup changes, we don't need them after saving
62
+ resetChanges(rowId);
63
+ setRowSaveStatus(rowId, 'complete');
64
+ });
65
+ }
66
+ if (getRowSaveStatus(rowId) === 'pending') {
67
+ _exit = true;
68
+ return;
69
+ }
70
+ // set saving = true
71
+ setRowSaveStatus(rowId, 'pending');
72
+ // re-run validation, maybe a cell is already invalid but has never been blurred
73
+ const _temp2 = function () {
74
+ if (validator) {
75
+ return Promise.resolve(validator(changeSet)).then(function (errors) {
76
+ if (errors && Object.keys(errors).length) {
77
+ throw errors;
78
+ }
79
+ });
80
+ }
81
+ }();
82
+ return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2); // send new data to the server
83
+ }, function (error) {
84
+ // the onEditingSave handler should throw errors when something fails, e.g. validation, network errors etc
85
+ // this code handles those errors and maps them either to row errors or cell specific errors
86
+ let rowError;
87
+ let cellErrors;
88
+ if (typeof error === 'string') {
89
+ rowError = error;
90
+ } else if (error instanceof Error) {
91
+ var _error$response;
92
+ rowError = error.message;
93
+ // most of our apis return error objects within this shape
94
+ if (typeof ((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) === 'object') {
95
+ var _error$response2;
96
+ cellErrors = (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data;
97
+ }
98
+ } else if (typeof error === 'object') {
99
+ cellErrors = error;
100
+ }
101
+ if (rowError || cellErrors) {
102
+ setPendingChanges(currentChanges => {
103
+ const nextChanges = {
104
+ ...currentChanges
105
+ };
106
+ nextChanges[rowId]._meta.errors = {
107
+ row: rowError,
108
+ cells: cellErrors,
109
+ shouldShowErrorAlert: true
110
+ };
111
+ return nextChanges;
112
+ });
113
+ }
114
+ setRowSaveStatus(rowId, undefined);
115
+ });
116
+ }, function () {
117
+ return _exit;
118
+ });
119
+ }
120
+ }());
121
+ } catch (e) {
122
+ return Promise.reject(e);
123
+ }
124
+ };
125
+ const validateCell = function (cell) {
126
+ try {
127
+ if (!validator || !isEnabled) {
128
+ return Promise.resolve();
129
+ }
130
+ const changeSet = getChangesetFromChanges(pendingChanges[cell.row.id]);
131
+ // only validate if the cell being blurred actually has any changes
132
+ const _temp = function () {
133
+ if (cell.column.id in changeSet) {
134
+ return Promise.resolve(validator(changeSet)).then(function (errors) {
135
+ setPendingChanges(currentChanges => {
136
+ const nextChanges = {
137
+ ...currentChanges
138
+ };
139
+ nextChanges[cell.row.id]._meta = {
140
+ ...nextChanges[cell.row.id]._meta,
141
+ errors: {
142
+ ...nextChanges[cell.row.id]._meta.errors,
143
+ cells: errors,
144
+ shouldShowErrorAlert: !Object.keys(errors).length ? false : nextChanges[cell.row.id]._meta.errors.shouldShowErrorAlert
145
+ }
146
+ };
147
+ return nextChanges;
148
+ });
149
+ });
150
+ }
151
+ }();
152
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
153
+ } catch (e) {
154
+ return Promise.reject(e);
155
+ }
156
+ };
157
+ const setCellValue = function (cell, change, rowIndex) {
158
+ try {
159
+ const changes = {
160
+ [cell.column.id]: change
161
+ };
162
+ setPendingChanges(currentChanges => {
163
+ const nextChanges = createPendingChangesSetter(currentChanges, cell.row, rowIndex, changes, localization);
164
+ pendingChangesUpdater.syncCellChanges(nextChanges);
165
+ return nextChanges;
166
+ });
167
+ pendingChangesUpdater.runCellUpdates(changes, cell, rowIndex);
168
+ return Promise.resolve();
169
+ } catch (e) {
170
+ return Promise.reject(e);
171
+ }
172
+ };
173
+ const addCreatedRowChangeset = function (row) {
174
+ try {
175
+ const cells = row.getAllCells();
176
+ setPendingChanges(currentChanges => {
177
+ return cells.reduce((changes, cell) => {
178
+ if (cell.getValue()) {
179
+ var _currentChanges$cell$, _currentChanges$cell$2, _currentChanges$cell$3;
180
+ return {
181
+ ...changes,
182
+ [cell.row.id]: {
183
+ ...changes[cell.row.id],
184
+ [cell.column.id]: cell.getValue(),
185
+ _meta: {
186
+ ...((_currentChanges$cell$ = currentChanges[cell.row.id]) === null || _currentChanges$cell$ === void 0 ? void 0 : _currentChanges$cell$._meta),
187
+ original: cell.row.original,
188
+ moveReason: {
189
+ ...((_currentChanges$cell$2 = currentChanges[cell.row.id]) === null || _currentChanges$cell$2 === void 0 ? void 0 : _currentChanges$cell$2._meta.moveReason)
190
+ },
191
+ errors: {
192
+ ...((_currentChanges$cell$3 = currentChanges[cell.row.id]) === null || _currentChanges$cell$3 === void 0 ? void 0 : _currentChanges$cell$3._meta.errors)
193
+ }
194
+ }
195
+ }
196
+ };
197
+ } else {
198
+ return changes;
199
+ }
200
+ }, currentChanges);
201
+ });
202
+ return Promise.resolve();
203
+ } catch (e) {
204
+ return Promise.reject(e);
205
+ }
206
+ };
207
+ const localization = useLocalization();
208
+ const [pendingChanges, setPendingChanges] = React__default.useState({});
209
+ // we maintain save status as separate state because 'complete' needs to briefly show after pendingChanges are deleted
210
+ const [saveStates, setSaveState] = React__default.useState({});
211
+ function getCellValue(cell) {
212
+ var _pendingChanges$cell$;
213
+ return (_pendingChanges$cell$ = pendingChanges[cell.row.id]) === null || _pendingChanges$cell$ === void 0 ? void 0 : _pendingChanges$cell$[cell.column.id];
214
+ }
215
+ function getCellError(cell) {
216
+ var _pendingChanges$cell$2, _pendingChanges$cell$3, _pendingChanges$cell$4;
217
+ return (_pendingChanges$cell$2 = pendingChanges[cell.row.id]) === null || _pendingChanges$cell$2 === void 0 ? void 0 : (_pendingChanges$cell$3 = _pendingChanges$cell$2._meta.errors) === null || _pendingChanges$cell$3 === void 0 ? void 0 : (_pendingChanges$cell$4 = _pendingChanges$cell$3.cells) === null || _pendingChanges$cell$4 === void 0 ? void 0 : _pendingChanges$cell$4[cell.column.id];
218
+ }
219
+ const pendingChangesUpdater = usePendingChangesUpdater(handleChange, setPendingChanges);
220
+ function hasRowErrors(rowId) {
221
+ var _pendingChanges$rowId, _pendingChanges$rowId2, _pendingChanges$rowId3, _pendingChanges$rowId4, _pendingChanges$rowId5;
222
+ if (!isEnabled) {
223
+ return false;
224
+ }
225
+ return !!((_pendingChanges$rowId = pendingChanges[rowId]) !== null && _pendingChanges$rowId !== void 0 && (_pendingChanges$rowId2 = _pendingChanges$rowId._meta.errors) !== null && _pendingChanges$rowId2 !== void 0 && _pendingChanges$rowId2.row) || !!Object.keys((_pendingChanges$rowId3 = (_pendingChanges$rowId4 = pendingChanges[rowId]) === null || _pendingChanges$rowId4 === void 0 ? void 0 : (_pendingChanges$rowId5 = _pendingChanges$rowId4._meta.errors) === null || _pendingChanges$rowId5 === void 0 ? void 0 : _pendingChanges$rowId5.cells) !== null && _pendingChanges$rowId3 !== void 0 ? _pendingChanges$rowId3 : {}).length;
226
+ }
227
+ function hasRowErrorsSeen(rowId) {
228
+ var _pendingChanges$rowId6;
229
+ if (!isEnabled) {
230
+ return false;
231
+ }
232
+ return hasRowErrors(rowId) && !!((_pendingChanges$rowId6 = pendingChanges[rowId]._meta.errors) !== null && _pendingChanges$rowId6 !== void 0 && _pendingChanges$rowId6.shouldShowErrorAlert);
233
+ }
234
+ function getRowPendingChange(rowId) {
235
+ const rowPendingChanges = pendingChanges[rowId];
236
+ if (rowPendingChanges) {
237
+ const {
238
+ _meta,
239
+ ...pendingChange
240
+ } = rowPendingChanges;
241
+ return pendingChange;
242
+ }
243
+ return undefined;
244
+ }
245
+ function getRowSaveStatus(rowId) {
246
+ if (!isEnabled) {
247
+ return false;
248
+ }
249
+ return saveStates[rowId];
250
+ }
251
+ function setRowSaveStatus(rowId, status) {
252
+ setSaveState(currentStates => {
253
+ const nextStates = {
254
+ ...currentStates
255
+ };
256
+ if (status) {
257
+ nextStates[rowId] = status;
258
+ } else {
259
+ delete nextStates[rowId];
260
+ }
261
+ return nextStates;
262
+ });
263
+ }
264
+ function getRowMoveReason(rowId) {
265
+ var _pendingChanges$rowId7;
266
+ return (_pendingChanges$rowId7 = pendingChanges[rowId]) !== null && _pendingChanges$rowId7 !== void 0 && _pendingChanges$rowId7._meta.moveReason ? Object.values(pendingChanges[rowId]._meta.moveReason)[0] : undefined;
267
+ }
268
+ function hasChanges(rowId) {
269
+ if (!isEnabled) {
270
+ return false;
271
+ }
272
+ return rowId ? !!pendingChanges[rowId] : !!Object.keys(pendingChanges).length;
273
+ }
274
+ function hasAlertErrors() {
275
+ if (!isEnabled) {
276
+ return false;
277
+ }
278
+ return !!getAlertErrors().length;
279
+ }
280
+ function getAlertErrors() {
281
+ return Object.keys(pendingChanges).filter(hasRowErrorsSeen).map(rowId => ({
282
+ rowId,
283
+ pendingChange: pendingChanges[rowId]
284
+ }));
285
+ }
286
+ function resetChanges(rowId) {
287
+ setPendingChanges(currentChanges => {
288
+ const nextChanges = {
289
+ ...currentChanges
290
+ };
291
+ delete nextChanges[rowId];
292
+ return nextChanges;
293
+ });
294
+ }
295
+ function getCompletedRowsCount() {
296
+ return Object.values(saveStates).filter(value => value === 'complete').length;
297
+ }
298
+ return {
299
+ getCellValue,
300
+ getCellError,
301
+ setCellValue,
302
+ validateCell,
303
+ addCreatedRowChangeset,
304
+ hasChanges,
305
+ hasAlertErrors,
306
+ getAlertErrors,
307
+ saveChanges,
308
+ resetChanges,
309
+ hasRowErrors,
310
+ hasRowErrorsSeen,
311
+ getRowPendingChange,
312
+ getRowSaveStatus,
313
+ setRowSaveStatus,
314
+ getRowMoveReason,
315
+ getCompletedRowsCount
316
+ };
317
+ }
318
+ function useLastFocusedCellIndex() {
319
+ // store the last focused cell, so that up/down arrow key navigation remains in the same column
320
+ const lastFocusedCellIndexRef = React__default.useRef(undefined);
321
+ const setLastFocusedCellIndex = React__default.useCallback(index => {
322
+ lastFocusedCellIndexRef.current = index;
323
+ }, []);
324
+ return [lastFocusedCellIndexRef.current, setLastFocusedCellIndex];
325
+ }
326
+ function usePendingChangesUpdater(handleChange, setPendingChanges) {
327
+ const localization = useLocalization();
328
+ const updatersRef = React__default.useRef({});
329
+ const runCellUpdates = React__default.useCallback(debounce(function (changes, cell, rowIndex) {
330
+ try {
331
+ const _temp4 = function () {
332
+ if (typeof handleChange === 'function') {
333
+ const previousValues = {
334
+ ...cell.row.original,
335
+ ...getChangesetFromChanges(updatersRef.current[cell.row.id])
336
+ };
337
+ const nextValues = {
338
+ ...previousValues,
339
+ ...changes
340
+ };
341
+ return Promise.resolve(handleChange(cell.column.id, changes[cell.column.id], nextValues, previousValues)).then(function (updates) {
342
+ if (updates && Object.keys(updates).length) {
343
+ setPendingChanges(currentChanges => createPendingChangesSetter(currentChanges, cell.row, rowIndex, updates, localization));
344
+ }
345
+ });
346
+ }
347
+ }();
348
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
349
+ } catch (e) {
350
+ return Promise.reject(e);
351
+ }
352
+ }, 250), []);
353
+ function syncCellChanges(changes) {
354
+ updatersRef.current = changes;
355
+ }
356
+ return {
357
+ syncCellChanges,
358
+ runCellUpdates
359
+ };
360
+ }
361
+ function createPendingChangesSetter(currentChanges, row, rowIndex, changes, localization) {
362
+ var _currentChanges$row$i, _currentChanges$row$i2, _currentChanges$row$i3;
363
+ // prepare
364
+ const nextChanges = {
365
+ ...currentChanges
366
+ };
367
+ const rowChanges = {
368
+ ...currentChanges[row.id],
369
+ _meta: {
370
+ ...((_currentChanges$row$i = currentChanges[row.id]) === null || _currentChanges$row$i === void 0 ? void 0 : _currentChanges$row$i._meta),
371
+ original: row.original,
372
+ moveReason: {
373
+ ...((_currentChanges$row$i2 = currentChanges[row.id]) === null || _currentChanges$row$i2 === void 0 ? void 0 : _currentChanges$row$i2._meta.moveReason)
374
+ },
375
+ errors: {
376
+ ...((_currentChanges$row$i3 = currentChanges[row.id]) === null || _currentChanges$row$i3 === void 0 ? void 0 : _currentChanges$row$i3._meta.errors)
377
+ }
378
+ }
379
+ };
380
+ // run changes
381
+ const cells = row._getAllCellsByColumnId();
382
+ for (const [accessor, change] of Object.entries(changes)) {
383
+ // update if the change is different to the original (saved) value,
384
+ // otherwise remove any change - no point saving the same value
385
+ if (change !== row.original[accessor]) {
386
+ rowChanges[accessor] = change;
387
+ // consumers sometimes include properties in onEditingChange that aren't rendered as columns, we need to guard against that.
388
+ // eslint-disable-next-line no-prototype-builtins
389
+ if (cells.hasOwnProperty(accessor)) {
390
+ // determine if the row will move position based on this change, and save why it will move
391
+ const reason = willRowMove(cells[accessor], change, rowIndex, localization);
392
+ if (reason) {
393
+ rowChanges._meta.moveReason[accessor] = reason;
394
+ } else {
395
+ delete rowChanges._meta.moveReason[accessor];
396
+ }
397
+ }
398
+ } else {
399
+ delete rowChanges[accessor];
400
+ delete rowChanges._meta.moveReason[accessor];
401
+ }
402
+ }
403
+ // set changes
404
+ // or delete if there are no changes left, so that we don't store changes with unchanged data
405
+ if (Object.keys(rowChanges).filter(k => k !== '_meta').length) {
406
+ nextChanges[row.id] = rowChanges;
407
+ } else {
408
+ delete nextChanges[row.id];
409
+ }
410
+ return nextChanges;
411
+ }
412
+ function getChangesetFromChanges(changes) {
413
+ // extract the original data from the row changes
414
+ const {
415
+ _meta,
416
+ ...changeset
417
+ } = changes !== null && changes !== void 0 ? changes : {};
418
+ // and mix them in with the changes, ready to send to the server
419
+ return {
420
+ ...(_meta === null || _meta === void 0 ? void 0 : _meta.original),
421
+ ...changeset
422
+ };
423
+ }
37
424
 
38
425
  export { useTableEditing };
39
426
  //# sourceMappingURL=useTableEditing.js.map