@apia/table 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +28 -0
- package/cleanDist.json +3 -0
- package/dist/index.d.ts +615 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3267 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3267 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import React, { useState, useMemo, forwardRef, useCallback } from 'react';
|
|
3
|
+
import { Box, Button, Input, Link, Spinner } from 'theme-ui';
|
|
4
|
+
import { useBreakpointIndex } from '@theme-ui/match-media';
|
|
5
|
+
import { getVariant } from '@apia/theme';
|
|
6
|
+
import { useThrottleFn, useMount, useUpdateEffect as useUpdateEffect$1, useUnmount } from 'ahooks';
|
|
7
|
+
import { uniqueId } from 'lodash-es';
|
|
8
|
+
import { createSlice, injectReducers, shallowEqual as shallowEqual$1 } from '@apia/store';
|
|
9
|
+
import { addBoundary, AriaLiveEmitter, formatMessage, useLatest, useUpdateEffect, getSpecificParent, isChild, autoDisconnectMutationObserver, getFocusSelector, cantFocusSelector, globalFocus, scrollParentIntoElement, customEvents, debugDispatcher, persistentStorage, EventEmitter, downloadUrl, arrayOrArray, useMount as useMount$1, getDateFormat } from '@apia/util';
|
|
10
|
+
import { shallowEqual } from 'react-redux';
|
|
11
|
+
import { useOtherTagButton, ApiaFilter, IconButton } from '@apia/components';
|
|
12
|
+
import { Icon } from '@apia/icons';
|
|
13
|
+
import { FaSortUp, FaSortDown, FaSort, FaMinusSquare, FaPlusSquare, FaSquare } from '@meronex/icons/fa';
|
|
14
|
+
import dayjs from 'dayjs';
|
|
15
|
+
|
|
16
|
+
const defaultLabels = {
|
|
17
|
+
noRegisters: window.FINDER_NO_DATA
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function getInitialState$1() {
|
|
21
|
+
return {
|
|
22
|
+
allowEdition: false,
|
|
23
|
+
allowSelection: true,
|
|
24
|
+
columns: [],
|
|
25
|
+
expandedRows: [],
|
|
26
|
+
isEditionMode: false,
|
|
27
|
+
isFocused: false,
|
|
28
|
+
filters: [],
|
|
29
|
+
focusedColumn: 0,
|
|
30
|
+
focusedRow: 0,
|
|
31
|
+
hasNonAdditionalFilters: false,
|
|
32
|
+
isMultiple: true,
|
|
33
|
+
nonAdditionalColumnsCount: 0,
|
|
34
|
+
rows: [],
|
|
35
|
+
selectedRows: [],
|
|
36
|
+
statesColumns: 0
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function addRowBoundary(newRow, state) {
|
|
41
|
+
const hasFiltersRow = !!state.filters.find(
|
|
42
|
+
(current) => !!state.columns.find((search) => search.name === current.column)
|
|
43
|
+
);
|
|
44
|
+
return addBoundary({
|
|
45
|
+
number: newRow,
|
|
46
|
+
min: hasFiltersRow ? -2 : -1,
|
|
47
|
+
max: Math.max(0, state.rows.length - 1)
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function addColumnBoundary(newColumn, state) {
|
|
51
|
+
return addBoundary({
|
|
52
|
+
number: newColumn,
|
|
53
|
+
min: 0,
|
|
54
|
+
max: state.nonAdditionalColumnsCount + state.statesColumns + (state.hasNonAdditionalFilters ? 1 : 0)
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function isBasicRow(row) {
|
|
58
|
+
return typeof row === "object" && !!row && "forbidSelection" in row;
|
|
59
|
+
}
|
|
60
|
+
function filterNonSellectableRows(state, newSelection) {
|
|
61
|
+
let expandedRowsBefore = 0;
|
|
62
|
+
return newSelection.filter((selectedRowIndex) => {
|
|
63
|
+
const row = state.rows[selectedRowIndex + expandedRowsBefore];
|
|
64
|
+
if (state.expandedRows.includes(selectedRowIndex))
|
|
65
|
+
expandedRowsBefore += 1;
|
|
66
|
+
return !(isBasicRow(row) && row.forbidSelection);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function setNewFocused(state, {
|
|
70
|
+
/**
|
|
71
|
+
* Propiedad proveniente del evento click o keydown.
|
|
72
|
+
*/
|
|
73
|
+
ctrlKey,
|
|
74
|
+
/**
|
|
75
|
+
* Propiedad proveniente del evento click o keydown.
|
|
76
|
+
*/
|
|
77
|
+
shiftKey,
|
|
78
|
+
newFocusedColumn,
|
|
79
|
+
newFocusedRow,
|
|
80
|
+
/**
|
|
81
|
+
* Con este método se puede seleccionar cuál celda
|
|
82
|
+
* va a recibir el foco y la selección, o solamente
|
|
83
|
+
* el foco si esta propiedad es pasada en false.
|
|
84
|
+
*/
|
|
85
|
+
shouldSelectNewFocused
|
|
86
|
+
}) {
|
|
87
|
+
var _a;
|
|
88
|
+
let actualNewFocusedRow = Math.round(
|
|
89
|
+
addRowBoundary((_a = newFocusedRow != null ? newFocusedRow : state.focusedRow) != null ? _a : 0, state) * 2
|
|
90
|
+
) / 2;
|
|
91
|
+
const actualNewFocusedColumn = addColumnBoundary(
|
|
92
|
+
newFocusedColumn != null ? newFocusedColumn : state.focusedColumn,
|
|
93
|
+
state
|
|
94
|
+
);
|
|
95
|
+
state.focusedColumn = actualNewFocusedColumn;
|
|
96
|
+
state.focusedRow = actualNewFocusedRow;
|
|
97
|
+
state.isFocused = shouldSelectNewFocused != null ? shouldSelectNewFocused : false;
|
|
98
|
+
if (shouldSelectNewFocused === false || actualNewFocusedRow < 0)
|
|
99
|
+
return;
|
|
100
|
+
if (Math.round(actualNewFocusedRow) - actualNewFocusedRow !== 0)
|
|
101
|
+
actualNewFocusedRow = Math.floor(actualNewFocusedRow);
|
|
102
|
+
const isDeselectingWithCtrl = ctrlKey && state.selectedRows.includes(actualNewFocusedRow);
|
|
103
|
+
if (state.allowSelection !== false) {
|
|
104
|
+
if (!ctrlKey && !shiftKey || state.isMultiple === false && !isDeselectingWithCtrl)
|
|
105
|
+
state.selectedRows = filterNonSellectableRows(state, [
|
|
106
|
+
actualNewFocusedRow
|
|
107
|
+
]);
|
|
108
|
+
else if (ctrlKey && state.isMultiple || isDeselectingWithCtrl) {
|
|
109
|
+
state.selectedRows = filterNonSellectableRows(
|
|
110
|
+
state,
|
|
111
|
+
state.selectedRows.includes(actualNewFocusedRow) ? state.selectedRows.filter(
|
|
112
|
+
(current) => current !== actualNewFocusedRow
|
|
113
|
+
) : [...state.selectedRows, actualNewFocusedRow]
|
|
114
|
+
);
|
|
115
|
+
} else if (shiftKey && state.isMultiple) {
|
|
116
|
+
const sortedSelectedRows = [...state.selectedRows].sort((a, b) => a - b);
|
|
117
|
+
let minSelectedRow = sortedSelectedRows[0];
|
|
118
|
+
let maxSelectedRow = sortedSelectedRows[sortedSelectedRows.length - 1];
|
|
119
|
+
if (minSelectedRow === void 0) {
|
|
120
|
+
state.selectedRows = filterNonSellectableRows(state, [
|
|
121
|
+
actualNewFocusedRow
|
|
122
|
+
]);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (actualNewFocusedRow < minSelectedRow)
|
|
126
|
+
minSelectedRow = actualNewFocusedRow;
|
|
127
|
+
if (actualNewFocusedRow > maxSelectedRow)
|
|
128
|
+
maxSelectedRow = actualNewFocusedRow;
|
|
129
|
+
const newSelectedRows = filterNonSellectableRows(
|
|
130
|
+
state,
|
|
131
|
+
new Array(maxSelectedRow - minSelectedRow + 1).fill("").map((_, i) => i + (minSelectedRow != null ? minSelectedRow : 0))
|
|
132
|
+
);
|
|
133
|
+
state.selectedRows = filterNonSellectableRows(state, newSelectedRows);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
var __defProp$p = Object.defineProperty;
|
|
139
|
+
var __getOwnPropSymbols$p = Object.getOwnPropertySymbols;
|
|
140
|
+
var __hasOwnProp$p = Object.prototype.hasOwnProperty;
|
|
141
|
+
var __propIsEnum$p = Object.prototype.propertyIsEnumerable;
|
|
142
|
+
var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
143
|
+
var __spreadValues$p = (a, b) => {
|
|
144
|
+
for (var prop in b || (b = {}))
|
|
145
|
+
if (__hasOwnProp$p.call(b, prop))
|
|
146
|
+
__defNormalProp$p(a, prop, b[prop]);
|
|
147
|
+
if (__getOwnPropSymbols$p)
|
|
148
|
+
for (var prop of __getOwnPropSymbols$p(b)) {
|
|
149
|
+
if (__propIsEnum$p.call(b, prop))
|
|
150
|
+
__defNormalProp$p(a, prop, b[prop]);
|
|
151
|
+
}
|
|
152
|
+
return a;
|
|
153
|
+
};
|
|
154
|
+
var __objRest$d = (source, exclude) => {
|
|
155
|
+
var target = {};
|
|
156
|
+
for (var prop in source)
|
|
157
|
+
if (__hasOwnProp$p.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
158
|
+
target[prop] = source[prop];
|
|
159
|
+
if (source != null && __getOwnPropSymbols$p)
|
|
160
|
+
for (var prop of __getOwnPropSymbols$p(source)) {
|
|
161
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$p.call(source, prop))
|
|
162
|
+
target[prop] = source[prop];
|
|
163
|
+
}
|
|
164
|
+
return target;
|
|
165
|
+
};
|
|
166
|
+
function willHandleKey(ev, state) {
|
|
167
|
+
const actualKey = ev.key.toLowerCase();
|
|
168
|
+
if (state.isEditionMode)
|
|
169
|
+
return false;
|
|
170
|
+
if (actualKey === " " && ev.ctrlKey)
|
|
171
|
+
return true;
|
|
172
|
+
if (actualKey === "a" && ev.ctrlKey)
|
|
173
|
+
return true;
|
|
174
|
+
if (actualKey === "m" && ev.ctrlKey)
|
|
175
|
+
return true;
|
|
176
|
+
if (state.draggingRow !== void 0) {
|
|
177
|
+
return ["Escape", "Enter"].includes(ev.key);
|
|
178
|
+
}
|
|
179
|
+
return [
|
|
180
|
+
"arrowup",
|
|
181
|
+
"arrowdown",
|
|
182
|
+
"arrowleft",
|
|
183
|
+
"arrowright",
|
|
184
|
+
"end",
|
|
185
|
+
"enter",
|
|
186
|
+
"home",
|
|
187
|
+
"pageup",
|
|
188
|
+
"pagedown"
|
|
189
|
+
].includes(ev.key.toLowerCase());
|
|
190
|
+
}
|
|
191
|
+
function handleKey(state, { ev }) {
|
|
192
|
+
const {
|
|
193
|
+
altKey: isAltPressed,
|
|
194
|
+
ctrlKey: isCtrlPressed,
|
|
195
|
+
key,
|
|
196
|
+
shiftKey: isShiftPressed
|
|
197
|
+
} = ev;
|
|
198
|
+
if (willHandleKey(ev, state))
|
|
199
|
+
ev.preventDefault();
|
|
200
|
+
const actualKey = key.toLowerCase();
|
|
201
|
+
const setFocus = (_a) => {
|
|
202
|
+
var _b = _a, {
|
|
203
|
+
newFocusedColumn,
|
|
204
|
+
newFocusedRow
|
|
205
|
+
} = _b, rest = __objRest$d(_b, [
|
|
206
|
+
"newFocusedColumn",
|
|
207
|
+
"newFocusedRow"
|
|
208
|
+
]);
|
|
209
|
+
return setNewFocused(state, __spreadValues$p({
|
|
210
|
+
altKey: isAltPressed,
|
|
211
|
+
ctrlKey: isCtrlPressed,
|
|
212
|
+
shiftKey: isShiftPressed,
|
|
213
|
+
newFocusedColumn,
|
|
214
|
+
newFocusedRow
|
|
215
|
+
}, rest));
|
|
216
|
+
};
|
|
217
|
+
if (!state.isEditionMode) {
|
|
218
|
+
if (actualKey === "enter" && (state.allowEdition === true || state.focusedRow < 0))
|
|
219
|
+
state.isEditionMode = true;
|
|
220
|
+
else
|
|
221
|
+
switch (actualKey) {
|
|
222
|
+
case "arrowup": {
|
|
223
|
+
let sumRate = state.expandedRows.includes(state.focusedRow - 1) ? 0.6 : 1;
|
|
224
|
+
if (Math.round(state.focusedRow) - state.focusedRow !== 0)
|
|
225
|
+
sumRate = 0.5;
|
|
226
|
+
setFocus({
|
|
227
|
+
newFocusedRow: state.focusedRow - sumRate,
|
|
228
|
+
shouldSelectNewFocused: !isCtrlPressed
|
|
229
|
+
});
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
case "arrowdown": {
|
|
233
|
+
let sumRate = state.expandedRows.includes(state.focusedRow) ? 0.6 : 1;
|
|
234
|
+
if (Math.round(state.focusedRow) - state.focusedRow !== 0)
|
|
235
|
+
sumRate = 0.5;
|
|
236
|
+
setFocus({
|
|
237
|
+
newFocusedRow: state.focusedRow + sumRate,
|
|
238
|
+
shouldSelectNewFocused: !isCtrlPressed
|
|
239
|
+
});
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
case "arrowleft":
|
|
243
|
+
case "arrowright": {
|
|
244
|
+
setFocus({
|
|
245
|
+
newFocusedColumn: state.focusedColumn + (actualKey === "arrowleft" ? -1 : 1),
|
|
246
|
+
shouldSelectNewFocused: !isCtrlPressed
|
|
247
|
+
});
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
case "home": {
|
|
251
|
+
if (isCtrlPressed)
|
|
252
|
+
setFocus({ newFocusedColumn: 0, newFocusedRow: 0, ctrlKey: false });
|
|
253
|
+
else
|
|
254
|
+
setFocus({ newFocusedColumn: 0 });
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
case "end": {
|
|
258
|
+
if (isCtrlPressed)
|
|
259
|
+
setFocus({
|
|
260
|
+
newFocusedRow: Number.POSITIVE_INFINITY,
|
|
261
|
+
newFocusedColumn: Number.POSITIVE_INFINITY,
|
|
262
|
+
ctrlKey: false
|
|
263
|
+
});
|
|
264
|
+
else
|
|
265
|
+
setFocus({
|
|
266
|
+
newFocusedColumn: Number.POSITIVE_INFINITY
|
|
267
|
+
});
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
case "pageup": {
|
|
271
|
+
setFocus({
|
|
272
|
+
newFocusedRow: state.focusedRow - 5,
|
|
273
|
+
shouldSelectNewFocused: !isCtrlPressed
|
|
274
|
+
});
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
case "pagedown": {
|
|
278
|
+
setFocus({
|
|
279
|
+
newFocusedRow: state.focusedRow + 5,
|
|
280
|
+
shouldSelectNewFocused: !isCtrlPressed
|
|
281
|
+
});
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
case " ": {
|
|
285
|
+
if (isCtrlPressed)
|
|
286
|
+
setFocus({
|
|
287
|
+
newFocusedRow: state.focusedRow
|
|
288
|
+
});
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
case "a": {
|
|
292
|
+
if (isCtrlPressed && state.allowSelection)
|
|
293
|
+
state.selectedRows = state.rows.map((_, i) => i);
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
} else
|
|
298
|
+
switch (actualKey) {
|
|
299
|
+
case "escape":
|
|
300
|
+
case "enter": {
|
|
301
|
+
if (state.isEditionMode)
|
|
302
|
+
state.isEditionMode = false;
|
|
303
|
+
ev.stopPropagation();
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
var __defProp$o = Object.defineProperty;
|
|
310
|
+
var __defProps$k = Object.defineProperties;
|
|
311
|
+
var __getOwnPropDescs$k = Object.getOwnPropertyDescriptors;
|
|
312
|
+
var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
|
|
313
|
+
var __hasOwnProp$o = Object.prototype.hasOwnProperty;
|
|
314
|
+
var __propIsEnum$o = Object.prototype.propertyIsEnumerable;
|
|
315
|
+
var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
316
|
+
var __spreadValues$o = (a, b) => {
|
|
317
|
+
for (var prop in b || (b = {}))
|
|
318
|
+
if (__hasOwnProp$o.call(b, prop))
|
|
319
|
+
__defNormalProp$o(a, prop, b[prop]);
|
|
320
|
+
if (__getOwnPropSymbols$o)
|
|
321
|
+
for (var prop of __getOwnPropSymbols$o(b)) {
|
|
322
|
+
if (__propIsEnum$o.call(b, prop))
|
|
323
|
+
__defNormalProp$o(a, prop, b[prop]);
|
|
324
|
+
}
|
|
325
|
+
return a;
|
|
326
|
+
};
|
|
327
|
+
var __spreadProps$k = (a, b) => __defProps$k(a, __getOwnPropDescs$k(b));
|
|
328
|
+
var __objRest$c = (source, exclude) => {
|
|
329
|
+
var target = {};
|
|
330
|
+
for (var prop in source)
|
|
331
|
+
if (__hasOwnProp$o.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
332
|
+
target[prop] = source[prop];
|
|
333
|
+
if (source != null && __getOwnPropSymbols$o)
|
|
334
|
+
for (var prop of __getOwnPropSymbols$o(source)) {
|
|
335
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$o.call(source, prop))
|
|
336
|
+
target[prop] = source[prop];
|
|
337
|
+
}
|
|
338
|
+
return target;
|
|
339
|
+
};
|
|
340
|
+
function shoutKeyhandlerLive(liveType, additionalData) {
|
|
341
|
+
var _a;
|
|
342
|
+
switch (liveType) {
|
|
343
|
+
case "howToEndDrag":
|
|
344
|
+
AriaLiveEmitter.emit("live", {
|
|
345
|
+
type: "assertive",
|
|
346
|
+
message: window.ARIA_HOW_TO_END_DRAG
|
|
347
|
+
});
|
|
348
|
+
break;
|
|
349
|
+
case "whichIsTheNewIndex":
|
|
350
|
+
AriaLiveEmitter.emit("live", {
|
|
351
|
+
type: "assertive",
|
|
352
|
+
message: formatMessage(window.ARIA_HOW_TO_WHICH_IS_THE_NEW_POSITION, {
|
|
353
|
+
TOK1: String((_a = additionalData == null ? void 0 : additionalData.newIndex) != null ? _a : 0)
|
|
354
|
+
})
|
|
355
|
+
});
|
|
356
|
+
break;
|
|
357
|
+
case "reset":
|
|
358
|
+
AriaLiveEmitter.emit("live", {
|
|
359
|
+
type: "reset",
|
|
360
|
+
message: ""
|
|
361
|
+
});
|
|
362
|
+
break;
|
|
363
|
+
default:
|
|
364
|
+
AriaLiveEmitter.emit("live", {
|
|
365
|
+
type: "assertive",
|
|
366
|
+
message: window.ARIA_HOW_TO_START_DRAG
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
let scrollTimeout;
|
|
371
|
+
function makeKeyHandler(actions, id, config) {
|
|
372
|
+
return function KeyHandler(_a) {
|
|
373
|
+
var _b = _a, {
|
|
374
|
+
children,
|
|
375
|
+
onChangeSelection,
|
|
376
|
+
onSelectRows
|
|
377
|
+
} = _b, props = __objRest$c(_b, [
|
|
378
|
+
"children",
|
|
379
|
+
"onChangeSelection",
|
|
380
|
+
"onSelectRows"
|
|
381
|
+
]);
|
|
382
|
+
var _a2, _b2;
|
|
383
|
+
const { run: keyHandler } = useThrottleFn((ev) => {
|
|
384
|
+
if (!["shift", "alt", "control"].includes(ev.key.toLowerCase())) {
|
|
385
|
+
responsiveTableStore.dispatch(actions.handleKey({ id, ev }));
|
|
386
|
+
}
|
|
387
|
+
}, (_a2 = config == null ? void 0 : config.throttleOptions) != null ? _a2 : { wait: 100 });
|
|
388
|
+
const [ref, setRef] = React.useState(null);
|
|
389
|
+
const selectedRows = useResponsiveTable(
|
|
390
|
+
(global) => {
|
|
391
|
+
var _a3;
|
|
392
|
+
const state = config.stateSelector(global);
|
|
393
|
+
return ((_a3 = state == null ? void 0 : state.selectedRows) != null ? _a3 : []).map((current) => ({
|
|
394
|
+
index: current,
|
|
395
|
+
row: state.rows[current]
|
|
396
|
+
}));
|
|
397
|
+
},
|
|
398
|
+
(a, b) => shallowEqual(
|
|
399
|
+
a.map((current) => current.index),
|
|
400
|
+
b.map((current) => current.index)
|
|
401
|
+
)
|
|
402
|
+
);
|
|
403
|
+
const selectedRowsRef = useLatest(selectedRows);
|
|
404
|
+
const focusedRow = useResponsiveTable((global) => {
|
|
405
|
+
var _a3;
|
|
406
|
+
const state = config.stateSelector(global);
|
|
407
|
+
return (_a3 = state == null ? void 0 : state.focusedRow) != null ? _a3 : -1;
|
|
408
|
+
});
|
|
409
|
+
const { allowKeyboardSorting, focusedCell, isEditionMode, isFocused } = useResponsiveTable((global) => {
|
|
410
|
+
const state = config.stateSelector(global);
|
|
411
|
+
return {
|
|
412
|
+
focusedCell: (state == null ? void 0 : state.focusedRow) !== void 0 ? `${state == null ? void 0 : state.focusedRow}_${state == null ? void 0 : state.focusedColumn}` : void 0,
|
|
413
|
+
isEditionMode: state == null ? void 0 : state.isEditionMode,
|
|
414
|
+
rows: state == null ? void 0 : state.rows,
|
|
415
|
+
isFocused: state == null ? void 0 : state.isFocused,
|
|
416
|
+
allowKeyboardSorting: state == null ? void 0 : state.allowRowsKeyboardSorting
|
|
417
|
+
};
|
|
418
|
+
}, shallowEqual);
|
|
419
|
+
useUpdateEffect(() => {
|
|
420
|
+
if (onChangeSelection)
|
|
421
|
+
onChangeSelection(selectedRows);
|
|
422
|
+
}, [onChangeSelection, selectedRows]);
|
|
423
|
+
const handleClick = React.useCallback(
|
|
424
|
+
(ev) => {
|
|
425
|
+
var _a3;
|
|
426
|
+
if (ev.target.closest(".moreInformationButton"))
|
|
427
|
+
return;
|
|
428
|
+
if (ev.shiftKey) {
|
|
429
|
+
(_a3 = document.getSelection()) == null ? void 0 : _a3.removeAllRanges();
|
|
430
|
+
}
|
|
431
|
+
const parentRow = getSpecificParent(
|
|
432
|
+
ev.target,
|
|
433
|
+
(current) => {
|
|
434
|
+
if (current.tagName.toLowerCase() === "table")
|
|
435
|
+
return null;
|
|
436
|
+
if (current.matches("tr")) {
|
|
437
|
+
return true;
|
|
438
|
+
}
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
);
|
|
442
|
+
const parentCell = getSpecificParent(
|
|
443
|
+
ev.target,
|
|
444
|
+
(current) => {
|
|
445
|
+
if (current.tagName.toLowerCase() === "table")
|
|
446
|
+
return null;
|
|
447
|
+
if (current.matches("td,th")) {
|
|
448
|
+
return true;
|
|
449
|
+
}
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
);
|
|
453
|
+
if (parentCell && parentRow) {
|
|
454
|
+
responsiveTableStore.dispatch(
|
|
455
|
+
actions.updateByClick({
|
|
456
|
+
altKey: ev.altKey,
|
|
457
|
+
id,
|
|
458
|
+
ctrlKey: ev.ctrlKey,
|
|
459
|
+
ariaColIndex: Number(parentCell.getAttribute("aria-colindex")),
|
|
460
|
+
rowIndex: Number(parentRow.getAttribute("data-focusindex")),
|
|
461
|
+
shiftKey: ev.shiftKey
|
|
462
|
+
})
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
},
|
|
466
|
+
[]
|
|
467
|
+
);
|
|
468
|
+
const handleDoubleClick = React.useCallback(
|
|
469
|
+
(ev) => {
|
|
470
|
+
if (isChild(
|
|
471
|
+
ev.target,
|
|
472
|
+
(current) => current.tagName === "THEAD"
|
|
473
|
+
))
|
|
474
|
+
return;
|
|
475
|
+
ev.preventDefault();
|
|
476
|
+
if (onSelectRows)
|
|
477
|
+
onSelectRows(selectedRowsRef.current, focusedRow);
|
|
478
|
+
},
|
|
479
|
+
[focusedRow, onSelectRows, selectedRowsRef]
|
|
480
|
+
);
|
|
481
|
+
const initialized = React.useRef(true);
|
|
482
|
+
const running = React.useRef(false);
|
|
483
|
+
const doFocusThings = React.useCallback(() => {
|
|
484
|
+
if (!running.current) {
|
|
485
|
+
running.current = true;
|
|
486
|
+
if (focusedCell === void 0) {
|
|
487
|
+
running.current = false;
|
|
488
|
+
return () => {
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
if (ref) {
|
|
492
|
+
const disconnectObserver = autoDisconnectMutationObserver(
|
|
493
|
+
ref,
|
|
494
|
+
() => {
|
|
495
|
+
scrollTimeout = setTimeout(() => {
|
|
496
|
+
var _a3;
|
|
497
|
+
const focusedElement = ref.querySelector(
|
|
498
|
+
'[data-focused="true"]'
|
|
499
|
+
);
|
|
500
|
+
let tableCellElement = null;
|
|
501
|
+
let tableCellWidget = null;
|
|
502
|
+
if (["td", "th"].includes(
|
|
503
|
+
(_a3 = focusedElement == null ? void 0 : focusedElement.tagName.toLowerCase()) != null ? _a3 : ""
|
|
504
|
+
)) {
|
|
505
|
+
tableCellElement = focusedElement;
|
|
506
|
+
tableCellWidget = focusedElement == null ? void 0 : focusedElement.querySelector(
|
|
507
|
+
getFocusSelector(":not(.debug_info__button)")
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
if ((focusedElement == null ? void 0 : focusedElement.tagName.toLowerCase()) === "tr") {
|
|
511
|
+
tableCellElement = focusedElement.querySelector("td,th");
|
|
512
|
+
tableCellWidget = focusedElement.querySelector(
|
|
513
|
+
getFocusSelector(":not(.debug_info__button)")
|
|
514
|
+
) || tableCellElement;
|
|
515
|
+
}
|
|
516
|
+
if (tableCellWidget) {
|
|
517
|
+
tableCellElement == null ? void 0 : tableCellElement.setAttribute("tabIndex", "-1");
|
|
518
|
+
tableCellWidget.setAttribute("tabIndex", "0");
|
|
519
|
+
} else
|
|
520
|
+
tableCellElement == null ? void 0 : tableCellElement.setAttribute("tabIndex", "0");
|
|
521
|
+
if (!isEditionMode) {
|
|
522
|
+
const allFocusableElements = ref == null ? void 0 : ref.querySelectorAll(
|
|
523
|
+
getFocusSelector(
|
|
524
|
+
`${cantFocusSelector}:not([data-focused="true"])`
|
|
525
|
+
)
|
|
526
|
+
);
|
|
527
|
+
allFocusableElements == null ? void 0 : allFocusableElements.forEach((current) => {
|
|
528
|
+
if (current !== tableCellWidget) {
|
|
529
|
+
current.setAttribute("tabIndex", "-1");
|
|
530
|
+
}
|
|
531
|
+
if ((tableCellWidget == null ? void 0 : tableCellWidget.tagName) === "BUTTON")
|
|
532
|
+
tableCellWidget.setAttribute("role", "gridcell");
|
|
533
|
+
});
|
|
534
|
+
} else {
|
|
535
|
+
const focusableElements = tableCellElement == null ? void 0 : tableCellElement.querySelectorAll('[tabindex="-1"]');
|
|
536
|
+
focusableElements == null ? void 0 : focusableElements.forEach(
|
|
537
|
+
(current) => current.setAttribute("tabIndex", "0")
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
const focusElement = tableCellWidget != null ? tableCellWidget : tableCellElement;
|
|
541
|
+
const row = getSpecificParent(
|
|
542
|
+
focusElement,
|
|
543
|
+
(current) => current.tagName === "TR"
|
|
544
|
+
);
|
|
545
|
+
if (focusElement && initialized.current && config.stateSelector(responsiveTableStore.getState()).isFocused) {
|
|
546
|
+
globalFocus.focus = focusElement;
|
|
547
|
+
focusElement.focus();
|
|
548
|
+
}
|
|
549
|
+
if (row) {
|
|
550
|
+
scrollParentIntoElement(row, 55, 2, 100, "makeKeyHandler");
|
|
551
|
+
}
|
|
552
|
+
if (!initialized.current) {
|
|
553
|
+
initialized.current = true;
|
|
554
|
+
}
|
|
555
|
+
}, 0);
|
|
556
|
+
},
|
|
557
|
+
{ timeout: 5e3 }
|
|
558
|
+
);
|
|
559
|
+
running.current = false;
|
|
560
|
+
return () => {
|
|
561
|
+
disconnectObserver();
|
|
562
|
+
clearTimeout(scrollTimeout);
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
running.current = false;
|
|
566
|
+
}
|
|
567
|
+
return () => {
|
|
568
|
+
};
|
|
569
|
+
}, [focusedCell, ref, isEditionMode]);
|
|
570
|
+
React.useLayoutEffect(doFocusThings, [
|
|
571
|
+
focusedCell,
|
|
572
|
+
isFocused,
|
|
573
|
+
isEditionMode
|
|
574
|
+
]);
|
|
575
|
+
React.useEffect(() => {
|
|
576
|
+
function handleFocus(ev) {
|
|
577
|
+
const targetTable = getSpecificParent(
|
|
578
|
+
ev.target,
|
|
579
|
+
(current) => current.tagName.toLowerCase() === "table"
|
|
580
|
+
);
|
|
581
|
+
const relatedTargetTable = getSpecificParent(
|
|
582
|
+
ev.relatedTarget,
|
|
583
|
+
(current) => current.tagName.toLowerCase() === "table"
|
|
584
|
+
);
|
|
585
|
+
if (!relatedTargetTable || relatedTargetTable !== targetTable)
|
|
586
|
+
handleClick(ev);
|
|
587
|
+
}
|
|
588
|
+
ref == null ? void 0 : ref.addEventListener("dblclick", handleDoubleClick);
|
|
589
|
+
ref == null ? void 0 : ref.addEventListener("mousedown", handleClick);
|
|
590
|
+
ref == null ? void 0 : ref.addEventListener("focusin", handleFocus);
|
|
591
|
+
ref == null ? void 0 : ref.addEventListener(customEvents.focus, handleClick);
|
|
592
|
+
return () => {
|
|
593
|
+
ref == null ? void 0 : ref.removeEventListener("mousedown", handleClick);
|
|
594
|
+
ref == null ? void 0 : ref.removeEventListener("dblclick", handleDoubleClick);
|
|
595
|
+
ref == null ? void 0 : ref.removeEventListener("focusin", handleFocus);
|
|
596
|
+
ref == null ? void 0 : ref.removeEventListener(customEvents.focus, handleClick);
|
|
597
|
+
};
|
|
598
|
+
}, [ref]);
|
|
599
|
+
const isDragging = React.useRef(false);
|
|
600
|
+
const isFocusedRef = React.useRef(false);
|
|
601
|
+
return /* @__PURE__ */ jsx(
|
|
602
|
+
Box,
|
|
603
|
+
__spreadProps$k(__spreadValues$o({
|
|
604
|
+
ref: setRef
|
|
605
|
+
}, props), {
|
|
606
|
+
className: `selection__keyHandler ${(_b2 = props.className) != null ? _b2 : ""}`,
|
|
607
|
+
onBlur: React.useCallback(
|
|
608
|
+
(ev) => {
|
|
609
|
+
if (!ev.relatedTarget || !getSpecificParent(
|
|
610
|
+
ev.relatedTarget,
|
|
611
|
+
(current) => current === ref
|
|
612
|
+
)) {
|
|
613
|
+
responsiveTableStore.dispatch(
|
|
614
|
+
actions.selectionStateUpdate({ id, isFocused: false })
|
|
615
|
+
);
|
|
616
|
+
shoutKeyhandlerLive("reset");
|
|
617
|
+
isFocusedRef.current = false;
|
|
618
|
+
}
|
|
619
|
+
},
|
|
620
|
+
[ref]
|
|
621
|
+
),
|
|
622
|
+
onFocus: React.useCallback(() => {
|
|
623
|
+
if (!isFocusedRef.current)
|
|
624
|
+
shoutKeyhandlerLive("howToStartDrag");
|
|
625
|
+
isFocusedRef.current = true;
|
|
626
|
+
}, []),
|
|
627
|
+
sx: React.useMemo(
|
|
628
|
+
() => ({ overflow: "auto", position: "relative" }),
|
|
629
|
+
[]
|
|
630
|
+
),
|
|
631
|
+
onKeyDown: React.useCallback(
|
|
632
|
+
(ev) => {
|
|
633
|
+
var _a3;
|
|
634
|
+
const state = config.stateSelector(responsiveTableStore.getState());
|
|
635
|
+
if (willHandleKey(
|
|
636
|
+
ev,
|
|
637
|
+
config.stateSelector(responsiveTableStore.getState())
|
|
638
|
+
)) {
|
|
639
|
+
ev.preventDefault();
|
|
640
|
+
ev.stopPropagation();
|
|
641
|
+
}
|
|
642
|
+
if (actions.swapFocusedRow && isDragging.current && allowKeyboardSorting) {
|
|
643
|
+
if ((ev.key === "Enter" || ev.key === "Escape") && isDragging.current) {
|
|
644
|
+
shoutKeyhandlerLive("howToStartDrag");
|
|
645
|
+
isDragging.current = false;
|
|
646
|
+
responsiveTableStore.dispatch(
|
|
647
|
+
actions.swapFocusedRow({
|
|
648
|
+
tableName: id,
|
|
649
|
+
newIndex: state.focusedRow
|
|
650
|
+
})
|
|
651
|
+
);
|
|
652
|
+
} else if (["ArrowDown", "ArrowUp"].includes(ev.key)) {
|
|
653
|
+
if (ev.key === "ArrowDown") {
|
|
654
|
+
responsiveTableStore.dispatch(
|
|
655
|
+
actions.swapFocusedRow({
|
|
656
|
+
tableName: id,
|
|
657
|
+
newIndex: state.focusedRow + 1
|
|
658
|
+
})
|
|
659
|
+
);
|
|
660
|
+
} else {
|
|
661
|
+
responsiveTableStore.dispatch(
|
|
662
|
+
actions.swapFocusedRow({
|
|
663
|
+
tableName: id,
|
|
664
|
+
newIndex: state.focusedRow - 1
|
|
665
|
+
})
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
} else if (ev.key === "m" && ev.ctrlKey && !isDragging.current && state.focusedRow >= 0 && actions.swapFocusedRow) {
|
|
670
|
+
isDragging.current = true;
|
|
671
|
+
shoutKeyhandlerLive("howToEndDrag");
|
|
672
|
+
responsiveTableStore.dispatch(
|
|
673
|
+
actions.swapFocusedRow({
|
|
674
|
+
tableName: id,
|
|
675
|
+
newIndex: state.focusedRow
|
|
676
|
+
})
|
|
677
|
+
);
|
|
678
|
+
} else {
|
|
679
|
+
const currentSelectedRows = ((_a3 = state == null ? void 0 : state.selectedRows) != null ? _a3 : []).map((current) => ({
|
|
680
|
+
index: current,
|
|
681
|
+
row: state.rows[current]
|
|
682
|
+
}));
|
|
683
|
+
if (props.onKeyDown)
|
|
684
|
+
props.onKeyDown(ev);
|
|
685
|
+
if (ev.key === "Enter" && onSelectRows && state.focusedRow >= 0) {
|
|
686
|
+
onSelectRows(currentSelectedRows, focusedRow);
|
|
687
|
+
}
|
|
688
|
+
keyHandler(ev);
|
|
689
|
+
}
|
|
690
|
+
},
|
|
691
|
+
[allowKeyboardSorting, focusedRow, keyHandler, onSelectRows, props]
|
|
692
|
+
),
|
|
693
|
+
children
|
|
694
|
+
})
|
|
695
|
+
);
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
var __defProp$n = Object.defineProperty;
|
|
700
|
+
var __defProps$j = Object.defineProperties;
|
|
701
|
+
var __getOwnPropDescs$j = Object.getOwnPropertyDescriptors;
|
|
702
|
+
var __getOwnPropSymbols$n = Object.getOwnPropertySymbols;
|
|
703
|
+
var __hasOwnProp$n = Object.prototype.hasOwnProperty;
|
|
704
|
+
var __propIsEnum$n = Object.prototype.propertyIsEnumerable;
|
|
705
|
+
var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
706
|
+
var __spreadValues$n = (a, b) => {
|
|
707
|
+
for (var prop in b || (b = {}))
|
|
708
|
+
if (__hasOwnProp$n.call(b, prop))
|
|
709
|
+
__defNormalProp$n(a, prop, b[prop]);
|
|
710
|
+
if (__getOwnPropSymbols$n)
|
|
711
|
+
for (var prop of __getOwnPropSymbols$n(b)) {
|
|
712
|
+
if (__propIsEnum$n.call(b, prop))
|
|
713
|
+
__defNormalProp$n(a, prop, b[prop]);
|
|
714
|
+
}
|
|
715
|
+
return a;
|
|
716
|
+
};
|
|
717
|
+
var __spreadProps$j = (a, b) => __defProps$j(a, __getOwnPropDescs$j(b));
|
|
718
|
+
var __objRest$b = (source, exclude) => {
|
|
719
|
+
var target = {};
|
|
720
|
+
for (var prop in source)
|
|
721
|
+
if (__hasOwnProp$n.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
722
|
+
target[prop] = source[prop];
|
|
723
|
+
if (source != null && __getOwnPropSymbols$n)
|
|
724
|
+
for (var prop of __getOwnPropSymbols$n(source)) {
|
|
725
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$n.call(source, prop))
|
|
726
|
+
target[prop] = source[prop];
|
|
727
|
+
}
|
|
728
|
+
return target;
|
|
729
|
+
};
|
|
730
|
+
function getReduxActions() {
|
|
731
|
+
return {
|
|
732
|
+
handleKey(state, { payload }) {
|
|
733
|
+
handleKey(state[payload.id], payload);
|
|
734
|
+
},
|
|
735
|
+
selectionStateUpdate(state, _a) {
|
|
736
|
+
var { payload: _b } = _a, _c = _b, { id } = _c, payload = __objRest$b(_c, ["id"]);
|
|
737
|
+
state[id] = __spreadValues$n(__spreadValues$n({}, state[id]), payload);
|
|
738
|
+
},
|
|
739
|
+
setNewFocused(state, _d) {
|
|
740
|
+
var { payload: _e } = _d, _f = _e, { id } = _f, payload = __objRest$b(_f, ["id"]);
|
|
741
|
+
setNewFocused(state[id], payload);
|
|
742
|
+
},
|
|
743
|
+
updateByClick(state, _g) {
|
|
744
|
+
var {
|
|
745
|
+
payload: _h
|
|
746
|
+
} = _g, _i = _h, {
|
|
747
|
+
id,
|
|
748
|
+
colIndex,
|
|
749
|
+
rowIndex,
|
|
750
|
+
ariaColIndex,
|
|
751
|
+
ariaRowIndex,
|
|
752
|
+
isFocused
|
|
753
|
+
} = _i, payload = __objRest$b(_i, [
|
|
754
|
+
"id",
|
|
755
|
+
"colIndex",
|
|
756
|
+
"rowIndex",
|
|
757
|
+
"ariaColIndex",
|
|
758
|
+
"ariaRowIndex",
|
|
759
|
+
"isFocused"
|
|
760
|
+
]);
|
|
761
|
+
var _a;
|
|
762
|
+
const hasFiltersRow = state[id].hasNonAdditionalFilters;
|
|
763
|
+
state[id].isEditionMode = false;
|
|
764
|
+
const newFocusedColumn = (_a = colIndex != null ? colIndex : ariaColIndex) != null ? _a : 1;
|
|
765
|
+
const newFocusedRow = ariaRowIndex !== void 0 ? ariaRowIndex : (rowIndex != null ? rowIndex : 0) - (1 + (hasFiltersRow ? 2 : 1));
|
|
766
|
+
setNewFocused(state[id], __spreadProps$j(__spreadValues$n({}, payload), {
|
|
767
|
+
newFocusedColumn,
|
|
768
|
+
newFocusedRow
|
|
769
|
+
}));
|
|
770
|
+
if (isFocused !== void 0)
|
|
771
|
+
state[id].isFocused = isFocused;
|
|
772
|
+
}
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
var __defProp$m = Object.defineProperty;
|
|
777
|
+
var __defProps$i = Object.defineProperties;
|
|
778
|
+
var __getOwnPropDescs$i = Object.getOwnPropertyDescriptors;
|
|
779
|
+
var __getOwnPropSymbols$m = Object.getOwnPropertySymbols;
|
|
780
|
+
var __hasOwnProp$m = Object.prototype.hasOwnProperty;
|
|
781
|
+
var __propIsEnum$m = Object.prototype.propertyIsEnumerable;
|
|
782
|
+
var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
783
|
+
var __spreadValues$m = (a, b) => {
|
|
784
|
+
for (var prop in b || (b = {}))
|
|
785
|
+
if (__hasOwnProp$m.call(b, prop))
|
|
786
|
+
__defNormalProp$m(a, prop, b[prop]);
|
|
787
|
+
if (__getOwnPropSymbols$m)
|
|
788
|
+
for (var prop of __getOwnPropSymbols$m(b)) {
|
|
789
|
+
if (__propIsEnum$m.call(b, prop))
|
|
790
|
+
__defNormalProp$m(a, prop, b[prop]);
|
|
791
|
+
}
|
|
792
|
+
return a;
|
|
793
|
+
};
|
|
794
|
+
var __spreadProps$i = (a, b) => __defProps$i(a, __getOwnPropDescs$i(b));
|
|
795
|
+
var __objRest$a = (source, exclude) => {
|
|
796
|
+
var target = {};
|
|
797
|
+
for (var prop in source)
|
|
798
|
+
if (__hasOwnProp$m.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
799
|
+
target[prop] = source[prop];
|
|
800
|
+
if (source != null && __getOwnPropSymbols$m)
|
|
801
|
+
for (var prop of __getOwnPropSymbols$m(source)) {
|
|
802
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$m.call(source, prop))
|
|
803
|
+
target[prop] = source[prop];
|
|
804
|
+
}
|
|
805
|
+
return target;
|
|
806
|
+
};
|
|
807
|
+
function getInitialState() {
|
|
808
|
+
const newState = __spreadProps$i(__spreadValues$m({}, getInitialState$1()), {
|
|
809
|
+
allowSelection: true,
|
|
810
|
+
allowSorting: true,
|
|
811
|
+
filters: [],
|
|
812
|
+
isLoading: false,
|
|
813
|
+
isMultiple: true,
|
|
814
|
+
accordionIndexColumns: {},
|
|
815
|
+
expandedRows: []
|
|
816
|
+
});
|
|
817
|
+
return newState;
|
|
818
|
+
}
|
|
819
|
+
const responsiveTableSlice = createSlice({
|
|
820
|
+
name: "responsiveTableSlice",
|
|
821
|
+
initialState: {},
|
|
822
|
+
reducers: __spreadValues$m({
|
|
823
|
+
update(state, _a) {
|
|
824
|
+
var {
|
|
825
|
+
payload: _b
|
|
826
|
+
} = _a, _c = _b, { tableName } = _c, rest = __objRest$a(_c, ["tableName"]);
|
|
827
|
+
var _a2, _b2, _c2, _d, _e, _f;
|
|
828
|
+
if (!state[tableName])
|
|
829
|
+
state[tableName] = getInitialState();
|
|
830
|
+
state[tableName] = __spreadValues$m(__spreadValues$m({}, state[tableName]), rest);
|
|
831
|
+
setNewFocused(state[tableName], {
|
|
832
|
+
altKey: false,
|
|
833
|
+
ctrlKey: false,
|
|
834
|
+
shiftKey: false,
|
|
835
|
+
shouldSelectNewFocused: (_a2 = rest.isFocused) != null ? _a2 : state[tableName].isFocused
|
|
836
|
+
});
|
|
837
|
+
if (rest.columns) {
|
|
838
|
+
state[tableName].nonAdditionalColumnsCount = rest.columns.filter(
|
|
839
|
+
(current) => !current.showAsAdditional
|
|
840
|
+
).length;
|
|
841
|
+
}
|
|
842
|
+
if (rest.rows) {
|
|
843
|
+
state[tableName].statesColumns = Math.max(
|
|
844
|
+
(_c2 = (_b2 = state[tableName]) == null ? void 0 : _b2.reserveColumnsForStates) != null ? _c2 : 0,
|
|
845
|
+
...(_f = (_e = (_d = state[tableName]) == null ? void 0 : _d.rows) == null ? void 0 : _e.map(
|
|
846
|
+
(current) => {
|
|
847
|
+
var _a3, _b3;
|
|
848
|
+
return (_b3 = (_a3 = current.states) == null ? void 0 : _a3.length) != null ? _b3 : 0;
|
|
849
|
+
}
|
|
850
|
+
)) != null ? _f : [0]
|
|
851
|
+
);
|
|
852
|
+
}
|
|
853
|
+
if (rest.filters) {
|
|
854
|
+
state[tableName].hasNonAdditionalFilters = rest.filters.filter(
|
|
855
|
+
(current) => {
|
|
856
|
+
var _a3, _b3;
|
|
857
|
+
return !current.asAdditional && ((_b3 = (_a3 = rest.columns) != null ? _a3 : state[tableName].columns) == null ? void 0 : _b3.find(
|
|
858
|
+
(search) => search.name === current.column
|
|
859
|
+
));
|
|
860
|
+
}
|
|
861
|
+
).length > 0;
|
|
862
|
+
}
|
|
863
|
+
},
|
|
864
|
+
addRows(state, { payload }) {
|
|
865
|
+
if (!state[payload.tableName])
|
|
866
|
+
state[payload.tableName] = getInitialState();
|
|
867
|
+
state[payload.tableName].rows = state[payload.tableName].rows.concat(
|
|
868
|
+
...payload.newRows
|
|
869
|
+
);
|
|
870
|
+
setNewFocused(state[payload.tableName], {
|
|
871
|
+
altKey: false,
|
|
872
|
+
ctrlKey: false,
|
|
873
|
+
shiftKey: false,
|
|
874
|
+
shouldSelectNewFocused: true,
|
|
875
|
+
newFocusedRow: state[payload.tableName].rows.length
|
|
876
|
+
});
|
|
877
|
+
},
|
|
878
|
+
deleteRows(state, { payload }) {
|
|
879
|
+
const table = state[payload.tableName];
|
|
880
|
+
const minIndex = payload.rowIndices.reduce((min, current) => {
|
|
881
|
+
return current < min ? current : min;
|
|
882
|
+
}, Infinity);
|
|
883
|
+
table.rows = table.rows.filter(
|
|
884
|
+
(_, index) => !payload.rowIndices.includes(index)
|
|
885
|
+
);
|
|
886
|
+
setNewFocused(state[payload.tableName], {
|
|
887
|
+
altKey: false,
|
|
888
|
+
ctrlKey: false,
|
|
889
|
+
shiftKey: false,
|
|
890
|
+
shouldSelectNewFocused: true,
|
|
891
|
+
newFocusedRow: minIndex
|
|
892
|
+
});
|
|
893
|
+
state[payload.tableName].isFocused = false;
|
|
894
|
+
},
|
|
895
|
+
destroy(state, { payload: { tableName } }) {
|
|
896
|
+
delete state[tableName];
|
|
897
|
+
},
|
|
898
|
+
swapFocusedRow(state, {
|
|
899
|
+
payload: { newIndex, tableName }
|
|
900
|
+
}) {
|
|
901
|
+
const tableState = state[tableName];
|
|
902
|
+
const focusedIndex = tableState.focusedRow;
|
|
903
|
+
if (focusedIndex === void 0 || newIndex < 0 || newIndex >= tableState.rows.length)
|
|
904
|
+
return;
|
|
905
|
+
if (focusedIndex === newIndex) {
|
|
906
|
+
if (tableState.draggingRow === newIndex)
|
|
907
|
+
tableState.draggingRow = void 0;
|
|
908
|
+
else
|
|
909
|
+
tableState.draggingRow = newIndex;
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
shoutKeyhandlerLive("whichIsTheNewIndex", { newIndex });
|
|
913
|
+
const isSelected = tableState.selectedRows.includes(focusedIndex);
|
|
914
|
+
if (isSelected) {
|
|
915
|
+
tableState.selectedRows = [
|
|
916
|
+
...tableState.selectedRows.filter(
|
|
917
|
+
(current) => current !== focusedIndex
|
|
918
|
+
),
|
|
919
|
+
newIndex
|
|
920
|
+
];
|
|
921
|
+
}
|
|
922
|
+
const aux = tableState.rows[newIndex];
|
|
923
|
+
tableState.rows[newIndex] = tableState.rows[focusedIndex];
|
|
924
|
+
tableState.rows[focusedIndex] = aux;
|
|
925
|
+
tableState.focusedRow = newIndex;
|
|
926
|
+
tableState.draggingRow = newIndex;
|
|
927
|
+
}
|
|
928
|
+
}, getReduxActions())
|
|
929
|
+
});
|
|
930
|
+
const { store: responsiveTableStore, useSelector: useResponsiveTable } = injectReducers({
|
|
931
|
+
responsiveTableSlice: responsiveTableSlice.reducer
|
|
932
|
+
});
|
|
933
|
+
const responsiveTableActions = responsiveTableSlice.actions;
|
|
934
|
+
|
|
935
|
+
var __defProp$l = Object.defineProperty;
|
|
936
|
+
var __defProps$h = Object.defineProperties;
|
|
937
|
+
var __getOwnPropDescs$h = Object.getOwnPropertyDescriptors;
|
|
938
|
+
var __getOwnPropSymbols$l = Object.getOwnPropertySymbols;
|
|
939
|
+
var __hasOwnProp$l = Object.prototype.hasOwnProperty;
|
|
940
|
+
var __propIsEnum$l = Object.prototype.propertyIsEnumerable;
|
|
941
|
+
var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
942
|
+
var __spreadValues$l = (a, b) => {
|
|
943
|
+
for (var prop in b || (b = {}))
|
|
944
|
+
if (__hasOwnProp$l.call(b, prop))
|
|
945
|
+
__defNormalProp$l(a, prop, b[prop]);
|
|
946
|
+
if (__getOwnPropSymbols$l)
|
|
947
|
+
for (var prop of __getOwnPropSymbols$l(b)) {
|
|
948
|
+
if (__propIsEnum$l.call(b, prop))
|
|
949
|
+
__defNormalProp$l(a, prop, b[prop]);
|
|
950
|
+
}
|
|
951
|
+
return a;
|
|
952
|
+
};
|
|
953
|
+
var __spreadProps$h = (a, b) => __defProps$h(a, __getOwnPropDescs$h(b));
|
|
954
|
+
const ResponsiveTableReactContext = React.createContext({});
|
|
955
|
+
function useResponsiveTableContext() {
|
|
956
|
+
const context = React.useContext(ResponsiveTableReactContext);
|
|
957
|
+
if (!context)
|
|
958
|
+
throw new Error("There is no ResponsiveTableContext");
|
|
959
|
+
return context;
|
|
960
|
+
}
|
|
961
|
+
const NoMemoResponsiveTableContext = ({
|
|
962
|
+
allowEdition,
|
|
963
|
+
allowRowsKeyboardSorting,
|
|
964
|
+
allowSelection,
|
|
965
|
+
allowSorting,
|
|
966
|
+
avoidReparseSelectionOnRowChange,
|
|
967
|
+
children = /* @__PURE__ */ jsx(ResponsiveTable, {}),
|
|
968
|
+
className,
|
|
969
|
+
currentBreakPoint,
|
|
970
|
+
customLabels,
|
|
971
|
+
columns,
|
|
972
|
+
filters,
|
|
973
|
+
rows,
|
|
974
|
+
label,
|
|
975
|
+
isMultiple,
|
|
976
|
+
name,
|
|
977
|
+
onChangeSelection,
|
|
978
|
+
onFilterBlur,
|
|
979
|
+
onFilterChange,
|
|
980
|
+
onFilterPressEnter,
|
|
981
|
+
onSelectRows,
|
|
982
|
+
onSortChange,
|
|
983
|
+
reserveColumnsForStates,
|
|
984
|
+
variant
|
|
985
|
+
}) => {
|
|
986
|
+
const actualName = React.useMemo(
|
|
987
|
+
() => name != null ? name : uniqueId("responsiveTable"),
|
|
988
|
+
[name]
|
|
989
|
+
);
|
|
990
|
+
const labels = React.useMemo(
|
|
991
|
+
() => __spreadValues$l(__spreadValues$l({}, defaultLabels), customLabels),
|
|
992
|
+
[customLabels]
|
|
993
|
+
);
|
|
994
|
+
const contextValue = React.useMemo(
|
|
995
|
+
() => ({
|
|
996
|
+
currentBreakPoint,
|
|
997
|
+
label,
|
|
998
|
+
labels,
|
|
999
|
+
name: actualName,
|
|
1000
|
+
onChangeSelection,
|
|
1001
|
+
onFilterBlur,
|
|
1002
|
+
onFilterChange,
|
|
1003
|
+
onFilterPressEnter,
|
|
1004
|
+
onSelectRows,
|
|
1005
|
+
onSortChange
|
|
1006
|
+
}),
|
|
1007
|
+
[
|
|
1008
|
+
actualName,
|
|
1009
|
+
currentBreakPoint,
|
|
1010
|
+
label,
|
|
1011
|
+
labels,
|
|
1012
|
+
onChangeSelection,
|
|
1013
|
+
onFilterBlur,
|
|
1014
|
+
onFilterChange,
|
|
1015
|
+
onFilterPressEnter,
|
|
1016
|
+
onSelectRows,
|
|
1017
|
+
onSortChange
|
|
1018
|
+
]
|
|
1019
|
+
);
|
|
1020
|
+
useMount(() => {
|
|
1021
|
+
responsiveTableStore.dispatch(
|
|
1022
|
+
responsiveTableActions.update({
|
|
1023
|
+
allowEdition,
|
|
1024
|
+
allowRowsKeyboardSorting,
|
|
1025
|
+
allowSelection,
|
|
1026
|
+
allowSorting,
|
|
1027
|
+
columns,
|
|
1028
|
+
filters: filters != null ? filters : [],
|
|
1029
|
+
rows,
|
|
1030
|
+
isMultiple,
|
|
1031
|
+
tableName: actualName,
|
|
1032
|
+
reserveColumnsForStates
|
|
1033
|
+
})
|
|
1034
|
+
);
|
|
1035
|
+
});
|
|
1036
|
+
useUpdateEffect$1(() => {
|
|
1037
|
+
responsiveTableStore.dispatch(
|
|
1038
|
+
responsiveTableActions.update({
|
|
1039
|
+
tableName: actualName,
|
|
1040
|
+
columns
|
|
1041
|
+
})
|
|
1042
|
+
);
|
|
1043
|
+
}, [columns]);
|
|
1044
|
+
useUpdateEffect$1(() => {
|
|
1045
|
+
responsiveTableStore.dispatch(
|
|
1046
|
+
responsiveTableActions.update({
|
|
1047
|
+
tableName: actualName,
|
|
1048
|
+
rows
|
|
1049
|
+
})
|
|
1050
|
+
);
|
|
1051
|
+
if (avoidReparseSelectionOnRowChange !== true) {
|
|
1052
|
+
const selected = rows.map((current, i) => __spreadProps$h(__spreadValues$l({}, current), { i })).filter((current) => current.initiallySelected);
|
|
1053
|
+
responsiveTableStore.dispatch(
|
|
1054
|
+
responsiveTableActions.update({
|
|
1055
|
+
tableName: actualName,
|
|
1056
|
+
selectedRows: selected.map((current) => current.i)
|
|
1057
|
+
})
|
|
1058
|
+
);
|
|
1059
|
+
}
|
|
1060
|
+
}, [rows]);
|
|
1061
|
+
useUpdateEffect$1(() => {
|
|
1062
|
+
responsiveTableStore.dispatch(
|
|
1063
|
+
responsiveTableActions.update({
|
|
1064
|
+
tableName: actualName,
|
|
1065
|
+
filters
|
|
1066
|
+
})
|
|
1067
|
+
);
|
|
1068
|
+
}, [filters]);
|
|
1069
|
+
useUnmount(() => {
|
|
1070
|
+
});
|
|
1071
|
+
return /* @__PURE__ */ jsx(ResponsiveTableReactContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
1072
|
+
Box,
|
|
1073
|
+
__spreadProps$h(__spreadValues$l({
|
|
1074
|
+
id: name,
|
|
1075
|
+
className: `responsiveTableContext__wrapper ${className != null ? className : ""}`
|
|
1076
|
+
}, variant ? getVariant(variant) : null), {
|
|
1077
|
+
children
|
|
1078
|
+
})
|
|
1079
|
+
) });
|
|
1080
|
+
};
|
|
1081
|
+
const ResponsiveTableContext = React.memo(NoMemoResponsiveTableContext);
|
|
1082
|
+
|
|
1083
|
+
var __defProp$k = Object.defineProperty;
|
|
1084
|
+
var __getOwnPropSymbols$k = Object.getOwnPropertySymbols;
|
|
1085
|
+
var __hasOwnProp$k = Object.prototype.hasOwnProperty;
|
|
1086
|
+
var __propIsEnum$k = Object.prototype.propertyIsEnumerable;
|
|
1087
|
+
var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1088
|
+
var __spreadValues$k = (a, b) => {
|
|
1089
|
+
for (var prop in b || (b = {}))
|
|
1090
|
+
if (__hasOwnProp$k.call(b, prop))
|
|
1091
|
+
__defNormalProp$k(a, prop, b[prop]);
|
|
1092
|
+
if (__getOwnPropSymbols$k)
|
|
1093
|
+
for (var prop of __getOwnPropSymbols$k(b)) {
|
|
1094
|
+
if (__propIsEnum$k.call(b, prop))
|
|
1095
|
+
__defNormalProp$k(a, prop, b[prop]);
|
|
1096
|
+
}
|
|
1097
|
+
return a;
|
|
1098
|
+
};
|
|
1099
|
+
const NoMemoKeyHandler = (props) => {
|
|
1100
|
+
const { name, onChangeSelection, onSelectRows } = useResponsiveTableContext();
|
|
1101
|
+
const Handler = React.useMemo(
|
|
1102
|
+
() => makeKeyHandler(responsiveTableActions, name, {
|
|
1103
|
+
throttleOptions: { wait: 50 },
|
|
1104
|
+
stateSelector: (global) => global.responsiveTableSlice[name]
|
|
1105
|
+
}),
|
|
1106
|
+
[name]
|
|
1107
|
+
);
|
|
1108
|
+
return /* @__PURE__ */ jsx(
|
|
1109
|
+
Handler,
|
|
1110
|
+
__spreadValues$k({
|
|
1111
|
+
onChangeSelection,
|
|
1112
|
+
onSelectRows
|
|
1113
|
+
}, props)
|
|
1114
|
+
);
|
|
1115
|
+
};
|
|
1116
|
+
const KeyHandler = React.memo(NoMemoKeyHandler);
|
|
1117
|
+
|
|
1118
|
+
function useDomProps(element, elementProps, stateSelector) {
|
|
1119
|
+
const state = useResponsiveTable((globalState) => {
|
|
1120
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1121
|
+
const tableState = stateSelector(globalState);
|
|
1122
|
+
const hasNonAdditionalFilters = tableState == null ? void 0 : tableState.hasNonAdditionalFilters;
|
|
1123
|
+
const startDataRowIndex = hasNonAdditionalFilters ? 2 : 1;
|
|
1124
|
+
const statesColumns = (_a = tableState == null ? void 0 : tableState.statesColumns) != null ? _a : 0;
|
|
1125
|
+
let expandedBeforeThisRow = 0;
|
|
1126
|
+
if (element === "tr")
|
|
1127
|
+
expandedBeforeThisRow = tableState == null ? void 0 : tableState.expandedRows.filter(
|
|
1128
|
+
(current) => current < elementProps.rowIndex
|
|
1129
|
+
).length;
|
|
1130
|
+
let isFocused = false;
|
|
1131
|
+
let isSelected = false;
|
|
1132
|
+
switch (element) {
|
|
1133
|
+
case "filterTd": {
|
|
1134
|
+
const castedProps = elementProps;
|
|
1135
|
+
isFocused = (tableState == null ? void 0 : tableState.focusedRow) === 1 - startDataRowIndex && addBoundary((_b = tableState == null ? void 0 : tableState.focusedColumn) != null ? _b : 0, 0) - statesColumns === castedProps.columnIndex + 1 + (hasNonAdditionalFilters ? 1 : 0);
|
|
1136
|
+
break;
|
|
1137
|
+
}
|
|
1138
|
+
case "tr": {
|
|
1139
|
+
const castedProps = elementProps;
|
|
1140
|
+
isFocused = !tableState ? false : tableState.focusedRow === castedProps.rowIndex && (tableState == null ? void 0 : tableState.focusedColumn) === 0 || Math.floor(tableState == null ? void 0 : tableState.focusedRow) === castedProps.rowIndex && Math.round(tableState == null ? void 0 : tableState.focusedRow) - tableState.focusedRow !== 0 && !!castedProps.isTheExpandedRow;
|
|
1141
|
+
isSelected = !castedProps.isTheExpandedRow && (tableState == null ? void 0 : tableState.selectedRows.includes(castedProps.rowIndex));
|
|
1142
|
+
break;
|
|
1143
|
+
}
|
|
1144
|
+
case "stateCell": {
|
|
1145
|
+
const castedProps = elementProps;
|
|
1146
|
+
isFocused = (tableState == null ? void 0 : tableState.focusedRow) === castedProps.rowIndex && ((_c = tableState == null ? void 0 : tableState.focusedColumn) != null ? _c : 0) === castedProps.columnIndex + 1 + (hasNonAdditionalFilters ? 1 : 0);
|
|
1147
|
+
break;
|
|
1148
|
+
}
|
|
1149
|
+
case "additionalTd": {
|
|
1150
|
+
const castedProps = elementProps;
|
|
1151
|
+
isFocused = (tableState == null ? void 0 : tableState.focusedRow) === castedProps.rowIndex && ((_d = tableState == null ? void 0 : tableState.focusedColumn) != null ? _d : 0) === 1;
|
|
1152
|
+
break;
|
|
1153
|
+
}
|
|
1154
|
+
case "td": {
|
|
1155
|
+
const castedProps = elementProps;
|
|
1156
|
+
isFocused = (tableState == null ? void 0 : tableState.focusedRow) === castedProps.rowIndex && ((_e = tableState == null ? void 0 : tableState.focusedColumn) != null ? _e : 0) - statesColumns === castedProps.columnIndex + 1 + (hasNonAdditionalFilters ? 1 : 0);
|
|
1157
|
+
break;
|
|
1158
|
+
}
|
|
1159
|
+
case "headerStateCell": {
|
|
1160
|
+
const castedProps = elementProps;
|
|
1161
|
+
isFocused = (tableState == null ? void 0 : tableState.focusedRow) === castedProps.rowIndex - 1 - startDataRowIndex && addBoundary(tableState == null ? void 0 : tableState.focusedColumn, 0) === castedProps.columnIndex + 1 + (hasNonAdditionalFilters ? 1 : 0);
|
|
1162
|
+
break;
|
|
1163
|
+
}
|
|
1164
|
+
case "th": {
|
|
1165
|
+
const castedProps = elementProps;
|
|
1166
|
+
isFocused = (tableState == null ? void 0 : tableState.focusedRow) === 0 - startDataRowIndex && addBoundary(((_f = tableState == null ? void 0 : tableState.focusedColumn) != null ? _f : 0) - statesColumns, 0) === castedProps.columnIndex + 1 + (hasNonAdditionalFilters ? 1 : 0);
|
|
1167
|
+
break;
|
|
1168
|
+
}
|
|
1169
|
+
case "separator": {
|
|
1170
|
+
const castedProps = elementProps;
|
|
1171
|
+
isFocused = !tableState ? false : tableState.focusedRow === castedProps.rowIndex;
|
|
1172
|
+
break;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
return {
|
|
1176
|
+
columns: (_g = tableState == null ? void 0 : tableState.columns) != null ? _g : [],
|
|
1177
|
+
expandedBeforeThisRow,
|
|
1178
|
+
isEditionMode: tableState == null ? void 0 : tableState.isEditionMode,
|
|
1179
|
+
hasNonAdditionalFilters,
|
|
1180
|
+
rowsLength: element === "table" ? tableState == null ? void 0 : tableState.rows.length : "",
|
|
1181
|
+
isSelected,
|
|
1182
|
+
isFocused,
|
|
1183
|
+
startDataRowIndex,
|
|
1184
|
+
statesColumns: tableState == null ? void 0 : tableState.statesColumns
|
|
1185
|
+
};
|
|
1186
|
+
}, shallowEqual);
|
|
1187
|
+
let returnObject = React.useMemo(() => ({}), []);
|
|
1188
|
+
switch (element) {
|
|
1189
|
+
case "filterTd": {
|
|
1190
|
+
const castedProps = elementProps;
|
|
1191
|
+
returnObject = {
|
|
1192
|
+
"aria-colindex": castedProps.columnIndex + 1 + state.statesColumns + (state.hasNonAdditionalFilters ? 1 : 0),
|
|
1193
|
+
"data-editionmode": state.isEditionMode && state.isFocused,
|
|
1194
|
+
"data-focused": state.isFocused,
|
|
1195
|
+
tabIndex: state.isFocused ? 0 : -1,
|
|
1196
|
+
"data-rowindex": 2
|
|
1197
|
+
};
|
|
1198
|
+
break;
|
|
1199
|
+
}
|
|
1200
|
+
case "separator": {
|
|
1201
|
+
const castedProps = elementProps;
|
|
1202
|
+
returnObject = {
|
|
1203
|
+
"aria-rowindex": castedProps.rowIndex + state.startDataRowIndex + 1 + state.expandedBeforeThisRow,
|
|
1204
|
+
"data-focusindex": castedProps.rowIndex + state.startDataRowIndex + 1,
|
|
1205
|
+
"aria-selected": state.isSelected,
|
|
1206
|
+
"data-focused": state.isFocused,
|
|
1207
|
+
"aria-expanded": false
|
|
1208
|
+
};
|
|
1209
|
+
break;
|
|
1210
|
+
}
|
|
1211
|
+
case "table": {
|
|
1212
|
+
returnObject = {
|
|
1213
|
+
role: "treegrid",
|
|
1214
|
+
"aria-colcount": state.columns.length,
|
|
1215
|
+
"aria-rowcount": state.rowsLength
|
|
1216
|
+
};
|
|
1217
|
+
break;
|
|
1218
|
+
}
|
|
1219
|
+
case "tr": {
|
|
1220
|
+
const castedProps = elementProps;
|
|
1221
|
+
returnObject = {
|
|
1222
|
+
"aria-rowindex": castedProps.rowIndex + state.startDataRowIndex + 1 + state.expandedBeforeThisRow + (castedProps.isTheExpandedRow ? 1 : 0),
|
|
1223
|
+
"data-focusindex": castedProps.rowIndex + state.startDataRowIndex + 1 + (castedProps.isTheExpandedRow ? 0.5 : 0),
|
|
1224
|
+
"aria-selected": state.isSelected,
|
|
1225
|
+
"data-focused": state.isFocused,
|
|
1226
|
+
"aria-expanded": castedProps.isThisRowExpanded,
|
|
1227
|
+
tabIndex: state.isFocused ? 0 : -1
|
|
1228
|
+
};
|
|
1229
|
+
break;
|
|
1230
|
+
}
|
|
1231
|
+
case "td": {
|
|
1232
|
+
const castedProps = elementProps;
|
|
1233
|
+
returnObject = {
|
|
1234
|
+
"aria-colindex": castedProps.columnIndex + 1 + state.statesColumns + (state.hasNonAdditionalFilters ? 1 : 0),
|
|
1235
|
+
"data-editionmode": state.isEditionMode && state.isFocused,
|
|
1236
|
+
"data-focused": state.isFocused,
|
|
1237
|
+
tabIndex: state.isFocused ? 0 : -1,
|
|
1238
|
+
"data-rowindex": castedProps.rowIndex + state.startDataRowIndex + 1
|
|
1239
|
+
};
|
|
1240
|
+
break;
|
|
1241
|
+
}
|
|
1242
|
+
case "additionalTd": {
|
|
1243
|
+
const castedProps = elementProps;
|
|
1244
|
+
returnObject = {
|
|
1245
|
+
"aria-colindex": 1,
|
|
1246
|
+
"data-editionmode": state.isEditionMode && state.isFocused,
|
|
1247
|
+
"data-focused": state.isFocused,
|
|
1248
|
+
tabIndex: state.isFocused ? 0 : -1,
|
|
1249
|
+
"data-rowindex": castedProps.rowIndex + state.startDataRowIndex + 1
|
|
1250
|
+
};
|
|
1251
|
+
break;
|
|
1252
|
+
}
|
|
1253
|
+
case "stateCell": {
|
|
1254
|
+
const castedProps = elementProps;
|
|
1255
|
+
returnObject = {
|
|
1256
|
+
"aria-colindex": castedProps.columnIndex + 1 + (state.hasNonAdditionalFilters ? 1 : 0),
|
|
1257
|
+
"data-editionmode": state.isEditionMode && state.isFocused,
|
|
1258
|
+
"data-focused": state.isFocused,
|
|
1259
|
+
tabIndex: state.isFocused ? 0 : -1,
|
|
1260
|
+
"data-rowindex": castedProps.rowIndex + state.startDataRowIndex + 1
|
|
1261
|
+
};
|
|
1262
|
+
break;
|
|
1263
|
+
}
|
|
1264
|
+
case "headerStateCell": {
|
|
1265
|
+
const castedProps = elementProps;
|
|
1266
|
+
returnObject = {
|
|
1267
|
+
"aria-colindex": castedProps.columnIndex + 1 + (state.hasNonAdditionalFilters ? 1 : 0),
|
|
1268
|
+
"aria-sort": "none",
|
|
1269
|
+
"data-editionmode": state.isEditionMode && state.isFocused,
|
|
1270
|
+
"data-focused": state.isFocused,
|
|
1271
|
+
tabIndex: state.isFocused ? 0 : -1,
|
|
1272
|
+
"data-rowindex": castedProps.rowIndex
|
|
1273
|
+
};
|
|
1274
|
+
break;
|
|
1275
|
+
}
|
|
1276
|
+
case "th": {
|
|
1277
|
+
const castedProps = elementProps;
|
|
1278
|
+
returnObject = {
|
|
1279
|
+
"aria-colindex": castedProps.columnIndex + 1 + state.statesColumns + (state.hasNonAdditionalFilters ? 1 : 0),
|
|
1280
|
+
"aria-sort": ["ascending", "descending", "none"][["Asc", "Desc", null].findIndex(
|
|
1281
|
+
(current) => current === state.columns[castedProps.columnIndex].currentSorting
|
|
1282
|
+
)],
|
|
1283
|
+
"data-editionmode": state.isEditionMode && state.isFocused,
|
|
1284
|
+
"data-focused": state.isFocused,
|
|
1285
|
+
tabIndex: state.isFocused ? 0 : -1,
|
|
1286
|
+
"data-rowindex": 1
|
|
1287
|
+
};
|
|
1288
|
+
break;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
return React.useMemo(() => returnObject, Object.values(returnObject));
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
var __defProp$j = Object.defineProperty;
|
|
1295
|
+
var __defProps$g = Object.defineProperties;
|
|
1296
|
+
var __getOwnPropDescs$g = Object.getOwnPropertyDescriptors;
|
|
1297
|
+
var __getOwnPropSymbols$j = Object.getOwnPropertySymbols;
|
|
1298
|
+
var __hasOwnProp$j = Object.prototype.hasOwnProperty;
|
|
1299
|
+
var __propIsEnum$j = Object.prototype.propertyIsEnumerable;
|
|
1300
|
+
var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1301
|
+
var __spreadValues$j = (a, b) => {
|
|
1302
|
+
for (var prop in b || (b = {}))
|
|
1303
|
+
if (__hasOwnProp$j.call(b, prop))
|
|
1304
|
+
__defNormalProp$j(a, prop, b[prop]);
|
|
1305
|
+
if (__getOwnPropSymbols$j)
|
|
1306
|
+
for (var prop of __getOwnPropSymbols$j(b)) {
|
|
1307
|
+
if (__propIsEnum$j.call(b, prop))
|
|
1308
|
+
__defNormalProp$j(a, prop, b[prop]);
|
|
1309
|
+
}
|
|
1310
|
+
return a;
|
|
1311
|
+
};
|
|
1312
|
+
var __spreadProps$g = (a, b) => __defProps$g(a, __getOwnPropDescs$g(b));
|
|
1313
|
+
const widthStorageName = "tablesWidths";
|
|
1314
|
+
function getColumnWidth(width) {
|
|
1315
|
+
if (typeof width === "string") {
|
|
1316
|
+
if (width.match(/(%|px|vw|vh|vmin|vmax|cm|mm|in|pt|pc)/))
|
|
1317
|
+
return width;
|
|
1318
|
+
return Number.parseInt(width, 10);
|
|
1319
|
+
}
|
|
1320
|
+
if (typeof width === "number")
|
|
1321
|
+
return width;
|
|
1322
|
+
return width;
|
|
1323
|
+
}
|
|
1324
|
+
debugDispatcher.on(
|
|
1325
|
+
"cleanTableSizes",
|
|
1326
|
+
([tableName]) => {
|
|
1327
|
+
const currentWidths = persistentStorage[widthStorageName];
|
|
1328
|
+
delete currentWidths[tableName];
|
|
1329
|
+
persistentStorage[widthStorageName] = currentWidths;
|
|
1330
|
+
},
|
|
1331
|
+
'Se usa para borrar el estado de una tabla. Uso: dd.cleanTableSizes("TableName")'
|
|
1332
|
+
);
|
|
1333
|
+
function makeColumnName(tableName, columnName) {
|
|
1334
|
+
return `${tableName}${columnName}`;
|
|
1335
|
+
}
|
|
1336
|
+
const thWidthEmitter = new class ThWidthEmitter extends EventEmitter {
|
|
1337
|
+
}();
|
|
1338
|
+
const NoMemoHeaderCell = ({
|
|
1339
|
+
apiaColumnIndex,
|
|
1340
|
+
columnIndex,
|
|
1341
|
+
inTableColumnIndex
|
|
1342
|
+
}) => {
|
|
1343
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1344
|
+
const { name, onSortChange } = useResponsiveTableContext();
|
|
1345
|
+
const uniqueId = (_d = (_c = (_a = window.location.href.match(/busEntId=(\d+)/)) == null ? void 0 : _a[1]) != null ? _c : (_b = window.location.href.match(/query=(\d+)/)) == null ? void 0 : _b[1]) != null ? _d : "";
|
|
1346
|
+
const isGlobal = window.isGlobal ? "isGlobal" : "notGlobal";
|
|
1347
|
+
const actualName = name + uniqueId + String(isGlobal);
|
|
1348
|
+
const column = useResponsiveTable((global) => {
|
|
1349
|
+
const tableState = global.responsiveTableSlice[name];
|
|
1350
|
+
return tableState == null ? void 0 : tableState.columns[columnIndex];
|
|
1351
|
+
}, shallowEqual);
|
|
1352
|
+
const storedWidth = (_f = (_e = persistentStorage[widthStorageName]) == null ? void 0 : _e[actualName]) == null ? void 0 : _f[column.name];
|
|
1353
|
+
const [width, setWidth] = React.useState(storedWidth != null ? storedWidth : 200);
|
|
1354
|
+
const [isResize, setIsResize] = React.useState(storedWidth !== void 0);
|
|
1355
|
+
React.useEffect(() => {
|
|
1356
|
+
return void thWidthEmitter.on("resize", (ev) => {
|
|
1357
|
+
if (ev.name === makeColumnName(actualName, column.name)) {
|
|
1358
|
+
setIsResize(true);
|
|
1359
|
+
setWidth(ev.width);
|
|
1360
|
+
}
|
|
1361
|
+
});
|
|
1362
|
+
}, [column.name, actualName]);
|
|
1363
|
+
const isFilterRequired = useResponsiveTable((global) => {
|
|
1364
|
+
const tableState = global.responsiveTableSlice[name];
|
|
1365
|
+
const columnFilter = tableState == null ? void 0 : tableState.filters.find(
|
|
1366
|
+
(current) => current.column === column.title
|
|
1367
|
+
);
|
|
1368
|
+
return columnFilter == null ? void 0 : columnFilter.required;
|
|
1369
|
+
}, shallowEqual);
|
|
1370
|
+
const isSortingAllowed = useResponsiveTable((global) => {
|
|
1371
|
+
const tableState = global.responsiveTableSlice[name];
|
|
1372
|
+
return tableState == null ? void 0 : tableState.allowSorting;
|
|
1373
|
+
});
|
|
1374
|
+
const domProps = useDomProps(
|
|
1375
|
+
"th",
|
|
1376
|
+
{
|
|
1377
|
+
columnIndex: inTableColumnIndex
|
|
1378
|
+
},
|
|
1379
|
+
domPropsSelector(name)
|
|
1380
|
+
);
|
|
1381
|
+
const sx = React.useMemo(
|
|
1382
|
+
() => {
|
|
1383
|
+
var _a2;
|
|
1384
|
+
return !isResize ? {
|
|
1385
|
+
minWidth: getColumnWidth((_a2 = column.minWidth) != null ? _a2 : column.width),
|
|
1386
|
+
maxWidth: column.maxWidth !== void 0 ? getColumnWidth(column.maxWidth) : void 0,
|
|
1387
|
+
width: getColumnWidth(column.width),
|
|
1388
|
+
position: "relative"
|
|
1389
|
+
} : {
|
|
1390
|
+
width: `${width}px`,
|
|
1391
|
+
minWidth: `${width}px`,
|
|
1392
|
+
position: "relative"
|
|
1393
|
+
};
|
|
1394
|
+
},
|
|
1395
|
+
[column.maxWidth, column.minWidth, column.width, isResize, width]
|
|
1396
|
+
);
|
|
1397
|
+
const buttonProps = useOtherTagButton(
|
|
1398
|
+
React.useMemo(
|
|
1399
|
+
() => ({
|
|
1400
|
+
className: "headButton",
|
|
1401
|
+
onClick: (ev) => {
|
|
1402
|
+
if (isChild(
|
|
1403
|
+
ev.target,
|
|
1404
|
+
(current) => current.classList.contains("headButton__resizer")
|
|
1405
|
+
))
|
|
1406
|
+
return;
|
|
1407
|
+
console.warn("Buttons slice is not defined");
|
|
1408
|
+
if (onSortChange && column.allowSorting !== false && isSortingAllowed !== false)
|
|
1409
|
+
onSortChange({
|
|
1410
|
+
column,
|
|
1411
|
+
columnIndex: apiaColumnIndex,
|
|
1412
|
+
name: column.name,
|
|
1413
|
+
sortValue: ["Asc", "Desc"][column.currentSorting !== "A" ? 0 : 1]
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
}),
|
|
1417
|
+
[apiaColumnIndex, column, isSortingAllowed, onSortChange]
|
|
1418
|
+
)
|
|
1419
|
+
);
|
|
1420
|
+
return /* @__PURE__ */ jsx(
|
|
1421
|
+
Box,
|
|
1422
|
+
__spreadProps$g(__spreadValues$j(__spreadValues$j({
|
|
1423
|
+
as: "th",
|
|
1424
|
+
style: sx,
|
|
1425
|
+
"data-columnname": column.name,
|
|
1426
|
+
title: (_h = (_g = column.title) != null ? _g : column.label) != null ? _h : column.name
|
|
1427
|
+
}, buttonProps), domProps), {
|
|
1428
|
+
role: "rowheader",
|
|
1429
|
+
className: `${isFilterRequired && window.SHOW_REQUIRED_POSITION ? "requiredFilterColumn" : ""}`,
|
|
1430
|
+
children: /* @__PURE__ */ jsxs(Box, { as: "span", className: "headButton__container", children: [
|
|
1431
|
+
/* @__PURE__ */ jsx(Box, { as: "span", className: "headButton__label", children: /* @__PURE__ */ jsx(
|
|
1432
|
+
Box,
|
|
1433
|
+
{
|
|
1434
|
+
as: "span",
|
|
1435
|
+
className: `${isFilterRequired ? "requiredFilter__Column" : ""}`,
|
|
1436
|
+
children: column.label
|
|
1437
|
+
}
|
|
1438
|
+
) }),
|
|
1439
|
+
/* @__PURE__ */ jsxs(Box, { as: "span", className: "headButton__sortIcon", children: [
|
|
1440
|
+
column.allowSorting !== false && column.currentSorting === "A" && /* @__PURE__ */ jsx(FaSortUp, {}),
|
|
1441
|
+
column.allowSorting !== false && column.currentSorting === "D" && /* @__PURE__ */ jsx(FaSortDown, {}),
|
|
1442
|
+
column.allowSorting !== false && !column.currentSorting && /* @__PURE__ */ jsx(FaSort, {})
|
|
1443
|
+
] }),
|
|
1444
|
+
/* @__PURE__ */ jsx(
|
|
1445
|
+
Box,
|
|
1446
|
+
{
|
|
1447
|
+
className: "headButton__resizer",
|
|
1448
|
+
onMouseDown: (ev) => {
|
|
1449
|
+
if (!isResize) {
|
|
1450
|
+
const trElement = getSpecificParent(
|
|
1451
|
+
ev.target,
|
|
1452
|
+
(current) => current.tagName === "TR"
|
|
1453
|
+
);
|
|
1454
|
+
trElement == null ? void 0 : trElement.querySelectorAll("th").forEach((current) => {
|
|
1455
|
+
thWidthEmitter.emit("resize", {
|
|
1456
|
+
name: makeColumnName(
|
|
1457
|
+
actualName,
|
|
1458
|
+
current.dataset.columnname
|
|
1459
|
+
),
|
|
1460
|
+
width: current.clientWidth
|
|
1461
|
+
});
|
|
1462
|
+
});
|
|
1463
|
+
setIsResize(true);
|
|
1464
|
+
}
|
|
1465
|
+
const th = getSpecificParent(
|
|
1466
|
+
ev.target,
|
|
1467
|
+
(current) => current.tagName === "TH"
|
|
1468
|
+
);
|
|
1469
|
+
if (!th)
|
|
1470
|
+
throw new Error("There is no th");
|
|
1471
|
+
const initialX = ev.clientX;
|
|
1472
|
+
const initialWidth = th.clientWidth;
|
|
1473
|
+
const resize = (mousemoveEv) => {
|
|
1474
|
+
const dif = mousemoveEv.clientX - initialX;
|
|
1475
|
+
setWidth(initialWidth + dif);
|
|
1476
|
+
};
|
|
1477
|
+
const unsuscribe = () => {
|
|
1478
|
+
const trElement = getSpecificParent(
|
|
1479
|
+
ev.target,
|
|
1480
|
+
(current) => current.tagName === "TR"
|
|
1481
|
+
);
|
|
1482
|
+
trElement == null ? void 0 : trElement.querySelectorAll("th").forEach((current) => {
|
|
1483
|
+
var _a2;
|
|
1484
|
+
persistentStorage[widthStorageName] = __spreadProps$g(__spreadValues$j({}, persistentStorage[widthStorageName]), {
|
|
1485
|
+
[actualName]: __spreadProps$g(__spreadValues$j({}, (_a2 = persistentStorage[widthStorageName]) == null ? void 0 : _a2[actualName]), {
|
|
1486
|
+
[current.dataset.columnname]: current.clientWidth
|
|
1487
|
+
})
|
|
1488
|
+
});
|
|
1489
|
+
});
|
|
1490
|
+
document.removeEventListener("mousemove", resize);
|
|
1491
|
+
document.removeEventListener("mouseup", unsuscribe);
|
|
1492
|
+
};
|
|
1493
|
+
document.addEventListener("mousemove", resize);
|
|
1494
|
+
document.addEventListener("mouseup", unsuscribe);
|
|
1495
|
+
return false;
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
)
|
|
1499
|
+
] })
|
|
1500
|
+
})
|
|
1501
|
+
);
|
|
1502
|
+
};
|
|
1503
|
+
const HeaderCell = React.memo(NoMemoHeaderCell);
|
|
1504
|
+
|
|
1505
|
+
var __defProp$i = Object.defineProperty;
|
|
1506
|
+
var __defProps$f = Object.defineProperties;
|
|
1507
|
+
var __getOwnPropDescs$f = Object.getOwnPropertyDescriptors;
|
|
1508
|
+
var __getOwnPropSymbols$i = Object.getOwnPropertySymbols;
|
|
1509
|
+
var __hasOwnProp$i = Object.prototype.hasOwnProperty;
|
|
1510
|
+
var __propIsEnum$i = Object.prototype.propertyIsEnumerable;
|
|
1511
|
+
var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1512
|
+
var __spreadValues$i = (a, b) => {
|
|
1513
|
+
for (var prop in b || (b = {}))
|
|
1514
|
+
if (__hasOwnProp$i.call(b, prop))
|
|
1515
|
+
__defNormalProp$i(a, prop, b[prop]);
|
|
1516
|
+
if (__getOwnPropSymbols$i)
|
|
1517
|
+
for (var prop of __getOwnPropSymbols$i(b)) {
|
|
1518
|
+
if (__propIsEnum$i.call(b, prop))
|
|
1519
|
+
__defNormalProp$i(a, prop, b[prop]);
|
|
1520
|
+
}
|
|
1521
|
+
return a;
|
|
1522
|
+
};
|
|
1523
|
+
var __spreadProps$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(b));
|
|
1524
|
+
const NoMemoRowStatesRenderer = ({
|
|
1525
|
+
state
|
|
1526
|
+
}) => {
|
|
1527
|
+
var _a;
|
|
1528
|
+
const { Icon } = state;
|
|
1529
|
+
return /* @__PURE__ */ jsx(
|
|
1530
|
+
Button,
|
|
1531
|
+
__spreadProps$f(__spreadValues$i({}, getVariant("inherit")), {
|
|
1532
|
+
title: state.tooltip,
|
|
1533
|
+
className: `${(_a = state.className) != null ? _a : "state"}_icon state_icon`,
|
|
1534
|
+
sx: React.useMemo(
|
|
1535
|
+
() => {
|
|
1536
|
+
var _a2;
|
|
1537
|
+
return {
|
|
1538
|
+
"svg, path": {
|
|
1539
|
+
color: (_a2 = state.color) != null ? _a2 : ""
|
|
1540
|
+
}
|
|
1541
|
+
};
|
|
1542
|
+
},
|
|
1543
|
+
[state.color]
|
|
1544
|
+
),
|
|
1545
|
+
children: /* @__PURE__ */ jsx(Icon, {})
|
|
1546
|
+
})
|
|
1547
|
+
);
|
|
1548
|
+
};
|
|
1549
|
+
const RowStatesRenderer = React.memo(NoMemoRowStatesRenderer);
|
|
1550
|
+
|
|
1551
|
+
var __defProp$h = Object.defineProperty;
|
|
1552
|
+
var __defProps$e = Object.defineProperties;
|
|
1553
|
+
var __getOwnPropDescs$e = Object.getOwnPropertyDescriptors;
|
|
1554
|
+
var __getOwnPropSymbols$h = Object.getOwnPropertySymbols;
|
|
1555
|
+
var __hasOwnProp$h = Object.prototype.hasOwnProperty;
|
|
1556
|
+
var __propIsEnum$h = Object.prototype.propertyIsEnumerable;
|
|
1557
|
+
var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1558
|
+
var __spreadValues$h = (a, b) => {
|
|
1559
|
+
for (var prop in b || (b = {}))
|
|
1560
|
+
if (__hasOwnProp$h.call(b, prop))
|
|
1561
|
+
__defNormalProp$h(a, prop, b[prop]);
|
|
1562
|
+
if (__getOwnPropSymbols$h)
|
|
1563
|
+
for (var prop of __getOwnPropSymbols$h(b)) {
|
|
1564
|
+
if (__propIsEnum$h.call(b, prop))
|
|
1565
|
+
__defNormalProp$h(a, prop, b[prop]);
|
|
1566
|
+
}
|
|
1567
|
+
return a;
|
|
1568
|
+
};
|
|
1569
|
+
var __spreadProps$e = (a, b) => __defProps$e(a, __getOwnPropDescs$e(b));
|
|
1570
|
+
const StateCell = ({ index, rowIndex, state, isHeader }) => {
|
|
1571
|
+
const { name } = useResponsiveTableContext();
|
|
1572
|
+
const domProps = useDomProps(
|
|
1573
|
+
isHeader ? "headerStateCell" : "stateCell",
|
|
1574
|
+
{ columnIndex: index, rowIndex },
|
|
1575
|
+
domPropsSelector(name)
|
|
1576
|
+
);
|
|
1577
|
+
return /* @__PURE__ */ jsx(Box, __spreadProps$e(__spreadValues$h({ as: "td", className: "stateCell" }, domProps), { children: state ? /* @__PURE__ */ jsx(RowStatesRenderer, { state }) : "" }));
|
|
1578
|
+
};
|
|
1579
|
+
|
|
1580
|
+
var __defProp$g = Object.defineProperty;
|
|
1581
|
+
var __defProps$d = Object.defineProperties;
|
|
1582
|
+
var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
|
|
1583
|
+
var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
|
|
1584
|
+
var __hasOwnProp$g = Object.prototype.hasOwnProperty;
|
|
1585
|
+
var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
|
|
1586
|
+
var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1587
|
+
var __spreadValues$g = (a, b) => {
|
|
1588
|
+
for (var prop in b || (b = {}))
|
|
1589
|
+
if (__hasOwnProp$g.call(b, prop))
|
|
1590
|
+
__defNormalProp$g(a, prop, b[prop]);
|
|
1591
|
+
if (__getOwnPropSymbols$g)
|
|
1592
|
+
for (var prop of __getOwnPropSymbols$g(b)) {
|
|
1593
|
+
if (__propIsEnum$g.call(b, prop))
|
|
1594
|
+
__defNormalProp$g(a, prop, b[prop]);
|
|
1595
|
+
}
|
|
1596
|
+
return a;
|
|
1597
|
+
};
|
|
1598
|
+
var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
|
|
1599
|
+
const NoMemoRangeFilter = ({ filter }) => {
|
|
1600
|
+
var _a, _b;
|
|
1601
|
+
const { onFilterBlur, onFilterChange, onFilterPressEnter } = useResponsiveTableContext();
|
|
1602
|
+
const filterLow = {
|
|
1603
|
+
id: filter.id,
|
|
1604
|
+
currentValue: filter.currentValue,
|
|
1605
|
+
type: "number"
|
|
1606
|
+
};
|
|
1607
|
+
const filterHigh = {
|
|
1608
|
+
id: (_a = filter.filterToId) != null ? _a : "",
|
|
1609
|
+
currentValue: (_b = filter.filterToValue) != null ? _b : "",
|
|
1610
|
+
type: "number"
|
|
1611
|
+
};
|
|
1612
|
+
return /* @__PURE__ */ jsxs(Box, { className: "ApiaFilter__Range", children: [
|
|
1613
|
+
/* @__PURE__ */ jsx(Box, { className: "ApiaFilter__Range__Low", children: /* @__PURE__ */ jsx(
|
|
1614
|
+
ApiaFilter,
|
|
1615
|
+
{
|
|
1616
|
+
filter: filterLow,
|
|
1617
|
+
onChange: (currentValue) => {
|
|
1618
|
+
if (onFilterChange)
|
|
1619
|
+
void onFilterChange(__spreadProps$d(__spreadValues$g({}, filterLow), { currentValue }));
|
|
1620
|
+
},
|
|
1621
|
+
onBlur: (currentValue) => {
|
|
1622
|
+
if (onFilterBlur)
|
|
1623
|
+
void onFilterBlur(__spreadProps$d(__spreadValues$g({}, filterLow), { currentValue }));
|
|
1624
|
+
},
|
|
1625
|
+
onPressEnter: (currentValue) => {
|
|
1626
|
+
if (onFilterPressEnter)
|
|
1627
|
+
void onFilterPressEnter(__spreadProps$d(__spreadValues$g({}, filterLow), { currentValue }));
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
) }),
|
|
1631
|
+
" - ",
|
|
1632
|
+
/* @__PURE__ */ jsx(Box, { className: "ApiaFilter__Range__High", children: /* @__PURE__ */ jsx(
|
|
1633
|
+
ApiaFilter,
|
|
1634
|
+
{
|
|
1635
|
+
filter: filterHigh,
|
|
1636
|
+
onChange: (currentValue) => {
|
|
1637
|
+
if (onFilterChange)
|
|
1638
|
+
void onFilterChange(__spreadProps$d(__spreadValues$g({}, filterHigh), { currentValue }));
|
|
1639
|
+
},
|
|
1640
|
+
onBlur: (currentValue) => {
|
|
1641
|
+
if (onFilterBlur)
|
|
1642
|
+
void onFilterBlur(__spreadProps$d(__spreadValues$g({}, filterHigh), { currentValue }));
|
|
1643
|
+
},
|
|
1644
|
+
onPressEnter: (currentValue) => {
|
|
1645
|
+
if (onFilterPressEnter)
|
|
1646
|
+
void onFilterPressEnter(__spreadProps$d(__spreadValues$g({}, filterHigh), { currentValue }));
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
) })
|
|
1650
|
+
] });
|
|
1651
|
+
};
|
|
1652
|
+
const RangeFilter = NoMemoRangeFilter;
|
|
1653
|
+
|
|
1654
|
+
var __defProp$f = Object.defineProperty;
|
|
1655
|
+
var __defProps$c = Object.defineProperties;
|
|
1656
|
+
var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
|
|
1657
|
+
var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
|
|
1658
|
+
var __hasOwnProp$f = Object.prototype.hasOwnProperty;
|
|
1659
|
+
var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
|
|
1660
|
+
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1661
|
+
var __spreadValues$f = (a, b) => {
|
|
1662
|
+
for (var prop in b || (b = {}))
|
|
1663
|
+
if (__hasOwnProp$f.call(b, prop))
|
|
1664
|
+
__defNormalProp$f(a, prop, b[prop]);
|
|
1665
|
+
if (__getOwnPropSymbols$f)
|
|
1666
|
+
for (var prop of __getOwnPropSymbols$f(b)) {
|
|
1667
|
+
if (__propIsEnum$f.call(b, prop))
|
|
1668
|
+
__defNormalProp$f(a, prop, b[prop]);
|
|
1669
|
+
}
|
|
1670
|
+
return a;
|
|
1671
|
+
};
|
|
1672
|
+
var __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
|
|
1673
|
+
const FilterCell = ({ columnIndex, filter }) => {
|
|
1674
|
+
const { name, onFilterBlur, onFilterChange, onFilterPressEnter } = useResponsiveTableContext();
|
|
1675
|
+
const domProps = useDomProps(
|
|
1676
|
+
"filterTd",
|
|
1677
|
+
{
|
|
1678
|
+
columnIndex
|
|
1679
|
+
},
|
|
1680
|
+
domPropsSelector(name)
|
|
1681
|
+
);
|
|
1682
|
+
const handleOnBlur = React.useCallback(
|
|
1683
|
+
(currentValue) => {
|
|
1684
|
+
if (filter && onFilterBlur)
|
|
1685
|
+
onFilterBlur(__spreadProps$c(__spreadValues$f({}, filter), { currentValue }));
|
|
1686
|
+
},
|
|
1687
|
+
[filter, onFilterBlur]
|
|
1688
|
+
);
|
|
1689
|
+
const handleOnChange = React.useCallback(
|
|
1690
|
+
(currentValue) => {
|
|
1691
|
+
if (filter && onFilterChange)
|
|
1692
|
+
return onFilterChange(__spreadProps$c(__spreadValues$f({}, filter), { currentValue }));
|
|
1693
|
+
return true;
|
|
1694
|
+
},
|
|
1695
|
+
[filter, onFilterChange]
|
|
1696
|
+
);
|
|
1697
|
+
const handleOnPressEnter = React.useCallback(
|
|
1698
|
+
(currentValue) => {
|
|
1699
|
+
if (filter && onFilterPressEnter)
|
|
1700
|
+
onFilterPressEnter(__spreadProps$c(__spreadValues$f({}, filter), { currentValue }));
|
|
1701
|
+
},
|
|
1702
|
+
[filter, onFilterPressEnter]
|
|
1703
|
+
);
|
|
1704
|
+
function findFilter() {
|
|
1705
|
+
if (filter == null ? void 0 : filter.isRange) {
|
|
1706
|
+
return /* @__PURE__ */ jsx(RangeFilter, { filter });
|
|
1707
|
+
}
|
|
1708
|
+
if (filter && !(filter.asAdditional || !filter.column || filter.isRange)) {
|
|
1709
|
+
return /* @__PURE__ */ jsx(
|
|
1710
|
+
ApiaFilter,
|
|
1711
|
+
{
|
|
1712
|
+
onBlur: handleOnBlur,
|
|
1713
|
+
onChange: handleOnChange,
|
|
1714
|
+
onPressEnter: handleOnPressEnter,
|
|
1715
|
+
filter
|
|
1716
|
+
}
|
|
1717
|
+
);
|
|
1718
|
+
}
|
|
1719
|
+
let label;
|
|
1720
|
+
if (filter && (filter.asAdditional || !filter.column || filter.isRange)) {
|
|
1721
|
+
label = window.LBL_ADDITIONAL_FILTER;
|
|
1722
|
+
} else {
|
|
1723
|
+
label = window.LBL_NO_COLUMN_FILTER;
|
|
1724
|
+
}
|
|
1725
|
+
return /* @__PURE__ */ jsx(Input, { "aria-label": label, disabled: true });
|
|
1726
|
+
}
|
|
1727
|
+
return /* @__PURE__ */ jsx("td", __spreadProps$c(__spreadValues$f({}, domProps), { children: findFilter() }));
|
|
1728
|
+
};
|
|
1729
|
+
|
|
1730
|
+
var __defProp$e = Object.defineProperty;
|
|
1731
|
+
var __defProps$b = Object.defineProperties;
|
|
1732
|
+
var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
|
|
1733
|
+
var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
|
|
1734
|
+
var __hasOwnProp$e = Object.prototype.hasOwnProperty;
|
|
1735
|
+
var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
|
|
1736
|
+
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1737
|
+
var __spreadValues$e = (a, b) => {
|
|
1738
|
+
for (var prop in b || (b = {}))
|
|
1739
|
+
if (__hasOwnProp$e.call(b, prop))
|
|
1740
|
+
__defNormalProp$e(a, prop, b[prop]);
|
|
1741
|
+
if (__getOwnPropSymbols$e)
|
|
1742
|
+
for (var prop of __getOwnPropSymbols$e(b)) {
|
|
1743
|
+
if (__propIsEnum$e.call(b, prop))
|
|
1744
|
+
__defNormalProp$e(a, prop, b[prop]);
|
|
1745
|
+
}
|
|
1746
|
+
return a;
|
|
1747
|
+
};
|
|
1748
|
+
var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
|
|
1749
|
+
const NoMemoHeader = () => {
|
|
1750
|
+
const { name } = useResponsiveTableContext();
|
|
1751
|
+
const { columns, hasNonAdditionalFilters, focusedColumn, focusedRow } = useResponsiveTable((global) => {
|
|
1752
|
+
var _a;
|
|
1753
|
+
const tableState = global.responsiveTableSlice[name];
|
|
1754
|
+
window.focusedRow = tableState == null ? void 0 : tableState.focusedRow;
|
|
1755
|
+
window.focusedColumn = tableState == null ? void 0 : tableState.focusedColumn;
|
|
1756
|
+
window.hasNonAdditionalFilters = (tableState == null ? void 0 : tableState.hasNonAdditionalFilters) || false;
|
|
1757
|
+
return {
|
|
1758
|
+
columns: (_a = tableState == null ? void 0 : tableState.columns) != null ? _a : [],
|
|
1759
|
+
focusedColumn: tableState == null ? void 0 : tableState.focusedColumn,
|
|
1760
|
+
focusedRow: tableState == null ? void 0 : tableState.focusedRow,
|
|
1761
|
+
hasNonAdditionalFilters: tableState == null ? void 0 : tableState.hasNonAdditionalFilters
|
|
1762
|
+
};
|
|
1763
|
+
}, shallowEqual$1);
|
|
1764
|
+
const filters = useResponsiveTable(
|
|
1765
|
+
(global) => {
|
|
1766
|
+
var _a;
|
|
1767
|
+
const tableState = global.responsiveTableSlice[name];
|
|
1768
|
+
const returnObject = ((_a = tableState == null ? void 0 : tableState.filters) != null ? _a : []).map((current) => ({
|
|
1769
|
+
columnIndex: tableState.columns.findIndex(
|
|
1770
|
+
(search) => search.name === current.column
|
|
1771
|
+
),
|
|
1772
|
+
definition: current
|
|
1773
|
+
})).filter((current) => current.columnIndex >= 0);
|
|
1774
|
+
return returnObject;
|
|
1775
|
+
},
|
|
1776
|
+
(a, b) => {
|
|
1777
|
+
return a.length === b.length && a.reduce((result, current, index) => {
|
|
1778
|
+
return result && shallowEqual$1(current.definition, b[index].definition);
|
|
1779
|
+
}, true);
|
|
1780
|
+
}
|
|
1781
|
+
);
|
|
1782
|
+
const statesCount = useResponsiveTable((globalState) => {
|
|
1783
|
+
var _a;
|
|
1784
|
+
const state = globalState.responsiveTableSlice[name];
|
|
1785
|
+
return (_a = state == null ? void 0 : state.statesColumns) != null ? _a : 0;
|
|
1786
|
+
}, shallowEqual$1);
|
|
1787
|
+
const additionalColumns = React.useMemo(
|
|
1788
|
+
() => columns.reduce(
|
|
1789
|
+
(count, column) => count + (column.showAsAdditional ? 1 : 0),
|
|
1790
|
+
0
|
|
1791
|
+
),
|
|
1792
|
+
[columns]
|
|
1793
|
+
);
|
|
1794
|
+
const statesIds = React.useMemo(() => {
|
|
1795
|
+
return Array(statesCount).fill("").map(() => uniqueId());
|
|
1796
|
+
}, [statesCount]);
|
|
1797
|
+
const [isFiltersRowVisible, setIsFiltersRowVisible] = React.useState(
|
|
1798
|
+
/* (persistentStorage.showResponsiveTableFilters as boolean) ?? */
|
|
1799
|
+
false
|
|
1800
|
+
);
|
|
1801
|
+
React.useEffect(() => {
|
|
1802
|
+
persistentStorage.showResponsiveTableFilters = isFiltersRowVisible;
|
|
1803
|
+
}, [isFiltersRowVisible]);
|
|
1804
|
+
const buttonProps = useOtherTagButton(
|
|
1805
|
+
React.useMemo(
|
|
1806
|
+
() => ({
|
|
1807
|
+
className: "additionalColumn",
|
|
1808
|
+
onClick: () => setIsFiltersRowVisible((current) => !current)
|
|
1809
|
+
}),
|
|
1810
|
+
[]
|
|
1811
|
+
)
|
|
1812
|
+
);
|
|
1813
|
+
const [ref, setRef] = useState(null);
|
|
1814
|
+
useUpdateEffect$1(() => {
|
|
1815
|
+
const handleFocus = (ev) => {
|
|
1816
|
+
ev.stopPropagation();
|
|
1817
|
+
setIsFiltersRowVisible(true);
|
|
1818
|
+
};
|
|
1819
|
+
ref == null ? void 0 : ref.addEventListener(customEvents.focus, handleFocus);
|
|
1820
|
+
return () => {
|
|
1821
|
+
ref == null ? void 0 : ref.removeEventListener(customEvents.focus, handleFocus);
|
|
1822
|
+
};
|
|
1823
|
+
}, [ref]);
|
|
1824
|
+
return /* @__PURE__ */ jsxs("thead", { children: [
|
|
1825
|
+
/* @__PURE__ */ jsxs("tr", { "data-focusindex": 1, children: [
|
|
1826
|
+
(additionalColumns > 0 || hasNonAdditionalFilters) && /* @__PURE__ */ jsx(
|
|
1827
|
+
"th",
|
|
1828
|
+
__spreadProps$b(__spreadValues$e({
|
|
1829
|
+
"aria-colindex": 1,
|
|
1830
|
+
"aria-rowindex": 1,
|
|
1831
|
+
"data-focused": focusedColumn === 1 && focusedRow === -1 - (hasNonAdditionalFilters ? 1 : 0)
|
|
1832
|
+
}, buttonProps), {
|
|
1833
|
+
tabIndex: focusedColumn === 1 && focusedRow === -1 - (hasNonAdditionalFilters ? 1 : 0) ? 0 : -1,
|
|
1834
|
+
role: "rowheader",
|
|
1835
|
+
children: hasNonAdditionalFilters ? /* @__PURE__ */ jsx(
|
|
1836
|
+
Icon,
|
|
1837
|
+
{
|
|
1838
|
+
className: "filterButton",
|
|
1839
|
+
name: "Filter",
|
|
1840
|
+
title: isFiltersRowVisible ? window.LBL_HIDE_FILTERS : window.LBL_SHOW_FILTERS,
|
|
1841
|
+
"aria-label": isFiltersRowVisible ? window.LBL_HIDE_FILTERS : window.LBL_SHOW_FILTERS
|
|
1842
|
+
}
|
|
1843
|
+
) : /* @__PURE__ */ jsx(Fragment, { children: "\xA0" })
|
|
1844
|
+
})
|
|
1845
|
+
),
|
|
1846
|
+
statesIds.map((id, i) => /* @__PURE__ */ jsx(StateCell, { isHeader: true, index: i, rowIndex: 1 }, id)),
|
|
1847
|
+
columns.map((current, actualColumnIndex) => __spreadProps$b(__spreadValues$e({}, current), {
|
|
1848
|
+
actualTableColumnIndex: actualColumnIndex
|
|
1849
|
+
})).filter((current) => !current.showAsAdditional).map((current, columnIndex) => {
|
|
1850
|
+
if (current.hidden)
|
|
1851
|
+
return null;
|
|
1852
|
+
return /* @__PURE__ */ jsx(
|
|
1853
|
+
HeaderCell,
|
|
1854
|
+
{
|
|
1855
|
+
apiaColumnIndex: current.actualTableColumnIndex,
|
|
1856
|
+
columnIndex: current.actualTableColumnIndex,
|
|
1857
|
+
inTableColumnIndex: columnIndex
|
|
1858
|
+
},
|
|
1859
|
+
current.name
|
|
1860
|
+
);
|
|
1861
|
+
})
|
|
1862
|
+
] }),
|
|
1863
|
+
filters.length > 0 && /* @__PURE__ */ jsxs(
|
|
1864
|
+
"tr",
|
|
1865
|
+
{
|
|
1866
|
+
ref: setRef,
|
|
1867
|
+
"data-focusindex": 2,
|
|
1868
|
+
className: `responsiveTable__filters__row ${isFiltersRowVisible ? "" : "hidden"}`,
|
|
1869
|
+
children: [
|
|
1870
|
+
(additionalColumns > 0 || hasNonAdditionalFilters) && /* @__PURE__ */ jsx(
|
|
1871
|
+
"td",
|
|
1872
|
+
{
|
|
1873
|
+
className: "noFilter",
|
|
1874
|
+
"aria-colindex": 1,
|
|
1875
|
+
"aria-rowindex": 2,
|
|
1876
|
+
tabIndex: focusedColumn === 1 && focusedRow === -1 ? 0 : -1,
|
|
1877
|
+
"data-focused": focusedColumn === 1 && focusedRow === -1,
|
|
1878
|
+
children: "\xA0"
|
|
1879
|
+
}
|
|
1880
|
+
),
|
|
1881
|
+
statesIds.map((id, i) => /* @__PURE__ */ jsx(StateCell, { isHeader: true, index: i, rowIndex: 2 }, id)),
|
|
1882
|
+
columns.filter((current) => !current.showAsAdditional).map((current, columnIndex) => {
|
|
1883
|
+
const filter = filters.find(
|
|
1884
|
+
(search) => search.definition.column === current.name
|
|
1885
|
+
);
|
|
1886
|
+
return current.showAsAdditional ? null : /* @__PURE__ */ jsx(
|
|
1887
|
+
FilterCell,
|
|
1888
|
+
{
|
|
1889
|
+
columnIndex,
|
|
1890
|
+
filter: filter == null ? void 0 : filter.definition
|
|
1891
|
+
},
|
|
1892
|
+
current.name
|
|
1893
|
+
);
|
|
1894
|
+
})
|
|
1895
|
+
]
|
|
1896
|
+
}
|
|
1897
|
+
)
|
|
1898
|
+
] });
|
|
1899
|
+
};
|
|
1900
|
+
const Header = React.memo(NoMemoHeader);
|
|
1901
|
+
|
|
1902
|
+
const NoMemoAdditionalColumnDefaultRenderer = ({
|
|
1903
|
+
column,
|
|
1904
|
+
cell
|
|
1905
|
+
}) => {
|
|
1906
|
+
var _a;
|
|
1907
|
+
return /* @__PURE__ */ jsxs(
|
|
1908
|
+
Box,
|
|
1909
|
+
{
|
|
1910
|
+
className: `${(_a = cell.className) != null ? _a : ""} responsiveTable__additionalInfoItem`,
|
|
1911
|
+
id: cell.id,
|
|
1912
|
+
title: cell.title,
|
|
1913
|
+
children: [
|
|
1914
|
+
/* @__PURE__ */ jsxs(Box, { as: "strong", children: [
|
|
1915
|
+
column.name,
|
|
1916
|
+
":"
|
|
1917
|
+
] }),
|
|
1918
|
+
" ",
|
|
1919
|
+
cell.children
|
|
1920
|
+
]
|
|
1921
|
+
}
|
|
1922
|
+
);
|
|
1923
|
+
};
|
|
1924
|
+
const AdditionalColumnDefaultRenderer = React.memo(
|
|
1925
|
+
NoMemoAdditionalColumnDefaultRenderer
|
|
1926
|
+
);
|
|
1927
|
+
|
|
1928
|
+
var __defProp$d = Object.defineProperty;
|
|
1929
|
+
var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
|
|
1930
|
+
var __hasOwnProp$d = Object.prototype.hasOwnProperty;
|
|
1931
|
+
var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
|
|
1932
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1933
|
+
var __spreadValues$d = (a, b) => {
|
|
1934
|
+
for (var prop in b || (b = {}))
|
|
1935
|
+
if (__hasOwnProp$d.call(b, prop))
|
|
1936
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
1937
|
+
if (__getOwnPropSymbols$d)
|
|
1938
|
+
for (var prop of __getOwnPropSymbols$d(b)) {
|
|
1939
|
+
if (__propIsEnum$d.call(b, prop))
|
|
1940
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
1941
|
+
}
|
|
1942
|
+
return a;
|
|
1943
|
+
};
|
|
1944
|
+
const SeparatorCell = ({
|
|
1945
|
+
colSpan,
|
|
1946
|
+
rowIndex
|
|
1947
|
+
}) => {
|
|
1948
|
+
const { name } = useResponsiveTableContext();
|
|
1949
|
+
const domProps = useDomProps(
|
|
1950
|
+
"separator",
|
|
1951
|
+
{ rowIndex },
|
|
1952
|
+
domPropsSelector(name)
|
|
1953
|
+
);
|
|
1954
|
+
return /* @__PURE__ */ jsx("td", __spreadValues$d({ className: "row__separator__cell", colSpan }, domProps));
|
|
1955
|
+
};
|
|
1956
|
+
|
|
1957
|
+
var __defProp$c = Object.defineProperty;
|
|
1958
|
+
var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
|
|
1959
|
+
var __hasOwnProp$c = Object.prototype.hasOwnProperty;
|
|
1960
|
+
var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
|
|
1961
|
+
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1962
|
+
var __spreadValues$c = (a, b) => {
|
|
1963
|
+
for (var prop in b || (b = {}))
|
|
1964
|
+
if (__hasOwnProp$c.call(b, prop))
|
|
1965
|
+
__defNormalProp$c(a, prop, b[prop]);
|
|
1966
|
+
if (__getOwnPropSymbols$c)
|
|
1967
|
+
for (var prop of __getOwnPropSymbols$c(b)) {
|
|
1968
|
+
if (__propIsEnum$c.call(b, prop))
|
|
1969
|
+
__defNormalProp$c(a, prop, b[prop]);
|
|
1970
|
+
}
|
|
1971
|
+
return a;
|
|
1972
|
+
};
|
|
1973
|
+
var __objRest$9 = (source, exclude) => {
|
|
1974
|
+
var target = {};
|
|
1975
|
+
for (var prop in source)
|
|
1976
|
+
if (__hasOwnProp$c.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1977
|
+
target[prop] = source[prop];
|
|
1978
|
+
if (source != null && __getOwnPropSymbols$c)
|
|
1979
|
+
for (var prop of __getOwnPropSymbols$c(source)) {
|
|
1980
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$c.call(source, prop))
|
|
1981
|
+
target[prop] = source[prop];
|
|
1982
|
+
}
|
|
1983
|
+
return target;
|
|
1984
|
+
};
|
|
1985
|
+
const NoMemoDefaultRowRenderer = React.forwardRef((_a, currentRef) => {
|
|
1986
|
+
var _b = _a, { row, rowIndex } = _b, props = __objRest$9(_b, ["row", "rowIndex"]);
|
|
1987
|
+
return /* @__PURE__ */ jsx(
|
|
1988
|
+
Box,
|
|
1989
|
+
__spreadValues$c({
|
|
1990
|
+
as: "tr",
|
|
1991
|
+
sx: useMemo(
|
|
1992
|
+
() => ({
|
|
1993
|
+
"&.colored, & > *": {
|
|
1994
|
+
color: row.color,
|
|
1995
|
+
background: row.background
|
|
1996
|
+
}
|
|
1997
|
+
}),
|
|
1998
|
+
[row.background, row.color]
|
|
1999
|
+
),
|
|
2000
|
+
ref: currentRef
|
|
2001
|
+
}, props)
|
|
2002
|
+
);
|
|
2003
|
+
});
|
|
2004
|
+
NoMemoDefaultRowRenderer.displayName = "DefaultRowRenderer";
|
|
2005
|
+
const DefaultRowRenderer = NoMemoDefaultRowRenderer;
|
|
2006
|
+
|
|
2007
|
+
var __defProp$b = Object.defineProperty;
|
|
2008
|
+
var __defProps$a = Object.defineProperties;
|
|
2009
|
+
var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
|
|
2010
|
+
var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
|
|
2011
|
+
var __hasOwnProp$b = Object.prototype.hasOwnProperty;
|
|
2012
|
+
var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
|
|
2013
|
+
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2014
|
+
var __spreadValues$b = (a, b) => {
|
|
2015
|
+
for (var prop in b || (b = {}))
|
|
2016
|
+
if (__hasOwnProp$b.call(b, prop))
|
|
2017
|
+
__defNormalProp$b(a, prop, b[prop]);
|
|
2018
|
+
if (__getOwnPropSymbols$b)
|
|
2019
|
+
for (var prop of __getOwnPropSymbols$b(b)) {
|
|
2020
|
+
if (__propIsEnum$b.call(b, prop))
|
|
2021
|
+
__defNormalProp$b(a, prop, b[prop]);
|
|
2022
|
+
}
|
|
2023
|
+
return a;
|
|
2024
|
+
};
|
|
2025
|
+
var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
|
|
2026
|
+
var __objRest$8 = (source, exclude) => {
|
|
2027
|
+
var target = {};
|
|
2028
|
+
for (var prop in source)
|
|
2029
|
+
if (__hasOwnProp$b.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2030
|
+
target[prop] = source[prop];
|
|
2031
|
+
if (source != null && __getOwnPropSymbols$b)
|
|
2032
|
+
for (var prop of __getOwnPropSymbols$b(source)) {
|
|
2033
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$b.call(source, prop))
|
|
2034
|
+
target[prop] = source[prop];
|
|
2035
|
+
}
|
|
2036
|
+
return target;
|
|
2037
|
+
};
|
|
2038
|
+
const NoMemoDefaultCellRenderer = React.forwardRef(
|
|
2039
|
+
(_a, currentRef) => {
|
|
2040
|
+
var _b = _a, {
|
|
2041
|
+
cell: _c
|
|
2042
|
+
} = _b, _d = _c, { Renderer, rendererProps, AccordionRenderer, ariaLabel } = _d, cell = __objRest$8(_d, ["Renderer", "rendererProps", "AccordionRenderer", "ariaLabel"]), _e = _b, props = __objRest$8(_e, [
|
|
2043
|
+
"cell",
|
|
2044
|
+
"column",
|
|
2045
|
+
"row"
|
|
2046
|
+
]);
|
|
2047
|
+
return /* @__PURE__ */ jsx(
|
|
2048
|
+
Box,
|
|
2049
|
+
__spreadProps$a(__spreadValues$b(__spreadValues$b({
|
|
2050
|
+
as: "td",
|
|
2051
|
+
sx: useMemo(
|
|
2052
|
+
() => ({
|
|
2053
|
+
"&.colored": {
|
|
2054
|
+
background: cell.background,
|
|
2055
|
+
color: cell.color
|
|
2056
|
+
}
|
|
2057
|
+
}),
|
|
2058
|
+
[cell.background, cell.color]
|
|
2059
|
+
),
|
|
2060
|
+
ref: currentRef
|
|
2061
|
+
}, props), cell), {
|
|
2062
|
+
"aria-label": ariaLabel
|
|
2063
|
+
})
|
|
2064
|
+
);
|
|
2065
|
+
}
|
|
2066
|
+
);
|
|
2067
|
+
NoMemoDefaultCellRenderer.displayName = "DefaultCellRenderer";
|
|
2068
|
+
const DefaultCellRenderer = NoMemoDefaultCellRenderer;
|
|
2069
|
+
|
|
2070
|
+
var __defProp$a = Object.defineProperty;
|
|
2071
|
+
var __defProps$9 = Object.defineProperties;
|
|
2072
|
+
var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
|
|
2073
|
+
var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
|
|
2074
|
+
var __hasOwnProp$a = Object.prototype.hasOwnProperty;
|
|
2075
|
+
var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
|
|
2076
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2077
|
+
var __spreadValues$a = (a, b) => {
|
|
2078
|
+
for (var prop in b || (b = {}))
|
|
2079
|
+
if (__hasOwnProp$a.call(b, prop))
|
|
2080
|
+
__defNormalProp$a(a, prop, b[prop]);
|
|
2081
|
+
if (__getOwnPropSymbols$a)
|
|
2082
|
+
for (var prop of __getOwnPropSymbols$a(b)) {
|
|
2083
|
+
if (__propIsEnum$a.call(b, prop))
|
|
2084
|
+
__defNormalProp$a(a, prop, b[prop]);
|
|
2085
|
+
}
|
|
2086
|
+
return a;
|
|
2087
|
+
};
|
|
2088
|
+
var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
|
|
2089
|
+
const NoMemoCell = ({
|
|
2090
|
+
columnIndex,
|
|
2091
|
+
inTableColumnIndex,
|
|
2092
|
+
rowIndex
|
|
2093
|
+
}) => {
|
|
2094
|
+
const { name } = useResponsiveTableContext();
|
|
2095
|
+
const domProps = useDomProps(
|
|
2096
|
+
"td",
|
|
2097
|
+
{ columnIndex: inTableColumnIndex, rowIndex },
|
|
2098
|
+
domPropsSelector(name)
|
|
2099
|
+
);
|
|
2100
|
+
const cell = useResponsiveTable((global) => {
|
|
2101
|
+
var _a;
|
|
2102
|
+
const tableState = global.responsiveTableSlice[name];
|
|
2103
|
+
return (_a = tableState == null ? void 0 : tableState.rows[rowIndex]) == null ? void 0 : _a.cells[columnIndex];
|
|
2104
|
+
}, shallowEqual);
|
|
2105
|
+
const column = useResponsiveTable((global) => {
|
|
2106
|
+
const tableState = global.responsiveTableSlice[name];
|
|
2107
|
+
return tableState == null ? void 0 : tableState.columns[columnIndex];
|
|
2108
|
+
}, shallowEqual);
|
|
2109
|
+
const row = useResponsiveTable((global) => {
|
|
2110
|
+
const tableState = global.responsiveTableSlice[name];
|
|
2111
|
+
return tableState == null ? void 0 : tableState.rows[rowIndex];
|
|
2112
|
+
}, shallowEqual);
|
|
2113
|
+
const Renderer = React.useMemo(
|
|
2114
|
+
() => {
|
|
2115
|
+
var _a;
|
|
2116
|
+
return (_a = cell == null ? void 0 : cell.Renderer) != null ? _a : DefaultCellRenderer;
|
|
2117
|
+
},
|
|
2118
|
+
[cell == null ? void 0 : cell.Renderer]
|
|
2119
|
+
);
|
|
2120
|
+
if (!Renderer || !cell)
|
|
2121
|
+
return row.separator ? /* @__PURE__ */ jsx("div", { className: "separator" }) : null;
|
|
2122
|
+
return /* @__PURE__ */ jsx(
|
|
2123
|
+
Renderer,
|
|
2124
|
+
__spreadProps$9(__spreadValues$a({}, domProps), {
|
|
2125
|
+
cell,
|
|
2126
|
+
column,
|
|
2127
|
+
row
|
|
2128
|
+
})
|
|
2129
|
+
);
|
|
2130
|
+
};
|
|
2131
|
+
const Cell = React.memo(NoMemoCell);
|
|
2132
|
+
|
|
2133
|
+
var __defProp$9 = Object.defineProperty;
|
|
2134
|
+
var __defProps$8 = Object.defineProperties;
|
|
2135
|
+
var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
|
|
2136
|
+
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
|
2137
|
+
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
|
2138
|
+
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
|
2139
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2140
|
+
var __spreadValues$9 = (a, b) => {
|
|
2141
|
+
for (var prop in b || (b = {}))
|
|
2142
|
+
if (__hasOwnProp$9.call(b, prop))
|
|
2143
|
+
__defNormalProp$9(a, prop, b[prop]);
|
|
2144
|
+
if (__getOwnPropSymbols$9)
|
|
2145
|
+
for (var prop of __getOwnPropSymbols$9(b)) {
|
|
2146
|
+
if (__propIsEnum$9.call(b, prop))
|
|
2147
|
+
__defNormalProp$9(a, prop, b[prop]);
|
|
2148
|
+
}
|
|
2149
|
+
return a;
|
|
2150
|
+
};
|
|
2151
|
+
var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
|
|
2152
|
+
var __objRest$7 = (source, exclude) => {
|
|
2153
|
+
var target = {};
|
|
2154
|
+
for (var prop in source)
|
|
2155
|
+
if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2156
|
+
target[prop] = source[prop];
|
|
2157
|
+
if (source != null && __getOwnPropSymbols$9)
|
|
2158
|
+
for (var prop of __getOwnPropSymbols$9(source)) {
|
|
2159
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
|
|
2160
|
+
target[prop] = source[prop];
|
|
2161
|
+
}
|
|
2162
|
+
return target;
|
|
2163
|
+
};
|
|
2164
|
+
const NoMemoRow = ({ rowIndex }) => {
|
|
2165
|
+
var _b;
|
|
2166
|
+
const { name } = useResponsiveTableContext();
|
|
2167
|
+
const { columns, hasNonAdditionalFilters } = useResponsiveTable((global) => {
|
|
2168
|
+
var _a2;
|
|
2169
|
+
const tableState = global.responsiveTableSlice[name];
|
|
2170
|
+
return {
|
|
2171
|
+
columns: (_a2 = tableState == null ? void 0 : tableState.columns) != null ? _a2 : [],
|
|
2172
|
+
hasNonAdditionalFilters: tableState == null ? void 0 : tableState.hasNonAdditionalFilters
|
|
2173
|
+
};
|
|
2174
|
+
}, shallowEqual);
|
|
2175
|
+
const row = useResponsiveTable(
|
|
2176
|
+
(global) => global.responsiveTableSlice[name].rows[rowIndex],
|
|
2177
|
+
shallowEqual
|
|
2178
|
+
);
|
|
2179
|
+
const additionalCells = useResponsiveTable(
|
|
2180
|
+
(global) => {
|
|
2181
|
+
const tableState = global.responsiveTableSlice[name];
|
|
2182
|
+
return tableState.columns.map(
|
|
2183
|
+
(current, index) => current.showAsAdditional ? {
|
|
2184
|
+
index,
|
|
2185
|
+
column: current
|
|
2186
|
+
} : null
|
|
2187
|
+
).filter(
|
|
2188
|
+
(current) => !!current
|
|
2189
|
+
).map((current) => {
|
|
2190
|
+
var _a2;
|
|
2191
|
+
return {
|
|
2192
|
+
cell: (_a2 = tableState.rows[rowIndex]) == null ? void 0 : _a2.cells[current.index],
|
|
2193
|
+
column: current.column,
|
|
2194
|
+
columnIndex: current.index
|
|
2195
|
+
};
|
|
2196
|
+
});
|
|
2197
|
+
},
|
|
2198
|
+
(currentValue, newValue) => {
|
|
2199
|
+
return currentValue.reduce(
|
|
2200
|
+
(accumulatedBoolean, currentCell, cellIndex) => {
|
|
2201
|
+
return accumulatedBoolean && shallowEqual(currentCell, newValue[cellIndex]);
|
|
2202
|
+
},
|
|
2203
|
+
true
|
|
2204
|
+
);
|
|
2205
|
+
}
|
|
2206
|
+
);
|
|
2207
|
+
const { isDragging, isExpanded, shouldForbidSelection } = useResponsiveTable(
|
|
2208
|
+
(global) => {
|
|
2209
|
+
var _a2;
|
|
2210
|
+
const tableState = global.responsiveTableSlice[name];
|
|
2211
|
+
return {
|
|
2212
|
+
isExpanded: tableState.expandedRows.includes(rowIndex),
|
|
2213
|
+
isDragging: tableState.draggingRow === rowIndex,
|
|
2214
|
+
shouldForbidSelection: (_a2 = tableState.rows[rowIndex]) == null ? void 0 : _a2.forbidSelection
|
|
2215
|
+
};
|
|
2216
|
+
},
|
|
2217
|
+
shallowEqual
|
|
2218
|
+
);
|
|
2219
|
+
const domProps = useDomProps(
|
|
2220
|
+
"tr",
|
|
2221
|
+
{
|
|
2222
|
+
isThisRowExpanded: isExpanded,
|
|
2223
|
+
rowIndex
|
|
2224
|
+
},
|
|
2225
|
+
domPropsSelector(name)
|
|
2226
|
+
);
|
|
2227
|
+
const expandedRowDomProps = useDomProps(
|
|
2228
|
+
"tr",
|
|
2229
|
+
{
|
|
2230
|
+
isTheExpandedRow: true,
|
|
2231
|
+
rowIndex
|
|
2232
|
+
},
|
|
2233
|
+
domPropsSelector(name)
|
|
2234
|
+
);
|
|
2235
|
+
const handleExpandedState = React.useCallback(
|
|
2236
|
+
(ev) => {
|
|
2237
|
+
const willBeExpanded = typeof ev === "boolean" ? ev : !isExpanded;
|
|
2238
|
+
if (!willBeExpanded)
|
|
2239
|
+
responsiveTableStore.dispatch(
|
|
2240
|
+
responsiveTableActions.update({
|
|
2241
|
+
tableName: name,
|
|
2242
|
+
expandedRows: responsiveTableStore.getState().responsiveTableSlice[name].expandedRows.filter(
|
|
2243
|
+
(current) => current !== rowIndex
|
|
2244
|
+
)
|
|
2245
|
+
})
|
|
2246
|
+
);
|
|
2247
|
+
else
|
|
2248
|
+
responsiveTableStore.dispatch(
|
|
2249
|
+
responsiveTableActions.update({
|
|
2250
|
+
tableName: name,
|
|
2251
|
+
expandedRows: [
|
|
2252
|
+
...responsiveTableStore.getState().responsiveTableSlice[name].expandedRows,
|
|
2253
|
+
rowIndex
|
|
2254
|
+
]
|
|
2255
|
+
})
|
|
2256
|
+
);
|
|
2257
|
+
},
|
|
2258
|
+
[isExpanded, name, rowIndex]
|
|
2259
|
+
);
|
|
2260
|
+
const statesCount = useResponsiveTable((globalState) => {
|
|
2261
|
+
var _a2;
|
|
2262
|
+
const state = globalState.responsiveTableSlice[name];
|
|
2263
|
+
return (_a2 = state == null ? void 0 : state.statesColumns) != null ? _a2 : 0;
|
|
2264
|
+
}, shallowEqual);
|
|
2265
|
+
const states = React.useMemo(
|
|
2266
|
+
() => {
|
|
2267
|
+
var _a2;
|
|
2268
|
+
return ((_a2 = row.states) != null ? _a2 : []).map((current) => __spreadProps$8(__spreadValues$9({}, current), { id: uniqueId() }));
|
|
2269
|
+
},
|
|
2270
|
+
[row.states]
|
|
2271
|
+
);
|
|
2272
|
+
const _a = useDomProps(
|
|
2273
|
+
"additionalTd",
|
|
2274
|
+
{ rowIndex },
|
|
2275
|
+
domPropsSelector(name)
|
|
2276
|
+
), additionalCellDomProps = __objRest$7(_a, ["ref"]);
|
|
2277
|
+
const Renderer = React.useMemo(
|
|
2278
|
+
() => {
|
|
2279
|
+
var _a2;
|
|
2280
|
+
return (_a2 = row.renderer) != null ? _a2 : DefaultRowRenderer;
|
|
2281
|
+
},
|
|
2282
|
+
[row.renderer]
|
|
2283
|
+
);
|
|
2284
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2285
|
+
/* @__PURE__ */ jsx(
|
|
2286
|
+
Renderer,
|
|
2287
|
+
__spreadProps$8(__spreadValues$9({}, domProps), {
|
|
2288
|
+
row,
|
|
2289
|
+
rowIndex,
|
|
2290
|
+
className: `responsiveTable__row ${row.isHidden ? "hidden" : ""} ${domProps["aria-selected"] ? "selected" : ""} ${shouldForbidSelection ? "non-selectable" : ""} ${states.map((current) => current.className).join(" ")} ${(_b = row.className) != null ? _b : ""} ${row.separator ? "row__separator" : ""} ${isDragging ? "draggingRow" : ""}`,
|
|
2291
|
+
onKeyDown: React.useCallback(
|
|
2292
|
+
(ev) => {
|
|
2293
|
+
if (ev.key.toLowerCase() === "arrowleft" && ev.ctrlKey) {
|
|
2294
|
+
ev.preventDefault();
|
|
2295
|
+
ev.stopPropagation();
|
|
2296
|
+
handleExpandedState(false);
|
|
2297
|
+
}
|
|
2298
|
+
if (ev.key.toLowerCase() === "arrowright" && ev.ctrlKey) {
|
|
2299
|
+
ev.preventDefault();
|
|
2300
|
+
ev.stopPropagation();
|
|
2301
|
+
handleExpandedState(true);
|
|
2302
|
+
}
|
|
2303
|
+
},
|
|
2304
|
+
[handleExpandedState]
|
|
2305
|
+
),
|
|
2306
|
+
children: row.separator ? /* @__PURE__ */ jsx(
|
|
2307
|
+
SeparatorCell,
|
|
2308
|
+
{
|
|
2309
|
+
colSpan: (additionalCells.length > 0 || hasNonAdditionalFilters ? 1 : 0) + statesCount + columns.filter((current) => !current.showAsAdditional).length,
|
|
2310
|
+
rowIndex
|
|
2311
|
+
}
|
|
2312
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2313
|
+
(additionalCells.length > 0 || hasNonAdditionalFilters) && /* @__PURE__ */ jsx("td", __spreadProps$8(__spreadValues$9({ className: "additionalInfo__cell" }, additionalCellDomProps), { children: additionalCells.length > 0 && /* @__PURE__ */ jsx(
|
|
2314
|
+
IconButton,
|
|
2315
|
+
__spreadProps$8(__spreadValues$9({}, getVariant("icon-outline")), {
|
|
2316
|
+
icon: isExpanded ? FaMinusSquare : FaPlusSquare,
|
|
2317
|
+
"aria-label": isExpanded ? window.LBL_COLLAPSE_ROW : window.LBL_EXPAND_ROW,
|
|
2318
|
+
className: "moreInformationButton",
|
|
2319
|
+
onClick: handleExpandedState
|
|
2320
|
+
})
|
|
2321
|
+
) })),
|
|
2322
|
+
Array(statesCount).fill("").map((_, i) => {
|
|
2323
|
+
var _a2, _b2;
|
|
2324
|
+
return /* @__PURE__ */ jsx(
|
|
2325
|
+
StateCell,
|
|
2326
|
+
{
|
|
2327
|
+
index: i,
|
|
2328
|
+
state: states[i],
|
|
2329
|
+
rowIndex
|
|
2330
|
+
},
|
|
2331
|
+
(_b2 = (_a2 = states[i]) == null ? void 0 : _a2.id) != null ? _b2 : i
|
|
2332
|
+
);
|
|
2333
|
+
}),
|
|
2334
|
+
columns.map((current, actualColumnIndex) => __spreadProps$8(__spreadValues$9({}, current), {
|
|
2335
|
+
actualColumnIndex
|
|
2336
|
+
})).filter((current) => !current.showAsAdditional).map((current, inTableColumnIndex) => {
|
|
2337
|
+
if (current.hidden)
|
|
2338
|
+
return null;
|
|
2339
|
+
return /* @__PURE__ */ jsx(
|
|
2340
|
+
Cell,
|
|
2341
|
+
{
|
|
2342
|
+
columnIndex: current.actualColumnIndex,
|
|
2343
|
+
rowIndex,
|
|
2344
|
+
inTableColumnIndex
|
|
2345
|
+
},
|
|
2346
|
+
current.name
|
|
2347
|
+
);
|
|
2348
|
+
})
|
|
2349
|
+
] })
|
|
2350
|
+
})
|
|
2351
|
+
),
|
|
2352
|
+
isExpanded && /* @__PURE__ */ jsx("tr", __spreadProps$8(__spreadValues$9({ className: "expandedRow" }, expandedRowDomProps), { children: /* @__PURE__ */ jsx(
|
|
2353
|
+
"td",
|
|
2354
|
+
{
|
|
2355
|
+
colSpan: columns.length - additionalCells.length + states.length + 1,
|
|
2356
|
+
children: /* @__PURE__ */ jsx(Box, { className: "responsiveTable__additionalInfoContainer", children: additionalCells.map((current) => {
|
|
2357
|
+
const { Renderer: ColumnRenderer } = current.column;
|
|
2358
|
+
if (ColumnRenderer)
|
|
2359
|
+
return /* @__PURE__ */ jsx(
|
|
2360
|
+
ColumnRenderer,
|
|
2361
|
+
{
|
|
2362
|
+
cell: current.cell,
|
|
2363
|
+
column: current.column,
|
|
2364
|
+
row
|
|
2365
|
+
},
|
|
2366
|
+
current.column.name
|
|
2367
|
+
);
|
|
2368
|
+
return /* @__PURE__ */ jsx(
|
|
2369
|
+
AdditionalColumnDefaultRenderer,
|
|
2370
|
+
{
|
|
2371
|
+
cell: current.cell,
|
|
2372
|
+
column: current.column,
|
|
2373
|
+
row
|
|
2374
|
+
},
|
|
2375
|
+
current.column.name
|
|
2376
|
+
);
|
|
2377
|
+
}) })
|
|
2378
|
+
}
|
|
2379
|
+
) }))
|
|
2380
|
+
] });
|
|
2381
|
+
};
|
|
2382
|
+
const Row = React.memo(NoMemoRow);
|
|
2383
|
+
|
|
2384
|
+
const NoRegistersRenderer = () => {
|
|
2385
|
+
const { labels } = useResponsiveTableContext();
|
|
2386
|
+
return /* @__PURE__ */ jsx(Box, { className: "no__registers", children: labels.noRegisters });
|
|
2387
|
+
};
|
|
2388
|
+
|
|
2389
|
+
var __defProp$8 = Object.defineProperty;
|
|
2390
|
+
var __defProps$7 = Object.defineProperties;
|
|
2391
|
+
var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
|
|
2392
|
+
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
2393
|
+
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
2394
|
+
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
2395
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2396
|
+
var __spreadValues$8 = (a, b) => {
|
|
2397
|
+
for (var prop in b || (b = {}))
|
|
2398
|
+
if (__hasOwnProp$8.call(b, prop))
|
|
2399
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
2400
|
+
if (__getOwnPropSymbols$8)
|
|
2401
|
+
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
2402
|
+
if (__propIsEnum$8.call(b, prop))
|
|
2403
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
2404
|
+
}
|
|
2405
|
+
return a;
|
|
2406
|
+
};
|
|
2407
|
+
var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
|
|
2408
|
+
const NoMemoTableRenderer = () => {
|
|
2409
|
+
const { name, label } = useResponsiveTableContext();
|
|
2410
|
+
const domProps = useDomProps(
|
|
2411
|
+
"table",
|
|
2412
|
+
{},
|
|
2413
|
+
(global) => global.responsiveTableSlice[name]
|
|
2414
|
+
);
|
|
2415
|
+
const rows = useResponsiveTable((global) => {
|
|
2416
|
+
var _a;
|
|
2417
|
+
const tableState = global.responsiveTableSlice[name];
|
|
2418
|
+
return ((_a = tableState == null ? void 0 : tableState.rows) != null ? _a : []).map((current) => current.id);
|
|
2419
|
+
}, shallowEqual);
|
|
2420
|
+
const { columnsCount, rowsCount } = useResponsiveTable((global) => {
|
|
2421
|
+
var _a, _b, _c;
|
|
2422
|
+
const tableState = global.responsiveTableSlice[name];
|
|
2423
|
+
return {
|
|
2424
|
+
rowsCount: (_a = tableState == null ? void 0 : tableState.rows.length) != null ? _a : 0,
|
|
2425
|
+
columnsCount: ((_b = tableState == null ? void 0 : tableState.nonAdditionalColumnsCount) != null ? _b : 0) + ((tableState == null ? void 0 : tableState.hasNonAdditionalFilters) ? 1 : 0) + ((_c = tableState == null ? void 0 : tableState.statesColumns) != null ? _c : 0)
|
|
2426
|
+
};
|
|
2427
|
+
}, shallowEqual);
|
|
2428
|
+
return /* @__PURE__ */ jsxs(
|
|
2429
|
+
Box,
|
|
2430
|
+
__spreadProps$7(__spreadValues$8(__spreadProps$7(__spreadValues$8({}, domProps), {
|
|
2431
|
+
as: "table",
|
|
2432
|
+
className: "responsiveTable__table"
|
|
2433
|
+
}), getVariant("layout.common.tables.primary")), {
|
|
2434
|
+
"aria-label": label,
|
|
2435
|
+
children: [
|
|
2436
|
+
/* @__PURE__ */ jsx(Header, {}),
|
|
2437
|
+
/* @__PURE__ */ jsx("tbody", { children: rowsCount > 0 ? rows.map((row, index) => {
|
|
2438
|
+
return /* @__PURE__ */ jsx(Row, { rowIndex: index }, row != null ? row : `${row}-${index}`);
|
|
2439
|
+
}) : /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: columnsCount, children: /* @__PURE__ */ jsx(NoRegistersRenderer, {}) }) }) })
|
|
2440
|
+
]
|
|
2441
|
+
})
|
|
2442
|
+
);
|
|
2443
|
+
};
|
|
2444
|
+
const TableRenderer = React.memo(NoMemoTableRenderer);
|
|
2445
|
+
|
|
2446
|
+
const NoMemoAccordionCell = ({ cell, column }) => {
|
|
2447
|
+
var _a;
|
|
2448
|
+
return /* @__PURE__ */ jsxs(
|
|
2449
|
+
Box,
|
|
2450
|
+
{
|
|
2451
|
+
className: "responsiveTable__accordionElement__column",
|
|
2452
|
+
children: [
|
|
2453
|
+
/* @__PURE__ */ jsxs(Box, { as: "strong", children: [
|
|
2454
|
+
(_a = column.label) != null ? _a : column.name,
|
|
2455
|
+
": "
|
|
2456
|
+
] }),
|
|
2457
|
+
/* @__PURE__ */ jsx(Box, { as: "span", children: cell == null ? void 0 : cell.children })
|
|
2458
|
+
]
|
|
2459
|
+
},
|
|
2460
|
+
column.name
|
|
2461
|
+
);
|
|
2462
|
+
};
|
|
2463
|
+
const AccordionCell = NoMemoAccordionCell;
|
|
2464
|
+
|
|
2465
|
+
const PrimitiveAccordionElement = ({ children }) => /* @__PURE__ */ jsx(Box, { className: "accordion", children });
|
|
2466
|
+
const NoMemoAccordionElement = ({ row, rowIndex }) => {
|
|
2467
|
+
const { name } = useResponsiveTableContext();
|
|
2468
|
+
const indexColumns = useResponsiveTable((global) => {
|
|
2469
|
+
const tableState = global.responsiveTableSlice[name];
|
|
2470
|
+
return tableState == null ? void 0 : tableState.accordionIndexColumns;
|
|
2471
|
+
}, shallowEqual);
|
|
2472
|
+
const columns = useResponsiveTable((global) => {
|
|
2473
|
+
const tableState = global.responsiveTableSlice[name];
|
|
2474
|
+
return tableState == null ? void 0 : tableState.columns;
|
|
2475
|
+
}, shallowEqual);
|
|
2476
|
+
const title = React.useMemo(() => {
|
|
2477
|
+
var _a;
|
|
2478
|
+
if (row.title)
|
|
2479
|
+
return row.title;
|
|
2480
|
+
if (Array.isArray(indexColumns))
|
|
2481
|
+
return indexColumns.map(
|
|
2482
|
+
(current) => {
|
|
2483
|
+
var _a2;
|
|
2484
|
+
return (_a2 = row.cells[current.index].title) != null ? _a2 : row.cells[current.index].children;
|
|
2485
|
+
}
|
|
2486
|
+
).join(" | ");
|
|
2487
|
+
return (_a = row.cells[0].title) != null ? _a : row.cells[0].children;
|
|
2488
|
+
}, [indexColumns, row.cells, row.title]);
|
|
2489
|
+
if (!Array.isArray(indexColumns) || !columns)
|
|
2490
|
+
return null;
|
|
2491
|
+
return /* @__PURE__ */ jsxs(
|
|
2492
|
+
PrimitiveAccordionElement,
|
|
2493
|
+
{
|
|
2494
|
+
ButtonComponent: Button,
|
|
2495
|
+
className: "responsiveTable__accordionElement",
|
|
2496
|
+
contentClassName: "responsiveTable__accordionElement__content",
|
|
2497
|
+
id: row.id,
|
|
2498
|
+
title,
|
|
2499
|
+
children: [
|
|
2500
|
+
columns.map((currentColumn, columnIndex) => {
|
|
2501
|
+
var _a, _b;
|
|
2502
|
+
const Renderer = (_b = (_a = row.cells[columnIndex].AccordionRenderer) != null ? _a : currentColumn.AccordionRenderer) != null ? _b : AccordionCell;
|
|
2503
|
+
return currentColumn.hideFromAccordion || currentColumn.showAsAdditional ? null : /* @__PURE__ */ jsx(
|
|
2504
|
+
Renderer,
|
|
2505
|
+
{
|
|
2506
|
+
cell: row.cells[columnIndex],
|
|
2507
|
+
column: currentColumn,
|
|
2508
|
+
columnIndex,
|
|
2509
|
+
row,
|
|
2510
|
+
rowIndex
|
|
2511
|
+
},
|
|
2512
|
+
currentColumn.name
|
|
2513
|
+
);
|
|
2514
|
+
}),
|
|
2515
|
+
columns.filter((current) => !!current.showAsAdditional).map((currentColumn, columnIndex) => {
|
|
2516
|
+
var _a, _b;
|
|
2517
|
+
const Renderer = (_b = (_a = row.cells[columnIndex].AccordionRenderer) != null ? _a : currentColumn.AccordionRenderer) != null ? _b : AccordionCell;
|
|
2518
|
+
return currentColumn.hideFromAccordion ? null : /* @__PURE__ */ jsx(
|
|
2519
|
+
Renderer,
|
|
2520
|
+
{
|
|
2521
|
+
cell: row.cells[columnIndex],
|
|
2522
|
+
column: currentColumn,
|
|
2523
|
+
columnIndex,
|
|
2524
|
+
row,
|
|
2525
|
+
rowIndex
|
|
2526
|
+
},
|
|
2527
|
+
currentColumn.name
|
|
2528
|
+
);
|
|
2529
|
+
})
|
|
2530
|
+
]
|
|
2531
|
+
}
|
|
2532
|
+
);
|
|
2533
|
+
};
|
|
2534
|
+
const AccordionElement = NoMemoAccordionElement;
|
|
2535
|
+
|
|
2536
|
+
var __defProp$7 = Object.defineProperty;
|
|
2537
|
+
var __defProps$6 = Object.defineProperties;
|
|
2538
|
+
var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
|
|
2539
|
+
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
2540
|
+
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
2541
|
+
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
2542
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2543
|
+
var __spreadValues$7 = (a, b) => {
|
|
2544
|
+
for (var prop in b || (b = {}))
|
|
2545
|
+
if (__hasOwnProp$7.call(b, prop))
|
|
2546
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
2547
|
+
if (__getOwnPropSymbols$7)
|
|
2548
|
+
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
2549
|
+
if (__propIsEnum$7.call(b, prop))
|
|
2550
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
2551
|
+
}
|
|
2552
|
+
return a;
|
|
2553
|
+
};
|
|
2554
|
+
var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
|
|
2555
|
+
const isDebugging = false;
|
|
2556
|
+
const NoMemoAccordionRenderer = () => {
|
|
2557
|
+
const { name } = useResponsiveTableContext();
|
|
2558
|
+
const { columns, rows } = useResponsiveTable((global) => {
|
|
2559
|
+
const tableState = global.responsiveTableSlice[name];
|
|
2560
|
+
return {
|
|
2561
|
+
columns: tableState == null ? void 0 : tableState.columns,
|
|
2562
|
+
rows: tableState == null ? void 0 : tableState.rows
|
|
2563
|
+
};
|
|
2564
|
+
}, shallowEqual);
|
|
2565
|
+
React.useEffect(() => {
|
|
2566
|
+
if (columns && rows) {
|
|
2567
|
+
const markedAsTitleColumns = [];
|
|
2568
|
+
columns.forEach((column, index) => {
|
|
2569
|
+
if (column.showInAccordionTitle)
|
|
2570
|
+
markedAsTitleColumns.push({ column, index });
|
|
2571
|
+
});
|
|
2572
|
+
if (markedAsTitleColumns.length > 0) {
|
|
2573
|
+
responsiveTableStore.dispatch(
|
|
2574
|
+
responsiveTableActions.update({
|
|
2575
|
+
tableName: name,
|
|
2576
|
+
accordionIndexColumns: markedAsTitleColumns
|
|
2577
|
+
})
|
|
2578
|
+
);
|
|
2579
|
+
} else {
|
|
2580
|
+
const columnsLength = columns.length;
|
|
2581
|
+
let indexColumn = null;
|
|
2582
|
+
let currentIndex = 0;
|
|
2583
|
+
while (!indexColumn && !isDebugging && currentIndex < columns.length || isDebugging ) {
|
|
2584
|
+
let isAnyEmptyRow = false;
|
|
2585
|
+
for (const row of rows) {
|
|
2586
|
+
if (!row.cells[currentIndex].children) {
|
|
2587
|
+
isAnyEmptyRow = true;
|
|
2588
|
+
break;
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
if (!isAnyEmptyRow && columns[currentIndex]) {
|
|
2592
|
+
indexColumn = columns[currentIndex];
|
|
2593
|
+
} else {
|
|
2594
|
+
currentIndex += 1;
|
|
2595
|
+
if (currentIndex === columnsLength)
|
|
2596
|
+
break;
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
if (!indexColumn) {
|
|
2600
|
+
[indexColumn] = columns;
|
|
2601
|
+
currentIndex = 0;
|
|
2602
|
+
}
|
|
2603
|
+
responsiveTableStore.dispatch(
|
|
2604
|
+
responsiveTableActions.update({
|
|
2605
|
+
tableName: name,
|
|
2606
|
+
accordionIndexColumns: [
|
|
2607
|
+
{ column: indexColumn, index: currentIndex }
|
|
2608
|
+
]
|
|
2609
|
+
})
|
|
2610
|
+
);
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
}, [columns, name, rows]);
|
|
2614
|
+
const [ref, setRef] = React.useState(null);
|
|
2615
|
+
React.useEffect(() => {
|
|
2616
|
+
const observer = new MutationObserver(([mutation]) => {
|
|
2617
|
+
if (mutation.addedNodes) {
|
|
2618
|
+
mutation.addedNodes.forEach((current) => {
|
|
2619
|
+
var _a, _b;
|
|
2620
|
+
if ((_a = current.classList) == null ? void 0 : _a.contains(
|
|
2621
|
+
"responsiveTable__accordionElement"
|
|
2622
|
+
))
|
|
2623
|
+
(_b = current.scrollIntoView) == null ? void 0 : _b.call(current);
|
|
2624
|
+
});
|
|
2625
|
+
}
|
|
2626
|
+
});
|
|
2627
|
+
if (ref)
|
|
2628
|
+
observer.observe(ref, { childList: true, subtree: true });
|
|
2629
|
+
return () => {
|
|
2630
|
+
observer.disconnect();
|
|
2631
|
+
};
|
|
2632
|
+
}, [ref]);
|
|
2633
|
+
return /* @__PURE__ */ jsxs(
|
|
2634
|
+
Box,
|
|
2635
|
+
__spreadProps$6(__spreadValues$7({
|
|
2636
|
+
className: "responsiveTable__accordion"
|
|
2637
|
+
}, getVariant("layout.common.tables.accordion")), {
|
|
2638
|
+
ref: setRef,
|
|
2639
|
+
children: [
|
|
2640
|
+
!rows || rows.length === 0 && /* @__PURE__ */ jsx(NoRegistersRenderer, {}),
|
|
2641
|
+
rows == null ? void 0 : rows.slice(0, void 0).map((current, rowIndex) => /* @__PURE__ */ jsx(
|
|
2642
|
+
AccordionElement,
|
|
2643
|
+
{
|
|
2644
|
+
row: current,
|
|
2645
|
+
rowIndex
|
|
2646
|
+
},
|
|
2647
|
+
current.id
|
|
2648
|
+
))
|
|
2649
|
+
]
|
|
2650
|
+
})
|
|
2651
|
+
);
|
|
2652
|
+
};
|
|
2653
|
+
const AccordionRenderer = React.memo(NoMemoAccordionRenderer);
|
|
2654
|
+
|
|
2655
|
+
var __defProp$6 = Object.defineProperty;
|
|
2656
|
+
var __defProps$5 = Object.defineProperties;
|
|
2657
|
+
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
2658
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
2659
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
2660
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
2661
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2662
|
+
var __spreadValues$6 = (a, b) => {
|
|
2663
|
+
for (var prop in b || (b = {}))
|
|
2664
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
2665
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
2666
|
+
if (__getOwnPropSymbols$6)
|
|
2667
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
2668
|
+
if (__propIsEnum$6.call(b, prop))
|
|
2669
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
2670
|
+
}
|
|
2671
|
+
return a;
|
|
2672
|
+
};
|
|
2673
|
+
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
2674
|
+
var __objRest$6 = (source, exclude) => {
|
|
2675
|
+
var target = {};
|
|
2676
|
+
for (var prop in source)
|
|
2677
|
+
if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2678
|
+
target[prop] = source[prop];
|
|
2679
|
+
if (source != null && __getOwnPropSymbols$6)
|
|
2680
|
+
for (var prop of __getOwnPropSymbols$6(source)) {
|
|
2681
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
|
|
2682
|
+
target[prop] = source[prop];
|
|
2683
|
+
}
|
|
2684
|
+
return target;
|
|
2685
|
+
};
|
|
2686
|
+
const domPropsSelector = (name) => (global) => global.responsiveTableSlice[name];
|
|
2687
|
+
const NoMemoResponsiveTable = React.forwardRef((_a, ref) => {
|
|
2688
|
+
var _b = _a, { className } = _b, props = __objRest$6(_b, ["className"]);
|
|
2689
|
+
const breakpoint = useBreakpointIndex({ defaultIndex: 3 });
|
|
2690
|
+
const { currentBreakPoint } = useResponsiveTableContext();
|
|
2691
|
+
const actualBreakpoint = currentBreakPoint != null ? currentBreakPoint : breakpoint;
|
|
2692
|
+
return /* @__PURE__ */ jsx(KeyHandler, { children: /* @__PURE__ */ jsx(
|
|
2693
|
+
Box,
|
|
2694
|
+
__spreadProps$5(__spreadValues$6(__spreadValues$6({}, props), getVariant("layout.common.tables.responsive")), {
|
|
2695
|
+
className: `responsiveTable__wrapper ${className != null ? className : ""}`,
|
|
2696
|
+
ref,
|
|
2697
|
+
children: actualBreakpoint >= 3 ? /* @__PURE__ */ jsx(TableRenderer, {}) : /* @__PURE__ */ jsx(AccordionRenderer, {})
|
|
2698
|
+
})
|
|
2699
|
+
) });
|
|
2700
|
+
});
|
|
2701
|
+
NoMemoResponsiveTable.displayName = "ResponsiveTable";
|
|
2702
|
+
const ResponsiveTable = React.memo(NoMemoResponsiveTable);
|
|
2703
|
+
|
|
2704
|
+
var __defProp$5 = Object.defineProperty;
|
|
2705
|
+
var __defProps$4 = Object.defineProperties;
|
|
2706
|
+
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
2707
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
2708
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
2709
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
2710
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2711
|
+
var __spreadValues$5 = (a, b) => {
|
|
2712
|
+
for (var prop in b || (b = {}))
|
|
2713
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
2714
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
2715
|
+
if (__getOwnPropSymbols$5)
|
|
2716
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
2717
|
+
if (__propIsEnum$5.call(b, prop))
|
|
2718
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
2719
|
+
}
|
|
2720
|
+
return a;
|
|
2721
|
+
};
|
|
2722
|
+
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
2723
|
+
var __objRest$5 = (source, exclude) => {
|
|
2724
|
+
var target = {};
|
|
2725
|
+
for (var prop in source)
|
|
2726
|
+
if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2727
|
+
target[prop] = source[prop];
|
|
2728
|
+
if (source != null && __getOwnPropSymbols$5)
|
|
2729
|
+
for (var prop of __getOwnPropSymbols$5(source)) {
|
|
2730
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
|
|
2731
|
+
target[prop] = source[prop];
|
|
2732
|
+
}
|
|
2733
|
+
return target;
|
|
2734
|
+
};
|
|
2735
|
+
const NoMemoDocNameCellRenderer = React.forwardRef(
|
|
2736
|
+
(_a, currentRef) => {
|
|
2737
|
+
var _b = _a, {
|
|
2738
|
+
cell: _c
|
|
2739
|
+
} = _b, _d = _c, { children, Renderer, rendererProps, AccordionRenderer } = _d, cell = __objRest$5(_d, ["children", "Renderer", "rendererProps", "AccordionRenderer"]), _e = _b, props = __objRest$5(_e, [
|
|
2740
|
+
"cell",
|
|
2741
|
+
"column",
|
|
2742
|
+
"row"
|
|
2743
|
+
]);
|
|
2744
|
+
return /* @__PURE__ */ jsx(
|
|
2745
|
+
"td",
|
|
2746
|
+
__spreadProps$4(__spreadValues$5(__spreadValues$5({
|
|
2747
|
+
ref: currentRef
|
|
2748
|
+
}, props), cell), {
|
|
2749
|
+
children: /* @__PURE__ */ jsxs(
|
|
2750
|
+
Link,
|
|
2751
|
+
{
|
|
2752
|
+
className: "cell__download__document",
|
|
2753
|
+
title: rendererProps == null ? void 0 : rendererProps.docName,
|
|
2754
|
+
href: rendererProps == null ? void 0 : rendererProps.docUrl,
|
|
2755
|
+
onClick: (ev) => {
|
|
2756
|
+
ev.preventDefault();
|
|
2757
|
+
if (rendererProps == null ? void 0 : rendererProps.docUrl)
|
|
2758
|
+
void downloadUrl(rendererProps == null ? void 0 : rendererProps.docUrl);
|
|
2759
|
+
},
|
|
2760
|
+
children: [
|
|
2761
|
+
/* @__PURE__ */ jsx(Icon, { title: "", name: "Download" }),
|
|
2762
|
+
rendererProps == null ? void 0 : rendererProps.docName
|
|
2763
|
+
]
|
|
2764
|
+
}
|
|
2765
|
+
)
|
|
2766
|
+
})
|
|
2767
|
+
);
|
|
2768
|
+
}
|
|
2769
|
+
);
|
|
2770
|
+
NoMemoDocNameCellRenderer.displayName = "DocNameCellRenderer";
|
|
2771
|
+
const DocNameCellRenderer = NoMemoDocNameCellRenderer;
|
|
2772
|
+
|
|
2773
|
+
var __defProp$4 = Object.defineProperty;
|
|
2774
|
+
var __defProps$3 = Object.defineProperties;
|
|
2775
|
+
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
2776
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
2777
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
2778
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
2779
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2780
|
+
var __spreadValues$4 = (a, b) => {
|
|
2781
|
+
for (var prop in b || (b = {}))
|
|
2782
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
2783
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
2784
|
+
if (__getOwnPropSymbols$4)
|
|
2785
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
2786
|
+
if (__propIsEnum$4.call(b, prop))
|
|
2787
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
2788
|
+
}
|
|
2789
|
+
return a;
|
|
2790
|
+
};
|
|
2791
|
+
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
2792
|
+
var __objRest$4 = (source, exclude) => {
|
|
2793
|
+
var target = {};
|
|
2794
|
+
for (var prop in source)
|
|
2795
|
+
if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2796
|
+
target[prop] = source[prop];
|
|
2797
|
+
if (source != null && __getOwnPropSymbols$4)
|
|
2798
|
+
for (var prop of __getOwnPropSymbols$4(source)) {
|
|
2799
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
|
|
2800
|
+
target[prop] = source[prop];
|
|
2801
|
+
}
|
|
2802
|
+
return target;
|
|
2803
|
+
};
|
|
2804
|
+
const NoMemoAccordionDocNameCellRenderer = React.forwardRef(
|
|
2805
|
+
(_a, currentRef) => {
|
|
2806
|
+
var _b = _a, {
|
|
2807
|
+
cell: _c
|
|
2808
|
+
} = _b, _d = _c, { children, Renderer, rendererProps, AccordionRenderer } = _d, cell = __objRest$4(_d, ["children", "Renderer", "rendererProps", "AccordionRenderer"]), {
|
|
2809
|
+
column
|
|
2810
|
+
} = _b;
|
|
2811
|
+
var _a2;
|
|
2812
|
+
return /* @__PURE__ */ jsxs(Box, __spreadProps$3(__spreadValues$4({ ref: currentRef }, cell), { children: [
|
|
2813
|
+
/* @__PURE__ */ jsxs(Box, { as: "strong", children: [
|
|
2814
|
+
(_a2 = column.label) != null ? _a2 : column.name,
|
|
2815
|
+
": "
|
|
2816
|
+
] }),
|
|
2817
|
+
/* @__PURE__ */ jsxs(
|
|
2818
|
+
Link,
|
|
2819
|
+
{
|
|
2820
|
+
className: "cell__download__document",
|
|
2821
|
+
title: rendererProps == null ? void 0 : rendererProps.docName,
|
|
2822
|
+
href: rendererProps == null ? void 0 : rendererProps.docUrl,
|
|
2823
|
+
onClick: (ev) => {
|
|
2824
|
+
ev.preventDefault();
|
|
2825
|
+
if (rendererProps == null ? void 0 : rendererProps.docUrl)
|
|
2826
|
+
void downloadUrl(rendererProps == null ? void 0 : rendererProps.docUrl);
|
|
2827
|
+
},
|
|
2828
|
+
children: [
|
|
2829
|
+
/* @__PURE__ */ jsx(Icon, { title: "", name: "Download" }),
|
|
2830
|
+
rendererProps == null ? void 0 : rendererProps.docName
|
|
2831
|
+
]
|
|
2832
|
+
}
|
|
2833
|
+
)
|
|
2834
|
+
] }));
|
|
2835
|
+
}
|
|
2836
|
+
);
|
|
2837
|
+
NoMemoAccordionDocNameCellRenderer.displayName = "AccordionDocNameCellRenderer";
|
|
2838
|
+
const AccordionDocNameCellRenderer = NoMemoAccordionDocNameCellRenderer;
|
|
2839
|
+
|
|
2840
|
+
var __defProp$3 = Object.defineProperty;
|
|
2841
|
+
var __defProps$2 = Object.defineProperties;
|
|
2842
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
2843
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
2844
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
2845
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
2846
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2847
|
+
var __spreadValues$3 = (a, b) => {
|
|
2848
|
+
for (var prop in b || (b = {}))
|
|
2849
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
2850
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
2851
|
+
if (__getOwnPropSymbols$3)
|
|
2852
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
2853
|
+
if (__propIsEnum$3.call(b, prop))
|
|
2854
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
2855
|
+
}
|
|
2856
|
+
return a;
|
|
2857
|
+
};
|
|
2858
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
2859
|
+
var __objRest$3 = (source, exclude) => {
|
|
2860
|
+
var target = {};
|
|
2861
|
+
for (var prop in source)
|
|
2862
|
+
if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2863
|
+
target[prop] = source[prop];
|
|
2864
|
+
if (source != null && __getOwnPropSymbols$3)
|
|
2865
|
+
for (var prop of __getOwnPropSymbols$3(source)) {
|
|
2866
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
|
|
2867
|
+
target[prop] = source[prop];
|
|
2868
|
+
}
|
|
2869
|
+
return target;
|
|
2870
|
+
};
|
|
2871
|
+
const NoMemoAccordionHTMLCellRenderer = React.forwardRef(
|
|
2872
|
+
(_a, currentRef) => {
|
|
2873
|
+
var _b = _a, {
|
|
2874
|
+
cell: _c
|
|
2875
|
+
} = _b, _d = _c, { children, Renderer, rendererProps, AccordionRenderer } = _d, cell = __objRest$3(_d, ["children", "Renderer", "rendererProps", "AccordionRenderer"]), _e = _b, props = __objRest$3(_e, [
|
|
2876
|
+
"cell",
|
|
2877
|
+
"column",
|
|
2878
|
+
"row"
|
|
2879
|
+
]);
|
|
2880
|
+
return (
|
|
2881
|
+
/**
|
|
2882
|
+
* Aca falta el title de la columna
|
|
2883
|
+
*/
|
|
2884
|
+
/* @__PURE__ */ jsx(
|
|
2885
|
+
Box,
|
|
2886
|
+
__spreadProps$2(__spreadValues$3(__spreadValues$3(__spreadValues$3({
|
|
2887
|
+
ref: currentRef
|
|
2888
|
+
}, props), cell), (rendererProps == null ? void 0 : rendererProps.html) ? {
|
|
2889
|
+
dangerouslySetInnerHTML: {
|
|
2890
|
+
__html: rendererProps.html.replaceAll(/<TOK(\d+)/g, "<TOK$1")
|
|
2891
|
+
}
|
|
2892
|
+
} : { children }), {
|
|
2893
|
+
as: "span"
|
|
2894
|
+
})
|
|
2895
|
+
)
|
|
2896
|
+
);
|
|
2897
|
+
}
|
|
2898
|
+
);
|
|
2899
|
+
NoMemoAccordionHTMLCellRenderer.displayName = "AccordionHTMLCellRenderer";
|
|
2900
|
+
const AccordionHTMLCellRenderer = NoMemoAccordionHTMLCellRenderer;
|
|
2901
|
+
|
|
2902
|
+
var __defProp$2 = Object.defineProperty;
|
|
2903
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
2904
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
2905
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
2906
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2907
|
+
var __spreadValues$2 = (a, b) => {
|
|
2908
|
+
for (var prop in b || (b = {}))
|
|
2909
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
2910
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
2911
|
+
if (__getOwnPropSymbols$2)
|
|
2912
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
2913
|
+
if (__propIsEnum$2.call(b, prop))
|
|
2914
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
2915
|
+
}
|
|
2916
|
+
return a;
|
|
2917
|
+
};
|
|
2918
|
+
var __objRest$2 = (source, exclude) => {
|
|
2919
|
+
var target = {};
|
|
2920
|
+
for (var prop in source)
|
|
2921
|
+
if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2922
|
+
target[prop] = source[prop];
|
|
2923
|
+
if (source != null && __getOwnPropSymbols$2)
|
|
2924
|
+
for (var prop of __getOwnPropSymbols$2(source)) {
|
|
2925
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
|
|
2926
|
+
target[prop] = source[prop];
|
|
2927
|
+
}
|
|
2928
|
+
return target;
|
|
2929
|
+
};
|
|
2930
|
+
const NoMemoHTMLCellRenderer = React.forwardRef(
|
|
2931
|
+
(_a, currentRef) => {
|
|
2932
|
+
var _b = _a, {
|
|
2933
|
+
cell: _c
|
|
2934
|
+
} = _b, _d = _c, { children, Renderer, rendererProps, AccordionRenderer } = _d, cell = __objRest$2(_d, ["children", "Renderer", "rendererProps", "AccordionRenderer"]), _e = _b, props = __objRest$2(_e, [
|
|
2935
|
+
"cell",
|
|
2936
|
+
"column",
|
|
2937
|
+
"row"
|
|
2938
|
+
]);
|
|
2939
|
+
return /* @__PURE__ */ jsx(
|
|
2940
|
+
"td",
|
|
2941
|
+
__spreadValues$2(__spreadValues$2(__spreadValues$2({
|
|
2942
|
+
ref: currentRef
|
|
2943
|
+
}, props), cell), (rendererProps == null ? void 0 : rendererProps.html) ? {
|
|
2944
|
+
dangerouslySetInnerHTML: {
|
|
2945
|
+
__html: rendererProps.html.replaceAll(
|
|
2946
|
+
/<TOK(\d+)/g,
|
|
2947
|
+
"<TOK$1"
|
|
2948
|
+
)
|
|
2949
|
+
}
|
|
2950
|
+
} : { children })
|
|
2951
|
+
);
|
|
2952
|
+
}
|
|
2953
|
+
);
|
|
2954
|
+
NoMemoHTMLCellRenderer.displayName = "HTMLCellRenderer";
|
|
2955
|
+
const HTMLCellRenderer = NoMemoHTMLCellRenderer;
|
|
2956
|
+
|
|
2957
|
+
const IsLoadingRenderer = () => {
|
|
2958
|
+
return /* @__PURE__ */ jsx(Box, { className: "responsiveTable__isLoading", children: /* @__PURE__ */ jsx(Spinner, {}) });
|
|
2959
|
+
};
|
|
2960
|
+
|
|
2961
|
+
var __async$1 = (__this, __arguments, generator) => {
|
|
2962
|
+
return new Promise((resolve, reject) => {
|
|
2963
|
+
var fulfilled = (value) => {
|
|
2964
|
+
try {
|
|
2965
|
+
step(generator.next(value));
|
|
2966
|
+
} catch (e) {
|
|
2967
|
+
reject(e);
|
|
2968
|
+
}
|
|
2969
|
+
};
|
|
2970
|
+
var rejected = (value) => {
|
|
2971
|
+
try {
|
|
2972
|
+
step(generator.throw(value));
|
|
2973
|
+
} catch (e) {
|
|
2974
|
+
reject(e);
|
|
2975
|
+
}
|
|
2976
|
+
};
|
|
2977
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
2978
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
2979
|
+
});
|
|
2980
|
+
};
|
|
2981
|
+
function makeAccordionAsyncRenderer(additionalInfoGetter) {
|
|
2982
|
+
const InnerRender = forwardRef(({ row }, ref) => {
|
|
2983
|
+
const [moreInfo, setMoreInfo] = useState(null);
|
|
2984
|
+
const loadMore = useCallback(() => __async$1(this, null, function* () {
|
|
2985
|
+
const result = yield additionalInfoGetter(row);
|
|
2986
|
+
setMoreInfo(result);
|
|
2987
|
+
}), [row]);
|
|
2988
|
+
return /* @__PURE__ */ jsx(Fragment, { children: moreInfo ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2989
|
+
/* @__PURE__ */ jsx(IconButton, { icon: "Minus", onClick: () => setMoreInfo(null) }),
|
|
2990
|
+
arrayOrArray(moreInfo).map(
|
|
2991
|
+
(dataCell) => {
|
|
2992
|
+
return /* @__PURE__ */ jsxs(Box, { ref, as: "div", children: [
|
|
2993
|
+
/* @__PURE__ */ jsxs(Box, { as: "strong", children: [
|
|
2994
|
+
dataCell.name,
|
|
2995
|
+
":"
|
|
2996
|
+
] }),
|
|
2997
|
+
" ",
|
|
2998
|
+
dataCell.label
|
|
2999
|
+
] }, dataCell.name);
|
|
3000
|
+
}
|
|
3001
|
+
)
|
|
3002
|
+
] }) : /* @__PURE__ */ jsx(IconButton, { icon: "Plus", onClick: () => void loadMore() }) });
|
|
3003
|
+
});
|
|
3004
|
+
InnerRender.displayName = "MakeAccordionAsyncRenderer";
|
|
3005
|
+
return InnerRender;
|
|
3006
|
+
}
|
|
3007
|
+
|
|
3008
|
+
var __async = (__this, __arguments, generator) => {
|
|
3009
|
+
return new Promise((resolve, reject) => {
|
|
3010
|
+
var fulfilled = (value) => {
|
|
3011
|
+
try {
|
|
3012
|
+
step(generator.next(value));
|
|
3013
|
+
} catch (e) {
|
|
3014
|
+
reject(e);
|
|
3015
|
+
}
|
|
3016
|
+
};
|
|
3017
|
+
var rejected = (value) => {
|
|
3018
|
+
try {
|
|
3019
|
+
step(generator.throw(value));
|
|
3020
|
+
} catch (e) {
|
|
3021
|
+
reject(e);
|
|
3022
|
+
}
|
|
3023
|
+
};
|
|
3024
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3025
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
3026
|
+
});
|
|
3027
|
+
};
|
|
3028
|
+
function makeAsyncRenderer(additionalInfoGetter) {
|
|
3029
|
+
const InnerRender = forwardRef(({ row }, ref) => {
|
|
3030
|
+
const [moreInfo, setMoreInfo] = useState(null);
|
|
3031
|
+
useMount$1(() => {
|
|
3032
|
+
void (() => __async(this, null, function* () {
|
|
3033
|
+
const result = yield additionalInfoGetter(row);
|
|
3034
|
+
setMoreInfo(result);
|
|
3035
|
+
}))();
|
|
3036
|
+
});
|
|
3037
|
+
return /* @__PURE__ */ jsx(Fragment, { children: moreInfo ? arrayOrArray(moreInfo).map((dataCell) => {
|
|
3038
|
+
return /* @__PURE__ */ jsx(
|
|
3039
|
+
Box,
|
|
3040
|
+
{
|
|
3041
|
+
ref,
|
|
3042
|
+
className: `responsiveTable__additionalInfoItem ${dataCell.newline ? "separator" : ""}`,
|
|
3043
|
+
children: dataCell.newline ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3044
|
+
/* @__PURE__ */ jsxs(Box, { sx: { height: "20px" }, as: "strong", children: [
|
|
3045
|
+
dataCell.name,
|
|
3046
|
+
":"
|
|
3047
|
+
] }),
|
|
3048
|
+
" ",
|
|
3049
|
+
dataCell.label
|
|
3050
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3051
|
+
/* @__PURE__ */ jsxs(Box, { as: "strong", children: [
|
|
3052
|
+
dataCell.name,
|
|
3053
|
+
":"
|
|
3054
|
+
] }),
|
|
3055
|
+
" ",
|
|
3056
|
+
dataCell.label
|
|
3057
|
+
] })
|
|
3058
|
+
},
|
|
3059
|
+
`${dataCell.name}-${uniqueId()}`
|
|
3060
|
+
);
|
|
3061
|
+
}) : /* @__PURE__ */ jsx(Spinner, { size: 15 }) });
|
|
3062
|
+
});
|
|
3063
|
+
InnerRender.displayName = "MakeAsyncRenderer";
|
|
3064
|
+
return InnerRender;
|
|
3065
|
+
}
|
|
3066
|
+
|
|
3067
|
+
var __defProp$1 = Object.defineProperty;
|
|
3068
|
+
var __defProps$1 = Object.defineProperties;
|
|
3069
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
3070
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
3071
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
3072
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
3073
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3074
|
+
var __spreadValues$1 = (a, b) => {
|
|
3075
|
+
for (var prop in b || (b = {}))
|
|
3076
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
3077
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
3078
|
+
if (__getOwnPropSymbols$1)
|
|
3079
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
3080
|
+
if (__propIsEnum$1.call(b, prop))
|
|
3081
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
3082
|
+
}
|
|
3083
|
+
return a;
|
|
3084
|
+
};
|
|
3085
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
3086
|
+
var __objRest$1 = (source, exclude) => {
|
|
3087
|
+
var target = {};
|
|
3088
|
+
for (var prop in source)
|
|
3089
|
+
if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
3090
|
+
target[prop] = source[prop];
|
|
3091
|
+
if (source != null && __getOwnPropSymbols$1)
|
|
3092
|
+
for (var prop of __getOwnPropSymbols$1(source)) {
|
|
3093
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
|
|
3094
|
+
target[prop] = source[prop];
|
|
3095
|
+
}
|
|
3096
|
+
return target;
|
|
3097
|
+
};
|
|
3098
|
+
function getPriorityHandler(priority) {
|
|
3099
|
+
let prio;
|
|
3100
|
+
if (priority == null ? void 0 : priority.includes("priority0"))
|
|
3101
|
+
prio = "priorityNone";
|
|
3102
|
+
if (priority == null ? void 0 : priority.includes("priority1"))
|
|
3103
|
+
prio = "priorityLow";
|
|
3104
|
+
if (priority == null ? void 0 : priority.includes("priority2"))
|
|
3105
|
+
prio = "priorityNormal";
|
|
3106
|
+
if (priority == null ? void 0 : priority.includes("priority3"))
|
|
3107
|
+
prio = "priorityHigh";
|
|
3108
|
+
if (priority == null ? void 0 : priority.includes("priority4"))
|
|
3109
|
+
prio = "priorityUrgent";
|
|
3110
|
+
return prio;
|
|
3111
|
+
}
|
|
3112
|
+
const NoMemoPriorityRenderer = React.forwardRef(
|
|
3113
|
+
(_a, currentRef) => {
|
|
3114
|
+
var _b = _a, {
|
|
3115
|
+
cell: _c
|
|
3116
|
+
} = _b, _d = _c, { children, Renderer, rendererProps, AccordionRenderer } = _d, cell = __objRest$1(_d, ["children", "Renderer", "rendererProps", "AccordionRenderer"]), _e = _b, props = __objRest$1(_e, [
|
|
3117
|
+
"cell",
|
|
3118
|
+
"column",
|
|
3119
|
+
"row"
|
|
3120
|
+
]);
|
|
3121
|
+
const taskPriorityColor = getPriorityHandler(rendererProps == null ? void 0 : rendererProps.src);
|
|
3122
|
+
return /* @__PURE__ */ jsx(
|
|
3123
|
+
"td",
|
|
3124
|
+
__spreadProps$1(__spreadValues$1(__spreadValues$1({}, props), cell), {
|
|
3125
|
+
ref: currentRef,
|
|
3126
|
+
className: "priority",
|
|
3127
|
+
sx: {
|
|
3128
|
+
color: taskPriorityColor
|
|
3129
|
+
},
|
|
3130
|
+
children: /* @__PURE__ */ jsx(FaSquare, {})
|
|
3131
|
+
})
|
|
3132
|
+
);
|
|
3133
|
+
}
|
|
3134
|
+
);
|
|
3135
|
+
NoMemoPriorityRenderer.displayName = "PriorityRenderer";
|
|
3136
|
+
const PriorityRenderer = NoMemoPriorityRenderer;
|
|
3137
|
+
|
|
3138
|
+
const NoMemoPriorityAccordionRenderer = React.forwardRef(
|
|
3139
|
+
({ cell, column }, currentRef) => {
|
|
3140
|
+
var _a, _b, _c;
|
|
3141
|
+
const taskPriorityColor = getPriorityHandler(
|
|
3142
|
+
(_a = cell.rendererProps) == null ? void 0 : _a.src
|
|
3143
|
+
);
|
|
3144
|
+
const title = (_b = column.label) != null ? _b : column.name;
|
|
3145
|
+
return /* @__PURE__ */ jsxs(Box, { ref: currentRef, className: "priority_container", children: [
|
|
3146
|
+
title && /* @__PURE__ */ jsxs(Box, { as: "strong", children: [
|
|
3147
|
+
(_c = column.label) != null ? _c : column.name,
|
|
3148
|
+
": "
|
|
3149
|
+
] }),
|
|
3150
|
+
/* @__PURE__ */ jsx(
|
|
3151
|
+
Box,
|
|
3152
|
+
{
|
|
3153
|
+
as: "span",
|
|
3154
|
+
className: "priority",
|
|
3155
|
+
sx: {
|
|
3156
|
+
color: taskPriorityColor
|
|
3157
|
+
},
|
|
3158
|
+
children: /* @__PURE__ */ jsx(FaSquare, {})
|
|
3159
|
+
}
|
|
3160
|
+
)
|
|
3161
|
+
] });
|
|
3162
|
+
}
|
|
3163
|
+
);
|
|
3164
|
+
NoMemoPriorityAccordionRenderer.displayName = "PriorityAccordionRenderer";
|
|
3165
|
+
const PriorityAccordionRenderer = NoMemoPriorityAccordionRenderer;
|
|
3166
|
+
|
|
3167
|
+
var __defProp = Object.defineProperty;
|
|
3168
|
+
var __defProps = Object.defineProperties;
|
|
3169
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
3170
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3171
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3172
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
3173
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3174
|
+
var __spreadValues = (a, b) => {
|
|
3175
|
+
for (var prop in b || (b = {}))
|
|
3176
|
+
if (__hasOwnProp.call(b, prop))
|
|
3177
|
+
__defNormalProp(a, prop, b[prop]);
|
|
3178
|
+
if (__getOwnPropSymbols)
|
|
3179
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
3180
|
+
if (__propIsEnum.call(b, prop))
|
|
3181
|
+
__defNormalProp(a, prop, b[prop]);
|
|
3182
|
+
}
|
|
3183
|
+
return a;
|
|
3184
|
+
};
|
|
3185
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
3186
|
+
var __objRest = (source, exclude) => {
|
|
3187
|
+
var target = {};
|
|
3188
|
+
for (var prop in source)
|
|
3189
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
3190
|
+
target[prop] = source[prop];
|
|
3191
|
+
if (source != null && __getOwnPropSymbols)
|
|
3192
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
3193
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
3194
|
+
target[prop] = source[prop];
|
|
3195
|
+
}
|
|
3196
|
+
return target;
|
|
3197
|
+
};
|
|
3198
|
+
function getStatusRendererClassName(cellValue, columnName) {
|
|
3199
|
+
var _a;
|
|
3200
|
+
if (cellValue === void 0)
|
|
3201
|
+
return "";
|
|
3202
|
+
const cellValueDate = cellValue.split(" ")[0];
|
|
3203
|
+
const cellValueHour = (_a = cellValue.split(" ")[1]) != null ? _a : "00:00:00";
|
|
3204
|
+
const dateFormat = getDateFormat();
|
|
3205
|
+
const currentDate = dayjs();
|
|
3206
|
+
const currentHour = Number(dayjs().format("HHmm"));
|
|
3207
|
+
const queriedDate = dayjs(cellValueDate, dateFormat);
|
|
3208
|
+
const queriedHour = Number(dayjs(cellValueHour, dateFormat));
|
|
3209
|
+
let statusClassName = "";
|
|
3210
|
+
if (currentDate >= queriedDate) {
|
|
3211
|
+
statusClassName = columnName;
|
|
3212
|
+
}
|
|
3213
|
+
if (!queriedHour)
|
|
3214
|
+
return statusClassName;
|
|
3215
|
+
if (currentDate <= queriedDate && currentHour < queriedHour) {
|
|
3216
|
+
statusClassName = columnName;
|
|
3217
|
+
}
|
|
3218
|
+
return statusClassName;
|
|
3219
|
+
}
|
|
3220
|
+
const NoMemoStatusRenderer = React.forwardRef(
|
|
3221
|
+
(_a, currentRef) => {
|
|
3222
|
+
var _b = _a, {
|
|
3223
|
+
cell: _c
|
|
3224
|
+
} = _b, _d = _c, { children, Renderer, rendererProps, AccordionRenderer } = _d, cell = __objRest(_d, ["children", "Renderer", "rendererProps", "AccordionRenderer"]), _e = _b, {
|
|
3225
|
+
column,
|
|
3226
|
+
row
|
|
3227
|
+
} = _e, props = __objRest(_e, [
|
|
3228
|
+
"cell",
|
|
3229
|
+
"column",
|
|
3230
|
+
"row"
|
|
3231
|
+
]);
|
|
3232
|
+
const taskStatusClassName = getStatusRendererClassName(
|
|
3233
|
+
children,
|
|
3234
|
+
column.name
|
|
3235
|
+
);
|
|
3236
|
+
return /* @__PURE__ */ jsx(
|
|
3237
|
+
"td",
|
|
3238
|
+
__spreadProps(__spreadValues(__spreadValues({}, props), cell), {
|
|
3239
|
+
ref: currentRef,
|
|
3240
|
+
className: taskStatusClassName,
|
|
3241
|
+
children
|
|
3242
|
+
})
|
|
3243
|
+
);
|
|
3244
|
+
}
|
|
3245
|
+
);
|
|
3246
|
+
NoMemoStatusRenderer.displayName = "StatusRenderer";
|
|
3247
|
+
const StatusRenderer = NoMemoStatusRenderer;
|
|
3248
|
+
|
|
3249
|
+
const NoMemoStatusAccordionRenderer = React.forwardRef(({ cell, column }, currentRef) => {
|
|
3250
|
+
var _a;
|
|
3251
|
+
const taskStatusClassName = getStatusRendererClassName(
|
|
3252
|
+
cell.children,
|
|
3253
|
+
column.name
|
|
3254
|
+
);
|
|
3255
|
+
return /* @__PURE__ */ jsxs(Box, { ref: currentRef, children: [
|
|
3256
|
+
/* @__PURE__ */ jsxs(Box, { as: "strong", children: [
|
|
3257
|
+
(_a = column.label) != null ? _a : column.name,
|
|
3258
|
+
": "
|
|
3259
|
+
] }),
|
|
3260
|
+
/* @__PURE__ */ jsx(Box, { as: "span", className: taskStatusClassName, children: cell.children })
|
|
3261
|
+
] });
|
|
3262
|
+
});
|
|
3263
|
+
NoMemoStatusAccordionRenderer.displayName = "StatusAccordionRenderer";
|
|
3264
|
+
const StatusAccordionRenderer = NoMemoStatusAccordionRenderer;
|
|
3265
|
+
|
|
3266
|
+
export { AccordionCell, AccordionDocNameCellRenderer, AccordionElement, AccordionHTMLCellRenderer, AccordionRenderer, AdditionalColumnDefaultRenderer, DefaultCellRenderer, DefaultRowRenderer, DocNameCellRenderer, HTMLCellRenderer, IsLoadingRenderer, NoRegistersRenderer, PriorityAccordionRenderer, PriorityRenderer, ResponsiveTable, ResponsiveTableContext, RowStatesRenderer, StatusAccordionRenderer, StatusRenderer, TableRenderer, defaultLabels, getPriorityHandler, getStatusRendererClassName, makeAccordionAsyncRenderer, makeAsyncRenderer, responsiveTableActions, responsiveTableStore, useResponsiveTable };
|
|
3267
|
+
//# sourceMappingURL=index.js.map
|