@wordrhyme/auto-crud 1.7.0 → 1.8.0

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.js CHANGED
@@ -2,17 +2,17 @@ import * as React from "react";
2
2
  import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
3
3
  import { ArrowDownUp, BadgeCheck, CalendarIcon, Check, CheckCircle2, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, ChevronsLeft, ChevronsRight, ChevronsUpDown, CommandIcon, Download, Ellipsis, EyeOff, FileDown, FileSpreadsheetIcon, GripVertical, ListFilter, ListFilterIcon, Loader2, PlusCircle, RefreshCw, Settings2, Text, Trash2, Upload, X, XCircle } from "lucide-react";
4
4
  import { flexRender, getCoreRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
5
- import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, Badge, Button, Calendar, Checkbox, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger, Input, Label, Popover, PopoverContent, PopoverTrigger, Select as Select$1, SelectContent, SelectItem, SelectTrigger, SelectValue, Separator, Sheet, SheetContent, SheetHeader, SheetTitle, Slider, Switch, Table as Table$1, TableBody, TableCell, TableHead, TableHeader, TableRow, cn as cn$1 } from "@wordrhyme/shadcn";
5
+ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, Badge, Button, Calendar, Checkbox, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger, Input, Label, Popover, PopoverContent, PopoverTrigger, Select as Select$1, SelectContent, SelectItem, SelectTrigger, SelectValue, Separator, Slider, Switch, Table as Table$1, TableBody, TableCell, TableHead, TableHeader, TableRow, cn as cn$1 } from "@wordrhyme/shadcn";
6
6
  import { clsx } from "clsx";
7
7
  import { twMerge } from "tailwind-merge";
8
8
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { customAlphabet } from "nanoid";
10
10
  import { ActionBar, ActionBarClose, ActionBarGroup, ActionBarItem, ActionBarSelection, ActionBarSeparator, Faceted, FacetedBadgeList, FacetedContent, FacetedEmpty, FacetedGroup, FacetedInput, FacetedItem, FacetedList, FacetedTrigger, MultiCombobox, Select, Select as Select$2, Sortable, SortableContent, SortableItem, SortableItemHandle, SortableOverlay } from "@wordrhyme/shadcn-ui";
