@economic/taco 2.44.4 → 2.44.5-create.5

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 +13 -0
  7. package/dist/components/Table3/components/Row/Editing/TemporaryRow.d.ts +11 -0
  8. package/dist/components/Table3/features/useEditingState.d.ts +28 -0
  9. package/dist/components/Table3/features/useTableEditing.d.ts +25 -36
  10. package/dist/components/Table3/types.d.ts +23 -8
  11. package/dist/components/Table3/useTable3.d.ts +6 -0
  12. package/dist/components/Table3/util/editing.d.ts +2 -1
  13. package/dist/esm/index.css +6 -2
  14. package/dist/esm/node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js +17 -17
  15. package/dist/esm/node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js.map +1 -1
  16. package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js +2 -2
  17. package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js.map +1 -1
  18. package/dist/esm/packages/taco/src/components/Provider/Localization.js +5 -3
  19. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  20. package/dist/esm/packages/taco/src/components/Switch/Switch.js +1 -1
  21. package/dist/esm/packages/taco/src/components/Switch/Switch.js.map +1 -1
  22. package/dist/esm/packages/taco/src/components/Table3/Table3.js +19 -7
  23. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  24. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +21 -10
  25. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
  26. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js +5 -37
  27. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js.map +1 -1
  28. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +17 -12
  29. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
  30. package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js +34 -0
  31. package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js.map +1 -0
  32. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +88 -0
  33. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js.map +1 -0
  34. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js +2 -14
  35. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js.map +1 -1
  36. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js +95 -0
  37. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js.map +1 -0
  38. package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js +39 -6
  39. package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js.map +1 -1
  40. package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js +7 -2
  41. package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js.map +1 -1
  42. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js +512 -0
  43. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js.map +1 -0
  44. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +19 -406
  45. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
  46. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +37 -32
  47. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
  48. package/dist/esm/packages/taco/src/components/Table3/useTable3.js +25 -8
  49. package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
  50. package/dist/esm/packages/taco/src/components/Table3/util/editing.js +6 -24
  51. package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
  52. package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js +18 -2
  53. package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js.map +1 -1
  54. package/dist/esm/packages/taco/src/primitives/Listbox2/components/Root.js +1 -0
  55. package/dist/esm/packages/taco/src/primitives/Listbox2/components/Root.js.map +1 -1
  56. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +3 -4
  57. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
  58. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js +9 -3
  59. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js.map +1 -1
  60. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +6 -3
  61. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
  62. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js +1 -1
  63. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
  64. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +1 -1
  65. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
  66. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +23 -6
  67. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  68. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js +2 -2
  69. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
  70. package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
  71. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +1 -1
  72. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
  73. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +11 -0
  74. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  75. package/dist/esm/packages/taco/src/utils/dom.js +7 -4
  76. package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
  77. package/dist/index.css +6 -2
  78. package/dist/primitives/Collection/components/Root.d.ts +2 -0
  79. package/dist/primitives/Table/Core/Table.d.ts +1 -0
  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/features/useTableRenderer.d.ts +2 -2
  83. package/dist/primitives/Table/Core/features/useTableStyle.d.ts +1 -1
  84. package/dist/primitives/Table/Core/types.d.ts +3 -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 +941 -628
  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 +3 -5
  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 +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 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
