@expcat/tigercat-react 2.0.0-preview.4 → 2.0.0-preview.5

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Table
3
- } from "./chunk-Z47SG5L5.mjs";
3
+ } from "./chunk-UKDPTEJI.mjs";
4
4
  import {
5
5
  Select
6
6
  } from "./chunk-PAN256RW.mjs";
@@ -89,26 +89,31 @@ var List = ({
89
89
  () => mergeTigerLocale(config.locale, locale),
90
90
  [config.locale, locale]
91
91
  );
92
- const [currentPage, setCurrentPage] = useState(
93
- pagination && typeof pagination === "object" ? pagination.current || 1 : 1
94
- );
92
+ const paginationCfg = pagination !== false && typeof pagination === "object" ? pagination : null;
93
+ const isRemotePagination = paginationCfg?.remote === true;
94
+ const [internalCurrentPage, setInternalCurrentPage] = useState(paginationCfg?.current || 1);
95
95
  const dragIndexRef = React.useRef(null);
96
- const [currentPageSize, setCurrentPageSize] = useState(
97
- pagination && typeof pagination === "object" ? pagination.pageSize || 10 : 10
96
+ const [internalCurrentPageSize, setInternalCurrentPageSize] = useState(
97
+ paginationCfg?.pageSize || 10
98
98
  );
99
+ const currentPage = isRemotePagination ? paginationCfg?.current ?? internalCurrentPage : internalCurrentPage;
100
+ const currentPageSize = isRemotePagination ? paginationCfg?.pageSize ?? internalCurrentPageSize : internalCurrentPageSize;
99
101
  const paginatedData = useMemo(() => {
100
102
  if (pagination === false) {
101
103
  return dataSource;
102
104
  }
105
+ if (isRemotePagination) {
106
+ return dataSource;
107
+ }
103
108
  return paginateData(dataSource, currentPage, currentPageSize);
104
- }, [dataSource, currentPage, currentPageSize, pagination]);
109
+ }, [dataSource, currentPage, currentPageSize, pagination, isRemotePagination]);
110
+ const paginationTotal = isRemotePagination ? paginationCfg?.total ?? dataSource.length : dataSource.length;
105
111
  const paginationInfo = useMemo(() => {
106
112
  if (pagination === false) {
107
113
  return null;
108
114
  }
109
- const total = dataSource.length;
110
- return calculatePagination(total, currentPage, currentPageSize);
111
- }, [dataSource.length, currentPage, currentPageSize, pagination]);
115
+ return calculatePagination(paginationTotal, currentPage, currentPageSize);
116
+ }, [paginationTotal, currentPage, currentPageSize, pagination]);
112
117
  const listClasses = useMemo(() => {
113
118
  return classNames(getListClasses(bordered), listSizeClasses[size], className);
114
119
  }, [bordered, size, className]);
@@ -120,12 +125,12 @@ var List = ({
120
125
  );
121
126
  }, [grid]);
122
127
  const handlePageChange = (page) => {
123
- setCurrentPage(page);
128
+ setInternalCurrentPage(page);
124
129
  onPageChange?.({ current: page, pageSize: currentPageSize });
125
130
  };
126
131
  const handlePageSizeChange = (pageSize) => {
127
- setCurrentPageSize(pageSize);
128
- setCurrentPage(1);
132
+ setInternalCurrentPageSize(pageSize);
133
+ setInternalCurrentPage(1);
129
134
  onPageChange?.({ current: 1, pageSize });
130
135
  };
131
136
  const handleItemClick = (item, index) => {
@@ -279,7 +284,7 @@ var List = ({
279
284
  return null;
280
285
  }
281
286
  const { totalPages, startIndex, endIndex, hasNext, hasPrev } = paginationInfo;
282
- const total = dataSource.length;
287
+ const total = paginationTotal;
283
288
  const paginationConfig = pagination;
284
289
  const paginationLabels = getPaginationLabels(mergedLocale);
285
290
  const localeCode = mergedLocale?.locale;
@@ -297,8 +297,11 @@ function useTableState(input) {
297
297
  if (pagination === false) {
298
298
  return processedData;
299
299
  }
300
+ if (paginationConfig?.remote) {
301
+ return processedData;
302
+ }
300
303
  return paginateData(processedData, currentPage, currentPageSize);
301
- }, [processedData, currentPage, currentPageSize, pagination]);
304
+ }, [processedData, currentPage, currentPageSize, pagination, paginationConfig?.remote]);
302
305
  const pageRowKeys = useMemo(
303
306
  () => createTableRowKeyCache(rowKey).getMany(paginatedData),
304
307
  [paginatedData, rowKey]
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-Z3CRHC5F.mjs";
5
5
  import {
6
6
  List
7
- } from "./chunk-D4LASFVY.mjs";
7
+ } from "./chunk-N3ESPSVN.mjs";
8
8
  import {
9
9
  Button
10
10
  } from "./chunk-5TE7KLE5.mjs";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  DataTableWithToolbar,
3
3
  DataTableWithToolbar_default
4
- } from "../chunk-IPJLQSAF.mjs";
5
- import "../chunk-Z47SG5L5.mjs";
4
+ } from "../chunk-HT7XNBI7.mjs";
5
+ import "../chunk-UKDPTEJI.mjs";
6
6
  import "../chunk-PAN256RW.mjs";
7
7
  import "../chunk-IIWUQK2P.mjs";
8
8
  import "../chunk-AKNWUI7K.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  List
3
- } from "../chunk-D4LASFVY.mjs";
3
+ } from "../chunk-N3ESPSVN.mjs";
4
4
  import "../chunk-Y5X3G2LD.mjs";
5
5
  import "../chunk-YSIXURBW.mjs";
6
6
  import "../chunk-TGXBCKOU.mjs";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  NotificationCenter,
3
3
  NotificationCenter_default
4
- } from "../chunk-532RNNPH.mjs";
4
+ } from "../chunk-YLUSOQKR.mjs";
5
5
  import "../chunk-Z3CRHC5F.mjs";
6
- import "../chunk-D4LASFVY.mjs";
6
+ import "../chunk-N3ESPSVN.mjs";
7
7
  import "../chunk-Y5X3G2LD.mjs";
8
8
  import "../chunk-5TE7KLE5.mjs";
9
9
  import "../chunk-ZJWUBR2X.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Table
3
- } from "../chunk-Z47SG5L5.mjs";
3
+ } from "../chunk-UKDPTEJI.mjs";
4
4
  import "../chunk-PAN256RW.mjs";
5
5
  import "../chunk-IIWUQK2P.mjs";
6
6
  import "../chunk-AKNWUI7K.mjs";
package/dist/index.d.mts CHANGED
@@ -149,6 +149,6 @@ import 'react';
149
149
  * React components for Tigercat UI library
150
150
  */
151
151
 
152
- declare const version = "2.0.0-preview.4";
152
+ declare const version = "2.0.0-preview.5";
153
153
 
154
154
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expcat/tigercat-react",
3
- "version": "2.0.0-preview.4",
3
+ "version": "2.0.0-preview.5",
4
4
  "description": "React components for Tigercat UI library",
5
5
  "license": "MIT",
6
6
  "author": "Yizhe Wang",
@@ -777,7 +777,7 @@
777
777
  "access": "public"
778
778
  },
779
779
  "dependencies": {
780
- "@expcat/tigercat-core": "2.0.0-preview.4"
780
+ "@expcat/tigercat-core": "2.0.0-preview.5"
781
781
  },
782
782
  "devDependencies": {
783
783
  "@types/node": "^22.20.0",