@wordrhyme/auto-crud 1.5.3 → 1.5.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.cjs CHANGED
@@ -66,18 +66,19 @@ function DataTablePagination({ table, pageSizeOptions = [
66
66
  40,
67
67
  50
68
68
  ], className,...props }) {
69
+ const total = table.options.rowCount ?? (table.options.manualPagination ? void 0 : table.getRowCount());
69
70
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
70
71
  className: cn("flex w-full flex-col-reverse items-center justify-between gap-4 overflow-auto p-1 sm:flex-row sm:gap-8", className),
71
72
  ...props,
72
73
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
73
- className: "flex-1 whitespace-nowrap text-muted-foreground text-sm",
74
- children: [
74
+ className: "flex flex-1 items-center gap-6 whitespace-nowrap text-muted-foreground text-sm",
75
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
75
76
  table.getFilteredSelectedRowModel().rows.length,
76
77
  " of",
77
78
  " ",
78
79
  table.getFilteredRowModel().rows.length,
79
80
  " row(s) selected."
80
- ]
81
+ ] }), total !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: ["Total: ", total] })]
81
82
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
82
83
  className: "flex flex-col-reverse items-center gap-4 sm:flex-row sm:gap-6 lg:gap-8",
83
84
  children: [
@@ -4025,7 +4026,7 @@ const filterModeConfig = {
4025
4026
  tooltip: "Linear-style command filters"
4026
4027
  }
4027
4028
  };
