@wordrhyme/auto-crud 1.4.3 → 1.5.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/README.md CHANGED
@@ -1021,6 +1021,29 @@ export default function TasksPage() {
1021
1021
 
1022
1022
  ## 🧰 工具函数
1023
1023
 
1024
+ ### 配置日期展示策略
1025
+
1026
+ 通过 `setDateFormatter` 可以让 AutoCrud 内部日期跟随宿主的语言和时区策略:
1027
+
1028
+ ```typescript
1029
+ import { setDateFormatter } from '@wordrhyme/auto-crud';
1030
+
1031
+ const disposeDateFormatter = setDateFormatter((date, options) =>
1032
+ new Intl.DateTimeFormat(getCurrentLocale(), {
1033
+ ...options,
1034
+ timeZone: getCurrentTimeZone(),
1035
+ }).format(date),
1036
+ );
1037
+
1038
+ // 应用卸载时移除当前注册
1039
+ disposeDateFormatter();
1040
+
1041
+ // 传入 undefined 可清空全部注册
1042
+ setDateFormatter(undefined);
1043
+ ```
1044
+
1045
+ `setDateFormatter` 是进程/运行时级配置,建议在应用启动时注册一个稳定的 formatter。多个注册可以重叠,清理函数只移除对应注册,允许乱序清理。SSR 场景不要在每个请求中重复调用 setter;如需按请求选择语言或时区,应由稳定 formatter 通过宿主提供的并发安全上下文读取当前请求策略。
1046
+
1024
1047
  ### Schema Bridge - 核心转换函数
1025
1048
 
1026
1049
  ```typescript
@@ -1396,7 +1419,8 @@ export type { DataSource, ListParams, ListResult } from './lib/data-source';
1396
1419
 
1397
1420
  // 工具函数
1398
1421
  export { cn } from './lib/utils';
1399
- export { formatDate } from './lib/format';
1422
+ export { formatDate, setDateFormatter } from './lib/format';
1423
+ export type { DateFormatter } from './lib/format';
1400
1424
  export { humanize } from './lib/humanize';
1401
1425
  ```
1402
1426
 
package/dist/index.cjs CHANGED
@@ -923,16 +923,43 @@ function useDebouncedCallback(callback, delay) {
923
923
 
924
924
  //#endregion
925
925
  //#region src/lib/format.ts
926
+ let hostDateFormatters = [];
927
+ function getHostDateFormatter() {
928
+ return hostDateFormatters[hostDateFormatters.length - 1]?.formatter;
929
+ }
930
+ /**
931
+ * Register the host's process-wide date presentation policy without coupling
932
+ * AutoCrud to locale or timezone selection. The returned cleanup removes only
933
+ * this registration, so overlapping registrations may be disposed out of order.
934
+ * Passing undefined clears every registration.
935
+ */
936
+ function setDateFormatter(formatter) {
937
+ if (formatter === void 0) {
938
+ hostDateFormatters = [];
939
+ return () => void 0;
940
+ }
941
+ const registration = {
942
+ formatter,
943
+ token: Symbol("date-formatter")
944
+ };
945
+ hostDateFormatters.push(registration);
946
+ return () => {
947
+ hostDateFormatters = hostDateFormatters.filter(({ token }) => token !== registration.token);
948
+ };
949
+ }
926
950
  function formatDate(date, opts = {}) {
927
- if (!date) return "";
951
+ if (date === void 0) return "";
928
952
  try {
929
- return new Intl.DateTimeFormat("en-US", {
953
+ const value = new Date(date);
954
+ const options = {
930
955
  month: opts.month ?? "long",
931
956
  day: opts.day ?? "numeric",
932
957
  year: opts.year ?? "numeric",
933
958
  ...opts
934
- }).format(new Date(date));
935
- } catch (_err) {
959
+ };
960
+ const hostDateFormatter = getHostDateFormatter();
961
+ return hostDateFormatter ? hostDateFormatter(value, options) : new Intl.DateTimeFormat("en-US", options).format(value);
962
+ } catch {
936
963
  return "";
937
964
  }
938
965
  }
@@ -8546,6 +8573,7 @@ exports.parseImportFile = parseImportFile;
8546
8573
  exports.parseJSON = parseJSON;
8547
8574
  exports.parseZodField = parseZodField;
8548
8575
  exports.resolveLocale = resolveLocale;
8576
+ exports.setDateFormatter = setDateFormatter;
8549
8577
  exports.setSearchParams = setSearchParams;
8550
8578
  exports.setToolbarResolver = setToolbarResolver;
8551
8579
  exports.useAutoCrudResource = useAutoCrudResource;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime2 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime3 from "react/jsx-runtime";
2
2
  import { z } from "zod";
3
3
  import { JsonSchemaFormScope } from "@wordrhyme/formily-shadcn";
4
4
  import * as _tanstack_react_table0 from "@tanstack/react-table";
@@ -411,7 +411,7 @@ declare function AutoTableActionBar<TData>({
411
411
  extraActions,
412
412
  actions,
413
413
  deleteConfirmation
414
- }: AutoTableActionBarProps<TData>): react_jsx_runtime2.JSX.Element;
414
+ }: AutoTableActionBarProps<TData>): react_jsx_runtime3.JSX.Element;
415
415
  //#endregion
