@wordrhyme/auto-crud 1.5.7 → 1.7.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,12 +2,13 @@ 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, DropdownMenuSeparator, DropdownMenuTrigger, Input, Label, Popover, PopoverContent, PopoverTrigger, Select as Select$1, SelectContent, SelectItem, SelectTrigger, SelectValue, Separator, Sheet, SheetContent, SheetDescription, 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, Sheet, SheetContent, SheetHeader, SheetTitle, 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
12
  import { z } from "zod";
12
13
  import { createForm } from "@formily/core";
13
14
  import { action, observable } from "@formily/reactive";
@@ -383,13 +384,15 @@ function hasValidCanonicalDateTimePrefix(value) {
383
384
  const match = canonicalDateTimePrefixPattern.exec(value);
384
385
  return !match || isValidCalendarDate(match[1], match[2], match[3]);
385
386
  }
387
+ function getDateLocaleOptions() {
388
+ return hostDateFormatters[hostDateFormatters.length - 1]?.options;
389
+ }
386
390
  /**
387
- * Register the host's process-wide date presentation policy without coupling
388
- * AutoCrud to locale or timezone selection. The returned cleanup removes only
389
- * this registration, so overlapping registrations may be disposed out of order.
391
+ * Register the host's date formatter and optional calendar locale policy.
392
+ * Cleanup removes only this registration, including out-of-order cleanup.
390
393
  * Passing undefined clears every registration.
391
394
  */
392
- function setDateFormatter(formatter) {
395
+ function setDateFormatter(formatter, options) {
393
396
  if (formatter === void 0) {
394
397
  const hadFormatter = hostDateFormatters.length > 0;
395
398
  hostDateFormatters = [];
@@ -398,15 +401,16 @@ function setDateFormatter(formatter) {
398
401
  }
399
402
  const registration = {
400
403
  formatter,
404
+ ...options ? { options } : {},
401
405
  token: Symbol("date-formatter")
402
406
  };
403
407
  hostDateFormatters.push(registration);
404
408
  notifyDateFormatterChange();
405
409
  return () => {
406
- const currentFormatter = getHostDateFormatter();
410
+ const currentRegistration = hostDateFormatters[hostDateFormatters.length - 1];
407
411
  const previousLength = hostDateFormatters.length;
408
412
  hostDateFormatters = hostDateFormatters.filter(({ token }) => token !== registration.token);
409
- if (hostDateFormatters.length !== previousLength && getHostDateFormatter() !== currentFormatter) notifyDateFormatterChange();
413
+ if (hostDateFormatters.length !== previousLength && hostDateFormatters[hostDateFormatters.length - 1] !== currentRegistration) notifyDateFormatterChange();
410
414
  };
411
415
  }
412
416
  function formatDate(date, opts = {}, preset) {
@@ -455,8 +459,14 @@ function formatDate(date, opts = {}, preset) {
455
459
 
456
460
  //#endregion
457
461
  //#region src/components/data-table/data-table.tsx
458
- function DataTable({ table, actionBar, children, className,...props }) {
462
+ function DataTable({ table, actionBar, children, className, classNames,...props }) {
459
463
  useDateFormatterVersion();
464
+ const columns = [
465
+ ...table.getLeftVisibleLeafColumns(),
466
+ ...table.getCenterVisibleLeafColumns(),
467
+ ...table.getRightVisibleLeafColumns()
468
+ ];
469
+ const hasWidthCap = columns.some((column) => (column.columnDef.maxSize ?? Number.MAX_SAFE_INTEGER) < Number.MAX_SAFE_INTEGER);
460
470
  return /* @__PURE__ */ jsxs("div", {
461
471
  className: cn("flex w-full flex-col gap-2.5 overflow-auto", className),
462
472
  ...props,
@@ -464,21 +474,53 @@ function DataTable({ table, actionBar, children, className,...props }) {
464
474
  children,
465
475
  /* @__PURE__ */ jsx("div", {
466
476
  className: "overflow-hidden rounded-md border",
467
- children: /* @__PURE__ */ jsxs(Table$1, { children: [/* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx(TableHead, {
468
- colSpan: header.colSpan,
469
- style: { ...getColumnPinningStyle({ column: header.column }) },
470
- children: header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())
471
- }, header.id)) }, headerGroup.id)) }), /* @__PURE__ */ jsx(TableBody, { children: table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx(TableRow, {
472
- "data-state": row.getIsSelected() && "selected",
473
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(TableCell, {
474
- style: { ...getColumnPinningStyle({ column: cell.column }) },
475
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
476
- }, cell.id))
477
- }, row.id)) : /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, {
478
- colSpan: table.getAllColumns().length,
479
- className: "h-24 text-center",
480
- children: "No results."
481
- }) }) })] })
477
+ children: /* @__PURE__ */ jsxs(Table$1, {
478
+ className: classNames?.table,
479
+ style: hasWidthCap ? {
480
+ tableLayout: "fixed",
481
+ width: columns.reduce((width, column) => width + column.getSize(), 0)
482
+ } : void 0,
483
+ children: [
484
+ hasWidthCap && /* @__PURE__ */ jsx("colgroup", { children: columns.map((column) => /* @__PURE__ */ jsx("col", { style: { width: column.getSize() } }, column.id)) }),
485
+ /* @__PURE__ */ jsx(TableHeader, {
486
+ className: classNames?.thead,
487
+ children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, {
488
+ className: classNames?.tr,
489
+ children: headerGroup.headers.map((header) => {
490
+ const columnClassName = header.column.columnDef.meta?.classNames?.th;
491
+ return /* @__PURE__ */ jsx(TableHead, {
492
+ colSpan: header.colSpan,
493
+ className: cn(hasWidthCap && "overflow-hidden text-ellipsis", classNames?.th, typeof columnClassName === "string" ? columnClassName : void 0),
494
+ style: { ...getColumnPinningStyle({ column: header.column }) },
495
+ children: header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())
496
+ }, header.id);
497
+ })
498
+ }, headerGroup.id))
499
+ }),
500
+ /* @__PURE__ */ jsx(TableBody, {
501
+ className: classNames?.tbody,
502
+ children: table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx(TableRow, {
503
+ className: classNames?.tr,
504
+ "data-state": row.getIsSelected() && "selected",
505
+ children: row.getVisibleCells().map((cell) => {
506
+ const columnClassName = cell.column.columnDef.meta?.classNames?.td;
507
+ return /* @__PURE__ */ jsx(TableCell, {
508
+ className: cn(hasWidthCap && "overflow-hidden text-ellipsis", classNames?.td, typeof columnClassName === "string" ? columnClassName : void 0),
509
+ style: { ...getColumnPinningStyle({ column: cell.column }) },
510
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
511
+ }, cell.id);
512
+ })
513
+ }, row.id)) : /* @__PURE__ */ jsx(TableRow, {
514
+ className: classNames?.tr,
515
+ children: /* @__PURE__ */ jsx(TableCell, {
516
+ colSpan: table.getAllColumns().length,
517
+ className: cn("h-24 text-center", classNames?.td),
518
+ children: "No results."
519
+ })
520
+ })
521
+ })
522
+ ]
523
+ })
482
524
  }),
483
525
  /* @__PURE__ */ jsxs("div", {
484
526
  className: "flex flex-col gap-2.5",
@@ -1006,6 +1048,71 @@ function useDebouncedCallback(callback, delay) {
1006
1048
  }, [handleCallback, delay]);
1007
1049
  }
1008
1050
 
1051
+ //#endregion
1052
+ //#region src/lib/calendar-date.ts
1053
+ /** Calendar days are wall dates, never instants in the host's time zone. */
1054
+ function serializeCalendarDate(date) {
1055
+ return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
1056
+ }
1057
+ function parseCalendarDate(value) {
1058
+ if (value === void 0 || value === "") return void 0;
1059
+ if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value)) {
1060
+ const date$1 = /* @__PURE__ */ new Date(`${value}T00:00:00`);
1061
+ return !Number.isNaN(date$1.getTime()) && serializeCalendarDate(date$1) === value ? date$1 : void 0;
1062
+ }
1063
+ const date = new Date(Number(value));
1064
+ return Number.isNaN(date.getTime()) ? void 0 : date;
1065
+ }
1066
+ function calendarPresentation() {
1067
+ const localeOptions = getDateLocaleOptions();
1068
+ const locale = localeOptions?.locale ?? "en-US";
1069
+ const chinese = locale.toLowerCase().startsWith("zh");
1070
+ const localeInfo = new Intl.Locale(locale);
1071
+ const firstDay = localeInfo.getWeekInfo?.().firstDay ?? localeInfo.weekInfo?.firstDay ?? (chinese ? 1 : 7);
1072
+ const format = (date, options) => new Intl.DateTimeFormat(locale, {
1073
+ ...options,
1074
+ timeZone: "UTC"
1075
+ }).format(/* @__PURE__ */ new Date(`${serializeCalendarDate(date)}T00:00:00Z`));
1076
+ return {
1077
+ locale,
1078
+ weekStartsOn: firstDay % 7,
1079
+ formatDate: (date) => {
1080
+ if (!localeOptions) return formatDate(date);
1081
+ return date ? format(date, {
1082
+ year: "numeric",
1083
+ month: "long",
1084
+ day: "numeric"
1085
+ }) : "";
1086
+ },
1087
+ clearLabel: (title) => chinese ? `清除${title ?? ""}筛选` : `Clear ${title ?? ""} filter`,
1088
+ formatters: {
1089
+ formatCaption: (date) => format(date, {
1090
+ year: "numeric",
1091
+ month: "long"
1092
+ }),
1093
+ formatMonthDropdown: (date) => format(date, { month: "long" }),
1094
+ formatWeekdayName: (date) => format(date, { weekday: "short" })
1095
+ },
1096
+ labels: {
1097
+ labelNext: () => chinese ? "下个月" : "Go to the Next Month",
1098
+ labelPrevious: () => chinese ? "上个月" : "Go to the Previous Month",
1099
+ labelMonthDropdown: () => chinese ? "选择月份" : "Choose the Month",
1100
+ labelYearDropdown: () => chinese ? "选择年份" : "Choose the Year",
1101
+ labelGrid: (date) => format(date, {
1102
+ year: "numeric",
1103
+ month: "long"
1104
+ }),
1105
+ labelWeekday: (date) => format(date, { weekday: "long" }),
1106
+ labelDayButton: (date) => format(date, {
1107
+ year: "numeric",
1108
+ month: "long",
1109
+ day: "numeric",
1110
+ weekday: "long"
1111
+ })
1112
+ }
1113
+ };
1114
+ }
1115
+
1009
1116
  //#endregion
