@pdg/react-table 1.0.8 → 1.0.10
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.esm.js +156 -147
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +155 -146
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -8339,78 +8339,12 @@ var equal = function (v1, v2) {
|
|
|
8339
8339
|
default:
|
|
8340
8340
|
return column.align || defaultAlign;
|
|
8341
8341
|
}
|
|
8342
|
-
}function useFirstSkipEffect(effect, deps) {
|
|
8343
|
-
var firstRef = React.useRef(true);
|
|
8344
|
-
React.useEffect(function () {
|
|
8345
|
-
if (firstRef.current) {
|
|
8346
|
-
firstRef.current = false;
|
|
8347
|
-
}
|
|
8348
|
-
else {
|
|
8349
|
-
effect();
|
|
8350
|
-
}
|
|
8351
|
-
}, deps);
|
|
8352
|
-
}var isSame = function (v1, v2) {
|
|
8353
|
-
if (v1 === v2)
|
|
8354
|
-
return true;
|
|
8355
|
-
if (typeof v1 !== typeof v2)
|
|
8356
|
-
return false;
|
|
8357
|
-
if (v1 == null || v2 == null)
|
|
8358
|
-
return false;
|
|
8359
|
-
if (Array.isArray(v1) && Array.isArray(v2)) {
|
|
8360
|
-
if (v1.length !== v2.length)
|
|
8361
|
-
return false;
|
|
8362
|
-
for (var i = 0; i < v1.length; i += 1) {
|
|
8363
|
-
if (v1[i] !== v2[i])
|
|
8364
|
-
return false;
|
|
8365
|
-
}
|
|
8366
|
-
}
|
|
8367
|
-
else {
|
|
8368
|
-
return v1 === v2;
|
|
8369
|
-
}
|
|
8370
|
-
return true;
|
|
8371
|
-
};function useAutoUpdateState(p1, p2) {
|
|
8372
|
-
var state = typeof p1 === 'function' ? undefined : p1;
|
|
8373
|
-
var finalStateCallback = typeof p1 === 'function' ? p1 : p2;
|
|
8374
|
-
var _a = React.useState(0), setUpdateKey = _a[1];
|
|
8375
|
-
var _initState = React.useState(function () {
|
|
8376
|
-
return finalStateCallback ? finalStateCallback(state) : state;
|
|
8377
|
-
})[0];
|
|
8378
|
-
var _state = React.useRef(_initState);
|
|
8379
|
-
var forceUpdate = React.useCallback(function () {
|
|
8380
|
-
setUpdateKey(function (updateKey) { return updateKey + 1; });
|
|
8381
|
-
}, []);
|
|
8382
|
-
useFirstSkipEffect(function () {
|
|
8383
|
-
var newState = finalStateCallback ? finalStateCallback(state) : state;
|
|
8384
|
-
if (!isSame(newState, _state.current)) {
|
|
8385
|
-
_state.current = newState;
|
|
8386
|
-
forceUpdate();
|
|
8387
|
-
}
|
|
8388
|
-
}, [state]);
|
|
8389
|
-
useFirstSkipEffect(function () {
|
|
8390
|
-
var newState = finalStateCallback ? finalStateCallback(_state.current) : _state.current;
|
|
8391
|
-
if (!isSame(newState, _state.current)) {
|
|
8392
|
-
_state.current = newState;
|
|
8393
|
-
forceUpdate();
|
|
8394
|
-
}
|
|
8395
|
-
}, [finalStateCallback]);
|
|
8396
|
-
var setState = React.useCallback(function (newState) {
|
|
8397
|
-
var finalNewState = typeof newState === 'function' ? newState(_state.current) : newState;
|
|
8398
|
-
if (!isSame(_state.current, finalNewState)) {
|
|
8399
|
-
_state.current = finalNewState;
|
|
8400
|
-
forceUpdate();
|
|
8401
|
-
}
|
|
8402
|
-
}, []);
|
|
8403
|
-
return [_state.current, setState];
|
|
8404
8342
|
}var StyledTableCell = material.styled(material.TableCell)(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n &.ellipsis {\n position: relative;\n max-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n"], ["\n &.ellipsis {\n position: relative;\n max-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n"])));
|
|
8405
8343
|
var TableCommonCell = function (_a) {
|
|
8406
8344
|
var children = _a.children, initClassName = _a.className, initStyle = _a.style, initSx = _a.sx, type = _a.type, column = _a.column, defaultAlign = _a.defaultAlign, initDefaultEllipsis = _a.defaultEllipsis, index = _a.index, item = _a.item, onClick = _a.onClick;
|
|
8407
|
-
var align =
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
var ellipsis = useAutoUpdateState(React.useCallback(function () {
|
|
8411
|
-
return column.ellipsis != null ? column.ellipsis : !!initDefaultEllipsis;
|
|
8412
|
-
}, [initDefaultEllipsis, column]))[0];
|
|
8413
|
-
var className = useAutoUpdateState(React.useCallback(function () {
|
|
8345
|
+
var align = React.useMemo(function () { return getTableColumnAlign(column, defaultAlign); }, [column, defaultAlign]);
|
|
8346
|
+
var ellipsis = React.useMemo(function () { return (column.ellipsis != null ? column.ellipsis : !!initDefaultEllipsis); }, [column, initDefaultEllipsis]);
|
|
8347
|
+
var className = React.useMemo(function () {
|
|
8414
8348
|
var _a, _b, _c, _d, _e, _f;
|
|
8415
8349
|
var className;
|
|
8416
8350
|
var getClassName;
|
|
@@ -8436,8 +8370,8 @@ var TableCommonCell = function (_a) {
|
|
|
8436
8370
|
else {
|
|
8437
8371
|
return initClassName;
|
|
8438
8372
|
}
|
|
8439
|
-
}, [
|
|
8440
|
-
var style =
|
|
8373
|
+
}, [column, index, initClassName, item, type]);
|
|
8374
|
+
var style = React.useMemo(function () {
|
|
8441
8375
|
var _a, _b, _c, _d, _e, _f;
|
|
8442
8376
|
var style;
|
|
8443
8377
|
var getStyle;
|
|
@@ -8458,8 +8392,8 @@ var TableCommonCell = function (_a) {
|
|
|
8458
8392
|
break;
|
|
8459
8393
|
}
|
|
8460
8394
|
return __assign$1(__assign$1(__assign$1(__assign$1({}, initStyle), { width: column.width, minWidth: column.minWidth, cursor: type === 'body' && (column.onClick || onClick) ? 'pointer' : undefined }), style), getStyle);
|
|
8461
|
-
}, [
|
|
8462
|
-
var sx =
|
|
8395
|
+
}, [column, index, initStyle, item, onClick, type]);
|
|
8396
|
+
var sx = React.useMemo(function () {
|
|
8463
8397
|
var _a, _b, _c, _d, _e, _f;
|
|
8464
8398
|
var sx;
|
|
8465
8399
|
var getSx;
|
|
@@ -8499,7 +8433,7 @@ var TableCommonCell = function (_a) {
|
|
|
8499
8433
|
}
|
|
8500
8434
|
}
|
|
8501
8435
|
}
|
|
8502
|
-
}, [
|
|
8436
|
+
}, [column, index, initSx, item, type]);
|
|
8503
8437
|
// Event Handler ---------------------------------------------------------------------------------------------------
|
|
8504
8438
|
var handleClick = React.useCallback(function (e) {
|
|
8505
8439
|
e.stopPropagation();
|
|
@@ -8520,9 +8454,9 @@ var TableCommonCell = function (_a) {
|
|
|
8520
8454
|
};
|
|
8521
8455
|
var templateObject_1$1;var StyledButtonsBox = material.styled(material.Box)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-wrap: wrap;\n gap: 5px;\n"], ["\n display: flex;\n flex-wrap: wrap;\n gap: 5px;\n"])));
|
|
8522
8456
|
var TableBodyCell = function (_a) {
|
|
8523
|
-
//
|
|
8457
|
+
// Memo --------------------------------------------------------------------------------------------------------------
|
|
8524
8458
|
var item = _a.item, index = _a.index, column = _a.column, defaultAlign = _a.defaultAlign, defaultEllipsis = _a.defaultEllipsis, onClick = _a.onClick;
|
|
8525
|
-
var buttonsBoxJustifyContent =
|
|
8459
|
+
var buttonsBoxJustifyContent = React.useMemo(function () {
|
|
8526
8460
|
switch (getTableColumnAlign(column, defaultAlign)) {
|
|
8527
8461
|
case 'center':
|
|
8528
8462
|
return 'center';
|
|
@@ -8531,7 +8465,8 @@ var TableBodyCell = function (_a) {
|
|
|
8531
8465
|
default:
|
|
8532
8466
|
return 'start';
|
|
8533
8467
|
}
|
|
8534
|
-
}, [column, defaultAlign])
|
|
8468
|
+
}, [column, defaultAlign]);
|
|
8469
|
+
// State -----------------------------------------------------------------------------------------------------------
|
|
8535
8470
|
var _b = React.useState(), data = _b[0], setData = _b[1];
|
|
8536
8471
|
// Effect ----------------------------------------------------------------------------------------------------------
|
|
8537
8472
|
React.useEffect(function () {
|
|
@@ -8593,6 +8528,7 @@ var TableBodyCell = function (_a) {
|
|
|
8593
8528
|
break;
|
|
8594
8529
|
}
|
|
8595
8530
|
setData(data);
|
|
8531
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8596
8532
|
}, [item, column]);
|
|
8597
8533
|
// Event Handler ---------------------------------------------------------------------------------------------------
|
|
8598
8534
|
var handleClick = React.useCallback(function (item, index) {
|
|
@@ -8625,22 +8561,21 @@ var TableBodyRow = function (_a) {
|
|
|
8625
8561
|
var style = _a.style,
|
|
8626
8562
|
//--------------------------------------------------------------------------------------------------------------------
|
|
8627
8563
|
id = _a.id, index = _a.index, defaultAlign = _a.defaultAlign, defaultEllipsis = _a.defaultEllipsis, sortable$1 = _a.sortable, columns = _a.columns, item = _a.item, onClick = _a.onClick, props = __rest$1(_a, ["style", "id", "index", "defaultAlign", "defaultEllipsis", "sortable", "columns", "item", "onClick"]);
|
|
8628
|
-
var
|
|
8629
|
-
var
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
}
|
|
8564
|
+
var _b = sortable.useSortable({ id: id }), attributes = _b.attributes, listeners = _b.listeners, setNodeRef = _b.setNodeRef, transform = _b.transform, transition = _b.transition;
|
|
8565
|
+
var finalStyle = React.useMemo(function () {
|
|
8566
|
+
return sortable$1
|
|
8567
|
+
? __assign$1(__assign$1({}, style), { transform: CSS.Transform.toString(transform), transition: transition }) : style;
|
|
8568
|
+
}, [sortable$1, style, transform, transition]);
|
|
8569
|
+
var sortableProps = React.useMemo(function () {
|
|
8570
|
+
return sortable$1
|
|
8571
|
+
? __assign$1(__assign$1({ ref: setNodeRef }, attributes), listeners) : {};
|
|
8572
|
+
}, [attributes, listeners, setNodeRef, sortable$1]);
|
|
8638
8573
|
return (React__default["default"].createElement(StyledBodyRow, __assign$1({ style: finalStyle }, props, sortableProps), columns.map(function (column, columnIdx) { return (React__default["default"].createElement(TableBodyCell, { key: columnIdx, index: index, item: item, defaultAlign: defaultAlign, defaultEllipsis: defaultEllipsis, column: column, onClick: onClick })); })));
|
|
8639
8574
|
};
|
|
8640
8575
|
TableBodyRow.displayName = 'TableBodyRow';
|
|
8641
8576
|
TableBodyRow.defaultProps = TableBodyRowDefaultProps;var TableHeadCell = function (_a) {
|
|
8642
8577
|
var column = _a.column, defaultAlign = _a.defaultAlign;
|
|
8643
|
-
var data =
|
|
8578
|
+
var data = React.useMemo(function () {
|
|
8644
8579
|
var _a, _b;
|
|
8645
8580
|
if ((_a = column.head) === null || _a === void 0 ? void 0 : _a.onRender) {
|
|
8646
8581
|
return (_b = column.head) === null || _b === void 0 ? void 0 : _b.onRender();
|
|
@@ -8648,11 +8583,11 @@ TableBodyRow.defaultProps = TableBodyRowDefaultProps;var TableHeadCell = functio
|
|
|
8648
8583
|
else {
|
|
8649
8584
|
return column.label;
|
|
8650
8585
|
}
|
|
8651
|
-
}, [column])
|
|
8586
|
+
}, [column]);
|
|
8652
8587
|
return (React__default["default"].createElement(TableCommonCell, { type: 'head', className: 'TableHeadCell', column: column, defaultAlign: defaultAlign }, data));
|
|
8653
8588
|
};var TableFooterCell = function (_a) {
|
|
8654
8589
|
var column = _a.column, defaultAlign = _a.defaultAlign;
|
|
8655
|
-
var data =
|
|
8590
|
+
var data = React.useMemo(function () {
|
|
8656
8591
|
var _a, _b, _c;
|
|
8657
8592
|
if ((_a = column.footer) === null || _a === void 0 ? void 0 : _a.onRender) {
|
|
8658
8593
|
return (_b = column.footer) === null || _b === void 0 ? void 0 : _b.onRender();
|
|
@@ -8660,7 +8595,7 @@ TableBodyRow.defaultProps = TableBodyRowDefaultProps;var TableHeadCell = functio
|
|
|
8660
8595
|
else {
|
|
8661
8596
|
return (_c = column.footer) === null || _c === void 0 ? void 0 : _c.value;
|
|
8662
8597
|
}
|
|
8663
|
-
}, [column])
|
|
8598
|
+
}, [column]);
|
|
8664
8599
|
return (React__default["default"].createElement(TableCommonCell, { type: 'head', className: 'TableFooterCell', column: column, defaultAlign: defaultAlign, style: { borderTop: '1px solid rgba(224, 224, 224, 1)' } }, data));
|
|
8665
8600
|
};var TablePagination = function (_a) {
|
|
8666
8601
|
var className = _a.className, style = _a.style, sx = _a.sx, paging = _a.paging, align = _a.align, onChange = _a.onChange;
|
|
@@ -8669,7 +8604,69 @@ TableBodyRow.defaultProps = TableBodyRowDefaultProps;var TableHeadCell = functio
|
|
|
8669
8604
|
if (onChange)
|
|
8670
8605
|
onChange(page);
|
|
8671
8606
|
} })));
|
|
8672
|
-
};function
|
|
8607
|
+
};var isSame = function (v1, v2) {
|
|
8608
|
+
if (v1 === v2)
|
|
8609
|
+
return true;
|
|
8610
|
+
if (typeof v1 !== typeof v2)
|
|
8611
|
+
return false;
|
|
8612
|
+
if (v1 == null || v2 == null)
|
|
8613
|
+
return false;
|
|
8614
|
+
if (Array.isArray(v1) && Array.isArray(v2)) {
|
|
8615
|
+
if (v1.length !== v2.length)
|
|
8616
|
+
return false;
|
|
8617
|
+
for (var i = 0; i < v1.length; i += 1) {
|
|
8618
|
+
if (v1[i] !== v2[i])
|
|
8619
|
+
return false;
|
|
8620
|
+
}
|
|
8621
|
+
}
|
|
8622
|
+
else {
|
|
8623
|
+
return v1 === v2;
|
|
8624
|
+
}
|
|
8625
|
+
return true;
|
|
8626
|
+
};function useFirstSkipLayoutEffect(effect, deps) {
|
|
8627
|
+
var firstRef = React.useRef(true);
|
|
8628
|
+
React.useLayoutEffect(function () {
|
|
8629
|
+
if (firstRef.current) {
|
|
8630
|
+
firstRef.current = false;
|
|
8631
|
+
}
|
|
8632
|
+
else {
|
|
8633
|
+
effect();
|
|
8634
|
+
}
|
|
8635
|
+
}, deps);
|
|
8636
|
+
}function useAutoUpdateLayoutState(p1, p2) {
|
|
8637
|
+
var state = typeof p1 === 'function' ? undefined : p1;
|
|
8638
|
+
var finalStateCallback = typeof p1 === 'function' ? p1 : p2;
|
|
8639
|
+
var _a = React.useState(0), setUpdateKey = _a[1];
|
|
8640
|
+
var _initState = React.useState(function () {
|
|
8641
|
+
return finalStateCallback ? finalStateCallback(state, 0) : state;
|
|
8642
|
+
})[0];
|
|
8643
|
+
var _state = React.useRef(_initState);
|
|
8644
|
+
var forceUpdate = React.useCallback(function () {
|
|
8645
|
+
setUpdateKey(function (updateKey) { return updateKey + 1; });
|
|
8646
|
+
}, []);
|
|
8647
|
+
useFirstSkipLayoutEffect(function () {
|
|
8648
|
+
var newState = finalStateCallback ? finalStateCallback(state) : state;
|
|
8649
|
+
if (!isSame(newState, _state.current)) {
|
|
8650
|
+
_state.current = newState;
|
|
8651
|
+
forceUpdate();
|
|
8652
|
+
}
|
|
8653
|
+
}, [state]);
|
|
8654
|
+
useFirstSkipLayoutEffect(function () {
|
|
8655
|
+
var newState = finalStateCallback ? finalStateCallback(_state.current) : _state.current;
|
|
8656
|
+
if (!isSame(newState, _state.current)) {
|
|
8657
|
+
_state.current = newState;
|
|
8658
|
+
forceUpdate();
|
|
8659
|
+
}
|
|
8660
|
+
}, [finalStateCallback]);
|
|
8661
|
+
var setState = React.useCallback(function (newState) {
|
|
8662
|
+
var finalNewState = typeof newState === 'function' ? newState(_state.current) : newState;
|
|
8663
|
+
if (!isSame(_state.current, finalNewState)) {
|
|
8664
|
+
_state.current = finalNewState;
|
|
8665
|
+
forceUpdate();
|
|
8666
|
+
}
|
|
8667
|
+
}, []);
|
|
8668
|
+
return [_state.current, setState];
|
|
8669
|
+
}function styleInject(css, ref) {
|
|
8673
8670
|
if ( ref === void 0 ) ref = {};
|
|
8674
8671
|
var insertAt = ref.insertAt;
|
|
8675
8672
|
|
|
@@ -8730,12 +8727,13 @@ var Table = React__default["default"].forwardRef(function (_a, ref) {
|
|
|
8730
8727
|
},
|
|
8731
8728
|
}).ref;
|
|
8732
8729
|
// State -----------------------------------------------------------------------------------------------------------
|
|
8733
|
-
var _c =
|
|
8730
|
+
var _c = useAutoUpdateLayoutState(initColumns), columns = _c[0], setColumns = _c[1];
|
|
8734
8731
|
var _d = React.useState(), finalColumns = _d[0], setFinalColumns = _d[1];
|
|
8735
|
-
var _e =
|
|
8732
|
+
var _e = useAutoUpdateLayoutState(initItems), items = _e[0], setItems = _e[1];
|
|
8736
8733
|
var _f = React.useState(), sortableItems = _f[0], setSortableItems = _f[1];
|
|
8737
|
-
var _g =
|
|
8738
|
-
|
|
8734
|
+
var _g = useAutoUpdateLayoutState(initPaging), paging = _g[0], setPaging = _g[1];
|
|
8735
|
+
// Memo --------------------------------------------------------------------------------------------------------------
|
|
8736
|
+
var tableSx = React.useMemo(function () {
|
|
8739
8737
|
var sx = {
|
|
8740
8738
|
padding: typeof cellPadding === 'number' ? "".concat(cellPadding, "px") : cellPadding,
|
|
8741
8739
|
};
|
|
@@ -8744,7 +8742,7 @@ var Table = React__default["default"].forwardRef(function (_a, ref) {
|
|
|
8744
8742
|
'> .MuiTableBody-root > .MuiTableRow-root > .MuiTableCell-root ': sx,
|
|
8745
8743
|
'> .MuiTableFooter-root > .MuiTableRow-root > .MuiTableCell-root ': sx,
|
|
8746
8744
|
};
|
|
8747
|
-
}, [cellPadding])
|
|
8745
|
+
}, [cellPadding]);
|
|
8748
8746
|
// Function --------------------------------------------------------------------------------------------------------
|
|
8749
8747
|
var makeSortableItems = React.useCallback(function (items) {
|
|
8750
8748
|
return items === null || items === void 0 ? void 0 : items.map(function (_a, index) {
|
|
@@ -8755,6 +8753,7 @@ var Table = React__default["default"].forwardRef(function (_a, ref) {
|
|
|
8755
8753
|
// Effect ----------------------------------------------------------------------------------------------------------
|
|
8756
8754
|
React.useEffect(function () {
|
|
8757
8755
|
setSortableItems(makeSortableItems(items));
|
|
8756
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8758
8757
|
}, [items]);
|
|
8759
8758
|
React.useEffect(function () {
|
|
8760
8759
|
setFinalColumns(columns === null || columns === void 0 ? void 0 : columns.filter(columnFilter));
|
|
@@ -8790,7 +8789,7 @@ var Table = React__default["default"].forwardRef(function (_a, ref) {
|
|
|
8790
8789
|
ref.current = commands;
|
|
8791
8790
|
}
|
|
8792
8791
|
}
|
|
8793
|
-
}, [ref, columns, items, paging, makeSortableItems]);
|
|
8792
|
+
}, [ref, columns, items, paging, makeSortableItems, setColumns, setItems, setPaging]);
|
|
8794
8793
|
// Event Handler ---------------------------------------------------------------------------------------------------
|
|
8795
8794
|
var handleDragEnd = React.useCallback(function (event) {
|
|
8796
8795
|
var active = event.active, over = event.over;
|
|
@@ -8889,6 +8888,7 @@ Table.defaultProps = TableDefaultProps;var SearchTableDefaultProps = {};var Sear
|
|
|
8889
8888
|
else {
|
|
8890
8889
|
setSearchInfo(getSearchInfo(search));
|
|
8891
8890
|
}
|
|
8891
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8892
8892
|
}, [search]);
|
|
8893
8893
|
// tableInfo -------------------------------------------------------------------------------------------------------
|
|
8894
8894
|
var tableInfoFirstUseEffect = React.useRef(true);
|
|
@@ -8900,6 +8900,7 @@ Table.defaultProps = TableDefaultProps;var SearchTableDefaultProps = {};var Sear
|
|
|
8900
8900
|
else {
|
|
8901
8901
|
setTableInfo(getTableInfo(table));
|
|
8902
8902
|
}
|
|
8903
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8903
8904
|
}, [table]);
|
|
8904
8905
|
// Function - getData ----------------------------------------------------------------------------------------------
|
|
8905
8906
|
var getData = React.useCallback(function (data) {
|
|
@@ -8908,44 +8909,7 @@ Table.defaultProps = TableDefaultProps;var SearchTableDefaultProps = {};var Sear
|
|
|
8908
8909
|
onGetData(data).then(setTableData);
|
|
8909
8910
|
}
|
|
8910
8911
|
}, [onGetData]);
|
|
8911
|
-
//
|
|
8912
|
-
React.useLayoutEffect(function () {
|
|
8913
|
-
if (ref) {
|
|
8914
|
-
var commands = {
|
|
8915
|
-
reload: function (page) {
|
|
8916
|
-
var _a, _b, _c;
|
|
8917
|
-
var finalData;
|
|
8918
|
-
if (lastGetDataDataRef.current) {
|
|
8919
|
-
finalData = __assign$1({}, lastGetDataDataRef.current);
|
|
8920
|
-
if (page != null) {
|
|
8921
|
-
(_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.setValue('page', page);
|
|
8922
|
-
finalData.page = page;
|
|
8923
|
-
}
|
|
8924
|
-
}
|
|
8925
|
-
else {
|
|
8926
|
-
if (hash) {
|
|
8927
|
-
hashToSearchValue();
|
|
8928
|
-
}
|
|
8929
|
-
if (page != null) {
|
|
8930
|
-
(_b = searchRef.current) === null || _b === void 0 ? void 0 : _b.setValue('page', page);
|
|
8931
|
-
}
|
|
8932
|
-
finalData = ((_c = searchRef.current) === null || _c === void 0 ? void 0 : _c.getAllFormValue()) || {};
|
|
8933
|
-
}
|
|
8934
|
-
getData(finalData);
|
|
8935
|
-
},
|
|
8936
|
-
getLastLoadData: function () { return lastGetDataDataRef.current || {}; },
|
|
8937
|
-
getSearch: function () { return searchRef.current; },
|
|
8938
|
-
getTable: function () { return tableRef.current; },
|
|
8939
|
-
};
|
|
8940
|
-
if (typeof ref === 'function') {
|
|
8941
|
-
ref(commands);
|
|
8942
|
-
}
|
|
8943
|
-
else {
|
|
8944
|
-
ref.current = commands;
|
|
8945
|
-
}
|
|
8946
|
-
}
|
|
8947
|
-
}, [ref, hash, lastGetDataDataRef, searchRef, tableRef, getData]);
|
|
8948
|
-
//--------------------------------------------------------------------------------------------------------------------
|
|
8912
|
+
// Function ----------------------------------------------------------------------------------------------------------
|
|
8949
8913
|
var deHash = React.useCallback(function () {
|
|
8950
8914
|
var values = {};
|
|
8951
8915
|
var hash = window.location.hash.substring(1);
|
|
@@ -8954,13 +8918,14 @@ Table.defaultProps = TableDefaultProps;var SearchTableDefaultProps = {};var Sear
|
|
|
8954
8918
|
return substring;
|
|
8955
8919
|
});
|
|
8956
8920
|
return values;
|
|
8957
|
-
}, [
|
|
8921
|
+
}, []);
|
|
8958
8922
|
var hashToSearchValue = React.useCallback(function () {
|
|
8959
8923
|
var commands = searchRef.current;
|
|
8960
8924
|
if (commands) {
|
|
8961
8925
|
commands.resetAll();
|
|
8962
8926
|
var hashValues_1 = deHash();
|
|
8963
8927
|
Object.keys(hashValues_1).forEach(function (name) {
|
|
8928
|
+
var _a, _b;
|
|
8964
8929
|
var value = hashValues_1[name];
|
|
8965
8930
|
if (name === 'page') {
|
|
8966
8931
|
commands.setValue(name, Number(value) || 1);
|
|
@@ -8969,6 +8934,17 @@ Table.defaultProps = TableDefaultProps;var SearchTableDefaultProps = {};var Sear
|
|
|
8969
8934
|
var itemCommands = commands.getItem(name);
|
|
8970
8935
|
if (itemCommands) {
|
|
8971
8936
|
switch (itemCommands.getType()) {
|
|
8937
|
+
case 'FormCheckbox':
|
|
8938
|
+
if (notEmpty(value)) {
|
|
8939
|
+
var checkCommands = itemCommands;
|
|
8940
|
+
if (value.toString() === ((_a = itemCommands.getValue()) === null || _a === void 0 ? void 0 : _a.toString())) {
|
|
8941
|
+
checkCommands.setChecked(true);
|
|
8942
|
+
}
|
|
8943
|
+
else if (value.toString() === ((_b = checkCommands.getUncheckedValue()) === null || _b === void 0 ? void 0 : _b.toString())) {
|
|
8944
|
+
checkCommands.setChecked(false);
|
|
8945
|
+
}
|
|
8946
|
+
}
|
|
8947
|
+
break;
|
|
8972
8948
|
case 'FormDatePicker':
|
|
8973
8949
|
case 'FormDateTimePicker':
|
|
8974
8950
|
case 'FormTimePicker':
|
|
@@ -9021,13 +8997,51 @@ Table.defaultProps = TableDefaultProps;var SearchTableDefaultProps = {};var Sear
|
|
|
9021
8997
|
return commands.getAllFormValue();
|
|
9022
8998
|
}
|
|
9023
8999
|
}, [searchRef, deHash]);
|
|
9024
|
-
|
|
9000
|
+
// Commands --------------------------------------------------------------------------------------------------------
|
|
9001
|
+
React.useLayoutEffect(function () {
|
|
9002
|
+
if (ref) {
|
|
9003
|
+
var commands = {
|
|
9004
|
+
reload: function (page) {
|
|
9005
|
+
var _a, _b, _c;
|
|
9006
|
+
var finalData;
|
|
9007
|
+
if (lastGetDataDataRef.current) {
|
|
9008
|
+
finalData = __assign$1({}, lastGetDataDataRef.current);
|
|
9009
|
+
if (page != null) {
|
|
9010
|
+
(_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.setValue('page', page);
|
|
9011
|
+
finalData.page = page;
|
|
9012
|
+
}
|
|
9013
|
+
}
|
|
9014
|
+
else {
|
|
9015
|
+
if (hash) {
|
|
9016
|
+
hashToSearchValue();
|
|
9017
|
+
}
|
|
9018
|
+
if (page != null) {
|
|
9019
|
+
(_b = searchRef.current) === null || _b === void 0 ? void 0 : _b.setValue('page', page);
|
|
9020
|
+
}
|
|
9021
|
+
finalData = ((_c = searchRef.current) === null || _c === void 0 ? void 0 : _c.getAllFormValue()) || {};
|
|
9022
|
+
}
|
|
9023
|
+
getData(finalData);
|
|
9024
|
+
},
|
|
9025
|
+
getLastLoadData: function () { return lastGetDataDataRef.current || {}; },
|
|
9026
|
+
getSearch: function () { return searchRef.current; },
|
|
9027
|
+
getTable: function () { return tableRef.current; },
|
|
9028
|
+
};
|
|
9029
|
+
if (typeof ref === 'function') {
|
|
9030
|
+
ref(commands);
|
|
9031
|
+
}
|
|
9032
|
+
else {
|
|
9033
|
+
ref.current = commands;
|
|
9034
|
+
}
|
|
9035
|
+
}
|
|
9036
|
+
}, [ref, hash, lastGetDataDataRef, searchRef, tableRef, getData, hashToSearchValue]);
|
|
9037
|
+
//--------------------------------------------------------------------------------------------------------------------
|
|
9025
9038
|
React.useEffect(function () {
|
|
9026
9039
|
if (hash) {
|
|
9027
9040
|
var data = hashToSearchValue();
|
|
9028
9041
|
if (data)
|
|
9029
9042
|
getData(data);
|
|
9030
9043
|
}
|
|
9044
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
9031
9045
|
}, [window.location.hash]);
|
|
9032
9046
|
//--------------------------------------------------------------------------------------------------------------------
|
|
9033
9047
|
var hashChange = React.useCallback(function (params) {
|
|
@@ -9153,21 +9167,16 @@ SearchTable.defaultProps = SearchTableDefaultProps;var TableButtonDefaultProps =
|
|
|
9153
9167
|
variant: 'outlined',
|
|
9154
9168
|
color: 'primary',
|
|
9155
9169
|
};var TableIconDefaultProps = {};var TableIcon = React__default["default"].forwardRef(function (_a, ref) {
|
|
9156
|
-
//
|
|
9170
|
+
// Memo --------------------------------------------------------------------------------------------------------------
|
|
9157
9171
|
var className = _a.className, initChildren = _a.children, props = __rest$1(_a, ["className", "children"]);
|
|
9158
|
-
var children =
|
|
9159
|
-
return initChildren.replace(/[A-Z]/g, function (letter, idx) { return "".concat(idx > 0 ? '_' : '').concat(letter.toLowerCase()); });
|
|
9160
|
-
}, [initChildren]))[0];
|
|
9172
|
+
var children = React.useMemo(function () { return initChildren.replace(/[A-Z]/g, function (letter, idx) { return "".concat(idx > 0 ? '_' : '').concat(letter.toLowerCase()); }); }, [initChildren]);
|
|
9161
9173
|
// Render ----------------------------------------------------------------------------------------------------------
|
|
9162
9174
|
return (React__default["default"].createElement(material.Icon, __assign$1({ ref: ref }, props, { className: classNames('TableIcon', className) }), children));
|
|
9163
9175
|
});
|
|
9164
9176
|
TableIcon.displayName = 'TableIcon';
|
|
9165
9177
|
TableIcon.defaultProps = TableIconDefaultProps;var TableButton = React__default["default"].forwardRef(function (_a, ref) {
|
|
9166
|
-
// State -----------------------------------------------------------------------------------------------------------
|
|
9167
9178
|
var children = _a.children, className = _a.className, initSx = _a.sx, color = _a.color, icon = _a.icon, startIcon = _a.startIcon, endIcon = _a.endIcon, onClick = _a.onClick, props = __rest$1(_a, ["children", "className", "sx", "color", "icon", "startIcon", "endIcon", "onClick"]);
|
|
9168
|
-
var sx =
|
|
9169
|
-
return __assign$1({ minWidth: 0, px: !startIcon && !endIcon ? 0.7 : 1.7 }, initSx);
|
|
9170
|
-
}, [initSx]))[0];
|
|
9179
|
+
var sx = React.useMemo(function () { return (__assign$1({ minWidth: 0, px: !startIcon && !endIcon ? 0.7 : 1.7 }, initSx)); }, [endIcon, initSx, startIcon]);
|
|
9171
9180
|
// Render ----------------------------------------------------------------------------------------------------------
|
|
9172
9181
|
return (React__default["default"].createElement(material.Button, __assign$1({ ref: ref, className: classNames(className, 'TableButton'), type: 'button', size: 'small', sx: sx, color: color, onClick: onClick, startIcon: startIcon ? (React__default["default"].createElement(TableIcon, { fontSize: 'small', sx: { mr: -0.5 } }, startIcon)) : undefined, endIcon: endIcon ? (React__default["default"].createElement(TableIcon, { fontSize: 'small', sx: { ml: -0.5 } }, endIcon)) : undefined }, props),
|
|
9173
9182
|
icon && (React__default["default"].createElement(TableIcon, { fontSize: 'small', color: color }, icon)),
|