11
- import { Dialog as Dialog$1, DialogContent as DialogContent$1, DialogDescription as DialogDescription$1, DialogHeader as DialogHeader$1, DialogTitle as DialogTitle$1, DropdownMenu as DropdownMenu$1, DropdownMenuContent as DropdownMenuContent$1, DropdownMenuItem as DropdownMenuItem$1, DropdownMenuSeparator, DropdownMenuTrigger as DropdownMenuTrigger$1, Sheet as Sheet$1, SheetContent as SheetContent$1, SheetDescription, SheetHeader as SheetHeader$1, SheetTitle as SheetTitle$1 } from "@wordrhyme/ui";
11
+ import { AlertDialog as AlertDialog$1, AlertDialogAction as AlertDialogAction$1, AlertDialogCancel as AlertDialogCancel$1, AlertDialogContent as AlertDialogContent$1, AlertDialogDescription as AlertDialogDescription$1, AlertDialogFooter as AlertDialogFooter$1, AlertDialogHeader as AlertDialogHeader$1, AlertDialogTitle as AlertDialogTitle$1, Button as Button$1, Calendar as Calendar$1, Dialog as Dialog$1, DialogContent as DialogContent$1, DialogDescription as DialogDescription$1, DialogHeader as DialogHeader$1, DialogTitle as DialogTitle$1, DropdownMenu as DropdownMenu$1, DropdownMenuContent as DropdownMenuContent$1, DropdownMenuItem as DropdownMenuItem$1, DropdownMenuSeparator, DropdownMenuTrigger as DropdownMenuTrigger$1, Popover as Popover$1, PopoverContent as PopoverContent$1, PopoverTrigger as PopoverTrigger$1, Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "@wordrhyme/ui";
12
12
  import { z } from "zod";
13
+ import { DatePicker, Form, JsonSchemaField, connect, mapProps } from "@wordrhyme/formily-shadcn";
13
14
  import { createForm } from "@formily/core";
14
15
  import { action, observable } from "@formily/reactive";
15
- import { Form, JsonSchemaField, connect, mapProps } from "@wordrhyme/formily-shadcn";
16
16
  import { toast } from "sonner";
17
17
  import { keepPreviousData } from "@tanstack/react-query";
18
18
 
@@ -29,12 +29,66 @@ function DataTablePagination({ table, pageSizeOptions = [
29
29
  30,
30
30
  40,
31
31
  50
32
- ], className,...props }) {
32
+ ], alwaysShowFirstLast = false, responsive = false, showPageJump = false, pageJumpLabel = "Go to page", className,...props }) {
33
+ const pageJump = useRef(null);
34
+ const container = useRef(null);
35
+ const summary = useRef(null);
36
+ const controls = useRef(null);
37
+ const navigation = useRef(null);
38
+ const [hasSpace, setHasSpace] = useState(false);
39
+ const hideExtras = responsive && !hasSpace;
40
+ const hiddenClass = hideExtras ? "absolute invisible pointer-events-none left-0 top-0" : void 0;
41
+ const pageIndex = table.getState().pagination.pageIndex;
42
+ const pageCount = table.getPageCount();
43
+ const canJump = Number.isFinite(pageCount) && pageCount > 0;
33
44
  const total = table.options.rowCount ?? (table.options.manualPagination ? void 0 : table.getRowCount());
45
+ useEffect(() => {
46
+ if (!responsive || !container.current || !summary.current || !controls.current || !navigation.current) return;
47
+ if (typeof ResizeObserver === "undefined") return;
48
+ const root = container.current;
49
+ const info = summary.current;
50
+ const group = controls.current;
51
+ const nav = navigation.current;
52
+ const jump = pageJump.current;
53
+ const gap = (node) => parseFloat(getComputedStyle(node).columnGap) || 0;
54
+ const width = (node) => {
55
+ const children = Array.from(node.children);
56
+ return children.reduce((sum, child) => {
57
+ const style = getComputedStyle(child);
58
+ return sum + (child === nav || child === jump ? width(child) : child.getBoundingClientRect().width) + (parseFloat(style.marginLeft) || 0) + (parseFloat(style.marginRight) || 0);
59
+ }, 0) + Math.max(0, children.length - 1) * gap(node);
60
+ };
61
+ const measure = () => {
62
+ const style = getComputedStyle(root);
63
+ const available = root.clientWidth - (parseFloat(style.paddingLeft) || 0) - (parseFloat(style.paddingRight) || 0);
64
+ const required = style.flexDirection.startsWith("column") ? Math.max(width(info), width(group)) : width(info) + width(group) + gap(root);
65
+ setHasSpace(available + .5 >= required);
66
+ };
67
+ const observer = new ResizeObserver(measure);
68
+ for (const node of [
69
+ root,
70
+ info,
71
+ group,
72
+ nav,
73
+ ...info.children,
74
+ ...group.children,
75
+ ...nav.children,
76
+ ...jump?.children ?? []
77
+ ]) observer.observe(node);
78
+ measure();
79
+ return () => observer.disconnect();
80
+ }, [
81
+ responsive,
82
+ showPageJump,
83
+ alwaysShowFirstLast,
84
+ total !== void 0
85
+ ]);
34
86
  return /* @__PURE__ */ jsxs("div", {
35
- 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),
87
+ ref: container,
88
+ className: cn("flex w-full flex-col-reverse items-center justify-between gap-4 overflow-auto p-1 sm:flex-row sm:gap-8", responsive && "relative", className),
36
89
  ...props,
37
90
  children: [/* @__PURE__ */ jsxs("div", {
91
+ ref: summary,
38
92
  className: "flex flex-1 items-center gap-6 whitespace-nowrap text-muted-foreground text-sm",
39
93
  children: [/* @__PURE__ */ jsxs("span", { children: [
40
94
  table.getFilteredSelectedRowModel().rows.length,
@@ -44,7 +98,8 @@ function DataTablePagination({ table, pageSizeOptions = [
44
98
  " row(s) selected."
45
99
  ] }), total !== void 0 && /* @__PURE__ */ jsxs("span", { children: ["Total: ", total] })]
46
100
  }), /* @__PURE__ */ jsxs("div", {
47
- className: "flex flex-col-reverse items-center gap-4 sm:flex-row sm:gap-6 lg:gap-8",
101
+ ref: controls,
102
+ className: cn("flex items-center gap-4 sm:gap-6 lg:gap-8", responsive ? "flex-row flex-wrap justify-center whitespace-nowrap [&>*]:shrink-0" : "flex-col-reverse sm:flex-row"),
48
103
  children: [
49
104
  /* @__PURE__ */ jsxs("div", {
50
105
  className: "flex items-center space-x-2",
@@ -72,19 +127,55 @@ function DataTablePagination({ table, pageSizeOptions = [
72
127
  className: "flex items-center justify-center font-medium text-sm",
73
128
  children: [
74
129
  "Page ",
75
- table.getState().pagination.pageIndex + 1,
130
+ pageIndex + 1,
76
131
  " of ",
77
- table.getPageCount()
132
+ pageCount
78
133
  ]
79
134
  }),
135
+ showPageJump && /* @__PURE__ */ jsx("div", {
136
+ ref: pageJump,
137
+ className: hideExtras ? "pointer-events-none absolute inset-x-0 top-0 invisible overflow-hidden" : void 0,
138
+ "aria-hidden": hideExtras || void 0,
139
+ children: /* @__PURE__ */ jsxs("form", {
140
+ className: "flex w-max items-center gap-2",
141
+ onSubmit: (event) => {
142
+ event.preventDefault();
143
+ const page = Number(new FormData(event.currentTarget).get("page"));
144
+ if (canJump && Number.isInteger(page) && page >= 1 && page <= pageCount) table.setPageIndex(page - 1);
145
+ },
146
+ children: [/* @__PURE__ */ jsxs("label", {
147
+ className: "flex items-center gap-2 whitespace-nowrap text-sm",
148
+ children: [pageJumpLabel, /* @__PURE__ */ jsx(Input, {
149
+ name: "page",
150
+ type: "number",
151
+ min: 1,
152
+ max: canJump ? pageCount : void 0,
153
+ step: 1,
154
+ required: true,
155
+ defaultValue: pageIndex + 1,
156
+ disabled: !canJump,
157
+ className: "h-8 w-20"
158
+ }, `${pageIndex}-${pageCount}`)]
159
+ }), /* @__PURE__ */ jsx(Button, {
160
+ type: "submit",
161
+ variant: "outline",
162
+ size: "icon",
163
+ className: "size-8",
164
+ disabled: !canJump,
165
+ "aria-label": pageJumpLabel,
166
+ children: /* @__PURE__ */ jsx(ChevronRight, {})
167
+ })]
168
+ })
169
+ }),
80
170
  /* @__PURE__ */ jsxs("div", {
171
+ ref: navigation,
81
172
  className: "flex items-center space-x-2",
82
173
  children: [
83
174
  /* @__PURE__ */ jsx(Button, {
84
175
  "aria-label": "Go to first page",
85
176
  variant: "outline",
86
177
  size: "icon",
87
- className: "hidden size-8 lg:flex",
178
+ className: cn("size-8", alwaysShowFirstLast ? "flex" : "hidden lg:flex", hiddenClass),
88
179
  onClick: () => table.setPageIndex(0),
89
180
  disabled: !table.getCanPreviousPage(),
90
181
  children: /* @__PURE__ */ jsx(ChevronsLeft, {})
@@ -111,9 +202,9 @@ function DataTablePagination({ table, pageSizeOptions = [
111
202
  "aria-label": "Go to last page",
112
203
  variant: "outline",
113
204
  size: "icon",
114
- className: "hidden size-8 lg:flex",
205
+ className: cn("size-8", alwaysShowFirstLast ? "flex" : "hidden lg:flex", hiddenClass),
115
206
  onClick: () => table.setPageIndex(table.getPageCount() - 1),
116
- disabled: !table.getCanNextPage(),
207
+ disabled: !table.getCanNextPage() || alwaysShowFirstLast && !canJump,
117
208
  children: /* @__PURE__ */ jsx(ChevronsRight, {})
118
209
  })
119
210
  ]
@@ -459,7 +550,7 @@ function formatDate(date, opts = {}, preset) {
459
550
 
460
551
  //#endregion
461
552
  //#region src/components/data-table/data-table.tsx
462
- function DataTable({ table, actionBar, children, className, classNames,...props }) {
553
+ function DataTable({ table, actionBar, pagination, children, className, classNames,...props }) {
463
554
  useDateFormatterVersion();
464
555
  const columns = [
465
556
  ...table.getLeftVisibleLeafColumns(),
@@ -524,7 +615,10 @@ function DataTable({ table, actionBar, children, className, classNames,...props
524
615
  }),
525
616
  /* @__PURE__ */ jsxs("div", {
526
617
  className: "flex flex-col gap-2.5",
527
- children: [/* @__PURE__ */ jsx(DataTablePagination, { table }), actionBar && table.getFilteredSelectedRowModel().rows.length > 0 && actionBar]
618
+ children: [/* @__PURE__ */ jsx(DataTablePagination, {
619
+ table,
620
+ ...pagination
621
+ }), actionBar && table.getFilteredSelectedRowModel().rows.length > 0 && actionBar]
528
622
  })
529
623
  ]
530
624
  });
@@ -1063,6 +1157,59 @@ function parseCalendarDate(value) {
1063
1157
  const date = new Date(Number(value));
1064
1158
  return Number.isNaN(date.getTime()) ? void 0 : date;
1065
1159
  }
1160
+ /** Resolve bounds and the calendar's today marker in the Host's configured time zone. */
1161
+ function calendarMaxDate(value) {
1162
+ if (value !== "today") return parseCalendarDate(value);
1163
+ return parseCalendarDate(calendarDay(/* @__PURE__ */ new Date(), calendarDayFormatter()));
1164
+ }
1165
+ function calendarDayFormatter() {
1166
+ return new Intl.DateTimeFormat("en-CA", {
1167
+ timeZone: getDateLocaleOptions()?.timeZone,
1168
+ year: "numeric",
1169
+ month: "2-digit",
1170
+ day: "2-digit"
1171
+ });
1172
+ }
1173
+ function calendarDay(date, formatter) {
1174
+ const parts = Object.fromEntries(formatter.formatToParts(date).map((part) => [part.type, part.value]));
1175
+ return `${parts.year}-${parts.month}-${parts.day}`;
1176
+ }
1177
+ /** Keep both the today marker and relative bounds current while a filter stays mounted. */
1178
+ function useCalendarToday() {
1179
+ useDateFormatterVersion();
1180
+ const timeZone = getDateLocaleOptions()?.timeZone;
1181
+ const [today, setToday] = useState(() => calendarMaxDate("today"));
1182
+ useEffect(() => {
1183
+ const formatter = calendarDayFormatter();
1184
+ let timer;
1185
+ const refresh = () => {
1186
+ clearTimeout(timer);
1187
+ const now = Date.now();
1188
+ const day = calendarDay(new Date(now), formatter);
1189
+ setToday((previous) => serializeCalendarDate(previous) === day ? previous : parseCalendarDate(day));
1190
+ let before = now;
1191
+ let after = now + 2880 * 60 * 1e3;
1192
+ while (after - before > 1) {
1193
+ const middle = Math.floor((before + after) / 2);
1194
+ if (calendarDay(new Date(middle), formatter) === day) before = middle;
1195
+ else after = middle;
1196
+ }
1197
+ timer = setTimeout(refresh, Math.max(1, after - Date.now()));
1198
+ };
1199
+ const onVisibilityChange = () => {
1200
+ if (!document.hidden) refresh();
1201
+ };
1202
+ refresh();
1203
+ window.addEventListener("focus", refresh);
1204
+ document.addEventListener("visibilitychange", onVisibilityChange);
1205
+ return () => {
1206
+ clearTimeout(timer);
1207
+ window.removeEventListener("focus", refresh);
1208
+ document.removeEventListener("visibilitychange", onVisibilityChange);
1209
+ };
1210
+ }, [timeZone]);
1211
+ return today;
1212
+ }
1066
1213
  function calendarPresentation() {
1067
1214
  const localeOptions = getDateLocaleOptions();
1068
1215
  const locale = localeOptions?.locale ?? "en-US";
@@ -1284,7 +1431,7 @@ function DataTableFilterList({ table, debounceMs = DEBOUNCE_MS$2, throttleMs = T
1284
1431
  });
1285
1432
  }
1286
1433
  function DataTableFilterItem$1({ filter, index: index$1, filterItemId, joinOperator, setJoinOperator, columns, onFilterUpdate, onFilterRemove }) {
1287
- useDateFormatterVersion();
1434
+ const today = useCalendarToday();
1288
1435
  const [showFieldSelector, setShowFieldSelector] = React.useState(false);
1289
1436
  const [showOperatorSelector, setShowOperatorSelector] = React.useState(false);
1290
1437
  const [showValueSelector, setShowValueSelector] = React.useState(false);
@@ -1413,6 +1560,7 @@ function DataTableFilterItem$1({ filter, index: index$1, filterItemId, joinOpera
1413
1560
  /* @__PURE__ */ jsx("div", {
1414
1561
  className: "min-w-36 max-w-60 flex-1",
1415
1562
  children: onFilterInputRender$1({
1563
+ today,
1416
1564
  filter,
1417
1565
  inputId,
1418
1566
  column,
@@ -1443,7 +1591,9 @@ function DataTableFilterItem$1({ filter, index: index$1, filterItemId, joinOpera
1443
1591
  })
1444
1592
  });
1445
1593
  }
1446
- function onFilterInputRender$1({ filter, inputId, column, columnMeta, onFilterUpdate, showValueSelector, setShowValueSelector }) {
1594
+ function onFilterInputRender$1({ today, filter, inputId, column, columnMeta, onFilterUpdate, showValueSelector, setShowValueSelector }) {
1595
+ const maxDate = column.columnDef.meta?.maxDate;
1596
+ const upperBound = maxDate === "today" ? today : calendarMaxDate(maxDate);
1447
1597
  if (filter.operator === "isEmpty" || filter.operator === "isNotEmpty") return /* @__PURE__ */ jsx("div", {
1448
1598
  id: inputId,
1449
1599
  role: "status",
@@ -1599,6 +1749,8 @@ function onFilterInputRender$1({ filter, inputId, column, columnMeta, onFilterUp
1599
1749
  align: "start",
1600
1750
  className: "w-auto p-0",
1601
1751
  children: filter.operator === "isBetween" ? /* @__PURE__ */ jsx(Calendar, {
1752
+ today,
1753
+ disabled: upperBound ? { after: upperBound } : void 0,
1602
1754
  lang: calendarPresentation().locale,
1603
1755
  weekStartsOn: calendarPresentation().weekStartsOn,
1604
1756
  formatters: calendarPresentation().formatters,
@@ -1607,6 +1759,7 @@ function onFilterInputRender$1({ filter, inputId, column, columnMeta, onFilterUp
1607
1759
  autoFocus: true,
1608
1760
  captionLayout: "dropdown",
1609
1761
  mode: "range",
1762
+ excludeDisabled: !!column.columnDef.meta?.maxDate,
1610
1763
  selected: dateValue.length === 2 ? {
1611
1764
  from: parseCalendarDate(dateValue[0]),
1612
1765
  to: parseCalendarDate(dateValue[1])
@@ -1618,6 +1771,8 @@ function onFilterInputRender$1({ filter, inputId, column, columnMeta, onFilterUp
1618
1771
  onFilterUpdate(filter.filterId, { value: date ? [date.from ? serializeCalendarDate(date.from) : "", date.to ? serializeCalendarDate(date.to) : ""] : [] });
1619
1772
  }
1620
1773
  }) : /* @__PURE__ */ jsx(Calendar, {
1774
+ today,
1775
+ disabled: upperBound ? { after: upperBound } : void 0,
1621
1776
  lang: calendarPresentation().locale,
1622
1777
  weekStartsOn: calendarPresentation().weekStartsOn,
1623
1778
  formatters: calendarPresentation().formatters,
@@ -1840,7 +1995,7 @@ function DataTableFilterMenu({ table, debounceMs = DEBOUNCE_MS$1, throttleMs = T
1840
1995
  }
1841
1996
  function DataTableFilterItem({ filter, filterItemId, columns, onFilterUpdate, onFilterRemove }) {
1842
1997
  {
1843
- useDateFormatterVersion();
1998
+ const today = useCalendarToday();
1844
1999
  const [showFieldSelector, setShowFieldSelector] = React.useState(false);
1845
2000
  const [showOperatorSelector, setShowOperatorSelector] = React.useState(false);
1846
2001
  const [showValueSelector, setShowValueSelector] = React.useState(false);
@@ -1931,6 +2086,7 @@ function DataTableFilterItem({ filter, filterItemId, columns, onFilterUpdate, on
1931
2086
  })]
1932
2087
  }),
1933
2088
  onFilterInputRender({
2089
+ today,
1934
2090
  filter,
1935
2091
  column,
1936
2092
  inputId,
@@ -1951,7 +2107,9 @@ function DataTableFilterItem({ filter, filterItemId, columns, onFilterUpdate, on
1951
2107
  }
1952
2108
  }
1953
2109
  function FilterValueSelector({ column, value, onSelect }) {
1954
- useDateFormatterVersion();
2110
+ const today = useCalendarToday();
2111
+ const maxDate = column.columnDef.meta?.maxDate;
2112
+ const upperBound = maxDate === "today" ? today : calendarMaxDate(maxDate);
1955
2113
  switch (column.columnDef.meta?.variant ?? "text") {
1956
2114
  case "boolean": return /* @__PURE__ */ jsxs(CommandGroup, { children: [/* @__PURE__ */ jsx(CommandItem, {
1957
2115
  value: "true",
@@ -1980,6 +2138,8 @@ function FilterValueSelector({ column, value, onSelect }) {
1980
2138
  }, option.value)) });
1981
2139
  case "date":
1982
2140
  case "dateRange": return /* @__PURE__ */ jsx(Calendar, {
2141
+ today,
2142
+ disabled: upperBound ? { after: upperBound } : void 0,
1983
2143
  lang: calendarPresentation().locale,
1984
2144
  weekStartsOn: calendarPresentation().weekStartsOn,
1985
2145
  formatters: calendarPresentation().formatters,
@@ -2008,7 +2168,9 @@ function FilterValueSelector({ column, value, onSelect }) {
2008
2168
  }
2009
2169
  }
2010
2170
  }
2011
- function onFilterInputRender({ filter, column, inputId, onFilterUpdate, showValueSelector, setShowValueSelector }) {
2171
+ function onFilterInputRender({ today, filter, column, inputId, onFilterUpdate, showValueSelector, setShowValueSelector }) {
2172
+ const maxDate = column.columnDef.meta?.maxDate;
2173
+ const upperBound = maxDate === "today" ? today : calendarMaxDate(maxDate);
2012
2174
  if (filter.operator === "isEmpty" || filter.operator === "isNotEmpty") return /* @__PURE__ */ jsx("div", {
2013
2175
  id: inputId,
2014
2176
  role: "status",
@@ -2167,6 +2329,8 @@ function onFilterInputRender({ filter, column, inputId, onFilterUpdate, showValu
2167
2329
  align: "start",
2168
2330
  className: "w-auto p-0",
2169
2331
  children: filter.operator === "isBetween" ? /* @__PURE__ */ jsx(Calendar, {
2332
+ today,
2333
+ disabled: upperBound ? { after: upperBound } : void 0,
2170
2334
  lang: calendarPresentation().locale,
2171
2335
  weekStartsOn: calendarPresentation().weekStartsOn,
2172
2336
  formatters: calendarPresentation().formatters,
@@ -2174,6 +2338,7 @@ function onFilterInputRender({ filter, column, inputId, onFilterUpdate, showValu
2174
2338
  autoFocus: true,
2175
2339
  captionLayout: "dropdown",
2176
2340
  mode: "range",
2341
+ excludeDisabled: !!column.columnDef.meta?.maxDate,
2177
2342
  selected: dateValue.length === 2 ? {
2178
2343
  from: parseCalendarDate(dateValue[0]),
2179
2344
  to: parseCalendarDate(dateValue[1])
@@ -2185,6 +2350,8 @@ function onFilterInputRender({ filter, column, inputId, onFilterUpdate, showValu
2185
2350
  onFilterUpdate(filter.filterId, { value: date ? [date.from ? serializeCalendarDate(date.from) : "", date.to ? serializeCalendarDate(date.to) : ""] : [] });
2186
2351
  }
2187
2352
  }) : /* @__PURE__ */ jsx(Calendar, {
2353
+ today,
2354
+ disabled: upperBound ? { after: upperBound } : void 0,
2188
2355
  lang: calendarPresentation().locale,
2189
2356
  weekStartsOn: calendarPresentation().weekStartsOn,
2190
2357
  formatters: calendarPresentation().formatters,
@@ -2720,6 +2887,7 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
2720
2887
  children: /* @__PURE__ */ jsx(SimpleDateFilter, {
2721
2888
  title: meta.label ?? column.id,
2722
2889
  multiple: meta.variant === "dateRange",
2890
+ maxDate: meta.maxDate,
2723
2891
  value,
2724
2892
  onChange: (v) => updateFilter(column.id, v)
2725
2893
  })
@@ -2942,7 +3110,9 @@ function SimpleSliderFilter({ title, range, unit, value, onChange }) {
2942
3110
  ]
2943
3111
  })] });
2944
3112
  }
2945
- function SimpleDateFilter({ title, multiple, value, onChange }) {
3113
+ function SimpleDateFilter({ title, maxDate, multiple, value, onChange }) {
3114
+ const today = useCalendarToday();
3115
+ const upperBound = maxDate === "today" ? today : calendarMaxDate(maxDate);
2946
3116
  const [open, setOpen] = React.useState(false);
2947
3117
  const commit = (next) => {
2948
3118
  setOpen(false);
@@ -3009,6 +3179,8 @@ function SimpleDateFilter({ title, multiple, value, onChange }) {
3009
3179
  className: "w-auto p-0",
3010
3180
  align: "start",
3011
3181
  children: multiple ? /* @__PURE__ */ jsx(Calendar, {
3182
+ today,
3183
+ disabled: upperBound ? { after: upperBound } : void 0,
3012
3184
  lang: presentation.locale,
3013
3185
  weekStartsOn: presentation.weekStartsOn,
3014
3186
  formatters: presentation.formatters,
@@ -3017,6 +3189,7 @@ function SimpleDateFilter({ title, multiple, value, onChange }) {
3017
3189
  autoFocus: true,
3018
3190
  captionLayout: "dropdown",
3019
3191
  mode: "range",
3192
+ excludeDisabled: !!upperBound,
3020
3193
  selected: localRange,
3021
3194
  onSelect: (range) => {
3022
3195
  if (!range?.from && !range?.to) {
@@ -3068,6 +3241,8 @@ function SimpleDateFilter({ title, multiple, value, onChange }) {
3068
3241
  }
3069
3242
  }
3070
3243
  }) : /* @__PURE__ */ jsx(Calendar, {
3244
+ today,
3245
+ disabled: upperBound ? { after: upperBound } : void 0,
3071
3246
  lang: presentation.locale,
3072
3247
  weekStartsOn: presentation.weekStartsOn,
3073
3248
  formatters: presentation.formatters,
@@ -3646,7 +3821,7 @@ function generateCSVTemplate(headers) {
3646
3821
  function dataToCSV(data, opts = {}) {
3647
3822
  if (data.length === 0) return "";
3648
3823
  const allHeaders = Object.keys(data[0]);
3649
- const headers = (opts.headers ?? allHeaders).filter((h) => !opts.excludeColumns?.includes(h));
3824
+ const headers = (opts.headers ?? allHeaders).filter((h) => h !== "__crudExtensionProjection" && !opts.excludeColumns?.includes(h));
3650
3825
  return [headers.map((h) => escapeCSVField(h)).join(","), ...data.map((row) => headers.map((h) => escapeCSVField(String(row[h] ?? ""))).join(","))].join("\n");
3651
3826
  }
3652
3827
  function escapeCSVField(field) {
@@ -3735,7 +3910,7 @@ function downloadCSVTemplate(headers, filename = "template") {
3735
3910
  }).join(",") + "\n", filename);
3736
3911
  }
3737
3912
  function downloadCSV(csvContent, filename) {
3738
- const blob = new Blob([csvContent], { type: "text/csv;charset=utf-8;" });
3913
+ const blob = new Blob(["", csvContent], { type: "text/csv;charset=utf-8;" });
3739
3914
  const url = URL.createObjectURL(blob);
3740
3915
  const link = document.createElement("a");
3741
3916
  link.setAttribute("href", url);
@@ -4210,7 +4385,7 @@ const filterModeConfig = {
4210
4385
  tooltip: "Linear-style command filters"
4211
4386
  }
4212
4387
  };
4213
- function AutoTable({ schema, data, pageCount = 1, total, overrides, classNames, enableRowSelection = true, exclude, actions, pinnedColumns, filterMode, search = false, onDeleteSelected, onUpdateSelected, batchUpdateFields, actionBarExtra, actionBarActions, deleteConfirmation, initialSorting, enableExport = true, showDefaultExport = true, onSelectedCountChange, onSelectedRowsChange, getSelectedRows }) {
4388
+ function AutoTable({ schema, data, pageCount = 1, pagination, total, overrides, classNames, enableRowSelection = true, exclude, actions, pinnedColumns, filterMode, search = false, onDeleteSelected, onUpdateSelected, batchUpdateFields, actionBarExtra, actionBarActions, deleteConfirmation, initialSorting, enableExport = true, showDefaultExport = true, onSelectedCountChange, onSelectedRowsChange, getSelectedRows }) {
4214
4389
  const modes = filterMode ? Array.isArray(filterMode) ? filterMode : [filterMode] : DEFAULT_MODES;
4215
4390
  const [currentMode, setCurrentMode] = useQueryState("filterMode", parseAsStringEnum(modes).withDefault(modes[0] ?? "simple"));
4216
4391
  const showToggle = modes.length > 1;
@@ -4373,6 +4548,7 @@ function AutoTable({ schema, data, pageCount = 1, total, overrides, classNames,
4373
4548
  })]
4374
4549
  }),
4375
4550
  /* @__PURE__ */ jsx(DataTable, {
4551
+ pagination,
4376
4552
  table,
4377
4553
  classNames
4378
4554
  }),
@@ -4395,16 +4571,16 @@ function AutoTable({ schema, data, pageCount = 1, total, overrides, classNames,
4395
4571
  //#endregion
4396
4572
  //#region src/components/auto-crud/form-modal.tsx
4397
4573
  function FormModal({ open, onOpenChange, title, description, children, variant = "dialog", side = "right", className, footer }) {
4398
- if (variant === "sheet") return /* @__PURE__ */ jsx(Sheet$1, {
4574
+ if (variant === "sheet") return /* @__PURE__ */ jsx(Sheet, {
4399
4575
  open,
4400
4576
  onOpenChange,
4401
- children: /* @__PURE__ */ jsxs(SheetContent$1, {
4577
+ children: /* @__PURE__ */ jsxs(SheetContent, {
4402
4578
  side,
4403
4579
  className: cn("sm:max-w-lg flex flex-col p-0", className),
4404
4580
  children: [
4405
- /* @__PURE__ */ jsxs(SheetHeader$1, {
4581
+ /* @__PURE__ */ jsxs(SheetHeader, {
4406
4582
  className: "flex-shrink-0 px-6 pt-6",
4407
- children: [/* @__PURE__ */ jsx(SheetTitle$1, { children: title }), description && /* @__PURE__ */ jsx(SheetDescription, { children: description })]
4583
+ children: [/* @__PURE__ */ jsx(SheetTitle, { children: title }), description && /* @__PURE__ */ jsx(SheetDescription, { children: description })]
4408
4584
  }),
4409
4585
  /* @__PURE__ */ jsx("div", {
4410
4586
  className: "flex-1 overflow-y-auto min-h-0",
@@ -4446,6 +4622,45 @@ function FormModal({ open, onOpenChange, title, description, children, variant =
4446
4622
  });
4447
4623
  }
4448
4624
 
4625
+ //#endregion
4626
+ //#region src/components/auto-crud/date-only-picker.tsx
4627
+ const primitives = {
4628
+ Button: Button$1,
4629
+ Calendar: Calendar$1,
4630
+ Popover: Popover$1,
4631
+ PopoverContent: PopoverContent$1,
4632
+ PopoverTrigger: PopoverTrigger$1
4633
+ };
4634
+ function DatePicker$1({ dateInput,...props }) {
4635
+ if (props.valueFormat !== void 0 && dateInput === "utc-projection") {
4636
+ const value = props.value;
4637
+ props = {
4638
+ ...props,
4639
+ value: value instanceof Date ? Number.isNaN(value.getTime()) ? "" : parseCalendarDate(value.toISOString().slice(0, 10)) : typeof value === "string" && /^\d{4}-\d{2}-\d{2}T/.test(value) && !Number.isNaN(Date.parse(value)) ? parseCalendarDate(value.slice(0, 10)) : value
4640
+ };
4641
+ }
4642
+ useDateFormatterVersion();
4643
+ const presentation = calendarPresentation();
4644
+ return /* @__PURE__ */ jsx(DatePicker, {
4645
+ primitives,
4646
+ ...props.valueFormat !== void 0 ? {
4647
+ captionLayout: "dropdown-months",
4648
+ formatters: presentation.formatters,
4649
+ labels: presentation.labels,
4650
+ weekStartsOn: presentation.weekStartsOn,
4651
+ placeholder: props.valueFormat
4652
+ } : {},
4653
+ ...props
4654
+ });
4655
+ }
4656
+ /** @deprecated Use DatePicker with valueFormat="YYYY-MM-DD". */
4657
+ function DateOnlyPicker(props) {
4658
+ return /* @__PURE__ */ jsx(DatePicker$1, {
4659
+ ...props,
4660
+ valueFormat: "YYYY-MM-DD"
4661
+ });
4662
+ }
4663
+
4449
4664
  //#endregion
4450
4665
  //#region src/lib/schema-bridge/zod-to-formily.ts
4451
4666
  const DEFAULT_FORM_MANAGED_FIELDS = [
@@ -4548,6 +4763,27 @@ function createEditFormSchema(schema, options) {
4548
4763
  });
4549
4764
  }
4550
4765
 
4766
+ //#endregion
4767
+ //#region src/lib/crud-reference-projection.ts
4768
+ function isRecord$1(value) {
4769
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4770
+ }
4771
+ /** Read a label only while its ID still matches the field's current value. */
4772
+ function readCrudReferenceOption(row, field, value) {
4773
+ if (!isRecord$1(row)) return void 0;
4774
+ const { __crudExtensionProjection: projections } = row;
4775
+ if (!isRecord$1(projections)) return void 0;
4776
+ const projection = projections[field];
4777
+ if (!isRecord$1(projection)) return void 0;
4778
+ if (typeof value !== "string" && typeof value !== "number") return void 0;
4779
+ if (typeof projection.refId !== "string" && typeof projection.refId !== "number") return;
4780
+ if (String(value).length === 0 || String(projection.refId) !== String(value) || typeof projection.display !== "string" || projection.display.length === 0) return;
4781
+ return {
4782
+ value: String(value),
4783
+ label: projection.display
4784
+ };
4785
+ }
4786
+
4551
4787
  //#endregion
4552
4788
  //#region src/lib/registries.ts
4553
4789
  function createRegistry(label) {
@@ -4587,6 +4823,7 @@ function createRegistry(label) {
4587
4823
  }
4588
4824
  };
4589
4825
  }
4826
+ const tablePagination = createRegistry("table pagination");
4590
4827
  const formComponents = createRegistry("form component");
4591
4828
  const components = formComponents;
4592
4829
  function normalizeDataSourceRegistration(registration) {
@@ -4725,6 +4962,14 @@ function AutoCrudMultiCombobox({ options = [], className,...props }) {
4725
4962
  });
4726
4963
  }
4727
4964
  const defaultFieldComponents = {
4965
+ DatePicker: {
4966
+ component: DatePicker$1,
4967
+ decorator: "FormItem"
4968
+ },
4969
+ DateOnlyPicker: {
4970
+ component: DateOnlyPicker,
4971
+ decorator: "FormItem"
4972
+ },
4728
4973
  Combobox: {
4729
4974
  component: FormilyCombobox,
4730
4975
  decorator: "FormItem"
@@ -4800,6 +5045,13 @@ function mergeDataSourceOptions(current, incoming) {
4800
5045
  for (const option of incoming) optionsByValue.set(option.value, option);
4801
5046
  return Array.from(optionsByValue.values());
4802
5047
  }
5048
+ function setAutoCrudDataSourceOptions(field, options) {
5049
+ const projectedOption = readCrudReferenceOption(field.form.initialValues, field.path.toString(), field.value);
5050
+ field.setDataSource(projectedOption ? mergeDataSourceOptions([{
5051
+ ...projectedOption,
5052
+ disabled: true
5053
+ }], options) : options);
5054
+ }
4803
5055
  function isNearPopupScrollBottom$1(target) {
4804
5056
  return target.scrollHeight - target.scrollTop - target.clientHeight <= POPUP_SCROLL_LOAD_THRESHOLD$1;
4805
5057
  }
@@ -4815,6 +5067,7 @@ function loadAutoCrudDataSource({ entry, field, registryVersion, search, sourceK
4815
5067
  values,
4816
5068
  search: searchValue
4817
5069
  });
5070
+ setAutoCrudDataSourceOptions(field, state.options);
4818
5071
  if (!append && state.loadKey === loadKey && state.registryVersion === registryVersion) return;
4819
5072
  if (entry.reset && state.dependencyKey !== void 0 && state.dependencyKey !== dependencyKey) field.setValue(void 0);
4820
5073
  state.dependencyKey = dependencyKey;
@@ -4857,7 +5110,7 @@ function loadAutoCrudDataSource({ entry, field, registryVersion, search, sourceK
4857
5110
  state.page = page ?? 0;
4858
5111
  state.hasMore = entry.loadMore ? normalizeHasMore(result) : false;
4859
5112
  state.appendLoading = false;
4860
- field.setDataSource(nextOptions);
5113
+ setAutoCrudDataSourceOptions(field, nextOptions);
4861
5114
  field.setLoading(false);
4862
5115
  field.setComponentProps({
4863
5116
  loading: false,
@@ -4869,7 +5122,7 @@ function loadAutoCrudDataSource({ entry, field, registryVersion, search, sourceK
4869
5122
  if (!append) {
4870
5123
  state.options = [];
4871
5124
  state.hasMore = false;
4872
- field.setDataSource([]);
5125
+ setAutoCrudDataSourceOptions(field, []);
4873
5126
  }
4874
5127
  state.appendLoading = false;
4875
5128
  field.setLoading(false);
@@ -4893,7 +5146,7 @@ function applySearchComponentProps({ entry, field, registryState, sourceKey, sta
4893
5146
  const currentEntry = dataSources.get(sourceKey);
4894
5147
  if (!currentEntry) {
4895
5148
  state.controller?.abort();
4896
- field.setDataSource([]);
5149
+ setAutoCrudDataSourceOptions(field, []);
4897
5150
  field.setLoading(false);
4898
5151
  field.setComponentProps({ loading: false });
4899
5152
  return;
@@ -4923,7 +5176,7 @@ function applyLoadMoreComponentProps({ entry, field, registryState, sourceKey, s
4923
5176
  state.controller?.abort();
4924
5177
  state.hasMore = false;
4925
5178
  state.appendLoading = false;
4926
- field.setDataSource([]);
5179
+ setAutoCrudDataSourceOptions(field, []);
4927
5180
  field.setLoading(false);
4928
5181
  field.setComponentProps({
4929
5182
  hasMore: false,
@@ -4956,14 +5209,14 @@ function createAutoCrudDataSourceReaction(config, registryState) {
4956
5209
  state.initialized = true;
4957
5210
  }
4958
5211
  if (!source) {
4959
- field.setDataSource([]);
5212
+ setAutoCrudDataSourceOptions(field, []);
4960
5213
  field.setLoading(false);
4961
5214
  return;
4962
5215
  }
4963
5216
  const entry = dataSources.get(source.key);
4964
5217
  if (!entry) {
4965
5218
  state.controller?.abort();
4966
- field.setDataSource([]);
5219
+ setAutoCrudDataSourceOptions(field, []);
4967
5220
  field.setLoading(false);
4968
5221
  return;
4969
5222
  }
@@ -5061,6 +5314,7 @@ const AutoForm = forwardRef(AutoFormInner);
5061
5314
  //#endregion
5062
5315
  //#region src/i18n/locale.ts
5063
5316
  const zhCN = {
5317
+ pagination: { pageJump: "跳转到页" },
5064
5318
  toolbar: {
5065
5319
  refresh: "刷新",
5066
5320
  create: "新建",
@@ -5128,6 +5382,7 @@ const zhCN = {
5128
5382
  }
5129
5383
  };
5130
5384
  const enUS = {
5385
+ pagination: { pageJump: "Go to page" },
5131
5386
  toolbar: {
5132
5387
  refresh: "Refresh",
5133
5388
  create: "New",
@@ -5195,6 +5450,7 @@ const enUS = {
5195
5450
  }
5196
5451
  };
5197
5452
  const jaJP = {
5453
+ pagination: { pageJump: "ページへ移動" },
5198
5454
  toolbar: {
5199
5455
  refresh: "更新",
5200
5456
  create: "新規作成",
@@ -5262,6 +5518,7 @@ const jaJP = {
5262
5518
  }
5263
5519
  };
5264
5520
  const koKR = {
5521
+ pagination: { pageJump: "페이지로 이동" },
5265
5522
  toolbar: {
5266
5523
  refresh: "새로고침",
5267
5524
  create: "새로 만들기",
@@ -5329,6 +5586,7 @@ const koKR = {
5329
5586
  }
5330
5587
  };
5331
5588
  const frFR = {
5589
+ pagination: { pageJump: "Aller à la page" },
5332
5590
  toolbar: {
5333
5591
  refresh: "Actualiser",
5334
5592
  create: "Nouveau",
@@ -5396,6 +5654,7 @@ const frFR = {
5396
5654
  }
5397
5655
  };
5398
5656
  const deDE = {
5657
+ pagination: { pageJump: "Zur Seite springen" },
5399
5658
  toolbar: {
5400
5659
  refresh: "Aktualisieren",
5401
5660
  create: "Neu",
@@ -5463,6 +5722,7 @@ const deDE = {
5463
5722
  }
5464
5723
  };
5465
5724
  const esES = {
5725
+ pagination: { pageJump: "Ir a la página" },
5466
5726
  toolbar: {
5467
5727
  refresh: "Actualizar",
5468
5728
  create: "Nuevo",
@@ -5699,7 +5959,11 @@ function ImportDialog({ open, onOpenChange, onImport, columns = [], title, local
5699
5959
  open,
5700
5960
  onOpenChange: handleOpenChange,
5701
5961
  children: /* @__PURE__ */ jsxs(DialogContent, {
5702
- className: "w-[calc(100vw-2rem)] sm:max-w-5xl",
5962
+ className: "max-h-[85vh] overflow-y-auto",
5963
+ style: {
5964
+ width: "calc(100vw - 4rem)",
5965
+ maxWidth: "52rem"
5966
+ },
5703
5967
  children: [/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: title ?? locale.title }), /* @__PURE__ */ jsxs(DialogDescription, { children: [
5704
5968
  step === "upload" && locale.uploadDescription,
5705
5969
  step === "preview" && locale.previewDescription(parsedData?.rows.length ?? 0),
@@ -6648,12 +6912,26 @@ function useDynamicResolveOptions(fields, rows, hiddenColumns) {
6648
6912
  rows,
6649
6913
  sourceEntries
6650
6914
  ]);
6651
- return { optionsByField };
6915
+ const displayOptionsByField = { ...optionsByField };
6916
+ for (const field of Object.keys(fields ?? {}).filter((key) => !hiddenColumns.includes(key))) {
6917
+ const projectedOptions = rows.flatMap((row) => {
6918
+ const option = readCrudReferenceOption(row, field, row[field]);
6919
+ return option ? [option] : [];
6920
+ });
6921
+ if (projectedOptions.length > 0) displayOptionsByField[field] = mergeFilterOptions(projectedOptions, optionsByField[field] ?? []);
6922
+ }
6923
+ return { optionsByField: displayOptionsByField };
6652
6924
  }
6653
6925
  function getOptionLabel(value, options) {
6654
6926
  const stringValue = String(value);
6655
6927
  return options?.find((option) => option.value === stringValue)?.label ?? stringValue;
6656
6928
  }
6929
+ function formatExportRow(row, fields, values = row) {
6930
+ return Object.fromEntries(Object.entries(values).map(([key, value]) => [key, fields[key]?.format?.(value, {
6931
+ row,
6932
+ target: "export"
6933
+ }) ?? value]));
6934
+ }
6657
6935
  /**
6658
6936
  * 从统一配置生成表格 overrides
6659
6937
  * 当 filter 配置存在时,合并到 meta 中(不影响列隐藏)
@@ -6750,10 +7028,16 @@ function buildTableOverrides(fields, legacyOverrides, dynamicFilterState, dynami
6750
7028
  const options = tableConfig?.dataSource ? mergeFieldOptions(dynamicResolveOptions, presentationOptions) : presentationOptions ?? mergedSharedDynamicOptions;
6751
7029
  result[key] = {
6752
7030
  ...result[key],
6753
- cell: ({ row }) => renderFieldValue(row.getValue(key), "string", {
6754
- true: "true",
6755
- false: "false"
6756
- }, options, display ?? "auto")
7031
+ cell: ({ row, getValue }) => {
7032
+ const value = getValue();
7033
+ return config.format?.(value, {
7034
+ row: row.original,
7035
+ target: "display"
7036
+ }) ?? renderFieldValue(value, "string", {
7037
+ true: "true",
7038
+ false: "false"
7039
+ }, options, display ?? "auto");
7040
+ }
6757
7041
  };
6758
7042
  }
6759
7043
  }
@@ -6970,7 +7254,13 @@ function ViewModalContent({ open, onOpenChange, variant, data, schema, fields: f
6970
7254
  overrides[key] = {
6971
7255
  label: tableConfig?.label ?? config.label ?? listOverride?.label ?? humanize(key),
6972
7256
  index: tableConfig?.index ?? listOverride?.index,
6973
- cell: ({ getValue }) => renderFieldValue(getValue(), parseZodField(fieldSchema).type, locale.boolean, options, tableConfig?.display ?? "auto", Infinity),
7257
+ cell: ({ getValue, row }) => {
7258
+ const value = getValue();
7259
+ return config.format?.(value, {
7260
+ row: row.original,
7261
+ target: "display"
7262
+ }) ?? renderFieldValue(value, parseZodField(fieldSchema).type, locale.boolean, options, tableConfig?.display ?? "auto", Infinity);
7263
+ },
6974
7264
  ...view?.presentation === "table" ? listOverride : void 0,
6975
7265
  hidden: false,
6976
7266
  ...view?.overrides?.[key]
@@ -7007,13 +7297,13 @@ function ViewModalContent({ open, onOpenChange, variant, data, schema, fields: f
7007
7297
  onOpenChange,
7008
7298
  children: /* @__PURE__ */ jsxs(SheetContent, { children: [/* @__PURE__ */ jsx(SheetHeader, { children: /* @__PURE__ */ jsx(SheetTitle, { children: locale.viewModal.title }) }), content] })
7009
7299
  });
7010
- return /* @__PURE__ */ jsx(Dialog, {
7300
+ return /* @__PURE__ */ jsx(Dialog$1, {
7011
7301
  open,
7012
7302
  onOpenChange,
7013
- children: /* @__PURE__ */ jsxs(DialogContent, {
7303
+ children: /* @__PURE__ */ jsxs(DialogContent$1, {
7014
7304
  "aria-describedby": void 0,
7015
7305
  className: "max-w-2xl max-h-[80vh] overflow-y-auto",
7016
- children: [/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: locale.viewModal.title }) }), content]
7306
+ children: [/* @__PURE__ */ jsx(DialogHeader$1, { children: /* @__PURE__ */ jsx(DialogTitle$1, { children: locale.viewModal.title }) }), content]
7017
7307
  })
7018
7308
  });
7019
7309
  }
@@ -7077,6 +7367,9 @@ function resolveActions(actions, defaults, rowActionsLocale, context) {
7077
7367
  */
7078
7368
  function AutoCrudTable({ id, title, description, schema, resource, fields, table: tableConfig, form: formConfig, view: viewConfig, permissions, actions: actionItems, toolbar, toolbarActions, locale: localeProp, onCreate }) {
7079
7369
  const locale = resolveLocale(localeProp);
7370
+ const getPagination = React.useCallback(() => id ? tablePagination.get(id) : void 0, [id]);
7371
+ const registeredPagination = React.useSyncExternalStore(tablePagination.subscribe, getPagination, getPagination);
7372
+ const pagination = tableConfig?.pagination ?? registeredPagination;
7080
7373
  const resolvedSchema = resource.schema ?? schema;
7081
7374
  const resolvedFields = React.useMemo(() => applyResourceTablePresentation(mergeFields(resource.fields, fields), resource.fields) ?? {}, [fields, resource.fields]);
7082
7375
  const can = {
@@ -7149,13 +7442,13 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
7149
7442
  if (mode === "selected") {
7150
7443
  const selectedRows$1 = getSelectedRowsRef.current?.();
7151
7444
  if (!selectedRows$1 || selectedRows$1.length === 0) return;
7152
- exportAllToCSV(selectedRows$1, {
7445
+ exportAllToCSV(selectedRows$1.map((row) => formatExportRow(row, resolvedFields)), {
7153
7446
  filename,
7154
7447
  excludeColumns
7155
7448
  });
7156
7449
  } else {
7157
7450
  if (!resource.handlers.export) return;
7158
- exportAllToCSV(await resource.handlers.export(), {
7451
+ exportAllToCSV((await resource.handlers.export()).map((row) => formatExportRow(row, resolvedFields)), {
7159
7452
  filename,
7160
7453
  excludeColumns
7161
7454
  });
@@ -7163,7 +7456,8 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
7163
7456
  }, [
7164
7457
  resource.handlers.export,
7165
7458
  title,
7166
- denyFields
7459
+ denyFields,
7460
+ resolvedFields
7167
7461
  ]);
7168
7462
  const handleExportClick = React.useCallback(async () => {
7169
7463
  const mode = selectedCount > 0 ? "selected" : "filtered";
@@ -7174,6 +7468,26 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
7174
7468
  setExporting(false);
7175
7469
  }
7176
7470
  }, [selectedCount, handleExport]);
7471
+ const exportBatchActions = React.useMemo(() => {
7472
+ if (!Object.values(resolvedFields).some((field) => field.format)) return registryBatchActions;
7473
+ return registryBatchActions.map((action$1) => {
7474
+ if (action$1.type !== "export" || action$1.onClick !== void 0 || Boolean(action$1.component)) return action$1;
7475
+ return {
7476
+ ...action$1,
7477
+ onClick: (_rows, { table }) => {
7478
+ const headers = table.getAllLeafColumns().map((column) => column.id).filter((key) => key !== "select" && key !== "actions" && !denyFields?.includes(key));
7479
+ exportAllToCSV(table.getFilteredSelectedRowModel().rows.map((row) => formatExportRow(row.original, resolvedFields, Object.fromEntries(headers.map((key) => [key, row.getValue(key)])))), {
7480
+ filename: "table",
7481
+ headers
7482
+ });
7483
+ }
7484
+ };
7485
+ });
7486
+ }, [
7487
+ registryBatchActions,
7488
+ resolvedFields,
7489
+ denyFields
7490
+ ]);
7177
7491
  const toolbarRefresh = React.useMemo(() => {
7178
7492
  const refresh = ownerRefreshAction?.onClick ?? resource.handlers.refresh;
7179
7493
  if (!refresh) return void 0;
@@ -7227,7 +7541,30 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
7227
7541
  toolbarOpenCreate
7228
7542
  ]);
7229
7543
  const resolvedToolbarActions = resolveToolbarActionsWithResolver(id, registryToolbarActions, toolbarContext);
7230
- const tableOverrides = React.useMemo(() => mergeTableOverrides(buildTableOverrides(resolvedFields, tableConfig?.overrides, dynamicFilterOptions, dynamicResolveOptions), buildCapabilityTableOverrides(resolvedSchema, resource.capabilities)), [
7544
+ const { tableOverrides, detailTableOverrides } = React.useMemo(() => {
7545
+ const presentationOverrides = mergeTableOverrides(buildTableOverrides(resolvedFields, tableConfig?.overrides, dynamicFilterOptions, dynamicResolveOptions), buildCapabilityTableOverrides(resolvedSchema, resource.capabilities));
7546
+ const formattedOverrides = { ...presentationOverrides };
7547
+ for (const [key, config] of Object.entries(resolvedFields)) {
7548
+ const override = formattedOverrides[key];
7549
+ if (config.format && override?.cell === void 0 && resolvedSchema.shape[key]) {
7550
+ const { type } = parseZodField(resolvedSchema.shape[key]);
7551
+ formattedOverrides[key] = {
7552
+ ...override,
7553
+ cell: (context) => {
7554
+ const value = context.getValue();
7555
+ return config.format?.(value, {
7556
+ row: context.row.original,
7557
+ target: "display"
7558
+ }) ?? renderCell(value, type, context.column.columnDef.meta?.options);
7559
+ }
7560
+ };
7561
+ }
7562
+ }
7563
+ return {
7564
+ tableOverrides: formattedOverrides,
7565
+ detailTableOverrides: presentationOverrides
7566
+ };
7567
+ }, [
7231
7568
  resolvedFields,
7232
7569
  tableConfig?.overrides,
7233
7570
  dynamicFilterOptions,
@@ -7393,6 +7730,10 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
7393
7730
  data: resource.tableData.data,
7394
7731
  schema: resolvedSchema,
7395
7732
  pageCount: resource.tableData.pageCount,
7733
+ pagination: pagination ? {
7734
+ pageJumpLabel: locale.pagination?.pageJump,
7735
+ ...pagination
7736
+ } : void 0,
7396
7737
  ...resource.tableData.total !== void 0 ? { total: resource.tableData.total } : {},
7397
7738
  overrides: tableOverrides,
7398
7739
  classNames: tableConfig?.classNames,
@@ -7403,7 +7744,7 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
7403
7744
  onDeleteSelected: can.delete ? resource.handlers.deleteMany : void 0,
7404
7745
  onUpdateSelected: can.update ? resource.handlers.updateMany : void 0,
7405
7746
  batchUpdateFields: can.update ? batchFields : void 0,
7406
- actionBarActions: registryBatchActions,
7747
+ actionBarActions: exportBatchActions,
7407
7748
  deleteConfirmation: locale.bulkDeleteModal,
7408
7749
  enableExport: canExport,
7409
7750
  showDefaultExport: false,
@@ -7440,13 +7781,13 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
7440
7781
  dynamicOptions: dynamicFilterOptions.labelOptionsByField,
7441
7782
  denyFields,
7442
7783
  locale,
7443
- tableOverrides,
7784
+ tableOverrides: detailTableOverrides,
7444
7785
  view: viewConfig
7445
7786
  }),
7446
- /* @__PURE__ */ jsx(AlertDialog, {
7787
+ /* @__PURE__ */ jsx(AlertDialog$1, {
7447
7788
  open: resource.modal.deleteOpen,
7448
7789
  onOpenChange: (open) => !open && resource.handlers.closeModals(),
7449
- children: /* @__PURE__ */ jsxs(AlertDialogContent, { children: [/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: locale.deleteModal.title }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: locale.deleteModal.description })] }), /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [/* @__PURE__ */ jsx(AlertDialogCancel, { children: locale.deleteModal.cancel }), /* @__PURE__ */ jsx(AlertDialogAction, {
7790
+ children: /* @__PURE__ */ jsxs(AlertDialogContent$1, { children: [/* @__PURE__ */ jsxs(AlertDialogHeader$1, { children: [/* @__PURE__ */ jsx(AlertDialogTitle$1, { children: locale.deleteModal.title }), /* @__PURE__ */ jsx(AlertDialogDescription$1, { children: locale.deleteModal.description })] }), /* @__PURE__ */ jsxs(AlertDialogFooter$1, { children: [/* @__PURE__ */ jsx(AlertDialogCancel$1, { children: locale.deleteModal.cancel }), /* @__PURE__ */ jsx(AlertDialogAction$1, {
7450
7791
  onClick: resource.handlers.confirmDelete,
7451
7792
  disabled: resource.mutations.isDeleting,
7452
7793
  children: resource.mutations.isDeleting ? locale.deleteModal.confirming : locale.deleteModal.confirm
@@ -7649,6 +7990,9 @@ function parseColumnFilterValue(value) {
7649
7990
  return [];
7650
7991
  }
7651
7992
  function DataTableDateFilter({ column, title, multiple }) {
7993
+ const today = useCalendarToday();
7994
+ const maxDate = column.columnDef.meta?.maxDate;
7995
+ const upperBound = maxDate === "today" ? today : calendarMaxDate(maxDate);
7652
7996
  const formatterVersion = useDateFormatterVersion();
7653
7997
  const presentation = React.useMemo(() => calendarPresentation(), [formatterVersion]);
7654
7998
  const { formatDate: formatDate$1 } = presentation;
@@ -7802,6 +8146,8 @@ function DataTableDateFilter({ column, title, multiple }) {
7802
8146
  className: "w-auto p-0",
7803
8147
  align: "start",
7804
8148
  children: multiple ? /* @__PURE__ */ jsx(Calendar, {
8149
+ today,
8150
+ disabled: upperBound ? { after: upperBound } : void 0,
7805
8151
  lang: presentation.locale,
7806
8152
  weekStartsOn: presentation.weekStartsOn,
7807
8153
  formatters: presentation.formatters,
@@ -7809,10 +8155,13 @@ function DataTableDateFilter({ column, title, multiple }) {
7809
8155
  autoFocus: true,
7810
8156
  captionLayout: "dropdown",
7811
8157
  mode: "range",
8158
+ excludeDisabled: !!upperBound,
7812
8159
  defaultMonth: localRange.from,
7813
8160
  selected: localRange,
7814
8161
  onSelect
7815
8162
  }) : /* @__PURE__ */ jsx(Calendar, {
8163
+ today,
8164
+ disabled: upperBound ? { after: upperBound } : void 0,
7816
8165
  lang: presentation.locale,
7817
8166
  weekStartsOn: presentation.weekStartsOn,
7818
8167
  formatters: presentation.formatters,
@@ -8860,4 +9209,4 @@ function createMemoryDataSource(initialData = []) {
8860
9209
  }
8861
9210
 
8862
9211
  //#endregion
8863
- export { AutoCrudTable, AutoForm, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, CrudFormModal, DataTable, DataTableAdvancedToolbar, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableToolbar, DataTableViewOptions, ExportDialog, ImportDialog, MultiCombobox, SchemaAdapter, Select, cn, coerceRowValues, components, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, crudActions, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, resolveLocale, setDateFormatter, setSearchParams, setToolbarResolver, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
9212
+ export { AutoCrudTable, AutoForm, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, CrudFormModal, DataTable, DataTableAdvancedToolbar, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableToolbar, DataTableViewOptions, ExportDialog, ImportDialog, MultiCombobox, SchemaAdapter, Select, cn, coerceRowValues, components, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, crudActions, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, resolveLocale, setDateFormatter, setSearchParams, setToolbarResolver, tablePagination, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };