@economic/taco 2.15.0 → 2.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. package/dist/components/Drawer/Drawer.d.ts +5 -1
  2. package/dist/components/Provider/Localization.d.ts +19 -0
  3. package/dist/components/SearchInput2/SearchInput2.d.ts +1 -0
  4. package/dist/components/Table3/components/alert/ErrorAlert.d.ts +10 -0
  5. package/dist/components/Table3/components/columns/cell/DisplayCell.d.ts +5 -2
  6. package/dist/components/Table3/components/columns/cell/EditingCell.d.ts +3 -0
  7. package/dist/components/Table3/components/columns/cell/Highlight.d.ts +2 -0
  8. package/dist/components/Table3/components/columns/internal/EditingActions.d.ts +1 -1
  9. package/dist/components/Table3/components/rows/Row.d.ts +2 -0
  10. package/dist/components/Table3/components/rows/RowContext.d.ts +1 -0
  11. package/dist/components/Table3/hooks/features/useEditing.d.ts +12 -11
  12. package/dist/components/Table3/hooks/features/usePauseShortcuts.d.ts +5 -0
  13. package/dist/components/Table3/hooks/features/useSearch.d.ts +2 -0
  14. package/dist/components/Table3/hooks/features/useValidation.d.ts +13 -0
  15. package/dist/components/Table3/hooks/useTable.d.ts +4 -0
  16. package/dist/components/Table3/types.d.ts +26 -1
  17. package/dist/components/Table3/util/editing.d.ts +6 -0
  18. package/dist/esm/index.css +108 -33
  19. package/dist/esm/packages/taco/src/components/Drawer/Drawer.js +7 -2
  20. package/dist/esm/packages/taco/src/components/Drawer/Drawer.js.map +1 -1
  21. package/dist/esm/packages/taco/src/components/Provider/Localization.js +19 -0
  22. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  23. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js +4 -0
  24. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js.map +1 -1
  25. package/dist/esm/packages/taco/src/components/Table3/Table3.js +7 -1
  26. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  27. package/dist/esm/packages/taco/src/components/Table3/components/alert/ErrorAlert.js +154 -0
  28. package/dist/esm/packages/taco/src/components/Table3/components/alert/ErrorAlert.js.map +1 -0
  29. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js +51 -6
  30. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js.map +1 -1
  31. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +7 -55
  32. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map +1 -1
  33. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +69 -37
  34. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
  35. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js +17 -17
  36. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js.map +1 -1
  37. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Highlight.js +41 -0
  38. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Highlight.js.map +1 -0
  39. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextareaControl.js +21 -12
  40. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextareaControl.js.map +1 -1
  41. package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Footer.js +1 -1
  42. package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Footer.js.map +1 -1
  43. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js +57 -17
  44. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js.map +1 -1
  45. package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js +39 -31
  46. package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js.map +1 -1
  47. package/dist/esm/packages/taco/src/components/Table3/components/rows/RowContext.js +2 -1
  48. package/dist/esm/packages/taco/src/components/Table3/components/rows/RowContext.js.map +1 -1
  49. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js +8 -1
  50. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js.map +1 -1
  51. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js +48 -1
  52. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js.map +1 -1
  53. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useEditing.js +185 -101
  54. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useEditing.js.map +1 -1
  55. package/dist/esm/packages/taco/src/components/Table3/hooks/features/usePauseShortcuts.js +12 -0
  56. package/dist/esm/packages/taco/src/components/Table3/hooks/features/usePauseShortcuts.js.map +1 -0
  57. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSearch.js +4 -1
  58. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSearch.js.map +1 -1
  59. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useValidation.js +178 -0
  60. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useValidation.js.map +1 -0
  61. package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js +1 -1
  62. package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js.map +1 -1
  63. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js +8 -2
  64. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
  65. package/dist/esm/packages/taco/src/components/Table3/strategies/virtualised.js +1 -1
  66. package/dist/esm/packages/taco/src/components/Table3/types.js.map +1 -1
  67. package/dist/esm/packages/taco/src/components/Table3/util/editing.js +21 -1
  68. package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
  69. package/dist/index.css +108 -33
  70. package/dist/taco.cjs.development.js +2605 -1970
  71. package/dist/taco.cjs.development.js.map +1 -1
  72. package/dist/taco.cjs.production.min.js +1 -1
  73. package/dist/taco.cjs.production.min.js.map +1 -1
  74. package/package.json +2 -2
  75. package/types.json +10973 -7880
@@ -1,6 +1,7 @@
1
1
  import React__default from 'react';
2
2
 
3
3
  function useSearch(isEnabled, excludeUnmatchedResultsInSearch = false, loadAll) {
4
+ const [isSearching, setIsSearching] = React__default.useState(false);
4
5
  const [query, setQuery] = React__default.useState();
5
6
  const [enableHighlighting, setEnableHighlighting] = React__default.useState(true);
6
7
  const [excludeUnmatchedResults, setExcludeUnmatchedResults] = React__default.useState(excludeUnmatchedResultsInSearch);
@@ -19,7 +20,9 @@ function useSearch(isEnabled, excludeUnmatchedResultsInSearch = false, loadAll)
19
20
  setHighlightedColumnIndexes,
20
21
  currentHighlightColumnIndex,
21
22
  setCurrentHighlightColumnIndex,
22
- loadAll
23
+ loadAll,
24
+ isSearching,
25
+ setIsSearching
23
26
  };
24
27
  }
25
28
 