4028
- function AutoTable({ schema, data, pageCount = 1, overrides, enableRowSelection = true, exclude, actions, pinnedColumns, filterMode, search = false, onDeleteSelected, onUpdateSelected, batchUpdateFields, actionBarExtra, actionBarActions, deleteConfirmation, initialSorting, enableExport = true, showDefaultExport = true, onSelectedCountChange, onSelectedRowsChange, getSelectedRows }) {
4029
+ function AutoTable({ schema, data, pageCount = 1, total, overrides, enableRowSelection = true, exclude, actions, pinnedColumns, filterMode, search = false, onDeleteSelected, onUpdateSelected, batchUpdateFields, actionBarExtra, actionBarActions, deleteConfirmation, initialSorting, enableExport = true, showDefaultExport = true, onSelectedCountChange, onSelectedRowsChange, getSelectedRows }) {
4029
4030
  const modes = filterMode ? Array.isArray(filterMode) ? filterMode : [filterMode] : DEFAULT_MODES;
4030
4031
  const [currentMode, setCurrentMode] = useQueryState("filterMode", parseAsStringEnum(modes).withDefault(modes[0] ?? "simple"));
4031
4032
  const showToggle = modes.length > 1;
@@ -4054,23 +4055,25 @@ function AutoTable({ schema, data, pageCount = 1, overrides, enableRowSelection
4054
4055
  exclude,
4055
4056
  actions
4056
4057
  ]);
4058
+ const stableInitialState = (0, react.useMemo)(() => ({
4059
+ sorting: initialSorting,
4060
+ columnPinning: pinnedColumns ?? {
4061
+ left: enableRowSelection ? ["select"] : [],
4062
+ right: actions ? ["actions"] : []
4063
+ }
4064
+ }), [
4065
+ initialSorting,
4066
+ pinnedColumns,
4067
+ enableRowSelection,
4068
+ actions
4069
+ ]);
4057
4070
  const { table, shallow, debounceMs, throttleMs } = useDataTable({
4058
4071
  data,
4059
4072
  columns,
4060
4073
  pageCount,
4074
+ ...total !== void 0 ? { rowCount: total } : {},
4061
4075
  enableAdvancedFilter,
4062
- initialState: (0, react.useMemo)(() => ({
4063
- sorting: initialSorting,
4064
- columnPinning: pinnedColumns ?? {
4065
- left: enableRowSelection ? ["select"] : [],
4066
- right: actions ? ["actions"] : []
4067
- }
4068
- }), [
4069
- initialSorting,
4070
- pinnedColumns,
4071
- enableRowSelection,
4072
- actions
4073
- ]),
4076
+ initialState: stableInitialState,
4074
4077
  shallow: false,
4075
4078
  clearOnDefault: true
4076
4079
  });
@@ -7081,6 +7084,7 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
7081
7084
  data: resource.tableData.data,
7082
7085
  schema: resolvedSchema,
7083
7086
  pageCount: resource.tableData.pageCount,
7087
+ ...resource.tableData.total !== void 0 ? { total: resource.tableData.total } : {},
7084
7088
  overrides: tableOverrides,
7085
7089
  exclude: hiddenColumns,
7086
7090
  filterMode: tableConfig?.filterModes,
@@ -8192,6 +8196,7 @@ function useAutoCrudResource({ router, schema, query: queryTransform, options =
8192
8196
  tableData: {
8193
8197
  data: tableRows,
8194
8198
  pageCount: listQuery.data?.pageCount ?? 0,
8199
+ ...typeof listQuery.data?.total === "number" ? { total: listQuery.data.total } : {},
8195
8200
  isLoading: listQuery.isLoading,
8196
8201
  isFetching: listQuery.isFetching
8197
8202
  },
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime2 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime3 from "react/jsx-runtime";
2
2
  import { z } from "zod";
3
3
  import { JsonSchemaFormScope } from "@wordrhyme/formily-shadcn";
4
4
  import * as _tanstack_react_table0 from "@tanstack/react-table";
@@ -151,6 +151,8 @@ interface UseAutoCrudResourceReturn<TSchema extends z.ZodObject<z.ZodRawShape>,
151
151
  tableData: {
152
152
  data: TListItem[];
153
153
  pageCount: number;
154
+ /** Total rows matching the current search and filters. */
155
+ total?: number;
154
156
  isLoading: boolean;
155
157
  /** 是否正在获取数据(用于显示微妙的加载指示器) */
156
158
  isFetching: boolean;
@@ -411,7 +413,7 @@ declare function AutoTableActionBar<TData>({
411
413
  extraActions,
412
414
  actions,
413
415
  deleteConfirmation
414
- }: AutoTableActionBarProps<TData>): react_jsx_runtime2.JSX.Element;
416
+ }: AutoTableActionBarProps<TData>): react_jsx_runtime3.JSX.Element;
415
417
  //#endregion
416
418
  //#region src/lib/schema-bridge/types.d.ts
417
419
  /**
@@ -519,6 +521,8 @@ interface AutoTableProps<T extends z.ZodObject<z.ZodRawShape>> {
519
521
  schema: T;
520
522
  data: z.infer<T>[];
521
523
  pageCount?: number;
524
+ /** Total rows matching the current search and filters. */
525
+ total?: number;
522
526
  overrides?: ColumnOverrides<z.infer<T>>;
523
527
  enableRowSelection?: boolean;
524
528
  exclude?: (keyof z.infer<T>)[];
@@ -568,6 +572,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
568
572
  schema,
569
573
  data,
570
574
  pageCount,
575
+ total,
571
576
  overrides,
572
577
  enableRowSelection,
573
578
  exclude,
@@ -587,7 +592,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
587
592
  onSelectedCountChange,
588
593
  onSelectedRowsChange,
589
594
  getSelectedRows
590
- }: AutoTableProps<T>): react_jsx_runtime2.JSX.Element;
595
+ }: AutoTableProps<T>): react_jsx_runtime3.JSX.Element;
591
596
  //#endregion
592
597
  //#region src/i18n/locale.d.ts
