@pdg/react-table 1.1.1 → 1.1.2

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 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 {useAutoUpdateLayoutState}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) {
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 {useAutoUpdateLayoutState,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');
@@ -3876,61 +3876,52 @@ var PTable = React__default.forwardRef(function (_a, ref) {
3876
3876
  /********************************************************************************************************************
3877
3877
  * Commands
3878
3878
  * ******************************************************************************************************************/
3879
- useLayoutEffect(function () {
3880
- if (ref) {
3881
- var lastColumns_1 = columns;
3882
- var lastItems_1 = items;
3883
- var lastPaging_1 = paging;
3884
- var commands = {
3885
- getColumns: function () { return lastColumns_1; },
3886
- setColumns: function (columns) {
3887
- lastColumns_1 = columns;
3888
- setColumns(lastColumns_1);
3889
- },
3890
- getItems: function () { return lastItems_1; },
3891
- setItems: function (items) {
3892
- lastItems_1 = items;
3893
- setItems(items);
3894
- },
3895
- getPaging: function () { return lastPaging_1; },
3896
- setItemsPaging: function (items, paging) {
3897
- lastItems_1 = items;
3898
- lastPaging_1 = paging;
3899
- setItems(lastItems_1);
3900
- setPaging(lastPaging_1);
3901
- },
3902
- resetSort: function () {
3903
- setSortableItems(makeSortableItems(lastItems_1));
3904
- },
3905
- getCheckedItems: getCheckedItems,
3906
- getChecked: getChecked,
3907
- setChecked: setChecked,
3908
- toggleChecked: toggleChecked,
3909
- setCheckedAll: setCheckedAll,
3910
- scrollToTop: simpleBarScrollToTop,
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
- getChecked,
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
- useLayoutEffect(function () {
4339
- if (ref) {
4340
- var commands = {
4341
- reload: function (page) {
4342
- var _a, _b, _c, _d;
4343
- if (page != null) {
4344
- (_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.scrollToTop();
4345
- }
4346
- var finalData;
4347
- if (lastGetDataDataRef.current) {
4348
- finalData = __assign$2({}, lastGetDataDataRef.current);
4349
- if (page != null) {
4350
- (_b = searchRef.current) === null || _b === void 0 ? void 0 : _b.setValue('page', page);
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
- ref.current = commands;
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
- }, [ref, hash, lastGetDataDataRef, searchRef, tableRef, getData, hashToSearchValue]);
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
@@ -3876,61 +3876,52 @@ var PTable = React.forwardRef(function (_a, ref) {
3876
3876
  /********************************************************************************************************************
3877
3877
  * Commands
3878
3878
  * ******************************************************************************************************************/
3879
- React.useLayoutEffect(function () {
3880
- if (ref) {
3881
- var lastColumns_1 = columns;
3882
- var lastItems_1 = items;
3883
- var lastPaging_1 = paging;
3884
- var commands = {
3885
- getColumns: function () { return lastColumns_1; },
3886
- setColumns: function (columns) {
3887
- lastColumns_1 = columns;
3888
- setColumns(lastColumns_1);
3889
- },
3890
- getItems: function () { return lastItems_1; },
3891
- setItems: function (items) {
3892
- lastItems_1 = items;
3893
- setItems(items);
3894
- },
3895
- getPaging: function () { return lastPaging_1; },
3896
- setItemsPaging: function (items, paging) {
3897
- lastItems_1 = items;
3898
- lastPaging_1 = paging;
3899
- setItems(lastItems_1);
3900
- setPaging(lastPaging_1);
3901
- },
3902
- resetSort: function () {
3903
- setSortableItems(makeSortableItems(lastItems_1));
3904
- },
3905
- getCheckedItems: getCheckedItems,
3906
- getChecked: getChecked,
3907
- setChecked: setChecked,
3908
- toggleChecked: toggleChecked,
3909
- setCheckedAll: setCheckedAll,
3910
- scrollToTop: simpleBarScrollToTop,
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
- getChecked,
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.useLayoutEffect(function () {
4339
- if (ref) {
4340
- var commands = {
4341
- reload: function (page) {
4342
- var _a, _b, _c, _d;
4343
- if (page != null) {
4344
- (_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.scrollToTop();
4345
- }
4346
- var finalData;
4347
- if (lastGetDataDataRef.current) {
4348
- finalData = __assign$2({}, lastGetDataDataRef.current);
4349
- if (page != null) {
4350
- (_b = searchRef.current) === null || _b === void 0 ? void 0 : _b.setValue('page', page);
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
- ref.current = commands;
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
- }, [ref, hash, lastGetDataDataRef, searchRef, tableRef, getData, hashToSearchValue]);
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.1",
4
+ "version": "1.1.2",
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.0",
63
- "@pdg/react-hook": "^1.0.30",
62
+ "@pdg/react-form": "^1.1.1",
63
+ "@pdg/react-hook": "^1.0.31",
64
64
  "@pdg/types": "^1.0.2",
65
65
  "@types/uuid": "^10.0.0",
66
66
  "react-intersection-observer": "^9.16.0",