@constructive-io/ui 0.4.1 → 0.6.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/LICENSE +21 -0
- package/README.md +17 -22
- package/dist/components/alert-dialog.cjs +333 -0
- package/dist/components/alert-dialog.cjs.map +1 -0
- package/dist/components/alert-dialog.d.cts +32 -0
- package/dist/components/alert-dialog.d.ts +16 -15
- package/dist/components/alert-dialog.js +89 -102
- package/dist/components/alert-dialog.js.map +1 -1
- package/dist/components/alert.cjs +119 -0
- package/dist/components/alert.cjs.map +1 -0
- package/dist/components/alert.d.cts +19 -0
- package/dist/components/alert.d.ts +10 -5
- package/dist/components/alert.js +62 -6
- package/dist/components/alert.js.map +1 -1
- package/dist/components/app-bar.cjs +367 -0
- package/dist/components/app-bar.cjs.map +1 -0
- package/dist/components/app-bar.d.cts +26 -0
- package/dist/components/app-bar.d.ts +26 -0
- package/dist/components/app-bar.js +344 -0
- package/dist/components/app-bar.js.map +1 -0
- package/dist/components/app-shell.cjs +1792 -0
- package/dist/components/app-shell.cjs.map +1 -0
- package/dist/components/app-shell.d.cts +106 -0
- package/dist/components/app-shell.d.ts +106 -0
- package/dist/components/app-shell.js +1771 -0
- package/dist/components/app-shell.js.map +1 -0
- package/dist/components/autocomplete.cjs +418 -0
- package/dist/components/autocomplete.cjs.map +1 -0
- package/dist/components/autocomplete.d.cts +28 -0
- package/dist/components/autocomplete.d.ts +15 -15
- package/dist/components/autocomplete.js +9 -30
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/avatar.cjs +51 -0
- package/dist/components/avatar.cjs.map +1 -0
- package/dist/components/avatar.d.cts +12 -0
- package/dist/components/avatar.d.ts +3 -4
- package/dist/components/avatar.js +11 -1
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/badge.cjs +66 -0
- package/dist/components/badge.cjs.map +1 -0
- package/dist/components/badge.d.cts +15 -0
- package/dist/components/badge.js +1 -1
- package/dist/components/badge.js.map +1 -1
- package/dist/components/breadcrumb.cjs +118 -0
- package/dist/components/breadcrumb.cjs.map +1 -0
- package/dist/components/breadcrumb.d.cts +14 -0
- package/dist/components/breadcrumb.d.ts +9 -9
- package/dist/components/breadcrumb.js +19 -83
- package/dist/components/breadcrumb.js.map +1 -1
- package/dist/components/button.cjs +169 -0
- package/dist/components/button.cjs.map +1 -0
- package/dist/components/button.d.cts +20 -0
- package/dist/components/button.d.ts +3 -0
- package/dist/components/button.js +105 -21
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar-rac.cjs +85 -0
- package/dist/components/calendar-rac.cjs.map +1 -0
- package/dist/components/calendar-rac.d.cts +13 -0
- package/dist/components/calendar-rac.d.ts +3 -3
- package/dist/components/card.cjs +99 -0
- package/dist/components/card.cjs.map +1 -0
- package/dist/components/card.d.cts +18 -0
- package/dist/components/card.d.ts +7 -8
- package/dist/components/card.js +23 -8
- package/dist/components/card.js.map +1 -1
- package/dist/components/checkbox-group.cjs +18 -0
- package/dist/components/checkbox-group.cjs.map +1 -0
- package/dist/components/checkbox-group.d.cts +7 -0
- package/dist/components/checkbox-group.d.ts +2 -2
- package/dist/components/checkbox.cjs +121 -0
- package/dist/components/checkbox.cjs.map +1 -0
- package/dist/components/checkbox.d.cts +8 -0
- package/dist/components/checkbox.d.ts +3 -3
- package/dist/components/checkbox.js +73 -41
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/collapsible.cjs +127 -0
- package/dist/components/collapsible.cjs.map +1 -0
- package/dist/components/collapsible.d.cts +44 -0
- package/dist/components/collapsible.d.ts +8 -18
- package/dist/components/collapsible.js +7 -27
- package/dist/components/collapsible.js.map +1 -1
- package/dist/components/combobox.cjs +551 -0
- package/dist/components/combobox.cjs.map +1 -0
- package/dist/components/combobox.d.cts +43 -0
- package/dist/components/combobox.d.ts +17 -18
- package/dist/components/combobox.js +37 -48
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/command.cjs +236 -0
- package/dist/components/command.cjs.map +1 -0
- package/dist/components/command.d.cts +23 -0
- package/dist/components/command.d.ts +14 -15
- package/dist/components/command.js +5 -38
- package/dist/components/command.js.map +1 -1
- package/dist/components/dialog.cjs +431 -0
- package/dist/components/dialog.cjs.map +1 -0
- package/dist/components/dialog.d.cts +30 -0
- package/dist/components/dialog.d.ts +13 -18
- package/dist/components/dialog.js +75 -119
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/dock.cjs +121 -0
- package/dist/components/dock.cjs.map +1 -0
- package/dist/components/dock.d.cts +30 -0
- package/dist/components/dock.d.ts +1 -2
- package/dist/components/dock.js +7 -5
- package/dist/components/dock.js.map +1 -1
- package/dist/components/drawer.cjs +149 -0
- package/dist/components/drawer.cjs.map +1 -0
- package/dist/components/drawer.d.cts +15 -0
- package/dist/components/drawer.d.ts +10 -11
- package/dist/components/drawer.js +11 -40
- package/dist/components/drawer.js.map +1 -1
- package/dist/components/dropdown-menu.cjs +292 -0
- package/dist/components/dropdown-menu.cjs.map +1 -0
- package/dist/components/dropdown-menu.d.cts +52 -0
- package/dist/components/dropdown-menu.d.ts +23 -21
- package/dist/components/dropdown-menu.js +67 -191
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/empty.cjs +106 -0
- package/dist/components/empty.cjs.map +1 -0
- package/dist/components/empty.d.cts +15 -0
- package/dist/components/empty.d.ts +15 -0
- package/dist/components/empty.js +99 -0
- package/dist/components/empty.js.map +1 -0
- package/dist/components/field.cjs +295 -0
- package/dist/components/field.cjs.map +1 -0
- package/dist/components/field.d.cts +46 -0
- package/dist/components/field.d.ts +34 -39
- package/dist/components/field.js +220 -72
- package/dist/components/field.js.map +1 -1
- package/dist/components/flickering-grid.cjs +176 -0
- package/dist/components/flickering-grid.cjs.map +1 -0
- package/dist/components/flickering-grid.d.cts +15 -0
- package/dist/components/flickering-grid.js +25 -2
- package/dist/components/flickering-grid.js.map +1 -1
- package/dist/components/flow-zoom-panel.cjs +194 -0
- package/dist/components/flow-zoom-panel.cjs.map +1 -0
- package/dist/components/flow-zoom-panel.d.cts +12 -0
- package/dist/components/flow-zoom-panel.d.ts +12 -0
- package/dist/components/flow-zoom-panel.js +173 -0
- package/dist/components/flow-zoom-panel.js.map +1 -0
- package/dist/components/form-control.cjs +193 -0
- package/dist/components/form-control.cjs.map +1 -0
- package/dist/components/form-control.d.cts +14 -0
- package/dist/components/form-control.d.ts +1 -2
- package/dist/components/form-control.js +2 -4
- package/dist/components/form-control.js.map +1 -1
- package/dist/components/form.cjs +208 -0
- package/dist/components/form.cjs.map +1 -0
- package/dist/components/form.d.cts +36 -0
- package/dist/components/form.d.ts +7 -8
- package/dist/components/input-group.cjs +184 -0
- package/dist/components/input-group.cjs.map +1 -0
- package/dist/components/input-group.d.cts +17 -0
- package/dist/components/input-group.d.ts +6 -7
- package/dist/components/input-group.js +3 -2
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input.cjs +62 -0
- package/dist/components/input.cjs.map +1 -0
- package/dist/components/input.d.cts +10 -0
- package/dist/components/input.d.ts +1 -2
- package/dist/components/input.js +1 -1
- package/dist/components/input.js.map +1 -1
- package/dist/components/json-input.cjs +351 -0
- package/dist/components/json-input.cjs.map +1 -0
- package/dist/components/json-input.d.cts +25 -0
- package/dist/components/json-input.d.ts +3 -3
- package/dist/components/json-input.js +89 -112
- package/dist/components/json-input.js.map +1 -1
- package/dist/components/label.cjs +29 -0
- package/dist/components/label.cjs.map +1 -0
- package/dist/components/label.d.cts +10 -0
- package/dist/components/label.d.ts +1 -2
- package/dist/components/motion-grid.cjs +108 -0
- package/dist/components/motion-grid.cjs.map +1 -0
- package/dist/components/motion-grid.d.cts +19 -0
- package/dist/components/motion-grid.d.ts +1 -2
- package/dist/components/motion-grid.js +9 -4
- package/dist/components/motion-grid.js.map +1 -1
- package/dist/components/multi-select.cjs +796 -0
- package/dist/components/multi-select.cjs.map +1 -0
- package/dist/components/multi-select.d.cts +198 -0
- package/dist/components/multi-select.js +54 -162
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/page-header.cjs +19 -0
- package/dist/components/page-header.cjs.map +1 -0
- package/dist/components/page-header.d.cts +17 -0
- package/dist/components/page-header.d.ts +2 -2
- package/dist/components/pagination.cjs +295 -0
- package/dist/components/pagination.cjs.map +1 -0
- package/dist/components/pagination.d.cts +18 -0
- package/dist/components/pagination.d.ts +7 -8
- package/dist/components/pagination.js +152 -29
- package/dist/components/pagination.js.map +1 -1
- package/dist/components/popover.cjs +140 -0
- package/dist/components/popover.cjs.map +1 -0
- package/dist/components/popover.d.cts +39 -0
- package/dist/components/popover.d.ts +13 -9
- package/dist/components/popover.js +56 -132
- package/dist/components/popover.js.map +1 -1
- package/dist/components/portal.cjs +109 -0
- package/dist/components/portal.cjs.map +1 -0
- package/dist/components/portal.d.cts +117 -0
- package/dist/components/portal.d.ts +16 -7
- package/dist/components/portal.js +13 -8
- package/dist/components/portal.js.map +1 -1
- package/dist/components/progress.cjs +31 -0
- package/dist/components/progress.cjs.map +1 -0
- package/dist/components/progress.d.cts +9 -0
- package/dist/components/progress.d.ts +1 -2
- package/dist/components/progress.js +1 -2
- package/dist/components/progress.js.map +1 -1
- package/dist/components/progressive-blur-scroll-container.cjs +144 -0
- package/dist/components/progressive-blur-scroll-container.cjs.map +1 -0
- package/dist/components/progressive-blur-scroll-container.d.cts +25 -0
- package/dist/components/progressive-blur-scroll-container.d.ts +2 -2
- package/dist/components/progressive-blur.cjs +70 -0
- package/dist/components/progressive-blur.cjs.map +1 -0
- package/dist/components/progressive-blur.d.cts +16 -0
- package/dist/components/progressive-blur.d.ts +2 -2
- package/dist/components/radio-group.cjs +52 -0
- package/dist/components/radio-group.cjs.map +1 -0
- package/dist/components/radio-group.d.cts +10 -0
- package/dist/components/radio-group.d.ts +3 -3
- package/dist/components/radio-group.js +21 -10
- package/dist/components/radio-group.js.map +1 -1
- package/dist/components/record-picker.cjs +420 -0
- package/dist/components/record-picker.cjs.map +1 -0
- package/dist/components/record-picker.d.cts +16 -0
- package/dist/components/record-picker.d.ts +2 -2
- package/dist/components/record-picker.js +76 -43
- package/dist/components/record-picker.js.map +1 -1
- package/dist/components/resizable.cjs +76 -0
- package/dist/components/resizable.cjs.map +1 -0
- package/dist/components/resizable.d.cts +10 -0
- package/dist/components/resizable.d.ts +3 -4
- package/dist/components/responsive-diagram.cjs +67 -0
- package/dist/components/responsive-diagram.cjs.map +1 -0
- package/dist/components/responsive-diagram.d.cts +10 -0
- package/dist/components/responsive-diagram.d.ts +2 -2
- package/dist/components/scroll-area.cjs +92 -0
- package/dist/components/scroll-area.cjs.map +1 -0
- package/dist/components/scroll-area.d.cts +11 -0
- package/dist/components/scroll-area.d.ts +5 -6
- package/dist/components/select.cjs +329 -0
- package/dist/components/select.cjs.map +1 -0
- package/dist/components/select.d.cts +46 -0
- package/dist/components/select.d.ts +13 -14
- package/dist/components/select.js +76 -67
- package/dist/components/select.js.map +1 -1
- package/dist/components/separator.cjs +26 -0
- package/dist/components/separator.cjs.map +1 -0
- package/dist/components/separator.d.cts +10 -0
- package/dist/components/separator.d.ts +1 -2
- package/dist/components/sheet.cjs +489 -0
- package/dist/components/sheet.cjs.map +1 -0
- package/dist/components/sheet.d.cts +107 -0
- package/dist/components/sheet.d.ts +14 -19
- package/dist/components/sheet.js +119 -264
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/sidebar.cjs +1300 -0
- package/dist/components/sidebar.cjs.map +1 -0
- package/dist/components/sidebar.d.cts +70 -0
- package/dist/components/sidebar.d.ts +32 -39
- package/dist/components/sidebar.js +401 -362
- package/dist/components/sidebar.js.map +1 -1
- package/dist/components/skeleton.cjs +36 -0
- package/dist/components/skeleton.cjs.map +1 -0
- package/dist/components/skeleton.d.cts +10 -0
- package/dist/components/skeleton.d.ts +5 -2
- package/dist/components/skeleton.js +19 -1
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/sonner.cjs +25 -0
- package/dist/components/sonner.cjs.map +1 -0
- package/dist/components/sonner.d.cts +10 -0
- package/dist/components/sonner.d.ts +2 -2
- package/dist/components/stack/index.cjs +1516 -0
- package/dist/components/stack/index.cjs.map +1 -0
- package/dist/components/stack/index.d.cts +672 -0
- package/dist/components/stack/index.d.ts +36 -38
- package/dist/components/stack/index.js +42 -31
- package/dist/components/stack/index.js.map +1 -1
- package/dist/components/stepper.cjs +314 -0
- package/dist/components/stepper.cjs.map +1 -0
- package/dist/components/stepper.d.cts +31 -0
- package/dist/components/stepper.d.ts +9 -8
- package/dist/components/stepper.js +22 -15
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/switch.cjs +46 -0
- package/dist/components/switch.cjs.map +1 -0
- package/dist/components/switch.d.cts +7 -0
- package/dist/components/switch.d.ts +1 -2
- package/dist/components/switch.js +9 -5
- package/dist/components/switch.js.map +1 -1
- package/dist/components/table.cjs +133 -0
- package/dist/components/table.cjs.map +1 -0
- package/dist/components/table.d.cts +22 -0
- package/dist/components/table.d.ts +19 -12
- package/dist/components/table.js +72 -13
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.cjs +53 -0
- package/dist/components/tabs.cjs.map +1 -0
- package/dist/components/tabs.d.cts +9 -0
- package/dist/components/tabs.d.ts +4 -5
- package/dist/components/tabs.js +2 -2
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/tags.cjs +451 -0
- package/dist/components/tags.cjs.map +1 -0
- package/dist/components/tags.d.cts +40 -0
- package/dist/components/tags.d.ts +10 -10
- package/dist/components/tags.js +129 -154
- package/dist/components/tags.js.map +1 -1
- package/dist/components/textarea.cjs +56 -0
- package/dist/components/textarea.cjs.map +1 -0
- package/dist/components/textarea.d.cts +9 -0
- package/dist/components/textarea.d.ts +1 -2
- package/dist/components/toast/index.cjs +612 -0
- package/dist/components/toast/index.cjs.map +1 -0
- package/dist/components/toast/index.d.cts +52 -0
- package/dist/components/toast/index.js +90 -127
- package/dist/components/toast/index.js.map +1 -1
- package/dist/components/tooltip.cjs +92 -0
- package/dist/components/tooltip.cjs.map +1 -0
- package/dist/components/tooltip.d.cts +28 -0
- package/dist/components/tooltip.d.ts +5 -6
- package/dist/components/tooltip.js +23 -130
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/unlink-button.cjs +197 -0
- package/dist/components/unlink-button.cjs.map +1 -0
- package/dist/components/unlink-button.d.cts +14 -0
- package/dist/components/unlink-button.d.ts +2 -2
- package/dist/components/unlink-button.js +105 -21
- package/dist/components/unlink-button.js.map +1 -1
- package/dist/index.cjs +2074 -2723
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +492 -904
- package/dist/index.d.ts +492 -904
- package/dist/index.js +1897 -2569
- package/dist/index.js.map +1 -1
- package/package.json +286 -45
- package/src/styles/globals.css +155 -203
- package/dist/components/org-chart/index.d.ts +0 -54
- package/dist/components/org-chart/index.js +0 -861
- package/dist/components/org-chart/index.js.map +0 -1
|
@@ -0,0 +1,796 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var React3 = require('react');
|
|
5
|
+
var classVarianceAuthority = require('class-variance-authority');
|
|
6
|
+
var lucideReact = require('lucide-react');
|
|
7
|
+
var clsx = require('clsx');
|
|
8
|
+
var tailwindMerge = require('tailwind-merge');
|
|
9
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
10
|
+
var popover = require('@base-ui/react/popover');
|
|
11
|
+
var portal = require('@constructive-io/ui/portal');
|
|
12
|
+
var separator = require('@base-ui/react/separator');
|
|
13
|
+
|
|
14
|
+
function _interopNamespace(e) {
|
|
15
|
+
if (e && e.__esModule) return e;
|
|
16
|
+
var n = Object.create(null);
|
|
17
|
+
if (e) {
|
|
18
|
+
Object.keys(e).forEach(function (k) {
|
|
19
|
+
if (k !== 'default') {
|
|
20
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return e[k]; }
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
n.default = e;
|
|
29
|
+
return Object.freeze(n);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
|
|
33
|
+
|
|
34
|
+
function cn(...inputs) {
|
|
35
|
+
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
36
|
+
}
|
|
37
|
+
var badgeVariants = classVarianceAuthority.cva(
|
|
38
|
+
"relative inline-flex shrink-0 items-center justify-center gap-1 whitespace-nowrap rounded-sm border border-transparent font-medium outline-none transition-shadow focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 [&_svg:not([class*='size-'])]:size-3 [&_svg]:pointer-events-none [&_svg]:shrink-0 [button,a&]:cursor-pointer [button,a&]:pointer-coarse:min-h-11 [button,a&]:pointer-coarse:min-w-11",
|
|
39
|
+
{
|
|
40
|
+
defaultVariants: {
|
|
41
|
+
size: "default",
|
|
42
|
+
variant: "default"
|
|
43
|
+
},
|
|
44
|
+
variants: {
|
|
45
|
+
size: {
|
|
46
|
+
default: "px-[calc(--spacing(1)-1px)] text-xs",
|
|
47
|
+
lg: "px-[calc(--spacing(1.5)-1px)] text-sm",
|
|
48
|
+
sm: "rounded-[calc(var(--radius-sm)-2px)] px-[calc(--spacing(1)-1px)] text-[.625rem]"
|
|
49
|
+
},
|
|
50
|
+
variant: {
|
|
51
|
+
default: "bg-primary text-primary-foreground [button,a&]:hover:bg-primary/90",
|
|
52
|
+
destructive: "bg-destructive text-white [button,a&]:hover:bg-destructive/90",
|
|
53
|
+
error: "bg-destructive/8 text-destructive dark:bg-destructive/16",
|
|
54
|
+
info: "bg-info/8 text-info-foreground dark:bg-info/16",
|
|
55
|
+
outline: "border-border/60 bg-transparent dark:bg-input/32 [button,a&]:hover:bg-accent/50 dark:[button,a&]:hover:bg-input/48",
|
|
56
|
+
secondary: "bg-secondary text-secondary-foreground [button,a&]:hover:bg-secondary/90",
|
|
57
|
+
success: "bg-success/8 text-success-foreground dark:bg-success/16",
|
|
58
|
+
warning: "bg-warning/8 text-warning-foreground dark:bg-warning/16"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
var Badge = React3__namespace.forwardRef(({ className, variant, size, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("span", { ref, "data-slot": "badge", className: cn(badgeVariants({ variant, size }), className), ...props }));
|
|
64
|
+
Badge.displayName = "Badge";
|
|
65
|
+
function Popover({ ...props }) {
|
|
66
|
+
return /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Root, { "data-slot": "popover", ...props });
|
|
67
|
+
}
|
|
68
|
+
function PopoverTrigger({ asChild, children, render, nativeButton, ...props }) {
|
|
69
|
+
const childRender = render === void 0 && asChild && React3__namespace.isValidElement(children) ? children : void 0;
|
|
70
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
71
|
+
popover.Popover.Trigger,
|
|
72
|
+
{
|
|
73
|
+
"data-slot": "popover-trigger",
|
|
74
|
+
nativeButton: nativeButton ?? (childRender ? true : void 0),
|
|
75
|
+
render: render ?? childRender,
|
|
76
|
+
...props,
|
|
77
|
+
children: childRender ? void 0 : children
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
function PopoverContent({
|
|
82
|
+
className,
|
|
83
|
+
align = "center",
|
|
84
|
+
sideOffset = 4,
|
|
85
|
+
showArrow = false,
|
|
86
|
+
side = "bottom",
|
|
87
|
+
children,
|
|
88
|
+
onOpenAutoFocus: _onOpenAutoFocus,
|
|
89
|
+
onCloseAutoFocus: _onCloseAutoFocus,
|
|
90
|
+
onFocusOutside: _onFocusOutside,
|
|
91
|
+
onEscapeKeyDown: _onEscapeKeyDown,
|
|
92
|
+
...props
|
|
93
|
+
}) {
|
|
94
|
+
const { container, zIndexClass } = portal.useFloatingOverlayPortalProps();
|
|
95
|
+
return /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Portal, { container, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
96
|
+
popover.Popover.Positioner,
|
|
97
|
+
{
|
|
98
|
+
side,
|
|
99
|
+
align,
|
|
100
|
+
sideOffset,
|
|
101
|
+
className: zIndexClass,
|
|
102
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
103
|
+
popover.Popover.Popup,
|
|
104
|
+
{
|
|
105
|
+
"data-slot": "popover-content",
|
|
106
|
+
className: cn(
|
|
107
|
+
`bg-popover text-popover-foreground origin-(--transform-origin) w-72 rounded-md border p-4 shadow-md outline-hidden
|
|
108
|
+
transition-[scale,opacity,translate] duration-150 ease-out data-starting-style:scale-95
|
|
109
|
+
data-ending-style:scale-95 data-starting-style:opacity-0 data-ending-style:opacity-0
|
|
110
|
+
data-[side=bottom]:data-starting-style:-translate-y-2
|
|
111
|
+
data-[side=left]:data-starting-style:translate-x-2
|
|
112
|
+
data-[side=right]:data-starting-style:-translate-x-2
|
|
113
|
+
data-[side=top]:data-starting-style:translate-y-2 motion-reduce:transition-none`,
|
|
114
|
+
className
|
|
115
|
+
),
|
|
116
|
+
...props,
|
|
117
|
+
children: [
|
|
118
|
+
children,
|
|
119
|
+
showArrow && /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Arrow, { className: "fill-popover -my-px drop-shadow-[0_1px_0_var(--border)]" })
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
) });
|
|
125
|
+
}
|
|
126
|
+
function Separator({ className, orientation = "horizontal", decorative: _decorative, ...props }) {
|
|
127
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
128
|
+
separator.Separator,
|
|
129
|
+
{
|
|
130
|
+
"data-slot": "separator-root",
|
|
131
|
+
orientation,
|
|
132
|
+
className: cn("bg-border shrink-0", orientation === "horizontal" ? "h-px w-full" : "h-full w-px", className),
|
|
133
|
+
...props
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
var multiSelectVariants = classVarianceAuthority.cva("m-0.5 inline-flex items-center gap-0.5 rounded-full border px-2 py-1 text-xs", {
|
|
138
|
+
variants: {
|
|
139
|
+
variant: {
|
|
140
|
+
default: "border-foreground/10 text-foreground bg-card",
|
|
141
|
+
secondary: "border-foreground/10 bg-secondary text-secondary-foreground",
|
|
142
|
+
destructive: "border-transparent bg-destructive text-destructive-foreground",
|
|
143
|
+
inverted: "inverted"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
defaultVariants: {
|
|
147
|
+
variant: "default"
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
function OptionItem({
|
|
151
|
+
option,
|
|
152
|
+
isSelected,
|
|
153
|
+
onSelect,
|
|
154
|
+
highlightedIndex,
|
|
155
|
+
index,
|
|
156
|
+
setHighlightedIndex
|
|
157
|
+
}) {
|
|
158
|
+
const isHighlighted = highlightedIndex === index;
|
|
159
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
160
|
+
"div",
|
|
161
|
+
{
|
|
162
|
+
role: "option",
|
|
163
|
+
"aria-selected": isSelected,
|
|
164
|
+
"aria-disabled": option.disabled,
|
|
165
|
+
"data-highlighted": isHighlighted,
|
|
166
|
+
"data-selected": isSelected,
|
|
167
|
+
"data-disabled": option.disabled,
|
|
168
|
+
tabIndex: -1,
|
|
169
|
+
className: cn(
|
|
170
|
+
"relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none",
|
|
171
|
+
"data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground",
|
|
172
|
+
"data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50"
|
|
173
|
+
),
|
|
174
|
+
onClick: (e) => {
|
|
175
|
+
e.preventDefault();
|
|
176
|
+
e.stopPropagation();
|
|
177
|
+
if (!option.disabled) {
|
|
178
|
+
onSelect();
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
onMouseEnter: () => setHighlightedIndex(index),
|
|
182
|
+
children: [
|
|
183
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
184
|
+
"div",
|
|
185
|
+
{
|
|
186
|
+
className: cn(
|
|
187
|
+
"border-primary mr-2 flex h-4 w-4 items-center justify-center rounded-sm border",
|
|
188
|
+
isSelected ? "bg-primary text-primary-foreground" : "opacity-60 [&_svg]:invisible"
|
|
189
|
+
),
|
|
190
|
+
"aria-hidden": "true",
|
|
191
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckIcon, { className: "h-4 w-4" })
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
option.icon && /* @__PURE__ */ jsxRuntime.jsx(option.icon, { className: "text-muted-foreground mr-2 h-4 w-4", "aria-hidden": "true" }),
|
|
195
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: option.label }),
|
|
196
|
+
option.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground ml-2 text-xs", children: option.description })
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
var MultiSelect = React3__namespace.forwardRef(
|
|
202
|
+
({
|
|
203
|
+
options,
|
|
204
|
+
onValueChange,
|
|
205
|
+
variant,
|
|
206
|
+
defaultValue = [],
|
|
207
|
+
placeholder = "Select options",
|
|
208
|
+
maxCount = 3,
|
|
209
|
+
className,
|
|
210
|
+
searchable = true,
|
|
211
|
+
emptyIndicator,
|
|
212
|
+
autoSize = false,
|
|
213
|
+
singleLine = false,
|
|
214
|
+
popoverClassName,
|
|
215
|
+
disabled = false,
|
|
216
|
+
responsive,
|
|
217
|
+
minWidth,
|
|
218
|
+
maxWidth,
|
|
219
|
+
dropdownMaxHeight,
|
|
220
|
+
deduplicateOptions = false,
|
|
221
|
+
footerContent,
|
|
222
|
+
resetOnDefaultValueChange = true,
|
|
223
|
+
closeOnSelect = false,
|
|
224
|
+
onClick,
|
|
225
|
+
...props
|
|
226
|
+
}, ref) => {
|
|
227
|
+
const [selectedValues, setSelectedValues] = React3__namespace.useState(defaultValue);
|
|
228
|
+
const [isPopoverOpen, setIsPopoverOpen] = React3__namespace.useState(false);
|
|
229
|
+
const [searchValue, setSearchValue] = React3__namespace.useState("");
|
|
230
|
+
const [highlightedIndex, setHighlightedIndex] = React3__namespace.useState(-1);
|
|
231
|
+
const multiSelectId = React3__namespace.useId();
|
|
232
|
+
const listboxId = `${multiSelectId}-listbox`;
|
|
233
|
+
const triggerDescriptionId = `${multiSelectId}-description`;
|
|
234
|
+
const selectedCountId = `${multiSelectId}-count`;
|
|
235
|
+
const searchInputId = `${multiSelectId}-search`;
|
|
236
|
+
const searchInputRef = React3__namespace.useRef(null);
|
|
237
|
+
const listRef = React3__namespace.useRef(null);
|
|
238
|
+
const prevDefaultValueRef = React3__namespace.useRef(defaultValue);
|
|
239
|
+
const isGroupedOptions = React3__namespace.useCallback(
|
|
240
|
+
(opts) => {
|
|
241
|
+
return opts.length > 0 && "heading" in opts[0];
|
|
242
|
+
},
|
|
243
|
+
[]
|
|
244
|
+
);
|
|
245
|
+
const arraysEqual = React3__namespace.useCallback((a, b) => {
|
|
246
|
+
if (a.length !== b.length) return false;
|
|
247
|
+
const sortedA = [...a].sort();
|
|
248
|
+
const sortedB = [...b].sort();
|
|
249
|
+
return sortedA.every((val, index) => val === sortedB[index]);
|
|
250
|
+
}, []);
|
|
251
|
+
const resetToDefault = React3__namespace.useCallback(() => {
|
|
252
|
+
setSelectedValues(defaultValue);
|
|
253
|
+
setIsPopoverOpen(false);
|
|
254
|
+
setSearchValue("");
|
|
255
|
+
onValueChange(defaultValue);
|
|
256
|
+
}, [defaultValue, onValueChange]);
|
|
257
|
+
const buttonRef = React3__namespace.useRef(null);
|
|
258
|
+
React3__namespace.useImperativeHandle(
|
|
259
|
+
ref,
|
|
260
|
+
() => ({
|
|
261
|
+
reset: resetToDefault,
|
|
262
|
+
getSelectedValues: () => selectedValues,
|
|
263
|
+
setSelectedValues: (values) => {
|
|
264
|
+
setSelectedValues(values);
|
|
265
|
+
onValueChange(values);
|
|
266
|
+
},
|
|
267
|
+
clear: () => {
|
|
268
|
+
setSelectedValues([]);
|
|
269
|
+
onValueChange([]);
|
|
270
|
+
},
|
|
271
|
+
focus: () => {
|
|
272
|
+
if (buttonRef.current) {
|
|
273
|
+
buttonRef.current.focus();
|
|
274
|
+
const originalOutline = buttonRef.current.style.outline;
|
|
275
|
+
const originalOutlineOffset = buttonRef.current.style.outlineOffset;
|
|
276
|
+
buttonRef.current.style.outline = "2px solid hsl(var(--ring))";
|
|
277
|
+
buttonRef.current.style.outlineOffset = "2px";
|
|
278
|
+
setTimeout(() => {
|
|
279
|
+
if (buttonRef.current) {
|
|
280
|
+
buttonRef.current.style.outline = originalOutline;
|
|
281
|
+
buttonRef.current.style.outlineOffset = originalOutlineOffset;
|
|
282
|
+
}
|
|
283
|
+
}, 1e3);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}),
|
|
287
|
+
[resetToDefault, selectedValues, onValueChange]
|
|
288
|
+
);
|
|
289
|
+
const [screenSize, setScreenSize] = React3__namespace.useState("desktop");
|
|
290
|
+
React3__namespace.useEffect(() => {
|
|
291
|
+
if (typeof window === "undefined") return;
|
|
292
|
+
const handleResize = () => {
|
|
293
|
+
const width = window.innerWidth;
|
|
294
|
+
if (width < 640) {
|
|
295
|
+
setScreenSize("mobile");
|
|
296
|
+
} else if (width < 1024) {
|
|
297
|
+
setScreenSize("tablet");
|
|
298
|
+
} else {
|
|
299
|
+
setScreenSize("desktop");
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
handleResize();
|
|
303
|
+
window.addEventListener("resize", handleResize);
|
|
304
|
+
return () => {
|
|
305
|
+
if (typeof window !== "undefined") {
|
|
306
|
+
window.removeEventListener("resize", handleResize);
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
}, []);
|
|
310
|
+
const getResponsiveSettings = () => {
|
|
311
|
+
if (!responsive) {
|
|
312
|
+
return {
|
|
313
|
+
maxCount,
|
|
314
|
+
hideIcons: false,
|
|
315
|
+
compactMode: false
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
if (responsive === true) {
|
|
319
|
+
const defaultResponsive = {
|
|
320
|
+
mobile: { maxCount: 2, hideIcons: false, compactMode: true },
|
|
321
|
+
tablet: { maxCount: 4, hideIcons: false, compactMode: false },
|
|
322
|
+
desktop: { maxCount: 6, hideIcons: false, compactMode: false }
|
|
323
|
+
};
|
|
324
|
+
const currentSettings2 = defaultResponsive[screenSize];
|
|
325
|
+
return {
|
|
326
|
+
maxCount: currentSettings2?.maxCount ?? maxCount,
|
|
327
|
+
hideIcons: currentSettings2?.hideIcons ?? false,
|
|
328
|
+
compactMode: currentSettings2?.compactMode ?? false
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
const currentSettings = responsive[screenSize];
|
|
332
|
+
return {
|
|
333
|
+
maxCount: currentSettings?.maxCount ?? maxCount,
|
|
334
|
+
hideIcons: currentSettings?.hideIcons ?? false,
|
|
335
|
+
compactMode: currentSettings?.compactMode ?? false
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
const responsiveSettings = getResponsiveSettings();
|
|
339
|
+
const getAllOptions = React3__namespace.useCallback(() => {
|
|
340
|
+
if (options.length === 0) return [];
|
|
341
|
+
let allOptions;
|
|
342
|
+
if (isGroupedOptions(options)) {
|
|
343
|
+
allOptions = options.flatMap((group) => group.options);
|
|
344
|
+
} else {
|
|
345
|
+
allOptions = options;
|
|
346
|
+
}
|
|
347
|
+
const valueSet = /* @__PURE__ */ new Set();
|
|
348
|
+
const duplicates = [];
|
|
349
|
+
const uniqueOptions = [];
|
|
350
|
+
allOptions.forEach((option) => {
|
|
351
|
+
if (valueSet.has(option.value)) {
|
|
352
|
+
duplicates.push(option.value);
|
|
353
|
+
if (!deduplicateOptions) {
|
|
354
|
+
uniqueOptions.push(option);
|
|
355
|
+
}
|
|
356
|
+
} else {
|
|
357
|
+
valueSet.add(option.value);
|
|
358
|
+
uniqueOptions.push(option);
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
if (process.env.NODE_ENV === "development" && duplicates.length > 0) {
|
|
362
|
+
const action = deduplicateOptions ? "automatically removed" : "detected";
|
|
363
|
+
console.warn(
|
|
364
|
+
`MultiSelect: Duplicate option values ${action}: ${duplicates.join(", ")}. ${deduplicateOptions ? "Duplicates have been removed automatically." : "This may cause unexpected behavior. Consider setting 'deduplicateOptions={true}' or ensure all option values are unique."}`
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
return deduplicateOptions ? uniqueOptions : allOptions;
|
|
368
|
+
}, [options, deduplicateOptions, isGroupedOptions]);
|
|
369
|
+
const getOptionByValue = React3__namespace.useCallback(
|
|
370
|
+
(value) => {
|
|
371
|
+
const option = getAllOptions().find((option2) => option2.value === value);
|
|
372
|
+
if (!option && process.env.NODE_ENV === "development") {
|
|
373
|
+
console.warn(`MultiSelect: Option with value "${value}" not found in options list`);
|
|
374
|
+
}
|
|
375
|
+
return option;
|
|
376
|
+
},
|
|
377
|
+
[getAllOptions]
|
|
378
|
+
);
|
|
379
|
+
const filteredOptions = React3__namespace.useMemo(() => {
|
|
380
|
+
if (!searchable || !searchValue) return options;
|
|
381
|
+
if (options.length === 0) return [];
|
|
382
|
+
if (isGroupedOptions(options)) {
|
|
383
|
+
return options.map((group) => ({
|
|
384
|
+
...group,
|
|
385
|
+
options: group.options.filter(
|
|
386
|
+
(option) => option.label.toLowerCase().includes(searchValue.toLowerCase()) || option.value.toLowerCase().includes(searchValue.toLowerCase())
|
|
387
|
+
)
|
|
388
|
+
})).filter((group) => group.options.length > 0);
|
|
389
|
+
}
|
|
390
|
+
return options.filter(
|
|
391
|
+
(option) => option.label.toLowerCase().includes(searchValue.toLowerCase()) || option.value.toLowerCase().includes(searchValue.toLowerCase())
|
|
392
|
+
);
|
|
393
|
+
}, [options, searchValue, searchable, isGroupedOptions]);
|
|
394
|
+
const flatFilteredOptions = React3__namespace.useMemo(() => {
|
|
395
|
+
if (isGroupedOptions(filteredOptions)) {
|
|
396
|
+
return filteredOptions.flatMap((group) => group.options);
|
|
397
|
+
}
|
|
398
|
+
return filteredOptions;
|
|
399
|
+
}, [filteredOptions, isGroupedOptions]);
|
|
400
|
+
const toggleOption = React3__namespace.useCallback(
|
|
401
|
+
(optionValue) => {
|
|
402
|
+
if (disabled) return;
|
|
403
|
+
const option = getOptionByValue(optionValue);
|
|
404
|
+
if (option?.disabled) return;
|
|
405
|
+
const newSelectedValues = selectedValues.includes(optionValue) ? selectedValues.filter((value) => value !== optionValue) : [...selectedValues, optionValue];
|
|
406
|
+
setSelectedValues(newSelectedValues);
|
|
407
|
+
onValueChange(newSelectedValues);
|
|
408
|
+
if (closeOnSelect) {
|
|
409
|
+
setIsPopoverOpen(false);
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
[disabled, getOptionByValue, selectedValues, onValueChange, closeOnSelect]
|
|
413
|
+
);
|
|
414
|
+
const handleClear = () => {
|
|
415
|
+
if (disabled) return;
|
|
416
|
+
setSelectedValues([]);
|
|
417
|
+
onValueChange([]);
|
|
418
|
+
};
|
|
419
|
+
const handleTogglePopover = () => {
|
|
420
|
+
if (disabled) return;
|
|
421
|
+
setIsPopoverOpen((prev) => !prev);
|
|
422
|
+
};
|
|
423
|
+
const clearExtraOptions = () => {
|
|
424
|
+
if (disabled) return;
|
|
425
|
+
const newSelectedValues = selectedValues.slice(0, responsiveSettings.maxCount);
|
|
426
|
+
setSelectedValues(newSelectedValues);
|
|
427
|
+
onValueChange(newSelectedValues);
|
|
428
|
+
};
|
|
429
|
+
const handleKeyDown = React3__namespace.useCallback(
|
|
430
|
+
(event) => {
|
|
431
|
+
const optionsCount = flatFilteredOptions.length;
|
|
432
|
+
if (optionsCount === 0) return;
|
|
433
|
+
switch (event.key) {
|
|
434
|
+
case "ArrowDown":
|
|
435
|
+
event.preventDefault();
|
|
436
|
+
setHighlightedIndex((prev) => prev < optionsCount - 1 ? prev + 1 : 0);
|
|
437
|
+
break;
|
|
438
|
+
case "ArrowUp":
|
|
439
|
+
event.preventDefault();
|
|
440
|
+
setHighlightedIndex((prev) => prev > 0 ? prev - 1 : optionsCount - 1);
|
|
441
|
+
break;
|
|
442
|
+
case "Enter":
|
|
443
|
+
event.preventDefault();
|
|
444
|
+
if (highlightedIndex >= 0 && highlightedIndex < optionsCount) {
|
|
445
|
+
const option = flatFilteredOptions[highlightedIndex];
|
|
446
|
+
if (option && !option.disabled) {
|
|
447
|
+
toggleOption(option.value);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
break;
|
|
451
|
+
case "Escape":
|
|
452
|
+
event.preventDefault();
|
|
453
|
+
setIsPopoverOpen(false);
|
|
454
|
+
break;
|
|
455
|
+
case "Backspace":
|
|
456
|
+
if (!searchValue && selectedValues.length > 0) {
|
|
457
|
+
const newSelectedValues = [...selectedValues];
|
|
458
|
+
newSelectedValues.pop();
|
|
459
|
+
setSelectedValues(newSelectedValues);
|
|
460
|
+
onValueChange(newSelectedValues);
|
|
461
|
+
}
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
[flatFilteredOptions, highlightedIndex, toggleOption, searchValue, selectedValues, onValueChange]
|
|
466
|
+
);
|
|
467
|
+
React3__namespace.useEffect(() => {
|
|
468
|
+
if (!resetOnDefaultValueChange) return;
|
|
469
|
+
const prevDefaultValue = prevDefaultValueRef.current;
|
|
470
|
+
if (!arraysEqual(prevDefaultValue, defaultValue)) {
|
|
471
|
+
if (!arraysEqual(selectedValues, defaultValue)) {
|
|
472
|
+
setSelectedValues(defaultValue);
|
|
473
|
+
}
|
|
474
|
+
prevDefaultValueRef.current = [...defaultValue];
|
|
475
|
+
}
|
|
476
|
+
}, [defaultValue, selectedValues, arraysEqual, resetOnDefaultValueChange]);
|
|
477
|
+
const getWidthConstraints = () => {
|
|
478
|
+
const defaultMinWidth = screenSize === "mobile" ? "0px" : "200px";
|
|
479
|
+
const effectiveMinWidth = minWidth || defaultMinWidth;
|
|
480
|
+
const effectiveMaxWidth = maxWidth || "100%";
|
|
481
|
+
return {
|
|
482
|
+
minWidth: effectiveMinWidth,
|
|
483
|
+
maxWidth: effectiveMaxWidth,
|
|
484
|
+
width: autoSize ? "auto" : "100%"
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
const widthConstraints = getWidthConstraints();
|
|
488
|
+
const effectiveDropdownMaxHeight = React3__namespace.useMemo(() => {
|
|
489
|
+
if (dropdownMaxHeight) return dropdownMaxHeight;
|
|
490
|
+
return screenSize === "mobile" ? "70vh" : "60vh";
|
|
491
|
+
}, [dropdownMaxHeight, screenSize]);
|
|
492
|
+
React3__namespace.useEffect(() => {
|
|
493
|
+
if (!isPopoverOpen) {
|
|
494
|
+
setSearchValue("");
|
|
495
|
+
setHighlightedIndex(-1);
|
|
496
|
+
}
|
|
497
|
+
}, [isPopoverOpen]);
|
|
498
|
+
React3__namespace.useEffect(() => {
|
|
499
|
+
if (isPopoverOpen && searchable && searchInputRef.current) {
|
|
500
|
+
const timer = setTimeout(() => {
|
|
501
|
+
searchInputRef.current?.focus();
|
|
502
|
+
}, 0);
|
|
503
|
+
return () => clearTimeout(timer);
|
|
504
|
+
}
|
|
505
|
+
}, [isPopoverOpen, searchable]);
|
|
506
|
+
React3__namespace.useEffect(() => {
|
|
507
|
+
setHighlightedIndex(flatFilteredOptions.length > 0 ? 0 : -1);
|
|
508
|
+
}, [searchValue, flatFilteredOptions.length]);
|
|
509
|
+
const totalFilteredCount = React3__namespace.useMemo(() => {
|
|
510
|
+
if (isGroupedOptions(filteredOptions)) {
|
|
511
|
+
return filteredOptions.reduce((acc, group) => acc + group.options.length, 0);
|
|
512
|
+
}
|
|
513
|
+
return filteredOptions.length;
|
|
514
|
+
}, [filteredOptions, isGroupedOptions]);
|
|
515
|
+
let optionIndex = 0;
|
|
516
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: isPopoverOpen, onOpenChange: setIsPopoverOpen, children: [
|
|
517
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { id: triggerDescriptionId, className: "sr-only", children: "Multi-select dropdown. Use arrow keys to navigate, Enter to select, and Escape to close." }),
|
|
518
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { id: selectedCountId, className: "sr-only", "aria-live": "polite", children: selectedValues.length === 0 ? "No options selected" : `${selectedValues.length} option${selectedValues.length === 1 ? "" : "s"} selected: ${selectedValues.map((value) => getOptionByValue(value)?.label).filter(Boolean).join(", ")}` }),
|
|
519
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
520
|
+
"button",
|
|
521
|
+
{
|
|
522
|
+
ref: buttonRef,
|
|
523
|
+
type: "button",
|
|
524
|
+
...props,
|
|
525
|
+
onClick: (event) => {
|
|
526
|
+
if (disabled) return;
|
|
527
|
+
onClick?.(event);
|
|
528
|
+
handleTogglePopover();
|
|
529
|
+
},
|
|
530
|
+
disabled,
|
|
531
|
+
role: "combobox",
|
|
532
|
+
"aria-expanded": isPopoverOpen,
|
|
533
|
+
"aria-haspopup": "listbox",
|
|
534
|
+
"aria-controls": isPopoverOpen ? listboxId : void 0,
|
|
535
|
+
"aria-describedby": `${triggerDescriptionId} ${selectedCountId}`,
|
|
536
|
+
"aria-label": `Multi-select: ${selectedValues.length} of ${getAllOptions().length} options selected. ${placeholder}`,
|
|
537
|
+
className: cn(
|
|
538
|
+
`border-input/70 focus-visible:border-primary/60 focus-visible:ring-primary/20 flex items-center
|
|
539
|
+
justify-between rounded-md border bg-transparent pr-1 pl-2 shadow-xs transition-[color,box-shadow,scale]
|
|
540
|
+
duration-150 ease-out outline-none focus-visible:ring-[3px] motion-safe:active:not-disabled:scale-[0.96]
|
|
541
|
+
motion-reduce:transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50`,
|
|
542
|
+
singleLine ? "h-8 min-h-8 py-0.5 text-xs" : "h-auto min-h-10 py-2 text-sm",
|
|
543
|
+
autoSize && "w-auto",
|
|
544
|
+
!autoSize && "w-full",
|
|
545
|
+
responsiveSettings.compactMode && "min-h-9 py-1.5 text-xs",
|
|
546
|
+
className
|
|
547
|
+
),
|
|
548
|
+
style: {
|
|
549
|
+
minWidth: widthConstraints.minWidth,
|
|
550
|
+
maxWidth: widthConstraints.maxWidth,
|
|
551
|
+
width: widthConstraints.width
|
|
552
|
+
},
|
|
553
|
+
children: selectedValues.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center justify-between", children: [
|
|
554
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
555
|
+
"div",
|
|
556
|
+
{
|
|
557
|
+
className: cn(
|
|
558
|
+
"flex items-center gap-1",
|
|
559
|
+
singleLine ? "multiselect-singleline-scroll overflow-x-auto" : "flex-wrap",
|
|
560
|
+
responsiveSettings.compactMode && "gap-0.5"
|
|
561
|
+
),
|
|
562
|
+
children: [
|
|
563
|
+
selectedValues.slice(0, responsiveSettings.maxCount).map((value) => {
|
|
564
|
+
const option = getOptionByValue(value);
|
|
565
|
+
const IconComponent = option?.icon;
|
|
566
|
+
const customStyle = option?.style;
|
|
567
|
+
if (!option) {
|
|
568
|
+
return null;
|
|
569
|
+
}
|
|
570
|
+
const badgeStyle = {
|
|
571
|
+
...customStyle?.badgeColor && {
|
|
572
|
+
backgroundColor: customStyle.badgeColor
|
|
573
|
+
},
|
|
574
|
+
...customStyle?.gradient && {
|
|
575
|
+
background: customStyle.gradient,
|
|
576
|
+
color: "white"
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
580
|
+
Badge,
|
|
581
|
+
{
|
|
582
|
+
className: cn(
|
|
583
|
+
multiSelectVariants({ variant }),
|
|
584
|
+
customStyle?.gradient && "border-transparent text-white",
|
|
585
|
+
responsiveSettings.compactMode && "px-1.5 py-0.5 text-xs",
|
|
586
|
+
singleLine && "py-0.5",
|
|
587
|
+
screenSize === "mobile" && "max-w-[120px] truncate",
|
|
588
|
+
singleLine && "flex-shrink-0 whitespace-nowrap",
|
|
589
|
+
"[&>svg]:pointer-events-auto"
|
|
590
|
+
),
|
|
591
|
+
style: badgeStyle,
|
|
592
|
+
children: [
|
|
593
|
+
IconComponent && !responsiveSettings.hideIcons && /* @__PURE__ */ jsxRuntime.jsx(
|
|
594
|
+
IconComponent,
|
|
595
|
+
{
|
|
596
|
+
className: cn(
|
|
597
|
+
"mr-2 h-4 w-4",
|
|
598
|
+
responsiveSettings.compactMode && "mr-1 h-3 w-3",
|
|
599
|
+
customStyle?.iconColor && "text-current"
|
|
600
|
+
),
|
|
601
|
+
...customStyle?.iconColor && {
|
|
602
|
+
style: { color: customStyle.iconColor }
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
),
|
|
606
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(screenSize === "mobile" && "truncate"), children: option.label }),
|
|
607
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
608
|
+
"div",
|
|
609
|
+
{
|
|
610
|
+
role: "button",
|
|
611
|
+
tabIndex: 0,
|
|
612
|
+
onClick: (event) => {
|
|
613
|
+
event.stopPropagation();
|
|
614
|
+
toggleOption(value);
|
|
615
|
+
},
|
|
616
|
+
onKeyDown: (event) => {
|
|
617
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
618
|
+
event.preventDefault();
|
|
619
|
+
event.stopPropagation();
|
|
620
|
+
toggleOption(value);
|
|
621
|
+
}
|
|
622
|
+
},
|
|
623
|
+
"aria-label": `Remove ${option.label} from selection`,
|
|
624
|
+
className: "-m-0.5 ml-2 h-4 w-4 cursor-pointer rounded-sm p-0.5 hover:bg-white/20 focus:ring-1 focus:ring-white/50 focus:outline-none",
|
|
625
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XCircle, { className: cn("h-3 w-3", responsiveSettings.compactMode && "h-2.5 w-2.5") })
|
|
626
|
+
}
|
|
627
|
+
)
|
|
628
|
+
]
|
|
629
|
+
},
|
|
630
|
+
value
|
|
631
|
+
);
|
|
632
|
+
}).filter(Boolean),
|
|
633
|
+
selectedValues.length > responsiveSettings.maxCount && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
634
|
+
Badge,
|
|
635
|
+
{
|
|
636
|
+
className: cn(
|
|
637
|
+
"text-foreground border-foreground/10 bg-transparent",
|
|
638
|
+
multiSelectVariants({ variant }),
|
|
639
|
+
responsiveSettings.compactMode && "px-1.5 py-0.5 text-xs",
|
|
640
|
+
singleLine && "flex-shrink-0 whitespace-nowrap",
|
|
641
|
+
"[&>svg]:pointer-events-auto"
|
|
642
|
+
),
|
|
643
|
+
children: [
|
|
644
|
+
`+ ${selectedValues.length - responsiveSettings.maxCount} more`,
|
|
645
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
646
|
+
"div",
|
|
647
|
+
{
|
|
648
|
+
role: "button",
|
|
649
|
+
tabIndex: 0,
|
|
650
|
+
onClick: (event) => {
|
|
651
|
+
event.stopPropagation();
|
|
652
|
+
clearExtraOptions();
|
|
653
|
+
},
|
|
654
|
+
onKeyDown: (event) => {
|
|
655
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
656
|
+
event.preventDefault();
|
|
657
|
+
event.stopPropagation();
|
|
658
|
+
clearExtraOptions();
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
"aria-label": "Clear extra selected options",
|
|
662
|
+
className: "-m-0.5 ml-2 h-4 w-4 cursor-pointer rounded-sm p-0.5 hover:bg-white/20 focus:ring-1\n focus:ring-white/50 focus:outline-none",
|
|
663
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XCircle, { className: cn("h-3 w-3", responsiveSettings.compactMode && "h-2.5 w-2.5") })
|
|
664
|
+
}
|
|
665
|
+
)
|
|
666
|
+
]
|
|
667
|
+
}
|
|
668
|
+
)
|
|
669
|
+
]
|
|
670
|
+
}
|
|
671
|
+
),
|
|
672
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
673
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
674
|
+
"div",
|
|
675
|
+
{
|
|
676
|
+
role: "button",
|
|
677
|
+
tabIndex: 0,
|
|
678
|
+
onClick: (event) => {
|
|
679
|
+
event.stopPropagation();
|
|
680
|
+
handleClear();
|
|
681
|
+
},
|
|
682
|
+
onKeyDown: (event) => {
|
|
683
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
684
|
+
event.preventDefault();
|
|
685
|
+
event.stopPropagation();
|
|
686
|
+
handleClear();
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
"aria-label": `Clear all ${selectedValues.length} selected options`,
|
|
690
|
+
className: "text-muted-foreground hover:text-foreground focus:ring-ring mx-2 flex h-4 w-4\n cursor-pointer items-center justify-center rounded-sm focus:ring-2 focus:ring-offset-1\n focus:outline-none",
|
|
691
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, { className: "h-4 w-4" })
|
|
692
|
+
}
|
|
693
|
+
),
|
|
694
|
+
/* @__PURE__ */ jsxRuntime.jsx(Separator, { orientation: "vertical", className: "flex h-full min-h-6" }),
|
|
695
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "text-muted-foreground mx-1 h-4 cursor-pointer" })
|
|
696
|
+
] })
|
|
697
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mx-auto flex w-full items-center justify-between", children: [
|
|
698
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground mx-1 text-sm", children: placeholder }),
|
|
699
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "text-muted-foreground mx-1 h-4 cursor-pointer" })
|
|
700
|
+
] })
|
|
701
|
+
}
|
|
702
|
+
) }),
|
|
703
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
704
|
+
PopoverContent,
|
|
705
|
+
{
|
|
706
|
+
id: listboxId,
|
|
707
|
+
"aria-label": "Available options",
|
|
708
|
+
className: cn("w-(--anchor-width) overflow-hidden p-0", popoverClassName),
|
|
709
|
+
style: {
|
|
710
|
+
minWidth: widthConstraints.minWidth,
|
|
711
|
+
maxWidth: widthConstraints.maxWidth,
|
|
712
|
+
width: widthConstraints.width === "auto" ? "auto" : void 0,
|
|
713
|
+
maxHeight: effectiveDropdownMaxHeight,
|
|
714
|
+
touchAction: "manipulation"
|
|
715
|
+
},
|
|
716
|
+
align: "start",
|
|
717
|
+
onEscapeKeyDown: () => setIsPopoverOpen(false),
|
|
718
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full max-h-[inherit] flex-col", onKeyDown: handleKeyDown, children: [
|
|
719
|
+
searchable && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center border-b px-3", children: [
|
|
720
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.SearchIcon, { className: "text-muted-foreground mr-2 h-4 w-4 shrink-0 opacity-50" }),
|
|
721
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
722
|
+
"input",
|
|
723
|
+
{
|
|
724
|
+
ref: searchInputRef,
|
|
725
|
+
id: searchInputId,
|
|
726
|
+
type: "text",
|
|
727
|
+
placeholder: "Search options...",
|
|
728
|
+
value: searchValue,
|
|
729
|
+
onChange: (e) => setSearchValue(e.target.value),
|
|
730
|
+
"aria-label": "Search through available options",
|
|
731
|
+
className: "placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none disabled:cursor-not-allowed disabled:opacity-50"
|
|
732
|
+
}
|
|
733
|
+
)
|
|
734
|
+
] }),
|
|
735
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
736
|
+
"div",
|
|
737
|
+
{
|
|
738
|
+
ref: listRef,
|
|
739
|
+
role: "listbox",
|
|
740
|
+
"aria-multiselectable": "true",
|
|
741
|
+
className: "multiselect-scrollbar scrollbar-neutral-thin overscroll-contain min-h-0 flex-1 overflow-y-auto p-1",
|
|
742
|
+
children: totalFilteredCount === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground py-6 text-center text-sm", children: emptyIndicator || "No results found." }) : isGroupedOptions(filteredOptions) ? filteredOptions.map((group) => /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "group", "aria-labelledby": `group-${group.heading}`, children: [
|
|
743
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
744
|
+
"div",
|
|
745
|
+
{
|
|
746
|
+
id: `group-${group.heading}`,
|
|
747
|
+
className: "text-muted-foreground px-2 py-1.5 text-xs font-medium",
|
|
748
|
+
children: group.heading
|
|
749
|
+
}
|
|
750
|
+
),
|
|
751
|
+
group.options.map((option) => {
|
|
752
|
+
const currentIndex = optionIndex++;
|
|
753
|
+
const isSelected = selectedValues.includes(option.value);
|
|
754
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
755
|
+
OptionItem,
|
|
756
|
+
{
|
|
757
|
+
option,
|
|
758
|
+
isSelected,
|
|
759
|
+
onSelect: () => toggleOption(option.value),
|
|
760
|
+
highlightedIndex,
|
|
761
|
+
index: currentIndex,
|
|
762
|
+
setHighlightedIndex
|
|
763
|
+
},
|
|
764
|
+
option.value
|
|
765
|
+
);
|
|
766
|
+
})
|
|
767
|
+
] }, group.heading)) : filteredOptions.map((option) => {
|
|
768
|
+
const currentIndex = optionIndex++;
|
|
769
|
+
const isSelected = selectedValues.includes(option.value);
|
|
770
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
771
|
+
OptionItem,
|
|
772
|
+
{
|
|
773
|
+
option,
|
|
774
|
+
isSelected,
|
|
775
|
+
onSelect: () => toggleOption(option.value),
|
|
776
|
+
highlightedIndex,
|
|
777
|
+
index: currentIndex,
|
|
778
|
+
setHighlightedIndex
|
|
779
|
+
},
|
|
780
|
+
option.value
|
|
781
|
+
);
|
|
782
|
+
})
|
|
783
|
+
}
|
|
784
|
+
),
|
|
785
|
+
footerContent && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t p-1", children: footerContent })
|
|
786
|
+
] })
|
|
787
|
+
}
|
|
788
|
+
)
|
|
789
|
+
] }) });
|
|
790
|
+
}
|
|
791
|
+
);
|
|
792
|
+
MultiSelect.displayName = "MultiSelect";
|
|
793
|
+
|
|
794
|
+
exports.MultiSelect = MultiSelect;
|
|
795
|
+
//# sourceMappingURL=multi-select.cjs.map
|
|
796
|
+
//# sourceMappingURL=multi-select.cjs.map
|