+ {"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,MA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AElB;;;;"}
@@ -0,0 +1,512 @@
1
+ import React__default from 'react';
2
+ import { useLocalization } from '../../Provider/Localization.js';
3
+ import { v4 } from 'uuid';
4
+ import { _forOf, _catch } from '../../../../../../node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js';
5
+ import omit from 'lodash-es/omit';
6
+ import setWith from 'lodash-es/setWith';
7
+ import { isTemporaryRow, willRowMove, TEMPORARY_ROW_ID_PREFIX } from '../util/editing.js';
8
+
9
+ const DELAY_BEFORE_REMOVING_SAVE_STATUS = 3000;
10
+ function reducer(state, action) {
11
+ const {
12
+ type,
13
+ rowId,
14
+ payload
15
+ } = action;
16
+ switch (type) {
17
+ case 'setCellValue':
18
+ {
19
+ const {
20
+ columnId,
21
+ row,
22
+ value
23
+ } = payload;
24
+ return {
25
+ ...state,
26
+ changes: {
27
+ ...state.changes,
28
+ rows: setWith(state.changes.rows, `${rowId}.${columnId}`, value, Object),
29
+ originals: setWith(state.changes.originals, rowId, row, Object)
30
+ }
31
+ };
32
+ }
33
+ case 'removeCellValue':
34
+ {
35
+ const {
36
+ columnId,
37
+ rowIdentityAccessor
38
+ } = payload;
39
+ const changes = omit(state.changes.rows, `${rowId}.${columnId}`);
40
+ // if there are no changes left, remove the row
41
+ if (!Object.keys(changes[rowId]).length) {
42
+ return reducer(state, {
43
+ type: 'removeRow',
44
+ rowId,
45
+ payload: {
46
+ rowIdentityAccessor
47
+ }
48
+ });
49
+ }
50
+ return {
51
+ ...state,
52
+ changes: {
53
+ ...state.changes,
54
+ rows: omit(state.changes.rows, `${rowId}.${columnId}`),
55
+ errors: omit(state.changes.errors, `${rowId}.cells.${columnId}`),
56
+ moveReasons: omit(state.changes.moveReasons, `${rowId}.${columnId}`)
57
+ }
58
+ };
59
+ }
60
+ case 'updateRow':
61
+ {
62
+ const {
63
+ cellErrors,
64
+ moveReasons,
65
+ original,
66
+ value
67
+ } = payload;
68
+ return {
69
+ ...state,
70
+ changes: {
71
+ ...state.changes,
72
+ rows: setWith(state.changes.rows, rowId, value, Object),
73
+ errors: setWith(state.changes.errors, `${rowId}.cells`, cellErrors !== null && cellErrors !== void 0 ? cellErrors : state.changes.errors.cells[rowId], Object),
74
+ originals: setWith(state.changes.originals, rowId, original !== null && original !== void 0 ? original : state.changes.originals[rowId], Object),
75
+ moveReasons: setWith(state.changes.moveReasons, rowId, moveReasons !== null && moveReasons !== void 0 ? moveReasons : state.changes.moveReasons[rowId], Object),
76
+ // status can be undefined, so don't use ??
77
+ status: setWith(state.changes.status, rowId, undefined, Object)
78
+ }
79
+ };
80
+ }
81
+ case 'removeRow':
82
+ {
83
+ const {
84
+ rowIdentityAccessor
85
+ } = payload;
86
+ return {
87
+ ...state,
88
+ changes: {
89
+ ...state.changes,
90
+ rows: omit(state.changes.rows, rowId),
91
+ errors: omit(state.changes.errors, rowId),
92
+ moveReasons: omit(state.changes.moveReasons, rowId),
93
+ originals: omit(state.changes.originals, rowId),
94
+ status: omit(state.changes.status, rowId)
95
+ },
96
+ temporaryRows: state.temporaryRows.filter(row => row[rowIdentityAccessor] !== rowId)
97
+ };
98
+ }
99
+ case 'setRowStatus':
100
+ {
101
+ const {
102
+ status
103
+ } = payload;
104
+ return {
105
+ ...state,
106
+ changes: {
107
+ ...state.changes,
108
+ status: status ? setWith(state.changes.status, rowId, status, Object) : omit(state.changes.status, rowId)
109
+ }
110
+ };
111
+ }
112
+ case 'setRowErrors':
113
+ {
114
+ const {
115
+ ...errors
116
+ } = payload;
117
+ return {
118
+ ...state,
119
+ changes: {
120
+ ...state.changes,
121
+ errors: setWith(state.changes.errors, rowId, errors, Object)
122
+ }
123
+ };
124
+ }
125
+ case 'createRow':
126
+ {
127
+ const {
128
+ value
129
+ } = payload;
130
+ return {
131
+ ...state,
132
+ temporaryRows: state.temporaryRows.concat(value),
133
+ changes: {
134
+ ...state.changes,
135
+ rows: setWith(state.changes.rows, rowId, value, Object),
136
+ originals: setWith(state.changes.originals, rowId, value, Object)
137
+ }
138
+ };
139
+ }
140
+ default:
141
+ return state;
142
+ }
143
+ }
144
+ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, validator) {
145
+ const saveChanges = function (table, rowId = undefined) {
146
+ try {
147
+ let _exit = false;
148
+ if (!handleSave) {
149
+ console.warn('Tried to save, but Table has no onEditingSave handler');
150
+ return Promise.resolve(false);
151
+ }
152
+ // sometimes we only want to save one row
153
+ const changes = rowId ? {
154
+ [rowId]: state.changes.rows[rowId]
155
+ } : state.changes.rows;
156
+ let completed = true;
157
+ const _temp9 = _forOf(Object.keys(changes), function (rowId) {
158
+ const status = getRowStatus(rowId);
159
+ return _catch(function () {
160
+ function _temp8(_result) {
161
+ return _exit ? _result : Promise.resolve(handleSave(changeSet)).then(function () {
162
+ // cleanup changes, we don't need them after saving
163
+ discardChanges(rowId, table);
164
+ // show the saved status, then remove it after a delay
165
+ setRowStatus(rowId, 'saved');
166
+ setTimeout(() => {
167
+ setRowStatus(rowId, undefined);
168
+ }, DELAY_BEFORE_REMOVING_SAVE_STATUS);
169
+ });
170
+ }
171
+ // don't try to save if - already saving, or there are known errors
172
+ if (status === 'saving' || status === 'errored') {
173
+ return;
174
+ }
175
+ setRowStatus(rowId, 'saving');
176
+ const changeSet = {
177
+ ...state.changes.originals[rowId],
178
+ ...changes[rowId]
179
+ };
180
+ // if we had to create a temporary id, delete it first - it's our data, not theirs
181
+ if (isTemporaryRow(changeSet[rowIdentityAccessor])) {
182
+ delete changeSet[rowIdentityAccessor];
183
+ }
184
+ // re-run validation, maybe a cell is already invalid but has never been blurred
185
+ const _temp7 = function () {
186
+ if (validator) {
187
+ return Promise.resolve(validator(changeSet)).then(function (errors) {
188
+ if (errors && Object.keys(errors).length) {
189
+ throw errors;
190
+ }
191
+ });
192
+ }
193
+ }();
194
+ return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7); // send new data to the server
195
+ }, function (error) {
196
+ var _error$response;
197
+ if (error instanceof ReferenceError || error instanceof TypeError || (error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) >= 500) {
198
+ console.error(error);
199
+ }
200
+ // the onEditingSave handler should throw errors when something fails, e.g. validation, network errors etc
201
+ // this code handles those errors and maps them either to row errors or cell specific errors
202
+ let rowError;
203
+ let cellErrors;
204
+ if (typeof error === 'string') {
205
+ rowError = error;
206
+ } else if (error instanceof Error) {
207
+ var _error$response2;
208
+ rowError = error.message;
209
+ // most of our apis return error objects within this shape
210
+ if (typeof ((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data) === 'object') {
211
+ var _error$response3;
212
+ cellErrors = (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data;
213
+ }
214
+ } else if (typeof error === 'object') {
215
+ cellErrors = error;
216
+ }
217
+ if (rowError || cellErrors) {
218
+ dispatch({
219
+ type: 'setRowErrors',
220
+ rowId,
221
+ payload: {
222
+ row: rowError,
223
+ cells: cellErrors,
224
+ shouldShowErrorAlert: true
225
+ }
226
+ });
227
+ }
228
+ setRowStatus(rowId, 'errored');
229
+ completed = false;
230
+ });
231
+ }, function () {
232
+ return _exit;
233
+ });
234
+ return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(function (_result3) {
235
+ return _exit ? _result3 : completed;
236
+ }) : _exit ? _temp9 : completed);
237
+ } catch (e) {
238
+ return Promise.reject(e);
239
+ }
240
+ };
241
+ const onCellChanged = function (cell, rowIndex) {
242
+ try {
243
+ function _temp6() {
244
+ var _state$changes$errors8;
245
+ function _temp4() {
246
+ // only set errors and move reasons for the cells we're currently acting on
247
+ // why? because the UX is not good if we set them for cells the user hasn't touched yet
248
+ const cellsToActOn = [cell.column.id, ...Object.keys(updatesForOtherCells)];
249
+ const allCells = cell.row._getAllCellsByColumnId();
250
+ cellsToActOn.forEach(accessor => {
251
+ if (validationErrors[accessor]) {
252
+ nextCellErrors[accessor] = validationErrors[accessor];
253
+ // don't show move indicator for cells with errors, they aren't valid and can't be saved
254
+ delete nextMoveReasons[accessor];
255
+ } else {
256
+ var _allCells$accessor;
257
+ // there isn't any error in this run, remove any error set in state
258
+ delete nextCellErrors[accessor];
259
+ if ((_allCells$accessor = allCells[accessor]) !== null && _allCells$accessor !== void 0 && _allCells$accessor.column.getIsSorted()) {
260
+ // run row move determination
261
+ const reason = willRowMove(cell, nextChanges[accessor], rowIndex, localization);
262
+ // if the row will move based on this change save why, otherwise delete any existing state
263
+ if (reason) {
264
+ nextMoveReasons[accessor] = reason;
265
+ } else {
266
+ delete nextMoveReasons[accessor];
267
+ }
268
+ }
269
+ }
270
+ });
271
+ dispatch({
272
+ type: 'updateRow',
273
+ rowId: cell.row.id,
274
+ payload: {
275
+ cellErrors: nextCellErrors,
276
+ moveReasons: nextMoveReasons,
277
+ value: nextChanges
278
+ }
279
+ });
280
+ }
281
+ // create a projection of the next state, so we can act against it
282
+ const nextChanges = {
283
+ ...state.changes.rows[cell.row.id],
284
+ ...updatesForOtherCells
285
+ };
286
+ const nextMoveReasons = {
287
+ ...state.changes.moveReasons[cell.row.id]
288
+ };
289
+ const nextCellErrors = {
290
+ ...((_state$changes$errors8 = state.changes.errors[cell.row.id]) === null || _state$changes$errors8 === void 0 ? void 0 : _state$changes$errors8.cells)
291
+ };
292
+ // run validation
293
+ let validationErrors = {};
294
+ const _temp3 = function () {
295
+ if (validator) {
296
+ const nextRowValue = {
297
+ ...state.changes.originals[cell.row.id],
298
+ ...changes,
299
+ ...updatesForOtherCells
300
+ };
301
+ return Promise.resolve(validator(nextRowValue)).then(function (_validator2) {
302
+ validationErrors = _validator2 !== null && _validator2 !== void 0 ? _validator2 : {};
303
+ });
304
+ }
305
+ }();
306
+ return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
307
+ }
308
+ const changes = state.changes.rows[cell.row.id];
309
+ if (!changes) {
310
+ return Promise.resolve();
311
+ }
312
+ let updatesForOtherCells = {};
313
+ // run the updater handler if there is one, to see if there are any other cells to update
314
+ const _temp5 = function () {
315
+ if (typeof handleChange === 'function') {
316
+ const previousRowValue = {
317
+ ...state.changes.originals[cell.row.id]
318
+ };
319
+ const nextRowValue = {
320
+ ...state.changes.originals[cell.row.id],
321
+ ...changes
322
+ };
323
+ return Promise.resolve(handleChange(cell.column.id, changes[cell.column.id], nextRowValue, previousRowValue)).then(function (_handleChange) {
324
+ updatesForOtherCells = _handleChange !== null && _handleChange !== void 0 ? _handleChange : {};
325
+ });
326
+ }
327
+ }();
328
+ return Promise.resolve(_temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5));
329
+ } catch (e) {
330
+ return Promise.reject(e);
331
+ }
332
+ }; // general
333
+ const createRow = function (data) {
334
+ try {
335
+ const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${v4()}`;
336
+ const value = {
337
+ ...data,
338
+ [rowIdentityAccessor]: newRowId
339
+ };
340
+ dispatch({
341
+ type: 'createRow',
342
+ rowId: newRowId,
343
+ payload: {
344
+ value
345
+ }
346
+ });
347
+ return Promise.resolve(newRowId);
348
+ } catch (e) {
349
+ return Promise.reject(e);
350
+ }
351
+ }; // cells
352
+ // rows
353
+ const setRowValue = function (rowId, original, value) {
354
+ try {
355
+ function _temp2() {
356
+ dispatch({
357
+ type: 'updateRow',
358
+ rowId,
359
+ payload: {
360
+ cellErrors,
361
+ original,
362
+ value
363
+ }
364
+ });
365
+ }
366
+ let cellErrors;
367
+ const _temp = function () {
368
+ if (validator) {
369
+ const row = {
370
+ ...original,
371
+ ...value
372
+ };
373
+ return Promise.resolve(validator(row)).then(function (_validator) {
374
+ cellErrors = _validator !== null && _validator !== void 0 ? _validator : {};
375
+ });
376
+ }
377
+ }();
378
+ return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
379
+ } catch (e) {
380
+ return Promise.reject(e);
381
+ }
382
+ };
383
+ const localization = useLocalization();
384
+ const [state, dispatch] = React__default.useReducer(reducer, {
385
+ changes: {
386
+ rows: {},
387
+ errors: {},
388
+ moveReasons: {},
389
+ originals: {},
390
+ status: {}
391
+ },
392
+ temporaryRows: []
393
+ });
394
+ function getRowValue(rowId) {
395
+ var _state$changes$rows$r, _state$changes$rows;
396
+ return (_state$changes$rows$r = (_state$changes$rows = state.changes.rows) === null || _state$changes$rows === void 0 ? void 0 : _state$changes$rows[rowId]) !== null && _state$changes$rows$r !== void 0 ? _state$changes$rows$r : undefined;
397
+ }
398
+ function getRowMoveReason(rowId) {
399
+ var _Object$values$, _state$changes$moveRe, _state$changes$moveRe2;
400
+ return (_Object$values$ = Object.values((_state$changes$moveRe = (_state$changes$moveRe2 = state.changes.moveReasons) === null || _state$changes$moveRe2 === void 0 ? void 0 : _state$changes$moveRe2[rowId]) !== null && _state$changes$moveRe !== void 0 ? _state$changes$moveRe : {})[0]) !== null && _Object$values$ !== void 0 ? _Object$values$ : undefined;
401
+ }
402
+ function hasRowErrors(rowId) {
403
+ var _state$changes$errors, _state$changes$errors2, _state$changes$errors3;
404
+ return !!((_state$changes$errors = state.changes.errors[rowId]) !== null && _state$changes$errors !== void 0 && _state$changes$errors.row) || !!Object.keys((_state$changes$errors2 = (_state$changes$errors3 = state.changes.errors[rowId]) === null || _state$changes$errors3 === void 0 ? void 0 : _state$changes$errors3.cells) !== null && _state$changes$errors2 !== void 0 ? _state$changes$errors2 : {}).length;
405
+ }
406
+ function hasRowErrorsShownInAlert(rowId) {
407
+ var _state$changes$errors4;
408
+ return hasRowErrors(rowId) && !!((_state$changes$errors4 = state.changes.errors[rowId]) !== null && _state$changes$errors4 !== void 0 && _state$changes$errors4.shouldShowErrorAlert);
409
+ }
410
+ function getRowStatus(rowId) {
411
+ return state.changes.status[rowId];
412
+ }
413
+ function setRowStatus(rowId, status) {
414
+ dispatch({
415
+ type: 'setRowStatus',
416
+ rowId,
417
+ payload: {
418
+ status
419
+ }
420
+ });
421
+ }
422
+ function setCellValue(cell, value) {
423
+ const rowId = cell.row.id;
424
+ const columnId = cell.column.id;
425
+ // update if the change is different to the original value
426
+ if (value !== cell.row.original[columnId]) {
427
+ dispatch({
428
+ type: 'setCellValue',
429
+ rowId,
430
+ payload: {
431
+ columnId,
432
+ row: cell.row.original,
433
+ value
434
+ }
435
+ });
436
+ }
437
+ // otherwise remove any previous change - no point saving the same value
438
+ else if (cell.row.id in state.changes.rows) {
439
+ dispatch({
440
+ type: 'removeCellValue',
441
+ rowId,
442
+ payload: {
443
+ columnId,
444
+ rowIdentityAccessor
445
+ }
446
+ });
447
+ }
448
+ }
449
+ function getCellValue(cell) {
450
+ var _state$changes$rows2, _state$changes$rows2$;
451
+ return (_state$changes$rows2 = state.changes.rows) === null || _state$changes$rows2 === void 0 ? void 0 : (_state$changes$rows2$ = _state$changes$rows2[cell.row.id]) === null || _state$changes$rows2$ === void 0 ? void 0 : _state$changes$rows2$[cell.column.id];
452
+ }
453
+ function getCellError(cell) {
454
+ var _state$changes$errors5, _state$changes$errors6, _state$changes$errors7;
455
+ return (_state$changes$errors5 = state.changes.errors) === null || _state$changes$errors5 === void 0 ? void 0 : (_state$changes$errors6 = _state$changes$errors5[cell.row.id]) === null || _state$changes$errors6 === void 0 ? void 0 : (_state$changes$errors7 = _state$changes$errors6.cells) === null || _state$changes$errors7 === void 0 ? void 0 : _state$changes$errors7[cell.column.id];
456
+ }
457
+ function getErrorsShownInAlert() {
458
+ const rowsWithErrors = Object.keys(state.changes.errors);
459
+ if (!rowsWithErrors.length) {
460
+ return [];
461
+ }
462
+ return rowsWithErrors.filter(hasRowErrorsShownInAlert).map(rowId => ({
463
+ rowId,
464
+ changes: state.changes.rows[rowId],
465
+ errors: state.changes.errors[rowId]
466
+ }));
467
+ }
468
+ function hasSaved() {
469
+ return !!Object.values(state.changes.status).filter(value => value === 'saved').length;
470
+ }
471
+ function hasChanges(rowId) {
472
+ return rowId ? !!state.changes.rows[rowId] : !!Object.keys(state.changes.rows).length;
473
+ }
474
+ function discardChanges(rowId, table) {
475
+ // remove any new rows from pinned state before discarding them
476
+ table.resetRowPinning(true);
477
+ dispatch({
478
+ type: 'removeRow',
479
+ rowId,
480
+ payload: {
481
+ rowIdentityAccessor
482
+ }
483
+ });
484
+ }
485
+ return {
486
+ // row
487
+ setRowValue,
488
+ getRowValue,
489
+ getRowMoveReason,
490
+ hasRowErrors,
491
+ hasRowErrorsShownInAlert,
492
+ getRowStatus,
493
+ setRowStatus,
494
+ // cells
495
+ setCellValue,
496
+ getCellValue,
497
+ getCellError,
498
+ onCellChanged,
499
+ // general
500
+ getErrorsShownInAlert,
501
+ hasChanges,
502
+ saveChanges,
503
+ discardChanges,
504
+ hasSaved,
505
+ // new rows
506
+ createRow,
507
+ temporaryRows: state.temporaryRows
508
+ };
509
+ }
510
+
511
+ export { usePendingChangesState };
512
+ //# sourceMappingURL=useEditingState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEditingState.js","sources":["../../../../../../../../src/components/Table3/features/useEditingState.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, Cell as ReactTableCell } from '@tanstack/react-table';\nimport { v4 as uuid } from 'uuid';\nimport omit from 'lodash/omit';\nimport setWith from 'lodash/setWith';\nimport { Table3EditingChangeHandler, Table3EditingSaveHandler, Table3EditingValidatorFn } from '../types';\nimport { isTemporaryRow, TEMPORARY_ROW_ID_PREFIX, willRowMove } from '../util/editing';\nimport { useLocalization } from '../../Provider/Localization';\n\nconst DELAY_BEFORE_REMOVING_SAVE_STATUS = 3000;\n\ntype EditingError = {\n row: string;\n cells: Record<string, string>;\n shouldShowErrorAlert: boolean;\n};\ntype EditingRowMoveReason = Record<string, 'search' | 'sorting' | 'filter'>;\ntype EditingSaveState = 'saving' | 'saved' | 'errored';\ntype EditingChangeset<TType = unknown> = Partial<TType>;\ntype EditingState<TType = unknown> = {\n changes: {\n rows: Record<string, EditingChangeset<TType>>;\n errors: Record<string, EditingError>;\n moveReasons: Record<string, EditingRowMoveReason>;\n originals: Record<string, TType>;\n status: Record<string, EditingSaveState>;\n };\n temporaryRows: TType[];\n};\ntype EditingStateAction = {\n type:\n | 'setCellValue'\n | 'removeCellValue'\n | 'updateRow'\n | 'mergeRowValue'\n | 'removeRow'\n | 'setRowStatus'\n | 'setRowErrors'\n | 'createRow';\n rowId: string;\n payload?: any;\n};\n\nfunction reducer<TType = unknown>(state: EditingState<TType>, action: EditingStateAction) {\n const { type, rowId, payload } = action;\n\n switch (type) {\n case 'setCellValue': {\n const { columnId, row, value } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, `${rowId}.${columnId}`, value, Object),\n originals: setWith(state.changes.originals, rowId, row, Object),\n },\n };\n }\n\n case 'removeCellValue': {\n const { columnId, rowIdentityAccessor } = payload;\n const changes = omit(state.changes.rows, `${rowId}.${columnId}`);\n\n // if there are no changes left, remove the row\n if (!Object.keys(changes[rowId]).length) {\n return reducer(state, { type: 'removeRow', rowId, payload: { rowIdentityAccessor } });\n }\n\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: omit(state.changes.rows, `${rowId}.${columnId}`),\n errors: omit(state.changes.errors, `${rowId}.cells.${columnId}`),\n moveReasons: omit(state.changes.moveReasons, `${rowId}.${columnId}`),\n },\n };\n }\n\n case 'updateRow': {\n const { cellErrors, moveReasons, original, value } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, rowId, value, Object),\n errors: setWith(\n state.changes.errors,\n `${rowId}.cells`,\n cellErrors ?? state.changes.errors.cells[rowId],\n Object\n ),\n originals: setWith(state.changes.originals, rowId, original ?? state.changes.originals[rowId], Object),\n moveReasons: setWith(\n state.changes.moveReasons,\n rowId,\n moveReasons ?? state.changes.moveReasons[rowId],\n Object\n ),\n // status can be undefined, so don't use ??\n status: setWith(state.changes.status, rowId, undefined, Object),\n },\n };\n }\n\n case 'removeRow': {\n const { rowIdentityAccessor } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: omit(state.changes.rows, rowId),\n errors: omit(state.changes.errors, rowId),\n moveReasons: omit(state.changes.moveReasons, rowId),\n originals: omit(state.changes.originals, rowId),\n status: omit(state.changes.status, rowId),\n },\n temporaryRows: state.temporaryRows.filter(row => row[rowIdentityAccessor] !== rowId),\n };\n }\n\n case 'setRowStatus': {\n const { status } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n status: status ? setWith(state.changes.status, rowId, status, Object) : omit(state.changes.status, rowId),\n },\n };\n }\n\n case 'setRowErrors': {\n const { ...errors } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n errors: setWith(state.changes.errors, rowId, errors, Object),\n },\n };\n }\n\n case 'createRow': {\n const { value } = payload;\n return {\n ...state,\n temporaryRows: state.temporaryRows.concat(value),\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, rowId, value, Object),\n originals: setWith(state.changes.originals, rowId, value, Object),\n },\n };\n }\n\n default:\n return state;\n }\n}\n\nexport function usePendingChangesState<TType = unknown>(\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n rowIdentityAccessor: keyof TType,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n const localization = useLocalization();\n const [state, dispatch] = React.useReducer(reducer, {\n changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, status: {} },\n temporaryRows: [],\n });\n\n // rows\n async function setRowValue<T extends TType>(rowId: string, original: T, value: Partial<T>) {\n let cellErrors;\n\n if (validator) {\n const row = { ...original, ...value } as T;\n cellErrors = ((await validator(row)) ?? {}) as Record<string, string>;\n }\n\n dispatch({\n type: 'updateRow',\n rowId,\n payload: { cellErrors, original, value },\n });\n }\n\n function getRowValue(rowId: string) {\n return state.changes.rows?.[rowId] ?? undefined;\n }\n\n function getRowMoveReason(rowId: string) {\n return Object.values(state.changes.moveReasons?.[rowId] ?? {})[0] ?? undefined;\n }\n\n function hasRowErrors(rowId: string) {\n return !!state.changes.errors[rowId]?.row || !!Object.keys(state.changes.errors[rowId]?.cells ?? {}).length;\n }\n\n function hasRowErrorsShownInAlert(rowId: string) {\n return hasRowErrors(rowId) && !!state.changes.errors[rowId]?.shouldShowErrorAlert;\n }\n\n function getRowStatus(rowId: string) {\n return state.changes.status[rowId];\n }\n\n function setRowStatus(rowId: string, status: EditingSaveState | undefined) {\n dispatch({\n type: 'setRowStatus',\n rowId,\n payload: {\n status,\n },\n });\n }\n\n async function createRow<T extends TType>(data: Partial<T>) {\n const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${uuid()}`;\n const value: Partial<TType> = {\n ...data,\n [rowIdentityAccessor]: newRowId,\n };\n\n dispatch({\n type: 'createRow',\n rowId: newRowId,\n payload: { value },\n });\n\n return newRowId;\n }\n\n // cells\n function setCellValue<T extends TType>(cell: ReactTableCell<T, unknown>, value: unknown) {\n const rowId = cell.row.id;\n const columnId = cell.column.id;\n\n // update if the change is different to the original value\n if (value !== cell.row.original[columnId]) {\n dispatch({\n type: 'setCellValue',\n rowId,\n payload: {\n columnId,\n row: cell.row.original,\n value,\n },\n });\n }\n // otherwise remove any previous change - no point saving the same value\n else if (cell.row.id in state.changes.rows) {\n dispatch({\n type: 'removeCellValue',\n rowId,\n payload: {\n columnId,\n rowIdentityAccessor,\n },\n });\n }\n }\n\n function getCellValue<T extends TType>(cell: ReactTableCell<T, unknown>): unknown | undefined {\n return state.changes.rows?.[cell.row.id]?.[cell.column.id];\n }\n\n function getCellError<T extends TType>(cell: ReactTableCell<T, unknown>): string | undefined {\n return state.changes.errors?.[cell.row.id]?.cells?.[cell.column.id];\n }\n\n async function onCellChanged<T extends TType>(cell: ReactTableCell<T, unknown>, rowIndex: number) {\n const changes = state.changes.rows[cell.row.id];\n\n if (!changes) {\n return;\n }\n\n let updatesForOtherCells: Partial<T> = {};\n\n // run the updater handler if there is one, to see if there are any other cells to update\n if (typeof handleChange === 'function') {\n const previousRowValue = {\n ...state.changes.originals[cell.row.id],\n //...getRowChangeset(updatersRef.current[cell.row.id], rowIdentityAccessor),\n };\n const nextRowValue = {\n ...state.changes.originals[cell.row.id],\n ...changes,\n };\n updatesForOtherCells = ((await handleChange(\n cell.column.id,\n changes[cell.column.id],\n nextRowValue,\n previousRowValue\n )) ?? {}) as Partial<T>;\n }\n\n // create a projection of the next state, so we can act against it\n const nextChanges = { ...state.changes.rows[cell.row.id], ...updatesForOtherCells };\n const nextMoveReasons: EditingRowMoveReason = { ...state.changes.moveReasons[cell.row.id] };\n const nextCellErrors: Record<string, string> = { ...state.changes.errors[cell.row.id]?.cells };\n\n // run validation\n let validationErrors: Record<string, string> = {};\n\n if (validator) {\n const nextRowValue = { ...state.changes.originals[cell.row.id], ...changes, ...updatesForOtherCells };\n validationErrors = ((await validator(nextRowValue)) ?? {}) as Record<string, string>;\n }\n\n // only set errors and move reasons for the cells we're currently acting on\n // why? because the UX is not good if we set them for cells the user hasn't touched yet\n const cellsToActOn = [cell.column.id, ...Object.keys(updatesForOtherCells)];\n const allCells = cell.row._getAllCellsByColumnId();\n\n cellsToActOn.forEach(accessor => {\n if (validationErrors[accessor]) {\n nextCellErrors[accessor] = validationErrors[accessor];\n // don't show move indicator for cells with errors, they aren't valid and can't be saved\n delete nextMoveReasons[accessor];\n } else {\n // there isn't any error in this run, remove any error set in state\n delete nextCellErrors[accessor];\n\n if (allCells[accessor]?.column.getIsSorted()) {\n // run row move determination\n const reason = willRowMove(cell, nextChanges[accessor], rowIndex, localization);\n\n // if the row will move based on this change save why, otherwise delete any existing state\n if (reason) {\n nextMoveReasons[accessor] = reason;\n } else {\n delete nextMoveReasons[accessor];\n }\n }\n }\n });\n\n dispatch({\n type: 'updateRow',\n rowId: cell.row.id,\n payload: {\n cellErrors: nextCellErrors,\n moveReasons: nextMoveReasons,\n value: nextChanges,\n },\n });\n }\n\n // general\n function getErrorsShownInAlert<T extends TType>() {\n const rowsWithErrors = Object.keys(state.changes.errors);\n\n if (!rowsWithErrors.length) {\n return [];\n }\n\n return rowsWithErrors.filter(hasRowErrorsShownInAlert).map(rowId => ({\n rowId,\n changes: state.changes.rows[rowId] as EditingChangeset<T>,\n errors: state.changes.errors[rowId],\n }));\n }\n\n function hasSaved() {\n return !!Object.values(state.changes.status).filter(value => value === 'saved').length;\n }\n\n function hasChanges(rowId?: string) {\n return rowId ? !!state.changes.rows[rowId] : !!Object.keys(state.changes.rows).length;\n }\n\n async function saveChanges<T extends TType>(table: ReactTable<T>, rowId: string | undefined = undefined): Promise<boolean> {\n if (!handleSave) {\n console.warn('Tried to save, but Table has no onEditingSave handler');\n return false;\n }\n\n // sometimes we only want to save one row\n const changes = rowId ? { [rowId]: state.changes.rows[rowId] } : state.changes.rows;\n\n let completed = true;\n\n for (const rowId of Object.keys(changes)) {\n const status = getRowStatus(rowId);\n\n try {\n // don't try to save if - already saving, or there are known errors\n if (status === 'saving' || status === 'errored') {\n continue;\n }\n\n setRowStatus(rowId, 'saving');\n\n const changeSet = { ...state.changes.originals[rowId], ...changes[rowId] };\n\n // if we had to create a temporary id, delete it first - it's our data, not theirs\n if (isTemporaryRow(changeSet[rowIdentityAccessor as string])) {\n delete changeSet[rowIdentityAccessor];\n }\n\n // re-run validation, maybe a cell is already invalid but has never been blurred\n if (validator) {\n const errors = await validator(changeSet);\n\n if (errors && Object.keys(errors).length) {\n throw errors;\n }\n }\n\n // send new data to the server\n await handleSave(changeSet);\n\n // cleanup changes, we don't need them after saving\n discardChanges(rowId, table);\n\n // show the saved status, then remove it after a delay\n setRowStatus(rowId, 'saved');\n setTimeout(() => {\n setRowStatus(rowId, undefined);\n }, DELAY_BEFORE_REMOVING_SAVE_STATUS);\n } catch (error) {\n if (error instanceof ReferenceError || error instanceof TypeError || (error as any)?.response?.status >= 500) {\n console.error(error);\n }\n\n // the onEditingSave handler should throw errors when something fails, e.g. validation, network errors etc\n // this code handles those errors and maps them either to row errors or cell specific errors\n let rowError: string | undefined;\n let cellErrors;\n\n if (typeof error === 'string') {\n rowError = error;\n } else if (error instanceof Error) {\n rowError = error.message;\n\n // most of our apis return error objects within this shape\n if (typeof (error as any).response?.data === 'object') {\n cellErrors = (error as any).response?.data;\n }\n } else if (typeof error === 'object') {\n cellErrors = error;\n }\n\n if (rowError || cellErrors) {\n dispatch({\n type: 'setRowErrors',\n rowId,\n payload: {\n row: rowError,\n cells: cellErrors,\n shouldShowErrorAlert: true,\n },\n });\n }\n\n setRowStatus(rowId, 'errored');\n completed = false;\n }\n }\n\n return completed;\n }\n\n function discardChanges<T extends TType>(rowId: string, table: ReactTable<T>) {\n // remove any new rows from pinned state before discarding them\n table.resetRowPinning(true);\n\n dispatch({\n type: 'removeRow',\n rowId,\n payload: { rowIdentityAccessor },\n });\n }\n\n return {\n // row\n setRowValue,\n getRowValue,\n getRowMoveReason,\n hasRowErrors,\n hasRowErrorsShownInAlert,\n getRowStatus,\n setRowStatus,\n // cells\n setCellValue,\n getCellValue,\n getCellError,\n onCellChanged,\n // general\n getErrorsShownInAlert,\n hasChanges,\n saveChanges,\n discardChanges,\n hasSaved,\n // new rows\n createRow,\n temporaryRows: state.temporaryRows,\n };\n}\n"],"names":["DELAY_BEFORE_REMOVING_SAVE_STATUS","reducer","state","action","type","rowId","payload","columnId","row","value","changes","rows","setWith","Object","originals","rowIdentityAccessor","omit","keys","length","errors","moveReasons","cellErrors","original","cells","status","undefined","temporaryRows","filter","concat","usePendingChangesState","handleSave","handleChange","validator","saveChanges","table","console","warn","Promise","resolve","completed","_temp9","_forOf","getRowStatus","_catch","_temp8","_result","_exit","changeSet","then","discardChanges","setRowStatus","setTimeout","isTemporaryRow","_temp7","error","_error$response","ReferenceError","TypeError","response","rowError","Error","_error$response2","message","data","_error$response3","dispatch","shouldShowErrorAlert","_result3","e","reject","onCellChanged","cell","rowIndex","cellsToActOn","column","id","updatesForOtherCells","allCells","_getAllCellsByColumnId","forEach","accessor","validationErrors","nextCellErrors","nextMoveReasons","_allCells$accessor","getIsSorted","reason","willRowMove","nextChanges","localization","_state$changes$errors8","_temp3","nextRowValue","_validator2","_temp4","_temp5","previousRowValue","_handleChange","_temp6","createRow","newRowId","TEMPORARY_ROW_ID_PREFIX","uuid","setRowValue","_temp","_validator","_temp2","useLocalization","React","useReducer","getRowValue","_state$changes$rows$r","_state$changes$rows","getRowMoveReason","_Object$values$","values","_state$changes$moveRe","_state$changes$moveRe2","hasRowErrors","_state$changes$errors","_state$changes$errors2","_state$changes$errors3","hasRowErrorsShownInAlert","_state$changes$errors4","setCellValue","getCellValue","_state$changes$rows2","_state$changes$rows2$","getCellError","_state$changes$errors5","_state$changes$errors6","_state$changes$errors7","getErrorsShownInAlert","rowsWithErrors","map","hasSaved","hasChanges","resetRowPinning"],"mappings":";;;;;;;;AASA,MAAMA,iCAAiC,GAAG,IAAI;AAkC9C,SAASC,OAAOA,CAAkBC,KAA0B,EAAEC,MAA0B;EACpF,MAAM;IAAEC,IAAI;IAAEC,KAAK;IAAEC;GAAS,GAAGH,MAAM;EAEvC,QAAQC,IAAI;IACR,KAAK,cAAc;MAAE;QACjB,MAAM;UAAEG,QAAQ;UAAEC,GAAG;UAAEC;SAAO,GAAGH,OAAO;QACxC,OAAO;UACH,GAAGJ,KAAK;UACRQ,OAAO,EAAE;YACL,GAAGR,KAAK,CAACQ,OAAO;YAChBC,IAAI,EAAEC,OAAO,CAACV,KAAK,CAACQ,OAAO,CAACC,IAAI,EAAE,GAAGN,KAAK,IAAIE,QAAQ,EAAE,EAAEE,KAAK,EAAEI,MAAM,CAAC;YACxEC,SAAS,EAAEF,OAAO,CAACV,KAAK,CAACQ,OAAO,CAACI,SAAS,EAAET,KAAK,EAAEG,GAAG,EAAEK,MAAM;;SAErE;;IAGL,KAAK,iBAAiB;MAAE;QACpB,MAAM;UAAEN,QAAQ;UAAEQ;SAAqB,GAAGT,OAAO;QACjD,MAAMI,OAAO,GAAGM,IAAI,CAACd,KAAK,CAACQ,OAAO,CAACC,IAAI,EAAE,GAAGN,KAAK,IAAIE,QAAQ,EAAE,CAAC;;QAGhE,IAAI,CAACM,MAAM,CAACI,IAAI,CAACP,OAAO,CAACL,KAAK,CAAC,CAAC,CAACa,MAAM,EAAE;UACrC,OAAOjB,OAAO,CAACC,KAAK,EAAE;YAAEE,IAAI,EAAE,WAAW;YAAEC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