erp-pos-ecommerce-shared 0.1.2 → 0.1.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.
@@ -1,12 +1,13 @@
1
1
  import React$1, { ReactNode } from 'react';
2
2
  import { e as IField, b as IButton } from './form.interface-CqnTdmc8.js';
3
3
  import { ReactFormExtendedApi, FormValidateOrFn, FormAsyncValidateOrFn } from '@tanstack/react-form';
4
- import { UseMutationResult } from '@tanstack/react-query';
4
+ import { UseMutationResult, UseQueryOptions } from '@tanstack/react-query';
5
5
  import { s as TblProductsImage, o as ITableFilterConfig, g as IFilterSelectOption } from './filters.interface-Cx-AXMPz.js';
6
6
  import * as z from 'zod';
7
7
  import * as react_jsx_runtime from 'react/jsx-runtime';
8
- import { ColumnDef, Row, useReactTable } from '@tanstack/react-table';
8
+ import { ColumnDef, useReactTable, Row } from '@tanstack/react-table';
9
9
  import { D as DataTableConfig, S as ServerTableState } from './datatable.interface-DFSQWdXd.js';
10
+ import { T as TableQueryParams } from './types-CiX8AkJA.js';
10
11
 
11
12
  interface CreateEditFormProps<T> {
12
13
  fields: IField[];
@@ -151,8 +152,18 @@ interface DataTableProps$1<TData> {
151
152
  onClick: () => void;
152
153
  Icon?: React.ElementType;
153
154
  }[];
155
+ /** Called when a row is clicked */
156
+ onRowClick?: (row: TData) => void;
157
+ /** Called when a row is hovered */
158
+ onRowHover?: (row: TData) => void;
159
+ /** Empty state to display when no data is available */
160
+ emptyState?: React.ReactNode;
161
+ /** Table instance */
162
+ table?: ReturnType<typeof useReactTable<TData>>;
163
+ /** Custom Header component */
164
+ CustomHeader?: React.ReactNode;
154
165
  }
155
- declare const DataTable: <TData>({ data, columns, config, filters, totalRowCount, onStateChange, loading, enableRowCheck: canCheck, onSelectionChange, headerBgColor, columnActions, listMenuActions, }: DataTableProps$1<TData>) => react_jsx_runtime.JSX.Element;
166
+ declare const DataTable: <TData>({ data, columns, config, filters, totalRowCount, onStateChange, loading, enableRowCheck: canCheck, onSelectionChange, headerBgColor, columnActions, listMenuActions, onRowClick, onRowHover, emptyState, table: ExternalTable, CustomHeader, }: DataTableProps$1<TData>) => react_jsx_runtime.JSX.Element;
156
167
 
157
168
  interface EmptyStateProps {
158
169
  title?: string;
@@ -241,8 +252,18 @@ interface DataTableProps<TData> {
241
252
  }[];
242
253
  /** Header background color. Use light-dark(light, dark) for theme-aware colors */
243
254
  headerBgColor?: string;
255
+ /** Whether the table is loading (shows skeleton rows instead of data) */
256
+ loading?: boolean;
257
+ /** Number of skeleton rows to show when loading */
258
+ skeletonRowCount?: number;
259
+ /** Called when a row is clicked */
260
+ onRowClick?: (row: TData) => void;
261
+ /** Called when a row is hovered */
262
+ onRowHover?: (row: TData) => void;
263
+ /** Empty state to display when no data is available */
264
+ emptyState?: React$1.ReactNode;
244
265
  }
245
- declare const SimpleDataTable: <TData>({ table, withBorder, borderRadius, SortIcon, SortIconAsc, SortIconDesc, EmptyStateIcon, EmptyStateTitle, EmptyStateDescription, canCheck, columnActions, listMenuActions, headerBgColor, }: DataTableProps<TData>) => react_jsx_runtime.JSX.Element;
266
+ declare const SimpleDataTable: <TData>({ table, withBorder, borderRadius, SortIcon, SortIconAsc, SortIconDesc, canCheck, columnActions, listMenuActions, headerBgColor, loading, skeletonRowCount, onRowClick, onRowHover, emptyState, }: DataTableProps<TData>) => react_jsx_runtime.JSX.Element;
246
267
 
