@apia/table 3.0.9 → 3.0.11
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/dist/index.d.ts +21 -8
- package/dist/index.js +259 -112
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from '@apia/theme/jsx-runtime';
|
|
2
|
-
import React, { useMemo,
|
|
3
|
-
import { Box, getVariant, Input, useBreakpointIndex, Label,
|
|
2
|
+
import React, { useMemo, useRef, useState, memo, useEffect, useCallback, createRef, forwardRef } from 'react';
|
|
3
|
+
import { Box, getVariant, Input, Select, useBreakpointIndex, Label, Link, Spinner } from '@apia/theme';
|
|
4
4
|
import { useMount, useUpdateEffect, useUnmount, useThrottleFn } from 'ahooks';
|
|
5
5
|
import uniqueId from 'lodash-es/uniqueId';
|
|
6
6
|
import { createSlice, injectReducers, shallowEqual as shallowEqual$1 } from '@apia/store';
|
|
7
|
-
import { addBoundary, useLatest, useUpdateEffect as useUpdateEffect$1, getSpecificParent, isChild, autoDisconnectMutationObserver, getFocusSelector, cantFocusSelector, globalFocus, scrollParentIntoElement, customEvents, debugDispatcher, persistentStorage, EventEmitter, getLabel, getDateFormat, formatMessage, noNaN, downloadUrl, arrayOrArray, useMount as useMount$1 } from '@apia/util';
|
|
7
|
+
import { addBoundary, useLatest, useUpdateEffect as useUpdateEffect$1, getSpecificParent, isChild, autoDisconnectMutationObserver, getFocusSelector, cantFocusSelector, globalFocus, scrollParentIntoElement, customEvents, debugDispatcher, persistentStorage, EventEmitter, usePrevious, useIntermediateValue, getLabel, getDateFormat, formatMessage, noNaN, getIndex, downloadUrl, arrayOrArray, useMount as useMount$1 } from '@apia/util';
|
|
8
8
|
import { shallowEqual } from 'react-redux';
|
|
9
9
|
import { useOtherTagButton, AutoEllipsis, ApiaFilter, IconButton, AccordionItem, Accordion, RequiredMark, ApiaUtil, SimpleButton } from '@apia/components';
|
|
10
10
|
import { Icon } from '@apia/icons';
|
|
@@ -458,6 +458,7 @@ function useResponsiveTableContext(tableName) {
|
|
|
458
458
|
const NoMemoResponsiveTableContext = ({
|
|
459
459
|
allowEdition,
|
|
460
460
|
allowRowsKeyboardSorting,
|
|
461
|
+
avoidAutoEllipsis,
|
|
461
462
|
allowSelection,
|
|
462
463
|
allowSorting,
|
|
463
464
|
avoidReparseSelectionOnRowChange,
|
|
@@ -467,6 +468,7 @@ const NoMemoResponsiveTableContext = ({
|
|
|
467
468
|
customLabels,
|
|
468
469
|
columns,
|
|
469
470
|
filters,
|
|
471
|
+
FiltersRenderer,
|
|
470
472
|
rows,
|
|
471
473
|
label,
|
|
472
474
|
isMultiple,
|
|
@@ -475,6 +477,7 @@ const NoMemoResponsiveTableContext = ({
|
|
|
475
477
|
onFilterBlur,
|
|
476
478
|
onFilterChange,
|
|
477
479
|
onFilterPressEnter,
|
|
480
|
+
onRowClick,
|
|
478
481
|
onSelectRows,
|
|
479
482
|
onSortChange,
|
|
480
483
|
reserveColumnsForStates,
|
|
@@ -494,24 +497,30 @@ const NoMemoResponsiveTableContext = ({
|
|
|
494
497
|
currentBreakPoint,
|
|
495
498
|
label,
|
|
496
499
|
labels,
|
|
500
|
+
avoidAutoEllipsis,
|
|
501
|
+
FiltersRenderer,
|
|
497
502
|
name: actualName,
|
|
498
503
|
onChangeSelection,
|
|
499
504
|
onFilterBlur,
|
|
500
505
|
onFilterChange,
|
|
501
506
|
onFilterPressEnter,
|
|
507
|
+
onRowClick,
|
|
502
508
|
onSelectRows,
|
|
503
509
|
onSortChange,
|
|
504
510
|
SelectionHandler
|
|
505
511
|
}),
|
|
506
512
|
[
|
|
507
|
-
actualName,
|
|
508
513
|
currentBreakPoint,
|
|
509
514
|
label,
|
|
510
515
|
labels,
|
|
516
|
+
avoidAutoEllipsis,
|
|
517
|
+
actualName,
|
|
518
|
+
FiltersRenderer,
|
|
511
519
|
onChangeSelection,
|
|
512
520
|
onFilterBlur,
|
|
513
521
|
onFilterChange,
|
|
514
522
|
onFilterPressEnter,
|
|
523
|
+
onRowClick,
|
|
515
524
|
onSelectRows,
|
|
516
525
|
onSortChange,
|
|
517
526
|
SelectionHandler
|
|
@@ -593,6 +602,7 @@ function makeKeyHandler(actions, id, config) {
|
|
|
593
602
|
return function KeyHandler({
|
|
594
603
|
children,
|
|
595
604
|
onChangeSelection,
|
|
605
|
+
onRowClick: onClickRows,
|
|
596
606
|
onSelectRows,
|
|
597
607
|
...props
|
|
598
608
|
}) {
|
|
@@ -673,9 +683,14 @@ function makeKeyHandler(actions, id, config) {
|
|
|
673
683
|
shiftKey: ev.shiftKey
|
|
674
684
|
})
|
|
675
685
|
);
|
|
686
|
+
if (onClickRows && ev.type === "mousedown")
|
|
687
|
+
onClickRows(
|
|
688
|
+
selectedRowsRef.current?.[0],
|
|
689
|
+
config.stateSelector(responsiveTableStore.getState()).focusedRow
|
|
690
|
+
);
|
|
676
691
|
}
|
|
677
692
|
},
|
|
678
|
-
[]
|
|
693
|
+
[onClickRows, selectedRowsRef]
|
|
679
694
|
);
|
|
680
695
|
const handleDoubleClick = React.useCallback(
|
|
681
696
|
(ev) => {
|
|
@@ -905,7 +920,13 @@ function makeKeyHandler(actions, id, config) {
|
|
|
905
920
|
}
|
|
906
921
|
|
|
907
922
|
const NoMemoKeyHandler = (props) => {
|
|
908
|
-
const {
|
|
923
|
+
const {
|
|
924
|
+
name,
|
|
925
|
+
onChangeSelection,
|
|
926
|
+
onRowClick,
|
|
927
|
+
onSelectRows,
|
|
928
|
+
SelectionHandler
|
|
929
|
+
} = useResponsiveTableContext();
|
|
909
930
|
const Handler = React.useMemo(
|
|
910
931
|
() => SelectionHandler || makeKeyHandler(responsiveTableActions, name, {
|
|
911
932
|
throttleOptions: { wait: 50 },
|
|
@@ -918,6 +939,7 @@ const NoMemoKeyHandler = (props) => {
|
|
|
918
939
|
{
|
|
919
940
|
onChangeSelection,
|
|
920
941
|
onSelectRows,
|
|
942
|
+
onRowClick,
|
|
921
943
|
...props
|
|
922
944
|
}
|
|
923
945
|
);
|
|
@@ -1370,64 +1392,138 @@ const StateCell = ({ index, rowIndex, state, isHeader }) => {
|
|
|
1370
1392
|
return /* @__PURE__ */ jsx(Box, { as: "td", className: "stateCell", ...domProps, children: state ? /* @__PURE__ */ jsx(RowStatesRenderer, { state }) : "" });
|
|
1371
1393
|
};
|
|
1372
1394
|
|
|
1395
|
+
const units = ["B", "KB", "MB", "GB"];
|
|
1373
1396
|
const NoMemoRangeFilter = ({
|
|
1374
1397
|
filter,
|
|
1375
|
-
tableName
|
|
1398
|
+
tableName,
|
|
1399
|
+
className
|
|
1376
1400
|
}) => {
|
|
1377
1401
|
const { onFilterBlur, onFilterChange, onFilterPressEnter } = useResponsiveTableContext(tableName);
|
|
1378
1402
|
const filterLow = {
|
|
1379
|
-
|
|
1403
|
+
...filter,
|
|
1404
|
+
changeFiltersTimestamp: filter.changeFiltersTimestamp,
|
|
1380
1405
|
currentValue: filter.currentValue,
|
|
1381
|
-
|
|
1406
|
+
deleteFiltersTimestamp: filter.deleteFiltersTimestamp,
|
|
1407
|
+
id: filter.id,
|
|
1408
|
+
toolTip: filter.toolTip,
|
|
1409
|
+
type: "apiaNumber"
|
|
1382
1410
|
};
|
|
1383
|
-
const
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1411
|
+
const multiplier = useRef(1);
|
|
1412
|
+
const lastEmittedHigh = useRef(null);
|
|
1413
|
+
const lastEmittedLow = useRef(null);
|
|
1414
|
+
const lastEmittedMultiplier = useRef(1);
|
|
1415
|
+
const previousChangeTimestamp = usePrevious(filter.changeFiltersTimestamp);
|
|
1416
|
+
const previousDeleteTimestamp = usePrevious(filter.deleteFiltersTimestamp);
|
|
1417
|
+
if (previousChangeTimestamp.current !== filter.changeFiltersTimestamp) {
|
|
1418
|
+
lastEmittedLow.current = filterLow.currentValue;
|
|
1419
|
+
lastEmittedHigh.current = filterLow.filterToValue || "";
|
|
1420
|
+
}
|
|
1421
|
+
if (previousDeleteTimestamp.current !== filter.deleteFiltersTimestamp) {
|
|
1422
|
+
lastEmittedLow.current = "";
|
|
1423
|
+
lastEmittedHigh.current = "";
|
|
1424
|
+
}
|
|
1425
|
+
const emitLow = (method, currentValue) => {
|
|
1426
|
+
const numberValue = currentValue ?? "";
|
|
1427
|
+
if (lastEmittedLow.current === numberValue && lastEmittedMultiplier.current === multiplier.current) {
|
|
1428
|
+
return;
|
|
1429
|
+
}
|
|
1430
|
+
lastEmittedLow.current = numberValue;
|
|
1431
|
+
lastEmittedMultiplier.current = multiplier.current;
|
|
1432
|
+
const emitValue = numberValue;
|
|
1433
|
+
void method?.({
|
|
1434
|
+
...filterLow,
|
|
1435
|
+
currentValue: emitValue,
|
|
1436
|
+
filterToValue: lastEmittedHigh.current ?? "",
|
|
1437
|
+
sizeMultiplier: multiplier.current
|
|
1438
|
+
});
|
|
1387
1439
|
};
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1440
|
+
const emitHigh = (method, currentValue) => {
|
|
1441
|
+
const numberValue = currentValue ?? "";
|
|
1442
|
+
if (lastEmittedHigh.current === numberValue && lastEmittedMultiplier.current === multiplier.current) {
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
lastEmittedHigh.current = numberValue;
|
|
1446
|
+
lastEmittedMultiplier.current = multiplier.current;
|
|
1447
|
+
const emitValue = numberValue;
|
|
1448
|
+
void method?.({
|
|
1449
|
+
...filterLow,
|
|
1450
|
+
currentValue: lastEmittedLow.current ?? "",
|
|
1451
|
+
filterToValue: emitValue,
|
|
1452
|
+
sizeMultiplier: multiplier.current
|
|
1453
|
+
});
|
|
1454
|
+
};
|
|
1455
|
+
const [lowValue, setLowValue] = useIntermediateValue(filterLow.currentValue);
|
|
1456
|
+
const [highValue, setHighValue] = useIntermediateValue(
|
|
1457
|
+
filterLow.filterToValue
|
|
1458
|
+
);
|
|
1459
|
+
const [unit, setUnit] = useIntermediateValue(filterLow.sizeMultiplier);
|
|
1460
|
+
return /* @__PURE__ */ jsxs(
|
|
1461
|
+
Box,
|
|
1462
|
+
{
|
|
1463
|
+
className: `ApiaFilter__Range ${className || ""}`,
|
|
1464
|
+
...getVariant("layout.common.filters.rangeFilter"),
|
|
1465
|
+
children: [
|
|
1466
|
+
/* @__PURE__ */ jsx(Box, { className: "ApiaFilter__Range__Low", children: /* @__PURE__ */ jsx(
|
|
1467
|
+
Input,
|
|
1468
|
+
{
|
|
1469
|
+
onChange: ({ target: { value: currentValue } }) => {
|
|
1470
|
+
setLowValue(currentValue);
|
|
1471
|
+
emitLow(onFilterChange, currentValue);
|
|
1472
|
+
},
|
|
1473
|
+
onBlur: ({ target: { value: currentValue } }) => {
|
|
1474
|
+
emitLow(onFilterBlur, currentValue);
|
|
1475
|
+
},
|
|
1476
|
+
onKeyDown: ({ code, target }) => {
|
|
1477
|
+
if (code === "Enter") {
|
|
1478
|
+
emitLow(onFilterPressEnter, target.value);
|
|
1479
|
+
}
|
|
1480
|
+
},
|
|
1481
|
+
value: lowValue
|
|
1482
|
+
}
|
|
1483
|
+
) }),
|
|
1484
|
+
" - ",
|
|
1485
|
+
/* @__PURE__ */ jsx(Box, { className: "ApiaFilter__Range__High", children: /* @__PURE__ */ jsx(
|
|
1486
|
+
Input,
|
|
1487
|
+
{
|
|
1488
|
+
onChange: ({ target: { value: currentValue } }) => {
|
|
1489
|
+
setHighValue(currentValue);
|
|
1490
|
+
emitHigh(onFilterChange, currentValue);
|
|
1491
|
+
},
|
|
1492
|
+
onBlur: ({ target: { value: currentValue } }) => {
|
|
1493
|
+
emitHigh(onFilterBlur, currentValue);
|
|
1494
|
+
},
|
|
1495
|
+
onKeyDown: ({ code, target }) => {
|
|
1496
|
+
if (code === "Enter") {
|
|
1497
|
+
emitHigh(onFilterPressEnter, target.value);
|
|
1498
|
+
}
|
|
1499
|
+
},
|
|
1500
|
+
value: highValue
|
|
1501
|
+
}
|
|
1502
|
+
) }),
|
|
1503
|
+
filter.isSize && /* @__PURE__ */ jsx(
|
|
1504
|
+
Select,
|
|
1505
|
+
{
|
|
1506
|
+
className: "ApiaFilter__Range__UnitSelector",
|
|
1507
|
+
onChange: (ev) => {
|
|
1508
|
+
const unit2 = ev.target.value;
|
|
1509
|
+
const index = units.indexOf(unit2);
|
|
1510
|
+
if (index !== -1) {
|
|
1511
|
+
multiplier.current = 2 ** (index * 10);
|
|
1512
|
+
setUnit(multiplier.current);
|
|
1513
|
+
emitLow(onFilterChange, lastEmittedLow.current ?? "");
|
|
1514
|
+
}
|
|
1515
|
+
},
|
|
1516
|
+
value: units[Math.log2(unit || 1) / 10],
|
|
1517
|
+
children: units.map((c) => /* @__PURE__ */ jsx("option", { value: c, children: c }, c))
|
|
1518
|
+
}
|
|
1519
|
+
)
|
|
1520
|
+
]
|
|
1521
|
+
}
|
|
1522
|
+
);
|
|
1427
1523
|
};
|
|
1428
1524
|
const RangeFilter = NoMemoRangeFilter;
|
|
1429
1525
|
|
|
1430
|
-
const FilterCell = ({ columnIndex, filter }) => {
|
|
1526
|
+
const FilterCell = ({ columnIndex, filter, Renderer }) => {
|
|
1431
1527
|
const { name, onFilterBlur, onFilterChange, onFilterPressEnter } = useResponsiveTableContext();
|
|
1432
1528
|
const domProps = useDomProps(
|
|
1433
1529
|
"filterTd",
|
|
@@ -1481,11 +1577,11 @@ const FilterCell = ({ columnIndex, filter }) => {
|
|
|
1481
1577
|
}
|
|
1482
1578
|
return /* @__PURE__ */ jsx(Input, { "aria-label": label, disabled: true });
|
|
1483
1579
|
}
|
|
1484
|
-
return /* @__PURE__ */ jsx("td", { ...domProps, children: findFilter() });
|
|
1580
|
+
return /* @__PURE__ */ jsx("td", { ...domProps, children: Renderer ? /* @__PURE__ */ jsx(Renderer, { filter }) : findFilter() });
|
|
1485
1581
|
};
|
|
1486
1582
|
|
|
1487
1583
|
const NoMemoHeader = () => {
|
|
1488
|
-
const { name } = useResponsiveTableContext();
|
|
1584
|
+
const { name, FiltersRenderer } = useResponsiveTableContext();
|
|
1489
1585
|
const columns = useResponsiveTable(
|
|
1490
1586
|
(global) => global.responsiveTableSlice[name]?.columns
|
|
1491
1587
|
);
|
|
@@ -1604,6 +1700,8 @@ const NoMemoHeader = () => {
|
|
|
1604
1700
|
(filters?.length ?? 0) > 0 && /* @__PURE__ */ jsxs(
|
|
1605
1701
|
"tr",
|
|
1606
1702
|
{
|
|
1703
|
+
"aria-rowindex": 2,
|
|
1704
|
+
"data-rowindex": -1,
|
|
1607
1705
|
ref: setRef,
|
|
1608
1706
|
"data-focusindex": 2,
|
|
1609
1707
|
className: `responsiveTable__filters__row ${isFiltersRowVisible ? "" : "hidden"}`,
|
|
@@ -1620,15 +1718,17 @@ const NoMemoHeader = () => {
|
|
|
1620
1718
|
}
|
|
1621
1719
|
),
|
|
1622
1720
|
statesIds.map((id, i) => /* @__PURE__ */ jsx(StateCell, { isHeader: true, index: i, rowIndex: 2 }, id)),
|
|
1623
|
-
columns?.filter((current) => !current.showAsAdditional).map((current, columnIndex) => {
|
|
1721
|
+
columns?.filter((current) => !current.showAsAdditional && !current.hidden).map((current, columnIndex) => {
|
|
1624
1722
|
const filter = filters.find(
|
|
1625
1723
|
(search) => search.definition.column === current.name
|
|
1626
1724
|
);
|
|
1725
|
+
const RenderComponent = filter ? FiltersRenderer?.(String(filter.definition.id)) : void 0;
|
|
1627
1726
|
return current.showAsAdditional ? null : /* @__PURE__ */ jsx(
|
|
1628
1727
|
FilterCell,
|
|
1629
1728
|
{
|
|
1630
1729
|
columnIndex,
|
|
1631
|
-
filter: filter?.definition
|
|
1730
|
+
filter: filter?.definition,
|
|
1731
|
+
Renderer: RenderComponent
|
|
1632
1732
|
},
|
|
1633
1733
|
current.name
|
|
1634
1734
|
);
|
|
@@ -1704,38 +1804,41 @@ const NoMemoDefaultCellRenderer = React.forwardRef(
|
|
|
1704
1804
|
column,
|
|
1705
1805
|
row,
|
|
1706
1806
|
...props
|
|
1707
|
-
}, currentRef) =>
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1807
|
+
}, currentRef) => {
|
|
1808
|
+
const { avoidAutoEllipsis } = useResponsiveTableContext();
|
|
1809
|
+
return /* @__PURE__ */ jsx(
|
|
1810
|
+
Box,
|
|
1811
|
+
{
|
|
1812
|
+
as: "td",
|
|
1813
|
+
sx: useMemo(
|
|
1814
|
+
() => ({
|
|
1815
|
+
"&.colored": {
|
|
1816
|
+
background: cell.background,
|
|
1817
|
+
color: cell.color,
|
|
1818
|
+
fontWeight: "bold"
|
|
1819
|
+
}
|
|
1820
|
+
}),
|
|
1821
|
+
[cell.background, cell.color]
|
|
1822
|
+
),
|
|
1823
|
+
ref: currentRef,
|
|
1824
|
+
...props,
|
|
1825
|
+
...cell,
|
|
1826
|
+
"aria-label": ariaLabel,
|
|
1827
|
+
children: !avoidAutoEllipsis ? /* @__PURE__ */ jsx(
|
|
1828
|
+
AutoEllipsis,
|
|
1829
|
+
{
|
|
1830
|
+
overrideStyles: (el) => {
|
|
1831
|
+
const td = el.closest("td");
|
|
1832
|
+
return {
|
|
1833
|
+
width: window.getComputedStyle(td).width
|
|
1834
|
+
};
|
|
1835
|
+
},
|
|
1836
|
+
children: props.children ?? cell.children
|
|
1717
1837
|
}
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
...props,
|
|
1723
|
-
...cell,
|
|
1724
|
-
"aria-label": ariaLabel,
|
|
1725
|
-
children: /* @__PURE__ */ jsx(
|
|
1726
|
-
AutoEllipsis,
|
|
1727
|
-
{
|
|
1728
|
-
overrideStyles: (el) => {
|
|
1729
|
-
const td = el.closest("td");
|
|
1730
|
-
return {
|
|
1731
|
-
width: window.getComputedStyle(td).width
|
|
1732
|
-
};
|
|
1733
|
-
},
|
|
1734
|
-
children: props.children ?? cell.children
|
|
1735
|
-
}
|
|
1736
|
-
)
|
|
1737
|
-
}
|
|
1738
|
-
)
|
|
1838
|
+
) : props.children ?? cell.children
|
|
1839
|
+
}
|
|
1840
|
+
);
|
|
1841
|
+
}
|
|
1739
1842
|
);
|
|
1740
1843
|
NoMemoDefaultCellRenderer.displayName = "DefaultCellRenderer";
|
|
1741
1844
|
const DefaultCellRenderer = NoMemoDefaultCellRenderer;
|
|
@@ -2309,12 +2412,19 @@ const NoMemoInnerRender = React.forwardRef(
|
|
|
2309
2412
|
filters,
|
|
2310
2413
|
tableName
|
|
2311
2414
|
}, ref) => {
|
|
2312
|
-
const {
|
|
2415
|
+
const {
|
|
2416
|
+
onFilterBlur,
|
|
2417
|
+
onFilterChange,
|
|
2418
|
+
onFilterPressEnter,
|
|
2419
|
+
name,
|
|
2420
|
+
FiltersRenderer
|
|
2421
|
+
} = useResponsiveTableContext(tableName);
|
|
2313
2422
|
const [lastEmittedValue, setLastEmittedValue] = React.useState(null);
|
|
2314
2423
|
const [lastEmittedValueByPartner, setLastEmittedValueByPartner] = React.useState(null);
|
|
2315
2424
|
return /* @__PURE__ */ jsx(Box, { ref, className: "filtersRender", children: filters?.map((filter, key) => {
|
|
2316
2425
|
if (filter.hide)
|
|
2317
2426
|
return null;
|
|
2427
|
+
const Renderer = FiltersRenderer?.(String(filter.id));
|
|
2318
2428
|
const isDate = filter.type === "D" || filter.type === "date";
|
|
2319
2429
|
const filterToId = filter.filterToId ?? `${filter.id}i`;
|
|
2320
2430
|
const filterTo = {
|
|
@@ -2340,7 +2450,7 @@ const NoMemoInnerRender = React.forwardRef(
|
|
|
2340
2450
|
/* @__PURE__ */ jsx(Box, { as: "span", children: isDate && !filter.hideToFilter ? formatMessage(window.LBL_DATE_FILTER_FROM_TXT, {
|
|
2341
2451
|
TOK1: filterTitle
|
|
2342
2452
|
}) : filterTitle }),
|
|
2343
|
-
filter.isRange ? /* @__PURE__ */ jsx(RangeFilter, { filter }) : /* @__PURE__ */ jsx(
|
|
2453
|
+
Renderer ? /* @__PURE__ */ jsx(Renderer, { filter }) : filter.isRange ? /* @__PURE__ */ jsx(RangeFilter, { filter }) : /* @__PURE__ */ jsx(
|
|
2344
2454
|
ApiaFilter,
|
|
2345
2455
|
{
|
|
2346
2456
|
filter,
|
|
@@ -2874,7 +2984,6 @@ function applyFocusAttributes(table, _previousState, state, focus = state.isFocu
|
|
|
2874
2984
|
const focusedCell = table.querySelector(
|
|
2875
2985
|
`tr[data-rowindex="${state.focusedRow}"] td[aria-colindex="${state.focusedColumn}"], tr[data-rowindex="${state.focusedRow}"] th[aria-colindex="${state.focusedColumn}"]`
|
|
2876
2986
|
);
|
|
2877
|
-
console.log(focusedCell);
|
|
2878
2987
|
if (focusedCell instanceof HTMLElement) {
|
|
2879
2988
|
const widgets = [];
|
|
2880
2989
|
if (state.isEditionMode) {
|
|
@@ -2888,7 +2997,6 @@ function applyFocusAttributes(table, _previousState, state, focus = state.isFocu
|
|
|
2888
2997
|
}
|
|
2889
2998
|
}
|
|
2890
2999
|
if (widgets.length) {
|
|
2891
|
-
console.log(widgets);
|
|
2892
3000
|
widgets.forEach((widget, i) => {
|
|
2893
3001
|
widget.tabIndex = 0;
|
|
2894
3002
|
if (i === 0)
|
|
@@ -2914,15 +3022,23 @@ function setAriaAttributes(element, attribute, value) {
|
|
|
2914
3022
|
element.setAttribute(attribute, value);
|
|
2915
3023
|
}
|
|
2916
3024
|
function getRowDomProps(rowIndex, state) {
|
|
3025
|
+
const elementType = getIndex(
|
|
3026
|
+
["headerTr", "filtersTr", "tr"],
|
|
3027
|
+
[
|
|
3028
|
+
rowIndex == -2 || !state.hasNonAdditionalFilters && rowIndex == -1,
|
|
3029
|
+
rowIndex == -1,
|
|
3030
|
+
true
|
|
3031
|
+
]
|
|
3032
|
+
);
|
|
2917
3033
|
return getDomProps(
|
|
2918
3034
|
getDomStoreProps(
|
|
2919
|
-
|
|
3035
|
+
elementType,
|
|
2920
3036
|
{
|
|
2921
3037
|
rowIndex
|
|
2922
3038
|
},
|
|
2923
3039
|
() => state
|
|
2924
3040
|
),
|
|
2925
|
-
|
|
3041
|
+
elementType,
|
|
2926
3042
|
{ rowIndex }
|
|
2927
3043
|
);
|
|
2928
3044
|
}
|
|
@@ -2965,7 +3081,7 @@ function handleMouseDownEvent(ev) {
|
|
|
2965
3081
|
const rowIndex = Number.parseInt(row.dataset.rowindex || "a", 10);
|
|
2966
3082
|
const colIndex = Number.parseInt(cell.ariaColIndex || "a", 10);
|
|
2967
3083
|
if (!isNaN(rowIndex) && !isNaN(colIndex)) {
|
|
2968
|
-
if (!ev.ctrlKey && !ev.shiftKey) {
|
|
3084
|
+
if (!ev.ctrlKey && !ev.shiftKey || state.isMultiple === false) {
|
|
2969
3085
|
state.selectedRows = [rowIndex];
|
|
2970
3086
|
} else if (ev.ctrlKey) {
|
|
2971
3087
|
if (state.selectedRows.includes(rowIndex)) {
|
|
@@ -2990,6 +3106,10 @@ function handleMouseDownEvent(ev) {
|
|
|
2990
3106
|
applySelectionAttributes(table, this.getState(), state);
|
|
2991
3107
|
applyFocusAttributes(table, this.getState(), state);
|
|
2992
3108
|
this.setState(state);
|
|
3109
|
+
this.events.onRowClick?.(
|
|
3110
|
+
{ row: state.rows[state.focusedRow], index: state.focusedRow },
|
|
3111
|
+
state.focusedRow
|
|
3112
|
+
);
|
|
2993
3113
|
} else {
|
|
2994
3114
|
console.warn("Cannot parse rowIndex or colIndex");
|
|
2995
3115
|
}
|
|
@@ -3045,7 +3165,7 @@ function handleKeyDownEvent(ev) {
|
|
|
3045
3165
|
state.hasNonAdditionalFilters ? -2 : -1,
|
|
3046
3166
|
state.rows.length - 1
|
|
3047
3167
|
);
|
|
3048
|
-
if (ev.ctrlKey) ; else if (ev.shiftKey) {
|
|
3168
|
+
if (ev.ctrlKey) ; else if (ev.shiftKey && state.isMultiple !== false) {
|
|
3049
3169
|
state.selectedRows = [
|
|
3050
3170
|
...state.selectedRows,
|
|
3051
3171
|
state.focusedRow
|
|
@@ -3060,7 +3180,7 @@ function handleKeyDownEvent(ev) {
|
|
|
3060
3180
|
state.hasNonAdditionalFilters ? -2 : -1,
|
|
3061
3181
|
state.rows.length - 1
|
|
3062
3182
|
);
|
|
3063
|
-
if (ev.ctrlKey) ; else if (ev.shiftKey) {
|
|
3183
|
+
if (ev.ctrlKey) ; else if (ev.shiftKey && state.isMultiple !== false) {
|
|
3064
3184
|
state.selectedRows = [
|
|
3065
3185
|
...state.selectedRows,
|
|
3066
3186
|
state.focusedRow
|
|
@@ -3080,13 +3200,13 @@ function handleKeyDownEvent(ev) {
|
|
|
3080
3200
|
state.focusedColumn = addBoundary(
|
|
3081
3201
|
state.focusedColumn + 1,
|
|
3082
3202
|
0,
|
|
3083
|
-
state.columns.length
|
|
3203
|
+
state.columns.length + (state.hasNonAdditionalFilters ? 1 : 0)
|
|
3084
3204
|
);
|
|
3085
3205
|
break;
|
|
3086
3206
|
case "Home":
|
|
3087
3207
|
if (state.focusedColumn === 0) {
|
|
3088
3208
|
state.focusedRow = state.hasNonAdditionalFilters ? -2 : -1;
|
|
3089
|
-
if (ev.ctrlKey) ; else if (ev.shiftKey) {
|
|
3209
|
+
if (ev.ctrlKey) ; else if (ev.shiftKey && state.isMultiple !== false) {
|
|
3090
3210
|
const max = Math.max(
|
|
3091
3211
|
state.focusedRow,
|
|
3092
3212
|
this.getState().focusedRow
|
|
@@ -3108,7 +3228,7 @@ function handleKeyDownEvent(ev) {
|
|
|
3108
3228
|
case "End":
|
|
3109
3229
|
if (state.focusedColumn === 0) {
|
|
3110
3230
|
state.focusedRow = state.rows.length - 1;
|
|
3111
|
-
if (ev.ctrlKey) ; else if (ev.shiftKey) {
|
|
3231
|
+
if (ev.ctrlKey) ; else if (ev.shiftKey && state.isMultiple !== false) {
|
|
3112
3232
|
const max = Math.max(
|
|
3113
3233
|
state.focusedRow,
|
|
3114
3234
|
this.getState().focusedRow
|
|
@@ -3133,7 +3253,7 @@ function handleKeyDownEvent(ev) {
|
|
|
3133
3253
|
state.hasNonAdditionalFilters ? -2 : -1,
|
|
3134
3254
|
state.rows.length - 1
|
|
3135
3255
|
);
|
|
3136
|
-
if (ev.ctrlKey) ; else if (ev.shiftKey) {
|
|
3256
|
+
if (ev.ctrlKey) ; else if (ev.shiftKey && state.isMultiple !== false) {
|
|
3137
3257
|
const previousFocused = this.getState().focusedRow;
|
|
3138
3258
|
state.selectedRows = [...state.selectedRows];
|
|
3139
3259
|
const min = Math.min(previousFocused, state.focusedRow);
|
|
@@ -3151,7 +3271,7 @@ function handleKeyDownEvent(ev) {
|
|
|
3151
3271
|
state.hasNonAdditionalFilters ? -2 : -1,
|
|
3152
3272
|
state.rows.length - 1
|
|
3153
3273
|
);
|
|
3154
|
-
if (ev.ctrlKey) ; else if (ev.shiftKey) {
|
|
3274
|
+
if (ev.ctrlKey) ; else if (ev.shiftKey && state.isMultiple !== false) {
|
|
3155
3275
|
const previousFocused = this.getState().focusedRow;
|
|
3156
3276
|
state.selectedRows = [...state.selectedRows];
|
|
3157
3277
|
const min = Math.min(previousFocused, state.focusedRow);
|
|
@@ -3163,11 +3283,21 @@ function handleKeyDownEvent(ev) {
|
|
|
3163
3283
|
state.selectedRows = [state.focusedRow];
|
|
3164
3284
|
}
|
|
3165
3285
|
break;
|
|
3166
|
-
case "Enter":
|
|
3286
|
+
case "Enter": {
|
|
3167
3287
|
state.isEditionMode = true;
|
|
3168
3288
|
this.setState(state);
|
|
3169
3289
|
applyFocusAttributes(table, this.getState(), state);
|
|
3290
|
+
if (state.focusedRow >= 0) {
|
|
3291
|
+
this.events.onSelectRows?.(
|
|
3292
|
+
this.getSelection().map((index) => ({
|
|
3293
|
+
index,
|
|
3294
|
+
row: this.getState().rows[index]
|
|
3295
|
+
})),
|
|
3296
|
+
state.focusedRow
|
|
3297
|
+
);
|
|
3298
|
+
}
|
|
3170
3299
|
return;
|
|
3300
|
+
}
|
|
3171
3301
|
}
|
|
3172
3302
|
state.isFocused = true;
|
|
3173
3303
|
applySelectionAttributes(table, this.getState(), state);
|
|
@@ -3199,14 +3329,25 @@ class Controller2 {
|
|
|
3199
3329
|
if (el) {
|
|
3200
3330
|
el.addEventListener("keydown", this.handleKeyDownEvent);
|
|
3201
3331
|
el.addEventListener("mousedown", this.handleClickEvent);
|
|
3332
|
+
el.addEventListener("dblclick", this.handleDoubleClickEvent);
|
|
3202
3333
|
this.unsubscribe = () => {
|
|
3203
3334
|
el.removeEventListener("keydown", this.handleKeyDownEvent);
|
|
3204
3335
|
el.removeEventListener("mousedown", this.handleClickEvent);
|
|
3336
|
+
el.removeEventListener("dblclick", this.handleDoubleClickEvent);
|
|
3205
3337
|
};
|
|
3206
3338
|
}
|
|
3207
3339
|
});
|
|
3208
3340
|
__publicField(this, "handleClickEvent");
|
|
3209
3341
|
__publicField(this, "handleKeyDownEvent");
|
|
3342
|
+
__publicField(this, "handleDoubleClickEvent", () => {
|
|
3343
|
+
this.events.onSelectRows?.(
|
|
3344
|
+
this.getSelection().map((index) => ({
|
|
3345
|
+
index,
|
|
3346
|
+
row: this.getState().rows[index]
|
|
3347
|
+
})),
|
|
3348
|
+
this.getState().focusedRow
|
|
3349
|
+
);
|
|
3350
|
+
});
|
|
3210
3351
|
this.handleClickEvent = handleMouseDownEvent.bind(this);
|
|
3211
3352
|
this.handleKeyDownEvent = handleKeyDownEvent.bind(this);
|
|
3212
3353
|
}
|
|
@@ -3221,6 +3362,10 @@ class Controller2 {
|
|
|
3221
3362
|
...responsiveTableStore.getState().responsiveTableSlice[this.tableName]
|
|
3222
3363
|
};
|
|
3223
3364
|
}
|
|
3365
|
+
getSelection() {
|
|
3366
|
+
const selectedRows = new Set(this.getState().selectedRows);
|
|
3367
|
+
return [...selectedRows.values()];
|
|
3368
|
+
}
|
|
3224
3369
|
setState(state) {
|
|
3225
3370
|
if (state.selectedRows && !shallowEqual$1(state.selectedRows, this.getState().selectedRows)) {
|
|
3226
3371
|
this.events.onChangeSelection?.(
|
|
@@ -3229,13 +3374,6 @@ class Controller2 {
|
|
|
3229
3374
|
row: this.getState().rows[index]
|
|
3230
3375
|
}))
|
|
3231
3376
|
);
|
|
3232
|
-
this.events.onSelectRows?.(
|
|
3233
|
-
state.selectedRows.map((index) => ({
|
|
3234
|
-
index,
|
|
3235
|
-
row: this.getState().rows[index]
|
|
3236
|
-
})),
|
|
3237
|
-
state.focusedRow
|
|
3238
|
-
);
|
|
3239
3377
|
}
|
|
3240
3378
|
if (state.scrollIntoViewRow !== void 0 && state.scrollIntoViewRow !== this.getState().scrollIntoViewRow) {
|
|
3241
3379
|
const row = this.el?.querySelector(
|
|
@@ -3269,7 +3407,8 @@ const Controller2Component = ({
|
|
|
3269
3407
|
}) => {
|
|
3270
3408
|
controller.setEvents({
|
|
3271
3409
|
onChangeSelection: props.onChangeSelection,
|
|
3272
|
-
onSelectRows: props.onSelectRows
|
|
3410
|
+
onSelectRows: props.onSelectRows,
|
|
3411
|
+
onRowClick: props.onRowClick
|
|
3273
3412
|
});
|
|
3274
3413
|
const previousColumns = useRef([]);
|
|
3275
3414
|
const previousRows = useRef([]);
|
|
@@ -3311,6 +3450,14 @@ function makeController2(tableName) {
|
|
|
3311
3450
|
];
|
|
3312
3451
|
}
|
|
3313
3452
|
|
|
3453
|
+
const TableContextReproducer = ({
|
|
3454
|
+
children,
|
|
3455
|
+
tableName
|
|
3456
|
+
}) => {
|
|
3457
|
+
const context = useResponsiveTableContext(tableName);
|
|
3458
|
+
return /* @__PURE__ */ jsx(ResponsiveTableReactContext.Provider, { value: context, children });
|
|
3459
|
+
};
|
|
3460
|
+
|
|
3314
3461
|
const NoMemoDocNameCellRenderer = React.forwardRef(
|
|
3315
3462
|
({
|
|
3316
3463
|
cell: { children, Renderer, rendererProps, AccordionRenderer, ...cell },
|
|
@@ -3664,5 +3811,5 @@ const NoMemoStatusAccordionRenderer = React.forwardRef(({ cell, column }, curren
|
|
|
3664
3811
|
NoMemoStatusAccordionRenderer.displayName = "StatusAccordionRenderer";
|
|
3665
3812
|
const StatusAccordionRenderer = NoMemoStatusAccordionRenderer;
|
|
3666
3813
|
|
|
3667
|
-
export { AccordionCell, AccordionDocNameCellRenderer, AccordionElement, AccordionHTMLCellRenderer, AccordionRenderer, Additional, AdditionalColumnDefaultRenderer, Controller2, DefaultCellRenderer, DefaultRowRenderer, DocNameCellRenderer, HTMLCellRenderer, IsLoadingRenderer, NoEllipsisCellRenderer, NoRegistersRenderer, Pagination, PriorityAccordionRenderer, PriorityRenderer, Responsive, ResponsiveTable, ResponsiveTableContext, RowStatesRenderer, Sort, StatusAccordionRenderer, StatusRenderer, TableRenderer, defaultLabels, getPriorityHandler, getStatusRendererClassName, makeAccordionAsyncRenderer, makeAsyncRenderer, makeController2, responsiveTableActions, responsiveTableStore, useResponsiveTable, useResponsiveTableContext };
|
|
3814
|
+
export { AccordionCell, AccordionDocNameCellRenderer, AccordionElement, AccordionHTMLCellRenderer, AccordionRenderer, Additional, AdditionalColumnDefaultRenderer, Controller2, DefaultCellRenderer, DefaultRowRenderer, DocNameCellRenderer, HTMLCellRenderer, IsLoadingRenderer, NoEllipsisCellRenderer, NoRegistersRenderer, Pagination, PriorityAccordionRenderer, PriorityRenderer, Responsive, ResponsiveTable, ResponsiveTableContext, RowStatesRenderer, Sort, StatusAccordionRenderer, StatusRenderer, TableContextReproducer, TableRenderer, defaultLabels, getPriorityHandler, getStatusRendererClassName, makeAccordionAsyncRenderer, makeAsyncRenderer, makeController2, responsiveTableActions, responsiveTableStore, useResponsiveTable, useResponsiveTableContext };
|
|
3668
3815
|
//# sourceMappingURL=index.js.map
|