@wordrhyme/auto-crud 1.1.4 → 1.1.6
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 +75 -26
- package/dist/index.d.cts +20 -18
- package/dist/index.d.ts +20 -18
- package/dist/index.js +75 -26
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1065,6 +1065,7 @@ function FacetedItem(props) {
|
|
|
1065
1065
|
else if (context.onItemSelect) context.onItemSelect(currentValue);
|
|
1066
1066
|
}, [onSelect, context]);
|
|
1067
1067
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.CommandItem, {
|
|
1068
|
+
value,
|
|
1068
1069
|
"aria-selected": isSelected,
|
|
1069
1070
|
"data-selected": isSelected,
|
|
1070
1071
|
className: cn("gap-2", className),
|
|
@@ -1458,6 +1459,7 @@ function DataTableFilterList({ table, debounceMs = DEBOUNCE_MS$2, throttleMs = T
|
|
|
1458
1459
|
const descriptionId = react.useId();
|
|
1459
1460
|
const [open, setOpen] = react.useState(false);
|
|
1460
1461
|
const addButtonRef = react.useRef(null);
|
|
1462
|
+
const columnDefs = table.options.columns;
|
|
1461
1463
|
const columns = react.useMemo(() => {
|
|
1462
1464
|
return table.getAllColumns().filter((column) => {
|
|
1463
1465
|
if (!column.getCanFilter()) return false;
|
|
@@ -1465,7 +1467,7 @@ function DataTableFilterList({ table, debounceMs = DEBOUNCE_MS$2, throttleMs = T
|
|
|
1465
1467
|
if (modes && !modes.includes("advanced")) return false;
|
|
1466
1468
|
return true;
|
|
1467
1469
|
});
|
|
1468
|
-
}, [table]);
|
|
1470
|
+
}, [table, columnDefs]);
|
|
1469
1471
|
const [filters, setFilters] = useReadableFilters(columns, { debounceMs });
|
|
1470
1472
|
const debouncedSetFilters = useDebouncedCallback(setFilters, debounceMs);
|
|
1471
1473
|
const [joinOperator, setJoinOperator] = useQueryState(table.options.meta?.queryKeys?.joinOperator ?? "", parseAsStringEnum(["and", "or"]).withDefault("and"));
|
|
@@ -1943,8 +1945,16 @@ const DEBOUNCE_MS$1 = 300;
|
|
|
1943
1945
|
const THROTTLE_MS$1 = 50;
|
|
1944
1946
|
const FILTER_SHORTCUT_KEY = "f";
|
|
1945
1947
|
const REMOVE_FILTER_SHORTCUTS = ["backspace", "delete"];
|
|
1948
|
+
function getOptionCommandValue$2(option) {
|
|
1949
|
+
return [
|
|
1950
|
+
option.value,
|
|
1951
|
+
option.label,
|
|
1952
|
+
option.searchText
|
|
1953
|
+
].filter(Boolean).join(" ");
|
|
1954
|
+
}
|
|
1946
1955
|
function DataTableFilterMenu({ table, debounceMs = DEBOUNCE_MS$1, throttleMs = THROTTLE_MS$1, shallow = true, disabled,...props }) {
|
|
1947
1956
|
const id = react.useId();
|
|
1957
|
+
const columnDefs = table.options.columns;
|
|
1948
1958
|
const columns = react.useMemo(() => {
|
|
1949
1959
|
return table.getAllColumns().filter((column) => {
|
|
1950
1960
|
if (!column.columnDef.enableColumnFilter) return false;
|
|
@@ -1952,7 +1962,7 @@ function DataTableFilterMenu({ table, debounceMs = DEBOUNCE_MS$1, throttleMs = T
|
|
|
1952
1962
|
if (modes && !modes.includes("command")) return false;
|
|
1953
1963
|
return true;
|
|
1954
1964
|
});
|
|
1955
|
-
}, [table]);
|
|
1965
|
+
}, [table, columnDefs]);
|
|
1956
1966
|
const [open, setOpen] = react.useState(false);
|
|
1957
1967
|
const [selectedColumn, setSelectedColumn] = react.useState(null);
|
|
1958
1968
|
const [inputValue, setInputValue] = react.useState("");
|
|
@@ -2221,7 +2231,7 @@ function FilterValueSelector({ column, value, onSelect }) {
|
|
|
2221
2231
|
})] });
|
|
2222
2232
|
case "select":
|
|
2223
2233
|
case "multiSelect": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.CommandGroup, { children: column.columnDef.meta?.options?.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.CommandItem, {
|
|
2224
|
-
value: option
|
|
2234
|
+
value: getOptionCommandValue$2(option),
|
|
2225
2235
|
onSelect: () => onSelect(option.value),
|
|
2226
2236
|
children: [
|
|
2227
2237
|
option.icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(option.icon, {}),
|
|
@@ -2348,7 +2358,7 @@ function onFilterInputRender({ filter, column, inputId, onFilterUpdate, showValu
|
|
|
2348
2358
|
align: "start",
|
|
2349
2359
|
className: "w-48 p-0",
|
|
2350
2360
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Command, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.CommandInput, { placeholder: "Search options..." }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.CommandList, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.CommandEmpty, { children: "No options found." }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.CommandGroup, { children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.CommandItem, {
|
|
2351
|
-
value: option
|
|
2361
|
+
value: getOptionCommandValue$2(option),
|
|
2352
2362
|
onSelect: () => {
|
|
2353
2363
|
const value = filter.variant === "multiSelect" ? selectedValues.includes(option.value) ? selectedValues.filter((v) => v !== option.value) : [...selectedValues, option.value] : option.value;
|
|
2354
2364
|
onFilterUpdate(filter.filterId, { value });
|
|
@@ -2708,6 +2718,7 @@ function DataTableViewOptions({ table, disabled,...props }) {
|
|
|
2708
2718
|
//#endregion
|
|
2709
2719
|
//#region src/components/auto-crud/auto-table-simple-filters.tsx
|
|
2710
2720
|
function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilters, onFiltersChange, leading }) {
|
|
2721
|
+
const columnDefs = table.options.columns;
|
|
2711
2722
|
const columns = react.useMemo(() => table.getAllColumns().filter((col) => col.getCanFilter()).sort((a, b) => {
|
|
2712
2723
|
const readOrder = (column) => {
|
|
2713
2724
|
const metaIndex = column.columnDef.meta?.index;
|
|
@@ -2717,7 +2728,7 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
|
|
|
2717
2728
|
const orderDiff = readOrder(a) - readOrder(b);
|
|
2718
2729
|
if (orderDiff !== 0) return orderDiff;
|
|
2719
2730
|
return a.getIndex() - b.getIndex();
|
|
2720
|
-
}), [table]);
|
|
2731
|
+
}), [table, columnDefs]);
|
|
2721
2732
|
const queryStateOptions = table.options.meta?.queryStateOptions;
|
|
2722
2733
|
const [queryFilters, setQueryFilters] = useReadableFilters(columns, {
|
|
2723
2734
|
...queryStateOptions,
|
|
@@ -2951,6 +2962,13 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
|
|
|
2951
2962
|
]
|
|
2952
2963
|
});
|
|
2953
2964
|
}
|
|
2965
|
+
function getOptionCommandValue$1(option) {
|
|
2966
|
+
return [
|
|
2967
|
+
option.value,
|
|
2968
|
+
option.label,
|
|
2969
|
+
option.searchText
|
|
2970
|
+
].filter(Boolean).join(" ");
|
|
2971
|
+
}
|
|
2954
2972
|
function SimpleFacetedFilter({ title, options, multiple, value, onChange }) {
|
|
2955
2973
|
const [open, setOpen] = react.useState(false);
|
|
2956
2974
|
const selectedValues = react.useMemo(() => new Set(value), [value]);
|
|
@@ -3030,6 +3048,7 @@ function SimpleFacetedFilter({ title, options, multiple, value, onChange }) {
|
|
|
3030
3048
|
children: options.map((option) => {
|
|
3031
3049
|
const isSelected = selectedValues.has(option.value);
|
|
3032
3050
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.CommandItem, {
|
|
3051
|
+
value: getOptionCommandValue$1(option),
|
|
3033
3052
|
onSelect: () => onItemSelect(option, isSelected),
|
|
3034
3053
|
children: [
|
|
3035
3054
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -4741,25 +4760,27 @@ function AutoTable({ schema, data, pageCount = 1, overrides, enableRowSelection
|
|
|
4741
4760
|
clearOnDefault: true
|
|
4742
4761
|
});
|
|
4743
4762
|
const searchConfig = search && typeof search === "object" ? search : {};
|
|
4763
|
+
const enableAdvancedFilter = true;
|
|
4764
|
+
const columns = (0, react.useMemo)(() => {
|
|
4765
|
+
const dataColumns = createTableSchema(schema, {
|
|
4766
|
+
overrides,
|
|
4767
|
+
exclude
|
|
4768
|
+
});
|
|
4769
|
+
const result = enableRowSelection ? [createSelectColumn(), ...dataColumns] : dataColumns;
|
|
4770
|
+
if (actions) result.push(createActionsColumn(actions));
|
|
4771
|
+
return result;
|
|
4772
|
+
}, [
|
|
4773
|
+
schema,
|
|
4774
|
+
overrides,
|
|
4775
|
+
enableRowSelection,
|
|
4776
|
+
exclude,
|
|
4777
|
+
actions
|
|
4778
|
+
]);
|
|
4744
4779
|
const { table, shallow, debounceMs, throttleMs } = useDataTable({
|
|
4745
4780
|
data,
|
|
4746
|
-
columns
|
|
4747
|
-
const dataColumns = createTableSchema(schema, {
|
|
4748
|
-
overrides,
|
|
4749
|
-
exclude
|
|
4750
|
-
});
|
|
4751
|
-
const result = enableRowSelection ? [createSelectColumn(), ...dataColumns] : dataColumns;
|
|
4752
|
-
if (actions) result.push(createActionsColumn(actions));
|
|
4753
|
-
return result;
|
|
4754
|
-
}, [
|
|
4755
|
-
schema,
|
|
4756
|
-
overrides,
|
|
4757
|
-
enableRowSelection,
|
|
4758
|
-
exclude,
|
|
4759
|
-
actions
|
|
4760
|
-
]),
|
|
4781
|
+
columns,
|
|
4761
4782
|
pageCount,
|
|
4762
|
-
enableAdvancedFilter
|
|
4783
|
+
enableAdvancedFilter,
|
|
4763
4784
|
initialState: (0, react.useMemo)(() => ({
|
|
4764
4785
|
sorting: initialSorting,
|
|
4765
4786
|
columnPinning: pinnedColumns ?? {
|
|
@@ -4845,6 +4866,7 @@ function AutoTable({ schema, data, pageCount = 1, overrides, enableRowSelection
|
|
|
4845
4866
|
}, [
|
|
4846
4867
|
currentMode,
|
|
4847
4868
|
table,
|
|
4869
|
+
columns,
|
|
4848
4870
|
shallow,
|
|
4849
4871
|
searchInput,
|
|
4850
4872
|
debounceMs,
|
|
@@ -5054,7 +5076,7 @@ function createEditFormSchema(schema, options) {
|
|
|
5054
5076
|
|
|
5055
5077
|
//#endregion
|
|
5056
5078
|
//#region src/components/auto-crud/auto-form.tsx
|
|
5057
|
-
const COMBOBOX_LIST_CLASS = "[&_[cmdk-list]]:max-h-[360px]";
|
|
5079
|
+
const COMBOBOX_LIST_CLASS = "[&_[cmdk-list]]:max-h-[360px] [&_[cmdk-list]]:overflow-x-hidden [&_[cmdk-list]]:overflow-y-auto";
|
|
5058
5080
|
const FormilySwitch = (0, __formily_react.connect)(__pixpilot_shadcn.Switch, (0, __formily_react.mapProps)({
|
|
5059
5081
|
value: "checked",
|
|
5060
5082
|
onInput: "onCheckedChange"
|
|
@@ -5926,6 +5948,28 @@ function ImportDialog({ open, onOpenChange, onImport, columns = [], title, local
|
|
|
5926
5948
|
|
|
5927
5949
|
//#endregion
|
|
5928
5950
|
//#region src/components/auto-crud/auto-crud-table.tsx
|
|
5951
|
+
function mergeFieldPart(base, override) {
|
|
5952
|
+
if (override === void 0) return base;
|
|
5953
|
+
if (override === false || base === false || typeof base !== "object" || typeof override !== "object" || base === null || override === null || Array.isArray(base) || Array.isArray(override)) return override;
|
|
5954
|
+
return {
|
|
5955
|
+
...base,
|
|
5956
|
+
...override
|
|
5957
|
+
};
|
|
5958
|
+
}
|
|
5959
|
+
function mergeFieldConfig(base, override) {
|
|
5960
|
+
return {
|
|
5961
|
+
...base,
|
|
5962
|
+
...override,
|
|
5963
|
+
table: mergeFieldPart(base?.table, override?.table),
|
|
5964
|
+
filter: mergeFieldPart(base?.filter, override?.filter),
|
|
5965
|
+
form: mergeFieldPart(base?.form, override?.form)
|
|
5966
|
+
};
|
|
5967
|
+
}
|
|
5968
|
+
function mergeFields(base, override) {
|
|
5969
|
+
if (!base && !override) return void 0;
|
|
5970
|
+
const keys = new Set([...Object.keys(base ?? {}), ...Object.keys(override ?? {})]);
|
|
5971
|
+
return Object.fromEntries(Array.from(keys).map((key) => [key, mergeFieldConfig(base?.[key], override?.[key])]));
|
|
5972
|
+
}
|
|
5929
5973
|
/**
|
|
5930
5974
|
* 从统一配置生成表格 overrides
|
|
5931
5975
|
* 当 filter 配置存在时,合并到 meta 中(不影响列隐藏)
|
|
@@ -6218,10 +6262,7 @@ function resolveActions(actionsOrFn, defaults, rowActionsLocale) {
|
|
|
6218
6262
|
function AutoCrudTable({ title, description, schema, resource, fields, table: tableConfig, form: formConfig, permissions, actions: actionItems, toolbarActions, locale: localeProp, onCreate }) {
|
|
6219
6263
|
const locale = resolveLocale(localeProp);
|
|
6220
6264
|
const resolvedSchema = resource.schema ?? schema;
|
|
6221
|
-
const resolvedFields = react.useMemo(() => ({
|
|
6222
|
-
...fields,
|
|
6223
|
-
...resource.fields
|
|
6224
|
-
}), [fields, resource.fields]);
|
|
6265
|
+
const resolvedFields = react.useMemo(() => mergeFields(resource.fields, fields) ?? {}, [fields, resource.fields]);
|
|
6225
6266
|
const can = {
|
|
6226
6267
|
create: permissions?.can?.create ?? true,
|
|
6227
6268
|
update: permissions?.can?.update ?? true,
|
|
@@ -6545,6 +6586,13 @@ function DataTableAdvancedToolbar({ table, children, className,...props }) {
|
|
|
6545
6586
|
|
|
6546
6587
|
//#endregion
|
|
6547
6588
|
//#region src/components/data-table/data-table-faceted-filter.tsx
|
|
6589
|
+
function getOptionCommandValue(option) {
|
|
6590
|
+
return [
|
|
6591
|
+
option.value,
|
|
6592
|
+
option.label,
|
|
6593
|
+
option.searchText
|
|
6594
|
+
].filter(Boolean).join(" ");
|
|
6595
|
+
}
|
|
6548
6596
|
function DataTableFacetedFilter({ column, title, options, multiple }) {
|
|
6549
6597
|
const [open, setOpen] = react.useState(false);
|
|
6550
6598
|
const columnFilterValue = column?.getFilterValue();
|
|
@@ -6626,6 +6674,7 @@ function DataTableFacetedFilter({ column, title, options, multiple }) {
|
|
|
6626
6674
|
children: options.map((option) => {
|
|
6627
6675
|
const isSelected = selectedValues.has(option.value);
|
|
6628
6676
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.CommandItem, {
|
|
6677
|
+
value: getOptionCommandValue(option),
|
|
6629
6678
|
onSelect: () => onItemSelect(option, isSelected),
|
|
6630
6679
|
children: [
|
|
6631
6680
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime7 from "react/jsx-runtime";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import * as _tanstack_react_table0 from "@tanstack/react-table";
|
|
4
4
|
import { Column, ColumnDef, ColumnSort, Row, RowData, Table, TableOptions, TableState } from "@tanstack/react-table";
|
|
@@ -361,7 +361,7 @@ declare function AutoTableActionBar<TData>({
|
|
|
361
361
|
enableDelete,
|
|
362
362
|
extraActions,
|
|
363
363
|
actions
|
|
364
|
-
}: AutoTableActionBarProps<TData>):
|
|
364
|
+
}: AutoTableActionBarProps<TData>): react_jsx_runtime7.JSX.Element;
|
|
365
365
|
//#endregion
|
|
366
366
|
//#region src/lib/schema-bridge/types.d.ts
|
|
367
367
|
/**
|
|
@@ -529,7 +529,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
529
529
|
showDefaultExport,
|
|
530
530
|
onSelectedCountChange,
|
|
531
531
|
getSelectedRows
|
|
532
|
-
}: AutoTableProps<T>):
|
|
532
|
+
}: AutoTableProps<T>): react_jsx_runtime7.JSX.Element;
|
|
533
533
|
//#endregion
|
|
534
534
|
//#region src/i18n/locale.d.ts
|
|
535
535
|
/**
|
|
@@ -635,6 +635,7 @@ interface FilterConfig {
|
|
|
635
635
|
options?: Array<{
|
|
636
636
|
label: string;
|
|
637
637
|
value: string;
|
|
638
|
+
searchText?: string;
|
|
638
639
|
count?: number;
|
|
639
640
|
icon?: React$1.FC<React$1.SVGProps<SVGSVGElement>>;
|
|
640
641
|
}>;
|
|
@@ -874,7 +875,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
874
875
|
toolbarActions,
|
|
875
876
|
locale: localeProp,
|
|
876
877
|
onCreate
|
|
877
|
-
}: AutoCrudTableProps<TSchema>):
|
|
878
|
+
}: AutoCrudTableProps<TSchema>): react_jsx_runtime7.JSX.Element;
|
|
878
879
|
//#endregion
|
|
879
880
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
880
881
|
interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
@@ -882,11 +883,11 @@ interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
|
882
883
|
initialValues?: Partial<z.infer<T>>;
|
|
883
884
|
onSubmit: (values: z.infer<T>) => void | Promise<void>;
|
|
884
885
|
overrides?: FormSchemaOverrides;
|
|
885
|
-
mode?:
|
|
886
|
+
mode?: 'create' | 'edit';
|
|
886
887
|
loading?: boolean;
|
|
887
888
|
gridColumns?: number;
|
|
888
889
|
/** Label 对齐方式 */
|
|
889
|
-
labelAlign?:
|
|
890
|
+
labelAlign?: 'left' | 'top' | 'right';
|
|
890
891
|
/** Label 宽度(labelAlign 为 left 时有效) */
|
|
891
892
|
labelWidth?: number | string;
|
|
892
893
|
/** 是否显示提交按钮(默认 true) */
|
|
@@ -906,7 +907,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
906
907
|
labelAlign,
|
|
907
908
|
labelWidth,
|
|
908
909
|
showSubmitButton
|
|
909
|
-
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>):
|
|
910
|
+
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime7.JSX.Element;
|
|
910
911
|
declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
|
|
911
912
|
ref?: React.Ref<AutoFormRef>;
|
|
912
913
|
}) => ReturnType<typeof AutoFormInner>;
|
|
@@ -1176,6 +1177,7 @@ interface QueryKeys {
|
|
|
1176
1177
|
interface Option {
|
|
1177
1178
|
label: string;
|
|
1178
1179
|
value: string;
|
|
1180
|
+
searchText?: string;
|
|
1179
1181
|
count?: number;
|
|
1180
1182
|
icon?: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
1181
1183
|
}
|
|
@@ -1207,7 +1209,7 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
1207
1209
|
filters: externalFilters,
|
|
1208
1210
|
onFiltersChange,
|
|
1209
1211
|
leading
|
|
1210
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
1212
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime7.JSX.Element | null;
|
|
1211
1213
|
//#endregion
|
|
1212
1214
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
1213
1215
|
type ModalVariant = "dialog" | "sheet";
|
|
@@ -1249,7 +1251,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1249
1251
|
labelAlign,
|
|
1250
1252
|
labelWidth,
|
|
1251
1253
|
className
|
|
1252
|
-
}: CrudFormModalProps<T>):
|
|
1254
|
+
}: CrudFormModalProps<T>): react_jsx_runtime7.JSX.Element;
|
|
1253
1255
|
//#endregion
|
|
1254
1256
|
//#region src/components/auto-crud/import-dialog.d.ts
|
|
1255
1257
|
interface ImportDialogProps {
|
|
@@ -1271,7 +1273,7 @@ declare function ImportDialog({
|
|
|
1271
1273
|
columns,
|
|
1272
1274
|
title,
|
|
1273
1275
|
locale
|
|
1274
|
-
}: ImportDialogProps):
|
|
1276
|
+
}: ImportDialogProps): react_jsx_runtime7.JSX.Element;
|
|
1275
1277
|
//#endregion
|
|
1276
1278
|
//#region src/components/auto-crud/export-dialog.d.ts
|
|
1277
1279
|
type ExportMode = "selected" | "filtered";
|
|
@@ -1291,7 +1293,7 @@ declare function ExportDialog({
|
|
|
1291
1293
|
selectedCount,
|
|
1292
1294
|
onExport,
|
|
1293
1295
|
canExportFiltered
|
|
1294
|
-
}: ExportDialogProps):
|
|
1296
|
+
}: ExportDialogProps): react_jsx_runtime7.JSX.Element;
|
|
1295
1297
|
//#endregion
|
|
1296
1298
|
//#region src/components/data-table/data-table.d.ts
|
|
1297
1299
|
interface DataTableProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1304,7 +1306,7 @@ declare function DataTable<TData>({
|
|
|
1304
1306
|
children,
|
|
1305
1307
|
className,
|
|
1306
1308
|
...props
|
|
1307
|
-
}: DataTableProps<TData>):
|
|
1309
|
+
}: DataTableProps<TData>): react_jsx_runtime7.JSX.Element;
|
|
1308
1310
|
//#endregion
|
|
1309
1311
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
1310
1312
|
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1315,7 +1317,7 @@ declare function DataTableAdvancedToolbar<TData>({
|
|
|
1315
1317
|
children,
|
|
1316
1318
|
className,
|
|
1317
1319
|
...props
|
|
1318
|
-
}: DataTableAdvancedToolbarProps<TData>):
|
|
1320
|
+
}: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime7.JSX.Element;
|
|
1319
1321
|
//#endregion
|
|
1320
1322
|
//#region src/components/data-table/data-table-column-header.d.ts
|
|
1321
1323
|
interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
|
|
@@ -1327,7 +1329,7 @@ declare function DataTableColumnHeader<TData, TValue>({
|
|
|
1327
1329
|
label,
|
|
1328
1330
|
className,
|
|
1329
1331
|
...props
|
|
1330
|
-
}: DataTableColumnHeaderProps<TData, TValue>):
|
|
1332
|
+
}: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime7.JSX.Element;
|
|
1331
1333
|
//#endregion
|
|
1332
1334
|
//#region src/components/data-table/data-table-faceted-filter.d.ts
|
|
1333
1335
|
interface DataTableFacetedFilterProps<TData, TValue> {
|
|
@@ -1341,7 +1343,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
1341
1343
|
title,
|
|
1342
1344
|
options,
|
|
1343
1345
|
multiple
|
|
1344
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
1346
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime7.JSX.Element;
|
|
1345
1347
|
//#endregion
|
|
1346
1348
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
1347
1349
|
interface DataTablePaginationProps<TData> extends React.ComponentProps<"div"> {
|
|
@@ -1353,7 +1355,7 @@ declare function DataTablePagination<TData>({
|
|
|
1353
1355
|
pageSizeOptions,
|
|
1354
1356
|
className,
|
|
1355
1357
|
...props
|
|
1356
|
-
}: DataTablePaginationProps<TData>):
|
|
1358
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime7.JSX.Element;
|
|
1357
1359
|
//#endregion
|
|
1358
1360
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
1359
1361
|
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1364,7 +1366,7 @@ declare function DataTableToolbar<TData>({
|
|
|
1364
1366
|
children,
|
|
1365
1367
|
className,
|
|
1366
1368
|
...props
|
|
1367
|
-
}: DataTableToolbarProps<TData>):
|
|
1369
|
+
}: DataTableToolbarProps<TData>): react_jsx_runtime7.JSX.Element;
|
|
1368
1370
|
//#endregion
|
|
1369
1371
|
//#region src/components/data-table/data-table-view-options.d.ts
|
|
1370
1372
|
interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
|
|
@@ -1375,7 +1377,7 @@ declare function DataTableViewOptions<TData>({
|
|
|
1375
1377
|
table,
|
|
1376
1378
|
disabled,
|
|
1377
1379
|
...props
|
|
1378
|
-
}: DataTableViewOptionsProps<TData>):
|
|
1380
|
+
}: DataTableViewOptionsProps<TData>): react_jsx_runtime7.JSX.Element;
|
|
1379
1381
|
//#endregion
|
|
1380
1382
|
//#region src/hooks/use-data-table.d.ts
|
|
1381
1383
|
interface UseDataTableProps<TData> extends Omit<TableOptions<TData>, "state" | "pageCount" | "getCoreRowModel" | "manualFiltering" | "manualPagination" | "manualSorting">, Required<Pick<TableOptions<TData>, "pageCount">> {
|
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 "@pixpilot/shadcn";
|
|
5
5
|
import { ClassValue } from "clsx";
|
|
6
|
-
import * as
|
|
6
|
+
import * as react_jsx_runtime3 from "react/jsx-runtime";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import { ISchema } from "@formily/json-schema";
|
|
9
9
|
|
|
@@ -361,7 +361,7 @@ declare function AutoTableActionBar<TData>({
|
|
|
361
361
|
enableDelete,
|
|
362
362
|
extraActions,
|
|
363
363
|
actions
|
|
364
|
-
}: AutoTableActionBarProps<TData>):
|
|
364
|
+
}: AutoTableActionBarProps<TData>): react_jsx_runtime3.JSX.Element;
|
|
365
365
|
//#endregion
|
|
366
366
|
//#region src/lib/schema-bridge/types.d.ts
|
|
367
367
|
/**
|
|
@@ -529,7 +529,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
529
529
|
showDefaultExport,
|
|
530
530
|
onSelectedCountChange,
|
|
531
531
|
getSelectedRows
|
|
532
|
-
}: AutoTableProps<T>):
|
|
532
|
+
}: AutoTableProps<T>): react_jsx_runtime3.JSX.Element;
|
|
533
533
|
//#endregion
|
|
534
534
|
//#region src/i18n/locale.d.ts
|
|
535
535
|
/**
|
|
@@ -635,6 +635,7 @@ interface FilterConfig {
|
|
|
635
635
|
options?: Array<{
|
|
636
636
|
label: string;
|
|
637
637
|
value: string;
|
|
638
|
+
searchText?: string;
|
|
638
639
|
count?: number;
|
|
639
640
|
icon?: React$1.FC<React$1.SVGProps<SVGSVGElement>>;
|
|
640
641
|
}>;
|
|
@@ -874,7 +875,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
|
|
|
874
875
|
toolbarActions,
|
|
875
876
|
locale: localeProp,
|
|
876
877
|
onCreate
|
|
877
|
-
}: AutoCrudTableProps<TSchema>):
|
|
878
|
+
}: AutoCrudTableProps<TSchema>): react_jsx_runtime3.JSX.Element;
|
|
878
879
|
//#endregion
|
|
879
880
|
//#region src/components/auto-crud/auto-form.d.ts
|
|
880
881
|
interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
@@ -882,11 +883,11 @@ interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
|
|
|
882
883
|
initialValues?: Partial<z.infer<T>>;
|
|
883
884
|
onSubmit: (values: z.infer<T>) => void | Promise<void>;
|
|
884
885
|
overrides?: FormSchemaOverrides;
|
|
885
|
-
mode?:
|
|
886
|
+
mode?: 'create' | 'edit';
|
|
886
887
|
loading?: boolean;
|
|
887
888
|
gridColumns?: number;
|
|
888
889
|
/** Label 对齐方式 */
|
|
889
|
-
labelAlign?:
|
|
890
|
+
labelAlign?: 'left' | 'top' | 'right';
|
|
890
891
|
/** Label 宽度(labelAlign 为 left 时有效) */
|
|
891
892
|
labelWidth?: number | string;
|
|
892
893
|
/** 是否显示提交按钮(默认 true) */
|
|
@@ -906,7 +907,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
906
907
|
labelAlign,
|
|
907
908
|
labelWidth,
|
|
908
909
|
showSubmitButton
|
|
909
|
-
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>):
|
|
910
|
+
}: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime3.JSX.Element;
|
|
910
911
|
declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
|
|
911
912
|
ref?: React.Ref<AutoFormRef>;
|
|
912
913
|
}) => ReturnType<typeof AutoFormInner>;
|
|
@@ -1176,6 +1177,7 @@ interface QueryKeys {
|
|
|
1176
1177
|
interface Option {
|
|
1177
1178
|
label: string;
|
|
1178
1179
|
value: string;
|
|
1180
|
+
searchText?: string;
|
|
1179
1181
|
count?: number;
|
|
1180
1182
|
icon?: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
1181
1183
|
}
|
|
@@ -1207,7 +1209,7 @@ declare function AutoTableSimpleFilters<TData>({
|
|
|
1207
1209
|
filters: externalFilters,
|
|
1208
1210
|
onFiltersChange,
|
|
1209
1211
|
leading
|
|
1210
|
-
}: AutoTableSimpleFiltersProps<TData>):
|
|
1212
|
+
}: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime3.JSX.Element | null;
|
|
1211
1213
|
//#endregion
|
|
1212
1214
|
//#region src/components/auto-crud/form-modal.d.ts
|
|
1213
1215
|
type ModalVariant = "dialog" | "sheet";
|
|
@@ -1249,7 +1251,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
|
|
|
1249
1251
|
labelAlign,
|
|
1250
1252
|
labelWidth,
|
|
1251
1253
|
className
|
|
1252
|
-
}: CrudFormModalProps<T>):
|
|
1254
|
+
}: CrudFormModalProps<T>): react_jsx_runtime3.JSX.Element;
|
|
1253
1255
|
//#endregion
|
|
1254
1256
|
//#region src/components/auto-crud/import-dialog.d.ts
|
|
1255
1257
|
interface ImportDialogProps {
|
|
@@ -1271,7 +1273,7 @@ declare function ImportDialog({
|
|
|
1271
1273
|
columns,
|
|
1272
1274
|
title,
|
|
1273
1275
|
locale
|
|
1274
|
-
}: ImportDialogProps):
|
|
1276
|
+
}: ImportDialogProps): react_jsx_runtime3.JSX.Element;
|
|
1275
1277
|
//#endregion
|
|
1276
1278
|
//#region src/components/auto-crud/export-dialog.d.ts
|
|
1277
1279
|
type ExportMode = "selected" | "filtered";
|
|
@@ -1291,7 +1293,7 @@ declare function ExportDialog({
|
|
|
1291
1293
|
selectedCount,
|
|
1292
1294
|
onExport,
|
|
1293
1295
|
canExportFiltered
|
|
1294
|
-
}: ExportDialogProps):
|
|
1296
|
+
}: ExportDialogProps): react_jsx_runtime3.JSX.Element;
|
|
1295
1297
|
//#endregion
|
|
1296
1298
|
//#region src/components/data-table/data-table.d.ts
|
|
1297
1299
|
interface DataTableProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1304,7 +1306,7 @@ declare function DataTable<TData>({
|
|
|
1304
1306
|
children,
|
|
1305
1307
|
className,
|
|
1306
1308
|
...props
|
|
1307
|
-
}: DataTableProps<TData>):
|
|
1309
|
+
}: DataTableProps<TData>): react_jsx_runtime3.JSX.Element;
|
|
1308
1310
|
//#endregion
|
|
1309
1311
|
//#region src/components/data-table/data-table-advanced-toolbar.d.ts
|
|
1310
1312
|
interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1315,7 +1317,7 @@ declare function DataTableAdvancedToolbar<TData>({
|
|
|
1315
1317
|
children,
|
|
1316
1318
|
className,
|
|
1317
1319
|
...props
|
|
1318
|
-
}: DataTableAdvancedToolbarProps<TData>):
|
|
1320
|
+
}: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime3.JSX.Element;
|
|
1319
1321
|
//#endregion
|
|
1320
1322
|
//#region src/components/data-table/data-table-column-header.d.ts
|
|
1321
1323
|
interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
|
|
@@ -1327,7 +1329,7 @@ declare function DataTableColumnHeader<TData, TValue>({
|
|
|
1327
1329
|
label,
|
|
1328
1330
|
className,
|
|
1329
1331
|
...props
|
|
1330
|
-
}: DataTableColumnHeaderProps<TData, TValue>):
|
|
1332
|
+
}: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime3.JSX.Element;
|
|
1331
1333
|
//#endregion
|
|
1332
1334
|
//#region src/components/data-table/data-table-faceted-filter.d.ts
|
|
1333
1335
|
interface DataTableFacetedFilterProps<TData, TValue> {
|
|
@@ -1341,7 +1343,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
|
|
|
1341
1343
|
title,
|
|
1342
1344
|
options,
|
|
1343
1345
|
multiple
|
|
1344
|
-
}: DataTableFacetedFilterProps<TData, TValue>):
|
|
1346
|
+
}: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime3.JSX.Element;
|
|
1345
1347
|
//#endregion
|
|
1346
1348
|
//#region src/components/data-table/data-table-pagination.d.ts
|
|
1347
1349
|
interface DataTablePaginationProps<TData> extends React.ComponentProps<"div"> {
|
|
@@ -1353,7 +1355,7 @@ declare function DataTablePagination<TData>({
|
|
|
1353
1355
|
pageSizeOptions,
|
|
1354
1356
|
className,
|
|
1355
1357
|
...props
|
|
1356
|
-
}: DataTablePaginationProps<TData>):
|
|
1358
|
+
}: DataTablePaginationProps<TData>): react_jsx_runtime3.JSX.Element;
|
|
1357
1359
|
//#endregion
|
|
1358
1360
|
//#region src/components/data-table/data-table-toolbar.d.ts
|
|
1359
1361
|
interface DataTableToolbarProps<TData> extends React$1.ComponentProps<"div"> {
|
|
@@ -1364,7 +1366,7 @@ declare function DataTableToolbar<TData>({
|
|
|
1364
1366
|
children,
|
|
1365
1367
|
className,
|
|
1366
1368
|
...props
|
|
1367
|
-
}: DataTableToolbarProps<TData>):
|
|
1369
|
+
}: DataTableToolbarProps<TData>): react_jsx_runtime3.JSX.Element;
|
|
1368
1370
|
//#endregion
|
|
1369
1371
|
//#region src/components/data-table/data-table-view-options.d.ts
|
|
1370
1372
|
interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
|
|
@@ -1375,7 +1377,7 @@ declare function DataTableViewOptions<TData>({
|
|
|
1375
1377
|
table,
|
|
1376
1378
|
disabled,
|
|
1377
1379
|
...props
|
|
1378
|
-
}: DataTableViewOptionsProps<TData>):
|
|
1380
|
+
}: DataTableViewOptionsProps<TData>): react_jsx_runtime3.JSX.Element;
|
|
1379
1381
|
//#endregion
|
|
1380
1382
|
//#region src/hooks/use-data-table.d.ts
|
|
1381
1383
|
interface UseDataTableProps<TData> extends Omit<TableOptions<TData>, "state" | "pageCount" | "getCoreRowModel" | "manualFiltering" | "manualPagination" | "manualSorting">, Required<Pick<TableOptions<TData>, "pageCount">> {
|
package/dist/index.js
CHANGED
|
@@ -1022,6 +1022,7 @@ function FacetedItem(props) {
|
|
|
1022
1022
|
else if (context.onItemSelect) context.onItemSelect(currentValue);
|
|
1023
1023
|
}, [onSelect, context]);
|
|
1024
1024
|
return /* @__PURE__ */ jsxs(CommandItem, {
|
|
1025
|
+
value,
|
|
1025
1026
|
"aria-selected": isSelected,
|
|
1026
1027
|
"data-selected": isSelected,
|
|
1027
1028
|
className: cn("gap-2", className),
|
|
@@ -1415,6 +1416,7 @@ function DataTableFilterList({ table, debounceMs = DEBOUNCE_MS$2, throttleMs = T
|
|
|
1415
1416
|
const descriptionId = React.useId();
|
|
1416
1417
|
const [open, setOpen] = React.useState(false);
|
|
1417
1418
|
const addButtonRef = React.useRef(null);
|
|
1419
|
+
const columnDefs = table.options.columns;
|
|
1418
1420
|
const columns = React.useMemo(() => {
|
|
1419
1421
|
return table.getAllColumns().filter((column) => {
|
|
1420
1422
|
if (!column.getCanFilter()) return false;
|
|
@@ -1422,7 +1424,7 @@ function DataTableFilterList({ table, debounceMs = DEBOUNCE_MS$2, throttleMs = T
|
|
|
1422
1424
|
if (modes && !modes.includes("advanced")) return false;
|
|
1423
1425
|
return true;
|
|
1424
1426
|
});
|
|
1425
|
-
}, [table]);
|
|
1427
|
+
}, [table, columnDefs]);
|
|
1426
1428
|
const [filters, setFilters] = useReadableFilters(columns, { debounceMs });
|
|
1427
1429
|
const debouncedSetFilters = useDebouncedCallback(setFilters, debounceMs);
|
|
1428
1430
|
const [joinOperator, setJoinOperator] = useQueryState(table.options.meta?.queryKeys?.joinOperator ?? "", parseAsStringEnum(["and", "or"]).withDefault("and"));
|
|
@@ -1900,8 +1902,16 @@ const DEBOUNCE_MS$1 = 300;
|
|
|
1900
1902
|
const THROTTLE_MS$1 = 50;
|
|
1901
1903
|
const FILTER_SHORTCUT_KEY = "f";
|
|
1902
1904
|
const REMOVE_FILTER_SHORTCUTS = ["backspace", "delete"];
|
|
1905
|
+
function getOptionCommandValue$2(option) {
|
|
1906
|
+
return [
|
|
1907
|
+
option.value,
|
|
1908
|
+
option.label,
|
|
1909
|
+
option.searchText
|
|
1910
|
+
].filter(Boolean).join(" ");
|
|
1911
|
+
}
|
|
1903
1912
|
function DataTableFilterMenu({ table, debounceMs = DEBOUNCE_MS$1, throttleMs = THROTTLE_MS$1, shallow = true, disabled,...props }) {
|
|
1904
1913
|
const id = React.useId();
|
|
1914
|
+
const columnDefs = table.options.columns;
|
|
1905
1915
|
const columns = React.useMemo(() => {
|
|
1906
1916
|
return table.getAllColumns().filter((column) => {
|
|
1907
1917
|
if (!column.columnDef.enableColumnFilter) return false;
|
|
@@ -1909,7 +1919,7 @@ function DataTableFilterMenu({ table, debounceMs = DEBOUNCE_MS$1, throttleMs = T
|
|
|
1909
1919
|
if (modes && !modes.includes("command")) return false;
|
|
1910
1920
|
return true;
|
|
1911
1921
|
});
|
|
1912
|
-
}, [table]);
|
|
1922
|
+
}, [table, columnDefs]);
|
|
1913
1923
|
const [open, setOpen] = React.useState(false);
|
|
1914
1924
|
const [selectedColumn, setSelectedColumn] = React.useState(null);
|
|
1915
1925
|
const [inputValue, setInputValue] = React.useState("");
|
|
@@ -2178,7 +2188,7 @@ function FilterValueSelector({ column, value, onSelect }) {
|
|
|
2178
2188
|
})] });
|
|
2179
2189
|
case "select":
|
|
2180
2190
|
case "multiSelect": return /* @__PURE__ */ jsx(CommandGroup, { children: column.columnDef.meta?.options?.map((option) => /* @__PURE__ */ jsxs(CommandItem, {
|
|
2181
|
-
value: option
|
|
2191
|
+
value: getOptionCommandValue$2(option),
|
|
2182
2192
|
onSelect: () => onSelect(option.value),
|
|
2183
2193
|
children: [
|
|
2184
2194
|
option.icon && /* @__PURE__ */ jsx(option.icon, {}),
|
|
@@ -2305,7 +2315,7 @@ function onFilterInputRender({ filter, column, inputId, onFilterUpdate, showValu
|
|
|
2305
2315
|
align: "start",
|
|
2306
2316
|
className: "w-48 p-0",
|
|
2307
2317
|
children: /* @__PURE__ */ jsxs(Command, { children: [/* @__PURE__ */ jsx(CommandInput, { placeholder: "Search options..." }), /* @__PURE__ */ jsxs(CommandList, { children: [/* @__PURE__ */ jsx(CommandEmpty, { children: "No options found." }), /* @__PURE__ */ jsx(CommandGroup, { children: options.map((option) => /* @__PURE__ */ jsxs(CommandItem, {
|
|
2308
|
-
value: option
|
|
2318
|
+
value: getOptionCommandValue$2(option),
|
|
2309
2319
|
onSelect: () => {
|
|
2310
2320
|
const value = filter.variant === "multiSelect" ? selectedValues.includes(option.value) ? selectedValues.filter((v) => v !== option.value) : [...selectedValues, option.value] : option.value;
|
|
2311
2321
|
onFilterUpdate(filter.filterId, { value });
|
|
@@ -2665,6 +2675,7 @@ function DataTableViewOptions({ table, disabled,...props }) {
|
|
|
2665
2675
|
//#endregion
|
|
2666
2676
|
//#region src/components/auto-crud/auto-table-simple-filters.tsx
|
|
2667
2677
|
function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilters, onFiltersChange, leading }) {
|
|
2678
|
+
const columnDefs = table.options.columns;
|
|
2668
2679
|
const columns = React.useMemo(() => table.getAllColumns().filter((col) => col.getCanFilter()).sort((a, b) => {
|
|
2669
2680
|
const readOrder = (column) => {
|
|
2670
2681
|
const metaIndex = column.columnDef.meta?.index;
|
|
@@ -2674,7 +2685,7 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
|
|
|
2674
2685
|
const orderDiff = readOrder(a) - readOrder(b);
|
|
2675
2686
|
if (orderDiff !== 0) return orderDiff;
|
|
2676
2687
|
return a.getIndex() - b.getIndex();
|
|
2677
|
-
}), [table]);
|
|
2688
|
+
}), [table, columnDefs]);
|
|
2678
2689
|
const queryStateOptions = table.options.meta?.queryStateOptions;
|
|
2679
2690
|
const [queryFilters, setQueryFilters] = useReadableFilters(columns, {
|
|
2680
2691
|
...queryStateOptions,
|
|
@@ -2908,6 +2919,13 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
|
|
|
2908
2919
|
]
|
|
2909
2920
|
});
|
|
2910
2921
|
}
|
|
2922
|
+
function getOptionCommandValue$1(option) {
|
|
2923
|
+
return [
|
|
2924
|
+
option.value,
|
|
2925
|
+
option.label,
|
|
2926
|
+
option.searchText
|
|
2927
|
+
].filter(Boolean).join(" ");
|
|
2928
|
+
}
|
|
2911
2929
|
function SimpleFacetedFilter({ title, options, multiple, value, onChange }) {
|
|
2912
2930
|
const [open, setOpen] = React.useState(false);
|
|
2913
2931
|
const selectedValues = React.useMemo(() => new Set(value), [value]);
|
|
@@ -2987,6 +3005,7 @@ function SimpleFacetedFilter({ title, options, multiple, value, onChange }) {
|
|
|
2987
3005
|
children: options.map((option) => {
|
|
2988
3006
|
const isSelected = selectedValues.has(option.value);
|
|
2989
3007
|
return /* @__PURE__ */ jsxs(CommandItem, {
|
|
3008
|
+
value: getOptionCommandValue$1(option),
|
|
2990
3009
|
onSelect: () => onItemSelect(option, isSelected),
|
|
2991
3010
|
children: [
|
|
2992
3011
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -4698,25 +4717,27 @@ function AutoTable({ schema, data, pageCount = 1, overrides, enableRowSelection
|
|
|
4698
4717
|
clearOnDefault: true
|
|
4699
4718
|
});
|
|
4700
4719
|
const searchConfig = search && typeof search === "object" ? search : {};
|
|
4720
|
+
const enableAdvancedFilter = true;
|
|
4721
|
+
const columns = useMemo(() => {
|
|
4722
|
+
const dataColumns = createTableSchema(schema, {
|
|
4723
|
+
overrides,
|
|
4724
|
+
exclude
|
|
4725
|
+
});
|
|
4726
|
+
const result = enableRowSelection ? [createSelectColumn(), ...dataColumns] : dataColumns;
|
|
4727
|
+
if (actions) result.push(createActionsColumn(actions));
|
|
4728
|
+
return result;
|
|
4729
|
+
}, [
|
|
4730
|
+
schema,
|
|
4731
|
+
overrides,
|
|
4732
|
+
enableRowSelection,
|
|
4733
|
+
exclude,
|
|
4734
|
+
actions
|
|
4735
|
+
]);
|
|
4701
4736
|
const { table, shallow, debounceMs, throttleMs } = useDataTable({
|
|
4702
4737
|
data,
|
|
4703
|
-
columns
|
|
4704
|
-
const dataColumns = createTableSchema(schema, {
|
|
4705
|
-
overrides,
|
|
4706
|
-
exclude
|
|
4707
|
-
});
|
|
4708
|
-
const result = enableRowSelection ? [createSelectColumn(), ...dataColumns] : dataColumns;
|
|
4709
|
-
if (actions) result.push(createActionsColumn(actions));
|
|
4710
|
-
return result;
|
|
4711
|
-
}, [
|
|
4712
|
-
schema,
|
|
4713
|
-
overrides,
|
|
4714
|
-
enableRowSelection,
|
|
4715
|
-
exclude,
|
|
4716
|
-
actions
|
|
4717
|
-
]),
|
|
4738
|
+
columns,
|
|
4718
4739
|
pageCount,
|
|
4719
|
-
enableAdvancedFilter
|
|
4740
|
+
enableAdvancedFilter,
|
|
4720
4741
|
initialState: useMemo(() => ({
|
|
4721
4742
|
sorting: initialSorting,
|
|
4722
4743
|
columnPinning: pinnedColumns ?? {
|
|
@@ -4802,6 +4823,7 @@ function AutoTable({ schema, data, pageCount = 1, overrides, enableRowSelection
|
|
|
4802
4823
|
}, [
|
|
4803
4824
|
currentMode,
|
|
4804
4825
|
table,
|
|
4826
|
+
columns,
|
|
4805
4827
|
shallow,
|
|
4806
4828
|
searchInput,
|
|
4807
4829
|
debounceMs,
|
|
@@ -5011,7 +5033,7 @@ function createEditFormSchema(schema, options) {
|
|
|
5011
5033
|
|
|
5012
5034
|
//#endregion
|
|
5013
5035
|
//#region src/components/auto-crud/auto-form.tsx
|
|
5014
|
-
const COMBOBOX_LIST_CLASS = "[&_[cmdk-list]]:max-h-[360px]";
|
|
5036
|
+
const COMBOBOX_LIST_CLASS = "[&_[cmdk-list]]:max-h-[360px] [&_[cmdk-list]]:overflow-x-hidden [&_[cmdk-list]]:overflow-y-auto";
|
|
5015
5037
|
const FormilySwitch = connect(Switch, mapProps({
|
|
5016
5038
|
value: "checked",
|
|
5017
5039
|
onInput: "onCheckedChange"
|
|
@@ -5883,6 +5905,28 @@ function ImportDialog({ open, onOpenChange, onImport, columns = [], title, local
|
|
|
5883
5905
|
|
|
5884
5906
|
//#endregion
|
|
5885
5907
|
//#region src/components/auto-crud/auto-crud-table.tsx
|
|
5908
|
+
function mergeFieldPart(base, override) {
|
|
5909
|
+
if (override === void 0) return base;
|
|
5910
|
+
if (override === false || base === false || typeof base !== "object" || typeof override !== "object" || base === null || override === null || Array.isArray(base) || Array.isArray(override)) return override;
|
|
5911
|
+
return {
|
|
5912
|
+
...base,
|
|
5913
|
+
...override
|
|
5914
|
+
};
|
|
5915
|
+
}
|
|
5916
|
+
function mergeFieldConfig(base, override) {
|
|
5917
|
+
return {
|
|
5918
|
+
...base,
|
|
5919
|
+
...override,
|
|
5920
|
+
table: mergeFieldPart(base?.table, override?.table),
|
|
5921
|
+
filter: mergeFieldPart(base?.filter, override?.filter),
|
|
5922
|
+
form: mergeFieldPart(base?.form, override?.form)
|
|
5923
|
+
};
|
|
5924
|
+
}
|
|
5925
|
+
function mergeFields(base, override) {
|
|
5926
|
+
if (!base && !override) return void 0;
|
|
5927
|
+
const keys = new Set([...Object.keys(base ?? {}), ...Object.keys(override ?? {})]);
|
|
5928
|
+
return Object.fromEntries(Array.from(keys).map((key) => [key, mergeFieldConfig(base?.[key], override?.[key])]));
|
|
5929
|
+
}
|
|
5886
5930
|
/**
|
|
5887
5931
|
* 从统一配置生成表格 overrides
|
|
5888
5932
|
* 当 filter 配置存在时,合并到 meta 中(不影响列隐藏)
|
|
@@ -6175,10 +6219,7 @@ function resolveActions(actionsOrFn, defaults, rowActionsLocale) {
|
|
|
6175
6219
|
function AutoCrudTable({ title, description, schema, resource, fields, table: tableConfig, form: formConfig, permissions, actions: actionItems, toolbarActions, locale: localeProp, onCreate }) {
|
|
6176
6220
|
const locale = resolveLocale(localeProp);
|
|
6177
6221
|
const resolvedSchema = resource.schema ?? schema;
|
|
6178
|
-
const resolvedFields = React.useMemo(() => ({
|
|
6179
|
-
...fields,
|
|
6180
|
-
...resource.fields
|
|
6181
|
-
}), [fields, resource.fields]);
|
|
6222
|
+
const resolvedFields = React.useMemo(() => mergeFields(resource.fields, fields) ?? {}, [fields, resource.fields]);
|
|
6182
6223
|
const can = {
|
|
6183
6224
|
create: permissions?.can?.create ?? true,
|
|
6184
6225
|
update: permissions?.can?.update ?? true,
|
|
@@ -6502,6 +6543,13 @@ function DataTableAdvancedToolbar({ table, children, className,...props }) {
|
|
|
6502
6543
|
|
|
6503
6544
|
//#endregion
|
|
6504
6545
|
//#region src/components/data-table/data-table-faceted-filter.tsx
|
|
6546
|
+
function getOptionCommandValue(option) {
|
|
6547
|
+
return [
|
|
6548
|
+
option.value,
|
|
6549
|
+
option.label,
|
|
6550
|
+
option.searchText
|
|
6551
|
+
].filter(Boolean).join(" ");
|
|
6552
|
+
}
|
|
6505
6553
|
function DataTableFacetedFilter({ column, title, options, multiple }) {
|
|
6506
6554
|
const [open, setOpen] = React.useState(false);
|
|
6507
6555
|
const columnFilterValue = column?.getFilterValue();
|
|
@@ -6583,6 +6631,7 @@ function DataTableFacetedFilter({ column, title, options, multiple }) {
|
|
|
6583
6631
|
children: options.map((option) => {
|
|
6584
6632
|
const isSelected = selectedValues.has(option.value);
|
|
6585
6633
|
return /* @__PURE__ */ jsxs(CommandItem, {
|
|
6634
|
+
value: getOptionCommandValue(option),
|
|
6586
6635
|
onSelect: () => onItemSelect(option, isSelected),
|
|
6587
6636
|
children: [
|
|
6588
6637
|
/* @__PURE__ */ jsx("div", {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordrhyme/auto-crud",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.6",
|
|
5
5
|
"description": "Schema-first CRUD components with auto-generated tables and forms",
|
|
6
6
|
"author": "wordrhyme",
|
|
7
7
|
"license": "MIT",
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
"typescript": "^5.9.3",
|
|
85
85
|
"@internal/prettier-config": "0.0.1",
|
|
86
86
|
"@internal/eslint-config": "0.3.0",
|
|
87
|
-
"@internal/tsconfig": "0.1.0",
|
|
88
87
|
"@internal/tsdown-config": "0.1.0",
|
|
89
|
-
"@internal/vitest-config": "0.1.0"
|
|
88
|
+
"@internal/vitest-config": "0.1.0",
|
|
89
|
+
"@internal/tsconfig": "0.1.0"
|
|
90
90
|
},
|
|
91
91
|
"prettier": "@internal/prettier-config",
|
|
92
92
|
"scripts": {
|