247
268
  interface TableSkeletonProps {
248
269
  /** Number of skeleton rows to show */
@@ -260,4 +281,82 @@ interface TableSkeletonProps {
260
281
  }
261
282
  declare const TableSkeleton: ({ rows, columns, canCheck, withBorder, borderRadius, rowHeight, }: TableSkeletonProps) => react_jsx_runtime.JSX.Element;
262
283
 
263
- export { BottomPagination, CreateEditForm, DataTable, EmptyState, FilterDate, type FilterDateProps, FilterSelect, type FilterSelectProps, FormGenerator, type FormInstance, type FormValues, ImageForm, SearchInput, SimpleDataTable, TableSkeleton, configureImageFormIcons, dateGteFilterFn, fieldGenerator, generateFormSchema };
284
+ /** Shape that the query must return for TablePage to work correctly. */
285
+ interface PaginatedResponse<TRow> {
286
+ data: TRow[];
287
+ total: number;
288
+ }
289
+ interface TablePageProps<TRow> {
290
+ /**
291
+ * Factory that receives the current pagination/filter params and returns
292
+ * the query options. Called every time the table state changes.
293
+ */
294
+ getQueryOptions: (params: TableQueryParams) => UseQueryOptions<PaginatedResponse<TRow>>;
295
+ /**
296
+ * Title of the table
297
+ */
298
+ title: string;
299
+ /**
300
+ * Columns of the table
301
+ */
302
+ columns: ColumnDef<TRow>[];
303
+ /**
304
+ * Filters of the table
305
+ */
306
+ filters?: ITableFilterConfig[];
307
+ /**
308
+ * Whether the table is loading externally
309
+ */
310
+ isLoadingExternal?: boolean;
311
+ /**
312
+ * Called when a row is clicked
313
+ */
314
+ onRowClick?: (row: TRow) => void;
315
+ /**
316
+ * Called when a row is hovered
317
+ */
318
+ onRowHover?: (row: TRow) => void;
319
+ /**
320
+ * Empty state of the table
321
+ */
322
+ emptyState?: React.ReactNode;
323
+ /**
324
+ * Table instance
325
+ */
326
+ table?: ReturnType<typeof useReactTable<TRow>>;
327
+ /**
328
+ * Whether to enable row selection
329
+ */
330
+ enableRowSelection?: boolean;
331
+ /**
332
+ * Header background color
333
+ */
334
+ headerBgColor?: string;
335
+ /**
336
+ * Column actions to display per row
337
+ */
338
+ columnActions?: (row: TRow) => React.ReactNode;
339
+ /**
340
+ * List menu actions to display per row
341
+ */
342
+ listMenuActions?: (row: TRow) => {
343
+ label: string;
344
+ onClick: () => void;
345
+ Icon?: React.ElementType;
346
+ }[];
347
+ /**
348
+ * Called when row selection changes
349
+ */
350
+ onSelectionChange?: (selectedRows: TRow[]) => void;
351
+ /**
352
+ * Configuration for the table
353
+ */
354
+ config?: Partial<DataTableConfig>;
355
+ /**
356
+ * Custom Header component
357
+ */
358
+ CustomHeader?: React.ReactNode;
359
+ }
360
+ declare const TablePage: <TRow>({ getQueryOptions, title, columns, filters, isLoadingExternal, onRowClick, onRowHover, emptyState, table, enableRowSelection, headerBgColor, columnActions, listMenuActions, onSelectionChange, config, CustomHeader, }: TablePageProps<TRow>) => react_jsx_runtime.JSX.Element;
361
+
362
+ export { BottomPagination, CreateEditForm, DataTable, EmptyState, FilterDate, type FilterDateProps, FilterSelect, type FilterSelectProps, FormGenerator, type FormInstance, type FormValues, ImageForm, type PaginatedResponse, SearchInput, SimpleDataTable, TablePage, TableSkeleton, configureImageFormIcons, dateGteFilterFn, fieldGenerator, generateFormSchema };
@@ -1,8 +1,8 @@
1
- import { useMutation } from '@tanstack/react-query';
2
- import { Text, Group, Box, rem, Button, ScrollArea, Image, ActionIcon, TagsInput, Switch, MultiSelect, Select, NumberInput, PasswordInput, TextInput, LoadingOverlay, Stepper, Flex, Container, Title, Card, Pagination, Stack, Paper, Table, Menu, Popover, Skeleton, Checkbox, UnstyledButton } from '@mantine/core';
1
+ import { useMutation, useQuery } from '@tanstack/react-query';
2
+ import { Text, Group, Box, rem, Button, ScrollArea, Image, ActionIcon, TagsInput, Switch, MultiSelect, Select, NumberInput, PasswordInput, TextInput, LoadingOverlay, Stepper, Flex, Container, Title, Card, Pagination, Stack, Paper, Table, Skeleton, Menu, Popover, Checkbox, UnstyledButton } from '@mantine/core';
3
3
  import { useForm } from '@tanstack/react-form';
4
4
  import axios, { isAxiosError } from 'axios';
5
- import { useRef, useMemo, useState, useEffect } from 'react';
5
+ import { useRef, useMemo, useState, useEffect, useCallback } from 'react';
6
6
  import { DatePickerInput, DatePicker } from '@mantine/dates';
7
7
  import { Dropzone, IMAGE_MIME_TYPE } from '@mantine/dropzone';
8
8
  import { modals } from '@mantine/modals';
@@ -1363,60 +1363,77 @@ var TableBody = ({
1363
1363
  canCheck = false,
1364
1364
  columnActions,
1365
1365
  MenuIcon = MoreVertical,
1366
- listMenuActions
1366
+ listMenuActions,
1367
+ onRowClick,
1368
+ onRowHover
1367
1369
  }) => {
1368
- return /* @__PURE__ */ jsx(Table.Tbody, { children: table.getRowModel().rows.map((row) => /* @__PURE__ */ jsxs(Table.Tr, { children: [
1369
- canCheck && /* @__PURE__ */ jsx(
1370
- Table.Td,
1371
- {
1372
- styles: {
1373
- td: {
1374
- padding: "0 0 0 6px"
1375
- }
1376
- },
1377
- children: /* @__PURE__ */ jsx(
1378
- Checkbox,
1370
+ return /* @__PURE__ */ jsx(Table.Tbody, { children: table.getRowModel().rows.map((row) => /* @__PURE__ */ jsxs(
1371
+ Table.Tr,
1372
+ {
1373
+ style: onRowClick ? { cursor: "pointer" } : void 0,
1374
+ onMouseEnter: () => onRowHover?.(row.original),
1375
+ children: [
1376
+ canCheck && /* @__PURE__ */ jsx(
1377
+ Table.Td,
1379
1378
  {
1380
- size: "xs",
1381
1379
  styles: {
1382
- root: {
1383
- width: 5
1380
+ td: {
1381
+ padding: "0 0 0 6px"
1384
1382
  }
1385
1383
  },
1386
- checked: row.getIsSelected(),
1387
- onChange: row.getToggleSelectedHandler(),
1388
- disabled: !row.getCanSelect(),
1389
- "aria-label": "Select row"
1384
+ children: /* @__PURE__ */ jsx(
1385
+ Checkbox,
1386
+ {
1387
+ size: "xs",
1388
+ styles: {
1389
+ root: {
1390
+ width: 5
1391
+ }
1392
+ },
1393
+ checked: row.getIsSelected(),
1394
+ onChange: row.getToggleSelectedHandler(),
1395
+ disabled: !row.getCanSelect(),
1396
+ "aria-label": "Select row"
1397
+ }
1398
+ )
1390
1399
  }
1391
- )
1392
- }
1393
- ),
1394
- row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(
1395
- Text,
1396
- {
1397
- size: "sm",
1398
- style: {
1399
- color: "light-dark(var(--mantine-color-dark-7), var(--mantine-color-gray-1))"
1400
- },
1401
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
1402
- }
1403
- ) }, cell.id)),
1404
- /* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsxs(Flex, { justify: "flex-end", align: "center", gap: "sm", children: [
1405
- columnActions?.(row.original),
1406
- listMenuActions && /* @__PURE__ */ jsxs(Menu, { variant: "subtle", children: [
1407
- /* @__PURE__ */ jsx(Menu.Target, { children: /* @__PURE__ */ jsx(ActionIcon, { variant: "subtle", color: "gray", size: "sm", children: /* @__PURE__ */ jsx(MenuIcon, { size: 16 }) }) }),
1408
- /* @__PURE__ */ jsx(Menu.Dropdown, { children: listMenuActions(row.original).map((action) => /* @__PURE__ */ jsx(
1409
- Menu.Item,
1400
+ ),
1401
+ row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(
1402
+ Table.Td,
1410
1403
  {
1411
- onClick: action.onClick,
1412
- rightSection: action.Icon && /* @__PURE__ */ jsx(action.Icon, {}),
1413
- children: action.label
1404
+ onClick: () => onRowClick?.(row.original),
1405
+ children: /* @__PURE__ */ jsx(
1406
+ Text,
1407
+ {
1408
+ size: "sm",
1409
+ style: {
1410
+ color: "light-dark(var(--mantine-color-dark-7), var(--mantine-color-gray-1))"
1411
+ },
1412
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
1413
+ }
1414
+ )
1414
1415
  },
1415
- action.label
1416
- )) })
1417
- ] })
1418
- ] }) })
1419
- ] }, row.id)) });
1416
+ cell.id
1417
+ )),
1418
+ /* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsxs(Flex, { justify: "flex-end", align: "center", gap: "sm", children: [
1419
+ columnActions?.(row.original),
1420
+ listMenuActions && /* @__PURE__ */ jsxs(Menu, { variant: "subtle", children: [
1421
+ /* @__PURE__ */ jsx(Menu.Target, { children: /* @__PURE__ */ jsx(ActionIcon, { variant: "subtle", color: "gray", size: "sm", children: /* @__PURE__ */ jsx(MenuIcon, { size: 16 }) }) }),
1422
+ /* @__PURE__ */ jsx(Menu.Dropdown, { children: listMenuActions(row.original).map((action) => /* @__PURE__ */ jsx(
1423
+ Menu.Item,
1424
+ {
1425
+ onClick: action.onClick,
1426
+ rightSection: action.Icon && /* @__PURE__ */ jsx(action.Icon, {}),
1427
+ children: action.label
1428
+ },
1429
+ action.label
1430
+ )) })
1431
+ ] })
1432
+ ] }) })
1433
+ ]
1434
+ },
1435
+ row.id
1436
+ )) });
1420
1437
  };
