funda-ui 4.7.890 → 4.7.895
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/Table/index.js +39 -15
- package/lib/cjs/Table/index.js +39 -15
- package/lib/esm/Table/Table.tsx +2 -5
- package/lib/esm/Table/TableCell.tsx +1 -1
- package/lib/esm/Table/utils/SortSprite.tsx +1 -1
- package/lib/esm/Table/utils/func.ts +1 -1
- package/lib/esm/Table/utils/hooks/useTableDraggable.tsx +9 -3
- package/lib/esm/Table/utils/hooks/useTableKeyPress.tsx +14 -5
- package/lib/esm/Table/utils/hooks/useTableResponsive.tsx +8 -4
- package/lib/esm/Table/utils/hooks/useTableSort.tsx +9 -4
- package/package.json +1 -1
package/Table/index.js
CHANGED
|
@@ -579,7 +579,7 @@ function initRowColProps(rootElem) {
|
|
|
579
579
|
// !!! Important, performance optimization for large data renderings
|
|
580
580
|
// With this protection, it is only performed once
|
|
581
581
|
if (typeof rootElem.dataset.rowColPropsInit !== 'undefined') return;
|
|
582
|
-
rootElem.dataset.rowColPropsInit =
|
|
582
|
+
rootElem.dataset.rowColPropsInit = 1;
|
|
583
583
|
|
|
584
584
|
//
|
|
585
585
|
var _allRows = allRows(rootElem);
|
|
@@ -745,16 +745,20 @@ function useTableResponsive(_ref, deps) {
|
|
|
745
745
|
}
|
|
746
746
|
}
|
|
747
747
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
748
|
-
if (enabled) {
|
|
749
|
-
//
|
|
748
|
+
if (enabled && spyElement) {
|
|
749
|
+
// 1. Remove the tag to allow initRowColProps to re-execute (!!!REQUIRED)
|
|
750
|
+
delete spyElement.dataset.customPropsInit;
|
|
751
|
+
delete spyElement.dataset.rowColPropsInit;
|
|
752
|
+
|
|
753
|
+
// 2. Initialize custom props of table elements
|
|
750
754
|
initOrderProps(spyElement);
|
|
751
755
|
initRowColProps(spyElement);
|
|
752
756
|
|
|
753
|
-
// With scroll bars
|
|
757
|
+
// 3. With scroll bars
|
|
754
758
|
var _windowWidth = window.innerWidth;
|
|
755
759
|
tableElemScrolledInit(spyElement, _windowWidth);
|
|
756
760
|
|
|
757
|
-
// Add function to the element that should be used as the scrollable area.
|
|
761
|
+
// 4. Add function to the element that should be used as the scrollable area.
|
|
758
762
|
window.removeEventListener('resize', windowResizeUpdate);
|
|
759
763
|
window.addEventListener('resize', windowResizeUpdate);
|
|
760
764
|
|
|
@@ -1320,18 +1324,23 @@ function useTableDraggable(_ref, deps) {
|
|
|
1320
1324
|
dragCacheRef.current.lastOverOrder = null;
|
|
1321
1325
|
}, [sortData, spyElement, data, onRowDrag]);
|
|
1322
1326
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
1323
|
-
if (enabled) {
|
|
1327
|
+
if (enabled && spyElement) {
|
|
1324
1328
|
if (Array.isArray(data) && data.length > 0) {
|
|
1329
|
+
// 1. Remove the tag to allow initRowColProps to re-execute (!!!REQUIRED)
|
|
1330
|
+
delete spyElement.dataset.customPropsInit;
|
|
1331
|
+
delete spyElement.dataset.rowColPropsInit;
|
|
1332
|
+
|
|
1333
|
+
// 2. Set order for new data items (although this is only in-memory data and has no direct impact on the DOM)
|
|
1325
1334
|
// !!! REQUIRED "data.length > 0" to avoid data-order cannot be assigned when asynchronous data is empty
|
|
1326
1335
|
data.forEach(function (item, i) {
|
|
1327
1336
|
item.order = i;
|
|
1328
1337
|
});
|
|
1329
1338
|
|
|
1330
|
-
// Initialize custom props of table elements
|
|
1339
|
+
// 3. Initialize custom props of table elements
|
|
1331
1340
|
initOrderProps(spyElement);
|
|
1332
1341
|
initRowColProps(spyElement);
|
|
1333
1342
|
|
|
1334
|
-
// Initialize drag & drop data
|
|
1343
|
+
// 4. Initialize drag & drop data
|
|
1335
1344
|
initDragDropData();
|
|
1336
1345
|
}
|
|
1337
1346
|
}
|
|
@@ -1401,6 +1410,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
1401
1410
|
};
|
|
1402
1411
|
|
|
1403
1412
|
const { handleKeyPressed } = useTableKeyPress({
|
|
1413
|
+
// isCell: true, // Avoid duplicate rendering
|
|
1404
1414
|
enabled: keyboardFocusable,
|
|
1405
1415
|
data: [{ a: 1, b: 2, c: 3 }],
|
|
1406
1416
|
spyElement: rootRef.current,
|
|
@@ -1424,7 +1434,9 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
1424
1434
|
|
|
1425
1435
|
|
|
1426
1436
|
var useTableKeyPress = function useTableKeyPress(_ref, deps) {
|
|
1427
|
-
var
|
|
1437
|
+
var _ref$isCell = _ref.isCell,
|
|
1438
|
+
isCell = _ref$isCell === void 0 ? false : _ref$isCell,
|
|
1439
|
+
enabled = _ref.enabled,
|
|
1428
1440
|
data = _ref.data,
|
|
1429
1441
|
spyElement = _ref.spyElement,
|
|
1430
1442
|
rootDataInfo = _ref.rootDataInfo,
|
|
@@ -1558,12 +1570,17 @@ var useTableKeyPress = function useTableKeyPress(_ref, deps) {
|
|
|
1558
1570
|
};
|
|
1559
1571
|
}(), [focusableCellId, rootDataInfo, data]);
|
|
1560
1572
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
1561
|
-
if (
|
|
1562
|
-
|
|
1573
|
+
if (isCell) return;
|
|
1574
|
+
if (enabled && spyElement) {
|
|
1575
|
+
// 1. Remove the tag to allow initRowColProps to re-execute (!!!REQUIRED)
|
|
1576
|
+
delete spyElement.dataset.customPropsInit;
|
|
1577
|
+
delete spyElement.dataset.rowColPropsInit;
|
|
1578
|
+
|
|
1579
|
+
// 2. Initialize custom props of table elements (only once)
|
|
1563
1580
|
initOrderProps(spyElement);
|
|
1564
1581
|
initRowColProps(spyElement);
|
|
1565
1582
|
}
|
|
1566
|
-
}, [enabled, spyElement].concat(useTableKeyPress_toConsumableArray(deps)));
|
|
1583
|
+
}, [enabled, spyElement, isCell].concat(useTableKeyPress_toConsumableArray(deps)));
|
|
1567
1584
|
return {
|
|
1568
1585
|
handleKeyPressed: handleKeyPressed,
|
|
1569
1586
|
/**
|
|
@@ -1886,6 +1903,8 @@ var TableCell = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_rea
|
|
|
1886
1903
|
|
|
1887
1904
|
// key press initialization
|
|
1888
1905
|
var _useTableKeyPress = hooks_useTableKeyPress({
|
|
1906
|
+
isCell: true,
|
|
1907
|
+
// Avoid duplicate rendering
|
|
1889
1908
|
enabled: keyboardFocusable,
|
|
1890
1909
|
data: originData,
|
|
1891
1910
|
spyElement: rootRef.current,
|
|
@@ -2542,13 +2561,18 @@ function useTableSort(_ref, deps) {
|
|
|
2542
2561
|
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
2543
2562
|
}
|
|
2544
2563
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
2545
|
-
if (enabled) {
|
|
2564
|
+
if (enabled && spyElement) {
|
|
2546
2565
|
if (Array.isArray(data)) {
|
|
2566
|
+
// 1. Remove the tag to allow initRowColProps to re-execute (!!!REQUIRED)
|
|
2567
|
+
delete spyElement.dataset.customPropsInit;
|
|
2568
|
+
delete spyElement.dataset.rowColPropsInit;
|
|
2569
|
+
|
|
2570
|
+
// 2. Set order for new data items (although this is only in-memory data and has no direct impact on the DOM)
|
|
2547
2571
|
data.forEach(function (item, i) {
|
|
2548
2572
|
item.order = i;
|
|
2549
2573
|
});
|
|
2550
2574
|
|
|
2551
|
-
// Initialize custom props of table elements
|
|
2575
|
+
// 3. Initialize custom props of table elements
|
|
2552
2576
|
initOrderProps(spyElement);
|
|
2553
2577
|
initRowColProps(spyElement);
|
|
2554
2578
|
}
|
|
@@ -2587,7 +2611,7 @@ var SortSprite = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_re
|
|
|
2587
2611
|
isReverse: isReverse,
|
|
2588
2612
|
onClick: onClick,
|
|
2589
2613
|
sortBy: sortBy
|
|
2590
|
-
}, [rootRef]),
|
|
2614
|
+
}, [rootRef, originData]),
|
|
2591
2615
|
handleSortList = _useTableSort.handleSortList;
|
|
2592
2616
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, colSortable ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
2593
2617
|
className: className || 'sort-trigger',
|
package/lib/cjs/Table/index.js
CHANGED
|
@@ -579,7 +579,7 @@ function initRowColProps(rootElem) {
|
|
|
579
579
|
// !!! Important, performance optimization for large data renderings
|
|
580
580
|
// With this protection, it is only performed once
|
|
581
581
|
if (typeof rootElem.dataset.rowColPropsInit !== 'undefined') return;
|
|
582
|
-
rootElem.dataset.rowColPropsInit =
|
|
582
|
+
rootElem.dataset.rowColPropsInit = 1;
|
|
583
583
|
|
|
584
584
|
//
|
|
585
585
|
var _allRows = allRows(rootElem);
|
|
@@ -745,16 +745,20 @@ function useTableResponsive(_ref, deps) {
|
|
|
745
745
|
}
|
|
746
746
|
}
|
|
747
747
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
748
|
-
if (enabled) {
|
|
749
|
-
//
|
|
748
|
+
if (enabled && spyElement) {
|
|
749
|
+
// 1. Remove the tag to allow initRowColProps to re-execute (!!!REQUIRED)
|
|
750
|
+
delete spyElement.dataset.customPropsInit;
|
|
751
|
+
delete spyElement.dataset.rowColPropsInit;
|
|
752
|
+
|
|
753
|
+
// 2. Initialize custom props of table elements
|
|
750
754
|
initOrderProps(spyElement);
|
|
751
755
|
initRowColProps(spyElement);
|
|
752
756
|
|
|
753
|
-
// With scroll bars
|
|
757
|
+
// 3. With scroll bars
|
|
754
758
|
var _windowWidth = window.innerWidth;
|
|
755
759
|
tableElemScrolledInit(spyElement, _windowWidth);
|
|
756
760
|
|
|
757
|
-
// Add function to the element that should be used as the scrollable area.
|
|
761
|
+
// 4. Add function to the element that should be used as the scrollable area.
|
|
758
762
|
window.removeEventListener('resize', windowResizeUpdate);
|
|
759
763
|
window.addEventListener('resize', windowResizeUpdate);
|
|
760
764
|
|
|
@@ -1320,18 +1324,23 @@ function useTableDraggable(_ref, deps) {
|
|
|
1320
1324
|
dragCacheRef.current.lastOverOrder = null;
|
|
1321
1325
|
}, [sortData, spyElement, data, onRowDrag]);
|
|
1322
1326
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
1323
|
-
if (enabled) {
|
|
1327
|
+
if (enabled && spyElement) {
|
|
1324
1328
|
if (Array.isArray(data) && data.length > 0) {
|
|
1329
|
+
// 1. Remove the tag to allow initRowColProps to re-execute (!!!REQUIRED)
|
|
1330
|
+
delete spyElement.dataset.customPropsInit;
|
|
1331
|
+
delete spyElement.dataset.rowColPropsInit;
|
|
1332
|
+
|
|
1333
|
+
// 2. Set order for new data items (although this is only in-memory data and has no direct impact on the DOM)
|
|
1325
1334
|
// !!! REQUIRED "data.length > 0" to avoid data-order cannot be assigned when asynchronous data is empty
|
|
1326
1335
|
data.forEach(function (item, i) {
|
|
1327
1336
|
item.order = i;
|
|
1328
1337
|
});
|
|
1329
1338
|
|
|
1330
|
-
// Initialize custom props of table elements
|
|
1339
|
+
// 3. Initialize custom props of table elements
|
|
1331
1340
|
initOrderProps(spyElement);
|
|
1332
1341
|
initRowColProps(spyElement);
|
|
1333
1342
|
|
|
1334
|
-
// Initialize drag & drop data
|
|
1343
|
+
// 4. Initialize drag & drop data
|
|
1335
1344
|
initDragDropData();
|
|
1336
1345
|
}
|
|
1337
1346
|
}
|
|
@@ -1401,6 +1410,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
1401
1410
|
};
|
|
1402
1411
|
|
|
1403
1412
|
const { handleKeyPressed } = useTableKeyPress({
|
|
1413
|
+
// isCell: true, // Avoid duplicate rendering
|
|
1404
1414
|
enabled: keyboardFocusable,
|
|
1405
1415
|
data: [{ a: 1, b: 2, c: 3 }],
|
|
1406
1416
|
spyElement: rootRef.current,
|
|
@@ -1424,7 +1434,9 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
1424
1434
|
|
|
1425
1435
|
|
|
1426
1436
|
var useTableKeyPress = function useTableKeyPress(_ref, deps) {
|
|
1427
|
-
var
|
|
1437
|
+
var _ref$isCell = _ref.isCell,
|
|
1438
|
+
isCell = _ref$isCell === void 0 ? false : _ref$isCell,
|
|
1439
|
+
enabled = _ref.enabled,
|
|
1428
1440
|
data = _ref.data,
|
|
1429
1441
|
spyElement = _ref.spyElement,
|
|
1430
1442
|
rootDataInfo = _ref.rootDataInfo,
|
|
@@ -1558,12 +1570,17 @@ var useTableKeyPress = function useTableKeyPress(_ref, deps) {
|
|
|
1558
1570
|
};
|
|
1559
1571
|
}(), [focusableCellId, rootDataInfo, data]);
|
|
1560
1572
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
1561
|
-
if (
|
|
1562
|
-
|
|
1573
|
+
if (isCell) return;
|
|
1574
|
+
if (enabled && spyElement) {
|
|
1575
|
+
// 1. Remove the tag to allow initRowColProps to re-execute (!!!REQUIRED)
|
|
1576
|
+
delete spyElement.dataset.customPropsInit;
|
|
1577
|
+
delete spyElement.dataset.rowColPropsInit;
|
|
1578
|
+
|
|
1579
|
+
// 2. Initialize custom props of table elements (only once)
|
|
1563
1580
|
initOrderProps(spyElement);
|
|
1564
1581
|
initRowColProps(spyElement);
|
|
1565
1582
|
}
|
|
1566
|
-
}, [enabled, spyElement].concat(useTableKeyPress_toConsumableArray(deps)));
|
|
1583
|
+
}, [enabled, spyElement, isCell].concat(useTableKeyPress_toConsumableArray(deps)));
|
|
1567
1584
|
return {
|
|
1568
1585
|
handleKeyPressed: handleKeyPressed,
|
|
1569
1586
|
/**
|
|
@@ -1886,6 +1903,8 @@ var TableCell = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_rea
|
|
|
1886
1903
|
|
|
1887
1904
|
// key press initialization
|
|
1888
1905
|
var _useTableKeyPress = hooks_useTableKeyPress({
|
|
1906
|
+
isCell: true,
|
|
1907
|
+
// Avoid duplicate rendering
|
|
1889
1908
|
enabled: keyboardFocusable,
|
|
1890
1909
|
data: originData,
|
|
1891
1910
|
spyElement: rootRef.current,
|
|
@@ -2542,13 +2561,18 @@ function useTableSort(_ref, deps) {
|
|
|
2542
2561
|
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
2543
2562
|
}
|
|
2544
2563
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
2545
|
-
if (enabled) {
|
|
2564
|
+
if (enabled && spyElement) {
|
|
2546
2565
|
if (Array.isArray(data)) {
|
|
2566
|
+
// 1. Remove the tag to allow initRowColProps to re-execute (!!!REQUIRED)
|
|
2567
|
+
delete spyElement.dataset.customPropsInit;
|
|
2568
|
+
delete spyElement.dataset.rowColPropsInit;
|
|
2569
|
+
|
|
2570
|
+
// 2. Set order for new data items (although this is only in-memory data and has no direct impact on the DOM)
|
|
2547
2571
|
data.forEach(function (item, i) {
|
|
2548
2572
|
item.order = i;
|
|
2549
2573
|
});
|
|
2550
2574
|
|
|
2551
|
-
// Initialize custom props of table elements
|
|
2575
|
+
// 3. Initialize custom props of table elements
|
|
2552
2576
|
initOrderProps(spyElement);
|
|
2553
2577
|
initRowColProps(spyElement);
|
|
2554
2578
|
}
|
|
@@ -2587,7 +2611,7 @@ var SortSprite = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_re
|
|
|
2587
2611
|
isReverse: isReverse,
|
|
2588
2612
|
onClick: onClick,
|
|
2589
2613
|
sortBy: sortBy
|
|
2590
|
-
}, [rootRef]),
|
|
2614
|
+
}, [rootRef, originData]),
|
|
2591
2615
|
handleSortList = _useTableSort.handleSortList;
|
|
2592
2616
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, colSortable ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
2593
2617
|
className: className || 'sort-trigger',
|
package/lib/esm/Table/Table.tsx
CHANGED
|
@@ -5,7 +5,6 @@ import useComId from 'funda-utils/dist/cjs/useComId';
|
|
|
5
5
|
import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
import { TableProvider } from './TableContext';
|
|
10
9
|
import useTableResponsive from './utils/hooks/useTableResponsive';
|
|
11
10
|
import useTableDraggable from './utils/hooks/useTableDraggable';
|
|
@@ -256,6 +255,7 @@ const Table = forwardRef<HTMLDivElement, TableProps>((
|
|
|
256
255
|
triggerCellKeyPressed: tableKeyPress.triggerCellKeyPressed
|
|
257
256
|
}), [rootRef, data, rootDataInfo]);
|
|
258
257
|
|
|
258
|
+
|
|
259
259
|
return (
|
|
260
260
|
<>
|
|
261
261
|
|
|
@@ -297,12 +297,9 @@ const Table = forwardRef<HTMLDivElement, TableProps>((
|
|
|
297
297
|
focusableCellId,
|
|
298
298
|
setFocusableCellId,
|
|
299
299
|
onCellKeyPressed,
|
|
300
|
-
onCellPressEnter,
|
|
301
|
-
|
|
302
|
-
|
|
300
|
+
onCellPressEnter,
|
|
303
301
|
}}>
|
|
304
302
|
|
|
305
|
-
|
|
306
303
|
{/** Main */}
|
|
307
304
|
<div
|
|
308
305
|
{...attributes}
|
|
@@ -2,7 +2,6 @@ import React, { forwardRef, useContext } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
import { TableContext } from './TableContext';
|
|
7
6
|
|
|
8
7
|
import { cellMark, removeCellFocusClassName } from './utils/func';
|
|
@@ -55,6 +54,7 @@ const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>((
|
|
|
55
54
|
|
|
56
55
|
// key press initialization
|
|
57
56
|
const { handleKeyPressed } = useTableKeyPress({
|
|
57
|
+
isCell: true, // Avoid duplicate rendering
|
|
58
58
|
enabled: keyboardFocusable,
|
|
59
59
|
data: originData,
|
|
60
60
|
spyElement: rootRef.current,
|
|
@@ -67,7 +67,7 @@ export function initRowColProps(rootElem: any) {
|
|
|
67
67
|
// !!! Important, performance optimization for large data renderings
|
|
68
68
|
// With this protection, it is only performed once
|
|
69
69
|
if (typeof rootElem.dataset.rowColPropsInit !== 'undefined') return;
|
|
70
|
-
rootElem.dataset.rowColPropsInit =
|
|
70
|
+
rootElem.dataset.rowColPropsInit = 1;
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
//
|
|
@@ -614,18 +614,24 @@ function useTableDraggable({
|
|
|
614
614
|
|
|
615
615
|
|
|
616
616
|
useEffect(() => {
|
|
617
|
-
if (enabled) {
|
|
617
|
+
if (enabled && spyElement) {
|
|
618
618
|
if (Array.isArray(data) && data.length > 0) {
|
|
619
|
+
|
|
620
|
+
// 1. Remove the tag to allow initRowColProps to re-execute (!!!REQUIRED)
|
|
621
|
+
delete spyElement.dataset.customPropsInit;
|
|
622
|
+
delete spyElement.dataset.rowColPropsInit;
|
|
623
|
+
|
|
624
|
+
// 2. Set order for new data items (although this is only in-memory data and has no direct impact on the DOM)
|
|
619
625
|
// !!! REQUIRED "data.length > 0" to avoid data-order cannot be assigned when asynchronous data is empty
|
|
620
626
|
data.forEach((item: any, i: number) => {
|
|
621
627
|
item.order = i;
|
|
622
628
|
});
|
|
623
629
|
|
|
624
|
-
// Initialize custom props of table elements
|
|
630
|
+
// 3. Initialize custom props of table elements
|
|
625
631
|
initOrderProps(spyElement);
|
|
626
632
|
initRowColProps(spyElement);
|
|
627
633
|
|
|
628
|
-
// Initialize drag & drop data
|
|
634
|
+
// 4. Initialize drag & drop data
|
|
629
635
|
initDragDropData();
|
|
630
636
|
|
|
631
637
|
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
const { handleKeyPressed } = useTableKeyPress({
|
|
43
|
+
// isCell: true, // Avoid duplicate rendering
|
|
43
44
|
enabled: keyboardFocusable,
|
|
44
45
|
data: [{ a: 1, b: 2, c: 3 }],
|
|
45
46
|
spyElement: rootRef.current,
|
|
@@ -65,6 +66,7 @@ import { useEffect, useCallback, KeyboardEvent, useRef } from "react";
|
|
|
65
66
|
import { initOrderProps, initRowColProps, cellMark, removeCellFocusClassName } from '../func';
|
|
66
67
|
|
|
67
68
|
export interface UseTableKeyPressProps {
|
|
69
|
+
isCell?: boolean;
|
|
68
70
|
enabled?: boolean;
|
|
69
71
|
data?: any[];
|
|
70
72
|
spyElement?: any;
|
|
@@ -86,6 +88,7 @@ export interface UseTableKeyPressProps {
|
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
const useTableKeyPress = ({
|
|
91
|
+
isCell = false,
|
|
89
92
|
enabled,
|
|
90
93
|
data,
|
|
91
94
|
spyElement,
|
|
@@ -190,8 +193,7 @@ const useTableKeyPress = ({
|
|
|
190
193
|
if (typeof targetCell !== 'undefined') {
|
|
191
194
|
targetCell.classList.add('cell-focus');
|
|
192
195
|
}
|
|
193
|
-
|
|
194
|
-
|
|
196
|
+
|
|
195
197
|
setFocusableCellId(nextCellSignal);
|
|
196
198
|
// Callback with edge detection
|
|
197
199
|
onCellKeyPressed?.(
|
|
@@ -233,12 +235,19 @@ const useTableKeyPress = ({
|
|
|
233
235
|
}, [focusableCellId, rootDataInfo, data]);
|
|
234
236
|
|
|
235
237
|
useEffect(() => {
|
|
236
|
-
if (
|
|
237
|
-
|
|
238
|
+
if (isCell) return;
|
|
239
|
+
|
|
240
|
+
if (enabled && spyElement) {
|
|
241
|
+
|
|
242
|
+
// 1. Remove the tag to allow initRowColProps to re-execute (!!!REQUIRED)
|
|
243
|
+
delete spyElement.dataset.customPropsInit;
|
|
244
|
+
delete spyElement.dataset.rowColPropsInit;
|
|
245
|
+
|
|
246
|
+
// 2. Initialize custom props of table elements (only once)
|
|
238
247
|
initOrderProps(spyElement);
|
|
239
248
|
initRowColProps(spyElement);
|
|
240
249
|
}
|
|
241
|
-
}, [enabled, spyElement, ...deps]);
|
|
250
|
+
}, [enabled, spyElement, isCell, ...deps]);
|
|
242
251
|
|
|
243
252
|
return {
|
|
244
253
|
handleKeyPressed,
|
|
@@ -64,18 +64,22 @@ function useTableResponsive({
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
useEffect(() => {
|
|
67
|
-
if (enabled) {
|
|
67
|
+
if (enabled && spyElement) {
|
|
68
68
|
|
|
69
|
-
//
|
|
69
|
+
// 1. Remove the tag to allow initRowColProps to re-execute (!!!REQUIRED)
|
|
70
|
+
delete spyElement.dataset.customPropsInit;
|
|
71
|
+
delete spyElement.dataset.rowColPropsInit;
|
|
72
|
+
|
|
73
|
+
// 2. Initialize custom props of table elements
|
|
70
74
|
initOrderProps(spyElement);
|
|
71
75
|
initRowColProps(spyElement);
|
|
72
76
|
|
|
73
|
-
// With scroll bars
|
|
77
|
+
// 3. With scroll bars
|
|
74
78
|
let windowWidth = window.innerWidth;
|
|
75
79
|
tableElemScrolledInit(spyElement as never, windowWidth);
|
|
76
80
|
|
|
77
81
|
|
|
78
|
-
// Add function to the element that should be used as the scrollable area.
|
|
82
|
+
// 4. Add function to the element that should be used as the scrollable area.
|
|
79
83
|
window.removeEventListener('resize', windowResizeUpdate);
|
|
80
84
|
window.addEventListener('resize', windowResizeUpdate);
|
|
81
85
|
|
|
@@ -161,22 +161,27 @@ function useTableSort({
|
|
|
161
161
|
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
|
|
164
165
|
useEffect(() => {
|
|
165
|
-
if (enabled) {
|
|
166
|
+
if (enabled && spyElement) {
|
|
166
167
|
if (Array.isArray(data)) {
|
|
168
|
+
// 1. Remove the tag to allow initRowColProps to re-execute (!!!REQUIRED)
|
|
169
|
+
delete spyElement.dataset.customPropsInit;
|
|
170
|
+
delete spyElement.dataset.rowColPropsInit;
|
|
171
|
+
|
|
172
|
+
// 2. Set order for new data items (although this is only in-memory data and has no direct impact on the DOM)
|
|
167
173
|
data.forEach((item: any, i: number) => {
|
|
168
174
|
item.order = i;
|
|
169
175
|
});
|
|
170
176
|
|
|
171
|
-
|
|
172
|
-
// Initialize custom props of table elements
|
|
177
|
+
// 3. Initialize custom props of table elements
|
|
173
178
|
initOrderProps(spyElement);
|
|
174
179
|
initRowColProps(spyElement);
|
|
175
|
-
|
|
176
180
|
}
|
|
177
181
|
}
|
|
178
182
|
}, [data, enabled, spyElement, ...deps]);
|
|
179
183
|
|
|
184
|
+
|
|
180
185
|
return {
|
|
181
186
|
handleSortList
|
|
182
187
|
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"author":"UIUX Lab","email":"uiuxlab@gmail.com","name":"funda-ui","version":"4.7.
|
|
1
|
+
{"author":"UIUX Lab","email":"uiuxlab@gmail.com","name":"funda-ui","version":"4.7.895","description":"React components using pure Bootstrap 5+ which does not contain any external style and script libraries.","repository":{"type":"git","url":"git+https://github.com/xizon/funda-ui.git"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["bootstrap","react-bootstrap","react-components","components","components-react","react-bootstrap-components","react","funda-ui","fundaui","uikit","ui-kit","ui-components"],"bugs":{"url":"https://github.com/xizon/funda-ui/issues"},"homepage":"https://github.com/xizon/funda-ui#readme","main":"all.js","license":"MIT","dependencies":{"react":"^18.2.0","react-dom":"^18.2.0"},"types":"all.d.ts","publishConfig":{"directory":"lib"},"directories":{"lib":"lib"}}
|