1010
1117
  //#region src/components/data-table/data-table-filter-list.tsx
1011
1118
  const DEBOUNCE_MS$2 = 300;
@@ -1177,6 +1284,7 @@ function DataTableFilterList({ table, debounceMs = DEBOUNCE_MS$2, throttleMs = T
1177
1284
  });
1178
1285
  }
1179
1286
  function DataTableFilterItem$1({ filter, index: index$1, filterItemId, joinOperator, setJoinOperator, columns, onFilterUpdate, onFilterRemove }) {
1287
+ useDateFormatterVersion();
1180
1288
  const [showFieldSelector, setShowFieldSelector] = React.useState(false);
1181
1289
  const [showOperatorSelector, setShowOperatorSelector] = React.useState(false);
1182
1290
  const [showValueSelector, setShowValueSelector] = React.useState(false);
@@ -1465,10 +1573,10 @@ function onFilterInputRender$1({ filter, inputId, column, columnMeta, onFilterUp
1465
1573
  case "dateRange": {
1466
1574
  const inputListboxId = `${inputId}-listbox`;
1467
1575
  const dateValue = Array.isArray(filter.value) ? filter.value.filter(Boolean) : [filter.value, filter.value].filter(Boolean);
1468
- const startDate = dateValue[0] ? new Date(Number(dateValue[0])) : void 0;
1469
- const endDate = dateValue[1] ? new Date(Number(dateValue[1])) : void 0;
1576
+ const startDate = dateValue[0] ? parseCalendarDate(dateValue[0]) : void 0;
1577
+ const endDate = dateValue[1] ? parseCalendarDate(dateValue[1]) : void 0;
1470
1578
  const isSameDate = startDate && endDate && startDate.toDateString() === endDate.toDateString();
1471
- const displayValue = filter.operator === "isBetween" && dateValue.length === 2 && !isSameDate ? `${formatDate(startDate, { month: "short" })} - ${formatDate(endDate, { month: "short" })}` : startDate ? formatDate(startDate, { month: "short" }) : "Pick a date";
1579
+ const displayValue = filter.operator === "isBetween" && dateValue.length === 2 && !isSameDate ? `${calendarPresentation().formatDate(startDate)} - ${calendarPresentation().formatDate(endDate)}` : startDate ? calendarPresentation().formatDate(startDate) : "Pick a date";
1472
1580
  return /* @__PURE__ */ jsxs(Popover, {
1473
1581
  open: showValueSelector,
1474
1582
  onOpenChange: setShowValueSelector,
@@ -1491,28 +1599,36 @@ function onFilterInputRender$1({ filter, inputId, column, columnMeta, onFilterUp
1491
1599
  align: "start",
1492
1600
  className: "w-auto p-0",
1493
1601
  children: filter.operator === "isBetween" ? /* @__PURE__ */ jsx(Calendar, {
1602
+ lang: calendarPresentation().locale,
1603
+ weekStartsOn: calendarPresentation().weekStartsOn,
1604
+ formatters: calendarPresentation().formatters,
1605
+ labels: calendarPresentation().labels,
1494
1606
  "aria-label": `Select ${columnMeta?.label} date range`,
1495
1607
  autoFocus: true,
1496
1608
  captionLayout: "dropdown",
1497
1609
  mode: "range",
1498
1610
  selected: dateValue.length === 2 ? {
1499
- from: new Date(Number(dateValue[0])),
1500
- to: new Date(Number(dateValue[1]))
1611
+ from: parseCalendarDate(dateValue[0]),
1612
+ to: parseCalendarDate(dateValue[1])
1501
1613
  } : {
1502
1614
  from: /* @__PURE__ */ new Date(),
1503
1615
  to: /* @__PURE__ */ new Date()
1504
1616
  },
1505
1617
  onSelect: (date) => {
1506
- onFilterUpdate(filter.filterId, { value: date ? [(date.from?.getTime() ?? "").toString(), (date.to?.getTime() ?? "").toString()] : [] });
1618
+ onFilterUpdate(filter.filterId, { value: date ? [date.from ? serializeCalendarDate(date.from) : "", date.to ? serializeCalendarDate(date.to) : ""] : [] });
1507
1619
  }
1508
1620
  }) : /* @__PURE__ */ jsx(Calendar, {
1621
+ lang: calendarPresentation().locale,
1622
+ weekStartsOn: calendarPresentation().weekStartsOn,
1623
+ formatters: calendarPresentation().formatters,
1624
+ labels: calendarPresentation().labels,
1509
1625
  "aria-label": `Select ${columnMeta?.label} date`,
1510
1626
  autoFocus: true,
1511
1627
  captionLayout: "dropdown",
1512
1628
  mode: "single",
1513
- selected: dateValue[0] ? new Date(Number(dateValue[0])) : void 0,
1629
+ selected: dateValue[0] ? parseCalendarDate(dateValue[0]) : void 0,
1514
1630
  onSelect: (date) => {
1515
- onFilterUpdate(filter.filterId, { value: (date?.getTime() ?? "").toString() });
1631
+ onFilterUpdate(filter.filterId, { value: date ? serializeCalendarDate(date) : "" });
1516
1632
  setShowValueSelector(false);
1517
1633
  }
1518
1634
  })
@@ -1724,6 +1840,7 @@ function DataTableFilterMenu({ table, debounceMs = DEBOUNCE_MS$1, throttleMs = T
1724
1840
  }
1725
1841
  function DataTableFilterItem({ filter, filterItemId, columns, onFilterUpdate, onFilterRemove }) {
1726
1842
  {
1843
+ useDateFormatterVersion();
1727
1844
  const [showFieldSelector, setShowFieldSelector] = React.useState(false);
1728
1845
  const [showOperatorSelector, setShowOperatorSelector] = React.useState(false);
1729
1846
  const [showValueSelector, setShowValueSelector] = React.useState(false);
@@ -1834,6 +1951,7 @@ function DataTableFilterItem({ filter, filterItemId, columns, onFilterUpdate, on
1834
1951
  }
1835
1952
  }
1836
1953
  function FilterValueSelector({ column, value, onSelect }) {
1954
+ useDateFormatterVersion();
1837
1955
  switch (column.columnDef.meta?.variant ?? "text") {
1838
1956
  case "boolean": return /* @__PURE__ */ jsxs(CommandGroup, { children: [/* @__PURE__ */ jsx(CommandItem, {
1839
1957
  value: "true",
@@ -1862,11 +1980,15 @@ function FilterValueSelector({ column, value, onSelect }) {
1862
1980
  }, option.value)) });
1863
1981
  case "date":
1864
1982
  case "dateRange": return /* @__PURE__ */ jsx(Calendar, {
1983
+ lang: calendarPresentation().locale,
1984
+ weekStartsOn: calendarPresentation().weekStartsOn,
1985
+ formatters: calendarPresentation().formatters,
1986
+ labels: calendarPresentation().labels,
1865
1987
  autoFocus: true,
1866
1988
  captionLayout: "dropdown",
1867
1989
  mode: "single",
1868
- selected: value ? new Date(value) : void 0,
1869
- onSelect: (date) => onSelect(date?.getTime().toString() ?? "")
1990
+ selected: parseCalendarDate(value),
1991
+ onSelect: (date) => onSelect(date ? serializeCalendarDate(date) : "")
1870
1992
  });
1871
1993
  default: {
1872
1994
  const isEmpty = !value.trim();
@@ -2020,10 +2142,10 @@ function onFilterInputRender({ filter, column, inputId, onFilterUpdate, showValu
2020
2142
  case "dateRange": {
2021
2143
  const inputListboxId = `${inputId}-listbox`;
2022
2144
  const dateValue = Array.isArray(filter.value) ? filter.value.filter(Boolean) : [filter.value, filter.value].filter(Boolean);
2023
- const startDate = dateValue[0] ? new Date(Number(dateValue[0])) : void 0;
2024
- const endDate = dateValue[1] ? new Date(Number(dateValue[1])) : void 0;
2145
+ const startDate = dateValue[0] ? parseCalendarDate(dateValue[0]) : void 0;
2146
+ const endDate = dateValue[1] ? parseCalendarDate(dateValue[1]) : void 0;
2025
2147
  const isSameDate = startDate && endDate && startDate.toDateString() === endDate.toDateString();
2026
- const displayValue = filter.operator === "isBetween" && dateValue.length === 2 && !isSameDate ? `${formatDate(startDate, { month: "short" })} - ${formatDate(endDate, { month: "short" })}` : startDate ? formatDate(startDate, { month: "short" }) : "Pick date...";
2148
+ const displayValue = filter.operator === "isBetween" && dateValue.length === 2 && !isSameDate ? `${calendarPresentation().formatDate(startDate)} - ${calendarPresentation().formatDate(endDate)}` : startDate ? calendarPresentation().formatDate(startDate) : "Pick date...";
2027
2149
  return /* @__PURE__ */ jsxs(Popover, {
2028
2150
  open: showValueSelector,
2029
2151
  onOpenChange: setShowValueSelector,
@@ -2045,26 +2167,34 @@ function onFilterInputRender({ filter, column, inputId, onFilterUpdate, showValu
2045
2167
  align: "start",
2046
2168
  className: "w-auto p-0",
2047
2169
  children: filter.operator === "isBetween" ? /* @__PURE__ */ jsx(Calendar, {
2170
+ lang: calendarPresentation().locale,
2171
+ weekStartsOn: calendarPresentation().weekStartsOn,
2172
+ formatters: calendarPresentation().formatters,
2173
+ labels: calendarPresentation().labels,
2048
2174
  autoFocus: true,
2049
2175
  captionLayout: "dropdown",
2050
2176
  mode: "range",
2051
2177
  selected: dateValue.length === 2 ? {
2052
- from: new Date(Number(dateValue[0])),
2053
- to: new Date(Number(dateValue[1]))
2178
+ from: parseCalendarDate(dateValue[0]),
2179
+ to: parseCalendarDate(dateValue[1])
2054
2180
  } : {
2055
2181
  from: /* @__PURE__ */ new Date(),
2056
2182
  to: /* @__PURE__ */ new Date()
2057
2183
  },
2058
2184
  onSelect: (date) => {
2059
- onFilterUpdate(filter.filterId, { value: date ? [(date.from?.getTime() ?? "").toString(), (date.to?.getTime() ?? "").toString()] : [] });
2185
+ onFilterUpdate(filter.filterId, { value: date ? [date.from ? serializeCalendarDate(date.from) : "", date.to ? serializeCalendarDate(date.to) : ""] : [] });
2060
2186
  }
2061
2187
  }) : /* @__PURE__ */ jsx(Calendar, {
2188
+ lang: calendarPresentation().locale,
2189
+ weekStartsOn: calendarPresentation().weekStartsOn,
2190
+ formatters: calendarPresentation().formatters,
2191
+ labels: calendarPresentation().labels,
2062
2192
  autoFocus: true,
2063
2193
  captionLayout: "dropdown",
2064
2194
  mode: "single",
2065
- selected: dateValue[0] ? new Date(Number(dateValue[0])) : void 0,
2195
+ selected: dateValue[0] ? parseCalendarDate(dateValue[0]) : void 0,
2066
2196
  onSelect: (date) => {
2067
- onFilterUpdate(filter.filterId, { value: (date?.getTime() ?? "").toString() });
2197
+ onFilterUpdate(filter.filterId, { value: date ? serializeCalendarDate(date) : "" });
2068
2198
  }
2069
2199
  })
2070
2200
  })]
@@ -2813,11 +2943,17 @@ function SimpleSliderFilter({ title, range, unit, value, onChange }) {
2813
2943
  })] });
2814
2944
  }
2815
2945
  function SimpleDateFilter({ title, multiple, value, onChange }) {
2946
+ const [open, setOpen] = React.useState(false);
2947
+ const commit = (next) => {
2948
+ setOpen(false);
2949
+ onChange(next);
2950
+ };
2951
+ const formatterVersion = useDateFormatterVersion();
2952
+ const presentation = React.useMemo(() => calendarPresentation(), [formatterVersion]);
2953
+ const { formatDate: formatDate$1 } = presentation;
2816
2954
  const timestamps = Array.isArray(value) ? value : value ? [value] : [];
2817
- const fromTimestamp = timestamps[0] ? Number(timestamps[0]) : void 0;
2818
- const toTimestamp = timestamps[1] ? Number(timestamps[1]) : void 0;
2819
- const fromDate = fromTimestamp ? new Date(fromTimestamp) : void 0;
2820
- const toDate = toTimestamp ? new Date(toTimestamp) : void 0;
2955
+ const fromDate = parseCalendarDate(timestamps[0]);
2956
+ const toDate = parseCalendarDate(timestamps[1]);
2821
2957
  const [localRange, setLocalRange] = React.useState({
2822
2958
  from: void 0,
2823
2959
  to: void 0
@@ -2836,100 +2972,114 @@ function SimpleDateFilter({ title, multiple, value, onChange }) {
2836
2972
  const hasValue = multiple ? fromDate || toDate : fromDate;
2837
2973
  const onReset = (e) => {
2838
2974
  e.stopPropagation();
2839
- onChange(void 0);
2975
+ commit(void 0);
2840
2976
  };
2841
- const label = multiple ? fromDate && toDate ? `${formatDate(fromDate)} - ${formatDate(toDate)}` : fromDate ? formatDate(fromDate) : void 0 : fromDate ? formatDate(fromDate) : void 0;
2842
- return /* @__PURE__ */ jsxs(Popover, { children: [/* @__PURE__ */ jsx(PopoverTrigger, {
2843
- asChild: true,
2844
- children: /* @__PURE__ */ jsxs(Button, {
2845
- variant: "outline",
2846
- size: "sm",
2847
- className: "border-dashed font-normal",
2848
- children: [
2849
- hasValue ? /* @__PURE__ */ jsx("div", {
2850
- role: "button",
2851
- tabIndex: 0,
2852
- className: "rounded-sm opacity-70 hover:opacity-100",
2853
- onClick: onReset,
2854
- onKeyDown: (e) => {
2855
- if (e.key === "Enter" || e.key === " ") {
2856
- e.preventDefault();
2857
- onReset(e);
2977
+ const label = multiple ? fromDate && toDate ? `${formatDate$1(fromDate)} - ${formatDate$1(toDate)}` : fromDate ? formatDate$1(fromDate) : void 0 : fromDate ? formatDate$1(fromDate) : void 0;
2978
+ return /* @__PURE__ */ jsxs(Popover, {
2979
+ open,
2980
+ onOpenChange: setOpen,
2981
+ children: [/* @__PURE__ */ jsx(PopoverTrigger, {
2982
+ asChild: true,
2983
+ children: /* @__PURE__ */ jsxs(Button, {
2984
+ variant: "outline",
2985
+ size: "sm",
2986
+ className: "border-dashed font-normal",
2987
+ children: [
2988
+ hasValue ? /* @__PURE__ */ jsx("div", {
2989
+ role: "button",
2990
+ tabIndex: 0,
2991
+ className: "rounded-sm opacity-70 hover:opacity-100",
2992
+ onClick: onReset,
2993
+ onKeyDown: (e) => {
2994
+ if (e.key === "Enter" || e.key === " ") {
2995
+ e.preventDefault();
2996
+ onReset(e);
2997
+ }
2998
+ },
2999
+ children: /* @__PURE__ */ jsx(XCircle, {})
3000
+ }) : /* @__PURE__ */ jsx(CalendarIcon, {}),
3001
+ /* @__PURE__ */ jsx("span", { children: title }),
3002
+ label && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Separator, {
3003
+ orientation: "vertical",
3004
+ className: "mx-0.5 h-4"
3005
+ }), /* @__PURE__ */ jsx("span", { children: label })] })
3006
+ ]
3007
+ })
3008
+ }), /* @__PURE__ */ jsx(PopoverContent, {
3009
+ className: "w-auto p-0",
3010
+ align: "start",
3011
+ children: multiple ? /* @__PURE__ */ jsx(Calendar, {
3012
+ lang: presentation.locale,
3013
+ weekStartsOn: presentation.weekStartsOn,
3014
+ formatters: presentation.formatters,
3015
+ labels: presentation.labels,
3016
+ defaultMonth: fromDate,
3017
+ autoFocus: true,
3018
+ captionLayout: "dropdown",
3019
+ mode: "range",
3020
+ selected: localRange,
3021
+ onSelect: (range) => {
3022
+ if (!range?.from && !range?.to) {
3023
+ commit(void 0);
3024
+ setLocalRange({
3025
+ from: void 0,
3026
+ to: void 0
3027
+ });
3028
+ return;
3029
+ }
3030
+ const hadFrom = Boolean(localRange.from);
3031
+ const hadTo = Boolean(localRange.to);
3032
+ const from = range.from?.getTime();
3033
+ const to = range.to?.getTime();
3034
+ if (from != null && to != null && from === to) {
3035
+ if (!hadFrom || hadTo) {
3036
+ setLocalRange({
3037
+ from: range.from,
3038
+ to: void 0
3039
+ });
3040
+ return;
2858
3041
  }
2859
- },
2860
- children: /* @__PURE__ */ jsx(XCircle, {})
2861
- }) : /* @__PURE__ */ jsx(CalendarIcon, {}),
2862
- /* @__PURE__ */ jsx("span", { children: title }),
2863
- label && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Separator, {
2864
- orientation: "vertical",
2865
- className: "mx-0.5 h-4"
2866
- }), /* @__PURE__ */ jsx("span", { children: label })] })
2867
- ]
2868
- })
2869
- }), /* @__PURE__ */ jsx(PopoverContent, {
2870
- className: "w-auto p-0",
2871
- align: "start",
2872
- children: multiple ? /* @__PURE__ */ jsx(Calendar, {
2873
- autoFocus: true,
2874
- captionLayout: "dropdown",
2875
- mode: "range",
2876
- selected: localRange,
2877
- onSelect: (range) => {
2878
- if (!range?.from && !range?.to) {
2879
- onChange(void 0);
2880
- setLocalRange({
2881
- from: void 0,
2882
- to: void 0
2883
- });
2884
- return;
2885
- }
2886
- const hadFrom = Boolean(localRange.from);
2887
- const hadTo = Boolean(localRange.to);
2888
- const from = range.from?.getTime();
2889
- const to = range.to?.getTime();
2890
- if (from != null && to != null && from === to) {
2891
- if (!hadFrom || hadTo) {
3042
+ if (hadFrom && !hadTo && localRange.from) {
3043
+ const prevFrom = localRange.from;
3044
+ const newDate = range.from;
3045
+ const [finalFrom, finalTo] = prevFrom <= newDate ? [prevFrom, newDate] : [newDate, prevFrom];
3046
+ setLocalRange({
3047
+ from: finalFrom,
3048
+ to: finalTo
3049
+ });
3050
+ commit([serializeCalendarDate(finalFrom), serializeCalendarDate(finalTo)]);
3051
+ return;
3052
+ }
3053
+ }
3054
+ if (from != null && to != null && from !== to) {
2892
3055
  setLocalRange({
2893
3056
  from: range.from,
2894
- to: void 0
3057
+ to: range.to
2895
3058
  });
3059
+ commit([serializeCalendarDate(range.from), serializeCalendarDate(range.to)]);
2896
3060
  return;
2897
3061
  }
2898
- if (hadFrom && !hadTo && localRange.from) {
2899
- const prevFrom = localRange.from;
2900
- const newDate = range.from;
2901
- const [finalFrom, finalTo] = prevFrom <= newDate ? [prevFrom, newDate] : [newDate, prevFrom];
3062
+ if (range.from && !range.to) {
2902
3063
  setLocalRange({
2903
- from: finalFrom,
2904
- to: finalTo
3064
+ from: range.from,
3065
+ to: void 0
2905
3066
  });
2906
- onChange([finalFrom.getTime().toString(), finalTo.getTime().toString()]);
2907
3067
  return;
2908
3068
  }
2909
3069
  }
2910
- if (from != null && to != null && from !== to) {
2911
- setLocalRange({
2912
- from: range.from,
2913
- to: range.to
2914
- });
2915
- onChange([range.from.getTime().toString(), range.to.getTime().toString()]);
2916
- return;
2917
- }
2918
- if (range.from && !range.to) {
2919
- setLocalRange({
2920
- from: range.from,
2921
- to: void 0
2922
- });
2923
- return;
2924
- }
2925
- }
2926
- }) : /* @__PURE__ */ jsx(Calendar, {
2927
- captionLayout: "dropdown",
2928
- mode: "single",
2929
- selected: fromDate,
2930
- onSelect: (date) => onChange(date ? date.getTime().toString() : void 0)
2931
- })
2932
- })] });
3070
+ }) : /* @__PURE__ */ jsx(Calendar, {
3071
+ lang: presentation.locale,
3072
+ weekStartsOn: presentation.weekStartsOn,
3073
+ formatters: presentation.formatters,
3074
+ labels: presentation.labels,
3075
+ defaultMonth: fromDate,
3076
+ captionLayout: "dropdown",
3077
+ mode: "single",
3078
+ selected: fromDate,
3079
+ onSelect: (date) => commit(date ? serializeCalendarDate(date) : void 0)
3080
+ })
3081
+ })]
3082
+ });
2933
3083
  }
2934
3084
 
2935
3085
  //#endregion
@@ -3264,10 +3414,7 @@ function renderCell(value, type, options) {
3264
3414
  className: "tabular-nums",
3265
3415
  children: String(value)
3266
3416
  });
3267
- default: return /* @__PURE__ */ jsx("span", {
3268
- className: "truncate max-w-48",
3269
- children: String(value)
3270
- });
3417
+ default: return /* @__PURE__ */ jsx("span", { children: String(value) });
3271
3418
  }
3272
3419
  }
3273
3420
  /**
@@ -3353,33 +3500,38 @@ function createSelectColumn() {
3353
3500
  size: 40
3354
3501
  };
3355
3502
  }
3503
+ function ActionsCell({ row, column }) {
3504
+ const items = column.columnDef.meta?.rowActions ?? [];
3505
+ const renderActionComponent = (item) => {
3506
+ if (!item.component) return null;
3507
+ return typeof item.component === "function" ? item.component(item.getContext?.(row.original)) : item.component;
3508
+ };
3509
+ return /* @__PURE__ */ jsxs(DropdownMenu$1, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger$1, {
3510
+ asChild: true,
3511
+ children: /* @__PURE__ */ jsx(Button, {
3512
+ "aria-label": "Open menu",
3513
+ variant: "ghost",
3514
+ className: "flex size-8 p-0 data-[state=open]:bg-muted",
3515
+ children: /* @__PURE__ */ jsx(Ellipsis, { className: "size-4" })
3516
+ })
3517
+ }), /* @__PURE__ */ jsx(DropdownMenuContent$1, {
3518
+ align: "end",
3519
+ className: "w-40",
3520
+ children: items.map((item, i) => /* @__PURE__ */ jsxs(React.Fragment, { children: [item.separator && /* @__PURE__ */ jsx(DropdownMenuSeparator, {}), item.component ? renderActionComponent(item) : item.label && item.onClick ? /* @__PURE__ */ jsx(DropdownMenuItem$1, {
3521
+ className: item.variant === "destructive" ? "text-destructive" : "",
3522
+ onClick: () => item.onClick?.(row.original),
3523
+ children: item.label
3524
+ }) : null] }, i))
3525
+ })] });
3526
+ }
3356
3527
  /**
3357
3528
  * 创建操作列
3358
3529
  */
3359
3530
  function createActionsColumn(items) {
3360
- const renderActionComponent = (item, row) => {
3361
- if (!item.component) return null;
3362
- return typeof item.component === "function" ? item.component(item.getContext?.(row.original)) : item.component;
3363
- };
3364
3531
  return {
3365
3532
  id: "actions",
3366
- cell: ({ row }) => /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
3367
- asChild: true,
3368
- children: /* @__PURE__ */ jsx(Button, {
3369
- "aria-label": "Open menu",
3370
- variant: "ghost",
3371
- className: "flex size-8 p-0 data-[state=open]:bg-muted",
3372
- children: /* @__PURE__ */ jsx(Ellipsis, { className: "size-4" })
3373
- })
3374
- }), /* @__PURE__ */ jsx(DropdownMenuContent, {
3375
- align: "end",
3376
- className: "w-40",
3377
- children: items.map((item, i) => /* @__PURE__ */ jsxs(React.Fragment, { children: [item.separator && /* @__PURE__ */ jsx(DropdownMenuSeparator, {}), item.component ? renderActionComponent(item, row) : item.label && item.onClick ? /* @__PURE__ */ jsx(DropdownMenuItem, {
3378
- className: item.variant === "destructive" ? "text-destructive" : "",
3379
- onClick: () => item.onClick?.(row.original),
3380
- children: item.label
3381
- }) : null] }, i))
3382
- })] }),
3533
+ cell: ActionsCell,
3534
+ meta: { rowActions: items },
3383
3535
  size: 40
3384
3536
  };
3385
3537
  }
@@ -3937,7 +4089,8 @@ function useDataTable(props) {
3937
4089
  if (enableAdvancedFilter) return [];
3938
4090
  return Object.entries(filterValues).reduce((filters, [key, value]) => {
3939
4091
  if (value !== null) {
3940
- const processedValue = Array.isArray(value) ? value : typeof value === "string" && /[^a-zA-Z0-9]/.test(value) ? value.split(/[^a-zA-Z0-9]+/).filter(Boolean) : [value];
4092
+ const variant = filterableColumns.find((column) => column.id === key)?.meta?.variant;
4093
+ const processedValue = Array.isArray(value) ? value : typeof value === "string" && (variant === "date" || variant === "dateRange") ? value.split(",").filter(Boolean) : typeof value === "string" && /[^a-zA-Z0-9]/.test(value) ? value.split(/[^a-zA-Z0-9]+/).filter(Boolean) : [value];
3941
4094
  filters.push({
3942
4095
  id: key,
3943
4096
  value: processedValue
@@ -3945,7 +4098,11 @@ function useDataTable(props) {
3945
4098
  }
3946
4099
  return filters;
3947
4100
  }, []);
3948
- }, [filterValues, enableAdvancedFilter]);
4101
+ }, [
4102
+ filterValues,
4103
+ enableAdvancedFilter,
4104
+ filterableColumns
4105
+ ]);
3949
4106
  const [columnFilters, setColumnFilters] = React.useState(initialColumnFilters);
3950
4107
  const onColumnFiltersChange = React.useCallback((updaterOrValue) => {
3951
4108
  if (enableAdvancedFilter) return;
@@ -4053,7 +4210,7 @@ const filterModeConfig = {
4053
4210
  tooltip: "Linear-style command filters"
4054
4211
  }
4055
4212
  };
4056
- 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 }) {
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 }) {
4057
4214
  const modes = filterMode ? Array.isArray(filterMode) ? filterMode : [filterMode] : DEFAULT_MODES;
4058
4215
  const [currentMode, setCurrentMode] = useQueryState("filterMode", parseAsStringEnum(modes).withDefault(modes[0] ?? "simple"));
4059
4216
  const showToggle = modes.length > 1;
@@ -4215,7 +4372,10 @@ function AutoTable({ schema, data, pageCount = 1, total, overrides, enableRowSel
4215
4372
  ]
4216
4373
  })]
