@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 CHANGED
@@ -299,6 +299,16 @@ interface DataTableProps<TData extends object> {
299
299
  children: React$1.ReactNode;
300
300
  /** Função para obter ID único da row */
301
301
  getRowId?: (row: TData) => string;
302
+ /**
303
+ * Habilita server-side pagination.
304
+ * Quando true, a tabela não faz paginação local e depende do servidor.
305
+ */
306
+ manualPagination?: boolean;
307
+ /**
308
+ * Total de páginas (obrigatório se manualPagination=true).
309
+ * Usado para calcular navegação quando dados vêm do servidor.
310
+ */
311
+ pageCount?: number;
302
312
  /** Custom className */
303
313
  className?: string;
304
314
  }
@@ -515,7 +525,7 @@ declare const DENSITY_CONFIG: {
515
525
  };
516
526
  };
517
527
 
518
- declare function DataTableRoot<TData extends object>({ children, data, columns, getRowId, className, }: DataTableProps<TData>): react_jsx_runtime.JSX.Element;
528
+ declare function DataTableRoot<TData extends object>({ children, data, columns, getRowId, manualPagination, pageCount, className, }: DataTableProps<TData>): react_jsx_runtime.JSX.Element;
519
529
  declare namespace DataTableRoot {
520
530
  var displayName: string;
521
531
  }
@@ -609,6 +619,7 @@ declare function useDataTableDensity(): DensityContextValue;
609
619
  /**
610
620
  * Hook para paginação
611
621
  * Retorna informações de paginação memoizadas
622
+ * Re-renderiza quando pageIndex ou pageSize muda (via contexto)
612
623
  */
613
624
  declare function useDataTablePagination(): {
614
625
  pageIndex: number;
package/dist/index.d.ts CHANGED
@@ -299,6 +299,16 @@ interface DataTableProps<TData extends object> {
299
299
  children: React$1.ReactNode;
300
300
  /** Função para obter ID único da row */
301
301
  getRowId?: (row: TData) => string;
302
+ /**
303
+ * Habilita server-side pagination.
304
+ * Quando true, a tabela não faz paginação local e depende do servidor.
305
+ */
306
+ manualPagination?: boolean;
307
+ /**
308
+ * Total de páginas (obrigatório se manualPagination=true).
309
+ * Usado para calcular navegação quando dados vêm do servidor.
310
+ */
311
+ pageCount?: number;
302
312
  /** Custom className */
303
313
  className?: string;
304
314
  }
@@ -515,7 +525,7 @@ declare const DENSITY_CONFIG: {
515
525
  };
516
526
  };
517
527
 
518
- declare function DataTableRoot<TData extends object>({ children, data, columns, getRowId, className, }: DataTableProps<TData>): react_jsx_runtime.JSX.Element;
528
+ declare function DataTableRoot<TData extends object>({ children, data, columns, getRowId, manualPagination, pageCount, className, }: DataTableProps<TData>): react_jsx_runtime.JSX.Element;
519
529
  declare namespace DataTableRoot {
520
530
  var displayName: string;
521
531
  }
@@ -609,6 +619,7 @@ declare function useDataTableDensity(): DensityContextValue;
609
619
  /**
610
620
  * Hook para paginação
611
621
  * Retorna informações de paginação memoizadas
622
+ * Re-renderiza quando pageIndex ou pageSize muda (via contexto)
612
623
  */