593
598
  /**
@@ -1079,7 +1084,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
1079
1084
  toolbarActions,
1080
1085
  locale: localeProp,
1081
1086
  onCreate
1082
- }: AutoCrudTableProps<TSchema>): react_jsx_runtime2.JSX.Element;
1087
+ }: AutoCrudTableProps<TSchema>): react_jsx_runtime3.JSX.Element;
1083
1088
  //#endregion
1084
1089
  //#region src/components/auto-crud/auto-form.d.ts
1085
1090
  interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
@@ -1118,7 +1123,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
1118
1123
  labelAlign,
1119
1124
  labelWidth,
1120
1125
  showSubmitButton
1121
- }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime2.JSX.Element;
1126
+ }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime3.JSX.Element;
1122
1127
  declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
1123
1128
  ref?: React.Ref<AutoFormRef>;
1124
1129
  }) => ReturnType<typeof AutoFormInner>;
@@ -1434,7 +1439,7 @@ declare function AutoTableSimpleFilters<TData>({
1434
1439
  filters: externalFilters,
1435
1440
  onFiltersChange,
1436
1441
  leading
1437
- }: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime2.JSX.Element | null;
1442
+ }: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime3.JSX.Element | null;
1438
1443
  //#endregion
1439
1444
  //#region src/components/auto-crud/form-modal.d.ts
1440
1445
  type ModalVariant = 'dialog' | 'sheet';
@@ -1478,7 +1483,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
1478
1483
  labelAlign,
1479
1484
  labelWidth,
1480
1485
  className
1481
- }: CrudFormModalProps<T>): react_jsx_runtime2.JSX.Element;
1486
+ }: CrudFormModalProps<T>): react_jsx_runtime3.JSX.Element;
1482
1487
  //#endregion
1483
1488
  //#region src/components/auto-crud/import-dialog.d.ts
1484
1489
  interface ImportDialogProps {
@@ -1500,7 +1505,7 @@ declare function ImportDialog({
1500
1505
  columns,
1501
1506
  title,
1502
1507
  locale
1503
- }: ImportDialogProps): react_jsx_runtime2.JSX.Element;
1508
+ }: ImportDialogProps): react_jsx_runtime3.JSX.Element;
1504
1509
  //#endregion
1505
1510
  //#region src/components/auto-crud/export-dialog.d.ts
1506
1511
  type ExportMode = 'selected' | 'filtered';
@@ -1520,7 +1525,7 @@ declare function ExportDialog({
1520
1525
  selectedCount,
1521
1526
  onExport,
1522
1527
  canExportFiltered
1523
- }: ExportDialogProps): react_jsx_runtime2.JSX.Element;
1528
+ }: ExportDialogProps): react_jsx_runtime3.JSX.Element;
1524
1529
  //#endregion
1525
1530
  //#region src/components/data-table/data-table.d.ts
1526
1531
  interface DataTableProps<TData> extends React$1.ComponentProps<'div'> {
@@ -1533,7 +1538,7 @@ declare function DataTable<TData>({
1533
1538
  children,
1534
1539
  className,
1535
1540
  ...props
1536
- }: DataTableProps<TData>): react_jsx_runtime2.JSX.Element;
1541
+ }: DataTableProps<TData>): react_jsx_runtime3.JSX.Element;
1537
1542
  //#endregion
1538
1543
  //#region src/components/data-table/data-table-advanced-toolbar.d.ts
1539
1544
  interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<'div'> {
@@ -1544,7 +1549,7 @@ declare function DataTableAdvancedToolbar<TData>({
1544
1549
  children,
1545
1550
  className,
1546
1551
  ...props
1547
- }: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime2.JSX.Element;
1552
+ }: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime3.JSX.Element;
1548
1553
  //#endregion
1549
1554
  //#region src/components/data-table/data-table-column-header.d.ts
1550
1555
  interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
@@ -1556,7 +1561,7 @@ declare function DataTableColumnHeader<TData, TValue>({
1556
1561
  label,
1557
1562
  className,
1558
1563
  ...props
1559
- }: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime2.JSX.Element;
1564
+ }: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime3.JSX.Element;
1560
1565
  //#endregion
1561
1566
  //#region src/components/data-table/data-table-faceted-filter.d.ts
1562
1567
  interface DataTableFacetedFilterProps<TData, TValue> {
@@ -1570,7 +1575,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
1570
1575
  title,
1571
1576
  options,
1572
1577
  multiple
1573
- }: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime2.JSX.Element;
1578
+ }: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime3.JSX.Element;
1574
1579
  //#endregion
1575
1580
  //#region src/components/data-table/data-table-pagination.d.ts
1576
1581
  interface DataTablePaginationProps<TData> extends React.ComponentProps<'div'> {
@@ -1582,7 +1587,7 @@ declare function DataTablePagination<TData>({
1582
1587
  pageSizeOptions,
1583
1588
  className,
1584
1589
  ...props
1585
- }: DataTablePaginationProps<TData>): react_jsx_runtime2.JSX.Element;
1590
+ }: DataTablePaginationProps<TData>): react_jsx_runtime3.JSX.Element;
1586
1591
  //#endregion
1587
1592
  //#region src/components/data-table/data-table-toolbar.d.ts
1588
1593
  interface DataTableToolbarProps<TData> extends React$1.ComponentProps<'div'> {
@@ -1593,7 +1598,7 @@ declare function DataTableToolbar<TData>({
1593
1598
  children,
1594
1599
  className,
1595
1600
  ...props
1596
- }: DataTableToolbarProps<TData>): react_jsx_runtime2.JSX.Element;
1601
+ }: DataTableToolbarProps<TData>): react_jsx_runtime3.JSX.Element;
1597
1602
  //#endregion
1598
1603
  //#region src/components/data-table/data-table-view-options.d.ts
1599
1604
  interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
@@ -1604,7 +1609,7 @@ declare function DataTableViewOptions<TData>({
1604
1609
  table,
1605
1610
  disabled,
1606
1611
  ...props
1607
- }: DataTableViewOptionsProps<TData>): react_jsx_runtime2.JSX.Element;
1612
+ }: DataTableViewOptionsProps<TData>): react_jsx_runtime3.JSX.Element;
1608
1613
  //#endregion
1609
1614
  //#region src/lib/crud-actions.d.ts
1610
1615
  type CrudActionZone = 'toolbar' | 'row' | 'batch';
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import * as _tanstack_react_table0 from "@tanstack/react-table";
3
3
  import { Column, ColumnDef, ColumnSort, Row, RowData, Table, TableOptions, TableState } from "@tanstack/react-table";
4
4
  import { DropdownMenuTrigger, PopoverContent } from "@wordrhyme/shadcn";
5
5
  import { ClassValue } from "clsx";
6
- import * as react_jsx_runtime3 from "react/jsx-runtime";
6
+ import * as react_jsx_runtime2 from "react/jsx-runtime";
7
7
  import { MultiCombobox, MultiComboboxOption, MultiComboboxProps, MultiComboboxTriggerRenderProps, Select, SelectMode, SelectOption, SelectProps, SelectSearchableDynamicProps, SelectSearchableMultipleProps, SelectSearchableProps, SelectSearchableSingleProps, SelectSimpleProps, SelectTriggerRenderProps } from "@wordrhyme/shadcn-ui";
8
8
  import { z } from "zod";
9
9
  import { JsonSchemaFormScope } from "@wordrhyme/formily-shadcn";
@@ -151,6 +151,8 @@ interface UseAutoCrudResourceReturn<TSchema extends z.ZodObject<z.ZodRawShape>,
151
151
  tableData: {
152
152
  data: TListItem[];
153
153
  pageCount: number;
154
+ /** Total rows matching the current search and filters. */
155
+ total?: number;
154
156
  isLoading: boolean;