416
416
  //#region src/lib/schema-bridge/types.d.ts
417
417
  /**
@@ -587,7 +587,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
587
587
  onSelectedCountChange,
588
588
  onSelectedRowsChange,
589
589
  getSelectedRows
590
- }: AutoTableProps<T>): react_jsx_runtime2.JSX.Element;
590
+ }: AutoTableProps<T>): react_jsx_runtime3.JSX.Element;
591
591
  //#endregion
592
592
  //#region src/i18n/locale.d.ts
593
593
  /**
@@ -1079,7 +1079,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
1079
1079
  toolbarActions,
1080
1080
  locale: localeProp,
1081
1081
  onCreate
1082
- }: AutoCrudTableProps<TSchema>): react_jsx_runtime2.JSX.Element;
1082
+ }: AutoCrudTableProps<TSchema>): react_jsx_runtime3.JSX.Element;
1083
1083
  //#endregion
1084
1084
  //#region src/components/auto-crud/auto-form.d.ts
1085
1085
  interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
@@ -1118,7 +1118,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
1118
1118
  labelAlign,
1119
1119
  labelWidth,
1120
1120
  showSubmitButton
1121
- }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime2.JSX.Element;
1121
+ }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime3.JSX.Element;
1122
1122
  declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
1123
1123
  ref?: React.Ref<AutoFormRef>;
1124
1124
  }) => ReturnType<typeof AutoFormInner>;
@@ -1434,7 +1434,7 @@ declare function AutoTableSimpleFilters<TData>({
1434
1434
  filters: externalFilters,
1435
1435
  onFiltersChange,
1436
1436
  leading
1437
- }: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime2.JSX.Element | null;
1437
+ }: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime3.JSX.Element | null;
1438
1438
  //#endregion
1439
1439
  //#region src/components/auto-crud/form-modal.d.ts
1440
1440
  type ModalVariant = 'dialog' | 'sheet';
@@ -1478,7 +1478,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
1478
1478
  labelAlign,
1479
1479
  labelWidth,
1480
1480
  className
1481
- }: CrudFormModalProps<T>): react_jsx_runtime2.JSX.Element;
1481
+ }: CrudFormModalProps<T>): react_jsx_runtime3.JSX.Element;
1482
1482
  //#endregion
1483
1483
  //#region src/components/auto-crud/import-dialog.d.ts
1484
1484
  interface ImportDialogProps {
@@ -1500,7 +1500,7 @@ declare function ImportDialog({
1500
1500
  columns,
1501
1501
  title,
1502
1502
  locale
1503
- }: ImportDialogProps): react_jsx_runtime2.JSX.Element;
1503
+ }: ImportDialogProps): react_jsx_runtime3.JSX.Element;
1504
1504
  //#endregion
1505
1505
  //#region src/components/auto-crud/export-dialog.d.ts
1506
1506
  type ExportMode = 'selected' | 'filtered';
@@ -1520,7 +1520,7 @@ declare function ExportDialog({
1520
1520
  selectedCount,
1521
1521
  onExport,
1522
1522
  canExportFiltered
1523
- }: ExportDialogProps): react_jsx_runtime2.JSX.Element;
1523
+ }: ExportDialogProps): react_jsx_runtime3.JSX.Element;
1524
1524
  //#endregion
1525
1525
  //#region src/components/data-table/data-table.d.ts
1526
1526
  interface DataTableProps<TData> extends React$1.ComponentProps<'div'> {
@@ -1533,7 +1533,7 @@ declare function DataTable<TData>({
1533
1533
  children,
1534
1534
  className,
1535
1535
  ...props
1536
- }: DataTableProps<TData>): react_jsx_runtime2.JSX.Element;
1536
+ }: DataTableProps<TData>): react_jsx_runtime3.JSX.Element;
1537
1537
  //#endregion
1538
1538
  //#region src/components/data-table/data-table-advanced-toolbar.d.ts
1539
1539
  interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<'div'> {
@@ -1544,7 +1544,7 @@ declare function DataTableAdvancedToolbar<TData>({
1544
1544
  children,
1545
1545
  className,
1546
1546
  ...props
1547
- }: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime2.JSX.Element;
1547
+ }: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime3.JSX.Element;
1548
1548
  //#endregion
1549
1549
  //#region src/components/data-table/data-table-column-header.d.ts
1550
1550
  interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
@@ -1556,7 +1556,7 @@ declare function DataTableColumnHeader<TData, TValue>({
1556
1556
  label,
1557
1557
  className,
1558
1558
  ...props
1559
- }: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime2.JSX.Element;
1559
+ }: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime3.JSX.Element;
1560
1560
  //#endregion
1561
1561
  //#region src/components/data-table/data-table-faceted-filter.d.ts
1562
1562
  interface DataTableFacetedFilterProps<TData, TValue> {
@@ -1570,7 +1570,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
1570
1570
  title,
1571
1571
  options,
1572
1572
  multiple
1573
- }: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime2.JSX.Element;
1573
+ }: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime3.JSX.Element;
1574
1574
  //#endregion
1575
1575
  //#region src/components/data-table/data-table-pagination.d.ts
1576
1576
  interface DataTablePaginationProps<TData> extends React.ComponentProps<'div'> {
@@ -1582,7 +1582,7 @@ declare function DataTablePagination<TData>({
1582
1582
  pageSizeOptions,
1583
1583
  className,
1584
1584
  ...props
1585
- }: DataTablePaginationProps<TData>): react_jsx_runtime2.JSX.Element;
1585
+ }: DataTablePaginationProps<TData>): react_jsx_runtime3.JSX.Element;
1586
1586
  //#endregion
1587
1587
  //#region src/components/data-table/data-table-toolbar.d.ts
1588
1588
  interface DataTableToolbarProps<TData> extends React$1.ComponentProps<'div'> {
@@ -1593,7 +1593,7 @@ declare function DataTableToolbar<TData>({
1593
1593
  children,
1594
1594
  className,
1595
1595
  ...props
1596
- }: DataTableToolbarProps<TData>): react_jsx_runtime2.JSX.Element;
1596
+ }: DataTableToolbarProps<TData>): react_jsx_runtime3.JSX.Element;
1597
1597
  //#endregion
1598
1598
  //#region src/components/data-table/data-table-view-options.d.ts
1599
1599
  interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
@@ -1604,7 +1604,7 @@ declare function DataTableViewOptions<TData>({
1604
1604
  table,
1605
1605
  disabled,
1606
1606
  ...props
1607
- }: DataTableViewOptionsProps<TData>): react_jsx_runtime2.JSX.Element;
1607
+ }: DataTableViewOptionsProps<TData>): react_jsx_runtime3.JSX.Element;
1608
1608
  //#endregion
1609
1609
  //#region src/lib/crud-actions.d.ts
1610
1610
  type CrudActionZone = 'toolbar' | 'row' | 'batch';
@@ -1898,10 +1898,15 @@ declare function createMemoryDataSource<T extends {
1898
1898
  id: string | number;
1899
1899
  }>(initialData?: T[]): DataSource<T>;
1900
1900
  //#endregion
1901
- //#region src/lib/utils.d.ts
1902
- declare function cn(...inputs: ClassValue[]): string;
1903
- //#endregion
1904
1901
  //#region src/lib/format.d.ts
1902
+ type DateFormatter = (date: Date, options: Intl.DateTimeFormatOptions) => string;
1903
+ /**
1904
+ * Register the host's process-wide date presentation policy without coupling
1905
+ * AutoCrud to locale or timezone selection. The returned cleanup removes only
1906
+ * this registration, so overlapping registrations may be disposed out of order.
1907
+ * Passing undefined clears every registration.
1908
+ */
1909
+ declare function setDateFormatter(formatter?: DateFormatter): () => void;
1905
1910
  declare function formatDate(date: Date | string | number | undefined, opts?: Intl.DateTimeFormatOptions): string;
