@pdg/react-table 1.0.124 → 1.0.126
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 +30 -25
- package/dist/index.js +30 -25
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1359,21 +1359,21 @@ var deHash = function () {
|
|
|
1359
1359
|
/********************************************************************************************************************
|
|
1360
1360
|
* Ref
|
|
1361
1361
|
* ******************************************************************************************************************/
|
|
1362
|
-
var _b, _c;
|
|
1363
1362
|
var className = _a.className, initStyle = _a.style, sx = _a.sx, color = _a.color, hash = _a.hash, stickyHeader = _a.stickyHeader, fullHeight = _a.fullHeight, search = _a.search, table = _a.table, betweenSearchTableComponent = _a.betweenSearchTableComponent, onGetData = _a.onGetData, onRequestHashChange = _a.onRequestHashChange;
|
|
1363
|
+
var initPathRef = useRef(window.location.pathname);
|
|
1364
1364
|
var searchRef = useRef(undefined);
|
|
1365
1365
|
var tableRef = useRef(undefined);
|
|
1366
1366
|
var lastGetDataDataRef = useRef({});
|
|
1367
1367
|
/********************************************************************************************************************
|
|
1368
1368
|
* State
|
|
1369
1369
|
* ******************************************************************************************************************/
|
|
1370
|
-
var
|
|
1371
|
-
var
|
|
1370
|
+
var _b = useState(true), isFirstSearchSubmit = _b[0], setIsFirstSearchSubmit = _b[1];
|
|
1371
|
+
var _c = useState(), tableData = _c[0], setTableData = _c[1];
|
|
1372
1372
|
/********************************************************************************************************************
|
|
1373
1373
|
* searchInfo
|
|
1374
1374
|
* ******************************************************************************************************************/
|
|
1375
1375
|
var searchInfoFirstUseEffect = useRef(true);
|
|
1376
|
-
var
|
|
1376
|
+
var _d = useState(function () { return getSearchInfo(search); }), searchInfo = _d[0], setSearchInfo = _d[1];
|
|
1377
1377
|
useEffect(function () {
|
|
1378
1378
|
if (searchInfoFirstUseEffect.current) {
|
|
1379
1379
|
searchInfoFirstUseEffect.current = false;
|
|
@@ -1386,7 +1386,7 @@ var deHash = function () {
|
|
|
1386
1386
|
* tableInfo
|
|
1387
1387
|
* ******************************************************************************************************************/
|
|
1388
1388
|
var tableInfoFirstUseEffect = useRef(true);
|
|
1389
|
-
var
|
|
1389
|
+
var _e = useState(function () { return getTableInfo(table); }), tableInfo = _e[0], setTableInfo = _e[1];
|
|
1390
1390
|
useEffect(function () {
|
|
1391
1391
|
if (tableInfoFirstUseEffect.current) {
|
|
1392
1392
|
tableInfoFirstUseEffect.current = false;
|
|
@@ -1574,7 +1574,7 @@ var deHash = function () {
|
|
|
1574
1574
|
* hash
|
|
1575
1575
|
* ******************************************************************************************************************/
|
|
1576
1576
|
useEffect(function () {
|
|
1577
|
-
if (hash) {
|
|
1577
|
+
if (hash && window.location.pathname === initPathRef.current) {
|
|
1578
1578
|
var data = hashToSearchValue();
|
|
1579
1579
|
if (data)
|
|
1580
1580
|
getData(data);
|
|
@@ -1720,25 +1720,25 @@ var deHash = function () {
|
|
|
1720
1720
|
/********************************************************************************************************************
|
|
1721
1721
|
* Render
|
|
1722
1722
|
* ******************************************************************************************************************/
|
|
1723
|
-
return (React.createElement(Grid, {
|
|
1724
|
-
React.createElement(
|
|
1725
|
-
|
|
1726
|
-
if (searchInfo.ref) {
|
|
1727
|
-
|
|
1728
|
-
searchInfo.ref(commands);
|
|
1729
|
-
}
|
|
1730
|
-
else {
|
|
1731
|
-
searchInfo.ref.current = commands;
|
|
1732
|
-
}
|
|
1723
|
+
var searchView = useMemo(function () { return (React.createElement(Grid, { sx: { display: searchInfo.searchGroups ? undefined : 'none' } },
|
|
1724
|
+
React.createElement(Search, __assign({ color: color }, searchInfo.props, { ref: function (commands) {
|
|
1725
|
+
if (searchInfo.ref) {
|
|
1726
|
+
if (typeof searchInfo.ref === 'function') {
|
|
1727
|
+
searchInfo.ref(commands);
|
|
1733
1728
|
}
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1729
|
+
else {
|
|
1730
|
+
searchInfo.ref.current = commands;
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
searchRef.current = commands || undefined;
|
|
1734
|
+
}, autoSubmit: true, onSubmit: handleSearchSubmit }),
|
|
1735
|
+
React.createElement(SearchGroup, { hidden: true },
|
|
1736
|
+
React.createElement(FormHidden, { name: 'page', value: 1 })),
|
|
1737
|
+
searchInfo.searchGroups))); }, [color, handleSearchSubmit, searchInfo]);
|
|
1738
|
+
var tableView = useMemo(function () {
|
|
1739
|
+
var _a, _b;
|
|
1740
|
+
return (React.createElement(Grid, { style: fullHeight ? { flex: 1, display: 'flex', flexDirection: 'column' } : undefined },
|
|
1741
|
+
React.createElement(Table, __assign({}, tableInfo.props, { stickyHeader: stickyHeader || ((_a = tableInfo.props) === null || _a === void 0 ? void 0 : _a.stickyHeader), fullHeight: fullHeight || ((_b = tableInfo.props) === null || _b === void 0 ? void 0 : _b.fullHeight), ref: function (commands) {
|
|
1742
1742
|
if (tableInfo.ref) {
|
|
1743
1743
|
if (typeof tableInfo.ref === 'function') {
|
|
1744
1744
|
tableInfo.ref(commands);
|
|
@@ -1748,7 +1748,12 @@ var deHash = function () {
|
|
|
1748
1748
|
}
|
|
1749
1749
|
}
|
|
1750
1750
|
tableRef.current = commands || undefined;
|
|
1751
|
-
}, items: tableData === null || tableData === void 0 ? void 0 : tableData.items, paging: tableData === null || tableData === void 0 ? void 0 : tableData.paging, onPageChange: handlePageChange }))))
|
|
1751
|
+
}, items: tableData === null || tableData === void 0 ? void 0 : tableData.items, paging: tableData === null || tableData === void 0 ? void 0 : tableData.paging, onPageChange: handlePageChange }))));
|
|
1752
|
+
}, [fullHeight, handlePageChange, stickyHeader, tableData === null || tableData === void 0 ? void 0 : tableData.items, tableData === null || tableData === void 0 ? void 0 : tableData.paging, tableInfo]);
|
|
1753
|
+
return (React.createElement(Grid, { container: true, direction: 'column', spacing: 1, className: classNames('SearchTable', className), style: fullHeight ? __assign(__assign({}, initStyle), { flex: 1, display: 'flex' }) : initStyle, sx: sx },
|
|
1754
|
+
searchView,
|
|
1755
|
+
betweenSearchTableComponent && React.createElement(Grid, null, betweenSearchTableComponent),
|
|
1756
|
+
tableView));
|
|
1752
1757
|
});var TableButton = React.forwardRef(function (_a, ref) {
|
|
1753
1758
|
var children = _a.children, className = _a.className, initSx = _a.sx, _b = _a.variant, variant = _b === void 0 ? 'outlined' : _b, _c = _a.color, color = _c === void 0 ? 'primary' : _c, startIcon = _a.startIcon, endIcon = _a.endIcon, onClick = _a.onClick, props = __rest(_a, ["children", "className", "sx", "variant", "color", "startIcon", "endIcon", "onClick"]);
|
|
1754
1759
|
return (React.createElement(PdgButton, __assign({ ref: ref, className: classNames(className, 'TableButton'), variant: variant, type: 'button', size: 'small', sx: __assign({ minWidth: 0, px: empty(startIcon) && empty(endIcon)
|
package/dist/index.js
CHANGED
|
@@ -1359,21 +1359,21 @@ var deHash = function () {
|
|
|
1359
1359
|
/********************************************************************************************************************
|
|
1360
1360
|
* Ref
|
|
1361
1361
|
* ******************************************************************************************************************/
|
|
1362
|
-
var _b, _c;
|
|
1363
1362
|
var className = _a.className, initStyle = _a.style, sx = _a.sx, color = _a.color, hash = _a.hash, stickyHeader = _a.stickyHeader, fullHeight = _a.fullHeight, search = _a.search, table = _a.table, betweenSearchTableComponent = _a.betweenSearchTableComponent, onGetData = _a.onGetData, onRequestHashChange = _a.onRequestHashChange;
|
|
1363
|
+
var initPathRef = React.useRef(window.location.pathname);
|
|
1364
1364
|
var searchRef = React.useRef(undefined);
|
|
1365
1365
|
var tableRef = React.useRef(undefined);
|
|
1366
1366
|
var lastGetDataDataRef = React.useRef({});
|
|
1367
1367
|
/********************************************************************************************************************
|
|
1368
1368
|
* State
|
|
1369
1369
|
* ******************************************************************************************************************/
|
|
1370
|
-
var
|
|
1371
|
-
var
|
|
1370
|
+
var _b = React.useState(true), isFirstSearchSubmit = _b[0], setIsFirstSearchSubmit = _b[1];
|
|
1371
|
+
var _c = React.useState(), tableData = _c[0], setTableData = _c[1];
|
|
1372
1372
|
/********************************************************************************************************************
|
|
1373
1373
|
* searchInfo
|
|
1374
1374
|
* ******************************************************************************************************************/
|
|
1375
1375
|
var searchInfoFirstUseEffect = React.useRef(true);
|
|
1376
|
-
var
|
|
1376
|
+
var _d = React.useState(function () { return getSearchInfo(search); }), searchInfo = _d[0], setSearchInfo = _d[1];
|
|
1377
1377
|
React.useEffect(function () {
|
|
1378
1378
|
if (searchInfoFirstUseEffect.current) {
|
|
1379
1379
|
searchInfoFirstUseEffect.current = false;
|
|
@@ -1386,7 +1386,7 @@ var deHash = function () {
|
|
|
1386
1386
|
* tableInfo
|
|
1387
1387
|
* ******************************************************************************************************************/
|
|
1388
1388
|
var tableInfoFirstUseEffect = React.useRef(true);
|
|
1389
|
-
var
|
|
1389
|
+
var _e = React.useState(function () { return getTableInfo(table); }), tableInfo = _e[0], setTableInfo = _e[1];
|
|
1390
1390
|
React.useEffect(function () {
|
|
1391
1391
|
if (tableInfoFirstUseEffect.current) {
|
|
1392
1392
|
tableInfoFirstUseEffect.current = false;
|
|
@@ -1574,7 +1574,7 @@ var deHash = function () {
|
|
|
1574
1574
|
* hash
|
|
1575
1575
|
* ******************************************************************************************************************/
|
|
1576
1576
|
React.useEffect(function () {
|
|
1577
|
-
if (hash) {
|
|
1577
|
+
if (hash && window.location.pathname === initPathRef.current) {
|
|
1578
1578
|
var data = hashToSearchValue();
|
|
1579
1579
|
if (data)
|
|
1580
1580
|
getData(data);
|
|
@@ -1720,25 +1720,25 @@ var deHash = function () {
|
|
|
1720
1720
|
/********************************************************************************************************************
|
|
1721
1721
|
* Render
|
|
1722
1722
|
* ******************************************************************************************************************/
|
|
1723
|
-
return (React.createElement(material.Grid, {
|
|
1724
|
-
React.createElement(
|
|
1725
|
-
|
|
1726
|
-
if (searchInfo.ref) {
|
|
1727
|
-
|
|
1728
|
-
searchInfo.ref(commands);
|
|
1729
|
-
}
|
|
1730
|
-
else {
|
|
1731
|
-
searchInfo.ref.current = commands;
|
|
1732
|
-
}
|
|
1723
|
+
var searchView = React.useMemo(function () { return (React.createElement(material.Grid, { sx: { display: searchInfo.searchGroups ? undefined : 'none' } },
|
|
1724
|
+
React.createElement(reactForm.Search, __assign({ color: color }, searchInfo.props, { ref: function (commands) {
|
|
1725
|
+
if (searchInfo.ref) {
|
|
1726
|
+
if (typeof searchInfo.ref === 'function') {
|
|
1727
|
+
searchInfo.ref(commands);
|
|
1733
1728
|
}
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1729
|
+
else {
|
|
1730
|
+
searchInfo.ref.current = commands;
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
searchRef.current = commands || undefined;
|
|
1734
|
+
}, autoSubmit: true, onSubmit: handleSearchSubmit }),
|
|
1735
|
+
React.createElement(reactForm.SearchGroup, { hidden: true },
|
|
1736
|
+
React.createElement(reactForm.FormHidden, { name: 'page', value: 1 })),
|
|
1737
|
+
searchInfo.searchGroups))); }, [color, handleSearchSubmit, searchInfo]);
|
|
1738
|
+
var tableView = React.useMemo(function () {
|
|
1739
|
+
var _a, _b;
|
|
1740
|
+
return (React.createElement(material.Grid, { style: fullHeight ? { flex: 1, display: 'flex', flexDirection: 'column' } : undefined },
|
|
1741
|
+
React.createElement(Table, __assign({}, tableInfo.props, { stickyHeader: stickyHeader || ((_a = tableInfo.props) === null || _a === void 0 ? void 0 : _a.stickyHeader), fullHeight: fullHeight || ((_b = tableInfo.props) === null || _b === void 0 ? void 0 : _b.fullHeight), ref: function (commands) {
|
|
1742
1742
|
if (tableInfo.ref) {
|
|
1743
1743
|
if (typeof tableInfo.ref === 'function') {
|
|
1744
1744
|
tableInfo.ref(commands);
|
|
@@ -1748,7 +1748,12 @@ var deHash = function () {
|
|
|
1748
1748
|
}
|
|
1749
1749
|
}
|
|
1750
1750
|
tableRef.current = commands || undefined;
|
|
1751
|
-
}, items: tableData === null || tableData === void 0 ? void 0 : tableData.items, paging: tableData === null || tableData === void 0 ? void 0 : tableData.paging, onPageChange: handlePageChange }))))
|
|
1751
|
+
}, items: tableData === null || tableData === void 0 ? void 0 : tableData.items, paging: tableData === null || tableData === void 0 ? void 0 : tableData.paging, onPageChange: handlePageChange }))));
|
|
1752
|
+
}, [fullHeight, handlePageChange, stickyHeader, tableData === null || tableData === void 0 ? void 0 : tableData.items, tableData === null || tableData === void 0 ? void 0 : tableData.paging, tableInfo]);
|
|
1753
|
+
return (React.createElement(material.Grid, { container: true, direction: 'column', spacing: 1, className: classNames('SearchTable', className), style: fullHeight ? __assign(__assign({}, initStyle), { flex: 1, display: 'flex' }) : initStyle, sx: sx },
|
|
1754
|
+
searchView,
|
|
1755
|
+
betweenSearchTableComponent && React.createElement(material.Grid, null, betweenSearchTableComponent),
|
|
1756
|
+
tableView));
|
|
1752
1757
|
});var TableButton = React.forwardRef(function (_a, ref) {
|
|
1753
1758
|
var children = _a.children, className = _a.className, initSx = _a.sx, _b = _a.variant, variant = _b === void 0 ? 'outlined' : _b, _c = _a.color, color = _c === void 0 ? 'primary' : _c, startIcon = _a.startIcon, endIcon = _a.endIcon, onClick = _a.onClick, props = __rest(_a, ["children", "className", "sx", "variant", "color", "startIcon", "endIcon", "onClick"]);
|
|
1754
1759
|
return (React.createElement(reactComponent.PdgButton, __assign({ ref: ref, className: classNames(className, 'TableButton'), variant: variant, type: 'button', size: 'small', sx: __assign({ minWidth: 0, px: util.empty(startIcon) && util.empty(endIcon)
|