@middag-io/react 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist-lib/base/blocks/ActivityTimelineBlock.d.ts.map +1 -1
- package/dist-lib/base/shell/AuthShell.js +39 -0
- package/dist-lib/base/shell/BasicShell.js +207 -0
- package/dist-lib/base/shell/ImmersiveShell.js +55 -0
- package/dist-lib/base/shell/partials/InspectorContext.d.ts.map +1 -1
- package/dist-lib/base/shell/partials/InspectorContext.js +60 -0
- package/dist-lib/base/shell/partials/InspectorPanel.js +22 -0
- package/dist-lib/base/shell/partials/NavErrorBoundary.js +66 -0
- package/dist-lib/base/shell/partials/OverlayScreen.js +36 -0
- package/dist-lib/base/shell/partials/PageActionButton.js +4 -0
- package/dist-lib/base/theme/appearance.js +39 -0
- package/dist-lib/base/theme/host-layout-detector.js +39 -0
- package/dist-lib/base/theme/host-theme-detector.js +131 -0
- package/dist-lib/base/theme/sidebar-safelist.txt +20 -0
- package/dist-lib/base/theme/theme-bridge.css +164 -0
- package/dist-lib/base/theme/theme-context.js +103 -0
- package/dist-lib/base/theme/themes/classic.css +174 -0
- package/dist-lib/base/theme/tokens.css +290 -0
- package/dist-lib/base/theme/useHostTheme.js +34 -0
- package/dist-lib/base/utils/clipboard.js +16 -0
- package/dist-lib/base/utils/conditions.js +13 -0
- package/dist-lib/base/utils/icon-registry.js +16 -0
- package/dist-lib/base/utils/icons.js +11 -0
- package/dist-lib/base/utils/interpolate.js +6 -0
- package/dist-lib/base/utils/register-default-icons.js +9 -0
- package/dist-lib/base/utils/storage.js +30 -0
- package/dist-lib/base/utils/time.js +59 -0
- package/dist-lib/chunks/subpath-BD_PKGUX.js +146 -0
- package/dist-lib/chunks/subpath-DLFO_UGQ.js +604 -0
- package/dist-lib/components/reui/accordion.js +43 -0
- package/dist-lib/components/reui/alert-dialog.js +101 -0
- package/dist-lib/components/reui/alert.js +55 -0
- package/dist-lib/components/reui/aspect-ratio.js +11 -0
- package/dist-lib/components/reui/autocomplete.js +170 -0
- package/dist-lib/components/reui/avatar.js +51 -0
- package/dist-lib/components/reui/badge.js +64 -0
- package/dist-lib/components/reui/breadcrumb.js +69 -0
- package/dist-lib/components/reui/button-group.js +38 -0
- package/dist-lib/components/reui/button.js +47 -0
- package/dist-lib/components/reui/calendar.js +89 -0
- package/dist-lib/components/reui/card.js +55 -0
- package/dist-lib/components/reui/carousel.js +110 -0
- package/dist-lib/components/reui/chart.js +130 -0
- package/dist-lib/components/reui/checkbox.js +20 -0
- package/dist-lib/components/reui/collapsible.js +23 -0
- package/dist-lib/components/reui/combobox.js +166 -0
- package/dist-lib/components/reui/command.js +85 -0
- package/dist-lib/components/reui/context-menu.js +121 -0
- package/dist-lib/components/reui/data-grid/data-grid-column-filter.js +108 -0
- package/dist-lib/components/reui/data-grid/data-grid-column-header.js +217 -0
- package/dist-lib/components/reui/data-grid/data-grid-column-visibility.js +25 -0
- package/dist-lib/components/reui/data-grid/data-grid-pagination.js +132 -0
- package/dist-lib/components/reui/data-grid/data-grid-scroll-area.js +183 -0
- package/dist-lib/components/reui/data-grid/data-grid-table-dnd-rows.js +125 -0
- package/dist-lib/components/reui/data-grid/data-grid-table-dnd.js +130 -0
- package/dist-lib/components/reui/data-grid/data-grid-table-virtual.js +156 -0
- package/dist-lib/components/reui/data-grid/data-grid-table.js +546 -0
- package/dist-lib/components/reui/data-grid/data-grid.js +113 -0
- package/dist-lib/components/reui/data-grid-pagination.js +131 -0
- package/dist-lib/components/reui/date-selector.js +642 -0
- package/dist-lib/components/reui/dialog.js +94 -0
- package/dist-lib/components/reui/drawer.js +77 -0
- package/dist-lib/components/reui/dropdown-menu.js +123 -0
- package/dist-lib/components/reui/empty.js +59 -0
- package/dist-lib/components/reui/field.js +115 -0
- package/dist-lib/components/reui/filters.js +873 -0
- package/dist-lib/components/reui/frame.js +97 -0
- package/dist-lib/components/reui/hover-card.js +31 -0
- package/dist-lib/components/reui/icon-placeholder.js +14 -0
- package/dist-lib/components/reui/index.js +18 -0
- package/dist-lib/components/reui/input-group.js +78 -0
- package/dist-lib/components/reui/input-otp.js +44 -0
- package/dist-lib/components/reui/input.js +14 -0
- package/dist-lib/components/reui/item.js +116 -0
- package/dist-lib/components/reui/kanban.js +316 -0
- package/dist-lib/components/reui/kbd.js +19 -0
- package/dist-lib/components/reui/label.js +14 -0
- package/dist-lib/components/reui/menubar.js +132 -0
- package/dist-lib/components/reui/native-select.js +37 -0
- package/dist-lib/components/reui/navigation-menu.js +80 -0
- package/dist-lib/components/reui/number-field.js +126 -0
- package/dist-lib/components/reui/pagination.js +78 -0
- package/dist-lib/components/reui/phone-input.js +124 -0
- package/dist-lib/components/reui/popover.js +55 -0
- package/dist-lib/components/reui/progress.js +20 -0
- package/dist-lib/components/reui/radio-group.js +27 -0
- package/dist-lib/components/reui/rating.js +81 -0
- package/dist-lib/components/reui/resizable.js +31 -0
- package/dist-lib/components/reui/scroll-area.js +36 -0
- package/dist-lib/components/reui/scrollspy.js +104 -0
- package/dist-lib/components/reui/select.js +97 -0
- package/dist-lib/components/reui/separator.js +17 -0
- package/dist-lib/components/reui/sheet.js +81 -0
- package/dist-lib/components/reui/sidebar.js +350 -0
- package/dist-lib/components/reui/skeleton.js +12 -0
- package/dist-lib/components/reui/slider.js +35 -0
- package/dist-lib/components/reui/sonner.js +28 -0
- package/dist-lib/components/reui/sortable.js +172 -0
- package/dist-lib/components/reui/spinner.js +14 -0
- package/dist-lib/components/reui/stepper.js +193 -0
- package/dist-lib/components/reui/svgs/claudeAiIcon.js +13 -0
- package/dist-lib/components/reui/svgs/gemini.js +257 -0
- package/dist-lib/components/reui/svgs/openai.js +10 -0
- package/dist-lib/components/reui/svgs/openaiDark.js +13 -0
- package/dist-lib/components/reui/switch.js +19 -0
- package/dist-lib/components/reui/table.js +66 -0
- package/dist-lib/components/reui/tabs.js +47 -0
- package/dist-lib/components/reui/textarea.js +13 -0
- package/dist-lib/components/reui/timeline.js +84 -0
- package/dist-lib/components/reui/toggle-group.js +48 -0
- package/dist-lib/components/reui/toggle.js +36 -0
- package/dist-lib/components/reui/tooltip.js +35 -0
- package/dist-lib/components/reui/tree.js +102 -0
- package/dist-lib/contracts/block-data/data-display.d.ts +8 -0
- package/dist-lib/contracts/block-data/data-display.d.ts.map +1 -1
- package/dist-lib/i18n/I18nProvider.js +23 -0
- package/dist-lib/i18n/host-resolver.js +10 -0
- package/dist-lib/i18n/instance.js +2 -0
- package/dist-lib/i18n/locales/en/ui.json +266 -0
- package/dist-lib/i18n/locales/en/validators.json +13 -0
- package/dist-lib/i18n/locales/pt-BR/ui.json +266 -0
- package/dist-lib/i18n/locales/pt-BR/validators.json +13 -0
- package/dist-lib/i18n/register-strings.js +7 -0
- package/dist-lib/i18n/render-label.js +13 -0
- package/dist-lib/i18n/resolve-field-error.js +10 -0
- package/dist-lib/i18n/useHostString.js +31 -0
- package/dist-lib/i18n/useTranslation.js +48 -0
- package/dist-lib/lib/actions/resolve-action-target.js +48 -0
- package/dist-lib/lib/hooks/use-copy-to-clipboard.js +18 -0
- package/dist-lib/lib/hooks/use-file-upload.js +171 -0
- package/dist-lib/lib/hooks/use-mobile.js +18 -0
- package/dist-lib/lib/portal-container.js +7 -0
- package/dist-lib/lib/utils.js +8 -0
- package/dist-lib/middag-react.css +1 -1
- package/dist-lib/middag-react.js +26 -5
- package/package.json +39 -7
- package/dist-lib/_redirects +0 -1
- package/dist-lib/api/example/moodle/get/books.json +0 -209
- package/dist-lib/api/example/moodle/get/dashboard.json +0 -203
- package/dist-lib/api/example/wordpress/get/products.json +0 -165
- package/dist-lib/api/index.json +0 -66
- package/dist-lib/api/inspector/connectors/canvas.json +0 -18
- package/dist-lib/api/inspector/connectors/moodle.json +0 -18
- package/dist-lib/api/inspector/connectors/n8n.json +0 -18
- package/dist-lib/api/inspector/connectors/open-edx.json +0 -18
- package/dist-lib/api/inspector/offerings/off-1.json +0 -18
- package/dist-lib/api/inspector/offerings/off-2.json +0 -18
- package/dist-lib/api/inspector/offerings/off-3.json +0 -18
- package/dist-lib/api/inspector/offerings/off-4.json +0 -18
- package/dist-lib/api/inspector/offerings/off-5.json +0 -18
- package/dist-lib/api/inspector/offerings/off-6.json +0 -17
- package/dist-lib/lottie/calendar/schedule-1.json +0 -1
- package/dist-lib/lottie/calendar/schedule-2.json +0 -1
- package/dist-lib/lottie/celebration/confetti-1.json +0 -1
- package/dist-lib/lottie/celebration/confetti-2.json +0 -1
- package/dist-lib/lottie/celebration/confetti-3.json +0 -1
- package/dist-lib/lottie/cloud/cloud-1.json +0 -1
- package/dist-lib/lottie/cloud/cloud-2.json +0 -1
- package/dist-lib/lottie/connection/network-1.json +0 -1
- package/dist-lib/lottie/connection/network-2.json +0 -1
- package/dist-lib/lottie/connection/network-3.json +0 -1
- package/dist-lib/lottie/dashboard/analytics-1.json +0 -1
- package/dist-lib/lottie/dashboard/analytics-2.json +0 -1
- package/dist-lib/lottie/dashboard/analytics-3.json +0 -1
- package/dist-lib/lottie/email/mail-1.json +0 -1
- package/dist-lib/lottie/email/mail-2.json +0 -1
- package/dist-lib/lottie/email/mail-3.json +0 -1
- package/dist-lib/lottie/empty-state/empty-1.json +0 -1
- package/dist-lib/lottie/empty-state/empty-2.json +0 -1
- package/dist-lib/lottie/empty-state/empty-3.json +0 -1
- package/dist-lib/lottie/error/warning-1.json +0 -1
- package/dist-lib/lottie/error/warning-2.json +0 -1
- package/dist-lib/lottie/error/warning-3.json +0 -1
- package/dist-lib/lottie/index.ts +0 -49
- package/dist-lib/lottie/loading/spinner-1.json +0 -1
- package/dist-lib/lottie/loading/spinner-2.json +0 -1
- package/dist-lib/lottie/loading/spinner-3.json +0 -1
- package/dist-lib/lottie/maintenance/construction-1.json +0 -1
- package/dist-lib/lottie/maintenance/construction-2.json +0 -1
- package/dist-lib/lottie/maintenance/construction-3.json +0 -1
- package/dist-lib/lottie/not-found/404-1.json +0 -1
- package/dist-lib/lottie/not-found/404-2.json +0 -1
- package/dist-lib/lottie/not-found/404-3.json +0 -1
- package/dist-lib/lottie/notification/bell-1.json +0 -1
- package/dist-lib/lottie/notification/bell-2.json +0 -1
- package/dist-lib/lottie/notification/bell-3.json +0 -1
- package/dist-lib/lottie/onboarding/welcome-1.json +0 -1
- package/dist-lib/lottie/onboarding/welcome-2.json +0 -1
- package/dist-lib/lottie/onboarding/welcome-3.json +0 -1
- package/dist-lib/lottie/payment/wallet-1.json +0 -1
- package/dist-lib/lottie/payment/wallet-2.json +0 -1
- package/dist-lib/lottie/payment/wallet-3.json +0 -1
- package/dist-lib/lottie/search/search-1.json +0 -1
- package/dist-lib/lottie/search/search-2.json +0 -1
- package/dist-lib/lottie/search/search-3.json +0 -1
- package/dist-lib/lottie/security/lock-1.json +0 -1
- package/dist-lib/lottie/security/lock-2.json +0 -1
- package/dist-lib/lottie/security/lock-3.json +0 -1
- package/dist-lib/lottie/settings/gear-1.json +0 -1
- package/dist-lib/lottie/settings/gear-2.json +0 -1
- package/dist-lib/lottie/settings/gear-3.json +0 -1
- package/dist-lib/lottie/success/check-1.json +0 -1
- package/dist-lib/lottie/success/check-2.json +0 -1
- package/dist-lib/lottie/success/check-3.json +0 -1
- package/dist-lib/lottie/upload/upload-1.json +0 -1
- package/dist-lib/lottie/upload/upload-2.json +0 -1
- package/dist-lib/lottie/upload/upload-3.json +0 -1
- package/dist-lib/lottie/user/profile-1.json +0 -1
- package/dist-lib/lottie/user/profile-2.json +0 -1
- package/dist-lib/lottie/user/profile-3.json +0 -1
|
@@ -0,0 +1,873 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/utils.js";
|
|
2
|
+
import { Button as t } from "./button.js";
|
|
3
|
+
import { ScrollArea as n } from "./scroll-area.js";
|
|
4
|
+
import { ButtonGroup as r, ButtonGroupText as i } from "./button-group.js";
|
|
5
|
+
import { Input as a } from "./input.js";
|
|
6
|
+
import { InputGroup as o, InputGroupAddon as s, InputGroupButton as c, InputGroupInput as l, InputGroupText as u } from "./input-group.js";
|
|
7
|
+
import { DropdownMenu as d, DropdownMenuCheckboxItem as f, DropdownMenuContent as p, DropdownMenuGroup as m, DropdownMenuItem as h, DropdownMenuSeparator as g, DropdownMenuSub as _, DropdownMenuSubContent as v, DropdownMenuSubTrigger as y, DropdownMenuTrigger as b } from "./dropdown-menu.js";
|
|
8
|
+
import { Kbd as x } from "./kbd.js";
|
|
9
|
+
import { Tooltip as S, TooltipContent as C, TooltipProvider as w, TooltipTrigger as T } from "./tooltip.js";
|
|
10
|
+
import { createContext as E, useCallback as D, useContext as O, useEffect as k, useId as ee, useMemo as A, useRef as j, useState as M } from "react";
|
|
11
|
+
import { Fragment as N, jsx as P, jsxs as F } from "react/jsx-runtime";
|
|
12
|
+
import { cva as I } from "class-variance-authority";
|
|
13
|
+
import { HugeiconsIcon as L } from "@hugeicons/react";
|
|
14
|
+
import { AlertCircleIcon as R, Cancel01Icon as z, Plus01Icon as te, Tick02Icon as B } from "@hugeicons/core-free-icons";
|
|
15
|
+
//#region src/components/reui/filters.tsx
|
|
16
|
+
var V = {
|
|
17
|
+
addFilter: "Filter",
|
|
18
|
+
searchFields: "Filter...",
|
|
19
|
+
noFieldsFound: "No filters found.",
|
|
20
|
+
noResultsFound: "No results found.",
|
|
21
|
+
select: "Select...",
|
|
22
|
+
true: "True",
|
|
23
|
+
false: "False",
|
|
24
|
+
min: "Min",
|
|
25
|
+
max: "Max",
|
|
26
|
+
to: "to",
|
|
27
|
+
typeAndPressEnter: "Type and press Enter to add tag",
|
|
28
|
+
selected: "selected",
|
|
29
|
+
selectedCount: "selected",
|
|
30
|
+
percent: "%",
|
|
31
|
+
defaultCurrency: "$",
|
|
32
|
+
defaultColor: "#000000",
|
|
33
|
+
addFilterTitle: "Add filter",
|
|
34
|
+
operators: {
|
|
35
|
+
is: "is",
|
|
36
|
+
isNot: "is not",
|
|
37
|
+
isAnyOf: "is any of",
|
|
38
|
+
isNotAnyOf: "is not any of",
|
|
39
|
+
includesAll: "includes all",
|
|
40
|
+
excludesAll: "excludes all",
|
|
41
|
+
before: "before",
|
|
42
|
+
after: "after",
|
|
43
|
+
between: "between",
|
|
44
|
+
notBetween: "not between",
|
|
45
|
+
contains: "contains",
|
|
46
|
+
notContains: "does not contain",
|
|
47
|
+
startsWith: "starts with",
|
|
48
|
+
endsWith: "ends with",
|
|
49
|
+
isExactly: "is exactly",
|
|
50
|
+
equals: "equals",
|
|
51
|
+
notEquals: "not equals",
|
|
52
|
+
greaterThan: "greater than",
|
|
53
|
+
lessThan: "less than",
|
|
54
|
+
overlaps: "overlaps",
|
|
55
|
+
includes: "includes",
|
|
56
|
+
excludes: "excludes",
|
|
57
|
+
includesAllOf: "includes all of",
|
|
58
|
+
includesAnyOf: "includes any of",
|
|
59
|
+
empty: "is empty",
|
|
60
|
+
notEmpty: "is not empty"
|
|
61
|
+
},
|
|
62
|
+
placeholders: {
|
|
63
|
+
enterField: (e) => `Enter ${e}...`,
|
|
64
|
+
selectField: "Select...",
|
|
65
|
+
searchField: (e) => `Search ${e.toLowerCase()}...`,
|
|
66
|
+
enterKey: "Enter key...",
|
|
67
|
+
enterValue: "Enter value..."
|
|
68
|
+
},
|
|
69
|
+
helpers: { formatOperator: (e) => e.replace(/_/g, " ") },
|
|
70
|
+
validation: {
|
|
71
|
+
invalidEmail: "Invalid email format",
|
|
72
|
+
invalidUrl: "Invalid URL format",
|
|
73
|
+
invalidTel: "Invalid phone format",
|
|
74
|
+
invalid: "Invalid input format"
|
|
75
|
+
}
|
|
76
|
+
}, ne = E({
|
|
77
|
+
variant: "default",
|
|
78
|
+
size: "default",
|
|
79
|
+
radius: "default",
|
|
80
|
+
i18n: V,
|
|
81
|
+
className: void 0,
|
|
82
|
+
showSearchInput: !0,
|
|
83
|
+
trigger: void 0,
|
|
84
|
+
allowMultiple: !0
|
|
85
|
+
}), H = () => O(ne), re = I("flex flex-wrap items-center", {
|
|
86
|
+
variants: {
|
|
87
|
+
variant: {
|
|
88
|
+
solid: "gap-2",
|
|
89
|
+
default: ""
|
|
90
|
+
},
|
|
91
|
+
size: {
|
|
92
|
+
sm: "gap-1.5",
|
|
93
|
+
default: "gap-2.5",
|
|
94
|
+
lg: "gap-3.5"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
defaultVariants: {
|
|
98
|
+
variant: "default",
|
|
99
|
+
size: "default"
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
function ie({ field: t, onBlur: n, onKeyDown: r, className: i, ...a }) {
|
|
103
|
+
let d = H(), [f, p] = M(!0), [m, h] = M(""), g = j(null);
|
|
104
|
+
k(() => {
|
|
105
|
+
if (a.autoFocus) {
|
|
106
|
+
let e = setTimeout(() => {
|
|
107
|
+
g.current?.focus();
|
|
108
|
+
}, 300);
|
|
109
|
+
return () => clearTimeout(e);
|
|
110
|
+
}
|
|
111
|
+
}, [a.autoFocus]);
|
|
112
|
+
let _ = (e, t) => !t || !e ? !0 : new RegExp(t).test(e), v = () => d.i18n.validation.invalid, y = (e) => {
|
|
113
|
+
let r = e.target.value, i = t?.pattern || a.pattern;
|
|
114
|
+
if (r && (i || t?.validation)) {
|
|
115
|
+
let e = !0, n = "";
|
|
116
|
+
if (t?.validation) {
|
|
117
|
+
let i = t.validation(r);
|
|
118
|
+
typeof i == "boolean" ? e = i : (e = i.valid, n = i.message || "");
|
|
119
|
+
} else i && (e = _(r, i));
|
|
120
|
+
p(e), h(e ? "" : n || v());
|
|
121
|
+
} else p(!0), h("");
|
|
122
|
+
n?.(e);
|
|
123
|
+
}, b = (e) => {
|
|
124
|
+
!f && ![
|
|
125
|
+
"Tab",
|
|
126
|
+
"Escape",
|
|
127
|
+
"Enter",
|
|
128
|
+
"ArrowUp",
|
|
129
|
+
"ArrowDown",
|
|
130
|
+
"ArrowLeft",
|
|
131
|
+
"ArrowRight"
|
|
132
|
+
].includes(e.key) && (p(!0), h("")), r?.(e);
|
|
133
|
+
};
|
|
134
|
+
return /* @__PURE__ */ F(o, {
|
|
135
|
+
className: e("w-36", d.size == "sm" && "h-8!", d.size == "default" && "h-9!", d.size == "lg" && "h-10!", i),
|
|
136
|
+
children: [
|
|
137
|
+
t?.prefix && /* @__PURE__ */ P(s, { children: /* @__PURE__ */ P(u, { children: t.prefix }) }),
|
|
138
|
+
/* @__PURE__ */ P(l, {
|
|
139
|
+
ref: g,
|
|
140
|
+
"aria-invalid": !f,
|
|
141
|
+
"aria-describedby": !f && m ? `${t?.key || "input"}-error` : void 0,
|
|
142
|
+
onBlur: y,
|
|
143
|
+
onKeyDown: b,
|
|
144
|
+
className: e(d.size == "sm" && "h-8! text-xs", d.size == "default" && "h-9!", d.size == "lg" && "h-10!"),
|
|
145
|
+
...a
|
|
146
|
+
}),
|
|
147
|
+
!f && m && /* @__PURE__ */ P(s, {
|
|
148
|
+
align: "inline-end",
|
|
149
|
+
children: /* @__PURE__ */ P(w, { children: /* @__PURE__ */ F(S, { children: [/* @__PURE__ */ P(T, {
|
|
150
|
+
asChild: !0,
|
|
151
|
+
children: /* @__PURE__ */ P(c, {
|
|
152
|
+
size: "icon-xs",
|
|
153
|
+
children: /* @__PURE__ */ P(L, {
|
|
154
|
+
icon: R,
|
|
155
|
+
strokeWidth: 2,
|
|
156
|
+
className: "text-destructive size-3.5"
|
|
157
|
+
})
|
|
158
|
+
})
|
|
159
|
+
}), /* @__PURE__ */ P(C, { children: /* @__PURE__ */ P("p", {
|
|
160
|
+
className: "text-sm",
|
|
161
|
+
children: m
|
|
162
|
+
}) })] }) })
|
|
163
|
+
}),
|
|
164
|
+
t?.suffix && /* @__PURE__ */ P(s, {
|
|
165
|
+
align: "inline-end",
|
|
166
|
+
children: /* @__PURE__ */ P(u, { children: t.suffix })
|
|
167
|
+
})
|
|
168
|
+
]
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function ae({ className: e, icon: n = /* @__PURE__ */ P(L, {
|
|
172
|
+
icon: z,
|
|
173
|
+
strokeWidth: 2
|
|
174
|
+
}), ...r }) {
|
|
175
|
+
let i = H();
|
|
176
|
+
return /* @__PURE__ */ P(t, {
|
|
177
|
+
variant: "outline",
|
|
178
|
+
size: i.size === "sm" ? "icon-sm" : i.size === "lg" ? "icon-lg" : "icon",
|
|
179
|
+
...r,
|
|
180
|
+
children: n
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
var oe = (e) => "fields" in e && Array.isArray(e.fields), U = (e) => !!(e.group && e.fields), se = (e) => e.reduce((e, t) => oe(t) || U(t) ? [...e, ...t.fields] : [...e, t], []), ce = (e) => se(e).reduce((e, t) => (t.key && (e[t.key] = t), e), {}), W = (e) => ({
|
|
184
|
+
select: [
|
|
185
|
+
{
|
|
186
|
+
value: "is",
|
|
187
|
+
label: e.operators.is
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
value: "is_not",
|
|
191
|
+
label: e.operators.isNot
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
value: "empty",
|
|
195
|
+
label: e.operators.empty
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
value: "not_empty",
|
|
199
|
+
label: e.operators.notEmpty
|
|
200
|
+
}
|
|
201
|
+
],
|
|
202
|
+
multiselect: [
|
|
203
|
+
{
|
|
204
|
+
value: "is_any_of",
|
|
205
|
+
label: e.operators.isAnyOf
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
value: "is_not_any_of",
|
|
209
|
+
label: e.operators.isNotAnyOf
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
value: "includes_all",
|
|
213
|
+
label: e.operators.includesAll
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
value: "excludes_all",
|
|
217
|
+
label: e.operators.excludesAll
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
value: "empty",
|
|
221
|
+
label: e.operators.empty
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
value: "not_empty",
|
|
225
|
+
label: e.operators.notEmpty
|
|
226
|
+
}
|
|
227
|
+
],
|
|
228
|
+
text: [
|
|
229
|
+
{
|
|
230
|
+
value: "contains",
|
|
231
|
+
label: e.operators.contains
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
value: "not_contains",
|
|
235
|
+
label: e.operators.notContains
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
value: "starts_with",
|
|
239
|
+
label: e.operators.startsWith
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
value: "ends_with",
|
|
243
|
+
label: e.operators.endsWith
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
value: "is",
|
|
247
|
+
label: e.operators.isExactly
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
value: "empty",
|
|
251
|
+
label: e.operators.empty
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
value: "not_empty",
|
|
255
|
+
label: e.operators.notEmpty
|
|
256
|
+
}
|
|
257
|
+
],
|
|
258
|
+
custom: [
|
|
259
|
+
{
|
|
260
|
+
value: "is",
|
|
261
|
+
label: e.operators.is
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
value: "after",
|
|
265
|
+
label: e.operators.after
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
value: "is",
|
|
269
|
+
label: e.operators.is
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
value: "between",
|
|
273
|
+
label: e.operators.between
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
value: "empty",
|
|
277
|
+
label: e.operators.empty
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
value: "not_empty",
|
|
281
|
+
label: e.operators.notEmpty
|
|
282
|
+
}
|
|
283
|
+
]
|
|
284
|
+
}), G = W(V), K = (e, t, n) => {
|
|
285
|
+
if (e.operators) return e.operators;
|
|
286
|
+
let r = W(n), i = e.type || "select";
|
|
287
|
+
return i === "select" && t.length > 1 && (i = "multiselect"), i === "multiselect" || e.type === "multiselect" ? r.multiselect : r[i] || r.select;
|
|
288
|
+
};
|
|
289
|
+
function le({ field: n, operator: r, values: i, onChange: a }) {
|
|
290
|
+
let o = H(), s = K(n, i, o.i18n), c = s.find((e) => e.value === r)?.label || o.i18n.helpers.formatOperator(r);
|
|
291
|
+
return /* @__PURE__ */ F(d, { children: [/* @__PURE__ */ P(b, {
|
|
292
|
+
asChild: !0,
|
|
293
|
+
children: /* @__PURE__ */ P(t, {
|
|
294
|
+
variant: "outline",
|
|
295
|
+
size: o.size,
|
|
296
|
+
className: "text-muted-foreground hover:text-foreground",
|
|
297
|
+
children: c
|
|
298
|
+
})
|
|
299
|
+
}), /* @__PURE__ */ P(p, {
|
|
300
|
+
align: "start",
|
|
301
|
+
className: "w-fit min-w-fit",
|
|
302
|
+
children: s.map((t) => /* @__PURE__ */ F(h, {
|
|
303
|
+
onClick: () => a(t.value),
|
|
304
|
+
className: e("data-highlighted:bg-accent data-highlighted:text-accent-foreground flex items-center justify-between"),
|
|
305
|
+
children: [/* @__PURE__ */ P("span", { children: t.label }), /* @__PURE__ */ P(L, {
|
|
306
|
+
icon: B,
|
|
307
|
+
strokeWidth: 2,
|
|
308
|
+
className: e("text-primary ms-auto", t.value === r ? "opacity-100" : "opacity-0")
|
|
309
|
+
})]
|
|
310
|
+
}, t.value))
|
|
311
|
+
})] });
|
|
312
|
+
}
|
|
313
|
+
function q({ field: r, values: i, onChange: o, onClose: s, inline: c = !1 }) {
|
|
314
|
+
let [l, u] = M(!1), [h, _] = M(""), [v, y] = M(-1), x = j(null), S = H(), C = ee();
|
|
315
|
+
k(() => {
|
|
316
|
+
y(-1);
|
|
317
|
+
}, [h, l]), k(() => {
|
|
318
|
+
v >= 0 && l && document.getElementById(`${C}-item-${v}`)?.scrollIntoView({ block: "nearest" });
|
|
319
|
+
}, [
|
|
320
|
+
v,
|
|
321
|
+
l,
|
|
322
|
+
C
|
|
323
|
+
]);
|
|
324
|
+
let w = r.type === "multiselect" || i.length > 1, T = (r.value === void 0 ? i : r.value) || [], E = r.options?.filter((e) => T.includes(e.value)) || [], D = r.options?.filter((e) => !T.includes(e.value)) || [], O = E, I = D.filter((e) => e.label.toLowerCase().includes(h.toLowerCase())), L = A(() => [...O, ...I], [O, I]), R = () => {
|
|
325
|
+
u(!1), s?.();
|
|
326
|
+
}, z = () => /* @__PURE__ */ F(N, { children: [r.searchable !== !1 && /* @__PURE__ */ F(N, { children: [/* @__PURE__ */ P(a, {
|
|
327
|
+
ref: x,
|
|
328
|
+
role: "combobox",
|
|
329
|
+
"aria-autocomplete": "list",
|
|
330
|
+
"aria-expanded": !0,
|
|
331
|
+
"aria-haspopup": "listbox",
|
|
332
|
+
"aria-controls": `${C}-listbox`,
|
|
333
|
+
"aria-activedescendant": v >= 0 ? `${C}-item-${v}` : void 0,
|
|
334
|
+
placeholder: S.i18n.placeholders.searchField(r.label || ""),
|
|
335
|
+
className: e("border-input h-8 rounded-none border-0 bg-transparent! px-2 text-sm shadow-none", "focus-visible:border-border focus-visible:ring-0 focus-visible:ring-offset-0"),
|
|
336
|
+
value: h,
|
|
337
|
+
onChange: (e) => _(e.target.value),
|
|
338
|
+
onClick: (e) => e.stopPropagation(),
|
|
339
|
+
onKeyDown: (e) => {
|
|
340
|
+
if (e.key === "ArrowDown") e.preventDefault(), L.length > 0 && y((e) => e < L.length - 1 ? e + 1 : 0);
|
|
341
|
+
else if (e.key === "ArrowUp") e.preventDefault(), L.length > 0 && y((e) => e > 0 ? e - 1 : L.length - 1);
|
|
342
|
+
else if (e.key === "ArrowLeft") e.preventDefault(), u(!1);
|
|
343
|
+
else if (e.key === "Enter" && v >= 0) {
|
|
344
|
+
e.preventDefault();
|
|
345
|
+
let t = L[v];
|
|
346
|
+
if (t) {
|
|
347
|
+
let e = T.includes(t.value), n = e ? T.filter((e) => e !== t.value) : w ? [...T, t.value] : [t.value];
|
|
348
|
+
if (!e && w && r.maxSelections && n.length > r.maxSelections) return;
|
|
349
|
+
r.onValueChange ? r.onValueChange(n) : o(n), w || R();
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
e.stopPropagation();
|
|
353
|
+
}
|
|
354
|
+
}), /* @__PURE__ */ P(g, {})] }), /* @__PURE__ */ P("div", {
|
|
355
|
+
className: "relative flex max-h-full",
|
|
356
|
+
children: /* @__PURE__ */ P("div", {
|
|
357
|
+
className: "flex max-h-[min(var(--radix-dropdown-menu-content-available-height),24rem)] w-full scroll-pt-2 scroll-pb-2 flex-col overscroll-contain",
|
|
358
|
+
role: "listbox",
|
|
359
|
+
id: `${C}-listbox`,
|
|
360
|
+
children: /* @__PURE__ */ F(n, {
|
|
361
|
+
className: "size-full min-h-0 **:data-[slot=scroll-area-scrollbar]:m-0 **:data-[slot=scroll-area-viewport]:h-full **:data-[slot=scroll-area-viewport]:overscroll-contain",
|
|
362
|
+
children: [
|
|
363
|
+
L.length === 0 && /* @__PURE__ */ P("div", {
|
|
364
|
+
className: "text-muted-foreground py-2 text-center text-sm",
|
|
365
|
+
children: S.i18n.noResultsFound
|
|
366
|
+
}),
|
|
367
|
+
O.length > 0 && /* @__PURE__ */ P(m, {
|
|
368
|
+
className: "px-1",
|
|
369
|
+
children: O.map((t, n) => {
|
|
370
|
+
let i = v === n;
|
|
371
|
+
return /* @__PURE__ */ F(f, {
|
|
372
|
+
id: `${C}-item-${n}`,
|
|
373
|
+
role: "option",
|
|
374
|
+
"aria-selected": i,
|
|
375
|
+
"data-highlighted": i || void 0,
|
|
376
|
+
onMouseEnter: () => y(n),
|
|
377
|
+
checked: !0,
|
|
378
|
+
className: e("data-highlighted:bg-accent data-highlighted:text-accent-foreground", t.className),
|
|
379
|
+
onSelect: (e) => {
|
|
380
|
+
w && e.preventDefault();
|
|
381
|
+
},
|
|
382
|
+
onCheckedChange: () => {
|
|
383
|
+
let e = T.filter((e) => e !== t.value);
|
|
384
|
+
r.onValueChange ? r.onValueChange(e) : o(e), w || R();
|
|
385
|
+
},
|
|
386
|
+
children: [t.icon && t.icon, /* @__PURE__ */ P("span", {
|
|
387
|
+
className: "truncate",
|
|
388
|
+
children: t.label
|
|
389
|
+
})]
|
|
390
|
+
}, String(t.value));
|
|
391
|
+
})
|
|
392
|
+
}),
|
|
393
|
+
O.length > 0 && I.length > 0 && /* @__PURE__ */ P(g, { className: "mx-0" }),
|
|
394
|
+
I.length > 0 && /* @__PURE__ */ P(m, {
|
|
395
|
+
className: "px-1",
|
|
396
|
+
children: I.map((t, n) => {
|
|
397
|
+
let i = n + O.length, a = v === i;
|
|
398
|
+
return /* @__PURE__ */ F(f, {
|
|
399
|
+
id: `${C}-item-${i}`,
|
|
400
|
+
role: "option",
|
|
401
|
+
"aria-selected": a,
|
|
402
|
+
"data-highlighted": a || void 0,
|
|
403
|
+
onMouseEnter: () => y(i),
|
|
404
|
+
checked: !1,
|
|
405
|
+
className: e("data-highlighted:bg-accent data-highlighted:text-accent-foreground", t.className),
|
|
406
|
+
onSelect: (e) => {
|
|
407
|
+
w && e.preventDefault();
|
|
408
|
+
},
|
|
409
|
+
onCheckedChange: () => {
|
|
410
|
+
let e = w ? [...T, t.value] : [t.value];
|
|
411
|
+
w && r.maxSelections && e.length > r.maxSelections || (r.onValueChange ? r.onValueChange(e) : o(e), w || R());
|
|
412
|
+
},
|
|
413
|
+
children: [t.icon && t.icon, /* @__PURE__ */ P("span", {
|
|
414
|
+
className: "truncate",
|
|
415
|
+
children: t.label
|
|
416
|
+
})]
|
|
417
|
+
}, String(t.value));
|
|
418
|
+
})
|
|
419
|
+
})
|
|
420
|
+
]
|
|
421
|
+
})
|
|
422
|
+
})
|
|
423
|
+
})] });
|
|
424
|
+
return c ? /* @__PURE__ */ P("div", {
|
|
425
|
+
className: "w-full",
|
|
426
|
+
children: z()
|
|
427
|
+
}) : /* @__PURE__ */ F(d, {
|
|
428
|
+
open: l,
|
|
429
|
+
onOpenChange: (e) => {
|
|
430
|
+
u(e), e || setTimeout(() => _(""), 200);
|
|
431
|
+
},
|
|
432
|
+
children: [/* @__PURE__ */ P(b, {
|
|
433
|
+
asChild: !0,
|
|
434
|
+
children: /* @__PURE__ */ P(t, {
|
|
435
|
+
variant: "outline",
|
|
436
|
+
size: S.size,
|
|
437
|
+
children: /* @__PURE__ */ P("div", {
|
|
438
|
+
className: "flex items-center gap-1.5",
|
|
439
|
+
children: r.customValueRenderer ? r.customValueRenderer(i, r.options || []) : /* @__PURE__ */ F(N, { children: [E.length > 0 && /* @__PURE__ */ P("div", {
|
|
440
|
+
className: "flex items-center -space-x-1.5",
|
|
441
|
+
children: E.slice(0, 3).map((e) => /* @__PURE__ */ P("div", { children: e.icon }, String(e.value)))
|
|
442
|
+
}), E.length === 1 ? E[0].label : E.length > 1 ? `${E.length} ${S.i18n.selectedCount}` : S.i18n.select] })
|
|
443
|
+
})
|
|
444
|
+
})
|
|
445
|
+
}), /* @__PURE__ */ P(p, {
|
|
446
|
+
align: "start",
|
|
447
|
+
className: e("w-[200px] px-0", r.className),
|
|
448
|
+
children: z()
|
|
449
|
+
})]
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
function ue({ field: t, values: n, onChange: r, operator: a, autoFocus: o }) {
|
|
453
|
+
return H(), a === "empty" || a === "not_empty" ? null : t.customRenderer ? /* @__PURE__ */ P(i, {
|
|
454
|
+
className: "hover:bg-accent aria-expanded:bg-accent text-start whitespace-nowrap outline-hidden",
|
|
455
|
+
children: t.customRenderer({
|
|
456
|
+
field: t,
|
|
457
|
+
values: n,
|
|
458
|
+
onChange: r,
|
|
459
|
+
operator: a
|
|
460
|
+
})
|
|
461
|
+
}) : t.type === "text" ? /* @__PURE__ */ P(ie, {
|
|
462
|
+
type: "text",
|
|
463
|
+
value: n[0] || "",
|
|
464
|
+
onChange: (e) => r([e.target.value]),
|
|
465
|
+
placeholder: t.placeholder,
|
|
466
|
+
pattern: t.pattern,
|
|
467
|
+
field: t,
|
|
468
|
+
className: e("w-36", t.className),
|
|
469
|
+
autoFocus: o
|
|
470
|
+
}) : (t.type === "select" || t.type, /* @__PURE__ */ P(q, {
|
|
471
|
+
field: t,
|
|
472
|
+
values: n,
|
|
473
|
+
onChange: r
|
|
474
|
+
}));
|
|
475
|
+
}
|
|
476
|
+
var J = ({ filters: t, fields: n, onChange: a }) => {
|
|
477
|
+
let o = H(), s = A(() => ce(n), [n]), c = D((e, n) => {
|
|
478
|
+
a(t.map((t) => {
|
|
479
|
+
if (t.id === e) {
|
|
480
|
+
let e = {
|
|
481
|
+
...t,
|
|
482
|
+
...n
|
|
483
|
+
};
|
|
484
|
+
return (n.operator === "empty" || n.operator === "not_empty") && (e.values = []), e;
|
|
485
|
+
}
|
|
486
|
+
return t;
|
|
487
|
+
}));
|
|
488
|
+
}, [t, a]), l = D((e) => {
|
|
489
|
+
a(t.filter((t) => t.id !== e));
|
|
490
|
+
}, [t, a]);
|
|
491
|
+
return /* @__PURE__ */ P("div", {
|
|
492
|
+
className: e(re({
|
|
493
|
+
variant: o.variant,
|
|
494
|
+
size: o.size
|
|
495
|
+
}), o.className),
|
|
496
|
+
children: t.map((e) => {
|
|
497
|
+
let t = s[e.field];
|
|
498
|
+
return t ? /* @__PURE__ */ F(r, { children: [
|
|
499
|
+
/* @__PURE__ */ F(i, { children: [t.icon && t.icon, t.label] }),
|
|
500
|
+
/* @__PURE__ */ P(le, {
|
|
501
|
+
field: t,
|
|
502
|
+
operator: e.operator,
|
|
503
|
+
values: e.values,
|
|
504
|
+
onChange: (t) => c(e.id, { operator: t })
|
|
505
|
+
}),
|
|
506
|
+
/* @__PURE__ */ P(ue, {
|
|
507
|
+
field: t,
|
|
508
|
+
values: e.values,
|
|
509
|
+
onChange: (t) => c(e.id, { values: t }),
|
|
510
|
+
operator: e.operator,
|
|
511
|
+
autoFocus: !1
|
|
512
|
+
}),
|
|
513
|
+
/* @__PURE__ */ P(ae, { onClick: () => l(e.id) })
|
|
514
|
+
] }, e.id) : null;
|
|
515
|
+
})
|
|
516
|
+
});
|
|
517
|
+
};
|
|
518
|
+
function de({ field: t, currentValues: r, isMultiSelect: i, onToggle: o, i18n: s, isActive: c, onActive: l, onBack: u, onClose: d }) {
|
|
519
|
+
let [p, h] = M(""), [_, v] = M(-1), y = j(null), b = ee();
|
|
520
|
+
k(() => {
|
|
521
|
+
v(-1);
|
|
522
|
+
}, [p]), k(() => {
|
|
523
|
+
_ >= 0 && c && document.getElementById(`${b}-item-${_}`)?.scrollIntoView({ block: "nearest" });
|
|
524
|
+
}, [
|
|
525
|
+
_,
|
|
526
|
+
c,
|
|
527
|
+
b
|
|
528
|
+
]);
|
|
529
|
+
let x = A(() => t.options?.filter((e) => r.includes(e.value) || !p ? !0 : e.label.toLowerCase().includes(p.toLowerCase())) || [], [
|
|
530
|
+
t.options,
|
|
531
|
+
p,
|
|
532
|
+
r
|
|
533
|
+
]);
|
|
534
|
+
return k(() => {
|
|
535
|
+
c && x.length > 0 && v(0);
|
|
536
|
+
}, [c, x.length]), /* @__PURE__ */ F("div", {
|
|
537
|
+
className: "flex flex-col",
|
|
538
|
+
onMouseEnter: l,
|
|
539
|
+
children: [t.searchable !== !1 && /* @__PURE__ */ F(N, { children: [/* @__PURE__ */ P(a, {
|
|
540
|
+
ref: y,
|
|
541
|
+
role: "combobox",
|
|
542
|
+
"aria-autocomplete": "list",
|
|
543
|
+
"aria-expanded": !0,
|
|
544
|
+
"aria-haspopup": "listbox",
|
|
545
|
+
"aria-controls": `${b}-listbox`,
|
|
546
|
+
"aria-activedescendant": _ >= 0 ? `${b}-item-${_}` : void 0,
|
|
547
|
+
placeholder: s.placeholders.searchField(t.label || ""),
|
|
548
|
+
className: e("h-8 rounded-none border-0 bg-transparent! px-2 text-sm shadow-none", "focus-visible:border-border focus-visible:ring-0 focus-visible:ring-offset-0"),
|
|
549
|
+
value: p,
|
|
550
|
+
onChange: (e) => h(e.target.value),
|
|
551
|
+
onClick: (e) => e.stopPropagation(),
|
|
552
|
+
onKeyDown: (e) => {
|
|
553
|
+
if (e.key === "ArrowDown") e.preventDefault(), x.length > 0 && v((e) => e < x.length - 1 ? e + 1 : 0);
|
|
554
|
+
else if (e.key === "ArrowUp") e.preventDefault(), x.length > 0 && v((e) => e > 0 ? e - 1 : x.length - 1);
|
|
555
|
+
else if (e.key === "ArrowLeft") e.preventDefault(), u?.();
|
|
556
|
+
else if (e.key === "Enter" && _ >= 0) {
|
|
557
|
+
e.preventDefault();
|
|
558
|
+
let t = x[_];
|
|
559
|
+
t && (o(t.value, r.includes(t.value)), i || u?.());
|
|
560
|
+
} else e.key === "Escape" && (e.preventDefault(), d?.());
|
|
561
|
+
e.stopPropagation();
|
|
562
|
+
}
|
|
563
|
+
}), /* @__PURE__ */ P(g, {})] }), /* @__PURE__ */ P("div", {
|
|
564
|
+
className: "relative flex max-h-full",
|
|
565
|
+
children: /* @__PURE__ */ P("div", {
|
|
566
|
+
className: "flex max-h-[min(var(--radix-dropdown-menu-content-available-height),24rem)] w-full scroll-pt-2 scroll-pb-2 flex-col overscroll-contain outline-hidden",
|
|
567
|
+
role: "listbox",
|
|
568
|
+
id: `${b}-listbox`,
|
|
569
|
+
tabIndex: t.searchable === !1 ? 0 : -1,
|
|
570
|
+
onKeyDown: (e) => {
|
|
571
|
+
if (t.searchable === !1) {
|
|
572
|
+
if (e.key === "ArrowDown") e.preventDefault(), x.length > 0 && v((e) => e < x.length - 1 ? e + 1 : 0);
|
|
573
|
+
else if (e.key === "ArrowUp") e.preventDefault(), x.length > 0 && v((e) => e > 0 ? e - 1 : x.length - 1);
|
|
574
|
+
else if (e.key === "ArrowLeft") e.preventDefault(), u?.();
|
|
575
|
+
else if (e.key === "Enter" && _ >= 0) {
|
|
576
|
+
e.preventDefault();
|
|
577
|
+
let t = x[_];
|
|
578
|
+
t && (o(t.value, r.includes(t.value)), i || u?.());
|
|
579
|
+
} else e.key === "Escape" && (e.preventDefault(), d?.());
|
|
580
|
+
e.stopPropagation();
|
|
581
|
+
}
|
|
582
|
+
},
|
|
583
|
+
children: /* @__PURE__ */ P(n, {
|
|
584
|
+
className: "size-full min-h-0 **:data-[slot=scroll-area-scrollbar]:m-0 **:data-[slot=scroll-area-viewport]:h-full **:data-[slot=scroll-area-viewport]:overscroll-contain",
|
|
585
|
+
children: x.length === 0 ? /* @__PURE__ */ P("div", {
|
|
586
|
+
className: "text-muted-foreground py-2 text-center text-sm",
|
|
587
|
+
children: s.noResultsFound
|
|
588
|
+
}) : /* @__PURE__ */ P(m, { children: x.map((t, n) => {
|
|
589
|
+
let a = r.includes(t.value), s = _ === n;
|
|
590
|
+
return /* @__PURE__ */ F(f, {
|
|
591
|
+
id: `${b}-item-${n}`,
|
|
592
|
+
role: "option",
|
|
593
|
+
"aria-selected": s,
|
|
594
|
+
"data-highlighted": s || void 0,
|
|
595
|
+
onMouseEnter: () => v(n),
|
|
596
|
+
checked: a,
|
|
597
|
+
className: e("data-highlighted:bg-accent data-highlighted:text-accent-foreground", t.className),
|
|
598
|
+
onSelect: (e) => {
|
|
599
|
+
i && e.preventDefault();
|
|
600
|
+
},
|
|
601
|
+
onCheckedChange: () => o(t.value, a),
|
|
602
|
+
children: [t.icon && t.icon, /* @__PURE__ */ P("span", {
|
|
603
|
+
className: "truncate",
|
|
604
|
+
children: t.label
|
|
605
|
+
})]
|
|
606
|
+
}, String(t.value));
|
|
607
|
+
}) })
|
|
608
|
+
})
|
|
609
|
+
})
|
|
610
|
+
})]
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
function Y({ filters: o, fields: s, onChange: c, className: l, variant: u = "default", size: f = "default", radius: m = "default", i18n: S, showSearchInput: C = !0, trigger: w, allowMultiple: T = !0, menuPopupClassName: E, enableShortcut: O = !1, shortcutKey: I = "f", shortcutLabel: R = "F" }) {
|
|
614
|
+
let [z, B] = M(!1), [H, ie] = M(""), [oe, U] = M("root"), [W, G] = M(null), [K, q] = M(-1), [J, Y] = M(null), fe = j(null), Z = ee();
|
|
615
|
+
k(() => {
|
|
616
|
+
if (!O) return;
|
|
617
|
+
let e = (e) => {
|
|
618
|
+
e.key.toLowerCase() === I.toLowerCase() && !z && !(document.activeElement instanceof HTMLInputElement || document.activeElement instanceof HTMLTextAreaElement) && (e.preventDefault(), B(!0));
|
|
619
|
+
};
|
|
620
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
621
|
+
}, [
|
|
622
|
+
O,
|
|
623
|
+
I,
|
|
624
|
+
z
|
|
625
|
+
]), k(() => {
|
|
626
|
+
q(-1);
|
|
627
|
+
}, [H]), k(() => {
|
|
628
|
+
K >= 0 && z && document.getElementById(`${Z}-item-${K}`)?.scrollIntoView({ block: "nearest" });
|
|
629
|
+
}, [
|
|
630
|
+
K,
|
|
631
|
+
z,
|
|
632
|
+
Z
|
|
633
|
+
]), k(() => {
|
|
634
|
+
z || G(null);
|
|
635
|
+
}, [z]);
|
|
636
|
+
let [pe, me] = M({});
|
|
637
|
+
k(() => {
|
|
638
|
+
if (J) {
|
|
639
|
+
let e = setTimeout(() => {
|
|
640
|
+
Y(null);
|
|
641
|
+
}, 1e3);
|
|
642
|
+
return () => clearTimeout(e);
|
|
643
|
+
}
|
|
644
|
+
}, [J]);
|
|
645
|
+
let Q = {
|
|
646
|
+
...V,
|
|
647
|
+
...S,
|
|
648
|
+
operators: {
|
|
649
|
+
...V.operators,
|
|
650
|
+
...S?.operators
|
|
651
|
+
},
|
|
652
|
+
placeholders: {
|
|
653
|
+
...V.placeholders,
|
|
654
|
+
...S?.placeholders
|
|
655
|
+
},
|
|
656
|
+
validation: {
|
|
657
|
+
...V.validation,
|
|
658
|
+
...S?.validation
|
|
659
|
+
}
|
|
660
|
+
}, he = A(() => ce(s), [s]), ge = D((e, t) => {
|
|
661
|
+
c(o.map((n) => {
|
|
662
|
+
if (n.id === e) {
|
|
663
|
+
let e = {
|
|
664
|
+
...n,
|
|
665
|
+
...t
|
|
666
|
+
};
|
|
667
|
+
return (t.operator === "empty" || t.operator === "not_empty") && (e.values = []), e;
|
|
668
|
+
}
|
|
669
|
+
return n;
|
|
670
|
+
}));
|
|
671
|
+
}, [o, c]), _e = D((e) => {
|
|
672
|
+
c(o.filter((t) => t.id !== e));
|
|
673
|
+
}, [o, c]), ve = D((e) => {
|
|
674
|
+
let t = he[e];
|
|
675
|
+
if (t && t.key) {
|
|
676
|
+
let n = X(e, t.defaultOperator || (t.type === "multiselect" ? "is_any_of" : "is"), t.type === "text" ? [""] : []);
|
|
677
|
+
Y(n.id), c([...o, n]), B(!1), ie("");
|
|
678
|
+
}
|
|
679
|
+
}, [
|
|
680
|
+
he,
|
|
681
|
+
o,
|
|
682
|
+
c
|
|
683
|
+
]), ye = A(() => se(s).filter((e) => !e.key || e.type === "separator" ? !1 : T ? !0 : !o.some((t) => t.field === e.key)), [
|
|
684
|
+
s,
|
|
685
|
+
o,
|
|
686
|
+
T
|
|
687
|
+
]), $ = A(() => ye.filter((e) => !H || e.label?.toLowerCase().includes(H.toLowerCase())), [ye, H]);
|
|
688
|
+
return k(() => {
|
|
689
|
+
z && $.length > 0 && q(0);
|
|
690
|
+
}, [z, $.length]), /* @__PURE__ */ P(ne.Provider, {
|
|
691
|
+
value: {
|
|
692
|
+
variant: u,
|
|
693
|
+
size: f,
|
|
694
|
+
radius: m,
|
|
695
|
+
i18n: Q,
|
|
696
|
+
className: l,
|
|
697
|
+
trigger: w,
|
|
698
|
+
allowMultiple: T
|
|
699
|
+
},
|
|
700
|
+
children: /* @__PURE__ */ F("div", {
|
|
701
|
+
className: e(re({
|
|
702
|
+
variant: u,
|
|
703
|
+
size: f
|
|
704
|
+
}), l),
|
|
705
|
+
children: [ye.length > 0 && /* @__PURE__ */ F(d, {
|
|
706
|
+
open: z,
|
|
707
|
+
onOpenChange: (e) => {
|
|
708
|
+
B(e), e ? U("root") : (ie(""), me({}));
|
|
709
|
+
},
|
|
710
|
+
children: [/* @__PURE__ */ P(b, {
|
|
711
|
+
asChild: !0,
|
|
712
|
+
children: w || /* @__PURE__ */ F(t, {
|
|
713
|
+
variant: "outline",
|
|
714
|
+
children: [/* @__PURE__ */ P(L, {
|
|
715
|
+
icon: te,
|
|
716
|
+
strokeWidth: 2
|
|
717
|
+
}), Q.addFilter]
|
|
718
|
+
})
|
|
719
|
+
}), /* @__PURE__ */ F(p, {
|
|
720
|
+
className: e("w-[220px]", E),
|
|
721
|
+
align: "start",
|
|
722
|
+
children: [C && /* @__PURE__ */ F(N, { children: [/* @__PURE__ */ F("div", {
|
|
723
|
+
className: "relative",
|
|
724
|
+
children: [/* @__PURE__ */ P(a, {
|
|
725
|
+
ref: fe,
|
|
726
|
+
role: "combobox",
|
|
727
|
+
"aria-controls": `${Z}-listbox`,
|
|
728
|
+
"aria-activedescendant": K >= 0 ? `${Z}-item-${K}` : void 0,
|
|
729
|
+
placeholder: Q.searchFields,
|
|
730
|
+
className: e("h-8 rounded-none border-0 bg-transparent! px-2 text-sm shadow-none", "focus-visible:border-border focus-visible:ring-0 focus-visible:ring-offset-0"),
|
|
731
|
+
value: H,
|
|
732
|
+
onChange: (e) => ie(e.target.value),
|
|
733
|
+
onClick: (e) => e.stopPropagation(),
|
|
734
|
+
onKeyDown: (e) => {
|
|
735
|
+
if (e.key === "ArrowDown") e.preventDefault(), $.length > 0 && q((e) => e < $.length - 1 ? e + 1 : 0);
|
|
736
|
+
else if (e.key === "ArrowUp") e.preventDefault(), $.length > 0 && q((e) => e > 0 ? e - 1 : $.length - 1);
|
|
737
|
+
else if ((e.key === "ArrowRight" || e.key === "ArrowLeft") && K >= 0) {
|
|
738
|
+
let t = $[K], n = t && (t.type === "select" || t.type === "multiselect") && t.options?.length;
|
|
739
|
+
e.key === "ArrowRight" && n ? (e.preventDefault(), G(t.key || null), U(t.key || "root")) : e.key === "ArrowLeft" && (e.preventDefault(), W && (G(null), U("root")));
|
|
740
|
+
} else if (e.key === "Enter" && K >= 0) {
|
|
741
|
+
e.preventDefault();
|
|
742
|
+
let t = $[K];
|
|
743
|
+
t.key && ((t.type === "select" || t.type === "multiselect") && t.options?.length ? W === t.key ? (G(null), U("root")) : (G(t.key), U(t.key)) : ve(t.key));
|
|
744
|
+
} else e.key === "Escape" && B(!1);
|
|
745
|
+
e.stopPropagation();
|
|
746
|
+
}
|
|
747
|
+
}), O && R && /* @__PURE__ */ P(x, {
|
|
748
|
+
className: "bg-background absolute top-1/2 right-2 -translate-y-1/2 border",
|
|
749
|
+
children: R
|
|
750
|
+
})]
|
|
751
|
+
}), /* @__PURE__ */ P(g, {})] }), /* @__PURE__ */ P("div", {
|
|
752
|
+
className: "relative flex max-h-full",
|
|
753
|
+
children: /* @__PURE__ */ P("div", {
|
|
754
|
+
className: "flex max-h-[min(var(--radix-dropdown-menu-content-available-height),24rem)] w-full scroll-pt-2 scroll-pb-2 flex-col overscroll-contain",
|
|
755
|
+
role: "listbox",
|
|
756
|
+
id: `${Z}-listbox`,
|
|
757
|
+
children: /* @__PURE__ */ P(n, {
|
|
758
|
+
className: "**:data-[slot=scroll-area-scrollbar]:m-0",
|
|
759
|
+
children: $.length === 0 ? /* @__PURE__ */ P("div", {
|
|
760
|
+
className: "text-muted-foreground py-2 text-center text-sm",
|
|
761
|
+
children: Q.noFieldsFound
|
|
762
|
+
}) : $.map((e, t) => {
|
|
763
|
+
let n = K === t, r = `${Z}-item-${t}`;
|
|
764
|
+
if ((e.type === "select" || e.type === "multiselect") && e.options?.length) {
|
|
765
|
+
let i = e.type === "multiselect", a = e.key, s = pe[a], l = s ? o.find((e) => e.id === s) : null, u = l?.values || [];
|
|
766
|
+
return /* @__PURE__ */ F(_, {
|
|
767
|
+
open: W === a,
|
|
768
|
+
onOpenChange: (e) => {
|
|
769
|
+
e ? G((e) => e === a ? e : a) : W === a && (G(null), U("root"));
|
|
770
|
+
},
|
|
771
|
+
children: [/* @__PURE__ */ F(y, {
|
|
772
|
+
id: r,
|
|
773
|
+
role: "option",
|
|
774
|
+
"aria-selected": n,
|
|
775
|
+
"data-highlighted": n || void 0,
|
|
776
|
+
onMouseEnter: () => q(t),
|
|
777
|
+
className: "data-[state=open]:bg-accent data-[state=open]:text-accent-foreground data-highlighted:bg-accent data-highlighted:text-accent-foreground",
|
|
778
|
+
children: [e.icon, /* @__PURE__ */ P("span", { children: e.label })]
|
|
779
|
+
}), /* @__PURE__ */ P(v, {
|
|
780
|
+
className: "w-[200px]",
|
|
781
|
+
children: /* @__PURE__ */ P(de, {
|
|
782
|
+
field: e,
|
|
783
|
+
currentValues: u,
|
|
784
|
+
isMultiSelect: i,
|
|
785
|
+
i18n: Q,
|
|
786
|
+
isActive: oe === a,
|
|
787
|
+
onActive: () => {
|
|
788
|
+
e.searchable !== !1 && U(a);
|
|
789
|
+
},
|
|
790
|
+
onBack: () => {
|
|
791
|
+
G(null), U("root");
|
|
792
|
+
},
|
|
793
|
+
onClose: () => B(!1),
|
|
794
|
+
onToggle: (t, n) => {
|
|
795
|
+
if (i) {
|
|
796
|
+
let r = n ? u.filter((e) => e !== t) : [...u, t];
|
|
797
|
+
if (l) r.length === 0 ? (c(o.filter((e) => e.id !== l.id)), me((e) => ({
|
|
798
|
+
...e,
|
|
799
|
+
[a]: ""
|
|
800
|
+
}))) : c(o.map((e) => e.id === l.id ? {
|
|
801
|
+
...e,
|
|
802
|
+
values: r
|
|
803
|
+
} : e));
|
|
804
|
+
else {
|
|
805
|
+
let t = X(a, e.defaultOperator || "is_any_of", r);
|
|
806
|
+
c([...o, t]), me((e) => ({
|
|
807
|
+
...e,
|
|
808
|
+
[a]: t.id
|
|
809
|
+
}));
|
|
810
|
+
}
|
|
811
|
+
} else {
|
|
812
|
+
let n = X(a, e.defaultOperator || "is", [t]);
|
|
813
|
+
Y(n.id), c([...o, n]), B(!1);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
})
|
|
817
|
+
})]
|
|
818
|
+
}, a);
|
|
819
|
+
}
|
|
820
|
+
return /* @__PURE__ */ F(h, {
|
|
821
|
+
id: r,
|
|
822
|
+
role: "option",
|
|
823
|
+
"aria-selected": n,
|
|
824
|
+
"data-highlighted": n || void 0,
|
|
825
|
+
onMouseEnter: () => q(t),
|
|
826
|
+
onClick: () => e.key && ve(e.key),
|
|
827
|
+
className: "data-highlighted:bg-accent data-highlighted:text-accent-foreground",
|
|
828
|
+
children: [e.icon, /* @__PURE__ */ P("span", { children: e.label })]
|
|
829
|
+
}, e.key);
|
|
830
|
+
})
|
|
831
|
+
})
|
|
832
|
+
})
|
|
833
|
+
})]
|
|
834
|
+
})]
|
|
835
|
+
}), o.map((e) => {
|
|
836
|
+
let t = he[e.field];
|
|
837
|
+
return t ? /* @__PURE__ */ F(r, { children: [
|
|
838
|
+
/* @__PURE__ */ F(i, {
|
|
839
|
+
className: "",
|
|
840
|
+
children: [t.icon && t.icon, t.label]
|
|
841
|
+
}),
|
|
842
|
+
/* @__PURE__ */ P(le, {
|
|
843
|
+
field: t,
|
|
844
|
+
operator: e.operator,
|
|
845
|
+
values: e.values,
|
|
846
|
+
onChange: (t) => ge(e.id, { operator: t })
|
|
847
|
+
}),
|
|
848
|
+
/* @__PURE__ */ P(ue, {
|
|
849
|
+
field: t,
|
|
850
|
+
values: e.values,
|
|
851
|
+
operator: e.operator,
|
|
852
|
+
onChange: (t) => ge(e.id, { values: t }),
|
|
853
|
+
autoFocus: e.id === J
|
|
854
|
+
}),
|
|
855
|
+
/* @__PURE__ */ P(ae, { onClick: () => _e(e.id) })
|
|
856
|
+
] }, e.id) : null;
|
|
857
|
+
})]
|
|
858
|
+
})
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
var X = (e, t, n = []) => ({
|
|
862
|
+
id: `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`,
|
|
863
|
+
field: e,
|
|
864
|
+
operator: t || "is",
|
|
865
|
+
values: n
|
|
866
|
+
}), fe = (e, t, n, r = []) => ({
|
|
867
|
+
id: e,
|
|
868
|
+
label: t,
|
|
869
|
+
filters: r,
|
|
870
|
+
fields: n
|
|
871
|
+
});
|
|
872
|
+
//#endregion
|
|
873
|
+
export { V as DEFAULT_I18N, G as DEFAULT_OPERATORS, Y as Filters, J as FiltersContent, X as createFilter, fe as createFilterGroup };
|