4217
4374
  }),
4218
- /* @__PURE__ */ jsx(DataTable, { table }),
4375
+ /* @__PURE__ */ jsx(DataTable, {
4376
+ table,
4377
+ classNames
4378
+ }),
4219
4379
  enableRowSelection && /* @__PURE__ */ jsx(AutoTableActionBar, {
4220
4380
  table,
4221
4381
  onDeleteSelected,
@@ -4235,16 +4395,16 @@ function AutoTable({ schema, data, pageCount = 1, total, overrides, enableRowSel
4235
4395
  //#endregion
4236
4396
  //#region src/components/auto-crud/form-modal.tsx
4237
4397
  function FormModal({ open, onOpenChange, title, description, children, variant = "dialog", side = "right", className, footer }) {
4238
- if (variant === "sheet") return /* @__PURE__ */ jsx(Sheet, {
4398
+ if (variant === "sheet") return /* @__PURE__ */ jsx(Sheet$1, {
4239
4399
  open,
4240
4400
  onOpenChange,
4241
- children: /* @__PURE__ */ jsxs(SheetContent, {
4401
+ children: /* @__PURE__ */ jsxs(SheetContent$1, {
4242
4402
  side,
4243
4403
  className: cn("sm:max-w-lg flex flex-col p-0", className),
4244
4404
  children: [
4245
- /* @__PURE__ */ jsxs(SheetHeader, {
4405
+ /* @__PURE__ */ jsxs(SheetHeader$1, {
4246
4406
  className: "flex-shrink-0 px-6 pt-6",
4247
- children: [/* @__PURE__ */ jsx(SheetTitle, { children: title }), description && /* @__PURE__ */ jsx(SheetDescription, { children: description })]
4407
+ children: [/* @__PURE__ */ jsx(SheetTitle$1, { children: title }), description && /* @__PURE__ */ jsx(SheetDescription, { children: description })]
4248
4408
  }),
4249
4409
  /* @__PURE__ */ jsx("div", {
4250
4410
  className: "flex-1 overflow-y-auto min-h-0",
@@ -4260,15 +4420,15 @@ function FormModal({ open, onOpenChange, title, description, children, variant =
4260
4420
  ]
4261
4421
  })
4262
4422
  });
4263
- return /* @__PURE__ */ jsx(Dialog, {
4423
+ return /* @__PURE__ */ jsx(Dialog$1, {
4264
4424
  open,
4265
4425
  onOpenChange,
4266
- children: /* @__PURE__ */ jsxs(DialogContent, {
4426
+ children: /* @__PURE__ */ jsxs(DialogContent$1, {
4267
4427
  className: cn("max-w-2xl sm:max-w-2xl flex flex-col max-h-[85vh] overflow-hidden p-0", className),
4268
4428
  children: [
4269
- /* @__PURE__ */ jsxs(DialogHeader, {
4429
+ /* @__PURE__ */ jsxs(DialogHeader$1, {
4270
4430
  className: "flex-shrink-0 px-6 pt-6",
4271
- children: [/* @__PURE__ */ jsx(DialogTitle, { children: title }), description && /* @__PURE__ */ jsx(DialogDescription, { children: description })]
4431
+ children: [/* @__PURE__ */ jsx(DialogTitle$1, { children: title }), description && /* @__PURE__ */ jsx(DialogDescription$1, { children: description })]
4272
4432
  }),
4273
4433
  /* @__PURE__ */ jsx("div", {
4274
4434
  className: "flex-1 overflow-y-auto min-h-0",
@@ -5444,6 +5604,31 @@ function CrudFormModal({ open, onOpenChange, mode, schema, initialValues, onSubm
5444
5604
  });
5445
5605
  }
5446
5606
 
5607
+ //#endregion
5608
+ //#region src/lib/row-action-dialog.tsx
5609
+ /** Keep custom dialogs at table level, independently of the source row's lifetime. */
5610
+ function useRowActionDialog() {
5611
+ const [dialog, setDialog] = React.useState(null);
5612
+ const session = React.useRef(0);
5613
+ return {
5614
+ openComponent: React.useCallback((next) => {
5615
+ const id = ++session.current;
5616
+ const dismiss = () => {
5617
+ if (session.current === id) setDialog(null);
5618
+ };
5619
+ setDialog(React.cloneElement(next, {
5620
+ key: id,
5621
+ open: true,
5622
+ onOpenChange: (open) => {
5623
+ if (!open) dismiss();
5624
+ },
5625
+ onDismiss: dismiss
5626
+ }));
5627
+ }, []),
5628
+ dialog
5629
+ };
5630
+ }
5631
+
5447
5632
  //#endregion
5448
5633
  //#region src/components/auto-crud/import-dialog.tsx
5449
5634
  function ImportDialog({ open, onOpenChange, onImport, columns = [], title, locale = zhCN.importDialog }) {
@@ -5800,22 +5985,29 @@ function isCustomAction$1(action$1) {
5800
5985
  return action$1.type === "custom";
5801
5986
  }
5802
5987
  function resolveActions$1(targetId, zone, ownerActions) {
5803
- const baseActions = ownerActions.filter((action$1) => !action$1.hidden).map((action$1) => withoutRegistryMeta(action$1));
5804
- if (!targetId) return baseActions;
5805
- const registered = crudActions.get(targetId, zone);
5988
+ const registered = targetId ? crudActions.get(targetId, zone) : [];
5989
+ const hiddenCustomIds = new Set(registered.flatMap(({ action: action$1 }) => isCustomAction$1(action$1) && action$1.hidden && action$1.id ? [action$1.id] : []));
5990
+ const isMaskedCustom = (action$1) => isCustomAction$1(action$1) && Boolean(action$1.id && hiddenCustomIds.has(action$1.id));
5991
+ const customOverrides = /* @__PURE__ */ new Map();
5992
+ for (const entry of registered) {
5993
+ const { action: action$1 } = entry;
5994
+ if (isCustomAction$1(action$1) && action$1.id && !isMaskedCustom(action$1)) customOverrides.set(action$1.id, entry);
5995
+ }
5996
+ const ownerCustomIds = new Set(ownerActions.flatMap((action$1) => isCustomAction$1(action$1) && action$1.id ? [action$1.id] : []));
5997
+ const baseActions = ownerActions.filter((action$1) => !action$1.hidden && !isMaskedCustom(action$1)).map((action$1) => withoutRegistryMeta(isCustomAction$1(action$1) && action$1.id ? customOverrides.get(action$1.id)?.action ?? action$1 : action$1));
5998
+ const isReplacedCustom = ({ action: action$1, seq: seq$1 }) => isCustomAction$1(action$1) && Boolean(action$1.id && (ownerCustomIds.has(action$1.id) || customOverrides.get(action$1.id)?.seq !== seq$1));
5806
5999
  if (registered.length === 0) return baseActions;
5807
6000
  const nextActions = [...baseActions];
5808
6001
  const startCustomActions = [];
5809
6002
  const endCustomActions = [];
6003
+ const groups = /* @__PURE__ */ new Map();
5810
6004
  for (const entry of registered) {
6005
+ if (isMaskedCustom(entry.action)) continue;
6006
+ const group = groups.get(entry.ownerId) ?? [];
6007
+ group.push(entry);
6008
+ groups.set(entry.ownerId, group);
5811
6009
  const action$1 = entry.action;
5812
- if (action$1.hidden && isCustomAction$1(action$1)) continue;
5813
- if (isCustomAction$1(action$1)) {
5814
- const custom = withoutRegistryMeta(action$1);
5815
- if (custom.position === "start") startCustomActions.push(custom);
5816
- else endCustomActions.push(custom);
5817
- continue;
5818
- }
6010
+ if (isCustomAction$1(action$1)) continue;
5819
6011
  const existingIndex = nextActions.findIndex((item) => item.type === action$1.type);
5820
6012
  if (action$1.hidden) {
5821
6013
  if (existingIndex >= 0) nextActions.splice(existingIndex, 1);
@@ -5828,6 +6020,31 @@ function resolveActions$1(targetId, zone, ownerActions) {
5828
6020
  };
5829
6021
  else nextActions.push(builtin);
5830
6022
  }
6023
+ for (const group of groups.values()) {
6024
+ const items = group.sort((left, right) => left.seq - right.seq).flatMap((entry) => {
6025
+ const { action: action$1 } = entry;
6026
+ if (action$1.hidden || isReplacedCustom(entry)) return [];
6027
+ if (isCustomAction$1(action$1)) return [withoutRegistryMeta(action$1)];
6028
+ const builtin = nextActions.find((item) => item.type === action$1.type);
6029
+ return builtin ? [builtin] : [];
6030
+ });
6031
+ const firstBuiltin = items.find((item) => !isCustomAction$1(item));
6032
+ if (firstBuiltin) {
6033
+ let cursor = nextActions.indexOf(firstBuiltin);
6034
+ for (const item of items) {
6035
+ const existing = nextActions.indexOf(item);
6036
+ if (existing >= cursor) cursor = existing + 1;
6037
+ else {
6038
+ if (existing >= 0) {
6039
+ nextActions.splice(existing, 1);
6040
+ cursor -= 1;
6041
+ }
6042
+ nextActions.splice(cursor, 0, item);
6043
+ cursor += 1;
6044
+ }
6045
+ }
6046
+ } else for (const custom of items) (custom.position === "start" ? startCustomActions : endCustomActions).push(custom);
6047
+ }
5831
6048
  return [
5832
6049
  ...startCustomActions,
5833
6050
  ...nextActions,
@@ -6099,13 +6316,6 @@ function mergeFieldOptions(current, incoming) {
6099
6316
  if ((!current || current.length === 0) && (!incoming || incoming.length === 0)) return;
6100
6317
  return mergeFilterOptions(current, incoming ?? []);
6101
6318
  }
6102
- function mergeOptionsByField(left, right) {
6103
- const keys = new Set([...Object.keys(left ?? {}), ...Object.keys(right ?? {})]);
6104
- return Object.fromEntries(Array.from(keys).flatMap((key) => {
6105
- const options = mergeFieldOptions(left?.[key], right?.[key]);
6106
- return options ? [[key, options]] : [];
6107
- }));
6108
- }
6109
6319
  function shouldResolveOptions(field, config, hiddenColumns) {
6110
6320
  if (!config) return false;
6111
6321
  if (hiddenColumns.has(field)) return false;
@@ -6463,6 +6673,7 @@ function buildTableOverrides(fields, legacyOverrides, dynamicFilterState, dynami
6463
6673
  const mergedSharedDynamicOptions = mergeFieldOptions(dynamicFilterLabelOptions, tableConfig?.dataSource ? void 0 : dynamicResolveOptions);
6464
6674
  const dynamicOptions = !fieldOptions && mergedSharedDynamicOptions ? toTableOptions(mergedSharedDynamicOptions) : void 0;
6465
6675
  const tableMeta = config.table !== false && typeof config.table === "object" ? config.table.meta : void 0;
6676
+ const tableClassNames = tableConfig?.classNames;
6466
6677
  const fieldEnumMeta = tableOptions ? {
6467
6678
  options: tableOptions,
6468
6679
  variant: "multiSelect"
@@ -6502,13 +6713,14 @@ function buildTableOverrides(fields, legacyOverrides, dynamicFilterState, dynami
6502
6713
  enableColumnFilter: false
6503
6714
  };
6504
6715
  }
6505
- if (fieldEnumMeta || fieldDataSourceMeta || tableMeta || filterMeta) result[key] = {
6716
+ if (fieldEnumMeta || fieldDataSourceMeta || tableMeta || tableClassNames !== void 0 || filterMeta) result[key] = {
6506
6717
  ...result[key],
6507
6718
  meta: {
6508
6719
  ...result[key]?.meta ?? {},
6509
6720
  ...fieldEnumMeta ?? {},
6510
6721
  ...fieldDataSourceMeta ?? {},
6511
6722
  ...tableMeta ?? {},
6723
+ ...tableClassNames !== void 0 ? { classNames: tableClassNames } : {},
6512
6724
  ...filterMeta ?? {}
6513
6725
  }
6514
6726
  };
@@ -6526,6 +6738,7 @@ function buildTableOverrides(fields, legacyOverrides, dynamicFilterState, dynami
6526
6738
  };
6527
6739
  else if (config.table && typeof config.table === "object") {
6528
6740
  const { meta, display,...tableProps } = config.table;
6741
+ delete tableProps.classNames;
6529
6742
  delete tableProps.options;
6530
6743
  delete tableProps.dataSource;
6531
6744
  result[key] = {
@@ -6558,7 +6771,7 @@ function buildCapabilityTableOverrides(schema, capabilities) {
6558
6771
  const override = {};
6559
6772
  if (capabilities.filters) {
6560
6773
  if (!capabilities.filters.enabled) override.enableColumnFilter = false;
6561
- else if (filterSet) override.enableColumnFilter = filterSet.has(key);
6774
+ else if (filterSet && !filterSet.has(key)) override.enableColumnFilter = false;
6562
6775
  }
6563
6776
  if (capabilities.sort) {
6564
6777
  if (!capabilities.sort.enabled) override.enableSorting = false;
@@ -6642,7 +6855,7 @@ function buildBatchUpdateFields(schema, batchFields, fields) {
6642
6855
  /**
6643
6856
  * 渲染字段值
6644
6857
  */
6645
- function renderFieldValue(value, type, booleanLocale, options, display = "auto") {
6858
+ function renderFieldValue(value, type, booleanLocale, options, display = "auto", maxItems = 5) {
6646
6859
  if (value === null || value === void 0) return /* @__PURE__ */ jsx("span", {
6647
6860
  className: "text-muted-foreground",
6648
6861
  children: "-"
@@ -6657,12 +6870,12 @@ function renderFieldValue(value, type, booleanLocale, options, display = "auto")
6657
6870
  if (display === "badge" && (!options || options.length === 0)) {
6658
6871
  if (Array.isArray(value)) return /* @__PURE__ */ jsxs("div", {
6659
6872
  className: "flex gap-1 flex-wrap",
6660
- children: [value.slice(0, 5).map((item, index$1) => /* @__PURE__ */ jsx(Badge, {
6873
+ children: [value.slice(0, maxItems).map((item, index$1) => /* @__PURE__ */ jsx(Badge, {
6661
6874
  variant: "secondary",
6662
6875
  children: String(item)
6663
- }, index$1)), value.length > 5 && /* @__PURE__ */ jsxs(Badge, {
6876
+ }, index$1)), value.length > maxItems && /* @__PURE__ */ jsxs(Badge, {
6664
6877
  variant: "outline",
6665
- children: ["+", value.length - 5]
6878
+ children: ["+", value.length - maxItems]
6666
6879
  })]
6667
6880
  });
6668
6881
  return /* @__PURE__ */ jsx(Badge, {
@@ -6674,14 +6887,29 @@ function renderFieldValue(value, type, booleanLocale, options, display = "auto")
6674
6887
  if ((display === "badge" || display === "auto") && options && options.length > 0) {
6675
6888
  if (Array.isArray(value)) return /* @__PURE__ */ jsxs("div", {
6676
6889
  className: "flex gap-1 flex-wrap",
6677
- children: [value.slice(0, 5).map((v, i) => /* @__PURE__ */ jsx(Badge, {
6890
+ children: [value.slice(0, maxItems).map((v, i) => /* @__PURE__ */ jsx(Badge, {
6678
6891
  variant: "secondary",
6679
6892
  children: getOptionLabel(v, options)
6680
- }, i)), value.length > 5 && /* @__PURE__ */ jsxs(Badge, {
6893
+ }, i)), value.length > maxItems && /* @__PURE__ */ jsxs(Badge, {
6681
6894
  variant: "outline",
6682
- children: ["+", value.length - 5]
6895
+ children: ["+", value.length - maxItems]
6683
6896
  })]
6684
6897
  });
6898
+ const tone = options.find((option) => option.value === String(value))?.badgeTone;
6899
+ const toneClassName = tone && {
6900
+ neutral: "border-border bg-muted text-muted-foreground",
6901
+ success: "border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-950 dark:text-emerald-300",
6902
+ warning: "border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800 dark:bg-amber-950 dark:text-amber-300",
6903
+ info: "border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-300"
6904
+ }[tone];
6905
+ if (toneClassName) return /* @__PURE__ */ jsxs(Badge, {
6906
+ variant: "outline",
6907
+ className: toneClassName,
6908
+ children: [/* @__PURE__ */ jsx("span", {
6909
+ "aria-hidden": "true",
6910
+ className: "size-1.5 shrink-0 rounded-full bg-current"
6911
+ }), getOptionLabel(value, options)]
6912
+ });
6685
6913
  return /* @__PURE__ */ jsx(Badge, {
6686
6914
  variant: "outline",
6687
6915
  className: "capitalize",
@@ -6698,48 +6926,81 @@ function renderFieldValue(value, type, booleanLocale, options, display = "auto")
6698
6926
  });
6699
6927
  case "array": return Array.isArray(value) ? /* @__PURE__ */ jsxs("div", {
6700
6928
  className: "flex gap-1 flex-wrap",
6701
- children: [value.slice(0, 5).map((v, i) => /* @__PURE__ */ jsx(Badge, {
6929
+ children: [value.slice(0, maxItems).map((v, i) => /* @__PURE__ */ jsx(Badge, {
6702
6930
  variant: "secondary",
6703
6931
  children: String(v)
6704
- }, i)), value.length > 5 && /* @__PURE__ */ jsxs(Badge, {
6932
+ }, i)), value.length > maxItems && /* @__PURE__ */ jsxs(Badge, {
6705
6933
  variant: "outline",
6706
- children: ["+", value.length - 5]
6934
+ children: ["+", value.length - maxItems]
6707
6935
  })]
6708
6936
  }) : null;
6709
6937
  default: return String(value);
6710
6938
  }
6711
6939
  }
6712
- /**
6713
- * ViewModal 组件 - 详情查看弹窗
6714
- */
6715
- function ViewModal({ open, onOpenChange, variant, data, schema, fields: fieldConfig, dynamicOptions, denyFields, locale }) {
6716
- if (!data) return null;
6717
- const shape = schema.shape;
6718
- const denySet = new Set(denyFields ?? []);
6940
+ function ViewModal(props) {
6941
+ if (!props.open || !props.data) return null;
6942
+ return /* @__PURE__ */ jsx(ViewModalContent, { ...props });
6943
+ }
6944
+ function ViewModalContent({ open, onOpenChange, variant, data, schema, fields: fieldConfig, dynamicOptions, denyFields, locale, tableOverrides, view }) {
6945
+ const excluded = React.useMemo(() => {
6946
+ const denied = new Set(denyFields ?? []);
6947
+ return Object.keys(schema.shape).filter((key) => {
6948
+ const config = fieldConfig?.[key];
6949
+ return denied.has(key) || config?.hidden || view?.overrides?.[key]?.hidden || isDefaultHiddenAuditField(key) && !isFieldTableExplicitlyVisible(config) && view?.overrides?.[key]?.hidden !== false;
6950
+ });
6951
+ }, [
6952
+ schema,
6953
+ fieldConfig,
6954
+ denyFields,
6955
+ view?.overrides
6956
+ ]);
6957
+ const rows = React.useMemo(() => data ? [data] : [], [data]);
6958
+ const resolvedOptions = useDynamicResolveOptions(fieldConfig, rows, excluded);
6719
6959
  const content = /* @__PURE__ */ jsx("dl", {
6720
6960
  className: "grid gap-4 py-4",
6721
- children: Object.entries(shape).filter(([key]) => {
6722
- if (denySet.has(key)) return false;
6723
- const config = fieldConfig?.[key];
6724
- if (config?.hidden) return false;
6725
- if (isDefaultHiddenAuditField(key) && !isFieldTableExplicitlyVisible(config)) return false;
6726
- return true;
6727
- }).map(([key, fieldSchema]) => {
6728
- const parsed = parseZodField(fieldSchema);
6729
- const label = fieldConfig?.[key]?.label ?? humanize(key);
6730
- const value = data[key];
6731
- const options = normalizeFieldOptions(fieldConfig?.[key]?.enum) ?? normalizeFieldOptions(dynamicOptions?.[key]);
6732
- return /* @__PURE__ */ jsxs("div", {
6733
- className: "grid grid-cols-3 items-start gap-4",
6734
- children: [/* @__PURE__ */ jsx("dt", {
6735
- className: "text-sm font-medium text-muted-foreground",
6736
- children: label
6737
- }), /* @__PURE__ */ jsx("dd", {
6738
- className: "col-span-2 text-sm",
6739
- children: renderFieldValue(value, parsed.type, locale.boolean, options)
6740
- })]
6741
- }, key);
6742
- })
6961
+ children: useReactTable({
6962
+ data: rows,
6963
+ columns: React.useMemo(() => {
6964
+ const overrides = {};
6965
+ for (const [key, fieldSchema] of Object.entries(schema.shape).filter(([fieldKey]) => !excluded.includes(fieldKey))) {
6966
+ const config = fieldConfig?.[key] ?? {};
6967
+ const tableConfig = getTableConfig(config);
6968
+ const listOverride = tableOverrides?.[key];
6969
+ const options = getTableOptions(config) ?? resolvedOptions.optionsByField[key] ?? (tableConfig?.dataSource !== void 0 ? void 0 : dynamicOptions?.[key]);
6970
+ overrides[key] = {
6971
+ label: tableConfig?.label ?? config.label ?? listOverride?.label ?? humanize(key),
6972
+ index: tableConfig?.index ?? listOverride?.index,
6973
+ cell: ({ getValue }) => renderFieldValue(getValue(), parseZodField(fieldSchema).type, locale.boolean, options, tableConfig?.display ?? "auto", Infinity),
6974
+ ...view?.presentation === "table" ? listOverride : void 0,
6975
+ hidden: false,
6976
+ ...view?.overrides?.[key]
6977
+ };
6978
+ }
6979
+ return createTableSchema(schema, {
6980
+ overrides,
6981
+ exclude: excluded
6982
+ });
6983
+ }, [
6984
+ schema,
6985
+ excluded,
6986
+ fieldConfig,
6987
+ tableOverrides,
6988
+ view,
6989
+ resolvedOptions.optionsByField,
6990
+ dynamicOptions,
6991
+ locale.boolean
6992
+ ]),
6993
+ getCoreRowModel: getCoreRowModel()
6994
+ }).getRowModel().rows[0]?.getAllCells().map((cell) => /* @__PURE__ */ jsxs("div", {
6995
+ className: "grid grid-cols-3 items-start gap-4",
6996
+ children: [/* @__PURE__ */ jsx("dt", {
6997
+ className: "text-sm font-medium text-muted-foreground",
6998
+ children: cell.column.columnDef.meta?.label ?? humanize(cell.column.id)
6999
+ }), /* @__PURE__ */ jsx("dd", {
7000
+ className: "col-span-2 min-w-0 whitespace-pre-wrap break-words text-sm",
7001
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
7002
+ })]
7003
+ }, cell.id))
6743
7004
  });
6744
7005
  if (variant === "sheet") return /* @__PURE__ */ jsx(Sheet, {
6745
7006
  open,
@@ -6759,14 +7020,9 @@ function ViewModal({ open, onOpenChange, variant, data, schema, fields: fieldCon
6759
7020
  /**
6760
7021
  * 解析列表行操作
6761
7022
  */
6762
- function resolveActions(actionsOrFn, defaults, rowActionsLocale, context) {
6763
- const resolvedItems = typeof actionsOrFn === "function" ? actionsOrFn([
6764
- { type: "view" },
6765
- { type: "edit" },
6766
- { type: "copy" },
6767
- { type: "delete" }
6768
- ]) : actionsOrFn;
7023
+ function resolveActions(actions, defaults, rowActionsLocale, context) {
6769
7024
  const getContext = (row) => ({
7025
+ MenuItem: DropdownMenuItem$1,
6770
7026
  crudId: context.crudId,
6771
7027
  idKey: context.idKey,
6772
7028
  row,
@@ -6774,54 +7030,13 @@ function resolveActions(actionsOrFn, defaults, rowActionsLocale, context) {
6774
7030
  openView: defaults.openView,
6775
7031
  ...defaults.openEdit ? { openEdit: defaults.openEdit } : {},
6776
7032
  ...defaults.copyRow ? { copyRow: defaults.copyRow } : {},
6777
- ...defaults.openDelete ? { openDelete: defaults.openDelete } : {}
7033
+ ...defaults.openDelete ? { openDelete: defaults.openDelete } : {},
7034
+ open: (options) => {
7035
+ if (options.type === "custom") context.openComponent(options.component);
7036
+ else handlerMap[options.type]?.(options.row);
7037
+ }
6778
7038
  });
6779
- const defaultItems = [
6780
- {
6781
- label: rowActionsLocale.view,
6782
- onClick: defaults.openView
6783
- },
6784
- ...defaults.openEdit ? [{
6785
- label: rowActionsLocale.edit,
6786
- onClick: defaults.openEdit
6787
- }] : [],
6788
- ...defaults.copyRow ? [{
6789
- label: rowActionsLocale.copy,
6790
- onClick: defaults.copyRow
6791
- }] : [],
6792
- ...defaults.openDelete ? [{
6793
- label: rowActionsLocale.delete,
6794
- onClick: defaults.openDelete,
6795
- separator: true,
6796
- variant: "destructive"
6797
- }] : []
6798
- ];
6799
- if (resolvedItems === void 0) return defaultItems;
6800
- const items = resolvedItems.filter((item) => !item.hidden);
6801
- if (items.length === 0) return [];
6802
- if (!items.some((i) => i.type !== "custom")) {
6803
- const startItems = items.filter((i) => i.type === "custom" && i.position === "start").map(({ label, onClick, component, separator, variant }) => ({
6804
- label,
6805
- onClick,
6806
- component,
6807
- getContext,
6808
- separator,
6809
- variant
6810
- }));
6811
- const endItems = items.filter((i) => i.type === "custom" && i.position !== "start").map(({ label, onClick, component, separator, variant }) => ({
6812
- label,
6813
- onClick,
6814
- component,
6815
- getContext,
6816
- separator,
6817
- variant
6818
- }));
6819
- return [
6820
- ...startItems,
6821
- ...defaultItems,
6822
- ...endItems
6823
- ];
6824
- }
7039
+ const items = actions.filter((item) => !item.hidden);
6825
7040
  const handlerMap = {
6826
7041
  view: defaults.openView,
6827
7042
  edit: defaults.openEdit,
@@ -6860,7 +7075,7 @@ function resolveActions(actionsOrFn, defaults, rowActionsLocale, context) {
6860
7075
  *
6861
7076
  * 高级 CRUD 表格组件,封装了完整的增删改查流程
6862
7077
  */
6863
- function AutoCrudTable({ id, title, description, schema, resource, fields, table: tableConfig, form: formConfig, permissions, actions: actionItems, toolbar, toolbarActions, locale: localeProp, onCreate }) {
7078
+ function AutoCrudTable({ id, title, description, schema, resource, fields, table: tableConfig, form: formConfig, view: viewConfig, permissions, actions: actionItems, toolbar, toolbarActions, locale: localeProp, onCreate }) {
6864
7079
  const locale = resolveLocale(localeProp);
6865
7080
  const resolvedSchema = resource.schema ?? schema;
6866
7081
  const resolvedFields = React.useMemo(() => applyResourceTablePresentation(mergeFields(resource.fields, fields), resource.fields) ?? {}, [fields, resource.fields]);
@@ -6886,18 +7101,6 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
6886
7101
  tableConfig?.overrides
6887
7102
  ]);
6888
7103
  const dynamicResolveOptions = useDynamicResolveOptions(resolvedFields, resource.tableData.data, hiddenColumns);
6889
- const sharedResolveOptions = useDynamicResolveOptions(React.useMemo(() => Object.fromEntries(Object.entries(resolvedFields).flatMap(([field, config]) => {
6890
- const table = getTableConfig(config);
6891
- if (table?.options === void 0 && table?.dataSource === void 0) return [];
6892
- const { table: _table,...sharedConfig } = config;
6893
- return [[field, sharedConfig]];
6894
- })), [resolvedFields]), resource.tableData.data, hiddenColumns);
6895
- const viewDynamicOptionsByField = React.useMemo(() => mergeOptionsByField(mergeOptionsByField(dynamicFilterOptions.labelOptionsByField, sharedResolveOptions.optionsByField), Object.fromEntries(Object.entries(dynamicResolveOptions.optionsByField).filter(([field]) => !getTableConfig(resolvedFields[field] ?? {})?.dataSource))), [
6896
- dynamicFilterOptions.labelOptionsByField,
6897
- dynamicResolveOptions.optionsByField,
6898
- sharedResolveOptions.optionsByField,
6899
- resolvedFields
6900
- ]);
6901
7104
  const resourceIdKey = resource.idKey ?? "id";
6902
7105
  const actionRegistryVersion = useCrudActionsVersion();
6903
7106
  const unifiedActions = React.useMemo(() => {
@@ -7085,15 +7288,18 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
7085
7288
  resource.handlers.openEdit,
7086
7289
  resource.handlers.openView
7087
7290
  ]);
7291
+ const { openComponent, dialog: rowActionDialog } = useRowActionDialog();
7088
7292
  const tableRowActions = React.useMemo(() => resolveActions(registryRowActions, rowActionDefaults, locale.rowActions, {
7089
7293
  crudId: id ?? "",
7090
- idKey: resourceIdKey
7294
+ idKey: resourceIdKey,
7295
+ openComponent
7091
7296
  }), [
7092
7297
  id,
7093
7298
  locale.rowActions,
7094
7299
  registryRowActions,
7095
7300
  resourceIdKey,
7096
- rowActionDefaults
7301
+ rowActionDefaults,
7302
+ openComponent
7097
7303
  ]);
7098
7304
  return /* @__PURE__ */ jsxs("div", {
7099
7305
  className: "space-y-4",
@@ -7189,6 +7395,7 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
7189
7395
  pageCount: resource.tableData.pageCount,
7190
7396
  ...resource.tableData.total !== void 0 ? { total: resource.tableData.total } : {},
7191
7397
  overrides: tableOverrides,
7398
+ classNames: tableConfig?.classNames,
7192
7399
  exclude: hiddenColumns,
7193
7400
  filterMode: tableConfig?.filterModes,
7194
7401
  search: searchConfig,
@@ -7204,6 +7411,7 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
7204
7411
  onSelectedRowsChange: handleSelectedRowsChange,
7205
7412
  getSelectedRows: getSelectedRowsRef
7206
7413
  }),
7414
+ rowActionDialog,
7207
7415
  /* @__PURE__ */ jsx(CrudFormModal, {
7208
7416
  open: resource.modal.createOpen || resource.modal.editOpen,
7209
7417
  onOpenChange: (open) => !open && resource.handlers.closeModals(),
@@ -7229,9 +7437,11 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
7229
7437
  data: resource.modal.selected,
7230
7438
  schema: resolvedSchema,
7231
7439
  fields: resolvedFields,
7232
- dynamicOptions: viewDynamicOptionsByField,
7440
+ dynamicOptions: dynamicFilterOptions.labelOptionsByField,
7233
7441
  denyFields,
7234
- locale
7442
+ locale,
7443
+ tableOverrides,
7444
+ view: viewConfig
7235
7445
  }),
7236
7446
  /* @__PURE__ */ jsx(AlertDialog, {
7237
7447
  open: resource.modal.deleteOpen,
@@ -7428,10 +7638,7 @@ function getIsDateRange(value) {
7428
7638
  return value && typeof value === "object" && !Array.isArray(value);
7429
7639
  }
7430
7640
  function parseAsDate(timestamp) {
7431
- if (!timestamp) return void 0;
7432
- const numericTimestamp = typeof timestamp === "string" ? Number(timestamp) : timestamp;
7433
- const date = new Date(numericTimestamp);
7434
- return !Number.isNaN(date.getTime()) ? date : void 0;
7641
+ return parseCalendarDate(timestamp);
7435
7642
  }
7436
7643
  function parseColumnFilterValue(value) {
7437
7644
  if (value === null || value === void 0) return [];
@@ -7442,6 +7649,9 @@ function parseColumnFilterValue(value) {
7442
7649
  return [];
7443
7650
  }
7444
7651
  function DataTableDateFilter({ column, title, multiple }) {
7652
+ const formatterVersion = useDateFormatterVersion();
7653
+ const presentation = React.useMemo(() => calendarPresentation(), [formatterVersion]);
7654
+ const { formatDate: formatDate$1 } = presentation;
7445
7655
  const columnFilterValue = column.getFilterValue();
7446
7656
  const selectedDates = React.useMemo(() => {
7447
7657
  if (!columnFilterValue) return multiple ? {
@@ -7515,12 +7725,12 @@ function DataTableDateFilter({ column, title, multiple }) {
7515
7725
  from: nextFrom,
7516
7726
  to: nextTo
7517
7727
  });
7518
- if (nextTo) column.setFilterValue([nextFrom.getTime(), nextTo.getTime()]);
7728
+ if (nextTo) column.setFilterValue([serializeCalendarDate(nextFrom), serializeCalendarDate(nextTo)]);
7519
7729
  return;
7520
7730
  }
7521
7731
  setLocalRange(date);
7522
- if (from && to) column.setFilterValue([from, to]);
7523
- } else if (!multiple && "getTime" in date) column.setFilterValue(date.getTime());
7732
+ if (from && to) column.setFilterValue([serializeCalendarDate(new Date(from)), serializeCalendarDate(new Date(to))]);
7733
+ } else if (!multiple && "getTime" in date) column.setFilterValue(serializeCalendarDate(date));
7524
7734
  }, [
7525
7735
  column,
7526
7736
  multiple,
@@ -7540,9 +7750,9 @@ function DataTableDateFilter({ column, title, multiple }) {
7540
7750
  }, [multiple, selectedDates]);
7541
7751
  const formatDateRange = React.useCallback((range) => {
7542
7752
  if (!range.from && !range.to) return "";
7543
- if (range.from && range.to) return `${formatDate(range.from)} - ${formatDate(range.to)}`;
7544
- return formatDate(range.from ?? range.to);
7545
- }, []);
7753
+ if (range.from && range.to) return `${formatDate$1(range.from)} - ${formatDate$1(range.to)}`;
7754
+ return formatDate$1(range.from ?? range.to);
7755
+ }, [formatDate$1]);
7546
7756
  const label = React.useMemo(() => {
7547
7757
  if (multiple) {
7548
7758
  if (!getIsDateRange(selectedDates)) return null;
@@ -7558,7 +7768,7 @@ function DataTableDateFilter({ column, title, multiple }) {
7558
7768
  }
7559
7769
  if (getIsDateRange(selectedDates)) return null;
7560
7770
  const hasSelectedDate = selectedDates.length > 0;
7561
- const dateText = hasSelectedDate ? formatDate(selectedDates[0]) : "Select date";
7771
+ const dateText = hasSelectedDate ? formatDate$1(selectedDates[0]) : "Select date";
7562
7772
  return /* @__PURE__ */ jsxs("span", {
7563
7773
  className: "flex items-center gap-2",
7564
7774
  children: [/* @__PURE__ */ jsx("span", { children: title }), hasSelectedDate && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Separator, {
@@ -7570,7 +7780,8 @@ function DataTableDateFilter({ column, title, multiple }) {
7570
7780
  selectedDates,
7571
7781
  multiple,
7572
7782
  formatDateRange,
7573
- title
7783
+ title,
7784
+ formatDate$1
7574
7785
  ]);
7575
7786
  return /* @__PURE__ */ jsxs(Popover, { children: [/* @__PURE__ */ jsx(PopoverTrigger, {
7576
7787
  asChild: true,
@@ -7580,7 +7791,7 @@ function DataTableDateFilter({ column, title, multiple }) {
7580
7791
  className: "border-dashed font-normal",
7581
7792
  children: [hasValue ? /* @__PURE__ */ jsx("div", {
7582
7793
  role: "button",
7583
- "aria-label": `Clear ${title} filter`,
7794
+ "aria-label": presentation.clearLabel(title),
7584
7795
  tabIndex: 0,
7585
7796
  onClick: onReset,
7586
7797
  className: "rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
@@ -7591,14 +7802,24 @@ function DataTableDateFilter({ column, title, multiple }) {
7591
7802
  className: "w-auto p-0",
7592
7803
  align: "start",
7593
7804
  children: multiple ? /* @__PURE__ */ jsx(Calendar, {
7805
+ lang: presentation.locale,
7806
+ weekStartsOn: presentation.weekStartsOn,
7807
+ formatters: presentation.formatters,
7808
+ labels: presentation.labels,
7594
7809
  autoFocus: true,
7595
7810
  captionLayout: "dropdown",
7596
7811
  mode: "range",
7812
+ defaultMonth: localRange.from,
7597
7813
  selected: localRange,
7598
7814
  onSelect
7599
7815
  }) : /* @__PURE__ */ jsx(Calendar, {
7816
+ lang: presentation.locale,
7817
+ weekStartsOn: presentation.weekStartsOn,
7818
+ formatters: presentation.formatters,
7819
+ labels: presentation.labels,
7600
7820
  captionLayout: "dropdown",
7601
7821
  mode: "single",
7822
+ defaultMonth: !getIsDateRange(selectedDates) ? selectedDates[0] : void 0,
7602
7823
  selected: !getIsDateRange(selectedDates) ? selectedDates[0] : void 0,
7603
7824
  onSelect
7604
7825
  })