155
157
  /** 是否正在获取数据(用于显示微妙的加载指示器) */
156
158
  isFetching: boolean;
@@ -411,7 +413,7 @@ declare function AutoTableActionBar<TData>({
411
413
  extraActions,
412
414
  actions,
413
415
  deleteConfirmation
414
- }: AutoTableActionBarProps<TData>): react_jsx_runtime3.JSX.Element;
416
+ }: AutoTableActionBarProps<TData>): react_jsx_runtime2.JSX.Element;
415
417
  //#endregion
416
418
  //#region src/lib/schema-bridge/types.d.ts
417
419
  /**
@@ -519,6 +521,8 @@ interface AutoTableProps<T extends z.ZodObject<z.ZodRawShape>> {
519
521
  schema: T;
520
522
  data: z.infer<T>[];
521
523
  pageCount?: number;
524
+ /** Total rows matching the current search and filters. */
525
+ total?: number;
522
526
  overrides?: ColumnOverrides<z.infer<T>>;
523
527
  enableRowSelection?: boolean;
524
528
  exclude?: (keyof z.infer<T>)[];
@@ -568,6 +572,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
568
572
  schema,
569
573
  data,
570
574
  pageCount,
575
+ total,
571
576
  overrides,
572
577
  enableRowSelection,
573
578
  exclude,
@@ -587,7 +592,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
587
592
  onSelectedCountChange,
588
593
  onSelectedRowsChange,
589
594
  getSelectedRows
590
- }: AutoTableProps<T>): react_jsx_runtime3.JSX.Element;
595
+ }: AutoTableProps<T>): react_jsx_runtime2.JSX.Element;
591
596
  //#endregion
592
597
  //#region src/i18n/locale.d.ts