@@ -1 +1 @@
1
- {"version":3,"file":"useSearch.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useSearch.ts"],"sourcesContent":["import React from 'react';\nimport { Table3LoadAllHandler } from '../../types';\n\nexport function useSearch(isEnabled: boolean, excludeUnmatchedResultsInSearch = false, loadAll?: Table3LoadAllHandler) {\n const [query, setQuery] = React.useState<string | undefined>();\n const [enableHighlighting, setEnableHighlighting] = React.useState<boolean>(true);\n const [excludeUnmatchedResults, setExcludeUnmatchedResults] = React.useState<boolean>(excludeUnmatchedResultsInSearch);\n\n // highlighting\n const [highlightedColumnIndexes, setHighlightedColumnIndexes] = React.useState<number[][]>([]);\n const [currentHighlightColumnIndex, setCurrentHighlightColumnIndex] = React.useState<number | undefined>(undefined);\n\n return {\n isEnabled,\n isHighlightingEnabled: enableHighlighting,\n toggleHighlighting: setEnableHighlighting,\n excludeUnmatchedResults,\n toggleExcludeUnmatchedResults: setExcludeUnmatchedResults,\n query,\n setQuery: isEnabled ? setQuery : () => undefined,\n highlightedColumnIndexes,\n setHighlightedColumnIndexes,\n currentHighlightColumnIndex,\n setCurrentHighlightColumnIndex,\n loadAll,\n };\n}\n"],"names":["useSearch","isEnabled","excludeUnmatchedResultsInSearch","loadAll","query","setQuery","React","useState","enableHighlighting","setEnableHighlighting","excludeUnmatchedResults","setExcludeUnmatchedResults","highlightedColumnIndexes","setHighlightedColumnIndexes","currentHighlightColumnIndex","setCurrentHighlightColumnIndex","undefined","isHighlightingEnabled","toggleHighlighting","toggleExcludeUnmatchedResults"],"mappings":";;SAGgBA,SAASA,CAACC,SAAkB,EAAEC,+BAA+B,GAAG,KAAK,EAAEC,OAA8B;EACjH,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGC,cAAK,CAACC,QAAQ,EAAsB;EAC9D,MAAM,CAACC,kBAAkB,EAAEC,qBAAqB,CAAC,GAAGH,cAAK,CAACC,QAAQ,CAAU,IAAI,CAAC;EACjF,MAAM,CAACG,uBAAuB,EAAEC,0BAA0B,CAAC,GAAGL,cAAK,CAACC,QAAQ,CAAUL,+BAA+B,CAAC;;EAGtH,MAAM,CAACU,wBAAwB,EAAEC,2BAA2B,CAAC,GAAGP,cAAK,CAACC,QAAQ,CAAa,EAAE,CAAC;EAC9F,MAAM,CAACO,2BAA2B,EAAEC,8BAA8B,CAAC,GAAGT,cAAK,CAACC,QAAQ,CAAqBS,SAAS,CAAC;EAEnH,OAAO;IACHf,SAAS;IACTgB,qBAAqB,EAAET,kBAAkB;IACzCU,kBAAkB,EAAET,qBAAqB;IACzCC,uBAAuB;IACvBS,6BAA6B,EAAER,0BAA0B;IACzDP,KAAK;IACLC,QAAQ,EAAEJ,SAAS,GAAGI,QAAQ,GAAG,MAAMW,SAAS;IAChDJ,wBAAwB;IACxBC,2BAA2B;IAC3BC,2BAA2B;IAC3BC,8BAA8B;IAC9BZ;GACH;AACL;;;;"}
1
+ {"version":3,"file":"useSearch.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useSearch.ts"],"sourcesContent":["import React from 'react';\nimport { Table3LoadAllHandler } from '../../types';\n\nexport function useSearch(isEnabled: boolean, excludeUnmatchedResultsInSearch = false, loadAll?: Table3LoadAllHandler) {\n const [isSearching, setIsSearching] = React.useState(false);\n const [query, setQuery] = React.useState<string | undefined>();\n const [enableHighlighting, setEnableHighlighting] = React.useState<boolean>(true);\n const [excludeUnmatchedResults, setExcludeUnmatchedResults] = React.useState<boolean>(excludeUnmatchedResultsInSearch);\n\n // highlighting\n const [highlightedColumnIndexes, setHighlightedColumnIndexes] = React.useState<number[][]>([]);\n const [currentHighlightColumnIndex, setCurrentHighlightColumnIndex] = React.useState<number | undefined>(undefined);\n\n return {\n isEnabled,\n isHighlightingEnabled: enableHighlighting,\n toggleHighlighting: setEnableHighlighting,\n excludeUnmatchedResults,\n toggleExcludeUnmatchedResults: setExcludeUnmatchedResults,\n query,\n setQuery: isEnabled ? setQuery : () => undefined,\n highlightedColumnIndexes,\n setHighlightedColumnIndexes,\n currentHighlightColumnIndex,\n setCurrentHighlightColumnIndex,\n loadAll,\n isSearching,\n setIsSearching,\n };\n}\n"],"names":["useSearch","isEnabled","excludeUnmatchedResultsInSearch","loadAll","isSearching","setIsSearching","React","useState","query","setQuery","enableHighlighting","setEnableHighlighting","excludeUnmatchedResults","setExcludeUnmatchedResults","highlightedColumnIndexes","setHighlightedColumnIndexes","currentHighlightColumnIndex","setCurrentHighlightColumnIndex","undefined","isHighlightingEnabled","toggleHighlighting","toggleExcludeUnmatchedResults"],"mappings":";;SAGgBA,SAASA,CAACC,SAAkB,EAAEC,+BAA+B,GAAG,KAAK,EAAEC,OAA8B;EACjH,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EAC3D,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGH,cAAK,CAACC,QAAQ,EAAsB;EAC9D,MAAM,CAACG,kBAAkB,EAAEC,qBAAqB,CAAC,GAAGL,cAAK,CAACC,QAAQ,CAAU,IAAI,CAAC;EACjF,MAAM,CAACK,uBAAuB,EAAEC,0BAA0B,CAAC,GAAGP,cAAK,CAACC,QAAQ,CAAUL,+BAA+B,CAAC;;EAGtH,MAAM,CAACY,wBAAwB,EAAEC,2BAA2B,CAAC,GAAGT,cAAK,CAACC,QAAQ,CAAa,EAAE,CAAC;EAC9F,MAAM,CAACS,2BAA2B,EAAEC,8BAA8B,CAAC,GAAGX,cAAK,CAACC,QAAQ,CAAqBW,SAAS,CAAC;EAEnH,OAAO;IACHjB,SAAS;IACTkB,qBAAqB,EAAET,kBAAkB;IACzCU,kBAAkB,EAAET,qBAAqB;IACzCC,uBAAuB;IACvBS,6BAA6B,EAAER,0BAA0B;IACzDL,KAAK;IACLC,QAAQ,EAAER,SAAS,GAAGQ,QAAQ,GAAG,MAAMS,SAAS;IAChDJ,wBAAwB;IACxBC,2BAA2B;IAC3BC,2BAA2B;IAC3BC,8BAA8B;IAC9Bd,OAAO;IACPC,WAAW;IACXC;GACH;AACL;;;;"}
@@ -0,0 +1,178 @@
1
+ import React__default from 'react';
2
+
3
+ function useValidation(onCellValidate, onRowValidate) {
4
+ const [validationState, dispatch] = React__default.useReducer(validationReducer, {
5
+ errors: null,
6
+ draftErrors: null
7
+ });
8
+ function getCellError(cell) {
9
+ var _validationState$draf, _validationState$erro;
10
+ return validationState.draftErrors && ((_validationState$draf = validationState.draftErrors[cell.row.id]) === null || _validationState$draf === void 0 ? void 0 : _validationState$draf[cell.column.id]) || (validationState.errors ? (_validationState$erro = validationState.errors[cell.row.id]) === null || _validationState$erro === void 0 ? void 0 : _validationState$erro[cell.column.id] : undefined);
11
+ }
12
+ function setCellError(rowId, cellId, error) {
13
+ dispatch({
14
+ type: ValidationActionType.SET_CELL_ERROR,
15
+ payload: {
16
+ rowId,
17
+ cellId,
18
+ error
19
+ }
20
+ });
21
+ }
22
+ function setRowErrors(rowId, errors) {
23
+ dispatch({
24
+ type: ValidationActionType.SET_ROW_ERROR,
25
+ payload: {
26
+ rowId,
27
+ errors
28
+ }
29
+ });
30
+ }
31
+ function confirmErrors(rowId) {
32
+ dispatch({
33
+ type: ValidationActionType.CONFIRN_ERRORS,
34
+ payload: {
35
+ rowId
36
+ }
37
+ });
38
+ }
39
+ function resetErrors(rowId, cellId) {
40
+ dispatch({
41
+ type: ValidationActionType.RESET_ERRORS,
42
+ payload: {
43
+ rowId,
44
+ cellId
45
+ }
46
+ });
47
+ }
48
+ const setErrors = (errors, rowId, cellId) => {
49
+ if (cellId) {
50
+ setCellError(rowId, cellId, errors[cellId]);
51
+ } else {
52
+ setRowErrors(rowId, errors);
53
+ }
54
+ };
55
+ const validate = (rowId, row, cellId) => {
56
+ let validationPromise;
57
+ if (cellId && onCellValidate) {
58
+ validationPromise = onCellValidate(row[cellId], cellId, row);
59
+ } else if (onRowValidate) {
60
+ validationPromise = onRowValidate(row);
61
+ } else {
62
+ validationPromise = new Promise(resolve => {
63
+ resolve();
64
+ });
65
+ }
66
+ validationPromise.then(() => {
67
+ // Need to reset previous errors,
68
+ // since promise resolve is the only place where we consider that previous errors is not relevant anymore.
69
+ resetErrors(rowId, cellId);
70
+ }).catch(errors => {
71
+ setErrors(errors, rowId, cellId);
72
+ });
73
+ return validationPromise;
74
+ };
75
+ return {
76
+ validate,
77
+ setCellError,
78
+ setRowErrors,
79
+ confirmErrors,
80
+ getCellError,
81
+ resetErrors,
82
+ errors: validationState.errors,
83
+ draftErrors: validationState.draftErrors
84
+ };
85
+ }
86
+ // Taking care of reseting/removing errors for particular cell/row and reseting errors object to null, when no errors at all.
87
+ function _resetErrors(errors, rowId, columnId) {
88
+ let currentErrors = errors ? {
89
+ ...errors
90
+ } : {};
91
+ if (currentErrors && currentErrors[rowId]) {
92
+ if (columnId) {
93
+ delete currentErrors[rowId][columnId];
94
+ const rowErrorsSet = Object.keys(currentErrors[rowId]);
95
+ if (rowErrorsSet.length === 0) {
96
+ delete currentErrors[rowId];
97
+ }
98
+ } else {
99
+ delete currentErrors[rowId];
100
+ }
101
+ }
102
+ const errorsSet = Object.keys(currentErrors);
103
+ if (errorsSet.length === 0) {
104
+ currentErrors = null;
105
+ }
106
+ return currentErrors;
107
+ }
108
+ var ValidationActionType;
109
+ (function (ValidationActionType) {
110
+ ValidationActionType[ValidationActionType["SET_CELL_ERROR"] = 0] = "SET_CELL_ERROR";
111
+ ValidationActionType[ValidationActionType["SET_ROW_ERROR"] = 1] = "SET_ROW_ERROR";
112
+ ValidationActionType[ValidationActionType["CONFIRN_ERRORS"] = 2] = "CONFIRN_ERRORS";
113
+ ValidationActionType[ValidationActionType["RESET_ERRORS"] = 3] = "RESET_ERRORS";
114
+ })(ValidationActionType || (ValidationActionType = {}));
115
+ function validationReducer(state, action) {
116
+ var _state$draftErrors, _state$draftErrors2;
117
+ switch (action.type) {
118
+ // Saves cell error into draft errors state.
119
+ case ValidationActionType.SET_CELL_ERROR:
120
+ return {
121
+ ...state,
122
+ draftErrors: {
123
+ ...state.draftErrors,
124
+ [action.payload.rowId]: {
125
+ ...((_state$draftErrors = state.draftErrors) === null || _state$draftErrors === void 0 ? void 0 : _state$draftErrors[action.payload.rowId]),
126
+ [action.payload.cellId]: action.payload.error
127
+ }
128
+ }
129
+ };
130
+ // Saves row errors into draft errors state.
131
+ case ValidationActionType.SET_ROW_ERROR:
132
+ return {
133
+ ...state,
134
+ draftErrors: {
135
+ ...state.draftErrors,
136
+ [action.payload.rowId]: {
137
+ ...((_state$draftErrors2 = state.draftErrors) === null || _state$draftErrors2 === void 0 ? void 0 : _state$draftErrors2[action.payload.rowId]),
138
+ ...action.payload.errors
139
+ }
140
+ }
141
+ };
142
+ // Promotes errors from draft into confirmed state (When user moves to next/prev row)
143
+ case ValidationActionType.CONFIRN_ERRORS:
144
+ {
145
+ const newDraftErrors = {
146
+ ...state.draftErrors
147
+ };
148
+ const confirmedRow = {
149
+ ...newDraftErrors[action.payload.rowId]
150
+ };
151
+ delete newDraftErrors[action.payload.rowId];
152
+ return {
153
+ draftErrors: newDraftErrors,
154
+ errors: {
155
+ ...state.errors,
156
+ [action.payload.rowId]: confirmedRow
157
+ }
158
+ };
159
+ }
160
+ // Resets all errors for particular row or cell if cell id is passed.
161
+ // We need to reset both confirmed and draft errors, for the situations,
162
+ // when user is getting back to the row wich already had error.
163
+ case ValidationActionType.RESET_ERRORS:
164
+ {
165
+ const newDraftErrors = _resetErrors(state.draftErrors, action.payload.rowId, action.payload.cellId);
166
+ const newErrors = _resetErrors(state.errors, action.payload.rowId, action.payload.cellId);
167
+ return {
168
+ errors: newErrors,
169
+ draftErrors: newDraftErrors
170
+ };
171
+ }
172
+ default:
173
+ return state;
174
+ }
175
+ }
176
+
177
+ export { useValidation };
178
+ //# sourceMappingURL=useValidation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useValidation.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useValidation.ts"],"sourcesContent":["import React from 'react';\nimport * as _ from 'lodash';\nimport { Cell as RTCell } from '@tanstack/react-table';\nimport { RowErrors, Table3CellValidationHandler, Table3RowValidationHandler } from '../../types';\n\nexport type Table3Validation<TType = unknown> = {\n validate: (rowId: string, row: TType, cellId?: string) => Promise<void | RowErrors>;\n setCellError: (rowId: string, cellId: string, error: string) => void;\n setRowErrors: (rowId: string, errors: Record<string, string>) => void;\n confirmErrors: (rowId: string) => void;\n getCellError: <T extends TType>(cell: RTCell<T, unknown>) => string | undefined;\n resetErrors: (rowId: string, cellId?: string) => void;\n errors: Record<string, RowErrors> | null;\n draftErrors: Record<string, RowErrors> | null;\n};\n\nexport function useValidation<TType = unknown>(\n onCellValidate?: Table3CellValidationHandler<TType>,\n onRowValidate?: Table3RowValidationHandler<TType>\n): Table3Validation<TType> {\n const [validationState, dispatch] = React.useReducer(validationReducer, { errors: null, draftErrors: null });\n\n function getCellError<T extends TType>(cell: RTCell<T, unknown>) {\n return (\n (validationState.draftErrors && validationState.draftErrors[cell.row.id]?.[cell.column.id]) ||\n (validationState.errors ? validationState.errors[cell.row.id]?.[cell.column.id] : undefined)\n );\n }\n\n function setCellError(rowId: string, cellId: string, error: string) {\n dispatch({\n type: ValidationActionType.SET_CELL_ERROR,\n payload: { rowId, cellId, error },\n });\n }\n\n function setRowErrors(rowId: string, errors: Record<string, string>) {\n dispatch({\n type: ValidationActionType.SET_ROW_ERROR,\n payload: { rowId, errors },\n });\n }\n\n function confirmErrors(rowId: string) {\n dispatch({\n type: ValidationActionType.CONFIRN_ERRORS,\n payload: { rowId },\n });\n }\n\n function resetErrors(rowId: string, cellId?: string) {\n dispatch({\n type: ValidationActionType.RESET_ERRORS,\n payload: { rowId, cellId },\n });\n }\n\n const setErrors = (errors: RowErrors, rowId: string, cellId?: string) => {\n if (cellId) {\n setCellError(rowId, cellId, errors[cellId]);\n } else {\n setRowErrors(rowId, errors);\n }\n };\n\n const validate = (rowId: string, row: TType, cellId?: string) => {\n let validationPromise: Promise<RowErrors | void>;\n if (cellId && onCellValidate) {\n validationPromise = onCellValidate(row[cellId], cellId, row);\n } else if (onRowValidate) {\n validationPromise = onRowValidate(row);\n } else {\n validationPromise = new Promise(resolve => {\n resolve();\n });\n }\n\n validationPromise\n .then(() => {\n // Need to reset previous errors,\n // since promise resolve is the only place where we consider that previous errors is not relevant anymore.\n resetErrors(rowId, cellId);\n })\n .catch((errors: RowErrors) => {\n setErrors(errors, rowId, cellId);\n });\n\n return validationPromise;\n };\n\n return {\n validate,\n setCellError,\n setRowErrors,\n confirmErrors,\n getCellError,\n resetErrors,\n errors: validationState.errors,\n draftErrors: validationState.draftErrors,\n };\n}\n\n// Taking care of reseting/removing errors for particular cell/row and reseting errors object to null, when no errors at all.\nfunction _resetErrors(\n errors: Record<string, RowErrors> | null,\n rowId: string,\n columnId?: string\n): Record<string, RowErrors> | null {\n let currentErrors: Record<string, RowErrors> | null = errors ? { ...errors } : {};\n\n if (currentErrors && currentErrors[rowId]) {\n if (columnId) {\n delete currentErrors[rowId][columnId];\n const rowErrorsSet = Object.keys(currentErrors[rowId]);\n if (rowErrorsSet.length === 0) {\n delete currentErrors[rowId];\n }\n } else {\n delete currentErrors[rowId];\n }\n }\n\n const errorsSet = Object.keys(currentErrors);\n if (errorsSet.length === 0) {\n currentErrors = null;\n }\n\n return currentErrors;\n}\n\nenum ValidationActionType {\n SET_CELL_ERROR,\n SET_ROW_ERROR,\n CONFIRN_ERRORS,\n RESET_ERRORS,\n}\n\ntype ValidationState = {\n // According to UX requirement, while user still editing current row, the error alert should not be yet shown,\n // and row should not be highlighted in red, but error still need to be shown on a cell level when user moving from cell to cell.\n // This means that we need to maintain some kind of draft validation errors as well as confirmed errors.\n draftErrors: Record<string, RowErrors> | null;\n // sets of row errors\n errors: Record<string, RowErrors> | null;\n};\n\ntype ValidationAction =\n | { type: ValidationActionType.SET_CELL_ERROR; payload: { rowId: string; cellId: string; error: string } }\n | { type: ValidationActionType.SET_ROW_ERROR; payload: { rowId: string; errors: RowErrors } }\n | { type: ValidationActionType.CONFIRN_ERRORS; payload: { rowId: string } }\n | { type: ValidationActionType.RESET_ERRORS; payload: { rowId: string; cellId?: string } };\n\nfunction validationReducer(state: ValidationState, action: ValidationAction): ValidationState {\n switch (action.type) {\n // Saves cell error into draft errors state.\n case ValidationActionType.SET_CELL_ERROR:\n return {\n ...state,\n draftErrors: {\n ...state.draftErrors,\n [action.payload.rowId]: {\n ...state.draftErrors?.[action.payload.rowId],\n [action.payload.cellId]: action.payload.error,\n },\n },\n };\n\n // Saves row errors into draft errors state.\n case ValidationActionType.SET_ROW_ERROR:\n return {\n ...state,\n draftErrors: {\n ...state.draftErrors,\n [action.payload.rowId]: {\n ...state.draftErrors?.[action.payload.rowId],\n ...action.payload.errors,\n },\n },\n };\n\n // Promotes errors from draft into confirmed state (When user moves to next/prev row)\n case ValidationActionType.CONFIRN_ERRORS: {\n const newDraftErrors = { ...state.draftErrors };\n const confirmedRow = { ...newDraftErrors[action.payload.rowId] };\n delete newDraftErrors[action.payload.rowId];\n return {\n draftErrors: newDraftErrors,\n errors: {\n ...state.errors,\n [action.payload.rowId]: confirmedRow,\n },\n };\n }\n\n // Resets all errors for particular row or cell if cell id is passed.\n // We need to reset both confirmed and draft errors, for the situations,\n // when user is getting back to the row wich already had error.\n case ValidationActionType.RESET_ERRORS: {\n const newDraftErrors = _resetErrors(state.draftErrors, action.payload.rowId, action.payload.cellId);\n const newErrors = _resetErrors(state.errors, action.payload.rowId, action.payload.cellId);\n return {\n errors: newErrors,\n draftErrors: newDraftErrors,\n };\n }\n\n default:\n return state;\n }\n}\n"],"names":["useValidation","onCellValidate","onRowValidate","validationState","dispatch","React","useReducer","validationReducer","errors","draftErrors","getCellError","cell","_validationState$draf","row","id","column","_validationState$erro","undefined","setCellError","rowId","cellId","error","type","ValidationActionType","SET_CELL_ERROR","payload","setRowErrors","SET_ROW_ERROR","confirmErrors","CONFIRN_ERRORS","resetErrors","RESET_ERRORS","setErrors","validate","validationPromise","Promise","resolve","then","catch","_resetErrors","columnId","currentErrors","rowErrorsSet","Object","keys","length","errorsSet","state","action","_state$draftErrors","_state$draftErrors2","newDraftErrors","confirmedRow","newErrors"],"mappings":";;SAgBgBA,aAAaA,CACzBC,cAAmD,EACnDC,aAAiD;EAEjD,MAAM,CAACC,eAAe,EAAEC,QAAQ,CAAC,GAAGC,cAAK,CAACC,UAAU,CAACC,iBAAiB,EAAE;IAAEC,MAAM,EAAE,IAAI;IAAEC,WAAW,EAAE;GAAM,CAAC;EAE5G,SAASC,YAAYA,CAAkBC,IAAwB;;IAC3D,OACKR,eAAe,CAACM,WAAW,MAAAG,qBAAA,GAAIT,eAAe,CAACM,WAAW,CAACE,IAAI,CAACE,GAAG,CAACC,EAAE,CAAC,cAAAF,qBAAA,uBAAxCA,qBAAA,CAA2CD,IAAI,CAACI,MAAM,CAACD,EAAE,CAAC,MACzFX,eAAe,CAACK,MAAM,IAAAQ,qBAAA,GAAGb,eAAe,CAACK,MAAM,CAACG,IAAI,CAACE,GAAG,CAACC,EAAE,CAAC,cAAAE,qBAAA,uBAAnCA,qBAAA,CAAsCL,IAAI,CAACI,MAAM,CAACD,EAAE,CAAC,GAAGG,SAAS,CAAC;;EAIpG,SAASC,YAAYA,CAACC,KAAa,EAAEC,MAAc,EAAEC,KAAa;IAC9DjB,QAAQ,CAAC;MACLkB,IAAI,EAAEC,oBAAoB,CAACC,cAAc;MACzCC,OA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,WAAW,EAAEuC,MAAM,CAACvB,OAAO,CAACN,KAAK,EAAE6B,MAAM,CAACvB,OAAO,CAACL,MAAM,CAAC;QACnG,MAAMiC,SAAS,GAAGd,YAAY,CAACQ,KAAK,CAACvC,MAAM,EAAEwC,MAAM,CAACvB,OAAO,CAACN,KAAK,EAAE6B,MAAM,CAACvB,OAAO,CAACL,MAAM,CAAC;QACzF,OAAO;UACHZ,MAAM,EAAE6C,SAAS;UACjB5C,WAAW,EAAE0C;SAChB;;IAGL;MACI,OAAOJ,KAAK;;AAExB;;;;"}
@@ -129,7 +129,7 @@ function useConvertChildrenToColumns(props, options, editing) {
129
129
  columns.push(columnHelper.display(createRowActionsColumn()));
130
130
  }
