@wordrhyme/auto-crud 1.1.6 → 1.1.7
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 +420 -261
- package/dist/index.d.cts +71 -25
- package/dist/index.d.ts +71 -25
- package/dist/index.js +420 -261
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -59,8 +59,6 @@ let __pixpilot_formily_shadcn = require("@pixpilot/formily-shadcn");
|
|
|
59
59
|
__pixpilot_formily_shadcn = __toESM(__pixpilot_formily_shadcn);
|
|
60
60
|
let __formily_react = require("@formily/react");
|
|
61
61
|
__formily_react = __toESM(__formily_react);
|
|
62
|
-
let __pixpilot_shadcn_ui = require("@pixpilot/shadcn-ui");
|
|
63
|
-
__pixpilot_shadcn_ui = __toESM(__pixpilot_shadcn_ui);
|
|
64
62
|
let sonner = require("sonner");
|
|
65
63
|
sonner = __toESM(sonner);
|
|
66
64
|
|
|
@@ -1945,7 +1943,7 @@ const DEBOUNCE_MS$1 = 300;
|
|
|
1945
1943
|
const THROTTLE_MS$1 = 50;
|
|
1946
1944
|
const FILTER_SHORTCUT_KEY = "f";
|
|
1947
1945
|
const REMOVE_FILTER_SHORTCUTS = ["backspace", "delete"];
|
|
1948
|
-
function getOptionCommandValue
|
|
1946
|
+
function getOptionCommandValue(option) {
|
|
1949
1947
|
return [
|
|
1950
1948
|
option.value,
|
|
1951
1949
|
option.label,
|
|
@@ -2231,7 +2229,7 @@ function FilterValueSelector({ column, value, onSelect }) {
|
|
|
2231
2229
|
})] });
|
|
2232
2230
|
case "select":
|
|
2233
2231
|
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, {
|
|
2234
|
-
value: getOptionCommandValue
|
|
2232
|
+
value: getOptionCommandValue(option),
|
|
2235
2233
|
onSelect: () => onSelect(option.value),
|
|
2236
2234
|
children: [
|
|
2237
2235
|
option.icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(option.icon, {}),
|
|
@@ -2358,7 +2356,7 @@ function onFilterInputRender({ filter, column, inputId, onFilterUpdate, showValu
|
|
|
2358
2356
|
align: "start",
|
|
2359
2357
|
className: "w-48 p-0",
|
|
2360
2358
|
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, {
|
|
2361
|
-
value: getOptionCommandValue
|
|
2359
|
+
value: getOptionCommandValue(option),
|
|
2362
2360
|
onSelect: () => {
|
|
2363
2361
|
const value = filter.variant === "multiSelect" ? selectedValues.includes(option.value) ? selectedValues.filter((v) => v !== option.value) : [...selectedValues, option.value] : option.value;
|
|
2364
2362
|
onFilterUpdate(filter.filterId, { value });
|
|
@@ -2715,6 +2713,205 @@ function DataTableViewOptions({ table, disabled,...props }) {
|
|
|
2715
2713
|
})] });
|
|
2716
2714
|
}
|
|
2717
2715
|
|
|
2716
|
+
//#endregion
|
|
2717
|
+
//#region src/components/ui/multi-combobox.tsx
|
|
2718
|
+
const DEFAULT_OPTIONS = [];
|
|
2719
|
+
const SCROLLABLE_COMMAND_GROUP_STYLE = {
|
|
2720
|
+
maxHeight: "300px",
|
|
2721
|
+
overscrollBehavior: "contain",
|
|
2722
|
+
overflowX: "hidden",
|
|
2723
|
+
overflowY: "auto"
|
|
2724
|
+
};
|
|
2725
|
+
function getWheelDeltaY(event) {
|
|
2726
|
+
if (event.deltaMode === 1) return event.deltaY * 16;
|
|
2727
|
+
if (event.deltaMode === 2) return event.deltaY * event.currentTarget.clientHeight;
|
|
2728
|
+
return event.deltaY;
|
|
2729
|
+
}
|
|
2730
|
+
function handleScrollableCommandGroupWheel(event) {
|
|
2731
|
+
const target = event.currentTarget;
|
|
2732
|
+
if (target.scrollHeight <= target.clientHeight) return;
|
|
2733
|
+
const maxScrollTop = target.scrollHeight - target.clientHeight;
|
|
2734
|
+
const nextScrollTop = Math.max(0, Math.min(target.scrollTop + getWheelDeltaY(event), maxScrollTop));
|
|
2735
|
+
if (nextScrollTop === target.scrollTop) return;
|
|
2736
|
+
event.preventDefault();
|
|
2737
|
+
event.stopPropagation();
|
|
2738
|
+
target.scrollTop = nextScrollTop;
|
|
2739
|
+
}
|
|
2740
|
+
function collectSearchText(...parts) {
|
|
2741
|
+
const texts = [];
|
|
2742
|
+
for (const part of parts) {
|
|
2743
|
+
if (!part) continue;
|
|
2744
|
+
if (Array.isArray(part)) texts.push(...part.map(String));
|
|
2745
|
+
else if (typeof part === "object") texts.push(...Object.values(part).filter(Boolean).map(String));
|
|
2746
|
+
else texts.push(String(part));
|
|
2747
|
+
}
|
|
2748
|
+
return texts.join(" ");
|
|
2749
|
+
}
|
|
2750
|
+
function getOptionKeywords(option) {
|
|
2751
|
+
return collectSearchText(typeof option.label === "string" || typeof option.label === "number" ? option.label : void 0, option.searchText, option.keywords).split(/\s+/).filter(Boolean);
|
|
2752
|
+
}
|
|
2753
|
+
function getOptionText(option) {
|
|
2754
|
+
if (typeof option.label === "string" || typeof option.label === "number") return String(option.label);
|
|
2755
|
+
return option.value;
|
|
2756
|
+
}
|
|
2757
|
+
function createNextValue(currentValue, optionValue, isSelected, selectionMode) {
|
|
2758
|
+
if (selectionMode === "single") return isSelected ? [] : [optionValue];
|
|
2759
|
+
return isSelected ? currentValue.filter((value) => value !== optionValue) : [...currentValue, optionValue];
|
|
2760
|
+
}
|
|
2761
|
+
function DefaultMultiComboboxTrigger({ open, selectedOptions, selectedValues, clearSelection, disabled, readOnly, placeholder, selectedText, className,...buttonProps }) {
|
|
2762
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Button, {
|
|
2763
|
+
...buttonProps,
|
|
2764
|
+
type: "button",
|
|
2765
|
+
variant: "outline",
|
|
2766
|
+
role: "combobox",
|
|
2767
|
+
"aria-expanded": open,
|
|
2768
|
+
disabled,
|
|
2769
|
+
className: (0, __pixpilot_shadcn.cn)("w-full justify-between", className),
|
|
2770
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2771
|
+
className: "flex min-w-0 flex-1 items-center gap-1 overflow-hidden",
|
|
2772
|
+
children: selectedValues.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2773
|
+
className: "truncate text-muted-foreground",
|
|
2774
|
+
children: placeholder
|
|
2775
|
+
}) : selectedOptions.length <= 2 ? selectedOptions.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Badge, {
|
|
2776
|
+
variant: "secondary",
|
|
2777
|
+
className: "max-w-[8rem] rounded-sm px-1 font-normal",
|
|
2778
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2779
|
+
className: "truncate",
|
|
2780
|
+
children: option.label
|
|
2781
|
+
})
|
|
2782
|
+
}, option.value)) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Badge, {
|
|
2783
|
+
variant: "secondary",
|
|
2784
|
+
className: "rounded-sm px-1 font-normal",
|
|
2785
|
+
children: [
|
|
2786
|
+
selectedValues.length,
|
|
2787
|
+
" ",
|
|
2788
|
+
selectedText
|
|
2789
|
+
]
|
|
2790
|
+
})
|
|
2791
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2792
|
+
className: "ml-2 flex shrink-0 items-center gap-1",
|
|
2793
|
+
children: [selectedValues.length > 0 && !readOnly && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2794
|
+
role: "button",
|
|
2795
|
+
"aria-label": "Clear selection",
|
|
2796
|
+
tabIndex: 0,
|
|
2797
|
+
className: "rounded-sm px-1 text-muted-foreground opacity-70 transition-opacity hover:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
2798
|
+
onClick: clearSelection,
|
|
2799
|
+
onKeyDown: (event) => {
|
|
2800
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
2801
|
+
event.preventDefault();
|
|
2802
|
+
clearSelection(event);
|
|
2803
|
+
}
|
|
2804
|
+
},
|
|
2805
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "size-3" })
|
|
2806
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronsUpDown, { className: "h-4 w-4 opacity-50" })]
|
|
2807
|
+
})]
|
|
2808
|
+
});
|
|
2809
|
+
}
|
|
2810
|
+
const MultiCombobox = ({ value, defaultValue, onChange, options = DEFAULT_OPTIONS, placeholder = "Select options...", searchPlaceholder = "Search...", emptyText = "No options found.", clearText = "Clear selection", selectedText = "selected", selectionMode = "multiple", disabled, readOnly, className, contentClassName, triggerClassName, matchTriggerWidth = true, renderTrigger, filter,...commandProps }) => {
|
|
2811
|
+
const [open, setOpen] = react.useState(false);
|
|
2812
|
+
const [internalValue, setInternalValue] = react.useState(defaultValue ?? []);
|
|
2813
|
+
const selectedValues = value ?? internalValue;
|
|
2814
|
+
const selectedValueSet = react.useMemo(() => new Set(selectedValues), [selectedValues]);
|
|
2815
|
+
const selectedOptions = react.useMemo(() => options.filter((option) => selectedValueSet.has(option.value)), [options, selectedValueSet]);
|
|
2816
|
+
const commitChange = react.useCallback((nextValue) => {
|
|
2817
|
+
if (value === void 0) setInternalValue(nextValue);
|
|
2818
|
+
onChange?.(nextValue);
|
|
2819
|
+
}, [onChange, value]);
|
|
2820
|
+
const clearSelection = react.useCallback((event) => {
|
|
2821
|
+
event?.preventDefault();
|
|
2822
|
+
event?.stopPropagation();
|
|
2823
|
+
if (readOnly) return;
|
|
2824
|
+
commitChange([]);
|
|
2825
|
+
}, [commitChange, readOnly]);
|
|
2826
|
+
const onItemSelect = react.useCallback((option) => {
|
|
2827
|
+
if (option.disabled || readOnly) return;
|
|
2828
|
+
const isSelected = selectedValueSet.has(option.value);
|
|
2829
|
+
commitChange(createNextValue(selectedValues, option.value, isSelected, selectionMode));
|
|
2830
|
+
if (selectionMode === "single") setOpen(false);
|
|
2831
|
+
}, [
|
|
2832
|
+
commitChange,
|
|
2833
|
+
readOnly,
|
|
2834
|
+
selectedValues,
|
|
2835
|
+
selectedValueSet,
|
|
2836
|
+
selectionMode
|
|
2837
|
+
]);
|
|
2838
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Popover, {
|
|
2839
|
+
open,
|
|
2840
|
+
onOpenChange: setOpen,
|
|
2841
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.PopoverTrigger, {
|
|
2842
|
+
asChild: true,
|
|
2843
|
+
children: renderTrigger ? renderTrigger({
|
|
2844
|
+
open,
|
|
2845
|
+
selectedOptions,
|
|
2846
|
+
selectedValues,
|
|
2847
|
+
clearSelection,
|
|
2848
|
+
disabled,
|
|
2849
|
+
readOnly
|
|
2850
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultMultiComboboxTrigger, {
|
|
2851
|
+
open,
|
|
2852
|
+
selectedOptions,
|
|
2853
|
+
selectedValues,
|
|
2854
|
+
clearSelection,
|
|
2855
|
+
disabled,
|
|
2856
|
+
readOnly,
|
|
2857
|
+
placeholder,
|
|
2858
|
+
selectedText,
|
|
2859
|
+
className: triggerClassName
|
|
2860
|
+
})
|
|
2861
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.PopoverContent, {
|
|
2862
|
+
className: (0, __pixpilot_shadcn.cn)("w-full p-0", contentClassName),
|
|
2863
|
+
style: matchTriggerWidth ? { width: "var(--radix-popover-trigger-width)" } : void 0,
|
|
2864
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Command, {
|
|
2865
|
+
className,
|
|
2866
|
+
filter,
|
|
2867
|
+
...commandProps,
|
|
2868
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.CommandInput, { placeholder: searchPlaceholder }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.CommandList, {
|
|
2869
|
+
className: "max-h-full",
|
|
2870
|
+
children: [
|
|
2871
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.CommandEmpty, { children: emptyText }),
|
|
2872
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.CommandGroup, {
|
|
2873
|
+
className: "max-h-[300px] scroll-py-1 overflow-y-auto overflow-x-hidden",
|
|
2874
|
+
onWheelCapture: handleScrollableCommandGroupWheel,
|
|
2875
|
+
style: SCROLLABLE_COMMAND_GROUP_STYLE,
|
|
2876
|
+
children: options.map((option) => {
|
|
2877
|
+
const isSelected = selectedValueSet.has(option.value);
|
|
2878
|
+
const Icon = option.icon;
|
|
2879
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.CommandItem, {
|
|
2880
|
+
value: option.value,
|
|
2881
|
+
keywords: getOptionKeywords(option),
|
|
2882
|
+
disabled: option.disabled,
|
|
2883
|
+
onSelect: () => onItemSelect(option),
|
|
2884
|
+
children: [
|
|
2885
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2886
|
+
className: (0, __pixpilot_shadcn.cn)("flex size-4 items-center justify-center rounded-sm border border-primary", isSelected ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"),
|
|
2887
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, {})
|
|
2888
|
+
}),
|
|
2889
|
+
Icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { className: "size-4" }),
|
|
2890
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2891
|
+
className: "truncate",
|
|
2892
|
+
children: getOptionText(option)
|
|
2893
|
+
}),
|
|
2894
|
+
option.count !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2895
|
+
className: "ml-auto font-mono text-xs",
|
|
2896
|
+
children: option.count
|
|
2897
|
+
})
|
|
2898
|
+
]
|
|
2899
|
+
}, option.value);
|
|
2900
|
+
})
|
|
2901
|
+
}),
|
|
2902
|
+
selectedValues.length > 0 && !readOnly && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.CommandSeparator, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.CommandGroup, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.CommandItem, {
|
|
2903
|
+
onSelect: () => commitChange([]),
|
|
2904
|
+
className: "justify-center text-center",
|
|
2905
|
+
children: clearText
|
|
2906
|
+
}) })] })
|
|
2907
|
+
]
|
|
2908
|
+
})]
|
|
2909
|
+
})
|
|
2910
|
+
})]
|
|
2911
|
+
});
|
|
2912
|
+
};
|
|
2913
|
+
MultiCombobox.displayName = "MultiCombobox";
|
|
2914
|
+
|
|
2718
2915
|
//#endregion
|
|
2719
2916
|
//#region src/components/auto-crud/auto-table-simple-filters.tsx
|
|
2720
2917
|
function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilters, onFiltersChange, leading }) {
|
|
@@ -2962,120 +3159,60 @@ function AutoTableSimpleFilters({ table, shallow = false, filters: externalFilte
|
|
|
2962
3159
|
]
|
|
2963
3160
|
});
|
|
2964
3161
|
}
|
|
2965
|
-
function getOptionCommandValue$1(option) {
|
|
2966
|
-
return [
|
|
2967
|
-
option.value,
|
|
2968
|
-
option.label,
|
|
2969
|
-
option.searchText
|
|
2970
|
-
].filter(Boolean).join(" ");
|
|
2971
|
-
}
|
|
2972
3162
|
function SimpleFacetedFilter({ title, options, multiple, value, onChange }) {
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
onKeyDown: (e) => {
|
|
3006
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
3007
|
-
e.preventDefault();
|
|
3008
|
-
onReset(e);
|
|
3009
|
-
}
|
|
3010
|
-
},
|
|
3011
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.XCircle, {})
|
|
3012
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.PlusCircle, {}),
|
|
3013
|
-
title,
|
|
3014
|
-
selectedValues.size > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
3015
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Separator, {
|
|
3016
|
-
orientation: "vertical",
|
|
3017
|
-
className: "mx-0.5 h-4"
|
|
3018
|
-
}),
|
|
3019
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Badge, {
|
|
3020
|
-
variant: "secondary",
|
|
3021
|
-
className: "rounded-sm px-1 font-normal lg:hidden",
|
|
3022
|
-
children: selectedValues.size
|
|
3023
|
-
}),
|
|
3024
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3025
|
-
className: "hidden items-center gap-1 lg:flex",
|
|
3026
|
-
children: selectedValues.size > 2 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Badge, {
|
|
3027
|
-
variant: "secondary",
|
|
3028
|
-
className: "rounded-sm px-1 font-normal",
|
|
3029
|
-
children: [selectedValues.size, " selected"]
|
|
3030
|
-
}) : options.filter((o) => selectedValues.has(o.value)).map((o) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Badge, {
|
|
3031
|
-
variant: "secondary",
|
|
3032
|
-
className: "rounded-sm px-1 font-normal",
|
|
3033
|
-
children: o.label
|
|
3034
|
-
}, o.value))
|
|
3035
|
-
})
|
|
3036
|
-
] })
|
|
3037
|
-
]
|
|
3038
|
-
})
|
|
3039
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.PopoverContent, {
|
|
3040
|
-
className: "w-50 p-0",
|
|
3041
|
-
align: "start",
|
|
3042
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Command, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.CommandInput, { placeholder: title }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.CommandList, {
|
|
3043
|
-
className: "max-h-full",
|
|
3044
|
-
children: [
|
|
3045
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.CommandEmpty, { children: "No results found." }),
|
|
3046
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.CommandGroup, {
|
|
3047
|
-
className: "max-h-[300px] overflow-y-auto",
|
|
3048
|
-
children: options.map((option) => {
|
|
3049
|
-
const isSelected = selectedValues.has(option.value);
|
|
3050
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.CommandItem, {
|
|
3051
|
-
value: getOptionCommandValue$1(option),
|
|
3052
|
-
onSelect: () => onItemSelect(option, isSelected),
|
|
3053
|
-
children: [
|
|
3054
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3055
|
-
className: cn("flex size-4 items-center justify-center rounded-sm border border-primary", isSelected ? "bg-primary" : "opacity-50 [&_svg]:invisible"),
|
|
3056
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, {})
|
|
3057
|
-
}),
|
|
3058
|
-
option.icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(option.icon, {}),
|
|
3059
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3060
|
-
className: "truncate",
|
|
3061
|
-
children: option.label
|
|
3062
|
-
}),
|
|
3063
|
-
option.count && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3064
|
-
className: "ml-auto font-mono text-xs",
|
|
3065
|
-
children: option.count
|
|
3066
|
-
})
|
|
3067
|
-
]
|
|
3068
|
-
}, option.value);
|
|
3069
|
-
})
|
|
3163
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MultiCombobox, {
|
|
3164
|
+
value,
|
|
3165
|
+
onChange,
|
|
3166
|
+
options,
|
|
3167
|
+
selectionMode: multiple ? "multiple" : "single",
|
|
3168
|
+
searchPlaceholder: title,
|
|
3169
|
+
contentClassName: "w-50",
|
|
3170
|
+
matchTriggerWidth: false,
|
|
3171
|
+
clearText: "Clear filters",
|
|
3172
|
+
renderTrigger: ({ selectedOptions, selectedValues, clearSelection }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Button, {
|
|
3173
|
+
variant: "outline",
|
|
3174
|
+
size: "sm",
|
|
3175
|
+
className: "border-dashed font-normal",
|
|
3176
|
+
children: [
|
|
3177
|
+
selectedValues.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3178
|
+
role: "button",
|
|
3179
|
+
tabIndex: 0,
|
|
3180
|
+
className: "rounded-sm opacity-70 hover:opacity-100",
|
|
3181
|
+
onClick: clearSelection,
|
|
3182
|
+
onKeyDown: (e) => {
|
|
3183
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
3184
|
+
e.preventDefault();
|
|
3185
|
+
clearSelection(e);
|
|
3186
|
+
}
|
|
3187
|
+
},
|
|
3188
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.XCircle, {})
|
|
3189
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.PlusCircle, {}),
|
|
3190
|
+
title,
|
|
3191
|
+
selectedValues.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
3192
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Separator, {
|
|
3193
|
+
orientation: "vertical",
|
|
3194
|
+
className: "mx-0.5 h-4"
|
|
3070
3195
|
}),
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
className: "
|
|
3074
|
-
children:
|
|
3075
|
-
})
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3196
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Badge, {
|
|
3197
|
+
variant: "secondary",
|
|
3198
|
+
className: "rounded-sm px-1 font-normal lg:hidden",
|
|
3199
|
+
children: selectedValues.length
|
|
3200
|
+
}),
|
|
3201
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3202
|
+
className: "hidden items-center gap-1 lg:flex",
|
|
3203
|
+
children: selectedValues.length > 2 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Badge, {
|
|
3204
|
+
variant: "secondary",
|
|
3205
|
+
className: "rounded-sm px-1 font-normal",
|
|
3206
|
+
children: [selectedValues.length, " selected"]
|
|
3207
|
+
}) : selectedOptions.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Badge, {
|
|
3208
|
+
variant: "secondary",
|
|
3209
|
+
className: "rounded-sm px-1 font-normal",
|
|
3210
|
+
children: option.label
|
|
3211
|
+
}, option.value))
|
|
3212
|
+
})
|
|
3213
|
+
] })
|
|
3214
|
+
]
|
|
3215
|
+
})
|
|
3079
3216
|
});
|
|
3080
3217
|
}
|
|
3081
3218
|
function SimpleSliderFilter({ title, range, unit, value, onChange }) {
|
|
@@ -3986,11 +4123,32 @@ function parseZodField(schema) {
|
|
|
3986
4123
|
/**
|
|
3987
4124
|
* 渲染单元格内容
|
|
3988
4125
|
*/
|
|
3989
|
-
function renderCell(value, type) {
|
|
4126
|
+
function renderCell(value, type, options) {
|
|
3990
4127
|
if (value === null || value === void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3991
4128
|
className: "text-muted-foreground",
|
|
3992
4129
|
children: "-"
|
|
3993
4130
|
});
|
|
4131
|
+
const formatOptionValue = (optionValue) => {
|
|
4132
|
+
const stringValue = String(optionValue);
|
|
4133
|
+
return options?.find((option) => option.value === stringValue)?.label ?? stringValue;
|
|
4134
|
+
};
|
|
4135
|
+
if (options && options.length > 0) {
|
|
4136
|
+
if (Array.isArray(value)) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4137
|
+
className: "flex gap-1 flex-wrap",
|
|
4138
|
+
children: [value.slice(0, 3).map((v, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Badge, {
|
|
4139
|
+
variant: "secondary",
|
|
4140
|
+
children: formatOptionValue(v)
|
|
4141
|
+
}, i)), value.length > 3 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Badge, {
|
|
4142
|
+
variant: "outline",
|
|
4143
|
+
children: ["+", value.length - 3]
|
|
4144
|
+
})]
|
|
4145
|
+
});
|
|
4146
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Badge, {
|
|
4147
|
+
variant: "outline",
|
|
4148
|
+
className: "capitalize",
|
|
4149
|
+
children: formatOptionValue(value)
|
|
4150
|
+
});
|
|
4151
|
+
}
|
|
3994
4152
|
switch (type) {
|
|
3995
4153
|
case "boolean": return value ? "✓" : "✗";
|
|
3996
4154
|
case "date": return formatDate(value);
|
|
@@ -4063,7 +4221,7 @@ function createTableSchema(schema, options) {
|
|
|
4063
4221
|
column,
|
|
4064
4222
|
label
|
|
4065
4223
|
}),
|
|
4066
|
-
cell: ({ row }) => renderCell(row.getValue(key), parsed.type),
|
|
4224
|
+
cell: ({ row }) => renderCell(row.getValue(key), parsed.type, meta.options),
|
|
4067
4225
|
enableColumnFilter: true,
|
|
4068
4226
|
enableSorting: true,
|
|
4069
4227
|
meta,
|
|
@@ -5082,37 +5240,31 @@ const FormilySwitch = (0, __formily_react.connect)(__pixpilot_shadcn.Switch, (0,
|
|
|
5082
5240
|
onInput: "onCheckedChange"
|
|
5083
5241
|
}));
|
|
5084
5242
|
const FormilyCombobox = (0, __formily_react.connect)(AutoCrudCombobox, (0, __formily_react.mapProps)({ dataSource: "options" }));
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
return
|
|
5243
|
+
const FormilyMultiCombobox = (0, __formily_react.connect)(AutoCrudMultiCombobox, (0, __formily_react.mapProps)({
|
|
5244
|
+
dataSource: "options",
|
|
5245
|
+
onInput: "onChange"
|
|
5246
|
+
}, (props, field) => {
|
|
5247
|
+
const fieldValue = field.value;
|
|
5248
|
+
return {
|
|
5249
|
+
...props,
|
|
5250
|
+
value: Array.isArray(fieldValue) ? fieldValue.map(String) : []
|
|
5251
|
+
};
|
|
5252
|
+
}));
|
|
5253
|
+
function AutoCrudCombobox({ options = [], className, value, onChange,...props }) {
|
|
5254
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MultiCombobox, {
|
|
5091
5255
|
...props,
|
|
5256
|
+
value: value ? [value] : [],
|
|
5092
5257
|
options,
|
|
5093
|
-
|
|
5258
|
+
selectionMode: "single",
|
|
5259
|
+
onChange: (nextValues) => onChange?.(nextValues[0] ?? ""),
|
|
5094
5260
|
className: (0, __pixpilot_shadcn.cn)(COMBOBOX_LIST_CLASS, className)
|
|
5095
5261
|
});
|
|
5096
5262
|
}
|
|
5097
|
-
function
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
const searchText = collectSearchText(searchTextByValue.get(value), keywords).toLocaleLowerCase();
|
|
5103
|
-
if (searchText === query) return 2;
|
|
5104
|
-
return searchText.includes(query) ? 1 : 0;
|
|
5105
|
-
};
|
|
5106
|
-
}
|
|
5107
|
-
function collectSearchText(...parts) {
|
|
5108
|
-
const texts = [];
|
|
5109
|
-
for (const part of parts) {
|
|
5110
|
-
if (!part) continue;
|
|
5111
|
-
if (Array.isArray(part)) texts.push(...part.map(String));
|
|
5112
|
-
else if (typeof part === "object") texts.push(...Object.values(part).filter(Boolean).map(String));
|
|
5113
|
-
else texts.push(String(part));
|
|
5114
|
-
}
|
|
5115
|
-
return texts.join(" ");
|
|
5263
|
+
function AutoCrudMultiCombobox({ options = [],...props }) {
|
|
5264
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MultiCombobox, {
|
|
5265
|
+
...props,
|
|
5266
|
+
options
|
|
5267
|
+
});
|
|
5116
5268
|
}
|
|
5117
5269
|
function AutoFormInner({ schema: zodSchema, initialValues, onSubmit, overrides, mode = "create", loading = false, gridColumns = 1, labelAlign = "top", labelWidth, showSubmitButton = true }, ref) {
|
|
5118
5270
|
const form = (0, react.useMemo)(() => (0, __formily_core.createForm)({ initialValues }), [JSON.stringify(initialValues)]);
|
|
@@ -5143,6 +5295,10 @@ function AutoFormInner({ schema: zodSchema, initialValues, onSubmit, overrides,
|
|
|
5143
5295
|
component: FormilyCombobox,
|
|
5144
5296
|
decorator: "FormItem"
|
|
5145
5297
|
},
|
|
5298
|
+
MultiCombobox: {
|
|
5299
|
+
component: FormilyMultiCombobox,
|
|
5300
|
+
decorator: "FormItem"
|
|
5301
|
+
},
|
|
5146
5302
|
Switch: {
|
|
5147
5303
|
component: FormilySwitch,
|
|
5148
5304
|
decorator: "FormItem"
|
|
@@ -5960,6 +6116,7 @@ function mergeFieldConfig(base, override) {
|
|
|
5960
6116
|
return {
|
|
5961
6117
|
...base,
|
|
5962
6118
|
...override,
|
|
6119
|
+
enum: override?.enum ?? base?.enum,
|
|
5963
6120
|
table: mergeFieldPart(base?.table, override?.table),
|
|
5964
6121
|
filter: mergeFieldPart(base?.filter, override?.filter),
|
|
5965
6122
|
form: mergeFieldPart(base?.form, override?.form)
|
|
@@ -5970,6 +6127,32 @@ function mergeFields(base, override) {
|
|
|
5970
6127
|
const keys = new Set([...Object.keys(base ?? {}), ...Object.keys(override ?? {})]);
|
|
5971
6128
|
return Object.fromEntries(Array.from(keys).map((key) => [key, mergeFieldConfig(base?.[key], override?.[key])]));
|
|
5972
6129
|
}
|
|
6130
|
+
function normalizeFieldOptions(options) {
|
|
6131
|
+
if (!options || options.length === 0) return void 0;
|
|
6132
|
+
return options.map((option) => ({
|
|
6133
|
+
...option,
|
|
6134
|
+
value: String(option.value)
|
|
6135
|
+
}));
|
|
6136
|
+
}
|
|
6137
|
+
function toTableOptions(options) {
|
|
6138
|
+
return options?.map(({ label, value, searchText, count, icon }) => ({
|
|
6139
|
+
label,
|
|
6140
|
+
value,
|
|
6141
|
+
searchText: Array.isArray(searchText) ? searchText.join(" ") : searchText,
|
|
6142
|
+
count,
|
|
6143
|
+
icon
|
|
6144
|
+
}));
|
|
6145
|
+
}
|
|
6146
|
+
function toBatchOptions(options) {
|
|
6147
|
+
return options?.map(({ label, value }) => ({
|
|
6148
|
+
label,
|
|
6149
|
+
value
|
|
6150
|
+
}));
|
|
6151
|
+
}
|
|
6152
|
+
function getOptionLabel(value, options) {
|
|
6153
|
+
const stringValue = String(value);
|
|
6154
|
+
return options?.find((option) => option.value === stringValue)?.label ?? stringValue;
|
|
6155
|
+
}
|
|
5973
6156
|
/**
|
|
5974
6157
|
* 从统一配置生成表格 overrides
|
|
5975
6158
|
* 当 filter 配置存在时,合并到 meta 中(不影响列隐藏)
|
|
@@ -5977,7 +6160,12 @@ function mergeFields(base, override) {
|
|
|
5977
6160
|
function buildTableOverrides(fields, legacyOverrides) {
|
|
5978
6161
|
const result = { ...legacyOverrides };
|
|
5979
6162
|
if (fields) for (const [key, config] of Object.entries(fields)) {
|
|
6163
|
+
const tableOptions = toTableOptions(normalizeFieldOptions(config.enum));
|
|
5980
6164
|
const tableMeta = config.table !== false && typeof config.table === "object" ? config.table.meta : void 0;
|
|
6165
|
+
const fieldEnumMeta = tableOptions ? {
|
|
6166
|
+
options: tableOptions,
|
|
6167
|
+
variant: "multiSelect"
|
|
6168
|
+
} : void 0;
|
|
5981
6169
|
let filterMeta;
|
|
5982
6170
|
if (config.filter && typeof config.filter === "object") {
|
|
5983
6171
|
if (config.filter.enabled !== false && config.filter.hidden !== true) {
|
|
@@ -5995,10 +6183,11 @@ function buildTableOverrides(fields, legacyOverrides) {
|
|
|
5995
6183
|
enableColumnFilter: false
|
|
5996
6184
|
};
|
|
5997
6185
|
}
|
|
5998
|
-
if (tableMeta || filterMeta) result[key] = {
|
|
6186
|
+
if (fieldEnumMeta || tableMeta || filterMeta) result[key] = {
|
|
5999
6187
|
...result[key],
|
|
6000
6188
|
meta: {
|
|
6001
6189
|
...result[key]?.meta ?? {},
|
|
6190
|
+
...fieldEnumMeta ?? {},
|
|
6002
6191
|
...tableMeta ?? {},
|
|
6003
6192
|
...filterMeta ?? {}
|
|
6004
6193
|
}
|
|
@@ -6036,6 +6225,7 @@ function buildFormOverrides(fields, legacyOverrides, denyFields) {
|
|
|
6036
6225
|
"x-hidden": true
|
|
6037
6226
|
};
|
|
6038
6227
|
if (fields) for (const [key, config] of Object.entries(fields)) {
|
|
6228
|
+
const fieldOptions = normalizeFieldOptions(config.enum);
|
|
6039
6229
|
if (config.label) result[key] = {
|
|
6040
6230
|
...result[key],
|
|
6041
6231
|
title: config.label
|
|
@@ -6044,6 +6234,10 @@ function buildFormOverrides(fields, legacyOverrides, denyFields) {
|
|
|
6044
6234
|
...result[key],
|
|
6045
6235
|
"x-hidden": true
|
|
6046
6236
|
};
|
|
6237
|
+
if (fieldOptions) result[key] = {
|
|
6238
|
+
...result[key],
|
|
6239
|
+
enum: fieldOptions
|
|
6240
|
+
};
|
|
6047
6241
|
if (config.form === false) result[key] = {
|
|
6048
6242
|
...result[key],
|
|
6049
6243
|
"x-hidden": true
|
|
@@ -6086,6 +6280,12 @@ function buildBatchUpdateFields(schema, batchFields, fields) {
|
|
|
6086
6280
|
}
|
|
6087
6281
|
const parsed = parseZodField(fieldSchema);
|
|
6088
6282
|
const label = fields?.[field]?.label ?? humanize(field);
|
|
6283
|
+
const batchOptions = toBatchOptions(normalizeFieldOptions(fields?.[field]?.enum));
|
|
6284
|
+
if (batchOptions) return {
|
|
6285
|
+
field,
|
|
6286
|
+
label,
|
|
6287
|
+
options: batchOptions
|
|
6288
|
+
};
|
|
6089
6289
|
if (parsed.type === "enum" && parsed.enumValues) return {
|
|
6090
6290
|
field,
|
|
6091
6291
|
label,
|
|
@@ -6105,11 +6305,28 @@ function buildBatchUpdateFields(schema, batchFields, fields) {
|
|
|
6105
6305
|
/**
|
|
6106
6306
|
* 渲染字段值
|
|
6107
6307
|
*/
|
|
6108
|
-
function renderFieldValue(value, type, booleanLocale) {
|
|
6308
|
+
function renderFieldValue(value, type, booleanLocale, options) {
|
|
6109
6309
|
if (value === null || value === void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6110
6310
|
className: "text-muted-foreground",
|
|
6111
6311
|
children: "-"
|
|
6112
6312
|
});
|
|
6313
|
+
if (options && options.length > 0) {
|
|
6314
|
+
if (Array.isArray(value)) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6315
|
+
className: "flex gap-1 flex-wrap",
|
|
6316
|
+
children: [value.slice(0, 5).map((v, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Badge, {
|
|
6317
|
+
variant: "secondary",
|
|
6318
|
+
children: getOptionLabel(v, options)
|
|
6319
|
+
}, i)), value.length > 5 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Badge, {
|
|
6320
|
+
variant: "outline",
|
|
6321
|
+
children: ["+", value.length - 5]
|
|
6322
|
+
})]
|
|
6323
|
+
});
|
|
6324
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Badge, {
|
|
6325
|
+
variant: "outline",
|
|
6326
|
+
className: "capitalize",
|
|
6327
|
+
children: getOptionLabel(value, options)
|
|
6328
|
+
});
|
|
6329
|
+
}
|
|
6113
6330
|
switch (type) {
|
|
6114
6331
|
case "boolean": return value ? booleanLocale.true : booleanLocale.false;
|
|
6115
6332
|
case "date": return formatDate(value);
|
|
@@ -6147,6 +6364,7 @@ function ViewModal({ open, onOpenChange, variant, data, schema, fields: fieldCon
|
|
|
6147
6364
|
const parsed = parseZodField(fieldSchema);
|
|
6148
6365
|
const label = fieldConfig?.[key]?.label ?? humanize(key);
|
|
6149
6366
|
const value = data[key];
|
|
6367
|
+
const options = normalizeFieldOptions(fieldConfig?.[key]?.enum);
|
|
6150
6368
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6151
6369
|
className: "grid grid-cols-3 items-start gap-4",
|
|
6152
6370
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", {
|
|
@@ -6154,7 +6372,7 @@ function ViewModal({ open, onOpenChange, variant, data, schema, fields: fieldCon
|
|
|
6154
6372
|
children: label
|
|
6155
6373
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", {
|
|
6156
6374
|
className: "col-span-2 text-sm",
|
|
6157
|
-
children: renderFieldValue(value, parsed.type, locale.boolean)
|
|
6375
|
+
children: renderFieldValue(value, parsed.type, locale.boolean, options)
|
|
6158
6376
|
})]
|
|
6159
6377
|
}, key);
|
|
6160
6378
|
})
|
|
@@ -6586,122 +6804,62 @@ function DataTableAdvancedToolbar({ table, children, className,...props }) {
|
|
|
6586
6804
|
|
|
6587
6805
|
//#endregion
|
|
6588
6806
|
//#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
|
-
}
|
|
6596
6807
|
function DataTableFacetedFilter({ column, title, options, multiple }) {
|
|
6597
|
-
const [open, setOpen] = react.useState(false);
|
|
6598
6808
|
const columnFilterValue = column?.getFilterValue();
|
|
6599
|
-
const selectedValues =
|
|
6600
|
-
const
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
role: "button",
|
|
6633
|
-
"aria-label": `Clear ${title} filter`,
|
|
6634
|
-
tabIndex: 0,
|
|
6635
|
-
className: "rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
6636
|
-
onClick: onReset,
|
|
6637
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.XCircle, {})
|
|
6638
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.PlusCircle, {}),
|
|
6639
|
-
title,
|
|
6640
|
-
selectedValues?.size > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
6641
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Separator, {
|
|
6642
|
-
orientation: "vertical",
|
|
6643
|
-
className: "mx-0.5 data-[orientation=vertical]:h-4"
|
|
6644
|
-
}),
|
|
6645
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Badge, {
|
|
6646
|
-
variant: "secondary",
|
|
6647
|
-
className: "rounded-sm px-1 font-normal lg:hidden",
|
|
6648
|
-
children: selectedValues.size
|
|
6649
|
-
}),
|
|
6650
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6651
|
-
className: "hidden items-center gap-1 lg:flex",
|
|
6652
|
-
children: selectedValues.size > 2 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Badge, {
|
|
6653
|
-
variant: "secondary",
|
|
6654
|
-
className: "rounded-sm px-1 font-normal",
|
|
6655
|
-
children: [selectedValues.size, " selected"]
|
|
6656
|
-
}) : options.filter((option) => selectedValues.has(option.value)).map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Badge, {
|
|
6657
|
-
variant: "secondary",
|
|
6658
|
-
className: "rounded-sm px-1 font-normal",
|
|
6659
|
-
children: option.label
|
|
6660
|
-
}, option.value))
|
|
6661
|
-
})
|
|
6662
|
-
] })
|
|
6663
|
-
]
|
|
6664
|
-
})
|
|
6665
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.PopoverContent, {
|
|
6666
|
-
className: "w-50 p-0",
|
|
6667
|
-
align: "start",
|
|
6668
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Command, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.CommandInput, { placeholder: title }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.CommandList, {
|
|
6669
|
-
className: "max-h-full",
|
|
6670
|
-
children: [
|
|
6671
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.CommandEmpty, { children: "No results found." }),
|
|
6672
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.CommandGroup, {
|
|
6673
|
-
className: "max-h-[300px] scroll-py-1 overflow-y-auto overflow-x-hidden",
|
|
6674
|
-
children: options.map((option) => {
|
|
6675
|
-
const isSelected = selectedValues.has(option.value);
|
|
6676
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.CommandItem, {
|
|
6677
|
-
value: getOptionCommandValue(option),
|
|
6678
|
-
onSelect: () => onItemSelect(option, isSelected),
|
|
6679
|
-
children: [
|
|
6680
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6681
|
-
className: cn("flex size-4 items-center justify-center rounded-sm border border-primary", isSelected ? "bg-primary" : "opacity-50 [&_svg]:invisible"),
|
|
6682
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, {})
|
|
6683
|
-
}),
|
|
6684
|
-
option.icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(option.icon, {}),
|
|
6685
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6686
|
-
className: "truncate",
|
|
6687
|
-
children: option.label
|
|
6688
|
-
}),
|
|
6689
|
-
option.count && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6690
|
-
className: "ml-auto font-mono text-xs",
|
|
6691
|
-
children: option.count
|
|
6692
|
-
})
|
|
6693
|
-
]
|
|
6694
|
-
}, option.value);
|
|
6695
|
-
})
|
|
6809
|
+
const selectedValues = Array.isArray(columnFilterValue) ? columnFilterValue.filter((value) => typeof value === "string") : [];
|
|
6810
|
+
const onChange = (nextValues) => {
|
|
6811
|
+
column?.setFilterValue(nextValues.length ? nextValues : void 0);
|
|
6812
|
+
};
|
|
6813
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MultiCombobox, {
|
|
6814
|
+
value: selectedValues,
|
|
6815
|
+
onChange,
|
|
6816
|
+
options,
|
|
6817
|
+
selectionMode: multiple ? "multiple" : "single",
|
|
6818
|
+
searchPlaceholder: title,
|
|
6819
|
+
contentClassName: "w-50",
|
|
6820
|
+
matchTriggerWidth: false,
|
|
6821
|
+
clearText: "Clear filters",
|
|
6822
|
+
renderTrigger: ({ selectedOptions, selectedValues: selectedValues$1, clearSelection }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Button, {
|
|
6823
|
+
type: "button",
|
|
6824
|
+
variant: "outline",
|
|
6825
|
+
size: "sm",
|
|
6826
|
+
className: "border-dashed font-normal",
|
|
6827
|
+
disabled: !column,
|
|
6828
|
+
children: [
|
|
6829
|
+
selectedValues$1.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6830
|
+
role: "button",
|
|
6831
|
+
"aria-label": `Clear ${title} filter`,
|
|
6832
|
+
tabIndex: 0,
|
|
6833
|
+
className: "rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
6834
|
+
onClick: clearSelection,
|
|
6835
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.XCircle, {})
|
|
6836
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.PlusCircle, {}),
|
|
6837
|
+
title,
|
|
6838
|
+
selectedValues$1.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
6839
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Separator, {
|
|
6840
|
+
orientation: "vertical",
|
|
6841
|
+
className: "mx-0.5 data-[orientation=vertical]:h-4"
|
|
6696
6842
|
}),
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
className: "
|
|
6700
|
-
children:
|
|
6701
|
-
})
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6843
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Badge, {
|
|
6844
|
+
variant: "secondary",
|
|
6845
|
+
className: "rounded-sm px-1 font-normal lg:hidden",
|
|
6846
|
+
children: selectedValues$1.length
|
|
6847
|
+
}),
|
|
6848
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6849
|
+
className: "hidden items-center gap-1 lg:flex",
|
|
6850
|
+
children: selectedValues$1.length > 2 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Badge, {
|
|
6851
|
+
variant: "secondary",
|
|
6852
|
+
className: "rounded-sm px-1 font-normal",
|
|
6853
|
+
children: [selectedValues$1.length, " selected"]
|
|
6854
|
+
}) : selectedOptions.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Badge, {
|
|
6855
|
+
variant: "secondary",
|
|
6856
|
+
className: "rounded-sm px-1 font-normal",
|
|
6857
|
+
children: option.label
|
|
6858
|
+
}, option.value))
|
|
6859
|
+
})
|
|
6860
|
+
] })
|
|
6861
|
+
]
|
|
6862
|
+
})
|
|
6705
6863
|
});
|
|
6706
6864
|
}
|
|
6707
6865
|
|
|
@@ -7935,6 +8093,7 @@ exports.DataTableToolbar = DataTableToolbar;
|
|
|
7935
8093
|
exports.DataTableViewOptions = DataTableViewOptions;
|
|
7936
8094
|
exports.ExportDialog = ExportDialog;
|
|
7937
8095
|
exports.ImportDialog = ImportDialog;
|
|
8096
|
+
exports.MultiCombobox = MultiCombobox;
|
|
7938
8097
|
exports.SchemaAdapter = SchemaAdapter;
|
|
7939
8098
|
exports.cn = cn;
|
|
7940
8099
|
exports.coerceRowValues = coerceRowValues;
|