1906
1911
  //#endregion
1907
1912
  //#region src/lib/humanize.d.ts
@@ -1915,6 +1920,9 @@ declare function formatDate(date: Date | string | number | undefined, opts?: Int
1915
1920
  */
1916
1921
  declare function humanize(str: string): string;
1917
1922
  //#endregion
1923
+ //#region src/lib/utils.d.ts
1924
+ declare function cn(...inputs: ClassValue[]): string;
1925
+ //#endregion
1918
1926
  //#region src/lib/import.d.ts
1919
1927
  interface ParsedImportData {
1920
1928
  headers: string[];
@@ -1979,4 +1987,4 @@ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], op
1979
1987
  */
1980
1988
  declare function downloadCSVTemplate(headers: string[], filename?: string): void;
1981
1989
  //#endregion
1982
- export { type ActionConfig, type ActionItem, type ActionsColumnConfig, type AutoCrudActionConfig, type AutoCrudActionsConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceEntry, type AutoCrudDataSourceLoader, type AutoCrudDataSourceRegistration, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, type AutoCrudQueryCapabilities, type AutoCrudRowActionContext, AutoCrudTable, type AutoCrudTableProps, type AutoCrudToolbarContext, type AutoCrudToolbarResolver, AutoForm, type AutoFormProps, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type BatchActionConfig, type BatchActionContext, type BatchActionItem, type BatchBuiltinActionItem, type BatchBuiltinActionType, type BatchCustomActionItem, type BatchUpdateField, type ColumnOverrides, type CreateFormSchemaOptions, type CreateTableSchemaOptions, type CrudActionBase, type CrudActionEntry, type CrudActionRegistration, type CrudActionZone, CrudFormModal, type CrudHooks, type CrudOperationPermissions, type CrudPermissions, type DataSource, DataTable, DataTableAdvancedToolbar, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableRowAction, DataTableToolbar, DataTableViewOptions, type EnumOption, ExportDialog, type ExportDialogProps, type ExportMode, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldOption, type FieldType, type Fields, type FilterConfig, FilterOperator, type FilterVariant, type FormSchemaOverrides, ImportDialog, type ImportDialogProps, type ImportResult, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, type LocaleProp, MultiCombobox, type MultiComboboxOption, type MultiComboboxProps, type MultiComboboxTriggerRenderProps, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, type RowActionConfig, type RowActionItem, type RowBuiltinActionItem, type RowBuiltinActionType, type RowCustomActionItem, SchemaAdapter, Select, type SelectMode, type SelectOption, type SelectProps, type SelectSearchableDynamicProps, type SelectSearchableMultipleProps, type SelectSearchableProps, type SelectSearchableSingleProps, type SelectSimpleProps, type SelectTriggerRenderProps, type SimpleFieldConfig, type SimpleFieldsConfig, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarBuiltinActionType, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, 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, setSearchParams, setToolbarResolver, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
1990
+ export { type ActionConfig, type ActionItem, type ActionsColumnConfig, type AutoCrudActionConfig, type AutoCrudActionsConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceEntry, type AutoCrudDataSourceLoader, type AutoCrudDataSourceRegistration, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, type AutoCrudQueryCapabilities, type AutoCrudRowActionContext, AutoCrudTable, type AutoCrudTableProps, type AutoCrudToolbarContext, type AutoCrudToolbarResolver, AutoForm, type AutoFormProps, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type BatchActionConfig, type BatchActionContext, type BatchActionItem, type BatchBuiltinActionItem, type BatchBuiltinActionType, type BatchCustomActionItem, type BatchUpdateField, type ColumnOverrides, type CreateFormSchemaOptions, type CreateTableSchemaOptions, type CrudActionBase, type CrudActionEntry, type CrudActionRegistration, type CrudActionZone, CrudFormModal, type CrudHooks, type CrudOperationPermissions, type CrudPermissions, type DataSource, DataTable, DataTableAdvancedToolbar, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableRowAction, DataTableToolbar, DataTableViewOptions, type DateFormatter, type EnumOption, ExportDialog, type ExportDialogProps, type ExportMode, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldOption, type FieldType, type Fields, type FilterConfig, FilterOperator, type FilterVariant, type FormSchemaOverrides, ImportDialog, type ImportDialogProps, type ImportResult, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, type LocaleProp, MultiCombobox, type MultiComboboxOption, type MultiComboboxProps, type MultiComboboxTriggerRenderProps, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, type RowActionConfig, type RowActionItem, type RowBuiltinActionItem, type RowBuiltinActionType, type RowCustomActionItem, SchemaAdapter, Select, type SelectMode, type SelectOption, type SelectProps, type SelectSearchableDynamicProps, type SelectSearchableMultipleProps, type SelectSearchableProps, type SelectSearchableSingleProps, type SelectSimpleProps, type SelectTriggerRenderProps, type SimpleFieldConfig, type SimpleFieldsConfig, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarBuiltinActionType, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, 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 };
package/dist/index.d.ts CHANGED
@@ -1898,10 +1898,15 @@ declare function createMemoryDataSource<T extends {
1898
1898
  id: string | number;
1899
1899
  }>(initialData?: T[]): DataSource<T>;
1900
1900
  //#endregion
1901
- //#region src/lib/utils.d.ts
1902
- declare function cn(...inputs: ClassValue[]): string;
1903
- //#endregion
1904
1901
  //#region src/lib/format.d.ts
1902
+ type DateFormatter = (date: Date, options: Intl.DateTimeFormatOptions) => string;
1903
+ /**
1904
+ * Register the host's process-wide date presentation policy without coupling
1905
+ * AutoCrud to locale or timezone selection. The returned cleanup removes only
1906
+ * this registration, so overlapping registrations may be disposed out of order.
1907
+ * Passing undefined clears every registration.
1908
+ */
1909
+ declare function setDateFormatter(formatter?: DateFormatter): () => void;
1905
1910
  declare function formatDate(date: Date | string | number | undefined, opts?: Intl.DateTimeFormatOptions): string;
1906
1911
  //#endregion
1907
1912
  //#region src/lib/humanize.d.ts
@@ -1915,6 +1920,9 @@ declare function formatDate(date: Date | string | number | undefined, opts?: Int
1915
1920
  */
1916
1921
  declare function humanize(str: string): string;
1917
1922
  //#endregion
1923
+ //#region src/lib/utils.d.ts
1924
+ declare function cn(...inputs: ClassValue[]): string;
1925
+ //#endregion
1918
1926
  //#region src/lib/import.d.ts
1919
1927
  interface ParsedImportData {
1920
1928
  headers: string[];
@@ -1979,4 +1987,4 @@ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], op
1979
1987
  */
1980
1988
  declare function downloadCSVTemplate(headers: string[], filename?: string): void;
1981
1989
  //#endregion
1982
- export { type ActionConfig, type ActionItem, type ActionsColumnConfig, type AutoCrudActionConfig, type AutoCrudActionsConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceEntry, type AutoCrudDataSourceLoader, type AutoCrudDataSourceRegistration, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, type AutoCrudQueryCapabilities, type AutoCrudRowActionContext, AutoCrudTable, type AutoCrudTableProps, type AutoCrudToolbarContext, type AutoCrudToolbarResolver, AutoForm, type AutoFormProps, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type BatchActionConfig, type BatchActionContext, type BatchActionItem, type BatchBuiltinActionItem, type BatchBuiltinActionType, type BatchCustomActionItem, type BatchUpdateField, type ColumnOverrides, type CreateFormSchemaOptions, type CreateTableSchemaOptions, type CrudActionBase, type CrudActionEntry, type CrudActionRegistration, type CrudActionZone, CrudFormModal, type CrudHooks, type CrudOperationPermissions, type CrudPermissions, type DataSource, DataTable, DataTableAdvancedToolbar, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableRowAction, DataTableToolbar, DataTableViewOptions, type EnumOption, ExportDialog, type ExportDialogProps, type ExportMode, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldOption, type FieldType, type Fields, type FilterConfig, FilterOperator, type FilterVariant, type FormSchemaOverrides, ImportDialog, type ImportDialogProps, type ImportResult, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, type LocaleProp, MultiCombobox, type MultiComboboxOption, type MultiComboboxProps, type MultiComboboxTriggerRenderProps, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, type RowActionConfig, type RowActionItem, type RowBuiltinActionItem, type RowBuiltinActionType, type RowCustomActionItem, SchemaAdapter, Select, type SelectMode, type SelectOption, type SelectProps, type SelectSearchableDynamicProps, type SelectSearchableMultipleProps, type SelectSearchableProps, type SelectSearchableSingleProps, type SelectSimpleProps, type SelectTriggerRenderProps, type SimpleFieldConfig, type SimpleFieldsConfig, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarBuiltinActionType, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, 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, setSearchParams, setToolbarResolver, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
1990
+ export { type ActionConfig, type ActionItem, type ActionsColumnConfig, type AutoCrudActionConfig, type AutoCrudActionsConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceEntry, type AutoCrudDataSourceLoader, type AutoCrudDataSourceRegistration, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, type AutoCrudQueryCapabilities, type AutoCrudRowActionContext, AutoCrudTable, type AutoCrudTableProps, type AutoCrudToolbarContext, type AutoCrudToolbarResolver, AutoForm, type AutoFormProps, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type BatchActionConfig, type BatchActionContext, type BatchActionItem, type BatchBuiltinActionItem, type BatchBuiltinActionType, type BatchCustomActionItem, type BatchUpdateField, type ColumnOverrides, type CreateFormSchemaOptions, type CreateTableSchemaOptions, type CrudActionBase, type CrudActionEntry, type CrudActionRegistration, type CrudActionZone, CrudFormModal, type CrudHooks, type CrudOperationPermissions, type CrudPermissions, type DataSource, DataTable, DataTableAdvancedToolbar, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableRowAction, DataTableToolbar, DataTableViewOptions, type DateFormatter, type EnumOption, ExportDialog, type ExportDialogProps, type ExportMode, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldOption, type FieldType, type Fields, type FilterConfig, FilterOperator, type FilterVariant, type FormSchemaOverrides, ImportDialog, type ImportDialogProps, type ImportResult, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, type LocaleProp, MultiCombobox, type MultiComboboxOption, type MultiComboboxProps, type MultiComboboxTriggerRenderProps, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, type RowActionConfig, type RowActionItem, type RowBuiltinActionItem, type RowBuiltinActionType, type RowCustomActionItem, SchemaAdapter, Select, type SelectMode, type SelectOption, type SelectProps, type SelectSearchableDynamicProps, type SelectSearchableMultipleProps, type SelectSearchableProps, type SelectSearchableSingleProps, type SelectSimpleProps, type SelectTriggerRenderProps, type SimpleFieldConfig, type SimpleFieldsConfig, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarBuiltinActionType, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, 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 };
package/dist/index.js CHANGED
@@ -886,16 +886,43 @@ function useDebouncedCallback(callback, delay) {
886
886
 
887
887
  //#endregion
888
888
  //#region src/lib/format.ts
889
+ let hostDateFormatters = [];
890
+ function getHostDateFormatter() {
891
+ return hostDateFormatters[hostDateFormatters.length - 1]?.formatter;
892
+ }
893
+ /**
894
+ * Register the host's process-wide date presentation policy without coupling
895
+ * AutoCrud to locale or timezone selection. The returned cleanup removes only
896
+ * this registration, so overlapping registrations may be disposed out of order.
897
+ * Passing undefined clears every registration.
898
+ */
899
+ function setDateFormatter(formatter) {
900
+ if (formatter === void 0) {
901
+ hostDateFormatters = [];
902
+ return () => void 0;
903
+ }
904
+ const registration = {
905
+ formatter,
906
+ token: Symbol("date-formatter")
907
+ };
908
+ hostDateFormatters.push(registration);
909
+ return () => {
910
+ hostDateFormatters = hostDateFormatters.filter(({ token }) => token !== registration.token);
911
+ };
912
+ }
889
913
  function formatDate(date, opts = {}) {
890
- if (!date) return "";
914
+ if (date === void 0) return "";
891
915
  try {
892
- return new Intl.DateTimeFormat("en-US", {
916
+ const value = new Date(date);
917
+ const options = {
893
918
  month: opts.month ?? "long",
894
919
  day: opts.day ?? "numeric",
895
920
  year: opts.year ?? "numeric",
896
921
  ...opts
897
- }).format(new Date(date));
898
- } catch (_err) {
922
+ };
923
+ const hostDateFormatter = getHostDateFormatter();
924
+ return hostDateFormatter ? hostDateFormatter(value, options) : new Intl.DateTimeFormat("en-US", options).format(value);
925
+ } catch {
899
926
  return "";
900
927
  }
901
928
  }
@@ -8442,4 +8469,4 @@ function createMemoryDataSource(initialData = []) {
8442
8469
  }
8443
8470
 
8444
8471
  //#endregion
8445
- 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, setSearchParams, setToolbarResolver, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
8472
+ 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 };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wordrhyme/auto-crud",
3
3
  "type": "module",
4
- "version": "1.4.3",
4
+ "version": "1.5.0",
5
5
  "description": "Schema-first CRUD components with auto-generated tables and forms",
6
6
  "author": "wordrhyme",
7
7
  "license": "MIT",
@@ -62,9 +62,9 @@
62
62
  "nanoid": "^5.1.6",
63
63
  "tailwind-merge": "^3.5.0",
64
64
  "vaul": "^1.1.2",
65
- "@wordrhyme/formily-shadcn": "1.13.1",
66
- "@wordrhyme/shadcn": "1.3.2",
67
- "@wordrhyme/shadcn-ui": "1.32.6"
65
+ "@wordrhyme/shadcn-ui": "1.32.7",
66
+ "@wordrhyme/formily-shadcn": "1.13.2",
67
+ "@wordrhyme/shadcn": "1.3.2"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@storybook/react": "^8.6.18",
@@ -84,9 +84,9 @@
84
84
  "tsdown": "^0.15.12",
85
85
  "typescript": "^5.9.3",
86
86
  "vitest": "^3.2.4",
87
+ "@internal/prettier-config": "0.0.1",
87
88
  "@internal/eslint-config": "0.3.0",
88
89
  "@internal/tsconfig": "0.1.0",
89
- "@internal/prettier-config": "0.0.1",
90
90
  "@internal/tsdown-config": "0.1.0",
91
91
  "@internal/vitest-config": "0.1.0"
92
92
  },