131
131
  if (editing.isEnabled && editing.isEditing) {
132
- columns.push(columnHelper.display(createRowEditingActionsColumn()));
132
+ columns.push(columnHelper.display(createRowEditingActionsColumn(props.rowIdentifier)));
133
133
  }
134
134
  return {
135
135
  columns,
@@ -1 +1 @@
1
- {"version":3,"file":"useConvertChildrenToColumns.js","sources":["../../../../../../../../src/components/Table3/hooks/useConvertChildrenToColumns.tsx"],"sourcesContent":["import React from 'react';\nimport {\n ColumnDef,\n ColumnSizingState,\n createColumnHelper,\n ColumnSort,\n VisibilityState,\n GroupColumnDef,\n} from '@tanstack/react-table';\nimport { Table3ColumnProps, Table3Props, Table3Options, Table3ColumnDataType, Table3SortFn, Table3GroupProps } from '../types';\nimport { Header } from '../components/columns/header/Header';\nimport { Footer } from '../components/columns/footer/Footer';\nimport { Cell } from '../components/columns/cell/Cell';\nimport { createRowSelectionColumn } from '../components/columns/internal/Selection';\nimport { getFontBasedMinColumnSize } from '../components/columns/styles';\nimport { createRowActionsColumn } from '../components/columns/internal/Actions';\nimport { createRowExpansionColumn } from '../components/columns/internal/Expansion';\nimport { createRowDragColumn } from '../components/columns/internal/Drag';\nimport { createRowEditingActionsColumn } from '../components/columns/internal/EditingActions';\nimport { useEditing } from './features/useEditing';\nimport { Group } from '../components/columns/header/Group';\n\nfunction getSortingFn<TType = unknown>(dataType?: Table3ColumnDataType, customFnOrBuiltIn?: Table3SortFn<TType>) {\n if (typeof customFnOrBuiltIn === 'function') {\n return (rowA, rowB, columnId) => customFnOrBuiltIn(rowA.original, rowB.original, columnId);\n }\n\n // if a built in is being used, just return that\n if (customFnOrBuiltIn) {\n return customFnOrBuiltIn;\n }\n\n // some times we alias based on the type\n if (dataType && dataType !== 'boolean' && dataType !== 'number') {\n return dataType;\n }\n\n // otherwise fall back to auto\n return 'auto';\n}\n\nexport function useConvertChildrenToColumns<TType = unknown>(\n props: Table3Props<TType>,\n options: Table3Options,\n editing: ReturnType<typeof useEditing>\n) {\n const minColumnSize = getFontBasedMinColumnSize(props?.defaultSettings?.fontSize);\n // It's important to memoise column definitions, because it prevents columns like \"Drag column\" to re-render on every state change,\n // and break dragging at the moment it happens.\n return React.useMemo(() => {\n const columnHelper = createColumnHelper<TType>();\n\n const defaultColumnSizing: ColumnSizingState = {};\n const defaultColumnVisibility: VisibilityState = {};\n const defaultSorting: ColumnSort[] = [];\n\n function processChild<TType>(child: React.ReactChild | React.ReactFragment | React.ReactPortal) {\n if (\n React.isValidElement<Table3ColumnProps<TType>>(child) &&\n (child as any).type?.displayName === 'Table3Column' &&\n child.props.accessor\n ) {\n if (child.props.defaultWidth) {\n defaultColumnSizing[child.props.accessor as string] =\n child.props.defaultWidth === 'grow' ? '1fr' : (child.props.defaultWidth as any);\n }\n\n if (child.props.defaultHidden && options.enableColumnHiding) {\n defaultColumnVisibility[child.props.accessor as string] = false;\n }\n\n if (child.props.sort !== undefined) {\n defaultSorting.push({\n id: child.props.accessor as string,\n desc: child.props.sort === 'desc',\n });\n }\n\n // return regular column definition\n return {\n accessorKey: child.props.accessor,\n id: child.props.accessor as string,\n header: Header,\n cell: Cell,\n footer: Footer,\n // sizing\n minSize: minColumnSize,\n enableResizing: child.props.enableResizing ?? true,\n // filtering\n enableColumnFilter: child.props.enableFiltering ?? true,\n filterFn: 'tacoFilter' as any,\n // sorting\n enableSorting: child.props.enableSorting ?? true,\n sortingFn: getSortingFn<TType>(child.props.dataType, child.props.sortFn),\n sortDescFirst: false,\n sortUndefined: 1,\n // visibility\n enableHiding: child.props.enableHiding ?? true,\n // custom options\n meta: {\n align: child.props.align,\n className: child.props.className,\n control: child.props.control,\n dataType: child.props.dataType,\n enableOrdering: child.props.enableOrdering ?? true,\n enablePrinting: child.props.enablePrinting ?? true,\n enableSearch: child.props.enableSearch ?? true,\n enableTruncate: child.props.enableTruncate ?? false,\n filters: child.props.filters,\n footer: child.props.footer,\n header: child.props.header,\n headerClassName: child.props.headerClassName,\n menu: child.props.menu,\n renderer: child.props.renderer,\n tooltip: child.props.tooltip,\n },\n };\n } else if (\n React.isValidElement<Table3GroupProps>(child) &&\n (child as any).type?.displayName === 'Table3Group' &&\n child.props.children\n ) {\n // return column group definition\n return columnHelper.group({\n id: child.props.id,\n header: Group,\n columns: processChildren(child.props.children),\n meta: {\n align: 'center',\n enableOrdering: false,\n enableSearch: false,\n enableTruncate: false,\n header: child.props.header,\n },\n });\n }\n return;\n }\n\n function processChildren<TType = unknown>(\n children: (JSX.Element | boolean | null | undefined)[]\n ): Array<ColumnDef<TType> | GroupColumnDef<TType>> {\n return (\n React.Children.toArray(children)\n .map(processChild)\n // compiler cannot get filtering out undefined items, so using the type casting here\n .filter(child => !!child) as Array<ColumnDef<TType> | GroupColumnDef<TType>>\n ); // need to remove undefined array items after processing the children\n }\n\n const columns: ColumnDef<TType>[] = processChildren(props.children);\n\n if (options.enableRowExpansion && props.expandedRowRenderer) {\n columns.unshift(columnHelper.display(createRowExpansionColumn(props.expandedRowRenderer)));\n }\n\n if (options.enableRowSelection) {\n columns.unshift(\n columnHelper.display(\n createRowSelectionColumn<TType>(!!(options.enableRowDrag && props.onRowDrag), !!props.expandedRowRenderer)\n )\n );\n }\n\n if (options.enableRowDrag && props.onRowDrag) {\n columns.unshift(columnHelper.display(createRowDragColumn(props.onRowDrag)));\n }\n\n if (props.actionsForRow?.length) {\n columns.push(columnHelper.display(createRowActionsColumn<TType>()));\n }\n\n if (editing.isEnabled && editing.isEditing) {\n columns.push(columnHelper.display(createRowEditingActionsColumn<TType>()));\n }\n\n return { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting };\n }, [editing.isEditing]);\n}\n"],"names":["getSortingFn","dataType","customFnOrBuiltIn","rowA","rowB","columnId","original","useConvertChildrenToColumns","props","options","editing","minColumnSize","getFontBasedMinColumnSize","_props$defaultSetting","defaultSettings","fontSize","React","useMemo","columnHelper","createColumnHelper","defaultColumnSizing","defaultColumnVisibility","defaultSorting","processChild","child","isValidElement","_child$type","type","displayName","accessor","_child$props$enableRe","_child$props$enableFi","_child$props$enableSo","_child$props$enableHi","_child$props$enableOr","_child$props$enablePr","_child$props$enableSe","_child$props$enableTr","defaultWidth","defaultHidden","enableColumnHiding","sort","undefined","push","id","desc","accessorKey","header","Header","cell","Cell","footer","Footer","minSize","enableResizing","enableColumnFilter","enableFiltering","filterFn","enableSorting","sortingFn","sortFn","sortDescFirst","sortUndefined","enableHiding","meta","align","className","control","enableOrdering","enablePrinting","enableSearch","enableTruncate","filters","headerClassName","menu","renderer","tooltip","_child$type2","children","group","Group","columns","processChildren","Children","toArray","map","filter","enableRowExpansion","expandedRowRenderer","unshift","display","createRowExpansionColumn","enableRowSelection","createRowSelectionColumn","enableRowDrag","onRowDrag","createRowDragColumn","_props$actionsForRow","actionsForRow","length","createRowActionsColumn","isEnabled","isEditing","createRowEditingActionsColumn"],"mappings":";;;;;;;;;;;;;AAsBA,SAASA,YAAYA,CAAkBC,QAA+B,EAAEC,iBAAuC;EAC3G,IAAI,OAAOA,iBAAiB,KAAK,UAAU,EAAE;IACzC,OAAO,CAACC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,KAAKH,iBAAiB,CAACC,IAAI,CAACG,QAAQ,EAAEF,IAAI,CAACE,QAAQ,EAAED,QAAQ,CAAC;;;EAI9F,IAAIH,iBAAiB,EAAE;IACnB,OAAOA,iBAA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BAAmB,CAACxF,KAAK,CAACuF,SAAS,CAAC,CAAC,CAAC;;IAG/E,KAAAE,oBAAA,GAAIzF,KAAK,CAAC0F,aAAa,cAAAD,oBAAA,eAAnBA,oBAAA,CAAqBE,MAAM,EAAE;MAC7BlB,OAAO,CAACtC,IAAI,CAACzB,YAAY,CAACwE,OAAO,CAACU,sBAAsB,EAAS,CAAC,CAAC;;IAGvE,IAAI1F,OAAO,CAAC2F,SAAS,IAAI3F,OAAO,CAAC4F,SAAS,EAAE;MACxCrB,OAAO,CAACtC,IAAI,CAACzB,YAAY,CAACwE,OAAO,CAACa,6BAA6B,EAAS,CAAC,CAAC;;IAG9E,OAAO;MAAEtB,OAAO;MAAE7D,mBAAmB;MAAEC,uBAAuB;MAAEC;KAAgB;GACnF,EAAE,CAACZ,OAAO,CAAC4F,SAAS,CAAC,CAAC;AAC3B;;;;"}
1
+ {"version":3,"file":"useConvertChildrenToColumns.js","sources":["../../../../../../../../src/components/Table3/hooks/useConvertChildrenToColumns.tsx"],"sourcesContent":["import React from 'react';\nimport {\n ColumnDef,\n ColumnSizingState,\n createColumnHelper,\n ColumnSort,\n VisibilityState,\n GroupColumnDef,\n} from '@tanstack/react-table';\nimport { Table3ColumnProps, Table3Props, Table3Options, Table3ColumnDataType, Table3SortFn, Table3GroupProps } from '../types';\nimport { Header } from '../components/columns/header/Header';\nimport { Footer } from '../components/columns/footer/Footer';\nimport { Cell } from '../components/columns/cell/Cell';\nimport { createRowSelectionColumn } from '../components/columns/internal/Selection';\nimport { getFontBasedMinColumnSize } from '../components/columns/styles';\nimport { createRowActionsColumn } from '../components/columns/internal/Actions';\nimport { createRowExpansionColumn } from '../components/columns/internal/Expansion';\nimport { createRowDragColumn } from '../components/columns/internal/Drag';\nimport { createRowEditingActionsColumn } from '../components/columns/internal/EditingActions';\nimport { useEditing } from './features/useEditing';\nimport { Group } from '../components/columns/header/Group';\n\nfunction getSortingFn<TType = unknown>(dataType?: Table3ColumnDataType, customFnOrBuiltIn?: Table3SortFn<TType>) {\n if (typeof customFnOrBuiltIn === 'function') {\n return (rowA, rowB, columnId) => customFnOrBuiltIn(rowA.original, rowB.original, columnId);\n }\n\n // if a built in is being used, just return that\n if (customFnOrBuiltIn) {\n return customFnOrBuiltIn;\n }\n\n // some times we alias based on the type\n if (dataType && dataType !== 'boolean' && dataType !== 'number') {\n return dataType;\n }\n\n // otherwise fall back to auto\n return 'auto';\n}\n\nexport function useConvertChildrenToColumns<TType = unknown>(\n props: Table3Props<TType>,\n options: Table3Options,\n editing: ReturnType<typeof useEditing>\n) {\n const minColumnSize = getFontBasedMinColumnSize(props?.defaultSettings?.fontSize);\n // It's important to memoise column definitions, because it prevents columns like \"Drag column\" to re-render on every state change,\n // and break dragging at the moment it happens.\n return React.useMemo(() => {\n const columnHelper = createColumnHelper<TType>();\n\n const defaultColumnSizing: ColumnSizingState = {};\n const defaultColumnVisibility: VisibilityState = {};\n const defaultSorting: ColumnSort[] = [];\n\n function processChild<TType>(child: React.ReactChild | React.ReactFragment | React.ReactPortal) {\n if (\n React.isValidElement<Table3ColumnProps<TType>>(child) &&\n (child as any).type?.displayName === 'Table3Column' &&\n child.props.accessor\n ) {\n if (child.props.defaultWidth) {\n defaultColumnSizing[child.props.accessor as string] =\n child.props.defaultWidth === 'grow' ? '1fr' : (child.props.defaultWidth as any);\n }\n\n if (child.props.defaultHidden && options.enableColumnHiding) {\n defaultColumnVisibility[child.props.accessor as string] = false;\n }\n\n if (child.props.sort !== undefined) {\n defaultSorting.push({\n id: child.props.accessor as string,\n desc: child.props.sort === 'desc',\n });\n }\n\n // return regular column definition\n return {\n accessorKey: child.props.accessor,\n id: child.props.accessor as string,\n header: Header,\n cell: Cell,\n footer: Footer,\n // sizing\n minSize: minColumnSize,\n enableResizing: child.props.enableResizing ?? true,\n // filtering\n enableColumnFilter: child.props.enableFiltering ?? true,\n filterFn: 'tacoFilter' as any,\n // sorting\n enableSorting: child.props.enableSorting ?? true,\n sortingFn: getSortingFn<TType>(child.props.dataType, child.props.sortFn),\n sortDescFirst: false,\n sortUndefined: 1,\n // visibility\n enableHiding: child.props.enableHiding ?? true,\n // custom options\n meta: {\n align: child.props.align,\n className: child.props.className,\n control: child.props.control,\n dataType: child.props.dataType,\n enableOrdering: child.props.enableOrdering ?? true,\n enablePrinting: child.props.enablePrinting ?? true,\n enableSearch: child.props.enableSearch ?? true,\n enableTruncate: child.props.enableTruncate ?? false,\n filters: child.props.filters,\n footer: child.props.footer,\n header: child.props.header,\n headerClassName: child.props.headerClassName,\n menu: child.props.menu,\n renderer: child.props.renderer,\n tooltip: child.props.tooltip,\n },\n };\n } else if (\n React.isValidElement<Table3GroupProps>(child) &&\n (child as any).type?.displayName === 'Table3Group' &&\n child.props.children\n ) {\n // return column group definition\n return columnHelper.group({\n id: child.props.id,\n header: Group,\n columns: processChildren(child.props.children),\n meta: {\n align: 'center',\n enableOrdering: false,\n enableSearch: false,\n enableTruncate: false,\n header: child.props.header,\n },\n });\n }\n return;\n }\n\n function processChildren<TType = unknown>(\n children: (JSX.Element | boolean | null | undefined)[]\n ): Array<ColumnDef<TType> | GroupColumnDef<TType>> {\n return (\n React.Children.toArray(children)\n .map(processChild)\n // compiler cannot get filtering out undefined items, so using the type casting here\n .filter(child => !!child) as Array<ColumnDef<TType> | GroupColumnDef<TType>>\n ); // need to remove undefined array items after processing the children\n }\n\n const columns: ColumnDef<TType>[] = processChildren(props.children);\n\n if (options.enableRowExpansion && props.expandedRowRenderer) {\n columns.unshift(columnHelper.display(createRowExpansionColumn(props.expandedRowRenderer)));\n }\n\n if (options.enableRowSelection) {\n columns.unshift(\n columnHelper.display(\n createRowSelectionColumn<TType>(!!(options.enableRowDrag && props.onRowDrag), !!props.expandedRowRenderer)\n )\n );\n }\n\n if (options.enableRowDrag && props.onRowDrag) {\n columns.unshift(columnHelper.display(createRowDragColumn(props.onRowDrag)));\n }\n\n if (props.actionsForRow?.length) {\n columns.push(columnHelper.display(createRowActionsColumn<TType>()));\n }\n\n if (editing.isEnabled && editing.isEditing) {\n columns.push(columnHelper.display(createRowEditingActionsColumn<TType>(props.rowIdentifier)));\n }\n\n return { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting };\n }, [editing.isEditing]);\n}\n"],"names":["getSortingFn","dataType","customFnOrBuiltIn","rowA","rowB","columnId","original","useConvertChildrenToColumns","props","options","editing","minColumnSize","getFontBasedMinColumnSize","_props$defaultSetting","defaultSettings","fontSize","React","useMemo","columnHelper","createColumnHelper","defaultColumnSizing","defaultColumnVisibility","defaultSorting","processChild","child","isValidElement","_child$type","type","displayName","accessor","_child$props$enableRe","_child$props$enableFi","_child$props$enableSo","_child$props$enableHi","_child$props$enableOr","_child$props$enablePr","_child$props$enableSe","_child$props$enableTr","defaultWidth","defaultHidden","enableColumnHiding","sort","undefined","push","id","desc","accessorKey","header","Header","cell","Cell","footer","Footer","minSize","enableResizing","enableColumnFilter","enableFiltering","filterFn","enableSorting","sortingFn","sortFn","sortDescFirst","sortUndefined","enableHiding","meta","align","className","control","enableOrdering","enablePrinting","enableSearch","enableTruncate","filters","headerClassName","menu","renderer","tooltip","_child$type2","children","group","Group","columns","processChildren","Children","toArray","map","filter","enableRowExpansion","expandedRowRenderer","unshift","display","createRowExpansionColumn","enableRowSelection","createRowSelectionColumn","enableRowDrag","onRowDrag","createRowDragColumn","_props$actionsForRow","actionsForRow","length","createRowActionsColumn","isEnabled","isEditing","createRowEditingActionsColumn","rowIdentifier"],"mappings":";;;;;;;;;;;;;AAsBA,SAASA,YAAYA,CAAkBC,QAA+B,EAAEC,iBAAuC;EAC3G,IAAI,OAAOA,iBAAiB,KAAK,UAAU,EAAE;IACzC,OAAO,CAACC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,KAAKH,iBAAiB,CAACC,IAAI,CAACG,QAAQ,EAAEF,IAAI,CAACE,QAAQ,EAAED,QAAQ,CAAC;;;EAI9F,IAAIH,iBAAiB,EAAE;IACnB,OAAOA,iBAAiB;;;EAI5B,IAAID,QAAQ,IAAIA,QA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AC,CAAC,CAAC;;IAG/E,KAAAE,oBAAA,GAAIzF,KAAK,CAAC0F,aAAa,cAAAD,oBAAA,eAAnBA,oBAAA,CAAqBE,MAAM,EAAE;MAC7BlB,OAAO,CAACtC,IAAI,CAACzB,YAAY,CAACwE,OAAO,CAACU,sBAAsB,EAAS,CAAC,CAAC;;IAGvE,IAAI1F,OAAO,CAAC2F,SAAS,IAAI3F,OAAO,CAAC4F,SAAS,EAAE;MACxCrB,OAAO,CAACtC,IAAI,CAACzB,YAAY,CAACwE,OAAO,CAACa,6BAA6B,CAAQ/F,KAAK,CAACgG,aAAa,CAAC,CAAC,CAAC;;IAGjG,OAAO;MAAEvB,OAAO;MAAE7D,mBAAmB;MAAEC,uBAAuB;MAAEC;KAAgB;GACnF,EAAE,CAACZ,OAAO,CAAC4F,SAAS,CAAC,CAAC;AAC3B;;;;"}
@@ -28,6 +28,8 @@ import { useEditingStateListener } from './listeners/useEditingStateListener.js'
28
28
  import { useSearch } from './features/useSearch.js';
29
29
  import { useRowActions } from './features/useRowActions.js';
30
30
  import { useSettings } from './features/useSettings.js';
31
+ import { useValidation } from './features/useValidation.js';
32
+ import { usePauseShortcuts } from './features/usePauseShortcuts.js';
31
33
 
32
34
  function useTable(props) {
33
35
  var _ref, _defaultSettings$colu, _defaultSettings$rowH, _props$length;
@@ -99,7 +101,8 @@ function useTable(props) {
99
101
  (_ref = (_defaultSettings$colu = defaultSettings.columnFreezingIndex) !== null && _defaultSettings$colu !== void 0 ? _defaultSettings$colu : defaultSettings === null || defaultSettings === void 0 ? void 0 : defaultSettings.frozenColumnCount) !== null && _ref !== void 0 ? _ref : props.defaultColumnFreezingIndex, options);
100
102
  const columnOrdering = useColumnOrdering(options);
101
103
  const currentRow = useCurrentRow(props.defaultCurrentRowIndex);
102
- const editing = useEditing(options.enableEditing, props.onSave);
104
+ const validation = useValidation(props.onCellValidate, props.onRowValidate);
105
+ const editing = useEditing(options.enableEditing, validation, props.onSave);
103
106
  const fontSize = useFontSize(options.enableFontSize, defaultSettings.fontSize);
104
107
  const hoverState = usePauseHoverState();
105
108
  const printing = usePrinting(options.enablePrinting, props.loadAll, defaultSettings.showWarningWhenPrintingLargeDataset);
@@ -112,6 +115,7 @@ function useTable(props) {
112
115
  (_defaultSettings$rowH = defaultSettings.rowHeight) !== null && _defaultSettings$rowH !== void 0 ? _defaultSettings$rowH : defaultSettings === null || defaultSettings === void 0 ? void 0 : defaultSettings.rowDensity);
113
116
  const rowSelection = useRowSelection();
114
117
  const search = useSearch(options.enableSearch, defaultSettings.excludeUnmatchedRecordsInSearch, props.loadAll);
118
+ const shortcutsState = usePauseShortcuts();
115
119
  // columns
116
120
  const {
117
121
  columns,
@@ -180,7 +184,9 @@ function useTable(props) {
180
184
  rowGoto,
181
185
  rowHeight,
182
186
  rowSelection,
183
- search
187
+ search,
188
+ shortcutsState,
189
+ validation
184
190
  }
185
191
  });
186
192
  // listeners
@@ -1 +1 @@
1
- {"version":3,"file":"useTable.js","sources":["../../../../../../../../src/components/Table3/hooks/useTable.tsx"],"sourcesContent":["import React from 'react';\nimport {\n getCoreRowModel,\n useReactTable,\n Row as RTRow,\n RowData,\n Column as RTColumn,\n TableOptions as RTableOptions,\n TableState,\n getSortedRowModel,\n getFilteredRowModel,\n ColumnMeta,\n} from '@tanstack/react-table';\nimport {\n Table3ColumnAlignment,\n Table3ColumnRenderer,\n Table3Props,\n Table3ColumnHeaderMenu,\n Table3ColumnControlRenderer,\n Table3ColumnDataType,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n TableStrategy,\n Table3FilterComparator,\n Table3Settings,\n} from '../types';\nimport { useCurrentRow } from './features/useCurrentRow';\nimport { usePauseHoverState } from './features/usePauseHoverState';\nimport { useTablePreset } from './useTablePreset';\nimport { useRowHeight } from './features/useRowHeight';\nimport { useFontSize } from './features/useFontSize';\nimport { useRowSelectionListener } from './listeners/useRowSelectionListener';\nimport { useRowDrag } from './features/useRowDrag';\nimport { useSettingsStateListener } from './listeners/useSettingsStateListener';\nimport { columnFilterFn, globalFilterFn } from '../util/filtering';\nimport { useSortingStateListener } from './listeners/useSortingStateListener';\nimport { useFilteringStateListener } from './listeners/useFilteringStateListener';\nimport { useCurrentRowListener } from './listeners/useCurrentRowListener';\nimport { useColumnFreezing } from './features/useColumnFreezing';\nimport { useRowSelection } from './features/useRowSelection';\nimport { useRowClick } from './features/useRowClick';\nimport { ensureOrdering, useColumnOrdering } from './features/useColumnOrdering';\nimport { useRowDrop } from './features/useRowDrop';\nimport { useConvertChildrenToColumns } from './useConvertChildrenToColumns';\nimport { useEditing } from './features/useEditing';\nimport { usePrinting } from './features/usePrinting';\nimport { useShortcutsListener } from './listeners/useShortcutsListener';\nimport { useRowGoto } from './features/useRowGoto';\nimport { useServerLoadingListener } from './listeners/useServerLoadingListener';\nimport { useEditingStateListener } from './listeners/useEditingStateListener';\nimport { useSearch } from './features/useSearch';\nimport { useRowActions } from './features/useRowActions';\nimport { useSettings } from './features/useSettings';\nimport { getCellValueAsString } from '../util/columns';\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useColumnFreezing>;\n columnOrdering: ReturnType<typeof useColumnOrdering>;\n currentRow: ReturnType<typeof useCurrentRow>;\n editing: ReturnType<typeof useEditing>;\n enableFooter: boolean;\n fontSize: ReturnType<typeof useFontSize>;\n getSettings: () => Table3Settings;\n hoverState: ReturnType<typeof usePauseHoverState>;\n isPrinting: boolean;\n isUsingServer: boolean;\n printing: ReturnType<typeof usePrinting>;\n rowActions: ReturnType<typeof useRowActions>;\n rowClick: ReturnType<typeof useRowClick>;\n rowDrag: ReturnType<typeof useRowDrag>;\n rowDrop: ReturnType<typeof useRowDrop>;\n rowGoto: ReturnType<typeof useRowGoto>;\n rowHeight: ReturnType<typeof useRowHeight>;\n rowSelection: ReturnType<typeof useRowSelection>;\n search: ReturnType<typeof useSearch>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: Table3ColumnAlignment;\n className?: Table3ColumnClassNameHandler<TData>;\n control?: Table3ColumnControlRenderer<TData>;\n dataType?: Table3ColumnDataType;\n defaultWidth?: number;\n enableOrdering: boolean;\n enableSearch: boolean;\n enableTruncate: boolean;\n filters?: Table3FilterComparator[];\n footer?: Table3ColumnFooterRenderer;\n header: string;\n headerClassName?: string;\n menu?: Table3ColumnHeaderMenu;\n renderer?: Table3ColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n\n interface CellContext<TData extends RowData, TValue> {\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n }\n\n interface HeaderContext<TData extends RowData, TValue> {\n scrollToIndex: TableStrategy['scrollToIndex'];\n }\n}\n\nexport function useTable<TType = unknown>(props: Table3Props<TType>) {\n // options\n const options = useTablePreset(props);\n\n const tableOptions: Partial<RTableOptions<TType>> = {\n enableColumnFilters: options.enableFiltering,\n enableColumnResizing: options.enableColumnResizing,\n enableExpanding: options.enableRowExpansion,\n enableGlobalFilter: options.enableSearch,\n enableHiding: options.enableColumnHiding,\n enableRowSelection: options.enableRowSelection,\n enableMultiRowSelection: !options.enableRowSelectionSingle,\n enableSorting: options.enableSorting,\n };\n\n // resizing\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n // filtering\n if (tableOptions.enableColumnFilters) {\n if (!props.onFilter) {\n tableOptions.filterFns = {\n tacoFilter: (row: RTRow<TType>, columnId: string, filter: any) => columnFilterFn(row.getValue(columnId), filter),\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n }\n\n // we don't tableOptions.manualFiltering = true; because it breaks global filtering, server filtering still works :shrug:\n }\n\n // search\n if (tableOptions.enableGlobalFilter) {\n // search is always client side, since we call loadAll when searching\n tableOptions.globalFilterFn = (row: RTRow<TType>, columnId: string, searchQuery: string) => {\n try {\n if (row.original) {\n const cell = row.getAllCells().find(cell => cell.column.id === columnId);\n const columnMeta = cell?.column.columnDef.meta;\n\n if (cell && cell.column.getIsVisible() && columnMeta?.enableSearch) {\n const cellValue = getCellValueAsString(row.original[columnId], columnMeta?.dataType);\n\n if (cellValue !== undefined) {\n return globalFilterFn(cellValue, searchQuery);\n }\n }\n return false;\n }\n } catch {\n //\n }\n\n return false;\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n tableOptions.getColumnCanGlobalFilter = (column: RTColumn<TType>) =>\n (column.columnDef.meta as ColumnMeta<TType, unknown>).enableSearch ?? true;\n }\n\n // sorting\n if (options.enableSorting) {\n if (props.onSort) {\n tableOptions.manualSorting = true;\n // onSort is called as a listener to let the consumer update their data, so we don't use onSortingChange\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n const [defaultSettings, setSettings] = useSettings(props.id, props.defaultSettings, props.onChangeSettings);\n\n // custom features\n const columnFreezing = useColumnFreezing(\n // temporarily see if deprecated frozenColumnCount is there\n defaultSettings.columnFreezingIndex ?? (defaultSettings as any)?.frozenColumnCount ?? props.defaultColumnFreezingIndex,\n options\n );\n const columnOrdering = useColumnOrdering(options);\n const currentRow = useCurrentRow(props.defaultCurrentRowIndex);\n const editing = useEditing(options.enableEditing, props.onSave);\n const fontSize = useFontSize(options.enableFontSize, defaultSettings.fontSize);\n const hoverState = usePauseHoverState();\n const printing = usePrinting(options.enablePrinting, props.loadAll, defaultSettings.showWarningWhenPrintingLargeDataset);\n const rowActions = useRowActions<TType>(props.actionsForRow, props.actionsForRowLength);\n const rowClick = useRowClick<TType>(props.onRowClick);\n const rowDrag = useRowDrag(options.enableRowDrag);\n const rowDrop = useRowDrop(options.enableRowDrop, props.onRowDrop);\n const rowGoto = useRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowHeight = useRowHeight(\n options.enableRowHeight,\n // temporarily see if deprecated rowDensity is there\n defaultSettings.rowHeight ?? (defaultSettings as any)?.rowDensity\n );\n const rowSelection = useRowSelection();\n const search = useSearch(options.enableSearch, defaultSettings.excludeUnmatchedRecordsInSearch, props.loadAll);\n\n // columns\n const { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting } = useConvertChildrenToColumns<TType>(\n props,\n options,\n editing\n );\n\n // built-in features\n const initialState: Partial<TableState> = React.useMemo(() => {\n const sanitizeSortedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);\n\n const state: Partial<TableState> = {\n columnOrder: ensureOrdering<TType>(columns, defaultSettings.columnOrder),\n columnSizing: defaultSettings.columnSizing ?? defaultColumnSizing,\n columnVisibility: defaultSettings.columnVisibility ?? defaultColumnVisibility,\n sorting: defaultSettings.sorting ? defaultSettings.sorting.filter(sanitizeSortedColumns) : defaultSorting,\n };\n\n // we don't save these outside the table, but they need to be here for print to inherit them - see PrintButton.tsx\n if ((props.defaultSettings as any)?.columnFilters) {\n state.columnFilters = (props.defaultSettings as any)?.columnFilters;\n }\n\n if ((props.defaultSettings as any)?.globalFilter) {\n state.globalFilter = (props.defaultSettings as any)?.globalFilter;\n }\n\n return state;\n }, []);\n\n const getSettings = () => {\n const state = table.getState();\n return {\n columnFreezingIndex: columnFreezing.frozenColumnIndex,\n columnOrder: columnOrdering.isEnabled ? state.columnOrder : undefined,\n columnSizing: table.options.enableColumnResizing ? state.columnSizing : undefined,\n columnVisibility: table.options.enableHiding ? state.columnVisibility : undefined,\n excludeUnmatchedRecordsInSearch: search.excludeUnmatchedResults,\n fontSize: fontSize.isEnabled ? fontSize.size : undefined,\n rowHeight: rowHeight.isEnabled ? rowHeight.height : undefined,\n showWarningWhenPrintingLargeDataset: printing.printWarningDialogVisibility,\n sorting: state.sorting,\n };\n };\n\n const table = useReactTable<TType>({\n data: props.data,\n columns,\n getCoreRowModel: getCoreRowModel(),\n initialState,\n ...tableOptions,\n //debugAll: true,\n meta: {\n columnFreezing,\n columnOrdering,\n currentRow,\n editing,\n enableFooter: options.enableFooter,\n fontSize,\n getSettings,\n hoverState,\n isPrinting: props.id.endsWith('_print'),\n isUsingServer: !!props.loadPage,\n printing,\n rowActions: rowActions as any,\n rowClick: rowClick as any,\n rowDrag,\n rowDrop,\n rowGoto,\n rowHeight,\n rowSelection,\n search,\n },\n });\n\n // listeners\n useCurrentRowListener(table);\n useEditingStateListener(table);\n useFilteringStateListener(table, props.onFilter);\n useRowSelectionListener(table, props.onRowSelect);\n useSettingsStateListener(table, setSettings);\n useShortcutsListener(table, props.shortcuts);\n useServerLoadingListener(table, props.loadPage);\n useSortingStateListener(table, props.onSort);\n\n return { table, length: props.length ?? props.data.length };\n}\n"],"names":["useTable","props","options","useTablePreset","tableOptions","enableColumnFilters","enableFiltering","enableColumnResizing","enableExpanding","enableRowExpansion","enableGlobalFilter","enableSearch","enableHiding","enableColumnHiding","enableRowSelection","enableMultiRowSelection","enableRowSelectionSingle","enableSorting","columnResizeMode","onFilter","filterFns","tacoFilter","row","columnId","filter","columnFilterFn","getValue","getFilteredRowModel","globalFilterFn","searchQuery","original","cell","getAllCells","find","column","id","columnMeta","columnDef","meta","getIsVisible","cellValue","getCellValueAsString","dataType","undefined","getColumnCanGlobalFilter","_column$columnDef$met","onSort","manualSorting","getSortedRowModel","defaultSettings","setSettings","useSettings","onChangeSettings","columnFreezing","useColumnFreezing","_ref","_defaultSettings$colu","columnFreezingIndex","frozenColumnCount","defaultColumnFreezingIndex","columnOrdering","useColumnOrdering","currentRow","useCurrentRow","defaultCurrentRowIndex","editing","useEditing","enableEditing","onSave","fontSize","useFontSize","enableFontSize","hoverState","usePauseHoverState","printing","usePrinting","enablePrinting","loadAll","showWarningWhenPrintingLargeDataset","rowActions","useRowActions","actionsForRow","actionsForRowLength","rowClick","useRowClick","onRowClick","rowDrag","useRowDrag","enableRowDrag","rowDrop","useRowDrop","enableRowDrop","onRowDrop","rowGoto","useRowGoto","enableRowGoto","onRowGoto","rowHeight","useRowHeight","enableRowHeight","_defaultSettings$rowH","rowDensity","rowSelection","useRowSelection","search","useSearch","excludeUnmatchedRecordsInSearch","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","useConvertChildrenToColumns","initialState","React","useMemo","sanitizeSortedColumns","definedColumn","state","columnOrder","ensureOrdering","columnSizing","_defaultSettings$colu2","columnVisibility","_defaultSettings$colu3","sorting","_props$defaultSetting","columnFilters","_props$defaultSetting2","_props$defaultSetting3","globalFilter","_props$defaultSetting4","getSettings","table","getState","frozenColumnIndex","isEnabled","excludeUnmatchedResults","size","height","printWarningDialogVisibility","useReactTable","data","getCoreRowModel","enableFooter","isPrinting","endsWith","isUsingServer","loadPage","useCurrentRowListener","useEditingStateListener","useFilteringStateListener","useRowSelectionListener","onRowSelect","useSettingsStateListener","useShortcutsListener","shortcuts","useServerLoadingListener","useSortingStateListener","length","_props$length"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA0GgBA,QAAQA,CAAkBC,KAAyB;;;EAE/D,MAAMC,OAAO,GAAGC,cAAc,CAACF,KAAK,CAAC;EAErC,MAAMG,YAAY,GAAkC;IAChDC,mBAAmB,EAAEH,OAAO,CAACI,eAAe;IAC5CC,oBAAoB,EAAEL,OAAO,CAACK,oBAAoB;IAClDC,eAAe,EAAEN,OAAO,CAACO,kBAAkB;IAC3CC,kBAAkB,EAAER,OAAO,CAACS,YAAY;IACxCC,YAAY,EAAEV,OAAO,CAACW,kBAAkB;IACxCC,kBAAkB,EAAEZ,OAAO,CAACY,kBAAkB;IAC9CC,uBAAuB,EAAE,CAACb,OAAO,CAACc,wBAAwB;IAC1DC,aAAa,EAAEf,OAAO,CAACe;GAC1B;;EAGD,IAAIb,YAAY,CAACG,oBAAoB,EAAE;IACnCH,YAAY,CAACc,gBAAgB,GAAG,UAAU;;;EAI9C,IAAId,YAAY,CAACC,mBAAmB,EAAE;IAClC,IAAI,CAACJ,KAAK,CAACkB,QAAQ,EAAE;MACjBf,YAAY,CAACgB,SAAS,GAAG;QACrBC,UAAU,EAAEA,CAACC,GAAiB,EAAEC,QAAgB,EAAEC,MAAW,KAAKC,cAAc,CAACH,GAAG,CAACI,QAAQ,CAACH,QAAQ,CAAC,EAAEC,MAAM;OAClH;MACDpB,YAAY,CAACuB,mBAAmB,GAAGA,m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iB;GAAQ;AAC/D;;;;"}
1
+ {"version":3,"file":"useTable.js","sources":["../../../../../../../../src/components/Table3/hooks/useTable.tsx"],"sourcesContent":["import React from 'react';\nimport {\n getCoreRowModel,\n useReactTable,\n Row as RTRow,\n RowData,\n Column as RTColumn,\n TableOptions as RTableOptions,\n TableState,\n getSortedRowModel,\n getFilteredRowModel,\n ColumnMeta,\n} from '@tanstack/react-table';\nimport {\n Table3ColumnAlignment,\n Table3ColumnRenderer,\n Table3Props,\n Table3ColumnHeaderMenu,\n Table3ColumnControlRenderer,\n Table3ColumnDataType,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n TableStrategy,\n Table3FilterComparator,\n Table3Settings,\n} from '../types';\nimport { useCurrentRow } from './features/useCurrentRow';\nimport { usePauseHoverState } from './features/usePauseHoverState';\nimport { useTablePreset } from './useTablePreset';\nimport { useRowHeight } from './features/useRowHeight';\nimport { useFontSize } from './features/useFontSize';\nimport { useRowSelectionListener } from './listeners/useRowSelectionListener';\nimport { useRowDrag } from './features/useRowDrag';\nimport { useSettingsStateListener } from './listeners/useSettingsStateListener';\nimport { columnFilterFn, globalFilterFn } from '../util/filtering';\nimport { useSortingStateListener } from './listeners/useSortingStateListener';\nimport { useFilteringStateListener } from './listeners/useFilteringStateListener';\nimport { useCurrentRowListener } from './listeners/useCurrentRowListener';\nimport { useColumnFreezing } from './features/useColumnFreezing';\nimport { useRowSelection } from './features/useRowSelection';\nimport { useRowClick } from './features/useRowClick';\nimport { ensureOrdering, useColumnOrdering } from './features/useColumnOrdering';\nimport { useRowDrop } from './features/useRowDrop';\nimport { useConvertChildrenToColumns } from './useConvertChildrenToColumns';\nimport { useEditing } from './features/useEditing';\nimport { usePrinting } from './features/usePrinting';\nimport { useShortcutsListener } from './listeners/useShortcutsListener';\nimport { useRowGoto } from './features/useRowGoto';\nimport { useServerLoadingListener } from './listeners/useServerLoadingListener';\nimport { useEditingStateListener } from './listeners/useEditingStateListener';\nimport { useSearch } from './features/useSearch';\nimport { useRowActions } from './features/useRowActions';\nimport { useSettings } from './features/useSettings';\nimport { getCellValueAsString } from '../util/columns';\nimport { Table3Validation, useValidation } from './features/useValidation';\nimport { usePauseShortcuts } from './features/usePauseShortcuts';\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useColumnFreezing>;\n columnOrdering: ReturnType<typeof useColumnOrdering>;\n currentRow: ReturnType<typeof useCurrentRow>;\n editing: ReturnType<typeof useEditing>;\n enableFooter: boolean;\n fontSize: ReturnType<typeof useFontSize>;\n getSettings: () => Table3Settings;\n hoverState: ReturnType<typeof usePauseHoverState>;\n isPrinting: boolean;\n isUsingServer: boolean;\n printing: ReturnType<typeof usePrinting>;\n rowActions: ReturnType<typeof useRowActions>;\n rowClick: ReturnType<typeof useRowClick>;\n rowDrag: ReturnType<typeof useRowDrag>;\n rowDrop: ReturnType<typeof useRowDrop>;\n rowGoto: ReturnType<typeof useRowGoto>;\n rowHeight: ReturnType<typeof useRowHeight>;\n rowSelection: ReturnType<typeof useRowSelection>;\n search: ReturnType<typeof useSearch>;\n shortcutsState: ReturnType<typeof usePauseShortcuts>;\n validation: Table3Validation<TData>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: Table3ColumnAlignment;\n className?: Table3ColumnClassNameHandler<TData>;\n control?: Table3ColumnControlRenderer<TData>;\n dataType?: Table3ColumnDataType;\n defaultWidth?: number;\n enableOrdering: boolean;\n enableSearch: boolean;\n enableTruncate: boolean;\n filters?: Table3FilterComparator[];\n footer?: Table3ColumnFooterRenderer;\n header: string;\n headerClassName?: string;\n menu?: Table3ColumnHeaderMenu;\n renderer?: Table3ColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n\n interface CellContext<TData extends RowData, TValue> {\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n }\n\n interface HeaderContext<TData extends RowData, TValue> {\n scrollToIndex: TableStrategy['scrollToIndex'];\n }\n}\n\nexport function useTable<TType = unknown>(props: Table3Props<TType>) {\n // options\n const options = useTablePreset(props);\n\n const tableOptions: Partial<RTableOptions<TType>> = {\n enableColumnFilters: options.enableFiltering,\n enableColumnResizing: options.enableColumnResizing,\n enableExpanding: options.enableRowExpansion,\n enableGlobalFilter: options.enableSearch,\n enableHiding: options.enableColumnHiding,\n enableRowSelection: options.enableRowSelection,\n enableMultiRowSelection: !options.enableRowSelectionSingle,\n enableSorting: options.enableSorting,\n };\n\n // resizing\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n // filtering\n if (tableOptions.enableColumnFilters) {\n if (!props.onFilter) {\n tableOptions.filterFns = {\n tacoFilter: (row: RTRow<TType>, columnId: string, filter: any) => columnFilterFn(row.getValue(columnId), filter),\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n }\n\n // we don't tableOptions.manualFiltering = true; because it breaks global filtering, server filtering still works :shrug:\n }\n\n // search\n if (tableOptions.enableGlobalFilter) {\n // search is always client side, since we call loadAll when searching\n tableOptions.globalFilterFn = (row: RTRow<TType>, columnId: string, searchQuery: string) => {\n try {\n if (row.original) {\n const cell = row.getAllCells().find(cell => cell.column.id === columnId);\n const columnMeta = cell?.column.columnDef.meta;\n\n if (cell && cell.column.getIsVisible() && columnMeta?.enableSearch) {\n const cellValue = getCellValueAsString(row.original[columnId], columnMeta?.dataType);\n\n if (cellValue !== undefined) {\n return globalFilterFn(cellValue, searchQuery);\n }\n }\n return false;\n }\n } catch {\n //\n }\n\n return false;\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n tableOptions.getColumnCanGlobalFilter = (column: RTColumn<TType>) =>\n (column.columnDef.meta as ColumnMeta<TType, unknown>).enableSearch ?? true;\n }\n\n // sorting\n if (options.enableSorting) {\n if (props.onSort) {\n tableOptions.manualSorting = true;\n // onSort is called as a listener to let the consumer update their data, so we don't use onSortingChange\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n const [defaultSettings, setSettings] = useSettings(props.id, props.defaultSettings, props.onChangeSettings);\n\n // custom features\n const columnFreezing = useColumnFreezing(\n // temporarily see if deprecated frozenColumnCount is there\n defaultSettings.columnFreezingIndex ?? (defaultSettings as any)?.frozenColumnCount ?? props.defaultColumnFreezingIndex,\n options\n );\n const columnOrdering = useColumnOrdering(options);\n const currentRow = useCurrentRow(props.defaultCurrentRowIndex);\n const validation = useValidation<TType>(props.onCellValidate, props.onRowValidate);\n const editing = useEditing<TType>(options.enableEditing, validation, props.onSave);\n const fontSize = useFontSize(options.enableFontSize, defaultSettings.fontSize);\n const hoverState = usePauseHoverState();\n const printing = usePrinting(options.enablePrinting, props.loadAll, defaultSettings.showWarningWhenPrintingLargeDataset);\n const rowActions = useRowActions<TType>(props.actionsForRow, props.actionsForRowLength);\n const rowClick = useRowClick<TType>(props.onRowClick);\n const rowDrag = useRowDrag(options.enableRowDrag);\n const rowDrop = useRowDrop(options.enableRowDrop, props.onRowDrop);\n const rowGoto = useRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowHeight = useRowHeight(\n options.enableRowHeight,\n // temporarily see if deprecated rowDensity is there\n defaultSettings.rowHeight ?? (defaultSettings as any)?.rowDensity\n );\n const rowSelection = useRowSelection();\n const search = useSearch(options.enableSearch, defaultSettings.excludeUnmatchedRecordsInSearch, props.loadAll);\n const shortcutsState = usePauseShortcuts();\n\n // columns\n const { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting } = useConvertChildrenToColumns<TType>(\n props,\n options,\n editing\n );\n\n // built-in features\n const initialState: Partial<TableState> = React.useMemo(() => {\n const sanitizeSortedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);\n\n const state: Partial<TableState> = {\n columnOrder: ensureOrdering<TType>(columns, defaultSettings.columnOrder),\n columnSizing: defaultSettings.columnSizing ?? defaultColumnSizing,\n columnVisibility: defaultSettings.columnVisibility ?? defaultColumnVisibility,\n sorting: defaultSettings.sorting ? defaultSettings.sorting.filter(sanitizeSortedColumns) : defaultSorting,\n };\n\n // we don't save these outside the table, but they need to be here for print to inherit them - see PrintButton.tsx\n if ((props.defaultSettings as any)?.columnFilters) {\n state.columnFilters = (props.defaultSettings as any)?.columnFilters;\n }\n\n if ((props.defaultSettings as any)?.globalFilter) {\n state.globalFilter = (props.defaultSettings as any)?.globalFilter;\n }\n\n return state;\n }, []);\n\n const getSettings = () => {\n const state = table.getState();\n return {\n columnFreezingIndex: columnFreezing.frozenColumnIndex,\n columnOrder: columnOrdering.isEnabled ? state.columnOrder : undefined,\n columnSizing: table.options.enableColumnResizing ? state.columnSizing : undefined,\n columnVisibility: table.options.enableHiding ? state.columnVisibility : undefined,\n excludeUnmatchedRecordsInSearch: search.excludeUnmatchedResults,\n fontSize: fontSize.isEnabled ? fontSize.size : undefined,\n rowHeight: rowHeight.isEnabled ? rowHeight.height : undefined,\n showWarningWhenPrintingLargeDataset: printing.printWarningDialogVisibility,\n sorting: state.sorting,\n };\n };\n\n const table = useReactTable<TType>({\n data: props.data,\n columns,\n getCoreRowModel: getCoreRowModel(),\n initialState,\n ...tableOptions,\n //debugAll: true,\n meta: {\n columnFreezing,\n columnOrdering,\n currentRow,\n editing,\n enableFooter: options.enableFooter,\n fontSize,\n getSettings,\n hoverState,\n isPrinting: props.id.endsWith('_print'),\n isUsingServer: !!props.loadPage,\n printing,\n rowActions: rowActions as any,\n rowClick: rowClick as any,\n rowDrag,\n rowDrop,\n rowGoto,\n rowHeight,\n rowSelection,\n search,\n shortcutsState,\n validation,\n },\n });\n\n // listeners\n useCurrentRowListener(table);\n useEditingStateListener(table);\n useFilteringStateListener(table, props.onFilter);\n useRowSelectionListener(table, props.onRowSelect);\n useSettingsStateListener(table, setSettings);\n useShortcutsListener(table, props.shortcuts);\n useServerLoadingListener(table, props.loadPage);\n useSortingStateListener(table, props.onSort);\n\n return { table, length: props.length ?? props.data.length };\n}\n"],"names":["useTable","props","options","useTablePreset","tableOptions","enableColumnFilters","enableFiltering","enableColumnResizing","enableExpanding","enableRowExpansion","enableGlobalFilter","enableSearch","enableHiding","enableColumnHiding","enableRowSelection","enableMultiRowSelection","enableRowSelectionSingle","enableSorting","columnResizeMode","onFilter","filterFns","tacoFilter","row","columnId","filter","columnFilterFn","getValue","getFilteredRowModel","globalFilterFn","searchQuery","original","cell","getAllCells","find","column","id","columnMeta","columnDef","meta","getIsVisible","cellValue","getCellValueAsString","dataType","undefined","getColumnCanGlobalFilter","_column$columnDef$met","onSort","manualSorting","getSortedRowModel","defaultSettings","setSettings","useSettings","onChangeSettings","columnFreezing","useColumnFreezing","_ref","_defaultSettings$colu","columnFreezingIndex","frozenColumnCount","defaultColumnFreezingIndex","columnOrdering","useColumnOrdering","currentRow","useCurrentRow","defaultCurrentRowIndex","validation","useValidation","onCellValidate","onRowValidate","editing","useEditing","enableEditing","onSave","fontSize","useFontSize","enableFontSize","hoverState","usePauseHoverState","printing","usePrinting","enablePrinting","loadAll","showWarningWhenPrintingLargeDataset","rowActions","useRowActions","actionsForRow","actionsForRowLength","rowClick","useRowClick","onRowClick","rowDrag","useRowDrag","enableRowDrag","rowDrop","useRowDrop","enableRowDrop","onRowDrop","rowGoto","useRowGoto","enableRowGoto","onRowGoto","rowHeight","useRowHeight","enableRowHeight","_defaultSettings$rowH","rowDensity","rowSelection","useRowSelection","search","useSearch","excludeUnmatchedRecordsInSearch","shortcutsState","usePauseShortcuts","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","useConvertChildrenToColumns","initialState","React","useMemo","sanitizeSortedColumns","definedColumn","state","columnOrder","ensureOrdering","columnSizing","_defaultSettings$colu2","columnVisibility","_defaultSettings$colu3","sorting","_props$defaultSetting","columnFilters","_props$defaultSetting2","_props$defaultSetting3","globalFilter","_props$defaultSetting4","getSettings","table","getState","frozenColumnIndex","isEnabled","excludeUnmatchedResults","size","height","printWarningDialogVisibility","useReactTable","data","getCoreRowModel","enableFooter","isPrinting","endsWith","isUsingServer","loadPage","useCurrentRowListener","useEditingStateListener","useFilteringStateListener","useRowSelectionListener","onRowSelect","useSettingsStateListener","useShortcutsListener","shortcuts","useServerLoadingListener","useSortingStateListener","length","_props$length"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA8GgBA,QAAQA,CAAkBC,KAAyB;;;EAE/D,MAAMC,OAAO,GAAGC,cAAc,CAACF,KAAK,CAAC;EAErC,MAAMG,YAAY,GAAkC;IAChDC,mBAAmB,EAAEH,OAAO,CAACI,eAAe;IAC5CC,oBAAoB,EAAEL,OAAO,CAACK,oBAAoB;IAClDC,eAAe,EAAEN,OAAO,CAACO,kBAAkB;IAC3CC,kBAAkB,EAAER,OAAO,CAACS,YAAY;IACxCC,YAAY,EAAEV,OAAO,CAACW,kBAAkB;IACxCC,kBAAkB,EAAEZ,OAAO,CAACY,kBAAkB;IAC9CC,uBAAuB,EAAE,CAACb,OAAO,CAACc,wBAAwB;IAC1DC,aAAa,EAAEf,OAAO,CAACe;GAC1B;;EAGD,IAAIb,YAAY,CAACG,oBAAoB,EAAE;IACnCH,YAAY,CAACc,gBAAgB,GAAG,UAAU;;;EAI9C,IAAId,YAAY,CAACC,mBAAmB,EAAE;IAClC,IAAI,CAACJ,KAAK,CAACkB,QAAQ,EAAE;MACjBf,YAAY,CAACgB,SAAS,GAAG;QACrBC,UAAU,EAAEA,CAACC,GAAiB,EAAEC,QAAgB,EAAEC,MAAW,KAAKC,cAAc,CAACH,GAAG,CAACI,QAAQ,CAACH,QAAQ,CAAC,EAAEC,MAAM;OAClH;MACDpB,YAAY,CAACuB,mBAAmB,GAAGA,mBAAmB,EAAE;;;;;EAOhE,IAAIvB,YAAY,CAACM,kBAAkB,EAAE;;IAEjCN,YAAY,CAACwB,cAAc,GAAG,CAACN,GAAiB,EAAEC,QAAgB,EAAEM,WAAmB;MACnF,IAAI;QACA,IAAIP,GAAG,CAACQ,QAAQ,EAAE;UACd,MAAMC,IAAI,GAAGT,GAAG,CAACU,WAAW,EAAE,CAACC,IAAI,CAACF,IAAI,IAAIA,IAAI,CAACG,MAAM,CAACC,EAA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AEA,eAAe,EAAE;IAClC9B,YAAY;IACZ,GAAGlH,YAAY;;IAEfkC,IAAI,EAAE;MACFe,cAAc;MACdO,cAAc;MACdE,UAAU;MACVO,OAAO;MACPgF,YAAY,EAAEnJ,OAAO,CAACmJ,YAAY;MAClC5E,QAAQ;MACRgE,WAAW;MACX7D,UAAU;MACV0E,UAAU,EAAErJ,KAAK,CAACkC,EAAE,CAACoH,QAAQ,CAAC,QAAQ,CAAC;MACvCC,aAAa,EAAE,CAAC,CAACvJ,KAAK,CAACwJ,QAAQ;MAC/B3E,QAAQ;MACRK,UAAU,EAAEA,UAAiB;MAC7BI,QAAQ,EAAEA,QAAe;MACzBG,OAAO;MACPG,OAAO;MACPI,OAAO;MACPI,SAAS;MACTK,YAAY;MACZE,MAAM;MACNG,cAAc;MACd9C;;GAEP,CAAC;;EAGFyF,qBAAqB,CAAChB,KAAK,CAAC;EAC5BiB,uBAAuB,CAACjB,KAAK,CAAC;EAC9BkB,yBAAyB,CAAClB,KAAK,EAAEzI,KAAK,CAACkB,QAAQ,CAAC;EAChD0I,uBAAuB,CAACnB,KAAK,EAAEzI,KAAK,CAAC6J,WAAW,CAAC;EACjDC,wBAAwB,CAACrB,KAAK,EAAExF,WAAW,CAAC;EAC5C8G,oBAAoB,CAACtB,KAAK,EAAEzI,KAAK,CAACgK,SAAS,CAAC;EAC5CC,wBAAwB,CAACxB,KAAK,EAAEzI,KAAK,CAACwJ,QAAQ,CAAC;EAC/CU,uBAAuB,CAACzB,KAAK,EAAEzI,KAAK,CAAC6C,MAAM,CAAC;EAE5C,OAAO;IAAE4F,KAAK;IAAE0B,MAAM,GAAAC,aAAA,GAAEpK,KAAK,CAACmK,MAAM,cAAAC,aAAA,cAAAA,aAAA,GAAIpK,KAAK,CAACkJ,IAAI,CAACiB;GAAQ;AAC/D;;;;"}
@@ -1,7 +1,7 @@
1
1
  import React__default from 'react';
2
2
  import { flexRender } from '@tanstack/react-table';
3
- import { useVirtual } from 'react-virtual';
4
3
  import { Row } from '../components/rows/Row.js';
4
+ import { useVirtual } from 'react-virtual';
5
5
  import { ExpandedRow } from '../components/rows/ExpandedRow.js';
6
6
  import { rowHeightSizeEstimates } from '../components/rows/styles.js';
7
7
  import { SkeletonRow } from '../components/rows/SkeletonRow.js';
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../../../../../src/components/Table3/types.ts"],"sourcesContent":["import {\n ColumnFilter as RTColumnFilter,\n ColumnOrderState,\n ColumnSizingState,\n ColumnSort as RTTableColumnSort,\n SortingState,\n VisibilityState,\n BuiltInSortingFn,\n} from '@tanstack/react-table';\nimport { MenuProps } from '../Menu/Menu';\nimport { MenuItemProps } from '../Menu/components/Item';\n\nexport type Table3SortDirection = 'asc' | 'desc';\nexport type Table3SortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | BuiltInSortingFn\n | 'auto';\n\n// columns\nexport type Table3ColumnRenderer<TValue = unknown, TType = unknown> = (\n value: TValue,\n row: TType\n) => JSX.Element | string | number | null;\nexport type Table3ColumnFooterRenderer<TValue = unknown> = (values: TValue[]) => JSX.Element | string | number | null;\nexport type Table3ColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type Table3ColumnAlignment = 'left' | 'center' | 'right';\nexport type Table3ColumnDataType = 'auto' | 'number' | 'alphanumeric' | 'alphanumericCaseSensitive' | 'datetime' | 'boolean';\nexport type Table3ColumnHeaderMenu = (props: Partial<MenuProps>) => JSX.Element;\n\nexport type Table3ColumnControlProps = {\n className?: string;\n disabled?: boolean;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement>;\n setValue: (value: any) => void;\n value: any;\n};\nexport type Table3ColumnControlRenderer<TType = unknown> =\n | ((props: Table3ColumnControlProps, row?: TType) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'textarea';\n\ntype ValueOf<T> = T[keyof T];\n\nexport type Table3ColumnProps<TType = unknown> = ValueOf<{\n [K in keyof TType]: {\n accessor: K;\n } & {\n align?: Table3ColumnAlignment;\n className?: Table3ColumnClassNameHandler<TType>;\n control?: Table3ColumnControlRenderer<TType>;\n dataType?: Table3ColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: number | 'grow';\n enableFiltering?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: Table3FilterComparator[];\n footer?: Table3ColumnFooterRenderer;\n header: string;\n headerClassName?: string;\n menu?: Table3ColumnHeaderMenu;\n minWidth?: number;\n renderer?: Table3ColumnRenderer<TType[K], TType>;\n sort?: Table3SortDirection;\n sortFn?: Table3SortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type Table3GroupProps = {\n id: string;\n header: string;\n colSpan?: number;\n children: (JSX.Element | boolean | null | undefined)[];\n};\n\n// rows\nexport type DeprecatedRowDensity = 'compact' | 'normal' | 'comfortable' | 'spacious';\nexport type Table3RowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type Table3FontSize = 'small' | 'medium' | 'large';\nexport type Table3RowClickHandler<TType = unknown> = (row: TType) => void;\nexport type Table3RowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type Table3RowDropHandler<TType = any> = (event: React.DragEvent, row: TType) => void;\nexport type Table3RowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type Table3RowSelectionHandler<TType = unknown> = (rows: TType[]) => void;\nexport type Table3RowActionRenderer<TType = unknown> = (row: TType) => JSX.Element | null;\n\n// table\nexport type Table3Preset = 'display' | 'editable';\nexport type Table3Settings = {\n columnFreezingIndex?: number;\n columnOrder?: ColumnOrderState;\n columnSizing?: ColumnSizingState;\n columnVisibility?: VisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: Table3FontSize;\n rowHeight?: Table3RowHeight;\n showWarningWhenPrintingLargeDataset?: boolean;\n sorting?: SortingState;\n};\nexport type Table3SettingsHandler = (settings: Table3Settings) => void | Promise<void>;\n\nexport enum Table3FilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\n\nexport type Table3FilterValue = {\n comparator: Table3FilterComparator;\n value: any;\n};\n\nexport type Table3Filter = { id: string | null; value: Table3FilterValue };\n\nexport type ColumnFilter = RTColumnFilter;\nexport type Table3FilterHandler = (filters: ColumnFilter[]) => void;\nexport type Table3LoadPageHandler = (\n pageIndex: number,\n sorting: Table3ColumnSort[],\n filters: ColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport type Table3LoadAllHandler = (\n sorting: Table3ColumnSort[],\n filters: ColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport type Table3RowGotoHandler = (\n column: string,\n query: string,\n sorting: Table3ColumnSort[],\n filters: ColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type Table3ColumnSort = RTTableColumnSort;\nexport type Table3SortHandler = (sorting: Table3ColumnSort[]) => void;\nexport type TableStrategy = {\n renderBody: () => JSX.Element | JSX.Element[] | null;\n scrollToIndex: (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\n};\nexport type Table3ShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type Table3ShortcutHandlerObject<TType = unknown> = {\n handler: Table3ShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\nexport type Table3Shortcuts<TType = unknown> = Record<\n string,\n Table3ShortcutHandlerFn<TType> | Table3ShortcutHandlerObject<TType>\n>;\nexport type Table3SaveHandler<TType = unknown> = (data: TType) => Promise<void>;\n\nexport type Table3Options = {\n enableColumnFreezing: boolean;\n enableColumnHiding: boolean;\n enableColumnOrdering: boolean;\n enableColumnResizing: boolean;\n enableFontSize: boolean;\n enableFooter: boolean;\n enablePrinting: boolean;\n enableRowDrag: boolean;\n enableRowDrop: boolean;\n enableRowExpansion: boolean;\n enableRowGoto: boolean;\n enableRowHeight: boolean;\n enableRowSelection: boolean;\n enableRowSelectionSingle: boolean;\n enableEditing: boolean;\n enableFiltering: boolean;\n enableSearch: boolean;\n enableSorting: boolean;\n};\n\nexport type Table3CustomSettingRenderer = (props: Table3Settings) => React.ReactElement<MenuItemProps> | null;\n\nexport type Table3CommonProps<TType = unknown> = Partial<Table3Options> & {\n actionsForRow?: Table3RowActionRenderer<TType>[];\n actionsForRowLength?: number;\n autoFocus?: boolean;\n children: (JSX.Element | boolean | null | undefined)[];\n customSettings?: Table3CustomSettingRenderer[];\n data: TType[];\n defaultColumnFreezingIndex?: number;\n defaultCurrentRowIndex?: number;\n defaultSettings?: Table3Settings;\n emptyState?: () => JSX.Element | null;\n expandedRowRenderer?: Table3RowExpansionRenderer<TType>;\n id: string;\n onChangeSettings?: Table3SettingsHandler;\n onRowClick?: Table3RowClickHandler<TType>;\n onRowDrag?: Table3RowDragHandler<TType>;\n onRowDrop?: Table3RowDropHandler<TType>;\n onRowGoto?: Table3RowGotoHandler;\n onRowSelect?: Table3RowSelectionHandler<TType>;\n onFilter?: Table3FilterHandler;\n onSave?: Table3SaveHandler<TType>;\n onSort?: Table3SortHandler;\n preset?: Table3Preset;\n shortcuts?: Table3Shortcuts<TType>;\n toolbarLeft?: JSX.Element;\n toolbarRight?: JSX.Element;\n};\n\ninterface Table3ClientProps<TType = unknown> extends Table3CommonProps<TType> {\n length?: never;\n loadPage?: never;\n loadAll?: never;\n pageSize?: never;\n}\n\ninterface Table3ServerProps<TType = unknown> extends Table3CommonProps<TType> {\n length: number | undefined;\n loadPage: Table3LoadPageHandler;\n loadAll: Table3LoadAllHandler;\n pageSize?: number;\n}\n\nexport type Table3Props<TType = unknown> = Table3ClientProps<TType> | Table3ServerProps<TType>;\n\nexport type Table3Ref = HTMLDivElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n toggleEditing: (enabled: boolean | undefined) => void;\n };\n};\n\nexport type Table3Texts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n editing: {\n actions: {\n tooltip: string;\n save: string;\n clear: string;\n exit: string;\n };\n buttons: {\n edit: {\n tooltip: string;\n };\n };\n rowIndicator: {\n rowWillMove: string;\n rowWillBeHidden: string;\n rowWillMoveReasonSearch: string;\n rowWillMoveReasonFilter: string;\n rowWillMoveReasonSorting: string;\n };\n saving: {\n progress: string;\n complete: string;\n };\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n hiddenColumn: string;\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n};\n"],"names":["Table3FilterComparator"],"mappings":"IAqHYA;AAAZ,WAAYA,sBAAsB;EAC9BA,2EAAQ;EACRA,uFAAc;EACdA,6EAAS;EACTA,mFAAY;EACZA,qFAAa;EACbA,+EAAU;EACVA,6EAAS;EACTA,yEAAO;EACPA,+EAAU;EACVA,iGAAmB;EACnBA,wGAAsB;EACtBA,4EAAQ;EACRA,4EAAQ;EACRA,8EAAS;AACb,CAAC,EAfWA,sBAAsB,KAAtBA,sBAAsB;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../../../../../src/components/Table3/types.ts"],"sourcesContent":["import {\n ColumnFilter as RTColumnFilter,\n ColumnOrderState,\n ColumnSizingState,\n ColumnSort as RTTableColumnSort,\n SortingState,\n VisibilityState,\n BuiltInSortingFn,\n} from '@tanstack/react-table';\nimport { MenuProps } from '../Menu/Menu';\nimport { MenuItemProps } from '../Menu/components/Item';\n\nexport type Table3SortDirection = 'asc' | 'desc';\nexport type Table3SortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | BuiltInSortingFn\n | 'auto';\n\n// columns\nexport type Table3ColumnRenderer<TValue = unknown, TType = unknown> = (\n value: TValue,\n row: TType\n) => JSX.Element | string | number | null;\nexport type Table3ColumnFooterRenderer<TValue = unknown> = (values: TValue[]) => JSX.Element | string | number | null;\nexport type Table3ColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type Table3ColumnAlignment = 'left' | 'center' | 'right';\nexport type Table3ColumnDataType = 'auto' | 'number' | 'alphanumeric' | 'alphanumericCaseSensitive' | 'datetime' | 'boolean';\nexport type Table3ColumnHeaderMenu = (props: Partial<MenuProps>) => JSX.Element;\n\nexport type Table3ColumnControlProps = {\n className?: string;\n disabled?: boolean;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: any) => void;\n value: any;\n};\nexport type Table3ColumnControlRenderer<TType = unknown> =\n | ((props: Table3ColumnControlProps, row?: TType) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'textarea';\n\ntype ValueOf<T> = T[keyof T];\n\nexport type Table3ColumnProps<TType = unknown> = ValueOf<{\n [K in keyof TType]: {\n accessor: K;\n } & {\n align?: Table3ColumnAlignment;\n className?: Table3ColumnClassNameHandler<TType>;\n control?: Table3ColumnControlRenderer<TType>;\n dataType?: Table3ColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: number | 'grow';\n enableFiltering?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: Table3FilterComparator[];\n footer?: Table3ColumnFooterRenderer;\n header: string;\n headerClassName?: string;\n menu?: Table3ColumnHeaderMenu;\n minWidth?: number;\n renderer?: Table3ColumnRenderer<TType[K], TType>;\n sort?: Table3SortDirection;\n sortFn?: Table3SortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type Table3GroupProps = {\n id: string;\n header: string;\n colSpan?: number;\n children: (JSX.Element | boolean | null | undefined)[];\n};\n\n// rows\nexport type DeprecatedRowDensity = 'compact' | 'normal' | 'comfortable' | 'spacious';\nexport type Table3RowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type Table3FontSize = 'small' | 'medium' | 'large';\nexport type Table3RowClickHandler<TType = unknown> = (row: TType) => void;\nexport type Table3RowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type Table3RowDropHandler<TType = any> = (event: React.DragEvent, row: TType) => void;\nexport type Table3RowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type Table3RowSelectionHandler<TType = unknown> = (rows: TType[]) => void;\nexport type Table3RowActionRenderer<TType = unknown> = (row: TType) => JSX.Element | null;\n\n// table\nexport type Table3Preset = 'display' | 'editable';\nexport type Table3Settings = {\n columnFreezingIndex?: number;\n columnOrder?: ColumnOrderState;\n columnSizing?: ColumnSizingState;\n columnVisibility?: VisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: Table3FontSize;\n rowHeight?: Table3RowHeight;\n showWarningWhenPrintingLargeDataset?: boolean;\n sorting?: SortingState;\n};\nexport type Table3SettingsHandler = (settings: Table3Settings) => void | Promise<void>;\n\nexport enum Table3FilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\n\nexport type Table3FilterValue = {\n comparator: Table3FilterComparator;\n value: any;\n};\n\nexport type Table3Filter = { id: string | null; value: Table3FilterValue };\n\nexport type ColumnFilter = RTColumnFilter;\nexport type Table3FilterHandler = (filters: ColumnFilter[]) => void;\nexport type Table3LoadPageHandler = (\n pageIndex: number,\n sorting: Table3ColumnSort[],\n filters: ColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport type Table3LoadAllHandler = (\n sorting: Table3ColumnSort[],\n filters: ColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport type Table3RowGotoHandler = (\n column: string,\n query: string,\n sorting: Table3ColumnSort[],\n filters: ColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type Table3ColumnSort = RTTableColumnSort;\nexport type Table3SortHandler = (sorting: Table3ColumnSort[]) => void;\nexport type RowErrors = Record<string, string>;\nexport type Table3CellValidationHandler<TType = unknown> = (\n cellValue: any,\n cellId: string,\n row: TType\n) => Promise<RowErrors | undefined | void>;\nexport type Table3RowValidationHandler<TType = unknown> = (row: TType) => Promise<RowErrors | undefined | void>;\nexport type TableStrategy = {\n renderBody: () => JSX.Element | JSX.Element[] | null;\n scrollToIndex: (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\n};\nexport type Table3ShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type Table3ShortcutHandlerObject<TType = unknown> = {\n handler: Table3ShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\nexport type Table3Shortcuts<TType = unknown> = Record<\n string,\n Table3ShortcutHandlerFn<TType> | Table3ShortcutHandlerObject<TType>\n>;\nexport type Table3SaveHandler<TType = unknown> = (data: TType) => Promise<void>;\n\nexport type Table3Options = {\n enableColumnFreezing: boolean;\n enableColumnHiding: boolean;\n enableColumnOrdering: boolean;\n enableColumnResizing: boolean;\n enableFontSize: boolean;\n enableFooter: boolean;\n enablePrinting: boolean;\n enableRowDrag: boolean;\n enableRowDrop: boolean;\n enableRowExpansion: boolean;\n enableRowGoto: boolean;\n enableRowHeight: boolean;\n enableRowSelection: boolean;\n enableRowSelectionSingle: boolean;\n enableEditing: boolean;\n enableFiltering: boolean;\n enableSearch: boolean;\n enableSorting: boolean;\n};\n\nexport type Table3CustomSettingRenderer = (props: Table3Settings) => React.ReactElement<MenuItemProps> | null;\n\nexport type Table3CommonProps<TType = unknown> = Partial<Table3Options> & {\n actionsForRow?: Table3RowActionRenderer<TType>[];\n actionsForRowLength?: number;\n autoFocus?: boolean;\n children: (JSX.Element | boolean | null | undefined)[];\n customSettings?: Table3CustomSettingRenderer[];\n data: TType[];\n defaultColumnFreezingIndex?: number;\n defaultCurrentRowIndex?: number;\n defaultSettings?: Table3Settings;\n emptyState?: () => JSX.Element | null;\n expandedRowRenderer?: Table3RowExpansionRenderer<TType>;\n id: string;\n onChangeSettings?: Table3SettingsHandler;\n onRowClick?: Table3RowClickHandler<TType>;\n onRowDrag?: Table3RowDragHandler<TType>;\n onRowDrop?: Table3RowDropHandler<TType>;\n onRowGoto?: Table3RowGotoHandler;\n onRowSelect?: Table3RowSelectionHandler<TType>;\n onFilter?: Table3FilterHandler;\n onSave?: Table3SaveHandler<TType>;\n onSort?: Table3SortHandler;\n onCellValidate?: Table3CellValidationHandler<TType>;\n onRowValidate?: Table3RowValidationHandler<TType>;\n preset?: Table3Preset;\n shortcuts?: Table3Shortcuts<TType>;\n toolbarLeft?: JSX.Element;\n toolbarRight?: JSX.Element;\n rowIdentifier?: string;\n};\n\ninterface Table3ClientProps<TType = unknown> extends Table3CommonProps<TType> {\n length?: never;\n loadPage?: never;\n loadAll?: never;\n pageSize?: never;\n}\n\ninterface Table3ServerProps<TType = unknown> extends Table3CommonProps<TType> {\n length: number | undefined;\n loadPage: Table3LoadPageHandler;\n loadAll: Table3LoadAllHandler;\n pageSize?: number;\n}\n\nexport type Table3Props<TType = unknown> = Table3ClientProps<TType> | Table3ServerProps<TType>;\n\nexport type Table3Ref = HTMLDivElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n toggleEditing: (enabled: boolean | undefined) => void;\n };\n};\n\nexport type Table3Texts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n editing: {\n actions: {\n tooltip: string;\n save: string;\n clear: string;\n exit: string;\n };\n buttons: {\n edit: {\n tooltip: string;\n };\n };\n rowIndicator: {\n rowWillMove: string;\n rowWillBeHidden: string;\n rowWillMoveReasonSearch: string;\n rowWillMoveReasonFilter: string;\n rowWillMoveReasonSorting: string;\n };\n saving: {\n progress: string;\n complete: string;\n };\n clearChangesConfirmationDialog: {\n title: string;\n description: string;\n cancel: string;\n confirm: string;\n };\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n hiddenColumn: string;\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n validation: {\n index: string;\n alert: {\n unsavedEntries: (count?: number) => string;\n incompleteAndHavntBeenSaved: (count?: number) => string;\n };\n resetFiltersDialog: {\n title: string;\n description: string;\n cancel: string;\n confirm: string;\n };\n };\n};\n"],"names":["Table3FilterComparator"],"mappings":"IAqHYA;AAAZ,WAAYA,sBAAsB;EAC9BA,2EAAQ;EACRA,uFAAc;EACdA,6EAAS;EACTA,mFAAY;EACZA,qFAAa;EACbA,+EAAU;EACVA,6EAAS;EACTA,yEAAO;EACPA,+EAAU;EACVA,iGAAmB;EACnBA,wGAAsB;EACtBA,4EAAQ;EACRA,4EAAQ;EACRA,8EAAS;AACb,CAAC,EAfWA,sBAAsB,KAAtBA,sBAAsB;;;;"}
@@ -36,6 +36,26 @@ const willRowMoveAfterSorting = (value, cell, rowIndex, rows, desc) => {
36
36
  }
37
37
  return ((_resortedRows$index = resortedRows[index]) === null || _resortedRows$index === void 0 ? void 0 : _resortedRows$index.id) !== cell.row.id;
38
38
  };
39
+ // Last focused cell state (not react state)
40
+ class LastCellIndex {
41
+ constructor() {
42
+ this._value = '0';
43
+ }
44
+ get value() {
45
+ return this._value;
46
+ }
47
+ set value(val) {
48
+ this._value = val;
49
+ }
50
+ }
51
+ // Returns index of a closest parent column
52
+ function getColumnIndex(element) {
53
+ if (element) {
54
+ var _element$closest;
55
+ return (_element$closest = element.closest('[role=cell]')) === null || _element$closest === void 0 ? void 0 : _element$closest.getAttribute('data-column-index');
56
+ }
57
+ return null;
58
+ }
39
59
 
40
- export { focusableSelector, focussableNodeNames, hasChanged, willRowMoveAfterSorting };
60
+ export { LastCellIndex, focusableSelector, focussableNodeNames, getColumnIndex, hasChanged, willRowMoveAfterSorting };
41
61
  //# sourceMappingURL=editing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"editing.js","sources":["../../../../../../../../src/components/Table3/util/editing.ts"],"sourcesContent":["import { isDate } from 'date-fns';\nimport { isWeakEqual as isWeakEqualDate } from '../../../utils/date';\n\nexport const focussableNodeNames = ['A', 'BUTTON', 'INPUT', 'TEXTAREA', 'SELECT', 'DETAILS'];\nexport const focusableSelector = focussableNodeNames.join(', ');\n\nexport const hasChanged = (value, newValue) => {\n if (isDate(value) && isDate(newValue)) {\n return !isWeakEqualDate(value, newValue);\n } else if (Array.isArray(value)) {\n return JSON.stringify(value) !== JSON.stringify(newValue);\n }\n\n return value !== newValue;\n};\n\nexport const willRowMoveAfterSorting = (value, cell, rowIndex, rows, desc): boolean => {\n const miniSortRows = [{ ...cell.row, original: { ...cell.row.original, [cell.column.id]: value } }];\n // getValue is used by the built-in sort functons, so we need to make sure it returns the changed value\n miniSortRows[0].getValue = () => value;\n\n let index = 0;\n\n if (rowIndex > 0) {\n miniSortRows.unshift(rows[rowIndex - 1]);\n index = 1;\n }\n\n if (rowIndex < rows.length - 1) {\n miniSortRows.push(rows[rowIndex + 1]);\n }\n\n let resortedRows = [...miniSortRows].sort((a, b) => cell.column.getSortingFn()(a, b, cell.column.id));\n\n if (desc) {\n resortedRows = resortedRows.reverse();\n }\n\n return resortedRows[index]?.id !== cell.row.id;\n};\n"],"names":["focussableNodeNames","focusableSelector","join","hasChanged","value","newValue","isDate","isWeakEqualDate","Array","isArray","JSON","stringify","willRowMoveAfterSorting","cell","rowIndex","rows","desc","miniSortRows","row","original","column","id","getValue","index","unshift","length","push","resortedRows","sort","a","b","getSortingFn","reverse","_resortedRows$index"],"mappings":";;;MAGaA,mBAAmB,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS;MAC9EC,iBAAiB,gBAAGD,mBAAmB,CAACE,IAAI,CAAC,IAAI;MAEjDC,UAAU,GAAGA,CAACC,KAAK,EAAEC,QAAQ;EACtC,IAAIC,MAAM,CAACF,KAAK,CAAC,IAAIE,MAAM,CAACD,QAAQ,CAAC,EAAE;IACnC,OAAO,CAACE,WAAe,CAACH,KAAK,EAAEC,QAAQ,CAAC;GAC3C,MAAM,IAAIG,KAAK,CAACC,OAAO,CAACL,KAAK,CAAC,EAAE;IAC7B,OAAOM,IAAI,CAACC,SAAS,CAACP,KAAK,CAAC,KAAKM,IAAI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ts"],"sourcesContent":["import { isDate } from 'date-fns';\nimport { isWeakEqual as isWeakEqualDate } from '../../../utils/date';\n\nexport const focussableNodeNames = ['A', 'BUTTON', 'INPUT', 'TEXTAREA', 'SELECT', 'DETAILS'];\nexport const focusableSelector = focussableNodeNames.join(', ');\n\nexport const hasChanged = (value, newValue) => {\n if (isDate(value) && isDate(newValue)) {\n return !isWeakEqualDate(value, newValue);\n } else if (Array.isArray(value)) {\n return JSON.stringify(value) !== JSON.stringify(newValue);\n }\n\n return value !== newValue;\n};\n\nexport const willRowMoveAfterSorting = (value, cell, rowIndex, rows, desc): boolean => {\n const miniSortRows = [{ ...cell.row, original: { ...cell.row.original, [cell.column.id]: value } }];\n // getValue is used by the built-in sort functons, so we need to make sure it returns the changed value\n miniSortRows[0].getValue = () => value;\n\n let index = 0;\n\n if (rowIndex > 0) {\n miniSortRows.unshift(rows[rowIndex - 1]);\n index = 1;\n }\n\n if (rowIndex < rows.length - 1) {\n miniSortRows.push(rows[rowIndex + 1]);\n }\n\n let resortedRows = [...miniSortRows].sort((a, b) => cell.column.getSortingFn()(a, b, cell.column.id));\n\n if (desc) {\n resortedRows = resortedRows.reverse();\n }\n\n return resortedRows[index]?.id !== cell.row.id;\n};\n// Last focused cell state (not react state)\nexport class LastCellIndex {\n _value: string | null | undefined = '0';\n get value() {\n return this._value;\n }\n set value(val: string | null | undefined) {\n this._value = val;\n }\n}\n\n// Returns index of a closest parent column\nexport function getColumnIndex(element: Element) {\n if (element) {\n return element.closest('[role=cell]')?.getAttribute('data-column-index');\n }\n\n return null;\n}\n"],"names":["focussableNodeNames","focusableSelector","join","hasChanged","value","newValue","isDate","isWeakEqualDate","Array","isArray","JSON","stringify","willRowMoveAfterSorting","cell","rowIndex","rows","desc","miniSortRows","row","original","column","id","getValue","index","unshift","length","push","resortedRows","sort","a","b","getSortingFn","reverse","_resortedRows$index","LastCellIndex","constructor","_value","val","getColumnIndex","element","_element$closest","closest","getAttribute"],"mappings":";;;MAGaA,mBAA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