1421
1438
  var EmptyState = ({
1422
1439
  title = "No hay datos disponibles",
@@ -1505,14 +1522,25 @@ var SimpleDataTable = ({
1505
1522
  SortIcon = ArrowUpDown,
1506
1523
  SortIconAsc = ArrowUp,
1507
1524
  SortIconDesc = ArrowDown,
1508
- EmptyStateIcon = FileX,
1509
- EmptyStateTitle = "No data found",
1510
- EmptyStateDescription = "No data found",
1511
1525
  canCheck = false,
1512
1526
  columnActions,
1513
1527
  listMenuActions,
1514
- headerBgColor
1528
+ headerBgColor,
1529
+ loading = false,
1530
+ skeletonRowCount = 10,
1531
+ onRowClick,
1532
+ onRowHover,
1533
+ emptyState = /* @__PURE__ */ jsx(
1534
+ EmptyState,
1535
+ {
1536
+ title: "No data found",
1537
+ description: "No data found",
1538
+ icon: /* @__PURE__ */ jsx(FileX, { size: 32, color: "var(--mantine-color-gray-6)" })
1539
+ }
1540
+ )
1515
1541
  }) => {
1542
+ const dataColumnsCount = table.getAllLeafColumns().length;
1543
+ const hasActionsColumn = !!(columnActions || listMenuActions);
1516
1544
  return /* @__PURE__ */ jsx(Paper, { withBorder, radius: borderRadius, children: /* @__PURE__ */ jsxs(Table, { children: [
1517
1545
  /* @__PURE__ */ jsx(
1518
1546
  TableHeader,
@@ -1522,13 +1550,33 @@ var SimpleDataTable = ({
1522
1550
  SortIcon,
1523
1551
  SortIconAsc,
1524
1552
  SortIconDesc,
1525
- hasActionsColumn: !!(columnActions || listMenuActions),
1553
+ hasActionsColumn,
1526
1554
  headerBgColor
1527
1555
  }
1528
1556
  ),
1529
- table.getRowCount() > 0 ? /* @__PURE__ */ jsx(
1557
+ loading ? /* @__PURE__ */ jsx(Table.Tbody, { children: Array.from({ length: skeletonRowCount }).map((_, rowIdx) => /* @__PURE__ */ jsxs(Table.Tr, { children: [
1558
+ canCheck && /* @__PURE__ */ jsx(Table.Td, { style: { minHeight: 40, verticalAlign: "middle" }, children: /* @__PURE__ */ jsx(Skeleton, { height: 16, width: 18, radius: "sm" }) }),
1559
+ Array.from({ length: dataColumnsCount }).map((_2, colIdx) => /* @__PURE__ */ jsx(
1560
+ Table.Td,
1561
+ {
1562
+ style: { minHeight: 40, verticalAlign: "middle" },
1563
+ children: /* @__PURE__ */ jsx(
1564
+ Skeleton,
1565
+ {
1566
+ height: 16,
1567
+ width: colIdx === dataColumnsCount - 1 ? 40 : `${60 + colIdx % 2 * 15}%`,
1568
+ radius: "sm"
1569
+ }
1570
+ )
1571
+ },
1572
+ colIdx
1573
+ )),
1574
+ hasActionsColumn && /* @__PURE__ */ jsx(Table.Td, { style: { minHeight: 40, verticalAlign: "middle" }, children: /* @__PURE__ */ jsx(Skeleton, { height: 16, width: 32, radius: "sm" }) })
1575
+ ] }, rowIdx)) }) : table.getRowCount() > 0 ? /* @__PURE__ */ jsx(
1530
1576
  TableBody,
1531
1577
  {
1578
+ onRowClick,
1579
+ onRowHover,
1532
1580
  table,
1533
1581
  canCheck,
1534
1582
  columnActions,
@@ -1544,20 +1592,7 @@ var SimpleDataTable = ({
1544
1592
  justify: "center",
1545
1593
  align: "center",
1546
1594
  style: { minHeight: 200 },
1547
- children: /* @__PURE__ */ jsx(
1548
- EmptyState,
1549
- {
1550
- title: EmptyStateTitle,
1551
- description: EmptyStateDescription,
1552
- icon: /* @__PURE__ */ jsx(
1553
- EmptyStateIcon,
1554
- {
1555
- size: 32,
1556
- color: "var(--mantine-color-gray-6)"
1557
- }
1558
- )
1559
- }
1560
- )
1595
+ children: emptyState
1561
1596
  }
1562
1597
  )
1563
1598
  }
@@ -1788,10 +1823,15 @@ var DataTable = ({
1788
1823
  onSelectionChange,
1789
1824
  headerBgColor,
1790
1825
  columnActions,
1791
- listMenuActions
1826
+ listMenuActions,
1827
+ onRowClick,
1828
+ onRowHover,
1829
+ emptyState,
1830
+ table: ExternalTable,
1831
+ CustomHeader
1792
1832
  }) => {
1793
1833
  const {
1794
- table,
1834
+ table: internalTable,
1795
1835
  globalFilter,
1796
1836
  setGlobalFilter,
1797
1837
  columnFilters,
@@ -1806,6 +1846,7 @@ var DataTable = ({
1806
1846
  totalRowCount,
1807
1847
  onStateChange
1808
1848
  });
1849
+ const table = ExternalTable ?? internalTable;
1809
1850
  useEffect(() => {
1810
1851
  if (canCheck && onSelectionChange) {
1811
1852
  onSelectionChange(selectedRows);
@@ -1813,80 +1854,54 @@ var DataTable = ({
1813
1854
  }, [canCheck, onSelectionChange, selectedRows]);
1814
1855
  const getFilterValue = (columnId) => columnFilters.find((f) => f.id === columnId)?.value ?? null;
1815
1856
  return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "md", children: [
1816
- /* @__PURE__ */ jsxs(Group, { gap: "md", wrap: "wrap", children: [
1817
- mergedConfig.enableGlobalFilter && /* @__PURE__ */ jsx(
1818
- SearchInput,
1819
- {
1820
- value: globalFilter,
1821
- onChange: setGlobalFilter,
1822
- placeholder: mergedConfig.searchPlaceholder
1823
- }
1824
- ),
1825
- filters?.map(
1826
- (f) => f.type === "date" ? /* @__PURE__ */ jsx(
1827
- FilterDate,
1857
+ /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", children: [
1858
+ /* @__PURE__ */ jsxs(Group, { gap: "md", wrap: "wrap", children: [
1859
+ mergedConfig.enableGlobalFilter && /* @__PURE__ */ jsx(
1860
+ SearchInput,
1828
1861
  {
1829
- columnId: f.columnId,
1830
- value: getFilterValue(f.columnId),
1831
- onChange: setColumnFilter,
1832
- placeholder: f.placeholder
1833
- },
1834
- f.columnId
1835
- ) : /* @__PURE__ */ jsx(
1836
- FilterSelect,
1837
- {
1838
- columnId: f.columnId,
1839
- options: f.options ?? [],
1840
- onChange: setColumnFilter,
1841
- placeholder: f.placeholder ?? "Todos"
1842
- },
1843
- f.columnId
1844
- )
1845
- )
1846
- ] }),
1847
- loading ? /* @__PURE__ */ jsx(Paper, { withBorder: true, radius: "md", children: /* @__PURE__ */ jsxs(Table, { children: [
1848
- /* @__PURE__ */ jsx(
1849
- TableHeader,
1850
- {
1851
- table,
1852
- canCheck,
1853
- SortIcon: ArrowUpDown,
1854
- SortIconAsc: ArrowUp,
1855
- SortIconDesc: ArrowDown,
1856
- hasActionsColumn: !!(columnActions || listMenuActions),
1857
- headerBgColor
1858
- }
1859
- ),
1860
- /* @__PURE__ */ jsx(Table.Tbody, { children: Array.from({ length: mergedConfig.defaultPageSize }).map(
1861
- (_, rowIdx) => /* @__PURE__ */ jsxs(Table.Tr, { children: [
1862
- canCheck && /* @__PURE__ */ jsx(Table.Td, { style: { minHeight: 40, verticalAlign: "middle" }, children: /* @__PURE__ */ jsx(Skeleton, { height: 16, width: 18, radius: "sm" }) }),
1863
- Array.from({ length: columns.length }).map((_2, colIdx) => /* @__PURE__ */ jsx(
1864
- Table.Td,
1862
+ value: globalFilter,
1863
+ onChange: setGlobalFilter,
1864
+ placeholder: mergedConfig.searchPlaceholder
1865
+ }
1866
+ ),
1867
+ filters?.map(
1868
+ (f) => f.type === "date" ? /* @__PURE__ */ jsx(
1869
+ FilterDate,
1865
1870
  {
1866
- style: { minHeight: 40, verticalAlign: "middle" },
1867
- children: /* @__PURE__ */ jsx(
1868
- Skeleton,
1869
- {
1870
- height: 16,
1871
- width: colIdx === columns.length - 1 ? 40 : `${60 + colIdx % 2 * 15}%`,
1872
- radius: "sm"
1873
- }
1874
- )
1871
+ columnId: f.columnId,
1872
+ value: getFilterValue(f.columnId),
1873
+ onChange: setColumnFilter,
1874
+ placeholder: f.placeholder
1875
1875
  },
1876
- colIdx
1877
- )),
1878
- (columnActions ?? listMenuActions) && /* @__PURE__ */ jsx(Table.Td, { style: { minHeight: 40, verticalAlign: "middle" }, children: /* @__PURE__ */ jsx(Skeleton, { height: 16, width: 32, radius: "sm" }) })
1879
- ] }, rowIdx)
1880
- ) })
1881
- ] }) }) : /* @__PURE__ */ jsxs(Paper, { withBorder: true, radius: "md", style: { overflow: "hidden" }, children: [
1876
+ f.columnId
1877
+ ) : /* @__PURE__ */ jsx(
1878
+ FilterSelect,
1879
+ {
1880
+ columnId: f.columnId,
1881
+ options: f.options ?? [],
1882
+ onChange: setColumnFilter,
1883
+ placeholder: f.placeholder ?? "Todos"
1884
+ },
1885
+ f.columnId
1886
+ )
1887
+ )
1888
+ ] }),
1889
+ CustomHeader
1890
+ ] }),
1891
+ /* @__PURE__ */ jsxs(Paper, { withBorder: true, radius: "md", style: { overflow: "hidden" }, children: [
1882
1892
  /* @__PURE__ */ jsx(
1883
1893
  SimpleDataTable,
1884
1894
  {
1895
+ onRowClick,
1896
+ onRowHover,
1885
1897
  table,
1886
1898
  canCheck,
1887
1899
  columnActions,
1888
1900
  listMenuActions,
1889
- headerBgColor
1901
+ headerBgColor,
1902
+ loading,
1903
+ skeletonRowCount: mergedConfig.defaultPageSize,
1904
+ emptyState
1890
1905
  }
1891
1906
  ),
1892
1907
  /* @__PURE__ */ jsx(
@@ -1926,7 +1941,65 @@ var TableSkeleton = ({
1926
1941
  ) }, colIdx)) }, rowIdx)) })
1927
1942
  ] }) });
1928
1943
  };
1944
+ var TablePage = ({
1945
+ getQueryOptions,
1946
+ title,
1947
+ columns,
1948
+ filters,
1949
+ isLoadingExternal,
1950
+ onRowClick,
1951
+ onRowHover,
1952
+ emptyState,
1953
+ table,
1954
+ enableRowSelection,
1955
+ headerBgColor,
1956
+ columnActions,
1957
+ listMenuActions,
1958
+ onSelectionChange,
1959
+ config,
1960
+ CustomHeader
1961
+ }) => {
1962
+ const [tableParams, setTableParams] = useState({
1963
+ skip: 0,
1964
+ limit: 10,
1965
+ query: void 0
1966
+ });
1967
+ const handleStateChange = useCallback((state) => {
1968
+ setTableParams({
1969
+ skip: state.pageIndex * state.pageSize,
1970
+ limit: state.pageSize,
1971
+ query: state.globalFilter || void 0,
1972
+ columnFilters: state.columnFilters.length > 0 ? state.columnFilters : void 0
1973
+ });
1974
+ }, []);
1975
+ const { data, isLoading } = useQuery(getQueryOptions(tableParams));
1976
+ return /* @__PURE__ */ jsxs("div", { children: [
1977
+ /* @__PURE__ */ jsx(Title, { order: 1, children: title }),
1978
+ /* @__PURE__ */ jsx(
1979
+ DataTable,
1980
+ {
1981
+ emptyState,
1982
+ table,
1983
+ onRowClick: (row) => onRowClick?.(row),
1984
+ onRowHover: (row) => onRowHover?.(row),
1985
+ totalRowCount: data?.total,
1986
+ data: data?.data ?? [],
1987
+ loading: isLoading || isLoadingExternal,
1988
+ columns,
1989
+ filters,
1990
+ onStateChange: handleStateChange,
1991
+ enableRowCheck: enableRowSelection,
1992
+ headerBgColor,
1993
+ columnActions,
1994
+ listMenuActions,
1995
+ onSelectionChange,
1996
+ config,
1997
+ CustomHeader
1998
+ }
1999
+ )
2000
+ ] });
2001
+ };
1929
2002
 
1930
- export { BottomPagination, CreateEditForm, DataTable, EmptyState, FilterDate, FilterSelect, FormGenerator, ImageForm, SearchInput, SimpleDataTable, TableSkeleton, configureImageFormIcons, dateGteFilterFn, fieldGenerator, generateFormSchema };
2003
+ export { BottomPagination, CreateEditForm, DataTable, EmptyState, FilterDate, FilterSelect, FormGenerator, ImageForm, SearchInput, SimpleDataTable, TablePage, TableSkeleton, configureImageFormIcons, dateGteFilterFn, fieldGenerator, generateFormSchema };
1931
2004
  //# sourceMappingURL=components.js.map
1932
2005
  //# sourceMappingURL=components.js.map