@pdg/react-table 1.1.1 → 1.1.3
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 +67 -86
- package/dist/index.js +66 -85
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as React from'react';import React__default,{useMemo,useRef,useState,useCallback,useEffect,createContext,useContext,useLayoutEffect,useId}from'react';import {styled,Box,IconButton,Grid,Stack,TableRow,lighten,TableCell,Pagination,Checkbox,useTheme,TableHead,Tooltip,TableBody,Icon,TableFooter,Paper,Table,Popper,Grow,ClickAwayListener}from'@mui/material';import {notEmpty,empty,ifUndefined,equal}from'@pdg/compare';import {formatPersonalNo,formatBusinessNo,formatTelNo,formatNumber}from'@pdg/formatting';import {PIcon,PCopyToClipboard,PButton}from'@pdg/react-component';import {PSearch,PSearchGroup,PFormHidden}from'@pdg/react-form';import {
|
|
1
|
+
import*as React from'react';import React__default,{useMemo,useRef,useState,useCallback,useEffect,createContext,useContext,useLayoutEffect,useId}from'react';import {styled,Box,IconButton,Grid,Stack,TableRow,lighten,TableCell,Pagination,Checkbox,useTheme,TableHead,Tooltip,TableBody,Icon,TableFooter,Paper,Table,Popper,Grow,ClickAwayListener}from'@mui/material';import {notEmpty,empty,ifUndefined,equal}from'@pdg/compare';import {formatPersonalNo,formatBusinessNo,formatTelNo,formatNumber}from'@pdg/formatting';import {PIcon,PCopyToClipboard,PButton}from'@pdg/react-component';import {PSearch,PSearchGroup,PFormHidden}from'@pdg/react-form';import {useAutoUpdateState,useForwardLayoutRef}from'@pdg/react-hook';import {useSensors,useSensor,MouseSensor,TouchSensor,KeyboardSensor,DndContext,closestCenter}from'@dnd-kit/core';import {useSortable,SortableContext,verticalListSortingStrategy,sortableKeyboardCoordinates,arrayMove}from'@dnd-kit/sortable';import {v4}from'uuid';import {useInView}from'react-intersection-observer';function insertStyle(css) {
|
|
2
2
|
if (typeof window === 'undefined')
|
|
3
3
|
return;
|
|
4
4
|
const style = document.createElement('style');
|
|
@@ -3610,11 +3610,11 @@ var PTable = React__default.forwardRef(function (_a, ref) {
|
|
|
3610
3610
|
* ******************************************************************************************************************/
|
|
3611
3611
|
var _e = useState(false), menuOpen = _e[0], setMenuOpen = _e[1];
|
|
3612
3612
|
var _f = useState(undefined), openMenuId = _f[0], setOpenMenuId = _f[1];
|
|
3613
|
-
var _g =
|
|
3613
|
+
var _g = useAutoUpdateState(initColumns), columns = _g[0], setColumns = _g[1];
|
|
3614
3614
|
var _h = useState(), finalColumns = _h[0], setFinalColumns = _h[1];
|
|
3615
|
-
var _j =
|
|
3615
|
+
var _j = useAutoUpdateState(initItems), items = _j[0], setItems = _j[1];
|
|
3616
3616
|
var _k = useState(), sortableItems = _k[0], setSortableItems = _k[1];
|
|
3617
|
-
var _l =
|
|
3617
|
+
var _l = useAutoUpdateState(initPaging), paging = _l[0], setPaging = _l[1];
|
|
3618
3618
|
/********************************************************************************************************************
|
|
3619
3619
|
* containerHeight
|
|
3620
3620
|
* ******************************************************************************************************************/
|
|
@@ -3876,61 +3876,52 @@ var PTable = React__default.forwardRef(function (_a, ref) {
|
|
|
3876
3876
|
/********************************************************************************************************************
|
|
3877
3877
|
* Commands
|
|
3878
3878
|
* ******************************************************************************************************************/
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
};
|
|
3912
|
-
if (typeof ref === 'function') {
|
|
3913
|
-
ref(commands);
|
|
3914
|
-
}
|
|
3915
|
-
else {
|
|
3916
|
-
ref.current = commands;
|
|
3917
|
-
}
|
|
3918
|
-
}
|
|
3879
|
+
useForwardLayoutRef(ref, useMemo(function () {
|
|
3880
|
+
var lastColumns = columns;
|
|
3881
|
+
var lastItems = items;
|
|
3882
|
+
var lastPaging = paging;
|
|
3883
|
+
return {
|
|
3884
|
+
getColumns: function () { return lastColumns; },
|
|
3885
|
+
setColumns: function (columns) {
|
|
3886
|
+
lastColumns = columns;
|
|
3887
|
+
setColumns(lastColumns);
|
|
3888
|
+
},
|
|
3889
|
+
getItems: function () { return lastItems; },
|
|
3890
|
+
setItems: function (items) {
|
|
3891
|
+
lastItems = items;
|
|
3892
|
+
setItems(items);
|
|
3893
|
+
},
|
|
3894
|
+
getPaging: function () { return lastPaging; },
|
|
3895
|
+
setItemsPaging: function (items, paging) {
|
|
3896
|
+
lastItems = items;
|
|
3897
|
+
lastPaging = paging;
|
|
3898
|
+
setItems(lastItems);
|
|
3899
|
+
setPaging(lastPaging);
|
|
3900
|
+
},
|
|
3901
|
+
resetSort: function () {
|
|
3902
|
+
setSortableItems(makeSortableItems(lastItems));
|
|
3903
|
+
},
|
|
3904
|
+
getCheckedItems: getCheckedItems,
|
|
3905
|
+
getChecked: getChecked,
|
|
3906
|
+
setChecked: setChecked,
|
|
3907
|
+
toggleChecked: toggleChecked,
|
|
3908
|
+
setCheckedAll: setCheckedAll,
|
|
3909
|
+
scrollToTop: simpleBarScrollToTop,
|
|
3910
|
+
};
|
|
3919
3911
|
}, [
|
|
3920
|
-
ref,
|
|
3921
3912
|
columns,
|
|
3913
|
+
getChecked,
|
|
3914
|
+
getCheckedItems,
|
|
3922
3915
|
items,
|
|
3923
3916
|
paging,
|
|
3917
|
+
setChecked,
|
|
3918
|
+
setCheckedAll,
|
|
3924
3919
|
setColumns,
|
|
3925
3920
|
setItems,
|
|
3926
3921
|
setPaging,
|
|
3927
|
-
getCheckedItems,
|
|
3928
3922
|
simpleBarScrollToTop,
|
|
3929
|
-
setChecked,
|
|
3930
3923
|
toggleChecked,
|
|
3931
|
-
|
|
3932
|
-
setCheckedAll,
|
|
3933
|
-
]);
|
|
3924
|
+
]));
|
|
3934
3925
|
/********************************************************************************************************************
|
|
3935
3926
|
* Event Handler
|
|
3936
3927
|
* ******************************************************************************************************************/
|
|
@@ -4335,45 +4326,35 @@ var deHash = function () {
|
|
|
4335
4326
|
/********************************************************************************************************************
|
|
4336
4327
|
* Commands
|
|
4337
4328
|
* ******************************************************************************************************************/
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
var
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
finalData.page = page;
|
|
4352
|
-
}
|
|
4353
|
-
}
|
|
4354
|
-
else {
|
|
4355
|
-
if (hash) {
|
|
4356
|
-
hashToSearchValue();
|
|
4357
|
-
}
|
|
4358
|
-
if (page != null) {
|
|
4359
|
-
(_c = searchRef.current) === null || _c === void 0 ? void 0 : _c.setValue('page', page);
|
|
4360
|
-
}
|
|
4361
|
-
finalData = ((_d = searchRef.current) === null || _d === void 0 ? void 0 : _d.getAllFormValue()) || {};
|
|
4362
|
-
}
|
|
4363
|
-
getData(finalData);
|
|
4364
|
-
},
|
|
4365
|
-
getLastLoadData: function () { return lastGetDataDataRef.current || {}; },
|
|
4366
|
-
getSearch: function () { return searchRef.current; },
|
|
4367
|
-
getTable: function () { return tableRef.current; },
|
|
4368
|
-
};
|
|
4369
|
-
if (typeof ref === 'function') {
|
|
4370
|
-
ref(commands);
|
|
4329
|
+
useForwardLayoutRef(ref, useMemo(function () { return ({
|
|
4330
|
+
reload: function (page) {
|
|
4331
|
+
var _a, _b, _c, _d;
|
|
4332
|
+
if (page != null) {
|
|
4333
|
+
(_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.scrollToTop();
|
|
4334
|
+
}
|
|
4335
|
+
var finalData;
|
|
4336
|
+
if (lastGetDataDataRef.current) {
|
|
4337
|
+
finalData = __assign$2({}, lastGetDataDataRef.current);
|
|
4338
|
+
if (page != null) {
|
|
4339
|
+
(_b = searchRef.current) === null || _b === void 0 ? void 0 : _b.setValue('page', page);
|
|
4340
|
+
finalData.page = page;
|
|
4341
|
+
}
|
|
4371
4342
|
}
|
|
4372
4343
|
else {
|
|
4373
|
-
|
|
4344
|
+
if (hash) {
|
|
4345
|
+
hashToSearchValue();
|
|
4346
|
+
}
|
|
4347
|
+
if (page != null) {
|
|
4348
|
+
(_c = searchRef.current) === null || _c === void 0 ? void 0 : _c.setValue('page', page);
|
|
4349
|
+
}
|
|
4350
|
+
finalData = ((_d = searchRef.current) === null || _d === void 0 ? void 0 : _d.getAllFormValue()) || {};
|
|
4374
4351
|
}
|
|
4375
|
-
|
|
4376
|
-
|
|
4352
|
+
getData(finalData);
|
|
4353
|
+
},
|
|
4354
|
+
getLastLoadData: function () { return lastGetDataDataRef.current || {}; },
|
|
4355
|
+
getSearch: function () { return searchRef.current; },
|
|
4356
|
+
getTable: function () { return tableRef.current; },
|
|
4357
|
+
}); }, [getData, hash, hashToSearchValue]));
|
|
4377
4358
|
/********************************************************************************************************************
|
|
4378
4359
|
* hash
|
|
4379
4360
|
* ******************************************************************************************************************/
|
package/dist/index.js
CHANGED
|
@@ -3610,11 +3610,11 @@ var PTable = React.forwardRef(function (_a, ref) {
|
|
|
3610
3610
|
* ******************************************************************************************************************/
|
|
3611
3611
|
var _e = React.useState(false), menuOpen = _e[0], setMenuOpen = _e[1];
|
|
3612
3612
|
var _f = React.useState(undefined), openMenuId = _f[0], setOpenMenuId = _f[1];
|
|
3613
|
-
var _g = reactHook.
|
|
3613
|
+
var _g = reactHook.useAutoUpdateState(initColumns), columns = _g[0], setColumns = _g[1];
|
|
3614
3614
|
var _h = React.useState(), finalColumns = _h[0], setFinalColumns = _h[1];
|
|
3615
|
-
var _j = reactHook.
|
|
3615
|
+
var _j = reactHook.useAutoUpdateState(initItems), items = _j[0], setItems = _j[1];
|
|
3616
3616
|
var _k = React.useState(), sortableItems = _k[0], setSortableItems = _k[1];
|
|
3617
|
-
var _l = reactHook.
|
|
3617
|
+
var _l = reactHook.useAutoUpdateState(initPaging), paging = _l[0], setPaging = _l[1];
|
|
3618
3618
|
/********************************************************************************************************************
|
|
3619
3619
|
* containerHeight
|
|
3620
3620
|
* ******************************************************************************************************************/
|
|
@@ -3876,61 +3876,52 @@ var PTable = React.forwardRef(function (_a, ref) {
|
|
|
3876
3876
|
/********************************************************************************************************************
|
|
3877
3877
|
* Commands
|
|
3878
3878
|
* ******************************************************************************************************************/
|
|
3879
|
-
React.
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
};
|
|
3912
|
-
if (typeof ref === 'function') {
|
|
3913
|
-
ref(commands);
|
|
3914
|
-
}
|
|
3915
|
-
else {
|
|
3916
|
-
ref.current = commands;
|
|
3917
|
-
}
|
|
3918
|
-
}
|
|
3879
|
+
reactHook.useForwardLayoutRef(ref, React.useMemo(function () {
|
|
3880
|
+
var lastColumns = columns;
|
|
3881
|
+
var lastItems = items;
|
|
3882
|
+
var lastPaging = paging;
|
|
3883
|
+
return {
|
|
3884
|
+
getColumns: function () { return lastColumns; },
|
|
3885
|
+
setColumns: function (columns) {
|
|
3886
|
+
lastColumns = columns;
|
|
3887
|
+
setColumns(lastColumns);
|
|
3888
|
+
},
|
|
3889
|
+
getItems: function () { return lastItems; },
|
|
3890
|
+
setItems: function (items) {
|
|
3891
|
+
lastItems = items;
|
|
3892
|
+
setItems(items);
|
|
3893
|
+
},
|
|
3894
|
+
getPaging: function () { return lastPaging; },
|
|
3895
|
+
setItemsPaging: function (items, paging) {
|
|
3896
|
+
lastItems = items;
|
|
3897
|
+
lastPaging = paging;
|
|
3898
|
+
setItems(lastItems);
|
|
3899
|
+
setPaging(lastPaging);
|
|
3900
|
+
},
|
|
3901
|
+
resetSort: function () {
|
|
3902
|
+
setSortableItems(makeSortableItems(lastItems));
|
|
3903
|
+
},
|
|
3904
|
+
getCheckedItems: getCheckedItems,
|
|
3905
|
+
getChecked: getChecked,
|
|
3906
|
+
setChecked: setChecked,
|
|
3907
|
+
toggleChecked: toggleChecked,
|
|
3908
|
+
setCheckedAll: setCheckedAll,
|
|
3909
|
+
scrollToTop: simpleBarScrollToTop,
|
|
3910
|
+
};
|
|
3919
3911
|
}, [
|
|
3920
|
-
ref,
|
|
3921
3912
|
columns,
|
|
3913
|
+
getChecked,
|
|
3914
|
+
getCheckedItems,
|
|
3922
3915
|
items,
|
|
3923
3916
|
paging,
|
|
3917
|
+
setChecked,
|
|
3918
|
+
setCheckedAll,
|
|
3924
3919
|
setColumns,
|
|
3925
3920
|
setItems,
|
|
3926
3921
|
setPaging,
|
|
3927
|
-
getCheckedItems,
|
|
3928
3922
|
simpleBarScrollToTop,
|
|
3929
|
-
setChecked,
|
|
3930
3923
|
toggleChecked,
|
|
3931
|
-
|
|
3932
|
-
setCheckedAll,
|
|
3933
|
-
]);
|
|
3924
|
+
]));
|
|
3934
3925
|
/********************************************************************************************************************
|
|
3935
3926
|
* Event Handler
|
|
3936
3927
|
* ******************************************************************************************************************/
|
|
@@ -4335,45 +4326,35 @@ var deHash = function () {
|
|
|
4335
4326
|
/********************************************************************************************************************
|
|
4336
4327
|
* Commands
|
|
4337
4328
|
* ******************************************************************************************************************/
|
|
4338
|
-
React.
|
|
4339
|
-
|
|
4340
|
-
var
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
finalData.page = page;
|
|
4352
|
-
}
|
|
4353
|
-
}
|
|
4354
|
-
else {
|
|
4355
|
-
if (hash) {
|
|
4356
|
-
hashToSearchValue();
|
|
4357
|
-
}
|
|
4358
|
-
if (page != null) {
|
|
4359
|
-
(_c = searchRef.current) === null || _c === void 0 ? void 0 : _c.setValue('page', page);
|
|
4360
|
-
}
|
|
4361
|
-
finalData = ((_d = searchRef.current) === null || _d === void 0 ? void 0 : _d.getAllFormValue()) || {};
|
|
4362
|
-
}
|
|
4363
|
-
getData(finalData);
|
|
4364
|
-
},
|
|
4365
|
-
getLastLoadData: function () { return lastGetDataDataRef.current || {}; },
|
|
4366
|
-
getSearch: function () { return searchRef.current; },
|
|
4367
|
-
getTable: function () { return tableRef.current; },
|
|
4368
|
-
};
|
|
4369
|
-
if (typeof ref === 'function') {
|
|
4370
|
-
ref(commands);
|
|
4329
|
+
reactHook.useForwardLayoutRef(ref, React.useMemo(function () { return ({
|
|
4330
|
+
reload: function (page) {
|
|
4331
|
+
var _a, _b, _c, _d;
|
|
4332
|
+
if (page != null) {
|
|
4333
|
+
(_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.scrollToTop();
|
|
4334
|
+
}
|
|
4335
|
+
var finalData;
|
|
4336
|
+
if (lastGetDataDataRef.current) {
|
|
4337
|
+
finalData = __assign$2({}, lastGetDataDataRef.current);
|
|
4338
|
+
if (page != null) {
|
|
4339
|
+
(_b = searchRef.current) === null || _b === void 0 ? void 0 : _b.setValue('page', page);
|
|
4340
|
+
finalData.page = page;
|
|
4341
|
+
}
|
|
4371
4342
|
}
|
|
4372
4343
|
else {
|
|
4373
|
-
|
|
4344
|
+
if (hash) {
|
|
4345
|
+
hashToSearchValue();
|
|
4346
|
+
}
|
|
4347
|
+
if (page != null) {
|
|
4348
|
+
(_c = searchRef.current) === null || _c === void 0 ? void 0 : _c.setValue('page', page);
|
|
4349
|
+
}
|
|
4350
|
+
finalData = ((_d = searchRef.current) === null || _d === void 0 ? void 0 : _d.getAllFormValue()) || {};
|
|
4374
4351
|
}
|
|
4375
|
-
|
|
4376
|
-
|
|
4352
|
+
getData(finalData);
|
|
4353
|
+
},
|
|
4354
|
+
getLastLoadData: function () { return lastGetDataDataRef.current || {}; },
|
|
4355
|
+
getSearch: function () { return searchRef.current; },
|
|
4356
|
+
getTable: function () { return tableRef.current; },
|
|
4357
|
+
}); }, [getData, hash, hashToSearchValue]));
|
|
4377
4358
|
/********************************************************************************************************************
|
|
4378
4359
|
* hash
|
|
4379
4360
|
* ******************************************************************************************************************/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdg/react-table",
|
|
3
3
|
"title": "React Table",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.3",
|
|
5
5
|
"description": "React Table",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"@pdg/compare": "^1.0.6",
|
|
60
60
|
"@pdg/formatting": "^1.0.5",
|
|
61
61
|
"@pdg/react-component": "^1.1.0",
|
|
62
|
-
"@pdg/react-form": "^1.1.
|
|
63
|
-
"@pdg/react-hook": "^1.0.
|
|
62
|
+
"@pdg/react-form": "^1.1.2",
|
|
63
|
+
"@pdg/react-hook": "^1.0.32",
|
|
64
64
|
"@pdg/types": "^1.0.2",
|
|
65
65
|
"@types/uuid": "^10.0.0",
|
|
66
66
|
"react-intersection-observer": "^9.16.0",
|