@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.
- package/dist/{chunk-IPJLQSAF.mjs → chunk-HT7XNBI7.mjs} +1 -1
- package/dist/{chunk-D4LASFVY.mjs → chunk-N3ESPSVN.mjs} +18 -13
- package/dist/{chunk-Z47SG5L5.mjs → chunk-UKDPTEJI.mjs} +4 -1
- package/dist/{chunk-532RNNPH.mjs → chunk-YLUSOQKR.mjs} +1 -1
- package/dist/components/DataTableWithToolbar.mjs +2 -2
- package/dist/components/List.mjs +1 -1
- package/dist/components/NotificationCenter.mjs +2 -2
- package/dist/components/Table.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/package.json +2 -2
|
@@ -89,26 +89,31 @@ var List = ({
|
|
|
89
89
|
() => mergeTigerLocale(config.locale, locale),
|
|
90
90
|
[config.locale, locale]
|
|
91
91
|
);
|
|
92
|
-
const
|
|
93
|
-
|
|
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 [
|
|
97
|
-
|
|
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
|
-
|
|
110
|
-
|
|
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
|
-
|
|
128
|
+
setInternalCurrentPage(page);
|
|
124
129
|
onPageChange?.({ current: page, pageSize: currentPageSize });
|
|
125
130
|
};
|
|
126
131
|
const handlePageSizeChange = (pageSize) => {
|
|
127
|
-
|
|
128
|
-
|
|
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 =
|
|
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]
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DataTableWithToolbar,
|
|
3
3
|
DataTableWithToolbar_default
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
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";
|
package/dist/components/List.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NotificationCenter,
|
|
3
3
|
NotificationCenter_default
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-YLUSOQKR.mjs";
|
|
5
5
|
import "../chunk-Z3CRHC5F.mjs";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-N3ESPSVN.mjs";
|
|
7
7
|
import "../chunk-Y5X3G2LD.mjs";
|
|
8
8
|
import "../chunk-5TE7KLE5.mjs";
|
|
9
9
|
import "../chunk-ZJWUBR2X.mjs";
|
package/dist/index.d.mts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expcat/tigercat-react",
|
|
3
|
-
"version": "2.0.0-preview.
|
|
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.
|
|
780
|
+
"@expcat/tigercat-core": "2.0.0-preview.5"
|
|
781
781
|
},
|
|
782
782
|
"devDependencies": {
|
|
783
783
|
"@types/node": "^22.20.0",
|