@wordrhyme/auto-crud 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +68 -43
- package/dist/index.d.ts +16 -16
- package/dist/index.js +69 -44
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -380,9 +380,77 @@ function getDefaultFilterOperator(filterVariant) {
|
|
|
380
380
|
return getFilterOperators(filterVariant)[0]?.value ?? (filterVariant === "text" ? "iLike" : "eq");
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
+
//#endregion
|
|
384
|
+
//#region src/lib/format.ts
|
|
385
|
+
let hostDateFormatters = [];
|
|
386
|
+
let dateFormatterVersion = 0;
|
|
387
|
+
const dateFormatterListeners = /* @__PURE__ */ new Set();
|
|
388
|
+
function notifyDateFormatterChange() {
|
|
389
|
+
dateFormatterVersion += 1;
|
|
390
|
+
dateFormatterListeners.forEach((listener) => listener());
|
|
391
|
+
}
|
|
392
|
+
function subscribeDateFormatter(listener) {
|
|
393
|
+
dateFormatterListeners.add(listener);
|
|
394
|
+
return () => {
|
|
395
|
+
dateFormatterListeners.delete(listener);
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
function getDateFormatterVersion() {
|
|
399
|
+
return dateFormatterVersion;
|
|
400
|
+
}
|
|
401
|
+
function useDateFormatterVersion() {
|
|
402
|
+
return (0, react.useSyncExternalStore)(subscribeDateFormatter, getDateFormatterVersion, getDateFormatterVersion);
|
|
403
|
+
}
|
|
404
|
+
function getHostDateFormatter() {
|
|
405
|
+
return hostDateFormatters[hostDateFormatters.length - 1]?.formatter;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Register the host's process-wide date presentation policy without coupling
|
|
409
|
+
* AutoCrud to locale or timezone selection. The returned cleanup removes only
|
|
410
|
+
* this registration, so overlapping registrations may be disposed out of order.
|
|
411
|
+
* Passing undefined clears every registration.
|
|
412
|
+
*/
|
|
413
|
+
function setDateFormatter(formatter) {
|
|
414
|
+
if (formatter === void 0) {
|
|
415
|
+
const hadFormatter = hostDateFormatters.length > 0;
|
|
416
|
+
hostDateFormatters = [];
|
|
417
|
+
if (hadFormatter) notifyDateFormatterChange();
|
|
418
|
+
return () => void 0;
|
|
419
|
+
}
|
|
420
|
+
const registration = {
|
|
421
|
+
formatter,
|
|
422
|
+
token: Symbol("date-formatter")
|
|
423
|
+
};
|
|
424
|
+
hostDateFormatters.push(registration);
|
|
425
|
+
notifyDateFormatterChange();
|
|
426
|
+
return () => {
|
|
427
|
+
const currentFormatter = getHostDateFormatter();
|
|
428
|
+
const previousLength = hostDateFormatters.length;
|
|
429
|
+
hostDateFormatters = hostDateFormatters.filter(({ token }) => token !== registration.token);
|
|
430
|
+
if (hostDateFormatters.length !== previousLength && getHostDateFormatter() !== currentFormatter) notifyDateFormatterChange();
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
function formatDate(date, opts = {}) {
|
|
434
|
+
if (date === void 0) return "";
|
|
435
|
+
try {
|
|
436
|
+
const value = new Date(date);
|
|
437
|
+
const options = {
|
|
438
|
+
month: opts.month ?? "long",
|
|
439
|
+
day: opts.day ?? "numeric",
|
|
440
|
+
year: opts.year ?? "numeric",
|
|
441
|
+
...opts
|
|
442
|
+
};
|
|
443
|
+
const hostDateFormatter = getHostDateFormatter();
|
|
444
|
+
return hostDateFormatter ? hostDateFormatter(value, options) : new Intl.DateTimeFormat("en-US", options).format(value);
|
|
445
|
+
} catch {
|
|
446
|
+
return "";
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
383
450
|
//#endregion
|
|
384
451
|
//#region src/components/data-table/data-table.tsx
|
|
385
452
|
function DataTable({ table, actionBar, children, className,...props }) {
|
|
453
|
+
useDateFormatterVersion();
|
|
386
454
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
387
455
|
className: cn("flex w-full flex-col gap-2.5 overflow-auto", className),
|
|
388
456
|
...props,
|
|
@@ -921,49 +989,6 @@ function useDebouncedCallback(callback, delay) {
|
|
|
921
989
|
}, [handleCallback, delay]);
|
|
922
990
|
}
|
|
923
991
|
|
|
924
|
-
//#endregion
|
|
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
|
-
}
|
|
950
|
-
function formatDate(date, opts = {}) {
|
|
951
|
-
if (date === void 0) return "";
|
|
952
|
-
try {
|
|
953
|
-
const value = new Date(date);
|
|
954
|
-
const options = {
|
|
955
|
-
month: opts.month ?? "long",
|
|
956
|
-
day: opts.day ?? "numeric",
|
|
957
|
-
year: opts.year ?? "numeric",
|
|
958
|
-
...opts
|
|
959
|
-
};
|
|
960
|
-
const hostDateFormatter = getHostDateFormatter();
|
|
961
|
-
return hostDateFormatter ? hostDateFormatter(value, options) : new Intl.DateTimeFormat("en-US", options).format(value);
|
|
962
|
-
} catch {
|
|
963
|
-
return "";
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
|
|
967
992
|
//#endregion
|
|
968
993
|
//#region src/components/data-table/data-table-filter-list.tsx
|
|
969
994
|
const DEBOUNCE_MS$2 = 300;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _tanstack_react_table0 from "@tanstack/react-table";
|
|
|
3
3
|
import { Column, ColumnDef, ColumnSort, Row, RowData, Table, TableOptions, TableState } from "@tanstack/react-table";
|
|
4
4
|
import { DropdownMenuTrigger, PopoverContent } from "@wordrhyme/shadcn";
|
|
5
5
|
import { ClassValue } from "clsx";
|
|
6
|
-
import * as
|
|
6
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
7
7
|
import { MultiCombobox, MultiComboboxOption, MultiComboboxProps, MultiComboboxTriggerRenderProps, Select, SelectMode, SelectOption, SelectProps, SelectSearchableDynamicProps, SelectSearchableMultipleProps, SelectSearchableProps, SelectSearchableSingleProps, SelectSimpleProps, SelectTriggerRenderProps } from "@wordrhyme/shadcn-ui";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import { JsonSchemaFormScope } from "@wordrhyme/formily-shadcn";
|
|
@@ -411,7 +411,7 @@ declare function AutoTableActionBar<TData>({
|
|
|
411
411
|
extraActions,
|
|
412
412
|
actions,
|
|
413
413
|
deleteConfirmation
|
|
414
|
-
}: AutoTableActionBarProps<TData>):
|
|
414
|
+
}: AutoTableActionBarProps<TData>): react_jsx_runtime2.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>):
|
|
590
|
+
}: AutoTableProps<T>): react_jsx_runtime2.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>):
|
|
1082
|
+
}: AutoCrudTableProps<TSchema>): react_jsx_runtime2.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>):
|
|
1121
|
+
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime2.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>):
|
|
1437
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime2.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>):
|
|
1481
|
+
}: CrudFormModalProps<T>): react_jsx_runtime2.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):
|
|
1503
|
+
}: ImportDialogProps): react_jsx_runtime2.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):
|
|
1523
|
+
}: ExportDialogProps): react_jsx_runtime2.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>):
|
|
1536
|
+
}: DataTableProps<TData>): react_jsx_runtime2.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>):
|
|
1547
|
+
}: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime2.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>):
|
|
1559
|
+
}: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime2.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>):
|
|
1573
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime2.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>):
|
|
1585
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime2.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>):
|
|
1596
|
+
}: DataTableToolbarProps<TData>): react_jsx_runtime2.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>):
|
|
1607
|
+
}: DataTableViewOptionsProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
1608
1608
|
//#endregion
|
|
1609
1609
|
//#region src/lib/crud-actions.d.ts
|
|
1610
1610
|
type CrudActionZone = 'toolbar' | 'row' | 'batch';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useReducer, useRef, useState } from "react";
|
|
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
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";
|
|
@@ -343,9 +343,77 @@ function getDefaultFilterOperator(filterVariant) {
|
|
|
343
343
|
return getFilterOperators(filterVariant)[0]?.value ?? (filterVariant === "text" ? "iLike" : "eq");
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/lib/format.ts
|
|
348
|
+
let hostDateFormatters = [];
|
|
349
|
+
let dateFormatterVersion = 0;
|
|
350
|
+
const dateFormatterListeners = /* @__PURE__ */ new Set();
|
|
351
|
+
function notifyDateFormatterChange() {
|
|
352
|
+
dateFormatterVersion += 1;
|
|
353
|
+
dateFormatterListeners.forEach((listener) => listener());
|
|
354
|
+
}
|
|
355
|
+
function subscribeDateFormatter(listener) {
|
|
356
|
+
dateFormatterListeners.add(listener);
|
|
357
|
+
return () => {
|
|
358
|
+
dateFormatterListeners.delete(listener);
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
function getDateFormatterVersion() {
|
|
362
|
+
return dateFormatterVersion;
|
|
363
|
+
}
|
|
364
|
+
function useDateFormatterVersion() {
|
|
365
|
+
return useSyncExternalStore(subscribeDateFormatter, getDateFormatterVersion, getDateFormatterVersion);
|
|
366
|
+
}
|
|
367
|
+
function getHostDateFormatter() {
|
|
368
|
+
return hostDateFormatters[hostDateFormatters.length - 1]?.formatter;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Register the host's process-wide date presentation policy without coupling
|
|
372
|
+
* AutoCrud to locale or timezone selection. The returned cleanup removes only
|
|
373
|
+
* this registration, so overlapping registrations may be disposed out of order.
|
|
374
|
+
* Passing undefined clears every registration.
|
|
375
|
+
*/
|
|
376
|
+
function setDateFormatter(formatter) {
|
|
377
|
+
if (formatter === void 0) {
|
|
378
|
+
const hadFormatter = hostDateFormatters.length > 0;
|
|
379
|
+
hostDateFormatters = [];
|
|
380
|
+
if (hadFormatter) notifyDateFormatterChange();
|
|
381
|
+
return () => void 0;
|
|
382
|
+
}
|
|
383
|
+
const registration = {
|
|
384
|
+
formatter,
|
|
385
|
+
token: Symbol("date-formatter")
|
|
386
|
+
};
|
|
387
|
+
hostDateFormatters.push(registration);
|
|
388
|
+
notifyDateFormatterChange();
|
|
389
|
+
return () => {
|
|
390
|
+
const currentFormatter = getHostDateFormatter();
|
|
391
|
+
const previousLength = hostDateFormatters.length;
|
|
392
|
+
hostDateFormatters = hostDateFormatters.filter(({ token }) => token !== registration.token);
|
|
393
|
+
if (hostDateFormatters.length !== previousLength && getHostDateFormatter() !== currentFormatter) notifyDateFormatterChange();
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
function formatDate(date, opts = {}) {
|
|
397
|
+
if (date === void 0) return "";
|
|
398
|
+
try {
|
|
399
|
+
const value = new Date(date);
|
|
400
|
+
const options = {
|
|
401
|
+
month: opts.month ?? "long",
|
|
402
|
+
day: opts.day ?? "numeric",
|
|
403
|
+
year: opts.year ?? "numeric",
|
|
404
|
+
...opts
|
|
405
|
+
};
|
|
406
|
+
const hostDateFormatter = getHostDateFormatter();
|
|
407
|
+
return hostDateFormatter ? hostDateFormatter(value, options) : new Intl.DateTimeFormat("en-US", options).format(value);
|
|
408
|
+
} catch {
|
|
409
|
+
return "";
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
346
413
|
//#endregion
|
|
347
414
|
//#region src/components/data-table/data-table.tsx
|
|
348
415
|
function DataTable({ table, actionBar, children, className,...props }) {
|
|
416
|
+
useDateFormatterVersion();
|
|
349
417
|
return /* @__PURE__ */ jsxs("div", {
|
|
350
418
|
className: cn("flex w-full flex-col gap-2.5 overflow-auto", className),
|
|
351
419
|
...props,
|
|
@@ -884,49 +952,6 @@ function useDebouncedCallback(callback, delay) {
|
|
|
884
952
|
}, [handleCallback, delay]);
|
|
885
953
|
}
|
|
886
954
|
|
|
887
|
-
//#endregion
|
|
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
|
-
}
|
|
913
|
-
function formatDate(date, opts = {}) {
|
|
914
|
-
if (date === void 0) return "";
|
|
915
|
-
try {
|
|
916
|
-
const value = new Date(date);
|
|
917
|
-
const options = {
|
|
918
|
-
month: opts.month ?? "long",
|
|
919
|
-
day: opts.day ?? "numeric",
|
|
920
|
-
year: opts.year ?? "numeric",
|
|
921
|
-
...opts
|
|
922
|
-
};
|
|
923
|
-
const hostDateFormatter = getHostDateFormatter();
|
|
924
|
-
return hostDateFormatter ? hostDateFormatter(value, options) : new Intl.DateTimeFormat("en-US", options).format(value);
|
|
925
|
-
} catch {
|
|
926
|
-
return "";
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
|
|
930
955
|
//#endregion
|
|
931
956
|
//#region src/components/data-table/data-table-filter-list.tsx
|
|
932
957
|
const DEBOUNCE_MS$2 = 300;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordrhyme/auto-crud",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.5.
|
|
4
|
+
"version": "1.5.1",
|
|
5
5
|
"description": "Schema-first CRUD components with auto-generated tables and forms",
|
|
6
6
|
"author": "wordrhyme",
|
|
7
7
|
"license": "MIT",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"nanoid": "^5.1.6",
|
|
63
63
|
"tailwind-merge": "^3.5.0",
|
|
64
64
|
"vaul": "^1.1.2",
|
|
65
|
-
"@wordrhyme/shadcn-ui": "1.32.7",
|
|
66
65
|
"@wordrhyme/formily-shadcn": "1.13.2",
|
|
66
|
+
"@wordrhyme/shadcn-ui": "1.32.7",
|
|
67
67
|
"@wordrhyme/shadcn": "1.3.2"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|