@wordrhyme/auto-crud 1.3.9 → 1.4.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 +49 -7
- package/dist/index.d.cts +50 -34
- package/dist/index.d.ts +50 -34
- package/dist/index.js +49 -7
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -108,8 +108,7 @@ function DataTablePagination({ table, pageSizeOptions = [
|
|
|
108
108
|
children: [
|
|
109
109
|
"Page ",
|
|
110
110
|
table.getState().pagination.pageIndex + 1,
|
|
111
|
-
" of",
|
|
112
|
-
" ",
|
|
111
|
+
" of ",
|
|
113
112
|
table.getPageCount()
|
|
114
113
|
]
|
|
115
114
|
}),
|
|
@@ -6426,6 +6425,35 @@ function buildTableOverrides(fields, legacyOverrides, dynamicFilterState, dynami
|
|
|
6426
6425
|
}
|
|
6427
6426
|
return result;
|
|
6428
6427
|
}
|
|
6428
|
+
function buildCapabilityTableOverrides(schema, capabilities) {
|
|
6429
|
+
if (!capabilities) return {};
|
|
6430
|
+
const result = {};
|
|
6431
|
+
const filterFields = capabilities.filters?.fields;
|
|
6432
|
+
const sortFields = capabilities.sort?.fields;
|
|
6433
|
+
const filterSet = Array.isArray(filterFields) ? new Set(filterFields) : null;
|
|
6434
|
+
const sortSet = Array.isArray(sortFields) ? new Set(sortFields) : null;
|
|
6435
|
+
for (const key of Object.keys(schema.shape)) {
|
|
6436
|
+
const override = {};
|
|
6437
|
+
if (capabilities.filters) {
|
|
6438
|
+
if (!capabilities.filters.enabled) override.enableColumnFilter = false;
|
|
6439
|
+
else if (filterSet) override.enableColumnFilter = filterSet.has(key);
|
|
6440
|
+
}
|
|
6441
|
+
if (capabilities.sort) {
|
|
6442
|
+
if (!capabilities.sort.enabled) override.enableSorting = false;
|
|
6443
|
+
else if (sortSet) override.enableSorting = sortSet.has(key);
|
|
6444
|
+
}
|
|
6445
|
+
if (Object.keys(override).length > 0) result[key] = override;
|
|
6446
|
+
}
|
|
6447
|
+
return result;
|
|
6448
|
+
}
|
|
6449
|
+
function mergeTableOverrides(base, enforced) {
|
|
6450
|
+
const result = { ...base ?? {} };
|
|
6451
|
+
for (const [key, override] of Object.entries(enforced)) result[key] = {
|
|
6452
|
+
...result[key] ?? {},
|
|
6453
|
+
...override
|
|
6454
|
+
};
|
|
6455
|
+
return result;
|
|
6456
|
+
}
|
|
6429
6457
|
/**
|
|
6430
6458
|
* 从统一配置生成隐藏列列表
|
|
6431
6459
|
*/
|
|
@@ -6837,11 +6865,13 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6837
6865
|
toolbarOpenCreate
|
|
6838
6866
|
]);
|
|
6839
6867
|
const resolvedToolbarActions = resolveToolbarActionsWithResolver(id, registryToolbarActions, toolbarContext);
|
|
6840
|
-
const tableOverrides = react.useMemo(() => buildTableOverrides(resolvedFields, tableConfig?.overrides, dynamicFilterOptions, dynamicResolveOptions), [
|
|
6868
|
+
const tableOverrides = react.useMemo(() => mergeTableOverrides(buildTableOverrides(resolvedFields, tableConfig?.overrides, dynamicFilterOptions, dynamicResolveOptions), buildCapabilityTableOverrides(resolvedSchema, resource.capabilities)), [
|
|
6841
6869
|
resolvedFields,
|
|
6842
6870
|
tableConfig?.overrides,
|
|
6843
6871
|
dynamicFilterOptions,
|
|
6844
|
-
dynamicResolveOptions
|
|
6872
|
+
dynamicResolveOptions,
|
|
6873
|
+
resolvedSchema,
|
|
6874
|
+
resource.capabilities
|
|
6845
6875
|
]);
|
|
6846
6876
|
const defaultSort = react.useMemo(() => resource.defaultSort ?? tableConfig?.defaultSort ?? getDefaultSortingForSchema(resolvedSchema), [
|
|
6847
6877
|
resource.defaultSort,
|
|
@@ -6855,10 +6885,21 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6855
6885
|
]);
|
|
6856
6886
|
const searchConfig = react.useMemo(() => {
|
|
6857
6887
|
const tableSearch = tableConfig?.search;
|
|
6888
|
+
const searchCapability = resource.capabilities?.search;
|
|
6858
6889
|
if (tableSearch === false) return false;
|
|
6890
|
+
if (searchCapability) {
|
|
6891
|
+
if (!searchCapability.enabled) return false;
|
|
6892
|
+
if (tableSearch && typeof tableSearch === "object") return tableSearch;
|
|
6893
|
+
return true;
|
|
6894
|
+
}
|
|
6859
6895
|
if (tableSearch && typeof tableSearch === "object") return tableSearch;
|
|
6896
|
+
if (tableSearch === true) return true;
|
|
6860
6897
|
return Object.values(resolvedFields).some((field) => field?.search === true) ? true : false;
|
|
6861
|
-
}, [
|
|
6898
|
+
}, [
|
|
6899
|
+
resolvedFields,
|
|
6900
|
+
resource.capabilities?.search,
|
|
6901
|
+
tableConfig?.search
|
|
6902
|
+
]);
|
|
6862
6903
|
const batchFields = react.useMemo(() => buildBatchUpdateFields(resolvedSchema, tableConfig?.batchFields, resolvedFields), [
|
|
6863
6904
|
resolvedSchema,
|
|
6864
6905
|
tableConfig?.batchFields,
|
|
@@ -7506,8 +7547,7 @@ function DataTableSliderFilter({ column, title }) {
|
|
|
7506
7547
|
className: "mx-0.5 data-[orientation=vertical]:h-4"
|
|
7507
7548
|
}),
|
|
7508
7549
|
formatValue(columnFilterValue[0]),
|
|
7509
|
-
" -",
|
|
7510
|
-
" ",
|
|
7550
|
+
" - ",
|
|
7511
7551
|
formatValue(columnFilterValue[1]),
|
|
7512
7552
|
unit ? ` ${unit}` : ""
|
|
7513
7553
|
] }) : null
|
|
@@ -7811,6 +7851,7 @@ function useAutoCrudResource({ router, schema, query: queryTransform, options =
|
|
|
7811
7851
|
const resolvedSchema = (0, react.useMemo)(() => mergeMetadataSchema(schema, metadata?.schema), [schema, metadata?.schema]);
|
|
7812
7852
|
const defaultSorting = (0, react.useMemo)(() => defaultSortOption === false ? [] : defaultSortOption ?? getDefaultSortingForSchema(resolvedSchema), [defaultSortOption, resolvedSchema]);
|
|
7813
7853
|
const metadataFields = (0, react.useMemo)(() => readMetadataFields(metadata?.fields), [metadata?.fields]);
|
|
7854
|
+
const capabilities = metadata?.capabilities;
|
|
7814
7855
|
const columns = (0, react.useMemo)(() => createTableSchema(resolvedSchema), [resolvedSchema]);
|
|
7815
7856
|
const [urlParams] = useQueryStates({
|
|
7816
7857
|
page: parseAsInteger.withDefault(1),
|
|
@@ -8103,6 +8144,7 @@ function useAutoCrudResource({ router, schema, query: queryTransform, options =
|
|
|
8103
8144
|
},
|
|
8104
8145
|
schema: resolvedSchema,
|
|
8105
8146
|
fields: metadataFields,
|
|
8147
|
+
capabilities,
|
|
8106
8148
|
defaultSort: defaultSorting,
|
|
8107
8149
|
modal,
|
|
8108
8150
|
mutations: {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime2 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";
|
|
@@ -28,6 +28,20 @@ interface ToastAdapter {
|
|
|
28
28
|
}
|
|
29
29
|
/** 空 toast 适配器(禁用通知) */
|
|
30
30
|
declare const noopToastAdapter: ToastAdapter;
|
|
31
|
+
interface AutoCrudQueryCapabilities {
|
|
32
|
+
search?: {
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
fields: string[];
|
|
35
|
+
};
|
|
36
|
+
filters?: {
|
|
37
|
+
enabled: boolean;
|
|
38
|
+
fields: string[] | null;
|
|
39
|
+
};
|
|
40
|
+
sort?: {
|
|
41
|
+
enabled: boolean;
|
|
42
|
+
fields: string[] | null;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
31
45
|
/**
|
|
32
46
|
* Modal 状态类型
|
|
33
47
|
*/
|
|
@@ -145,6 +159,8 @@ interface UseAutoCrudResourceReturn<TSchema extends z.ZodObject<z.ZodRawShape>,
|
|
|
145
159
|
schema?: z.ZodObject<z.ZodRawShape>;
|
|
146
160
|
/** Optional field config override from host metadata. */
|
|
147
161
|
fields?: Fields;
|
|
162
|
+
/** Query capabilities reported by auto-crud-server metadata. */
|
|
163
|
+
capabilities?: AutoCrudQueryCapabilities;
|
|
148
164
|
/** Default sorting used by this resource's list query. */
|
|
149
165
|
defaultSort?: AutoCrudSorting;
|
|
150
166
|
modal: ModalState<TListItem>;
|
|
@@ -395,7 +411,7 @@ declare function AutoTableActionBar<TData>({
|
|
|
395
411
|
extraActions,
|
|
396
412
|
actions,
|
|
397
413
|
deleteConfirmation
|
|
398
|
-
}: AutoTableActionBarProps<TData>):
|
|
414
|
+
}: AutoTableActionBarProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
399
415
|
//#endregion
|
|
400
416
|
//#region src/lib/schema-bridge/types.d.ts
|
|
401
417
|
/**
|
|
@@ -571,7 +587,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
571
587
|
onSelectedCountChange,
|
|
572
588
|
onSelectedRowsChange,
|
|
573
589
|
getSelectedRows
|
|
574
|
-
}: AutoTableProps<T>):
|
|
590
|
+
}: AutoTableProps<T>): react_jsx_runtime2.JSX.Element;
|
|
575
591
|
//#endregion
|
|
576
592
|
//#region src/i18n/locale.d.ts
|
|
577
593
|
/**
|
|
@@ -1063,7 +1079,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1063
1079
|
toolbarActions,
|
|
1064
1080
|
locale: localeProp,
|
|
1065
1081
|
onCreate
|
|
1066
|
-
}: AutoCrudTableProps<TSchema>):
|
|
1082
|
+
}: AutoCrudTableProps<TSchema>): react_jsx_runtime2.JSX.Element;
|
|
1067
1083
|
//#endregion
|
|
1068
1084
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
1069
1085
|
interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
@@ -1102,7 +1118,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1102
1118
|
labelAlign,
|
|
1103
1119
|
labelWidth,
|
|
1104
1120
|
showSubmitButton
|
|
1105
|
-
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>):
|
|
1121
|
+
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime2.JSX.Element;
|
|
1106
1122
|
declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
|
|
1107
1123
|
ref?: React.Ref<AutoFormRef>;
|
|
1108
1124
|
}) => ReturnType<typeof AutoFormInner>;
|
|
@@ -1118,7 +1134,7 @@ declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormPr
|
|
|
1118
1134
|
*/
|
|
1119
1135
|
interface UrlStateOptions {
|
|
1120
1136
|
/** 历史记录模式: push 添加新记录, replace 替换当前记录 */
|
|
1121
|
-
history?:
|
|
1137
|
+
history?: 'push' | 'replace';
|
|
1122
1138
|
/** 是否浅层更新(不触发页面刷新) */
|
|
1123
1139
|
shallow?: boolean;
|
|
1124
1140
|
/** 节流时间(毫秒) */
|
|
@@ -1157,7 +1173,7 @@ declare function parseAsArrayOf<T>(itemParser: Parser<T>, separator?: string): P
|
|
|
1157
1173
|
};
|
|
1158
1174
|
};
|
|
1159
1175
|
declare function getUrlParams(): URLSearchParams;
|
|
1160
|
-
declare function setSearchParams(params: URLSearchParams, options?: Pick<UrlStateOptions,
|
|
1176
|
+
declare function setSearchParams(params: URLSearchParams, options?: Pick<UrlStateOptions, 'history' | 'scroll'>): void;
|
|
1161
1177
|
/**
|
|
1162
1178
|
* 单个 URL 状态参数
|
|
1163
1179
|
*/
|
|
@@ -1418,10 +1434,10 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
1418
1434
|
filters: externalFilters,
|
|
1419
1435
|
onFiltersChange,
|
|
1420
1436
|
leading
|
|
1421
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
1437
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime2.JSX.Element | null;
|
|
1422
1438
|
//#endregion
|
|
1423
1439
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
1424
|
-
type ModalVariant =
|
|
1440
|
+
type ModalVariant = 'dialog' | 'sheet';
|
|
1425
1441
|
//#endregion
|
|
1426
1442
|
//#region src/components/auto-crud/crud-form-modal.d.ts
|
|
1427
1443
|
interface CrudFormModalProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
@@ -1462,7 +1478,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1462
1478
|
labelAlign,
|
|
1463
1479
|
labelWidth,
|
|
1464
1480
|
className
|
|
1465
|
-
}: CrudFormModalProps<T>):
|
|
1481
|
+
}: CrudFormModalProps<T>): react_jsx_runtime2.JSX.Element;
|
|
1466
1482
|
//#endregion
|
|
1467
1483
|
//#region src/components/auto-crud/import-dialog.d.ts
|
|
1468
1484
|
interface ImportDialogProps {
|
|
@@ -1484,10 +1500,10 @@ declare function ImportDialog({
|
|
|
1484
1500
|
columns,
|
|
1485
1501
|
title,
|
|
1486
1502
|
locale
|
|
1487
|
-
}: ImportDialogProps):
|
|
1503
|
+
}: ImportDialogProps): react_jsx_runtime2.JSX.Element;
|
|
1488
1504
|
//#endregion
|
|
1489
1505
|
//#region src/components/auto-crud/export-dialog.d.ts
|
|
1490
|
-
type ExportMode =
|
|
1506
|
+
type ExportMode = 'selected' | 'filtered';
|
|
1491
1507
|
interface ExportDialogProps {
|
|
1492
1508
|
open: boolean;
|
|
1493
1509
|
onOpenChange: (open: boolean) => void;
|
|
@@ -1504,10 +1520,10 @@ declare function ExportDialog({
|
|
|
1504
1520
|
selectedCount,
|
|
1505
1521
|
onExport,
|
|
1506
1522
|
canExportFiltered
|
|
1507
|
-
}: ExportDialogProps):
|
|
1523
|
+
}: ExportDialogProps): react_jsx_runtime2.JSX.Element;
|
|
1508
1524
|
//#endregion
|
|
1509
1525
|
//#region src/components/data-table/data-table.d.ts
|
|
1510
|
-
interface DataTableProps<TData> extends React$1.ComponentProps<
|
|
1526
|
+
interface DataTableProps<TData> extends React$1.ComponentProps<'div'> {
|
|
1511
1527
|
table: Table<TData>;
|
|
1512
1528
|
actionBar?: React$1.ReactNode;
|
|
1513
1529
|
}
|
|
@@ -1517,10 +1533,10 @@ declare function DataTable<TData>({
|
|
|
1517
1533
|
children,
|
|
1518
1534
|
className,
|
|
1519
1535
|
...props
|
|
1520
|
-
}: DataTableProps<TData>):
|
|
1536
|
+
}: DataTableProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
1521
1537
|
//#endregion
|
|
1522
1538
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
1523
|
-
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<
|
|
1539
|
+
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<'div'> {
|
|
1524
1540
|
table: Table<TData>;
|
|
1525
1541
|
}
|
|
1526
1542
|
declare function DataTableAdvancedToolbar<TData>({
|
|
@@ -1528,7 +1544,7 @@ declare function DataTableAdvancedToolbar<TData>({
|
|
|
1528
1544
|
children,
|
|
1529
1545
|
className,
|
|
1530
1546
|
...props
|
|
1531
|
-
}: DataTableAdvancedToolbarProps<TData>):
|
|
1547
|
+
}: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
1532
1548
|
//#endregion
|
|
1533
1549
|
//#region src/components/data-table/data-table-column-header.d.ts
|
|
1534
1550
|
interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
|
|
@@ -1540,7 +1556,7 @@ declare function DataTableColumnHeader<TData, TValue>({
|
|
|
1540
1556
|
label,
|
|
1541
1557
|
className,
|
|
1542
1558
|
...props
|
|
1543
|
-
}: DataTableColumnHeaderProps<TData, TValue>):
|
|
1559
|
+
}: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime2.JSX.Element;
|
|
1544
1560
|
//#endregion
|
|
1545
1561
|
//#region src/components/data-table/data-table-faceted-filter.d.ts
|
|
1546
1562
|
interface DataTableFacetedFilterProps<TData, TValue> {
|
|
@@ -1554,10 +1570,10 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
1554
1570
|
title,
|
|
1555
1571
|
options,
|
|
1556
1572
|
multiple
|
|
1557
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
1573
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime2.JSX.Element;
|
|
1558
1574
|
//#endregion
|
|
1559
1575
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
1560
|
-
interface DataTablePaginationProps<TData> extends React.ComponentProps<
|
|
1576
|
+
interface DataTablePaginationProps<TData> extends React.ComponentProps<'div'> {
|
|
1561
1577
|
table: Table<TData>;
|
|
1562
1578
|
pageSizeOptions?: number[];
|
|
1563
1579
|
}
|
|
@@ -1566,10 +1582,10 @@ declare function DataTablePagination<TData>({
|
|
|
1566
1582
|
pageSizeOptions,
|
|
1567
1583
|
className,
|
|
1568
1584
|
...props
|
|
1569
|
-
}: DataTablePaginationProps<TData>):
|
|
1585
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
1570
1586
|
//#endregion
|
|
1571
1587
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
1572
|
-
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<
|
|
1588
|
+
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<'div'> {
|
|
1573
1589
|
table: Table<TData>;
|
|
1574
1590
|
}
|
|
1575
1591
|
declare function DataTableToolbar<TData>({
|
|
@@ -1577,7 +1593,7 @@ declare function DataTableToolbar<TData>({
|
|
|
1577
1593
|
children,
|
|
1578
1594
|
className,
|
|
1579
1595
|
...props
|
|
1580
|
-
}: DataTableToolbarProps<TData>):
|
|
1596
|
+
}: DataTableToolbarProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
1581
1597
|
//#endregion
|
|
1582
1598
|
//#region src/components/data-table/data-table-view-options.d.ts
|
|
1583
1599
|
interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
|
|
@@ -1588,7 +1604,7 @@ declare function DataTableViewOptions<TData>({
|
|
|
1588
1604
|
table,
|
|
1589
1605
|
disabled,
|
|
1590
1606
|
...props
|
|
1591
|
-
}: DataTableViewOptionsProps<TData>):
|
|
1607
|
+
}: DataTableViewOptionsProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
1592
1608
|
//#endregion
|
|
1593
1609
|
//#region src/lib/crud-actions.d.ts
|
|
1594
1610
|
type CrudActionZone = 'toolbar' | 'row' | 'batch';
|
|
@@ -1630,12 +1646,12 @@ declare const crudActions: {
|
|
|
1630
1646
|
};
|
|
1631
1647
|
//#endregion
|
|
1632
1648
|
//#region src/hooks/use-data-table.d.ts
|
|
1633
|
-
interface UseDataTableProps<TData> extends Omit<TableOptions<TData>,
|
|
1634
|
-
initialState?: Omit<Partial<TableState>,
|
|
1649
|
+
interface UseDataTableProps<TData> extends Omit<TableOptions<TData>, 'state' | 'pageCount' | 'getCoreRowModel' | 'manualFiltering' | 'manualPagination' | 'manualSorting'>, Required<Pick<TableOptions<TData>, 'pageCount'>> {
|
|
1650
|
+
initialState?: Omit<Partial<TableState>, 'sorting'> & {
|
|
1635
1651
|
sorting?: ExtendedColumnSort<TData>[];
|
|
1636
1652
|
};
|
|
1637
1653
|
queryKeys?: Partial<QueryKeys>;
|
|
1638
|
-
history?:
|
|
1654
|
+
history?: 'push' | 'replace';
|
|
1639
1655
|
debounceMs?: number;
|
|
1640
1656
|
throttleMs?: number;
|
|
1641
1657
|
clearOnDefault?: boolean;
|
|
@@ -1683,12 +1699,12 @@ type UnifiedSchema = z.ZodObject<any> | JSONSchema | SimpleFieldsConfig;
|
|
|
1683
1699
|
* JSON Schema 类型
|
|
1684
1700
|
*/
|
|
1685
1701
|
interface JSONSchema {
|
|
1686
|
-
type:
|
|
1702
|
+
type: 'object';
|
|
1687
1703
|
properties: Record<string, JSONSchemaProperty>;
|
|
1688
1704
|
required?: string[];
|
|
1689
1705
|
}
|
|
1690
1706
|
interface JSONSchemaProperty {
|
|
1691
|
-
type:
|
|
1707
|
+
type: 'string' | 'number' | 'boolean' | 'array' | 'object';
|
|
1692
1708
|
title?: string;
|
|
1693
1709
|
description?: string;
|
|
1694
1710
|
enum?: any[];
|
|
@@ -1707,7 +1723,7 @@ interface SimpleFieldsConfig {
|
|
|
1707
1723
|
[key: string]: SimpleFieldConfig;
|
|
1708
1724
|
}
|
|
1709
1725
|
interface SimpleFieldConfig {
|
|
1710
|
-
type:
|
|
1726
|
+
type: 'string' | 'number' | 'boolean' | 'select' | 'multiselect' | 'date' | 'datetime' | 'textarea' | 'email' | 'url';
|
|
1711
1727
|
label?: string;
|
|
1712
1728
|
description?: string;
|
|
1713
1729
|
required?: boolean;
|
|
@@ -1748,7 +1764,7 @@ declare class SchemaAdapter {
|
|
|
1748
1764
|
/**
|
|
1749
1765
|
* 检测 Schema 类型
|
|
1750
1766
|
*/
|
|
1751
|
-
static detectType(schema: UnifiedSchema):
|
|
1767
|
+
static detectType(schema: UnifiedSchema): 'zod' | 'json' | 'simple';
|
|
1752
1768
|
/**
|
|
1753
1769
|
* 转换为统一格式
|
|
1754
1770
|
*/
|
|
@@ -1903,7 +1919,7 @@ declare function humanize(str: string): string;
|
|
|
1903
1919
|
interface ParsedImportData {
|
|
1904
1920
|
headers: string[];
|
|
1905
1921
|
rows: Record<string, unknown>[];
|
|
1906
|
-
format:
|
|
1922
|
+
format: 'csv' | 'json';
|
|
1907
1923
|
}
|
|
1908
1924
|
/**
|
|
1909
1925
|
* 解析 CSV 字符串为对象数组
|
|
@@ -1947,7 +1963,7 @@ declare function coerceRowValues<T extends z.ZodObject<z.ZodRawShape>>(rows: Rec
|
|
|
1947
1963
|
//#region src/lib/export.d.ts
|
|
1948
1964
|
declare function exportTableToCSV<TData>(table: Table<TData>, opts?: {
|
|
1949
1965
|
filename?: string;
|
|
1950
|
-
excludeColumns?: (keyof TData |
|
|
1966
|
+
excludeColumns?: (keyof TData | 'select' | 'actions')[];
|
|
1951
1967
|
onlySelected?: boolean;
|
|
1952
1968
|
}): void;
|
|
1953
1969
|
/**
|
|
@@ -1963,4 +1979,4 @@ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], op
|
|
|
1963
1979
|
*/
|
|
1964
1980
|
declare function downloadCSVTemplate(headers: string[], filename?: string): void;
|
|
1965
1981
|
//#endregion
|
|
1966
|
-
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 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 };
|
|
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 };
|
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";
|
|
@@ -28,6 +28,20 @@ interface ToastAdapter {
|
|
|
28
28
|
}
|
|
29
29
|
/** 空 toast 适配器(禁用通知) */
|
|
30
30
|
declare const noopToastAdapter: ToastAdapter;
|
|
31
|
+
interface AutoCrudQueryCapabilities {
|
|
32
|
+
search?: {
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
fields: string[];
|
|
35
|
+
};
|
|
36
|
+
filters?: {
|
|
37
|
+
enabled: boolean;
|
|
38
|
+
fields: string[] | null;
|
|
39
|
+
};
|
|
40
|
+
sort?: {
|
|
41
|
+
enabled: boolean;
|
|
42
|
+
fields: string[] | null;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
31
45
|
/**
|
|
32
46
|
* Modal 状态类型
|
|
33
47
|
*/
|
|
@@ -145,6 +159,8 @@ interface UseAutoCrudResourceReturn<TSchema extends z.ZodObject<z.ZodRawShape>,
|
|
|
145
159
|
schema?: z.ZodObject<z.ZodRawShape>;
|
|
146
160
|
/** Optional field config override from host metadata. */
|
|
147
161
|
fields?: Fields;
|
|
162
|
+
/** Query capabilities reported by auto-crud-server metadata. */
|
|
163
|
+
capabilities?: AutoCrudQueryCapabilities;
|
|
148
164
|
/** Default sorting used by this resource's list query. */
|
|
149
165
|
defaultSort?: AutoCrudSorting;
|
|
150
166
|
modal: ModalState<TListItem>;
|
|
@@ -395,7 +411,7 @@ declare function AutoTableActionBar<TData>({
|
|
|
395
411
|
extraActions,
|
|
396
412
|
actions,
|
|
397
413
|
deleteConfirmation
|
|
398
|
-
}: AutoTableActionBarProps<TData>):
|
|
414
|
+
}: AutoTableActionBarProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
399
415
|
//#endregion
|
|
400
416
|
//#region src/lib/schema-bridge/types.d.ts
|
|
401
417
|
/**
|
|
@@ -571,7 +587,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
571
587
|
onSelectedCountChange,
|
|
572
588
|
onSelectedRowsChange,
|
|
573
589
|
getSelectedRows
|
|
574
|
-
}: AutoTableProps<T>):
|
|
590
|
+
}: AutoTableProps<T>): react_jsx_runtime2.JSX.Element;
|
|
575
591
|
//#endregion
|
|
576
592
|
//#region src/i18n/locale.d.ts
|
|
577
593
|
/**
|
|
@@ -1063,7 +1079,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1063
1079
|
toolbarActions,
|
|
1064
1080
|
locale: localeProp,
|
|
1065
1081
|
onCreate
|
|
1066
|
-
}: AutoCrudTableProps<TSchema>):
|
|
1082
|
+
}: AutoCrudTableProps<TSchema>): react_jsx_runtime2.JSX.Element;
|
|
1067
1083
|
//#endregion
|
|
1068
1084
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
1069
1085
|
interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
@@ -1102,7 +1118,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1102
1118
|
labelAlign,
|
|
1103
1119
|
labelWidth,
|
|
1104
1120
|
showSubmitButton
|
|
1105
|
-
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>):
|
|
1121
|
+
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime2.JSX.Element;
|
|
1106
1122
|
declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
|
|
1107
1123
|
ref?: React.Ref<AutoFormRef>;
|
|
1108
1124
|
}) => ReturnType<typeof AutoFormInner>;
|
|
@@ -1118,7 +1134,7 @@ declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormPr
|
|
|
1118
1134
|
*/
|
|
1119
1135
|
interface UrlStateOptions {
|
|
1120
1136
|
/** 历史记录模式: push 添加新记录, replace 替换当前记录 */
|
|
1121
|
-
history?:
|
|
1137
|
+
history?: 'push' | 'replace';
|
|
1122
1138
|
/** 是否浅层更新(不触发页面刷新) */
|
|
1123
1139
|
shallow?: boolean;
|
|
1124
1140
|
/** 节流时间(毫秒) */
|
|
@@ -1157,7 +1173,7 @@ declare function parseAsArrayOf<T>(itemParser: Parser<T>, separator?: string): P
|
|
|
1157
1173
|
};
|
|
1158
1174
|
};
|
|
1159
1175
|
declare function getUrlParams(): URLSearchParams;
|
|
1160
|
-
declare function setSearchParams(params: URLSearchParams, options?: Pick<UrlStateOptions,
|
|
1176
|
+
declare function setSearchParams(params: URLSearchParams, options?: Pick<UrlStateOptions, 'history' | 'scroll'>): void;
|
|
1161
1177
|
/**
|
|
1162
1178
|
* 单个 URL 状态参数
|
|
1163
1179
|
*/
|
|
@@ -1418,10 +1434,10 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
1418
1434
|
filters: externalFilters,
|
|
1419
1435
|
onFiltersChange,
|
|
1420
1436
|
leading
|
|
1421
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
1437
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime2.JSX.Element | null;
|
|
1422
1438
|
//#endregion
|
|
1423
1439
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
1424
|
-
type ModalVariant =
|
|
1440
|
+
type ModalVariant = 'dialog' | 'sheet';
|
|
1425
1441
|
//#endregion
|
|
1426
1442
|
//#region src/components/auto-crud/crud-form-modal.d.ts
|
|
1427
1443
|
interface CrudFormModalProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
@@ -1462,7 +1478,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1462
1478
|
labelAlign,
|
|
1463
1479
|
labelWidth,
|
|
1464
1480
|
className
|
|
1465
|
-
}: CrudFormModalProps<T>):
|
|
1481
|
+
}: CrudFormModalProps<T>): react_jsx_runtime2.JSX.Element;
|
|
1466
1482
|
//#endregion
|
|
1467
1483
|
//#region src/components/auto-crud/import-dialog.d.ts
|
|
1468
1484
|
interface ImportDialogProps {
|
|
@@ -1484,10 +1500,10 @@ declare function ImportDialog({
|
|
|
1484
1500
|
columns,
|
|
1485
1501
|
title,
|
|
1486
1502
|
locale
|
|
1487
|
-
}: ImportDialogProps):
|
|
1503
|
+
}: ImportDialogProps): react_jsx_runtime2.JSX.Element;
|
|
1488
1504
|
//#endregion
|
|
1489
1505
|
//#region src/components/auto-crud/export-dialog.d.ts
|
|
1490
|
-
type ExportMode =
|
|
1506
|
+
type ExportMode = 'selected' | 'filtered';
|
|
1491
1507
|
interface ExportDialogProps {
|
|
1492
1508
|
open: boolean;
|
|
1493
1509
|
onOpenChange: (open: boolean) => void;
|
|
@@ -1504,10 +1520,10 @@ declare function ExportDialog({
|
|
|
1504
1520
|
selectedCount,
|
|
1505
1521
|
onExport,
|
|
1506
1522
|
canExportFiltered
|
|
1507
|
-
}: ExportDialogProps):
|
|
1523
|
+
}: ExportDialogProps): react_jsx_runtime2.JSX.Element;
|
|
1508
1524
|
//#endregion
|
|
1509
1525
|
//#region src/components/data-table/data-table.d.ts
|
|
1510
|
-
interface DataTableProps<TData> extends React$1.ComponentProps<
|
|
1526
|
+
interface DataTableProps<TData> extends React$1.ComponentProps<'div'> {
|
|
1511
1527
|
table: Table<TData>;
|
|
1512
1528
|
actionBar?: React$1.ReactNode;
|
|
1513
1529
|
}
|
|
@@ -1517,10 +1533,10 @@ declare function DataTable<TData>({
|
|
|
1517
1533
|
children,
|
|
1518
1534
|
className,
|
|
1519
1535
|
...props
|
|
1520
|
-
}: DataTableProps<TData>):
|
|
1536
|
+
}: DataTableProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
1521
1537
|
//#endregion
|
|
1522
1538
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
1523
|
-
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<
|
|
1539
|
+
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<'div'> {
|
|
1524
1540
|
table: Table<TData>;
|
|
1525
1541
|
}
|
|
1526
1542
|
declare function DataTableAdvancedToolbar<TData>({
|
|
@@ -1528,7 +1544,7 @@ declare function DataTableAdvancedToolbar<TData>({
|
|
|
1528
1544
|
children,
|
|
1529
1545
|
className,
|
|
1530
1546
|
...props
|
|
1531
|
-
}: DataTableAdvancedToolbarProps<TData>):
|
|
1547
|
+
}: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
1532
1548
|
//#endregion
|
|
1533
1549
|
//#region src/components/data-table/data-table-column-header.d.ts
|
|
1534
1550
|
interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
|
|
@@ -1540,7 +1556,7 @@ declare function DataTableColumnHeader<TData, TValue>({
|
|
|
1540
1556
|
label,
|
|
1541
1557
|
className,
|
|
1542
1558
|
...props
|
|
1543
|
-
}: DataTableColumnHeaderProps<TData, TValue>):
|
|
1559
|
+
}: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime2.JSX.Element;
|
|
1544
1560
|
//#endregion
|
|
1545
1561
|
//#region src/components/data-table/data-table-faceted-filter.d.ts
|
|
1546
1562
|
interface DataTableFacetedFilterProps<TData, TValue> {
|
|
@@ -1554,10 +1570,10 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
1554
1570
|
title,
|
|
1555
1571
|
options,
|
|
1556
1572
|
multiple
|
|
1557
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
1573
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime2.JSX.Element;
|
|
1558
1574
|
//#endregion
|
|
1559
1575
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
1560
|
-
interface DataTablePaginationProps<TData> extends React.ComponentProps<
|
|
1576
|
+
interface DataTablePaginationProps<TData> extends React.ComponentProps<'div'> {
|
|
1561
1577
|
table: Table<TData>;
|
|
1562
1578
|
pageSizeOptions?: number[];
|
|
1563
1579
|
}
|
|
@@ -1566,10 +1582,10 @@ declare function DataTablePagination<TData>({
|
|
|
1566
1582
|
pageSizeOptions,
|
|
1567
1583
|
className,
|
|
1568
1584
|
...props
|
|
1569
|
-
}: DataTablePaginationProps<TData>):
|
|
1585
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
1570
1586
|
//#endregion
|
|
1571
1587
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
1572
|
-
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<
|
|
1588
|
+
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<'div'> {
|
|
1573
1589
|
table: Table<TData>;
|
|
1574
1590
|
}
|
|
1575
1591
|
declare function DataTableToolbar<TData>({
|
|
@@ -1577,7 +1593,7 @@ declare function DataTableToolbar<TData>({
|
|
|
1577
1593
|
children,
|
|
1578
1594
|
className,
|
|
1579
1595
|
...props
|
|
1580
|
-
}: DataTableToolbarProps<TData>):
|
|
1596
|
+
}: DataTableToolbarProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
1581
1597
|
//#endregion
|
|
1582
1598
|
//#region src/components/data-table/data-table-view-options.d.ts
|
|
1583
1599
|
interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
|
|
@@ -1588,7 +1604,7 @@ declare function DataTableViewOptions<TData>({
|
|
|
1588
1604
|
table,
|
|
1589
1605
|
disabled,
|
|
1590
1606
|
...props
|
|
1591
|
-
}: DataTableViewOptionsProps<TData>):
|
|
1607
|
+
}: DataTableViewOptionsProps<TData>): react_jsx_runtime2.JSX.Element;
|
|
1592
1608
|
//#endregion
|
|
1593
1609
|
//#region src/lib/crud-actions.d.ts
|
|
1594
1610
|
type CrudActionZone = 'toolbar' | 'row' | 'batch';
|
|
@@ -1630,12 +1646,12 @@ declare const crudActions: {
|
|
|
1630
1646
|
};
|
|
1631
1647
|
//#endregion
|
|
1632
1648
|
//#region src/hooks/use-data-table.d.ts
|
|
1633
|
-
interface UseDataTableProps<TData> extends Omit<TableOptions<TData>,
|
|
1634
|
-
initialState?: Omit<Partial<TableState>,
|
|
1649
|
+
interface UseDataTableProps<TData> extends Omit<TableOptions<TData>, 'state' | 'pageCount' | 'getCoreRowModel' | 'manualFiltering' | 'manualPagination' | 'manualSorting'>, Required<Pick<TableOptions<TData>, 'pageCount'>> {
|
|
1650
|
+
initialState?: Omit<Partial<TableState>, 'sorting'> & {
|
|
1635
1651
|
sorting?: ExtendedColumnSort<TData>[];
|
|
1636
1652
|
};
|
|
1637
1653
|
queryKeys?: Partial<QueryKeys>;
|
|
1638
|
-
history?:
|
|
1654
|
+
history?: 'push' | 'replace';
|
|
1639
1655
|
debounceMs?: number;
|
|
1640
1656
|
throttleMs?: number;
|
|
1641
1657
|
clearOnDefault?: boolean;
|
|
@@ -1683,12 +1699,12 @@ type UnifiedSchema = z.ZodObject<any> | JSONSchema | SimpleFieldsConfig;
|
|
|
1683
1699
|
* JSON Schema 类型
|
|
1684
1700
|
*/
|
|
1685
1701
|
interface JSONSchema {
|
|
1686
|
-
type:
|
|
1702
|
+
type: 'object';
|
|
1687
1703
|
properties: Record<string, JSONSchemaProperty>;
|
|
1688
1704
|
required?: string[];
|
|
1689
1705
|
}
|
|
1690
1706
|
interface JSONSchemaProperty {
|
|
1691
|
-
type:
|
|
1707
|
+
type: 'string' | 'number' | 'boolean' | 'array' | 'object';
|
|
1692
1708
|
title?: string;
|
|
1693
1709
|
description?: string;
|
|
1694
1710
|
enum?: any[];
|
|
@@ -1707,7 +1723,7 @@ interface SimpleFieldsConfig {
|
|
|
1707
1723
|
[key: string]: SimpleFieldConfig;
|
|
1708
1724
|
}
|
|
1709
1725
|
interface SimpleFieldConfig {
|
|
1710
|
-
type:
|
|
1726
|
+
type: 'string' | 'number' | 'boolean' | 'select' | 'multiselect' | 'date' | 'datetime' | 'textarea' | 'email' | 'url';
|
|
1711
1727
|
label?: string;
|
|
1712
1728
|
description?: string;
|
|
1713
1729
|
required?: boolean;
|
|
@@ -1748,7 +1764,7 @@ declare class SchemaAdapter {
|
|
|
1748
1764
|
/**
|
|
1749
1765
|
* 检测 Schema 类型
|
|
1750
1766
|
*/
|
|
1751
|
-
static detectType(schema: UnifiedSchema):
|
|
1767
|
+
static detectType(schema: UnifiedSchema): 'zod' | 'json' | 'simple';
|
|
1752
1768
|
/**
|
|
1753
1769
|
* 转换为统一格式
|
|
1754
1770
|
*/
|
|
@@ -1903,7 +1919,7 @@ declare function humanize(str: string): string;
|
|
|
1903
1919
|
interface ParsedImportData {
|
|
1904
1920
|
headers: string[];
|
|
1905
1921
|
rows: Record<string, unknown>[];
|
|
1906
|
-
format:
|
|
1922
|
+
format: 'csv' | 'json';
|
|
1907
1923
|
}
|
|
1908
1924
|
/**
|
|
1909
1925
|
* 解析 CSV 字符串为对象数组
|
|
@@ -1947,7 +1963,7 @@ declare function coerceRowValues<T extends z.ZodObject<z.ZodRawShape>>(rows: Rec
|
|
|
1947
1963
|
//#region src/lib/export.d.ts
|
|
1948
1964
|
declare function exportTableToCSV<TData>(table: Table<TData>, opts?: {
|
|
1949
1965
|
filename?: string;
|
|
1950
|
-
excludeColumns?: (keyof TData |
|
|
1966
|
+
excludeColumns?: (keyof TData | 'select' | 'actions')[];
|
|
1951
1967
|
onlySelected?: boolean;
|
|
1952
1968
|
}): void;
|
|
1953
1969
|
/**
|
|
@@ -1963,4 +1979,4 @@ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], op
|
|
|
1963
1979
|
*/
|
|
1964
1980
|
declare function downloadCSVTemplate(headers: string[], filename?: string): void;
|
|
1965
1981
|
//#endregion
|
|
1966
|
-
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 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -71,8 +71,7 @@ function DataTablePagination({ table, pageSizeOptions = [
|
|
|
71
71
|
children: [
|
|
72
72
|
"Page ",
|
|
73
73
|
table.getState().pagination.pageIndex + 1,
|
|
74
|
-
" of",
|
|
75
|
-
" ",
|
|
74
|
+
" of ",
|
|
76
75
|
table.getPageCount()
|
|
77
76
|
]
|
|
78
77
|
}),
|
|
@@ -6389,6 +6388,35 @@ function buildTableOverrides(fields, legacyOverrides, dynamicFilterState, dynami
|
|
|
6389
6388
|
}
|
|
6390
6389
|
return result;
|
|
6391
6390
|
}
|
|
6391
|
+
function buildCapabilityTableOverrides(schema, capabilities) {
|
|
6392
|
+
if (!capabilities) return {};
|
|
6393
|
+
const result = {};
|
|
6394
|
+
const filterFields = capabilities.filters?.fields;
|
|
6395
|
+
const sortFields = capabilities.sort?.fields;
|
|
6396
|
+
const filterSet = Array.isArray(filterFields) ? new Set(filterFields) : null;
|
|
6397
|
+
const sortSet = Array.isArray(sortFields) ? new Set(sortFields) : null;
|
|
6398
|
+
for (const key of Object.keys(schema.shape)) {
|
|
6399
|
+
const override = {};
|
|
6400
|
+
if (capabilities.filters) {
|
|
6401
|
+
if (!capabilities.filters.enabled) override.enableColumnFilter = false;
|
|
6402
|
+
else if (filterSet) override.enableColumnFilter = filterSet.has(key);
|
|
6403
|
+
}
|
|
6404
|
+
if (capabilities.sort) {
|
|
6405
|
+
if (!capabilities.sort.enabled) override.enableSorting = false;
|
|
6406
|
+
else if (sortSet) override.enableSorting = sortSet.has(key);
|
|
6407
|
+
}
|
|
6408
|
+
if (Object.keys(override).length > 0) result[key] = override;
|
|
6409
|
+
}
|
|
6410
|
+
return result;
|
|
6411
|
+
}
|
|
6412
|
+
function mergeTableOverrides(base, enforced) {
|
|
6413
|
+
const result = { ...base ?? {} };
|
|
6414
|
+
for (const [key, override] of Object.entries(enforced)) result[key] = {
|
|
6415
|
+
...result[key] ?? {},
|
|
6416
|
+
...override
|
|
6417
|
+
};
|
|
6418
|
+
return result;
|
|
6419
|
+
}
|
|
6392
6420
|
/**
|
|
6393
6421
|
* 从统一配置生成隐藏列列表
|
|
6394
6422
|
*/
|
|
@@ -6800,11 +6828,13 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6800
6828
|
toolbarOpenCreate
|
|
6801
6829
|
]);
|
|
6802
6830
|
const resolvedToolbarActions = resolveToolbarActionsWithResolver(id, registryToolbarActions, toolbarContext);
|
|
6803
|
-
const tableOverrides = React.useMemo(() => buildTableOverrides(resolvedFields, tableConfig?.overrides, dynamicFilterOptions, dynamicResolveOptions), [
|
|
6831
|
+
const tableOverrides = React.useMemo(() => mergeTableOverrides(buildTableOverrides(resolvedFields, tableConfig?.overrides, dynamicFilterOptions, dynamicResolveOptions), buildCapabilityTableOverrides(resolvedSchema, resource.capabilities)), [
|
|
6804
6832
|
resolvedFields,
|
|
6805
6833
|
tableConfig?.overrides,
|
|
6806
6834
|
dynamicFilterOptions,
|
|
6807
|
-
dynamicResolveOptions
|
|
6835
|
+
dynamicResolveOptions,
|
|
6836
|
+
resolvedSchema,
|
|
6837
|
+
resource.capabilities
|
|
6808
6838
|
]);
|
|
6809
6839
|
const defaultSort = React.useMemo(() => resource.defaultSort ?? tableConfig?.defaultSort ?? getDefaultSortingForSchema(resolvedSchema), [
|
|
6810
6840
|
resource.defaultSort,
|
|
@@ -6818,10 +6848,21 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6818
6848
|
]);
|
|
6819
6849
|
const searchConfig = React.useMemo(() => {
|
|
6820
6850
|
const tableSearch = tableConfig?.search;
|
|
6851
|
+
const searchCapability = resource.capabilities?.search;
|
|
6821
6852
|
if (tableSearch === false) return false;
|
|
6853
|
+
if (searchCapability) {
|
|
6854
|
+
if (!searchCapability.enabled) return false;
|
|
6855
|
+
if (tableSearch && typeof tableSearch === "object") return tableSearch;
|
|
6856
|
+
return true;
|
|
6857
|
+
}
|
|
6822
6858
|
if (tableSearch && typeof tableSearch === "object") return tableSearch;
|
|
6859
|
+
if (tableSearch === true) return true;
|
|
6823
6860
|
return Object.values(resolvedFields).some((field) => field?.search === true) ? true : false;
|
|
6824
|
-
}, [
|
|
6861
|
+
}, [
|
|
6862
|
+
resolvedFields,
|
|
6863
|
+
resource.capabilities?.search,
|
|
6864
|
+
tableConfig?.search
|
|
6865
|
+
]);
|
|
6825
6866
|
const batchFields = React.useMemo(() => buildBatchUpdateFields(resolvedSchema, tableConfig?.batchFields, resolvedFields), [
|
|
6826
6867
|
resolvedSchema,
|
|
6827
6868
|
tableConfig?.batchFields,
|
|
@@ -7469,8 +7510,7 @@ function DataTableSliderFilter({ column, title }) {
|
|
|
7469
7510
|
className: "mx-0.5 data-[orientation=vertical]:h-4"
|
|
7470
7511
|
}),
|
|
7471
7512
|
formatValue(columnFilterValue[0]),
|
|
7472
|
-
" -",
|
|
7473
|
-
" ",
|
|
7513
|
+
" - ",
|
|
7474
7514
|
formatValue(columnFilterValue[1]),
|
|
7475
7515
|
unit ? ` ${unit}` : ""
|
|
7476
7516
|
] }) : null
|
|
@@ -7774,6 +7814,7 @@ function useAutoCrudResource({ router, schema, query: queryTransform, options =
|
|
|
7774
7814
|
const resolvedSchema = useMemo(() => mergeMetadataSchema(schema, metadata?.schema), [schema, metadata?.schema]);
|
|
7775
7815
|
const defaultSorting = useMemo(() => defaultSortOption === false ? [] : defaultSortOption ?? getDefaultSortingForSchema(resolvedSchema), [defaultSortOption, resolvedSchema]);
|
|
7776
7816
|
const metadataFields = useMemo(() => readMetadataFields(metadata?.fields), [metadata?.fields]);
|
|
7817
|
+
const capabilities = metadata?.capabilities;
|
|
7777
7818
|
const columns = useMemo(() => createTableSchema(resolvedSchema), [resolvedSchema]);
|
|
7778
7819
|
const [urlParams] = useQueryStates({
|
|
7779
7820
|
page: parseAsInteger.withDefault(1),
|
|
@@ -8066,6 +8107,7 @@ function useAutoCrudResource({ router, schema, query: queryTransform, options =
|
|
|
8066
8107
|
},
|
|
8067
8108
|
schema: resolvedSchema,
|
|
8068
8109
|
fields: metadataFields,
|
|
8110
|
+
capabilities,
|
|
8069
8111
|
defaultSort: defaultSorting,
|
|
8070
8112
|
modal,
|
|
8071
8113
|
mutations: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordrhyme/auto-crud",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.1",
|
|
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.
|
|
65
|
+
"@wordrhyme/formily-shadcn": "1.13.0",
|
|
66
66
|
"@wordrhyme/shadcn": "1.3.2",
|
|
67
|
-
"@wordrhyme/shadcn-ui": "1.32.
|
|
67
|
+
"@wordrhyme/shadcn-ui": "1.32.5"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@storybook/react": "^8.6.18",
|
|
@@ -84,8 +84,8 @@
|
|
|
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",
|
|
88
87
|
"@internal/eslint-config": "0.3.0",
|
|
88
|
+
"@internal/prettier-config": "0.0.1",
|
|
89
89
|
"@internal/tsconfig": "0.1.0",
|
|
90
90
|
"@internal/tsdown-config": "0.1.0",
|
|
91
91
|
"@internal/vitest-config": "0.1.0"
|