593
598
  /**
@@ -1079,7 +1084,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
1079
1084
  toolbarActions,
1080
1085
  locale: localeProp,
1081
1086
  onCreate
1082
- }: AutoCrudTableProps<TSchema>): react_jsx_runtime3.JSX.Element;
1087
+ }: AutoCrudTableProps<TSchema>): react_jsx_runtime2.JSX.Element;
1083
1088
  //#endregion
1084
1089
  //#region src/components/auto-crud/auto-form.d.ts
1085
1090
  interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
@@ -1118,7 +1123,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
1118
1123
  labelAlign,
1119
1124
  labelWidth,
1120
1125
  showSubmitButton
1121
- }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime3.JSX.Element;
1126
+ }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime2.JSX.Element;
1122
1127
  declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
1123
1128
  ref?: React.Ref<AutoFormRef>;
1124
1129
  }) => ReturnType<typeof AutoFormInner>;
@@ -1434,7 +1439,7 @@ declare function AutoTableSimpleFilters<TData>({
1434
1439
  filters: externalFilters,
1435
1440
  onFiltersChange,
1436
1441
  leading
1437
- }: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime3.JSX.Element | null;
1442
+ }: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime2.JSX.Element | null;
1438
1443
  //#endregion
1439
1444
  //#region src/components/auto-crud/form-modal.d.ts
1440
1445
  type ModalVariant = 'dialog' | 'sheet';
@@ -1478,7 +1483,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
1478
1483
  labelAlign,
1479
1484
  labelWidth,
1480
1485
  className
1481
- }: CrudFormModalProps<T>): react_jsx_runtime3.JSX.Element;
1486
+ }: CrudFormModalProps<T>): react_jsx_runtime2.JSX.Element;
1482
1487
  //#endregion
1483
1488
  //#region src/components/auto-crud/import-dialog.d.ts
1484
1489
  interface ImportDialogProps {
@@ -1500,7 +1505,7 @@ declare function ImportDialog({
1500
1505
  columns,
1501
1506
  title,
1502
1507
  locale
1503
- }: ImportDialogProps): react_jsx_runtime3.JSX.Element;
1508
+ }: ImportDialogProps): react_jsx_runtime2.JSX.Element;
1504
1509
  //#endregion
1505
1510
  //#region src/components/auto-crud/export-dialog.d.ts
1506
1511
  type ExportMode = 'selected' | 'filtered';
@@ -1520,7 +1525,7 @@ declare function ExportDialog({
1520
1525
  selectedCount,
1521
1526
  onExport,
1522
1527
  canExportFiltered
1523
- }: ExportDialogProps): react_jsx_runtime3.JSX.Element;
1528
+ }: ExportDialogProps): react_jsx_runtime2.JSX.Element;
1524
1529
  //#endregion
1525
1530
  //#region src/components/data-table/data-table.d.ts
1526
1531
  interface DataTableProps<TData> extends React$1.ComponentProps<'div'> {
@@ -1533,7 +1538,7 @@ declare function DataTable<TData>({
1533
1538
  children,
1534
1539
  className,
1535
1540
  ...props
1536
- }: DataTableProps<TData>): react_jsx_runtime3.JSX.Element;
1541
+ }: DataTableProps<TData>): react_jsx_runtime2.JSX.Element;
1537
1542
  //#endregion
1538
1543
  //#region src/components/data-table/data-table-advanced-toolbar.d.ts
1539
1544
  interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<'div'> {
@@ -1544,7 +1549,7 @@ declare function DataTableAdvancedToolbar<TData>({
1544
1549
  children,
1545
1550
  className,
1546
1551
  ...props
1547
- }: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime3.JSX.Element;
1552
+ }: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime2.JSX.Element;
1548
1553
  //#endregion
1549
1554
  //#region src/components/data-table/data-table-column-header.d.ts
1550
1555
  interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
@@ -1556,7 +1561,7 @@ declare function DataTableColumnHeader<TData, TValue>({
1556
1561
  label,
1557
1562
  className,
1558
1563
  ...props
1559
- }: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime3.JSX.Element;
1564
+ }: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime2.JSX.Element;
1560
1565
  //#endregion
1561
1566
  //#region src/components/data-table/data-table-faceted-filter.d.ts
1562
1567
  interface DataTableFacetedFilterProps<TData, TValue> {
@@ -1570,7 +1575,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
1570
1575
  title,
1571
1576
  options,
1572
1577
  multiple
1573
- }: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime3.JSX.Element;
1578
+ }: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime2.JSX.Element;
1574
1579
  //#endregion
1575
1580
  //#region src/components/data-table/data-table-pagination.d.ts
1576
1581
  interface DataTablePaginationProps<TData> extends React.ComponentProps<'div'> {
@@ -1582,7 +1587,7 @@ declare function DataTablePagination<TData>({
1582
1587
  pageSizeOptions,
1583
1588
  className,
1584
1589
  ...props
1585
- }: DataTablePaginationProps<TData>): react_jsx_runtime3.JSX.Element;
1590
+ }: DataTablePaginationProps<TData>): react_jsx_runtime2.JSX.Element;
1586
1591
  //#endregion
1587
1592
  //#region src/components/data-table/data-table-toolbar.d.ts
1588
1593
  interface DataTableToolbarProps<TData> extends React$1.ComponentProps<'div'> {
@@ -1593,7 +1598,7 @@ declare function DataTableToolbar<TData>({
1593
1598
  children,
1594
1599
  className,
1595
1600
  ...props
1596
- }: DataTableToolbarProps<TData>): react_jsx_runtime3.JSX.Element;
1601
+ }: DataTableToolbarProps<TData>): react_jsx_runtime2.JSX.Element;
1597
1602
  //#endregion
1598
1603
  //#region src/components/data-table/data-table-view-options.d.ts
1599
1604
  interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
@@ -1604,7 +1609,7 @@ declare function DataTableViewOptions<TData>({
1604
1609
  table,
1605
1610
  disabled,
1606
1611
  ...props
1607
- }: DataTableViewOptionsProps<TData>): react_jsx_runtime3.JSX.Element;
1612
+ }: DataTableViewOptionsProps<TData>): react_jsx_runtime2.JSX.Element;
1608
1613
  //#endregion
1609
1614
  //#region src/lib/crud-actions.d.ts
1610
1615
  type CrudActionZone = 'toolbar' | 'row' | 'batch';
package/dist/index.js CHANGED
@@ -29,18 +29,19 @@ function DataTablePagination({ table, pageSizeOptions = [
29
29
  40,
30
30
  50
31
31
  ], className,...props }) {
32
+ const total = table.options.rowCount ?? (table.options.manualPagination ? void 0 : table.getRowCount());
32
33
  return /* @__PURE__ */ jsxs("div", {
33
34
  className: cn("flex w-full flex-col-reverse items-center justify-between gap-4 overflow-auto p-1 sm:flex-row sm:gap-8", className),
34
35
  ...props,
35
36
  children: [/* @__PURE__ */ jsxs("div", {
36
- className: "flex-1 whitespace-nowrap text-muted-foreground text-sm",
37
- children: [
37
+ className: "flex flex-1 items-center gap-6 whitespace-nowrap text-muted-foreground text-sm",
38
+ children: [/* @__PURE__ */ jsxs("span", { children: [
38
39
  table.getFilteredSelectedRowModel().rows.length,
39
40
  " of",
40
41
  " ",
41
42
  table.getFilteredRowModel().rows.length,
42
43
  " row(s) selected."
43
- ]
44
+ ] }), total !== void 0 && /* @__PURE__ */ jsxs("span", { children: ["Total: ", total] })]
44
45
  }), /* @__PURE__ */ jsxs("div", {
45
46
  className: "flex flex-col-reverse items-center gap-4 sm:flex-row sm:gap-6 lg:gap-8",
46
47
  children: [
@@ -3988,7 +3989,7 @@ const filterModeConfig = {
3988
3989
  tooltip: "Linear-style command filters"
3989
3990
  }
3990
3991
  };
3991
- function AutoTable({ schema, data, pageCount = 1, overrides, enableRowSelection = true, exclude, actions, pinnedColumns, filterMode, search = false, onDeleteSelected, onUpdateSelected, batchUpdateFields, actionBarExtra, actionBarActions, deleteConfirmation, initialSorting, enableExport = true, showDefaultExport = true, onSelectedCountChange, onSelectedRowsChange, getSelectedRows }) {
3992
+ function AutoTable({ schema, data, pageCount = 1, total, overrides, enableRowSelection = true, exclude, actions, pinnedColumns, filterMode, search = false, onDeleteSelected, onUpdateSelected, batchUpdateFields, actionBarExtra, actionBarActions, deleteConfirmation, initialSorting, enableExport = true, showDefaultExport = true, onSelectedCountChange, onSelectedRowsChange, getSelectedRows }) {
3992
3993
  const modes = filterMode ? Array.isArray(filterMode) ? filterMode : [filterMode] : DEFAULT_MODES;
3993
3994
  const [currentMode, setCurrentMode] = useQueryState("filterMode", parseAsStringEnum(modes).withDefault(modes[0] ?? "simple"));
3994
3995
  const showToggle = modes.length > 1;
@@ -4017,23 +4018,25 @@ function AutoTable({ schema, data, pageCount = 1, overrides, enableRowSelection
4017
4018
  exclude,
4018
4019
  actions
4019
4020
  ]);
4021
+ const stableInitialState = useMemo(() => ({
4022
+ sorting: initialSorting,
4023
+ columnPinning: pinnedColumns ?? {
4024
+ left: enableRowSelection ? ["select"] : [],
4025
+ right: actions ? ["actions"] : []
4026
+ }
4027
+ }), [
4028
+ initialSorting,
4029
+ pinnedColumns,
4030
+ enableRowSelection,
4031
+ actions
4032
+ ]);
4020
4033
  const { table, shallow, debounceMs, throttleMs } = useDataTable({
4021
4034
  data,
4022
4035
  columns,
4023
4036
  pageCount,
4037
+ ...total !== void 0 ? { rowCount: total } : {},
4024
4038
  enableAdvancedFilter,
4025
- initialState: useMemo(() => ({
4026
- sorting: initialSorting,
4027
- columnPinning: pinnedColumns ?? {
4028
- left: enableRowSelection ? ["select"] : [],
4029
- right: actions ? ["actions"] : []
4030
- }
4031
- }), [
4032
- initialSorting,
4033
- pinnedColumns,
4034
- enableRowSelection,
4035
- actions
4036
- ]),
4039
+ initialState: stableInitialState,
4037
4040
  shallow: false,
4038
4041
  clearOnDefault: true
4039
4042
  });
@@ -7044,6 +7047,7 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
7044
7047
  data: resource.tableData.data,
7045
7048
  schema: resolvedSchema,
7046
7049
  pageCount: resource.tableData.pageCount,
7050
+ ...resource.tableData.total !== void 0 ? { total: resource.tableData.total } : {},
7047
7051
  overrides: tableOverrides,
7048
7052
  exclude: hiddenColumns,
7049
7053
  filterMode: tableConfig?.filterModes,
@@ -8155,6 +8159,7 @@ function useAutoCrudResource({ router, schema, query: queryTransform, options =
8155
8159
  tableData: {
8156
8160
  data: tableRows,
8157
8161
  pageCount: listQuery.data?.pageCount ?? 0,
8162
+ ...typeof listQuery.data?.total === "number" ? { total: listQuery.data.total } : {},
8158
8163
  isLoading: listQuery.isLoading,
8159
8164
  isFetching: listQuery.isFetching
8160
8165
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wordrhyme/auto-crud",
3
3
  "type": "module",
4
- "version": "1.5.3",
4
+ "version": "1.5.4",
5
5
  "description": "Schema-first CRUD components with auto-generated tables and forms",
6
6
  "author": "wordrhyme",
7
7
  "license": "MIT",
@@ -63,8 +63,8 @@
63
63
  "tailwind-merge": "^3.5.0",
64
64
  "vaul": "^1.1.2",
65
65
  "@wordrhyme/formily-shadcn": "1.13.4",
66
- "@wordrhyme/shadcn": "1.3.4",
67
- "@wordrhyme/shadcn-ui": "1.32.9"
66
+ "@wordrhyme/shadcn-ui": "1.32.9",
67
+ "@wordrhyme/shadcn": "1.3.4"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@storybook/react": "^8.6.18",
@@ -84,9 +84,9 @@
84
84
  "tsdown": "^0.15.12",
85
85
  "typescript": "^5.9.3",
86
86
  "vitest": "^3.2.4",
87
- "@internal/eslint-config": "0.3.0",
88
- "@internal/tsconfig": "0.1.0",
89
87
  "@internal/prettier-config": "0.0.1",
88
+ "@internal/tsconfig": "0.1.0",
89
+ "@internal/eslint-config": "0.3.0",
90
90
  "@internal/tsdown-config": "0.1.0",
91
91
  "@internal/vitest-config": "0.1.0"
92
92
  },