@wordrhyme/auto-crud 1.3.9 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +47 -3
- package/dist/index.d.cts +33 -17
- package/dist/index.d.ts +33 -17
- package/dist/index.js +47 -3
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -6426,6 +6426,35 @@ function buildTableOverrides(fields, legacyOverrides, dynamicFilterState, dynami
|
|
|
6426
6426
|
}
|
|
6427
6427
|
return result;
|
|
6428
6428
|
}
|
|
6429
|
+
function buildCapabilityTableOverrides(schema, capabilities) {
|
|
6430
|
+
if (!capabilities) return {};
|
|
6431
|
+
const result = {};
|
|
6432
|
+
const filterFields = capabilities.filters?.fields;
|
|
6433
|
+
const sortFields = capabilities.sort?.fields;
|
|
6434
|
+
const filterSet = Array.isArray(filterFields) ? new Set(filterFields) : null;
|
|
6435
|
+
const sortSet = Array.isArray(sortFields) ? new Set(sortFields) : null;
|
|
6436
|
+
for (const key of Object.keys(schema.shape)) {
|
|
6437
|
+
const override = {};
|
|
6438
|
+
if (capabilities.filters) {
|
|
6439
|
+
if (!capabilities.filters.enabled) override.enableColumnFilter = false;
|
|
6440
|
+
else if (filterSet) override.enableColumnFilter = filterSet.has(key);
|
|
6441
|
+
}
|
|
6442
|
+
if (capabilities.sort) {
|
|
6443
|
+
if (!capabilities.sort.enabled) override.enableSorting = false;
|
|
6444
|
+
else if (sortSet) override.enableSorting = sortSet.has(key);
|
|
6445
|
+
}
|
|
6446
|
+
if (Object.keys(override).length > 0) result[key] = override;
|
|
6447
|
+
}
|
|
6448
|
+
return result;
|
|
6449
|
+
}
|
|
6450
|
+
function mergeTableOverrides(base, enforced) {
|
|
6451
|
+
const result = { ...base ?? {} };
|
|
6452
|
+
for (const [key, override] of Object.entries(enforced)) result[key] = {
|
|
6453
|
+
...result[key] ?? {},
|
|
6454
|
+
...override
|
|
6455
|
+
};
|
|
6456
|
+
return result;
|
|
6457
|
+
}
|
|
6429
6458
|
/**
|
|
6430
6459
|
* 从统一配置生成隐藏列列表
|
|
6431
6460
|
*/
|
|
@@ -6837,11 +6866,13 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6837
6866
|
toolbarOpenCreate
|
|
6838
6867
|
]);
|
|
6839
6868
|
const resolvedToolbarActions = resolveToolbarActionsWithResolver(id, registryToolbarActions, toolbarContext);
|
|
6840
|
-
const tableOverrides = react.useMemo(() => buildTableOverrides(resolvedFields, tableConfig?.overrides, dynamicFilterOptions, dynamicResolveOptions), [
|
|
6869
|
+
const tableOverrides = react.useMemo(() => mergeTableOverrides(buildTableOverrides(resolvedFields, tableConfig?.overrides, dynamicFilterOptions, dynamicResolveOptions), buildCapabilityTableOverrides(resolvedSchema, resource.capabilities)), [
|
|
6841
6870
|
resolvedFields,
|
|
6842
6871
|
tableConfig?.overrides,
|
|
6843
6872
|
dynamicFilterOptions,
|
|
6844
|
-
dynamicResolveOptions
|
|
6873
|
+
dynamicResolveOptions,
|
|
6874
|
+
resolvedSchema,
|
|
6875
|
+
resource.capabilities
|
|
6845
6876
|
]);
|
|
6846
6877
|
const defaultSort = react.useMemo(() => resource.defaultSort ?? tableConfig?.defaultSort ?? getDefaultSortingForSchema(resolvedSchema), [
|
|
6847
6878
|
resource.defaultSort,
|
|
@@ -6855,10 +6886,21 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6855
6886
|
]);
|
|
6856
6887
|
const searchConfig = react.useMemo(() => {
|
|
6857
6888
|
const tableSearch = tableConfig?.search;
|
|
6889
|
+
const searchCapability = resource.capabilities?.search;
|
|
6858
6890
|
if (tableSearch === false) return false;
|
|
6891
|
+
if (searchCapability) {
|
|
6892
|
+
if (!searchCapability.enabled) return false;
|
|
6893
|
+
if (tableSearch && typeof tableSearch === "object") return tableSearch;
|
|
6894
|
+
return true;
|
|
6895
|
+
}
|
|
6859
6896
|
if (tableSearch && typeof tableSearch === "object") return tableSearch;
|
|
6897
|
+
if (tableSearch === true) return true;
|
|
6860
6898
|
return Object.values(resolvedFields).some((field) => field?.search === true) ? true : false;
|
|
6861
|
-
}, [
|
|
6899
|
+
}, [
|
|
6900
|
+
resolvedFields,
|
|
6901
|
+
resource.capabilities?.search,
|
|
6902
|
+
tableConfig?.search
|
|
6903
|
+
]);
|
|
6862
6904
|
const batchFields = react.useMemo(() => buildBatchUpdateFields(resolvedSchema, tableConfig?.batchFields, resolvedFields), [
|
|
6863
6905
|
resolvedSchema,
|
|
6864
6906
|
tableConfig?.batchFields,
|
|
@@ -7811,6 +7853,7 @@ function useAutoCrudResource({ router, schema, query: queryTransform, options =
|
|
|
7811
7853
|
const resolvedSchema = (0, react.useMemo)(() => mergeMetadataSchema(schema, metadata?.schema), [schema, metadata?.schema]);
|
|
7812
7854
|
const defaultSorting = (0, react.useMemo)(() => defaultSortOption === false ? [] : defaultSortOption ?? getDefaultSortingForSchema(resolvedSchema), [defaultSortOption, resolvedSchema]);
|
|
7813
7855
|
const metadataFields = (0, react.useMemo)(() => readMetadataFields(metadata?.fields), [metadata?.fields]);
|
|
7856
|
+
const capabilities = metadata?.capabilities;
|
|
7814
7857
|
const columns = (0, react.useMemo)(() => createTableSchema(resolvedSchema), [resolvedSchema]);
|
|
7815
7858
|
const [urlParams] = useQueryStates({
|
|
7816
7859
|
page: parseAsInteger.withDefault(1),
|
|
@@ -8103,6 +8146,7 @@ function useAutoCrudResource({ router, schema, query: queryTransform, options =
|
|
|
8103
8146
|
},
|
|
8104
8147
|
schema: resolvedSchema,
|
|
8105
8148
|
fields: metadataFields,
|
|
8149
|
+
capabilities,
|
|
8106
8150
|
defaultSort: defaultSorting,
|
|
8107
8151
|
modal,
|
|
8108
8152
|
mutations: {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime12 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_runtime12.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_runtime12.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_runtime12.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_runtime12.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>;
|
|
@@ -1418,7 +1434,7 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
1418
1434
|
filters: externalFilters,
|
|
1419
1435
|
onFiltersChange,
|
|
1420
1436
|
leading
|
|
1421
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
1437
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime12.JSX.Element | null;
|
|
1422
1438
|
//#endregion
|
|
1423
1439
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
1424
1440
|
type ModalVariant = "dialog" | "sheet";
|
|
@@ -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_runtime12.JSX.Element;
|
|
1466
1482
|
//#endregion
|
|
1467
1483
|
//#region src/components/auto-crud/import-dialog.d.ts
|
|
1468
1484
|
interface ImportDialogProps {
|
|
@@ -1484,7 +1500,7 @@ declare function ImportDialog({
|
|
|
1484
1500
|
columns,
|
|
1485
1501
|
title,
|
|
1486
1502
|
locale
|
|
1487
|
-
}: ImportDialogProps):
|
|
1503
|
+
}: ImportDialogProps): react_jsx_runtime12.JSX.Element;
|
|
1488
1504
|
//#endregion
|
|
1489
1505
|
//#region src/components/auto-crud/export-dialog.d.ts
|
|
1490
1506
|
type ExportMode = "selected" | "filtered";
|
|
@@ -1504,7 +1520,7 @@ declare function ExportDialog({
|
|
|
1504
1520
|
selectedCount,
|
|
1505
1521
|
onExport,
|
|
1506
1522
|
canExportFiltered
|
|
1507
|
-
}: ExportDialogProps):
|
|
1523
|
+
}: ExportDialogProps): react_jsx_runtime12.JSX.Element;
|
|
1508
1524
|
//#endregion
|
|
1509
1525
|
//#region src/components/data-table/data-table.d.ts
|
|
1510
1526
|
interface DataTableProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1517,7 +1533,7 @@ declare function DataTable<TData>({
|
|
|
1517
1533
|
children,
|
|
1518
1534
|
className,
|
|
1519
1535
|
...props
|
|
1520
|
-
}: DataTableProps<TData>):
|
|
1536
|
+
}: DataTableProps<TData>): react_jsx_runtime12.JSX.Element;
|
|
1521
1537
|
//#endregion
|
|
1522
1538
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
1523
1539
|
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -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_runtime12.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_runtime12.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,7 +1570,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
1554
1570
|
title,
|
|
1555
1571
|
options,
|
|
1556
1572
|
multiple
|
|
1557
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
1573
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime12.JSX.Element;
|
|
1558
1574
|
//#endregion
|
|
1559
1575
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
1560
1576
|
interface DataTablePaginationProps<TData> extends React.ComponentProps<"div"> {
|
|
@@ -1566,7 +1582,7 @@ declare function DataTablePagination<TData>({
|
|
|
1566
1582
|
pageSizeOptions,
|
|
1567
1583
|
className,
|
|
1568
1584
|
...props
|
|
1569
|
-
}: DataTablePaginationProps<TData>):
|
|
1585
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime12.JSX.Element;
|
|
1570
1586
|
//#endregion
|
|
1571
1587
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
1572
1588
|
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -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_runtime12.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_runtime12.JSX.Element;
|
|
1592
1608
|
//#endregion
|
|
1593
1609
|
//#region src/lib/crud-actions.d.ts
|
|
1594
1610
|
type CrudActionZone = 'toolbar' | 'row' | 'batch';
|
|
@@ -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_runtime4 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_runtime4.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_runtime4.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_runtime4.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_runtime4.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>;
|
|
@@ -1418,7 +1434,7 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
1418
1434
|
filters: externalFilters,
|
|
1419
1435
|
onFiltersChange,
|
|
1420
1436
|
leading
|
|
1421
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
1437
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime4.JSX.Element | null;
|
|
1422
1438
|
//#endregion
|
|
1423
1439
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
1424
1440
|
type ModalVariant = "dialog" | "sheet";
|
|
@@ -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_runtime4.JSX.Element;
|
|
1466
1482
|
//#endregion
|
|
1467
1483
|
//#region src/components/auto-crud/import-dialog.d.ts
|
|
1468
1484
|
interface ImportDialogProps {
|
|
@@ -1484,7 +1500,7 @@ declare function ImportDialog({
|
|
|
1484
1500
|
columns,
|
|
1485
1501
|
title,
|
|
1486
1502
|
locale
|
|
1487
|
-
}: ImportDialogProps):
|
|
1503
|
+
}: ImportDialogProps): react_jsx_runtime4.JSX.Element;
|
|
1488
1504
|
//#endregion
|
|
1489
1505
|
//#region src/components/auto-crud/export-dialog.d.ts
|
|
1490
1506
|
type ExportMode = "selected" | "filtered";
|
|
@@ -1504,7 +1520,7 @@ declare function ExportDialog({
|
|
|
1504
1520
|
selectedCount,
|
|
1505
1521
|
onExport,
|
|
1506
1522
|
canExportFiltered
|
|
1507
|
-
}: ExportDialogProps):
|
|
1523
|
+
}: ExportDialogProps): react_jsx_runtime4.JSX.Element;
|
|
1508
1524
|
//#endregion
|
|
1509
1525
|
//#region src/components/data-table/data-table.d.ts
|
|
1510
1526
|
interface DataTableProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1517,7 +1533,7 @@ declare function DataTable<TData>({
|
|
|
1517
1533
|
children,
|
|
1518
1534
|
className,
|
|
1519
1535
|
...props
|
|
1520
|
-
}: DataTableProps<TData>):
|
|
1536
|
+
}: DataTableProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
1521
1537
|
//#endregion
|
|
1522
1538
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
1523
1539
|
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -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_runtime4.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_runtime4.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,7 +1570,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
1554
1570
|
title,
|
|
1555
1571
|
options,
|
|
1556
1572
|
multiple
|
|
1557
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
1573
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime4.JSX.Element;
|
|
1558
1574
|
//#endregion
|
|
1559
1575
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
1560
1576
|
interface DataTablePaginationProps<TData> extends React.ComponentProps<"div"> {
|
|
@@ -1566,7 +1582,7 @@ declare function DataTablePagination<TData>({
|
|
|
1566
1582
|
pageSizeOptions,
|
|
1567
1583
|
className,
|
|
1568
1584
|
...props
|
|
1569
|
-
}: DataTablePaginationProps<TData>):
|
|
1585
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime4.JSX.Element;
|
|
1570
1586
|
//#endregion
|
|
1571
1587
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
1572
1588
|
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -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_runtime4.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_runtime4.JSX.Element;
|
|
1592
1608
|
//#endregion
|
|
1593
1609
|
//#region src/lib/crud-actions.d.ts
|
|
1594
1610
|
type CrudActionZone = 'toolbar' | 'row' | 'batch';
|
|
@@ -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
|
@@ -6389,6 +6389,35 @@ function buildTableOverrides(fields, legacyOverrides, dynamicFilterState, dynami
|
|
|
6389
6389
|
}
|
|
6390
6390
|
return result;
|
|
6391
6391
|
}
|
|
6392
|
+
function buildCapabilityTableOverrides(schema, capabilities) {
|
|
6393
|
+
if (!capabilities) return {};
|
|
6394
|
+
const result = {};
|
|
6395
|
+
const filterFields = capabilities.filters?.fields;
|
|
6396
|
+
const sortFields = capabilities.sort?.fields;
|
|
6397
|
+
const filterSet = Array.isArray(filterFields) ? new Set(filterFields) : null;
|
|
6398
|
+
const sortSet = Array.isArray(sortFields) ? new Set(sortFields) : null;
|
|
6399
|
+
for (const key of Object.keys(schema.shape)) {
|
|
6400
|
+
const override = {};
|
|
6401
|
+
if (capabilities.filters) {
|
|
6402
|
+
if (!capabilities.filters.enabled) override.enableColumnFilter = false;
|
|
6403
|
+
else if (filterSet) override.enableColumnFilter = filterSet.has(key);
|
|
6404
|
+
}
|
|
6405
|
+
if (capabilities.sort) {
|
|
6406
|
+
if (!capabilities.sort.enabled) override.enableSorting = false;
|
|
6407
|
+
else if (sortSet) override.enableSorting = sortSet.has(key);
|
|
6408
|
+
}
|
|
6409
|
+
if (Object.keys(override).length > 0) result[key] = override;
|
|
6410
|
+
}
|
|
6411
|
+
return result;
|
|
6412
|
+
}
|
|
6413
|
+
function mergeTableOverrides(base, enforced) {
|
|
6414
|
+
const result = { ...base ?? {} };
|
|
6415
|
+
for (const [key, override] of Object.entries(enforced)) result[key] = {
|
|
6416
|
+
...result[key] ?? {},
|
|
6417
|
+
...override
|
|
6418
|
+
};
|
|
6419
|
+
return result;
|
|
6420
|
+
}
|
|
6392
6421
|
/**
|
|
6393
6422
|
* 从统一配置生成隐藏列列表
|
|
6394
6423
|
*/
|
|
@@ -6800,11 +6829,13 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6800
6829
|
toolbarOpenCreate
|
|
6801
6830
|
]);
|
|
6802
6831
|
const resolvedToolbarActions = resolveToolbarActionsWithResolver(id, registryToolbarActions, toolbarContext);
|
|
6803
|
-
const tableOverrides = React.useMemo(() => buildTableOverrides(resolvedFields, tableConfig?.overrides, dynamicFilterOptions, dynamicResolveOptions), [
|
|
6832
|
+
const tableOverrides = React.useMemo(() => mergeTableOverrides(buildTableOverrides(resolvedFields, tableConfig?.overrides, dynamicFilterOptions, dynamicResolveOptions), buildCapabilityTableOverrides(resolvedSchema, resource.capabilities)), [
|
|
6804
6833
|
resolvedFields,
|
|
6805
6834
|
tableConfig?.overrides,
|
|
6806
6835
|
dynamicFilterOptions,
|
|
6807
|
-
dynamicResolveOptions
|
|
6836
|
+
dynamicResolveOptions,
|
|
6837
|
+
resolvedSchema,
|
|
6838
|
+
resource.capabilities
|
|
6808
6839
|
]);
|
|
6809
6840
|
const defaultSort = React.useMemo(() => resource.defaultSort ?? tableConfig?.defaultSort ?? getDefaultSortingForSchema(resolvedSchema), [
|
|
6810
6841
|
resource.defaultSort,
|
|
@@ -6818,10 +6849,21 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6818
6849
|
]);
|
|
6819
6850
|
const searchConfig = React.useMemo(() => {
|
|
6820
6851
|
const tableSearch = tableConfig?.search;
|
|
6852
|
+
const searchCapability = resource.capabilities?.search;
|
|
6821
6853
|
if (tableSearch === false) return false;
|
|
6854
|
+
if (searchCapability) {
|
|
6855
|
+
if (!searchCapability.enabled) return false;
|
|
6856
|
+
if (tableSearch && typeof tableSearch === "object") return tableSearch;
|
|
6857
|
+
return true;
|
|
6858
|
+
}
|
|
6822
6859
|
if (tableSearch && typeof tableSearch === "object") return tableSearch;
|
|
6860
|
+
if (tableSearch === true) return true;
|
|
6823
6861
|
return Object.values(resolvedFields).some((field) => field?.search === true) ? true : false;
|
|
6824
|
-
}, [
|
|
6862
|
+
}, [
|
|
6863
|
+
resolvedFields,
|
|
6864
|
+
resource.capabilities?.search,
|
|
6865
|
+
tableConfig?.search
|
|
6866
|
+
]);
|
|
6825
6867
|
const batchFields = React.useMemo(() => buildBatchUpdateFields(resolvedSchema, tableConfig?.batchFields, resolvedFields), [
|
|
6826
6868
|
resolvedSchema,
|
|
6827
6869
|
tableConfig?.batchFields,
|
|
@@ -7774,6 +7816,7 @@ function useAutoCrudResource({ router, schema, query: queryTransform, options =
|
|
|
7774
7816
|
const resolvedSchema = useMemo(() => mergeMetadataSchema(schema, metadata?.schema), [schema, metadata?.schema]);
|
|
7775
7817
|
const defaultSorting = useMemo(() => defaultSortOption === false ? [] : defaultSortOption ?? getDefaultSortingForSchema(resolvedSchema), [defaultSortOption, resolvedSchema]);
|
|
7776
7818
|
const metadataFields = useMemo(() => readMetadataFields(metadata?.fields), [metadata?.fields]);
|
|
7819
|
+
const capabilities = metadata?.capabilities;
|
|
7777
7820
|
const columns = useMemo(() => createTableSchema(resolvedSchema), [resolvedSchema]);
|
|
7778
7821
|
const [urlParams] = useQueryStates({
|
|
7779
7822
|
page: parseAsInteger.withDefault(1),
|
|
@@ -8066,6 +8109,7 @@ function useAutoCrudResource({ router, schema, query: queryTransform, options =
|
|
|
8066
8109
|
},
|
|
8067
8110
|
schema: resolvedSchema,
|
|
8068
8111
|
fields: metadataFields,
|
|
8112
|
+
capabilities,
|
|
8069
8113
|
defaultSort: defaultSorting,
|
|
8070
8114
|
modal,
|
|
8071
8115
|
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.0",
|
|
5
5
|
"description": "Schema-first CRUD components with auto-generated tables and forms",
|
|
6
6
|
"author": "wordrhyme",
|
|
7
7
|
"license": "MIT",
|
|
@@ -84,11 +84,11 @@
|
|
|
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
|
+
"@internal/vitest-config": "0.1.0",
|
|
89
90
|
"@internal/tsconfig": "0.1.0",
|
|
90
|
-
"@internal/tsdown-config": "0.1.0"
|
|
91
|
-
"@internal/vitest-config": "0.1.0"
|
|
91
|
+
"@internal/tsdown-config": "0.1.0"
|
|
92
92
|
},
|
|
93
93
|
"prettier": "@internal/prettier-config",
|
|
94
94
|
"scripts": {
|