@monolith-forensics/monolith-ui 1.3.20 → 1.3.22
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.
|
@@ -63,7 +63,7 @@ const TableMenu = () => {
|
|
|
63
63
|
});
|
|
64
64
|
};
|
|
65
65
|
const renderCustomMenuItems = (args) => {
|
|
66
|
-
return customMenuItems === null || customMenuItems === void 0 ? void 0 : customMenuItems.filter((item) => (item.
|
|
66
|
+
return customMenuItems === null || customMenuItems === void 0 ? void 0 : customMenuItems.filter((item) => (item.position || "left") === args.position).map((item, index) => {
|
|
67
67
|
if (item.type === "button") {
|
|
68
68
|
return _jsx(Button, Object.assign({ size: "xxs" }, item.options), index);
|
|
69
69
|
}
|
|
@@ -332,45 +332,99 @@ const TableProvider = (_a) => {
|
|
|
332
332
|
var _a;
|
|
333
333
|
return (((_a = columnState.find((col) => col.dataField === dataField)) === null || _a === void 0 ? void 0 : _a.visible) || true);
|
|
334
334
|
};
|
|
335
|
+
const saveSelectionState = (selectionState) => {
|
|
336
|
+
if (stateStorage === null || stateStorage === void 0 ? void 0 : stateStorage.enabled) {
|
|
337
|
+
if ((stateStorage === null || stateStorage === void 0 ? void 0 : stateStorage.type) === "localStorage") {
|
|
338
|
+
StateStorage.setSelectionState(stateStorage.key, selectionState);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
};
|
|
335
342
|
const selectRow = (row) => {
|
|
343
|
+
var _a;
|
|
336
344
|
const key = !!props.keyField ? row[props.keyField] : row.__key;
|
|
337
345
|
const keyField = !!props.keyField ? props.keyField : "__key";
|
|
346
|
+
const newSelectionState = {
|
|
347
|
+
selectedRowKeys,
|
|
348
|
+
excludedRowKeys,
|
|
349
|
+
selectionStatus,
|
|
350
|
+
};
|
|
338
351
|
if (props.data.length === selectedRowKeys.length + 1) {
|
|
339
|
-
|
|
352
|
+
newSelectionState.selectionStatus = SelectionStatus.All;
|
|
340
353
|
}
|
|
341
354
|
else {
|
|
342
|
-
|
|
355
|
+
newSelectionState.selectionStatus = SelectionStatus.SomeIncluded;
|
|
343
356
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
357
|
+
newSelectionState.selectedRowKeys = [
|
|
358
|
+
...newSelectionState.selectedRowKeys,
|
|
359
|
+
key,
|
|
360
|
+
];
|
|
361
|
+
newSelectionState.excludedRowKeys =
|
|
362
|
+
newSelectionState.excludedRowKeys.filter((k) => k !== key);
|
|
363
|
+
setSelectionStatus(newSelectionState.selectionStatus);
|
|
364
|
+
setSelectedRowKeys(newSelectionState.selectedRowKeys);
|
|
365
|
+
setExcludedRowKeys(newSelectionState.excludedRowKeys);
|
|
366
|
+
(_a = props.onSelectionChange) === null || _a === void 0 ? void 0 : _a.call(props, newSelectionState);
|
|
367
|
+
saveSelectionState(newSelectionState);
|
|
348
368
|
};
|
|
349
369
|
const deselectRow = (row) => {
|
|
370
|
+
var _a;
|
|
350
371
|
const key = !!props.keyField ? props.keyField : "__key";
|
|
372
|
+
const newSelectionState = {
|
|
373
|
+
selectedRowKeys,
|
|
374
|
+
excludedRowKeys,
|
|
375
|
+
selectionStatus,
|
|
376
|
+
};
|
|
351
377
|
if (selectionStatus === SelectionStatus.All ||
|
|
352
378
|
selectionStatus === SelectionStatus.SomeExcluded) {
|
|
353
|
-
|
|
354
|
-
|
|
379
|
+
newSelectionState.selectionStatus = SelectionStatus.SomeExcluded;
|
|
380
|
+
newSelectionState.excludedRowKeys = [
|
|
381
|
+
...newSelectionState.excludedRowKeys,
|
|
382
|
+
row[key],
|
|
383
|
+
];
|
|
355
384
|
}
|
|
356
385
|
if (selectedRowKeys.length === 1) {
|
|
357
|
-
|
|
386
|
+
newSelectionState.selectionStatus = SelectionStatus.None;
|
|
358
387
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
388
|
+
newSelectionState.selectedRowKeys =
|
|
389
|
+
newSelectionState.selectedRowKeys.filter((k) => k !== row[key]);
|
|
390
|
+
setSelectionStatus(newSelectionState.selectionStatus);
|
|
391
|
+
setSelectedRowKeys(newSelectionState.selectedRowKeys);
|
|
392
|
+
setExcludedRowKeys(newSelectionState.excludedRowKeys);
|
|
393
|
+
(_a = props.onSelectionChange) === null || _a === void 0 ? void 0 : _a.call(props, newSelectionState);
|
|
394
|
+
saveSelectionState(newSelectionState);
|
|
362
395
|
};
|
|
363
396
|
const selectAllRows = () => {
|
|
364
|
-
var _a;
|
|
397
|
+
var _a, _b;
|
|
365
398
|
const keys = ((_a = props.data) === null || _a === void 0 ? void 0 : _a.map((row) => !!props.keyField ? row[props.keyField] : row.__key)) || [];
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
399
|
+
const newSelectionState = {
|
|
400
|
+
selectedRowKeys,
|
|
401
|
+
excludedRowKeys,
|
|
402
|
+
selectionStatus,
|
|
403
|
+
};
|
|
404
|
+
newSelectionState.selectedRowKeys = keys;
|
|
405
|
+
newSelectionState.excludedRowKeys = [];
|
|
406
|
+
newSelectionState.selectionStatus = SelectionStatus.All;
|
|
407
|
+
setSelectionStatus(newSelectionState.selectionStatus);
|
|
408
|
+
setSelectedRowKeys(newSelectionState.selectedRowKeys);
|
|
409
|
+
setExcludedRowKeys(newSelectionState.excludedRowKeys);
|
|
410
|
+
(_b = props.onSelectionChange) === null || _b === void 0 ? void 0 : _b.call(props, newSelectionState);
|
|
411
|
+
saveSelectionState(newSelectionState);
|
|
369
412
|
};
|
|
370
413
|
const clearSelections = () => {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
414
|
+
var _a;
|
|
415
|
+
const newSelectionState = {
|
|
416
|
+
selectedRowKeys,
|
|
417
|
+
excludedRowKeys,
|
|
418
|
+
selectionStatus,
|
|
419
|
+
};
|
|
420
|
+
newSelectionState.selectedRowKeys = [];
|
|
421
|
+
newSelectionState.excludedRowKeys = [];
|
|
422
|
+
newSelectionState.selectionStatus = SelectionStatus.None;
|
|
423
|
+
setSelectionStatus(newSelectionState.selectionStatus);
|
|
424
|
+
setSelectedRowKeys(newSelectionState.selectedRowKeys);
|
|
425
|
+
setExcludedRowKeys(newSelectionState.excludedRowKeys);
|
|
426
|
+
(_a = props.onSelectionChange) === null || _a === void 0 ? void 0 : _a.call(props, newSelectionState);
|
|
427
|
+
saveSelectionState(newSelectionState);
|
|
374
428
|
};
|
|
375
429
|
const getSelectedRows = () => {
|
|
376
430
|
return props.data.filter((row) => {
|
|
@@ -436,31 +490,6 @@ const TableProvider = (_a) => {
|
|
|
436
490
|
};
|
|
437
491
|
}
|
|
438
492
|
}, [columnState]);
|
|
439
|
-
useEffect(() => {
|
|
440
|
-
var _a;
|
|
441
|
-
(_a = props === null || props === void 0 ? void 0 : props.onSelectionChange) === null || _a === void 0 ? void 0 : _a.call(props, {
|
|
442
|
-
selectedRowKeys,
|
|
443
|
-
excludedRowKeys,
|
|
444
|
-
selectionStatus,
|
|
445
|
-
});
|
|
446
|
-
if (stateStorage === null || stateStorage === void 0 ? void 0 : stateStorage.enabled) {
|
|
447
|
-
if ((stateStorage === null || stateStorage === void 0 ? void 0 : stateStorage.type) === "localStorage") {
|
|
448
|
-
StateStorage.setSelectionState(stateStorage.key, {
|
|
449
|
-
selectedRowKeys,
|
|
450
|
-
excludedRowKeys,
|
|
451
|
-
selectionStatus,
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
}, [
|
|
456
|
-
selectedRowKeys,
|
|
457
|
-
selectionStatus,
|
|
458
|
-
excludedRowKeys,
|
|
459
|
-
props === null || props === void 0 ? void 0 : props.onSelectionChange,
|
|
460
|
-
stateStorage === null || stateStorage === void 0 ? void 0 : stateStorage.enabled,
|
|
461
|
-
stateStorage === null || stateStorage === void 0 ? void 0 : stateStorage.type,
|
|
462
|
-
stateStorage === null || stateStorage === void 0 ? void 0 : stateStorage.key,
|
|
463
|
-
]);
|
|
464
493
|
useEffect(() => {
|
|
465
494
|
var _a, _b;
|
|
466
495
|
if (stateStorage === null || stateStorage === void 0 ? void 0 : stateStorage.enabled) {
|
package/dist/Table/types.d.ts
CHANGED
|
@@ -213,15 +213,15 @@ export type TableFilterOptions = {
|
|
|
213
213
|
};
|
|
214
214
|
export type CustomTableMenuItem = {
|
|
215
215
|
type: "button";
|
|
216
|
-
|
|
216
|
+
position?: "left" | "right";
|
|
217
217
|
options: ButtonProps;
|
|
218
218
|
} | {
|
|
219
219
|
type: "menu";
|
|
220
|
-
|
|
220
|
+
position?: "left" | "right";
|
|
221
221
|
options: DropDownMenuProps;
|
|
222
222
|
} | {
|
|
223
223
|
type: "switch";
|
|
224
|
-
|
|
224
|
+
position?: "left" | "right";
|
|
225
225
|
options: SwitchProps;
|
|
226
226
|
};
|
|
227
227
|
export type TableMenuOptions = {
|