613
624
  declare function useDataTablePagination(): {
614
625
  pageIndex: number;
package/dist/index.js CHANGED
@@ -1137,7 +1137,9 @@ EmptyState.displayName = "EmptyState";
1137
1137
  function useDataTableInternal({
1138
1138
  data,
1139
1139
  columns,
1140
- getRowId
1140
+ getRowId,
1141
+ manualPagination = false,
1142
+ pageCount: externalPageCount
1141
1143
  }) {
1142
1144
  const [rowSelection, setRowSelection] = React49__namespace.useState({});
1143
1145
  const [columnVisibility, setColumnVisibility] = React49__namespace.useState({});
@@ -1166,6 +1168,9 @@ function useDataTableInternal({
1166
1168
  enableSorting: true,
1167
1169
  enableFilters: true,
1168
1170
  enableGlobalFilter: true,
1171
+ // Server-side pagination support
1172
+ manualPagination,
1173
+ pageCount: manualPagination ? externalPageCount : void 0,
1169
1174
  // Handlers
1170
1175
  onRowSelectionChange: setRowSelection,
1171
1176
  onSortingChange: setSorting,
@@ -1194,7 +1199,9 @@ function useDataTableInternal({
1194
1199
  table,
1195
1200
  meta,
1196
1201
  density,
1197
- setDensity
1202
+ setDensity,
1203
+ pageIndex: pagination.pageIndex,
1204
+ pageSize: pagination.pageSize
1198
1205
  };
1199
1206
  }
1200
1207
  var DataTableInstanceContext = React49__namespace.createContext(null);
@@ -1203,12 +1210,16 @@ var DataTableMetaContext = React49__namespace.createContext(null);
1203
1210
  DataTableMetaContext.displayName = "DataTableMetaContext";
1204
1211
  var DataTableDensityContext = React49__namespace.createContext(null);
1205
1212
  DataTableDensityContext.displayName = "DataTableDensityContext";
1213
+ var DataTablePaginationContext = React49__namespace.createContext(null);
1214
+ DataTablePaginationContext.displayName = "DataTablePaginationContext";
1206
1215
  function DataTableProvider({
1207
1216
  children,
1208
1217
  table,
1209
1218
  meta,
1210
1219
  density,
1211
- setDensity
1220
+ setDensity,
1221
+ pageIndex,
1222
+ pageSize
1212
1223
  }) {
1213
1224
  const metaValue = React49__namespace.useMemo(
1214
1225
  () => meta,
@@ -1218,8 +1229,12 @@ function DataTableProvider({
1218
1229
  () => ({ density, setDensity }),
1219
1230
  [density, setDensity]
1220
1231
  );
1232
+ const paginationValue = React49__namespace.useMemo(
1233
+ () => ({ pageIndex, pageSize }),
1234
+ [pageIndex, pageSize]
1235
+ );
1221
1236
  const tableValue = table;
1222
- return /* @__PURE__ */ jsxRuntime.jsx(DataTableInstanceContext.Provider, { value: tableValue, children: /* @__PURE__ */ jsxRuntime.jsx(DataTableMetaContext.Provider, { value: metaValue, children: /* @__PURE__ */ jsxRuntime.jsx(DataTableDensityContext.Provider, { value: densityValue, children }) }) });
1237
+ return /* @__PURE__ */ jsxRuntime.jsx(DataTableInstanceContext.Provider, { value: tableValue, children: /* @__PURE__ */ jsxRuntime.jsx(DataTableMetaContext.Provider, { value: metaValue, children: /* @__PURE__ */ jsxRuntime.jsx(DataTableDensityContext.Provider, { value: densityValue, children: /* @__PURE__ */ jsxRuntime.jsx(DataTablePaginationContext.Provider, { value: paginationValue, children }) }) }) });
1223
1238
  }
1224
1239
  function useDataTable() {
1225
1240
  const context = React49__namespace.useContext(DataTableInstanceContext);
@@ -1262,9 +1277,18 @@ function useDataTableDensity() {
1262
1277
  }
1263
1278
  return context;
1264
1279
  }
1280
+ function useDataTablePaginationContext() {
1281
+ const context = React49__namespace.useContext(DataTablePaginationContext);
1282
+ if (!context) {
1283
+ throw new Error(
1284
+ "useDataTablePagination must be used within <DataTable>. Make sure your component is wrapped with DataTable."
1285
+ );
1286
+ }
1287
+ return context;
1288
+ }
1265
1289
  function useDataTablePagination() {
1266
1290
  const table = useDataTable();
1267
- const { pageIndex, pageSize } = table.getState().pagination;
1291
+ const { pageIndex, pageSize } = useDataTablePaginationContext();
1268
1292
  return React49__namespace.useMemo(() => {
1269
1293
  const pageCount = table.getPageCount();
1270
1294
  return {
@@ -1315,12 +1339,16 @@ function DataTableRoot({
1315
1339
  data,
1316
1340
  columns,
1317
1341
  getRowId,
1342
+ manualPagination,
1343
+ pageCount,
1318
1344
  className
1319
1345
  }) {
1320
- const { table, meta, density, setDensity } = useDataTableInternal({
1346
+ const { table, meta, density, setDensity, pageIndex, pageSize } = useDataTableInternal({
1321
1347
  data,
1322
1348
  columns,
1323
- getRowId
1349
+ getRowId,
1350
+ manualPagination,
1351
+ pageCount
1324
1352
  });
1325
1353
  return /* @__PURE__ */ jsxRuntime.jsx(
1326
1354
  DataTableProvider,
@@ -1329,6 +1357,8 @@ function DataTableRoot({
1329
1357
  meta,
1330
1358
  density,
1331
1359
  setDensity,
1360
+ pageIndex,
1361
+ pageSize,
1332
1362
  children: /* @__PURE__ */ jsxRuntime.jsx(
1333
1363
  "div",
1334
1364
  {