@wordrhyme/auto-crud 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +68 -14
- package/dist/index.d.cts +28 -22
- package/dist/index.d.ts +28 -22
- package/dist/index.js +73 -25
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -2544,11 +2544,15 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
|
|
|
2544
2544
|
});
|
|
2545
2545
|
}
|
|
2546
2546
|
function SimpleFacetedFilter({ title, options, multiple, value, hasMore, loading, searchValue, shouldFilter, onChange, onPopupScroll, onSearch }) {
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2547
|
+
const onSelectChange = (nextValue) => {
|
|
2548
|
+
onChange(Array.isArray(nextValue) ? nextValue : nextValue ? [nextValue] : []);
|
|
2549
|
+
};
|
|
2550
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn_ui.Select, {
|
|
2551
|
+
mode: "searchable",
|
|
2552
|
+
multiple: Boolean(multiple),
|
|
2553
|
+
value: multiple ? value : value[0] ?? "",
|
|
2554
|
+
onChange: onSelectChange,
|
|
2550
2555
|
options,
|
|
2551
|
-
selectionMode: multiple ? "multiple" : "single",
|
|
2552
2556
|
searchPlaceholder: title,
|
|
2553
2557
|
hasMore,
|
|
2554
2558
|
loading,
|
|
@@ -4462,18 +4466,20 @@ const FormilyMultiCombobox = (0, __wordrhyme_formily_shadcn.connect)(AutoCrudMul
|
|
|
4462
4466
|
};
|
|
4463
4467
|
}));
|
|
4464
4468
|
function AutoCrudCombobox({ options = [], className, value, onChange,...props }) {
|
|
4465
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn_ui.
|
|
4469
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn_ui.Select, {
|
|
4466
4470
|
...props,
|
|
4467
|
-
|
|
4471
|
+
mode: "searchable",
|
|
4472
|
+
value: value ?? "",
|
|
4468
4473
|
options,
|
|
4469
|
-
|
|
4470
|
-
onChange: (nextValues) => onChange?.(nextValues[0] ?? ""),
|
|
4474
|
+
onChange: (nextValue) => onChange?.(nextValue),
|
|
4471
4475
|
className: (0, __wordrhyme_shadcn.cn)(COMBOBOX_LIST_CLASS, className)
|
|
4472
4476
|
});
|
|
4473
4477
|
}
|
|
4474
4478
|
function AutoCrudMultiCombobox({ options = [],...props }) {
|
|
4475
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn_ui.
|
|
4479
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn_ui.Select, {
|
|
4476
4480
|
...props,
|
|
4481
|
+
mode: "searchable",
|
|
4482
|
+
multiple: true,
|
|
4477
4483
|
options
|
|
4478
4484
|
});
|
|
4479
4485
|
}
|
|
@@ -4813,6 +4819,7 @@ const AutoForm = (0, react.forwardRef)(AutoFormInner);
|
|
|
4813
4819
|
//#region src/i18n/locale.ts
|
|
4814
4820
|
const zhCN = {
|
|
4815
4821
|
toolbar: {
|
|
4822
|
+
refresh: "刷新",
|
|
4816
4823
|
create: "新建",
|
|
4817
4824
|
import: "导入",
|
|
4818
4825
|
export: "导出",
|
|
@@ -4879,6 +4886,7 @@ const zhCN = {
|
|
|
4879
4886
|
};
|
|
4880
4887
|
const enUS = {
|
|
4881
4888
|
toolbar: {
|
|
4889
|
+
refresh: "Refresh",
|
|
4882
4890
|
create: "New",
|
|
4883
4891
|
import: "Import",
|
|
4884
4892
|
export: "Export",
|
|
@@ -4945,6 +4953,7 @@ const enUS = {
|
|
|
4945
4953
|
};
|
|
4946
4954
|
const jaJP = {
|
|
4947
4955
|
toolbar: {
|
|
4956
|
+
refresh: "更新",
|
|
4948
4957
|
create: "新規作成",
|
|
4949
4958
|
import: "インポート",
|
|
4950
4959
|
export: "エクスポート",
|
|
@@ -5011,6 +5020,7 @@ const jaJP = {
|
|
|
5011
5020
|
};
|
|
5012
5021
|
const koKR = {
|
|
5013
5022
|
toolbar: {
|
|
5023
|
+
refresh: "새로고침",
|
|
5014
5024
|
create: "새로 만들기",
|
|
5015
5025
|
import: "가져오기",
|
|
5016
5026
|
export: "내보내기",
|
|
@@ -5077,6 +5087,7 @@ const koKR = {
|
|
|
5077
5087
|
};
|
|
5078
5088
|
const frFR = {
|
|
5079
5089
|
toolbar: {
|
|
5090
|
+
refresh: "Actualiser",
|
|
5080
5091
|
create: "Nouveau",
|
|
5081
5092
|
import: "Importer",
|
|
5082
5093
|
export: "Exporter",
|
|
@@ -5143,6 +5154,7 @@ const frFR = {
|
|
|
5143
5154
|
};
|
|
5144
5155
|
const deDE = {
|
|
5145
5156
|
toolbar: {
|
|
5157
|
+
refresh: "Aktualisieren",
|
|
5146
5158
|
create: "Neu",
|
|
5147
5159
|
import: "Importieren",
|
|
5148
5160
|
export: "Exportieren",
|
|
@@ -5209,6 +5221,7 @@ const deDE = {
|
|
|
5209
5221
|
};
|
|
5210
5222
|
const esES = {
|
|
5211
5223
|
toolbar: {
|
|
5224
|
+
refresh: "Actualizar",
|
|
5212
5225
|
create: "Nuevo",
|
|
5213
5226
|
import: "Importar",
|
|
5214
5227
|
export: "Exportar",
|
|
@@ -5781,6 +5794,7 @@ function setToolbarResolver(resolver) {
|
|
|
5781
5794
|
}
|
|
5782
5795
|
function getDefaultToolbarActions() {
|
|
5783
5796
|
return [
|
|
5797
|
+
{ type: "refresh" },
|
|
5784
5798
|
{ type: "import" },
|
|
5785
5799
|
{ type: "export" },
|
|
5786
5800
|
{ type: "create" }
|
|
@@ -6529,6 +6543,8 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6529
6543
|
rowIds,
|
|
6530
6544
|
selectedRowIds,
|
|
6531
6545
|
selectedCount,
|
|
6546
|
+
isRefreshing: resource.tableData.isFetching,
|
|
6547
|
+
...resource.handlers.refresh ? { refresh: resource.handlers.refresh } : {},
|
|
6532
6548
|
...toolbarOpenCreate ? { openCreate: toolbarOpenCreate } : {}
|
|
6533
6549
|
}), [
|
|
6534
6550
|
id,
|
|
@@ -6536,6 +6552,8 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6536
6552
|
rowIds,
|
|
6537
6553
|
selectedRowIds,
|
|
6538
6554
|
selectedCount,
|
|
6555
|
+
resource.handlers.refresh,
|
|
6556
|
+
resource.tableData.isFetching,
|
|
6539
6557
|
toolbarOpenCreate
|
|
6540
6558
|
]);
|
|
6541
6559
|
const resolvedToolbarActions = resolveToolbarActionsWithResolver(id, registryToolbarActions, toolbarContext);
|
|
@@ -6649,6 +6667,20 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6649
6667
|
className: "flex items-center justify-end gap-4",
|
|
6650
6668
|
children: (() => {
|
|
6651
6669
|
const renderBuiltinButton = (type, overrides) => {
|
|
6670
|
+
if (type === "refresh") {
|
|
6671
|
+
const onRefresh = overrides?.onClick ?? resource.handlers.refresh;
|
|
6672
|
+
const label = overrides?.label ?? locale.toolbar.refresh;
|
|
6673
|
+
if (!onRefresh) return null;
|
|
6674
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Button, {
|
|
6675
|
+
variant: "outline",
|
|
6676
|
+
size: "icon-sm",
|
|
6677
|
+
"aria-label": label,
|
|
6678
|
+
title: label,
|
|
6679
|
+
onClick: onRefresh,
|
|
6680
|
+
disabled: resource.tableData.isFetching,
|
|
6681
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.RefreshCw, { className: resource.tableData.isFetching ? "h-4 w-4 animate-spin" : "h-4 w-4" })
|
|
6682
|
+
}, "refresh");
|
|
6683
|
+
}
|
|
6652
6684
|
if (type === "import" && canImport) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.Button, {
|
|
6653
6685
|
variant: "outline",
|
|
6654
6686
|
size: "sm",
|
|
@@ -6677,6 +6709,7 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6677
6709
|
className: "flex items-center gap-2",
|
|
6678
6710
|
children: [
|
|
6679
6711
|
startNodes,
|
|
6712
|
+
renderBuiltinButton("refresh"),
|
|
6680
6713
|
renderBuiltinButton("import"),
|
|
6681
6714
|
renderBuiltinButton("export"),
|
|
6682
6715
|
renderBuiltinButton("create"),
|
|
@@ -6688,7 +6721,14 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6688
6721
|
className: "flex items-center gap-2",
|
|
6689
6722
|
children: resolvedToolbarActions.map((action$1, index$1) => {
|
|
6690
6723
|
if (action$1.type === "custom") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: renderToolbarComponent(action$1.component) }, `custom-${index$1}`);
|
|
6691
|
-
if (!(
|
|
6724
|
+
if (!(() => {
|
|
6725
|
+
switch (action$1.type) {
|
|
6726
|
+
case "refresh": return !!(resource.handlers.refresh || action$1.onClick || action$1.component);
|
|
6727
|
+
case "import": return canImport;
|
|
6728
|
+
case "export": return canExport;
|
|
6729
|
+
case "create": return can.create;
|
|
6730
|
+
}
|
|
6731
|
+
})()) return null;
|
|
6692
6732
|
if (action$1.component) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: renderToolbarComponent(action$1.component) }, action$1.type);
|
|
6693
6733
|
return renderBuiltinButton(action$1.type, {
|
|
6694
6734
|
onClick: action$1.onClick,
|
|
@@ -6873,11 +6913,15 @@ function DataTableFacetedFilter({ column, title, options, multiple }) {
|
|
|
6873
6913
|
const onChange = (nextValues) => {
|
|
6874
6914
|
column?.setFilterValue(nextValues.length ? nextValues : void 0);
|
|
6875
6915
|
};
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6916
|
+
const onSelectChange = (nextValue) => {
|
|
6917
|
+
onChange(Array.isArray(nextValue) ? nextValue : nextValue ? [nextValue] : []);
|
|
6918
|
+
};
|
|
6919
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn_ui.Select, {
|
|
6920
|
+
mode: "searchable",
|
|
6921
|
+
multiple: Boolean(multiple),
|
|
6922
|
+
value: multiple ? selectedValues : selectedValues[0] ?? "",
|
|
6923
|
+
onChange: onSelectChange,
|
|
6879
6924
|
options: comboboxOptions,
|
|
6880
|
-
selectionMode: multiple ? "multiple" : "single",
|
|
6881
6925
|
searchPlaceholder: title,
|
|
6882
6926
|
hasMore: column?.columnDef.meta?.autoCrudFilterHasMore,
|
|
6883
6927
|
loading: column?.columnDef.meta?.autoCrudFilterLoading,
|
|
@@ -7800,6 +7844,9 @@ function useAutoCrudResource({ router, schema, query: queryTransform, options =
|
|
|
7800
7844
|
queryInput
|
|
7801
7845
|
]);
|
|
7802
7846
|
const canExport = !!(exportFetcher || exportQuery);
|
|
7847
|
+
const refresh = (0, react.useCallback)(async () => {
|
|
7848
|
+
return listQuery.refetch();
|
|
7849
|
+
}, [listQuery]);
|
|
7803
7850
|
return {
|
|
7804
7851
|
idKey,
|
|
7805
7852
|
tableData: {
|
|
@@ -7830,6 +7877,7 @@ function useAutoCrudResource({ router, schema, query: queryTransform, options =
|
|
|
7830
7877
|
deleteMany,
|
|
7831
7878
|
updateMany,
|
|
7832
7879
|
setVariant,
|
|
7880
|
+
refresh,
|
|
7833
7881
|
import: importMutation ? handleImport : null,
|
|
7834
7882
|
export: canExport ? handleExport : null
|
|
7835
7883
|
}
|
|
@@ -8163,6 +8211,12 @@ Object.defineProperty(exports, 'MultiCombobox', {
|
|
|
8163
8211
|
}
|
|
8164
8212
|
});
|
|
8165
8213
|
exports.SchemaAdapter = SchemaAdapter;
|
|
8214
|
+
Object.defineProperty(exports, 'Select', {
|
|
8215
|
+
enumerable: true,
|
|
8216
|
+
get: function () {
|
|
8217
|
+
return __wordrhyme_shadcn_ui.Select;
|
|
8218
|
+
}
|
|
8219
|
+
});
|
|
8166
8220
|
exports.cn = cn;
|
|
8167
8221
|
exports.coerceRowValues = coerceRowValues;
|
|
8168
8222
|
exports.components = components;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime1 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";
|
|
@@ -6,7 +6,7 @@ import { Column, ColumnDef, ColumnSort, Row, RowData, Table, TableOptions, Table
|
|
|
6
6
|
import * as React$1 from "react";
|
|
7
7
|
import { ISchema } from "@formily/json-schema";
|
|
8
8
|
import { DropdownMenuTrigger, PopoverContent } from "@wordrhyme/shadcn";
|
|
9
|
-
import { MultiCombobox, MultiComboboxOption, MultiComboboxProps, MultiComboboxTriggerRenderProps } from "@wordrhyme/shadcn-ui";
|
|
9
|
+
import { MultiCombobox, MultiComboboxOption, MultiComboboxProps, MultiComboboxTriggerRenderProps, Select, SelectMode, SelectOption, SelectProps, SelectSearchableDynamicProps, SelectSearchableMultipleProps, SelectSearchableProps, SelectSearchableSingleProps, SelectSimpleProps, SelectTriggerRenderProps } from "@wordrhyme/shadcn-ui";
|
|
10
10
|
import { ClassValue } from "clsx";
|
|
11
11
|
|
|
12
12
|
//#region src/hooks/use-auto-crud-resource.d.ts
|
|
@@ -153,6 +153,8 @@ interface UseAutoCrudResourceReturn<TSchema extends z.ZodObject<z.ZodRawShape>,
|
|
|
153
153
|
deleteMany: (rows: TListItem[]) => void;
|
|
154
154
|
updateMany: (rows: TListItem[], data: Record<string, unknown>) => void;
|
|
155
155
|
setVariant: (variant: ModalVariant$1) => void;
|
|
156
|
+
/** 刷新当前列表数据 */
|
|
157
|
+
refresh?: () => Promise<unknown>;
|
|
156
158
|
/** 导入数据(router 有 import 路由时自动可用) */
|
|
157
159
|
import: ((rows: Record<string, unknown>[]) => Promise<ImportResult>) | null;
|
|
158
160
|
/** 导出筛选结果(router 有 export procedure 或传入 exportFetcher 时自动可用)。导出选中行由 AutoCrudTable 内部处理 */
|
|
@@ -379,7 +381,7 @@ declare function AutoTableActionBar<TData>({
|
|
|
379
381
|
extraActions,
|
|
380
382
|
actions,
|
|
381
383
|
deleteConfirmation
|
|
382
|
-
}: AutoTableActionBarProps<TData>):
|
|
384
|
+
}: AutoTableActionBarProps<TData>): react_jsx_runtime1.JSX.Element;
|
|
383
385
|
//#endregion
|
|
384
386
|
//#region src/lib/schema-bridge/types.d.ts
|
|
385
387
|
/**
|
|
@@ -555,7 +557,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
555
557
|
onSelectedCountChange,
|
|
556
558
|
onSelectedRowsChange,
|
|
557
559
|
getSelectedRows
|
|
558
|
-
}: AutoTableProps<T>):
|
|
560
|
+
}: AutoTableProps<T>): react_jsx_runtime1.JSX.Element;
|
|
559
561
|
//#endregion
|
|
560
562
|
//#region src/i18n/locale.d.ts
|
|
561
563
|
/**
|
|
@@ -570,6 +572,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
570
572
|
*/
|
|
571
573
|
interface AutoCrudLocale {
|
|
572
574
|
toolbar: {
|
|
575
|
+
refresh: string;
|
|
573
576
|
create: string;
|
|
574
577
|
import: string;
|
|
575
578
|
export: string;
|
|
@@ -869,8 +872,9 @@ type AutoCrudActionConfig<T> = RowActionConfig<T> | AutoCrudActionsConfig<T>;
|
|
|
869
872
|
/**
|
|
870
873
|
* 顶部工具栏内置操作项
|
|
871
874
|
*/
|
|
875
|
+
type ToolbarBuiltinActionType = 'refresh' | 'create' | 'import' | 'export';
|
|
872
876
|
type ToolbarBuiltinActionItem = ActionMeta & {
|
|
873
|
-
type:
|
|
877
|
+
type: ToolbarBuiltinActionType;
|
|
874
878
|
/** 替代默认的行为 */
|
|
875
879
|
onClick?: () => void;
|
|
876
880
|
/** 替代默认的标签文本 */
|
|
@@ -896,6 +900,8 @@ interface AutoCrudToolbarContext {
|
|
|
896
900
|
rowIds: string[];
|
|
897
901
|
selectedRowIds: string[];
|
|
898
902
|
selectedCount: number;
|
|
903
|
+
refresh?: () => Promise<unknown>;
|
|
904
|
+
isRefreshing: boolean;
|
|
899
905
|
openCreate?: () => void;
|
|
900
906
|
}
|
|
901
907
|
type AutoCrudToolbarResolver = (targetId: string, ownerActions: readonly ToolbarActionItem[], context: AutoCrudToolbarContext) => ToolbarActionItem[];
|
|
@@ -1031,7 +1037,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1031
1037
|
toolbarActions,
|
|
1032
1038
|
locale: localeProp,
|
|
1033
1039
|
onCreate
|
|
1034
|
-
}: AutoCrudTableProps<TSchema>):
|
|
1040
|
+
}: AutoCrudTableProps<TSchema>): react_jsx_runtime1.JSX.Element;
|
|
1035
1041
|
//#endregion
|
|
1036
1042
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
1037
1043
|
interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
@@ -1070,7 +1076,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1070
1076
|
labelAlign,
|
|
1071
1077
|
labelWidth,
|
|
1072
1078
|
showSubmitButton
|
|
1073
|
-
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>):
|
|
1079
|
+
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime1.JSX.Element;
|
|
1074
1080
|
declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
|
|
1075
1081
|
ref?: React.Ref<AutoFormRef>;
|
|
1076
1082
|
}) => ReturnType<typeof AutoFormInner>;
|
|
@@ -1284,12 +1290,12 @@ declare const filterItemSchema: z.ZodObject<{
|
|
|
1284
1290
|
variant: z.ZodEnum<{
|
|
1285
1291
|
number: "number";
|
|
1286
1292
|
boolean: "boolean";
|
|
1287
|
-
text: "text";
|
|
1288
|
-
range: "range";
|
|
1289
1293
|
date: "date";
|
|
1290
|
-
|
|
1294
|
+
text: "text";
|
|
1291
1295
|
select: "select";
|
|
1292
1296
|
multiSelect: "multiSelect";
|
|
1297
|
+
dateRange: "dateRange";
|
|
1298
|
+
range: "range";
|
|
1293
1299
|
}>;
|
|
1294
1300
|
operator: z.ZodEnum<{
|
|
1295
1301
|
iLike: "iLike";
|
|
@@ -1386,7 +1392,7 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
1386
1392
|
filters: externalFilters,
|
|
1387
1393
|
onFiltersChange,
|
|
1388
1394
|
leading
|
|
1389
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
1395
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime1.JSX.Element | null;
|
|
1390
1396
|
//#endregion
|
|
1391
1397
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
1392
1398
|
type ModalVariant = "dialog" | "sheet";
|
|
@@ -1430,7 +1436,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1430
1436
|
labelAlign,
|
|
1431
1437
|
labelWidth,
|
|
1432
1438
|
className
|
|
1433
|
-
}: CrudFormModalProps<T>):
|
|
1439
|
+
}: CrudFormModalProps<T>): react_jsx_runtime1.JSX.Element;
|
|
1434
1440
|
//#endregion
|
|
1435
1441
|
//#region src/components/auto-crud/import-dialog.d.ts
|
|
1436
1442
|
interface ImportDialogProps {
|
|
@@ -1452,7 +1458,7 @@ declare function ImportDialog({
|
|
|
1452
1458
|
columns,
|
|
1453
1459
|
title,
|
|
1454
1460
|
locale
|
|
1455
|
-
}: ImportDialogProps):
|
|
1461
|
+
}: ImportDialogProps): react_jsx_runtime1.JSX.Element;
|
|
1456
1462
|
//#endregion
|
|
1457
1463
|
//#region src/components/auto-crud/export-dialog.d.ts
|
|
1458
1464
|
type ExportMode = "selected" | "filtered";
|
|
@@ -1472,7 +1478,7 @@ declare function ExportDialog({
|
|
|
1472
1478
|
selectedCount,
|
|
1473
1479
|
onExport,
|
|
1474
1480
|
canExportFiltered
|
|
1475
|
-
}: ExportDialogProps):
|
|
1481
|
+
}: ExportDialogProps): react_jsx_runtime1.JSX.Element;
|
|
1476
1482
|
//#endregion
|
|
1477
1483
|
//#region src/components/data-table/data-table.d.ts
|
|
1478
1484
|
interface DataTableProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1485,7 +1491,7 @@ declare function DataTable<TData>({
|
|
|
1485
1491
|
children,
|
|
1486
1492
|
className,
|
|
1487
1493
|
...props
|
|
1488
|
-
}: DataTableProps<TData>):
|
|
1494
|
+
}: DataTableProps<TData>): react_jsx_runtime1.JSX.Element;
|
|
1489
1495
|
//#endregion
|
|
1490
1496
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
1491
1497
|
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1496,7 +1502,7 @@ declare function DataTableAdvancedToolbar<TData>({
|
|
|
1496
1502
|
children,
|
|
1497
1503
|
className,
|
|
1498
1504
|
...props
|
|
1499
|
-
}: DataTableAdvancedToolbarProps<TData>):
|
|
1505
|
+
}: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime1.JSX.Element;
|
|
1500
1506
|
//#endregion
|
|
1501
1507
|
//#region src/components/data-table/data-table-column-header.d.ts
|
|
1502
1508
|
interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
|
|
@@ -1508,7 +1514,7 @@ declare function DataTableColumnHeader<TData, TValue>({
|
|
|
1508
1514
|
label,
|
|
1509
1515
|
className,
|
|
1510
1516
|
...props
|
|
1511
|
-
}: DataTableColumnHeaderProps<TData, TValue>):
|
|
1517
|
+
}: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime1.JSX.Element;
|
|
1512
1518
|
//#endregion
|
|
1513
1519
|
//#region src/components/data-table/data-table-faceted-filter.d.ts
|
|
1514
1520
|
interface DataTableFacetedFilterProps<TData, TValue> {
|
|
@@ -1522,7 +1528,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
1522
1528
|
title,
|
|
1523
1529
|
options,
|
|
1524
1530
|
multiple
|
|
1525
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
1531
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime1.JSX.Element;
|
|
1526
1532
|
//#endregion
|
|
1527
1533
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
1528
1534
|
interface DataTablePaginationProps<TData> extends React.ComponentProps<"div"> {
|
|
@@ -1534,7 +1540,7 @@ declare function DataTablePagination<TData>({
|
|
|
1534
1540
|
pageSizeOptions,
|
|
1535
1541
|
className,
|
|
1536
1542
|
...props
|
|
1537
|
-
}: DataTablePaginationProps<TData>):
|
|
1543
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime1.JSX.Element;
|
|
1538
1544
|
//#endregion
|
|
1539
1545
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
1540
1546
|
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1545,7 +1551,7 @@ declare function DataTableToolbar<TData>({
|
|
|
1545
1551
|
children,
|
|
1546
1552
|
className,
|
|
1547
1553
|
...props
|
|
1548
|
-
}: DataTableToolbarProps<TData>):
|
|
1554
|
+
}: DataTableToolbarProps<TData>): react_jsx_runtime1.JSX.Element;
|
|
1549
1555
|
//#endregion
|
|
1550
1556
|
//#region src/components/data-table/data-table-view-options.d.ts
|
|
1551
1557
|
interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
|
|
@@ -1556,7 +1562,7 @@ declare function DataTableViewOptions<TData>({
|
|
|
1556
1562
|
table,
|
|
1557
1563
|
disabled,
|
|
1558
1564
|
...props
|
|
1559
|
-
}: DataTableViewOptionsProps<TData>):
|
|
1565
|
+
}: DataTableViewOptionsProps<TData>): react_jsx_runtime1.JSX.Element;
|
|
1560
1566
|
//#endregion
|
|
1561
1567
|
//#region src/lib/crud-actions.d.ts
|
|
1562
1568
|
type CrudActionZone = 'toolbar' | 'row' | 'batch';
|
|
@@ -1931,4 +1937,4 @@ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], op
|
|
|
1931
1937
|
*/
|
|
1932
1938
|
declare function downloadCSVTemplate(headers: string[], filename?: string): void;
|
|
1933
1939
|
//#endregion
|
|
1934
|
-
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, type SimpleFieldConfig, type SimpleFieldsConfig, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, 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 };
|
|
1940
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ 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
|
|
7
|
-
import { MultiCombobox, MultiComboboxOption, MultiComboboxProps, MultiComboboxTriggerRenderProps } from "@wordrhyme/shadcn-ui";
|
|
6
|
+
import * as react_jsx_runtime7 from "react/jsx-runtime";
|
|
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";
|
|
10
10
|
import { ISchema } from "@formily/json-schema";
|
|
@@ -153,6 +153,8 @@ interface UseAutoCrudResourceReturn<TSchema extends z.ZodObject<z.ZodRawShape>,
|
|
|
153
153
|
deleteMany: (rows: TListItem[]) => void;
|
|
154
154
|
updateMany: (rows: TListItem[], data: Record<string, unknown>) => void;
|
|
155
155
|
setVariant: (variant: ModalVariant$1) => void;
|
|
156
|
+
/** 刷新当前列表数据 */
|
|
157
|
+
refresh?: () => Promise<unknown>;
|
|
156
158
|
/** 导入数据(router 有 import 路由时自动可用) */
|
|
157
159
|
import: ((rows: Record<string, unknown>[]) => Promise<ImportResult>) | null;
|
|
158
160
|
/** 导出筛选结果(router 有 export procedure 或传入 exportFetcher 时自动可用)。导出选中行由 AutoCrudTable 内部处理 */
|
|
@@ -379,7 +381,7 @@ declare function AutoTableActionBar<TData>({
|
|
|
379
381
|
extraActions,
|
|
380
382
|
actions,
|
|
381
383
|
deleteConfirmation
|
|
382
|
-
}: AutoTableActionBarProps<TData>):
|
|
384
|
+
}: AutoTableActionBarProps<TData>): react_jsx_runtime7.JSX.Element;
|
|
383
385
|
//#endregion
|
|
384
386
|
//#region src/lib/schema-bridge/types.d.ts
|
|
385
387
|
/**
|
|
@@ -555,7 +557,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
555
557
|
onSelectedCountChange,
|
|
556
558
|
onSelectedRowsChange,
|
|
557
559
|
getSelectedRows
|
|
558
|
-
}: AutoTableProps<T>):
|
|
560
|
+
}: AutoTableProps<T>): react_jsx_runtime7.JSX.Element;
|
|
559
561
|
//#endregion
|
|
560
562
|
//#region src/i18n/locale.d.ts
|
|
561
563
|
/**
|
|
@@ -570,6 +572,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
570
572
|
*/
|
|
571
573
|
interface AutoCrudLocale {
|
|
572
574
|
toolbar: {
|
|
575
|
+
refresh: string;
|
|
573
576
|
create: string;
|
|
574
577
|
import: string;
|
|
575
578
|
export: string;
|
|
@@ -869,8 +872,9 @@ type AutoCrudActionConfig<T> = RowActionConfig<T> | AutoCrudActionsConfig<T>;
|
|
|
869
872
|
/**
|
|
870
873
|
* 顶部工具栏内置操作项
|
|
871
874
|
*/
|
|
875
|
+
type ToolbarBuiltinActionType = 'refresh' | 'create' | 'import' | 'export';
|
|
872
876
|
type ToolbarBuiltinActionItem = ActionMeta & {
|
|
873
|
-
type:
|
|
877
|
+
type: ToolbarBuiltinActionType;
|
|
874
878
|
/** 替代默认的行为 */
|
|
875
879
|
onClick?: () => void;
|
|
876
880
|
/** 替代默认的标签文本 */
|
|
@@ -896,6 +900,8 @@ interface AutoCrudToolbarContext {
|
|
|
896
900
|
rowIds: string[];
|
|
897
901
|
selectedRowIds: string[];
|
|
898
902
|
selectedCount: number;
|
|
903
|
+
refresh?: () => Promise<unknown>;
|
|
904
|
+
isRefreshing: boolean;
|
|
899
905
|
openCreate?: () => void;
|
|
900
906
|
}
|
|
901
907
|
type AutoCrudToolbarResolver = (targetId: string, ownerActions: readonly ToolbarActionItem[], context: AutoCrudToolbarContext) => ToolbarActionItem[];
|
|
@@ -1031,7 +1037,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1031
1037
|
toolbarActions,
|
|
1032
1038
|
locale: localeProp,
|
|
1033
1039
|
onCreate
|
|
1034
|
-
}: AutoCrudTableProps<TSchema>):
|
|
1040
|
+
}: AutoCrudTableProps<TSchema>): react_jsx_runtime7.JSX.Element;
|
|
1035
1041
|
//#endregion
|
|
1036
1042
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
1037
1043
|
interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
@@ -1070,7 +1076,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1070
1076
|
labelAlign,
|
|
1071
1077
|
labelWidth,
|
|
1072
1078
|
showSubmitButton
|
|
1073
|
-
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>):
|
|
1079
|
+
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime7.JSX.Element;
|
|
1074
1080
|
declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
|
|
1075
1081
|
ref?: React.Ref<AutoFormRef>;
|
|
1076
1082
|
}) => ReturnType<typeof AutoFormInner>;
|
|
@@ -1284,12 +1290,12 @@ declare const filterItemSchema: z.ZodObject<{
|
|
|
1284
1290
|
variant: z.ZodEnum<{
|
|
1285
1291
|
number: "number";
|
|
1286
1292
|
boolean: "boolean";
|
|
1287
|
-
text: "text";
|
|
1288
|
-
range: "range";
|
|
1289
1293
|
date: "date";
|
|
1290
|
-
|
|
1294
|
+
text: "text";
|
|
1291
1295
|
select: "select";
|
|
1292
1296
|
multiSelect: "multiSelect";
|
|
1297
|
+
dateRange: "dateRange";
|
|
1298
|
+
range: "range";
|
|
1293
1299
|
}>;
|
|
1294
1300
|
operator: z.ZodEnum<{
|
|
1295
1301
|
iLike: "iLike";
|
|
@@ -1386,7 +1392,7 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
1386
1392
|
filters: externalFilters,
|
|
1387
1393
|
onFiltersChange,
|
|
1388
1394
|
leading
|
|
1389
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
1395
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime7.JSX.Element | null;
|
|
1390
1396
|
//#endregion
|
|
1391
1397
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
1392
1398
|
type ModalVariant = "dialog" | "sheet";
|
|
@@ -1430,7 +1436,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1430
1436
|
labelAlign,
|
|
1431
1437
|
labelWidth,
|
|
1432
1438
|
className
|
|
1433
|
-
}: CrudFormModalProps<T>):
|
|
1439
|
+
}: CrudFormModalProps<T>): react_jsx_runtime7.JSX.Element;
|
|
1434
1440
|
//#endregion
|
|
1435
1441
|
//#region src/components/auto-crud/import-dialog.d.ts
|
|
1436
1442
|
interface ImportDialogProps {
|
|
@@ -1452,7 +1458,7 @@ declare function ImportDialog({
|
|
|
1452
1458
|
columns,
|
|
1453
1459
|
title,
|
|
1454
1460
|
locale
|
|
1455
|
-
}: ImportDialogProps):
|
|
1461
|
+
}: ImportDialogProps): react_jsx_runtime7.JSX.Element;
|
|
1456
1462
|
//#endregion
|
|
1457
1463
|
//#region src/components/auto-crud/export-dialog.d.ts
|
|
1458
1464
|
type ExportMode = "selected" | "filtered";
|
|
@@ -1472,7 +1478,7 @@ declare function ExportDialog({
|
|
|
1472
1478
|
selectedCount,
|
|
1473
1479
|
onExport,
|
|
1474
1480
|
canExportFiltered
|
|
1475
|
-
}: ExportDialogProps):
|
|
1481
|
+
}: ExportDialogProps): react_jsx_runtime7.JSX.Element;
|
|
1476
1482
|
//#endregion
|
|
1477
1483
|
//#region src/components/data-table/data-table.d.ts
|
|
1478
1484
|
interface DataTableProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1485,7 +1491,7 @@ declare function DataTable<TData>({
|
|
|
1485
1491
|
children,
|
|
1486
1492
|
className,
|
|
1487
1493
|
...props
|
|
1488
|
-
}: DataTableProps<TData>):
|
|
1494
|
+
}: DataTableProps<TData>): react_jsx_runtime7.JSX.Element;
|
|
1489
1495
|
//#endregion
|
|
1490
1496
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
1491
1497
|
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1496,7 +1502,7 @@ declare function DataTableAdvancedToolbar<TData>({
|
|
|
1496
1502
|
children,
|
|
1497
1503
|
className,
|
|
1498
1504
|
...props
|
|
1499
|
-
}: DataTableAdvancedToolbarProps<TData>):
|
|
1505
|
+
}: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime7.JSX.Element;
|
|
1500
1506
|
//#endregion
|
|
1501
1507
|
//#region src/components/data-table/data-table-column-header.d.ts
|
|
1502
1508
|
interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
|
|
@@ -1508,7 +1514,7 @@ declare function DataTableColumnHeader<TData, TValue>({
|
|
|
1508
1514
|
label,
|
|
1509
1515
|
className,
|
|
1510
1516
|
...props
|
|
1511
|
-
}: DataTableColumnHeaderProps<TData, TValue>):
|
|
1517
|
+
}: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime7.JSX.Element;
|
|
1512
1518
|
//#endregion
|
|
1513
1519
|
//#region src/components/data-table/data-table-faceted-filter.d.ts
|
|
1514
1520
|
interface DataTableFacetedFilterProps<TData, TValue> {
|
|
@@ -1522,7 +1528,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
1522
1528
|
title,
|
|
1523
1529
|
options,
|
|
1524
1530
|
multiple
|
|
1525
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
1531
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime7.JSX.Element;
|
|
1526
1532
|
//#endregion
|
|
1527
1533
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
1528
1534
|
interface DataTablePaginationProps<TData> extends React.ComponentProps<"div"> {
|
|
@@ -1534,7 +1540,7 @@ declare function DataTablePagination<TData>({
|
|
|
1534
1540
|
pageSizeOptions,
|
|
1535
1541
|
className,
|
|
1536
1542
|
...props
|
|
1537
|
-
}: DataTablePaginationProps<TData>):
|
|
1543
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime7.JSX.Element;
|
|
1538
1544
|
//#endregion
|
|
1539
1545
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
1540
1546
|
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1545,7 +1551,7 @@ declare function DataTableToolbar<TData>({
|
|
|
1545
1551
|
children,
|
|
1546
1552
|
className,
|
|
1547
1553
|
...props
|
|
1548
|
-
}: DataTableToolbarProps<TData>):
|
|
1554
|
+
}: DataTableToolbarProps<TData>): react_jsx_runtime7.JSX.Element;
|
|
1549
1555
|
//#endregion
|
|
1550
1556
|
//#region src/components/data-table/data-table-view-options.d.ts
|
|
1551
1557
|
interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
|
|
@@ -1556,7 +1562,7 @@ declare function DataTableViewOptions<TData>({
|
|
|
1556
1562
|
table,
|
|
1557
1563
|
disabled,
|
|
1558
1564
|
...props
|
|
1559
|
-
}: DataTableViewOptionsProps<TData>):
|
|
1565
|
+
}: DataTableViewOptionsProps<TData>): react_jsx_runtime7.JSX.Element;
|
|
1560
1566
|
//#endregion
|
|
1561
1567
|
//#region src/lib/crud-actions.d.ts
|
|
1562
1568
|
type CrudActionZone = 'toolbar' | 'row' | 'batch';
|
|
@@ -1931,4 +1937,4 @@ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], op
|
|
|
1931
1937
|
*/
|
|
1932
1938
|
declare function downloadCSVTemplate(headers: string[], filename?: string): void;
|
|
1933
1939
|
//#endregion
|
|
1934
|
-
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, type SimpleFieldConfig, type SimpleFieldsConfig, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, 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 };
|
|
1940
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useReducer, useRef, useState } from "react";
|
|
3
|
-
import { ArrowDownUp, BadgeCheck, CalendarIcon, Check, CheckCircle2, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, ChevronsLeft, ChevronsRight, ChevronsUpDown, CommandIcon, Download, Ellipsis, EyeOff, FileDown, FileSpreadsheetIcon, GripVertical, ListFilter, ListFilterIcon, Loader2, PlusCircle, Settings2, Text, Trash2, Upload, X, XCircle } from "lucide-react";
|
|
3
|
+
import { ArrowDownUp, BadgeCheck, CalendarIcon, Check, CheckCircle2, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, ChevronsLeft, ChevronsRight, ChevronsUpDown, CommandIcon, Download, Ellipsis, EyeOff, FileDown, FileSpreadsheetIcon, GripVertical, ListFilter, ListFilterIcon, Loader2, PlusCircle, RefreshCw, Settings2, Text, Trash2, Upload, X, XCircle } from "lucide-react";
|
|
4
4
|
import { flexRender, getCoreRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
|
|
5
|
-
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, Badge, Button, Calendar, Checkbox, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, Input, Label, Popover, PopoverContent, PopoverTrigger, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Separator, Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, Slider, Switch, Table as Table$1, TableBody, TableCell, TableHead, TableHeader, TableRow, cn as cn$1 } from "@wordrhyme/shadcn";
|
|
5
|
+
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, Badge, Button, Calendar, Checkbox, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, Input, Label, Popover, PopoverContent, PopoverTrigger, Select as Select$1, SelectContent, SelectItem, SelectTrigger, SelectValue, Separator, Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, Slider, Switch, Table as Table$1, TableBody, TableCell, TableHead, TableHeader, TableRow, cn as cn$1 } from "@wordrhyme/shadcn";
|
|
6
6
|
import { clsx } from "clsx";
|
|
7
7
|
import { twMerge } from "tailwind-merge";
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { customAlphabet } from "nanoid";
|
|
10
|
-
import { ActionBar, ActionBarClose, ActionBarGroup, ActionBarItem, ActionBarSelection, ActionBarSeparator, Faceted, FacetedBadgeList, FacetedContent, FacetedEmpty, FacetedGroup, FacetedInput, FacetedItem, FacetedList, FacetedTrigger, MultiCombobox,
|
|
10
|
+
import { ActionBar, ActionBarClose, ActionBarGroup, ActionBarItem, ActionBarSelection, ActionBarSeparator, Faceted, FacetedBadgeList, FacetedContent, FacetedEmpty, FacetedGroup, FacetedInput, FacetedItem, FacetedList, FacetedTrigger, MultiCombobox, Select, Select as Select$2, Sortable, SortableContent, SortableItem, SortableItemHandle, SortableOverlay } from "@wordrhyme/shadcn-ui";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
import { createForm } from "@formily/core";
|
|
13
13
|
import { action, observable } from "@formily/reactive";
|
|
@@ -49,7 +49,7 @@ function DataTablePagination({ table, pageSizeOptions = [
|
|
|
49
49
|
children: [/* @__PURE__ */ jsx("p", {
|
|
50
50
|
className: "whitespace-nowrap font-medium text-sm",
|
|
51
51
|
children: "Rows per page"
|
|
52
|
-
}), /* @__PURE__ */ jsxs(Select, {
|
|
52
|
+
}), /* @__PURE__ */ jsxs(Select$1, {
|
|
53
53
|
value: `${table.getState().pagination.pageSize}`,
|
|
54
54
|
onValueChange: (value) => {
|
|
55
55
|
table.setPageSize(Number(value));
|
|
@@ -1109,7 +1109,7 @@ function DataTableFilterItem$1({ filter, index: index$1, filterItemId, joinOpera
|
|
|
1109
1109
|
children: index$1 === 0 ? /* @__PURE__ */ jsx("span", {
|
|
1110
1110
|
className: "text-muted-foreground text-sm",
|
|
1111
1111
|
children: "Where"
|
|
1112
|
-
}) : index$1 === 1 ? /* @__PURE__ */ jsxs(Select, {
|
|
1112
|
+
}) : index$1 === 1 ? /* @__PURE__ */ jsxs(Select$1, {
|
|
1113
1113
|
value: joinOperator,
|
|
1114
1114
|
onValueChange: (value) => setJoinOperator(value),
|
|
1115
1115
|
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
@@ -1169,7 +1169,7 @@ function DataTableFilterItem$1({ filter, index: index$1, filterItemId, joinOpera
|
|
|
1169
1169
|
}, column$1.id)) })] })] })
|
|
1170
1170
|
})]
|
|
1171
1171
|
}),
|
|
1172
|
-
/* @__PURE__ */ jsxs(Select, {
|
|
1172
|
+
/* @__PURE__ */ jsxs(Select$1, {
|
|
1173
1173
|
open: showOperatorSelector,
|
|
1174
1174
|
onOpenChange: setShowOperatorSelector,
|
|
1175
1175
|
value: filter.operator,
|
|
@@ -1261,7 +1261,7 @@ function onFilterInputRender$1({ filter, inputId, column, columnMeta, onFilterUp
|
|
|
1261
1261
|
case "boolean": {
|
|
1262
1262
|
if (Array.isArray(filter.value)) return null;
|
|
1263
1263
|
const inputListboxId = `${inputId}-listbox`;
|
|
1264
|
-
return /* @__PURE__ */ jsxs(Select, {
|
|
1264
|
+
return /* @__PURE__ */ jsxs(Select$1, {
|
|
1265
1265
|
open: showValueSelector,
|
|
1266
1266
|
onOpenChange: setShowValueSelector,
|
|
1267
1267
|
value: filter.value,
|
|
@@ -1681,7 +1681,7 @@ function DataTableFilterItem({ filter, filterItemId, columns, onFilterUpdate, on
|
|
|
1681
1681
|
})
|
|
1682
1682
|
})]
|
|
1683
1683
|
}),
|
|
1684
|
-
/* @__PURE__ */ jsxs(Select, {
|
|
1684
|
+
/* @__PURE__ */ jsxs(Select$1, {
|
|
1685
1685
|
open: showOperatorSelector,
|
|
1686
1686
|
onOpenChange: setShowOperatorSelector,
|
|
1687
1687
|
value: filter.operator,
|
|
@@ -1807,7 +1807,7 @@ function onFilterInputRender({ filter, column, inputId, onFilterUpdate, showValu
|
|
|
1807
1807
|
}
|
|
1808
1808
|
case "boolean": {
|
|
1809
1809
|
const inputListboxId = `${inputId}-listbox`;
|
|
1810
|
-
return /* @__PURE__ */ jsxs(Select, {
|
|
1810
|
+
return /* @__PURE__ */ jsxs(Select$1, {
|
|
1811
1811
|
open: showValueSelector,
|
|
1812
1812
|
onOpenChange: setShowValueSelector,
|
|
1813
1813
|
value: typeof filter.value === "string" ? filter.value : "true",
|
|
@@ -2176,7 +2176,7 @@ function DataTableSortItem({ sort, sortItemId, columns, columnLabels, onSortUpda
|
|
|
2176
2176
|
}, column.id)) })] })] })
|
|
2177
2177
|
})]
|
|
2178
2178
|
}),
|
|
2179
|
-
/* @__PURE__ */ jsxs(Select, {
|
|
2179
|
+
/* @__PURE__ */ jsxs(Select$1, {
|
|
2180
2180
|
open: showDirectionSelector,
|
|
2181
2181
|
onOpenChange: setShowDirectionSelector,
|
|
2182
2182
|
value: sort.desc ? "desc" : "asc",
|
|
@@ -2507,11 +2507,15 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
|
|
|
2507
2507
|
});
|
|
2508
2508
|
}
|
|
2509
2509
|
function SimpleFacetedFilter({ title, options, multiple, value, hasMore, loading, searchValue, shouldFilter, onChange, onPopupScroll, onSearch }) {
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2510
|
+
const onSelectChange = (nextValue) => {
|
|
2511
|
+
onChange(Array.isArray(nextValue) ? nextValue : nextValue ? [nextValue] : []);
|
|
2512
|
+
};
|
|
2513
|
+
return /* @__PURE__ */ jsx(Select$2, {
|
|
2514
|
+
mode: "searchable",
|
|
2515
|
+
multiple: Boolean(multiple),
|
|
2516
|
+
value: multiple ? value : value[0] ?? "",
|
|
2517
|
+
onChange: onSelectChange,
|
|
2513
2518
|
options,
|
|
2514
|
-
selectionMode: multiple ? "multiple" : "single",
|
|
2515
2519
|
searchPlaceholder: title,
|
|
2516
2520
|
hasMore,
|
|
2517
2521
|
loading,
|
|
@@ -4425,18 +4429,20 @@ const FormilyMultiCombobox = connect(AutoCrudMultiCombobox, mapProps({
|
|
|
4425
4429
|
};
|
|
4426
4430
|
}));
|
|
4427
4431
|
function AutoCrudCombobox({ options = [], className, value, onChange,...props }) {
|
|
4428
|
-
return /* @__PURE__ */ jsx(
|
|
4432
|
+
return /* @__PURE__ */ jsx(Select$2, {
|
|
4429
4433
|
...props,
|
|
4430
|
-
|
|
4434
|
+
mode: "searchable",
|
|
4435
|
+
value: value ?? "",
|
|
4431
4436
|
options,
|
|
4432
|
-
|
|
4433
|
-
onChange: (nextValues) => onChange?.(nextValues[0] ?? ""),
|
|
4437
|
+
onChange: (nextValue) => onChange?.(nextValue),
|
|
4434
4438
|
className: cn$1(COMBOBOX_LIST_CLASS, className)
|
|
4435
4439
|
});
|
|
4436
4440
|
}
|
|
4437
4441
|
function AutoCrudMultiCombobox({ options = [],...props }) {
|
|
4438
|
-
return /* @__PURE__ */ jsx(
|
|
4442
|
+
return /* @__PURE__ */ jsx(Select$2, {
|
|
4439
4443
|
...props,
|
|
4444
|
+
mode: "searchable",
|
|
4445
|
+
multiple: true,
|
|
4440
4446
|
options
|
|
4441
4447
|
});
|
|
4442
4448
|
}
|
|
@@ -4776,6 +4782,7 @@ const AutoForm = forwardRef(AutoFormInner);
|
|
|
4776
4782
|
//#region src/i18n/locale.ts
|
|
4777
4783
|
const zhCN = {
|
|
4778
4784
|
toolbar: {
|
|
4785
|
+
refresh: "刷新",
|
|
4779
4786
|
create: "新建",
|
|
4780
4787
|
import: "导入",
|
|
4781
4788
|
export: "导出",
|
|
@@ -4842,6 +4849,7 @@ const zhCN = {
|
|
|
4842
4849
|
};
|
|
4843
4850
|
const enUS = {
|
|
4844
4851
|
toolbar: {
|
|
4852
|
+
refresh: "Refresh",
|
|
4845
4853
|
create: "New",
|
|
4846
4854
|
import: "Import",
|
|
4847
4855
|
export: "Export",
|
|
@@ -4908,6 +4916,7 @@ const enUS = {
|
|
|
4908
4916
|
};
|
|
4909
4917
|
const jaJP = {
|
|
4910
4918
|
toolbar: {
|
|
4919
|
+
refresh: "更新",
|
|
4911
4920
|
create: "新規作成",
|
|
4912
4921
|
import: "インポート",
|
|
4913
4922
|
export: "エクスポート",
|
|
@@ -4974,6 +4983,7 @@ const jaJP = {
|
|
|
4974
4983
|
};
|
|
4975
4984
|
const koKR = {
|
|
4976
4985
|
toolbar: {
|
|
4986
|
+
refresh: "새로고침",
|
|
4977
4987
|
create: "새로 만들기",
|
|
4978
4988
|
import: "가져오기",
|
|
4979
4989
|
export: "내보내기",
|
|
@@ -5040,6 +5050,7 @@ const koKR = {
|
|
|
5040
5050
|
};
|
|
5041
5051
|
const frFR = {
|
|
5042
5052
|
toolbar: {
|
|
5053
|
+
refresh: "Actualiser",
|
|
5043
5054
|
create: "Nouveau",
|
|
5044
5055
|
import: "Importer",
|
|
5045
5056
|
export: "Exporter",
|
|
@@ -5106,6 +5117,7 @@ const frFR = {
|
|
|
5106
5117
|
};
|
|
5107
5118
|
const deDE = {
|
|
5108
5119
|
toolbar: {
|
|
5120
|
+
refresh: "Aktualisieren",
|
|
5109
5121
|
create: "Neu",
|
|
5110
5122
|
import: "Importieren",
|
|
5111
5123
|
export: "Exportieren",
|
|
@@ -5172,6 +5184,7 @@ const deDE = {
|
|
|
5172
5184
|
};
|
|
5173
5185
|
const esES = {
|
|
5174
5186
|
toolbar: {
|
|
5187
|
+
refresh: "Actualizar",
|
|
5175
5188
|
create: "Nuevo",
|
|
5176
5189
|
import: "Importar",
|
|
5177
5190
|
export: "Exportar",
|
|
@@ -5744,6 +5757,7 @@ function setToolbarResolver(resolver) {
|
|
|
5744
5757
|
}
|
|
5745
5758
|
function getDefaultToolbarActions() {
|
|
5746
5759
|
return [
|
|
5760
|
+
{ type: "refresh" },
|
|
5747
5761
|
{ type: "import" },
|
|
5748
5762
|
{ type: "export" },
|
|
5749
5763
|
{ type: "create" }
|
|
@@ -6492,6 +6506,8 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6492
6506
|
rowIds,
|
|
6493
6507
|
selectedRowIds,
|
|
6494
6508
|
selectedCount,
|
|
6509
|
+
isRefreshing: resource.tableData.isFetching,
|
|
6510
|
+
...resource.handlers.refresh ? { refresh: resource.handlers.refresh } : {},
|
|
6495
6511
|
...toolbarOpenCreate ? { openCreate: toolbarOpenCreate } : {}
|
|
6496
6512
|
}), [
|
|
6497
6513
|
id,
|
|
@@ -6499,6 +6515,8 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6499
6515
|
rowIds,
|
|
6500
6516
|
selectedRowIds,
|
|
6501
6517
|
selectedCount,
|
|
6518
|
+
resource.handlers.refresh,
|
|
6519
|
+
resource.tableData.isFetching,
|
|
6502
6520
|
toolbarOpenCreate
|
|
6503
6521
|
]);
|
|
6504
6522
|
const resolvedToolbarActions = resolveToolbarActionsWithResolver(id, registryToolbarActions, toolbarContext);
|
|
@@ -6612,6 +6630,20 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6612
6630
|
className: "flex items-center justify-end gap-4",
|
|
6613
6631
|
children: (() => {
|
|
6614
6632
|
const renderBuiltinButton = (type, overrides) => {
|
|
6633
|
+
if (type === "refresh") {
|
|
6634
|
+
const onRefresh = overrides?.onClick ?? resource.handlers.refresh;
|
|
6635
|
+
const label = overrides?.label ?? locale.toolbar.refresh;
|
|
6636
|
+
if (!onRefresh) return null;
|
|
6637
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
6638
|
+
variant: "outline",
|
|
6639
|
+
size: "icon-sm",
|
|
6640
|
+
"aria-label": label,
|
|
6641
|
+
title: label,
|
|
6642
|
+
onClick: onRefresh,
|
|
6643
|
+
disabled: resource.tableData.isFetching,
|
|
6644
|
+
children: /* @__PURE__ */ jsx(RefreshCw, { className: resource.tableData.isFetching ? "h-4 w-4 animate-spin" : "h-4 w-4" })
|
|
6645
|
+
}, "refresh");
|
|
6646
|
+
}
|
|
6615
6647
|
if (type === "import" && canImport) return /* @__PURE__ */ jsxs(Button, {
|
|
6616
6648
|
variant: "outline",
|
|
6617
6649
|
size: "sm",
|
|
@@ -6640,6 +6672,7 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6640
6672
|
className: "flex items-center gap-2",
|
|
6641
6673
|
children: [
|
|
6642
6674
|
startNodes,
|
|
6675
|
+
renderBuiltinButton("refresh"),
|
|
6643
6676
|
renderBuiltinButton("import"),
|
|
6644
6677
|
renderBuiltinButton("export"),
|
|
6645
6678
|
renderBuiltinButton("create"),
|
|
@@ -6651,7 +6684,14 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
|
|
|
6651
6684
|
className: "flex items-center gap-2",
|
|
6652
6685
|
children: resolvedToolbarActions.map((action$1, index$1) => {
|
|
6653
6686
|
if (action$1.type === "custom") return /* @__PURE__ */ jsx(React.Fragment, { children: renderToolbarComponent(action$1.component) }, `custom-${index$1}`);
|
|
6654
|
-
if (!(
|
|
6687
|
+
if (!(() => {
|
|
6688
|
+
switch (action$1.type) {
|
|
6689
|
+
case "refresh": return !!(resource.handlers.refresh || action$1.onClick || action$1.component);
|
|
6690
|
+
case "import": return canImport;
|
|
6691
|
+
case "export": return canExport;
|
|
6692
|
+
case "create": return can.create;
|
|
6693
|
+
}
|
|
6694
|
+
})()) return null;
|
|
6655
6695
|
if (action$1.component) return /* @__PURE__ */ jsx(React.Fragment, { children: renderToolbarComponent(action$1.component) }, action$1.type);
|
|
6656
6696
|
return renderBuiltinButton(action$1.type, {
|
|
6657
6697
|
onClick: action$1.onClick,
|
|
@@ -6836,11 +6876,15 @@ function DataTableFacetedFilter({ column, title, options, multiple }) {
|
|
|
6836
6876
|
const onChange = (nextValues) => {
|
|
6837
6877
|
column?.setFilterValue(nextValues.length ? nextValues : void 0);
|
|
6838
6878
|
};
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6879
|
+
const onSelectChange = (nextValue) => {
|
|
6880
|
+
onChange(Array.isArray(nextValue) ? nextValue : nextValue ? [nextValue] : []);
|
|
6881
|
+
};
|
|
6882
|
+
return /* @__PURE__ */ jsx(Select$2, {
|
|
6883
|
+
mode: "searchable",
|
|
6884
|
+
multiple: Boolean(multiple),
|
|
6885
|
+
value: multiple ? selectedValues : selectedValues[0] ?? "",
|
|
6886
|
+
onChange: onSelectChange,
|
|
6842
6887
|
options: comboboxOptions,
|
|
6843
|
-
selectionMode: multiple ? "multiple" : "single",
|
|
6844
6888
|
searchPlaceholder: title,
|
|
6845
6889
|
hasMore: column?.columnDef.meta?.autoCrudFilterHasMore,
|
|
6846
6890
|
loading: column?.columnDef.meta?.autoCrudFilterLoading,
|
|
@@ -7763,6 +7807,9 @@ function useAutoCrudResource({ router, schema, query: queryTransform, options =
|
|
|
7763
7807
|
queryInput
|
|
7764
7808
|
]);
|
|
7765
7809
|
const canExport = !!(exportFetcher || exportQuery);
|
|
7810
|
+
const refresh = useCallback(async () => {
|
|
7811
|
+
return listQuery.refetch();
|
|
7812
|
+
}, [listQuery]);
|
|
7766
7813
|
return {
|
|
7767
7814
|
idKey,
|
|
7768
7815
|
tableData: {
|
|
@@ -7793,6 +7840,7 @@ function useAutoCrudResource({ router, schema, query: queryTransform, options =
|
|
|
7793
7840
|
deleteMany,
|
|
7794
7841
|
updateMany,
|
|
7795
7842
|
setVariant,
|
|
7843
|
+
refresh,
|
|
7796
7844
|
import: importMutation ? handleImport : null,
|
|
7797
7845
|
export: canExport ? handleExport : null
|
|
7798
7846
|
}
|
|
@@ -8104,4 +8152,4 @@ function createMemoryDataSource(initialData = []) {
|
|
|
8104
8152
|
}
|
|
8105
8153
|
|
|
8106
8154
|
//#endregion
|
|
8107
|
-
export { AutoCrudTable, AutoForm, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, CrudFormModal, DataTable, DataTableAdvancedToolbar, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableToolbar, DataTableViewOptions, ExportDialog, ImportDialog, MultiCombobox, SchemaAdapter, 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 };
|
|
8155
|
+
export { AutoCrudTable, AutoForm, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, CrudFormModal, DataTable, DataTableAdvancedToolbar, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableToolbar, DataTableViewOptions, ExportDialog, ImportDialog, MultiCombobox, SchemaAdapter, Select, cn, coerceRowValues, components, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, crudActions, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, resolveLocale, setSearchParams, setToolbarResolver, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordrhyme/auto-crud",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.3",
|
|
5
5
|
"description": "Schema-first CRUD components with auto-generated tables and forms",
|
|
6
6
|
"author": "wordrhyme",
|
|
7
7
|
"license": "MIT",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"tailwind-merge": "^3.5.0",
|
|
64
64
|
"vaul": "^1.1.2",
|
|
65
65
|
"@wordrhyme/shadcn": "1.3.2",
|
|
66
|
-
"@wordrhyme/shadcn
|
|
67
|
-
"@wordrhyme/
|
|
66
|
+
"@wordrhyme/formily-shadcn": "1.12.9",
|
|
67
|
+
"@wordrhyme/shadcn-ui": "1.32.2"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@tanstack/react-query": "^5.90.15",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"typescript": "^5.9.3",
|
|
84
84
|
"vitest": "^3.2.4",
|
|
85
85
|
"@internal/eslint-config": "0.3.0",
|
|
86
|
-
"@internal/prettier-config": "0.0.1",
|
|
87
86
|
"@internal/tsconfig": "0.1.0",
|
|
87
|
+
"@internal/prettier-config": "0.0.1",
|
|
88
88
|
"@internal/tsdown-config": "0.1.0",
|
|
89
89
|
"@internal/vitest-config": "0.1.0"
|
|
90
90
|
},
|