@facter/ds-core 1.7.2 → 1.7.4
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.d.mts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +37 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1106,7 +1106,9 @@ EmptyState.displayName = "EmptyState";
|
|
|
1106
1106
|
function useDataTableInternal({
|
|
1107
1107
|
data,
|
|
1108
1108
|
columns,
|
|
1109
|
-
getRowId
|
|
1109
|
+
getRowId,
|
|
1110
|
+
manualPagination = false,
|
|
1111
|
+
pageCount: externalPageCount
|
|
1110
1112
|
}) {
|
|
1111
1113
|
const [rowSelection, setRowSelection] = React49.useState({});
|
|
1112
1114
|
const [columnVisibility, setColumnVisibility] = React49.useState({});
|
|
@@ -1135,6 +1137,9 @@ function useDataTableInternal({
|
|
|
1135
1137
|
enableSorting: true,
|
|
1136
1138
|
enableFilters: true,
|
|
1137
1139
|
enableGlobalFilter: true,
|
|
1140
|
+
// Server-side pagination support
|
|
1141
|
+
manualPagination,
|
|
1142
|
+
pageCount: manualPagination ? externalPageCount : void 0,
|
|
1138
1143
|
// Handlers
|
|
1139
1144
|
onRowSelectionChange: setRowSelection,
|
|
1140
1145
|
onSortingChange: setSorting,
|
|
@@ -1163,7 +1168,9 @@ function useDataTableInternal({
|
|
|
1163
1168
|
table,
|
|
1164
1169
|
meta,
|
|
1165
1170
|
density,
|
|
1166
|
-
setDensity
|
|
1171
|
+
setDensity,
|
|
1172
|
+
pageIndex: pagination.pageIndex,
|
|
1173
|
+
pageSize: pagination.pageSize
|
|
1167
1174
|
};
|
|
1168
1175
|
}
|
|
1169
1176
|
var DataTableInstanceContext = React49.createContext(null);
|
|
@@ -1172,12 +1179,16 @@ var DataTableMetaContext = React49.createContext(null);
|
|
|
1172
1179
|
DataTableMetaContext.displayName = "DataTableMetaContext";
|
|
1173
1180
|
var DataTableDensityContext = React49.createContext(null);
|
|
1174
1181
|
DataTableDensityContext.displayName = "DataTableDensityContext";
|
|
1182
|
+
var DataTablePaginationContext = React49.createContext(null);
|
|
1183
|
+
DataTablePaginationContext.displayName = "DataTablePaginationContext";
|
|
1175
1184
|
function DataTableProvider({
|
|
1176
1185
|
children,
|
|
1177
1186
|
table,
|
|
1178
1187
|
meta,
|
|
1179
1188
|
density,
|
|
1180
|
-
setDensity
|
|
1189
|
+
setDensity,
|
|
1190
|
+
pageIndex,
|
|
1191
|
+
pageSize
|
|
1181
1192
|
}) {
|
|
1182
1193
|
const metaValue = React49.useMemo(
|
|
1183
1194
|
() => meta,
|
|
@@ -1187,8 +1198,12 @@ function DataTableProvider({
|
|
|
1187
1198
|
() => ({ density, setDensity }),
|
|
1188
1199
|
[density, setDensity]
|
|
1189
1200
|
);
|
|
1201
|
+
const paginationValue = React49.useMemo(
|
|
1202
|
+
() => ({ pageIndex, pageSize }),
|
|
1203
|
+
[pageIndex, pageSize]
|
|
1204
|
+
);
|
|
1190
1205
|
const tableValue = table;
|
|
1191
|
-
return /* @__PURE__ */ jsx(DataTableInstanceContext.Provider, { value: tableValue, children: /* @__PURE__ */ jsx(DataTableMetaContext.Provider, { value: metaValue, children: /* @__PURE__ */ jsx(DataTableDensityContext.Provider, { value: densityValue, children }) }) });
|
|
1206
|
+
return /* @__PURE__ */ jsx(DataTableInstanceContext.Provider, { value: tableValue, children: /* @__PURE__ */ jsx(DataTableMetaContext.Provider, { value: metaValue, children: /* @__PURE__ */ jsx(DataTableDensityContext.Provider, { value: densityValue, children: /* @__PURE__ */ jsx(DataTablePaginationContext.Provider, { value: paginationValue, children }) }) }) });
|
|
1192
1207
|
}
|
|
1193
1208
|
function useDataTable() {
|
|
1194
1209
|
const context = React49.useContext(DataTableInstanceContext);
|
|
@@ -1231,9 +1246,18 @@ function useDataTableDensity() {
|
|
|
1231
1246
|
}
|
|
1232
1247
|
return context;
|
|
1233
1248
|
}
|
|
1249
|
+
function useDataTablePaginationContext() {
|
|
1250
|
+
const context = React49.useContext(DataTablePaginationContext);
|
|
1251
|
+
if (!context) {
|
|
1252
|
+
throw new Error(
|
|
1253
|
+
"useDataTablePagination must be used within <DataTable>. Make sure your component is wrapped with DataTable."
|
|
1254
|
+
);
|
|
1255
|
+
}
|
|
1256
|
+
return context;
|
|
1257
|
+
}
|
|
1234
1258
|
function useDataTablePagination() {
|
|
1235
1259
|
const table = useDataTable();
|
|
1236
|
-
const { pageIndex, pageSize } =
|
|
1260
|
+
const { pageIndex, pageSize } = useDataTablePaginationContext();
|
|
1237
1261
|
return React49.useMemo(() => {
|
|
1238
1262
|
const pageCount = table.getPageCount();
|
|
1239
1263
|
return {
|
|
@@ -1284,12 +1308,16 @@ function DataTableRoot({
|
|
|
1284
1308
|
data,
|
|
1285
1309
|
columns,
|
|
1286
1310
|
getRowId,
|
|
1311
|
+
manualPagination,
|
|
1312
|
+
pageCount,
|
|
1287
1313
|
className
|
|
1288
1314
|
}) {
|
|
1289
|
-
const { table, meta, density, setDensity } = useDataTableInternal({
|
|
1315
|
+
const { table, meta, density, setDensity, pageIndex, pageSize } = useDataTableInternal({
|
|
1290
1316
|
data,
|
|
1291
1317
|
columns,
|
|
1292
|
-
getRowId
|
|
1318
|
+
getRowId,
|
|
1319
|
+
manualPagination,
|
|
1320
|
+
pageCount
|
|
1293
1321
|
});
|
|
1294
1322
|
return /* @__PURE__ */ jsx(
|
|
1295
1323
|
DataTableProvider,
|
|
@@ -1298,6 +1326,8 @@ function DataTableRoot({
|
|
|
1298
1326
|
meta,
|
|
1299
1327
|
density,
|
|
1300
1328
|
setDensity,
|
|
1329
|
+
pageIndex,
|
|
1330
|
+
pageSize,
|
|
1301
1331
|
children: /* @__PURE__ */ jsx(
|
|
1302
1332
|
"div",
|
|
1303
1333
|
{
|