@uipath/apollo-wind 2.56.0 → 2.57.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/dist/components/ui/combobox.cjs +33 -15
- package/dist/components/ui/combobox.js +33 -15
- package/dist/components/ui/date-picker.cjs +62 -26
- package/dist/components/ui/date-picker.js +62 -26
- package/dist/components/ui/datetime-picker.cjs +29 -12
- package/dist/components/ui/datetime-picker.js +29 -12
- package/dist/components/ui/dropdown-menu.cjs +12 -8
- package/dist/components/ui/dropdown-menu.js +12 -8
- package/dist/components/ui/field-actions/ai-assist-action.cjs +121 -0
- package/dist/components/ui/field-actions/ai-assist-action.d.ts +21 -0
- package/dist/components/ui/field-actions/ai-assist-action.js +84 -0
- package/dist/components/ui/field-actions/collapse.cjs +44 -0
- package/dist/components/ui/field-actions/collapse.d.ts +6 -0
- package/dist/components/ui/field-actions/collapse.js +4 -0
- package/dist/components/ui/field-actions/index.cjs +46 -0
- package/dist/components/ui/field-actions/index.d.ts +2 -0
- package/dist/components/ui/field-actions/index.js +3 -0
- package/dist/components/ui/field-actions/insert-variable-action.cjs +94 -0
- package/dist/components/ui/field-actions/insert-variable-action.d.ts +22 -0
- package/dist/components/ui/field-actions/insert-variable-action.js +57 -0
- package/dist/components/ui/field-addons/index.cjs +50 -0
- package/dist/components/ui/field-addons/index.d.ts +3 -0
- package/dist/components/ui/field-addons/index.js +4 -0
- package/dist/components/ui/field-addons/value-mode-indicator.cjs +57 -0
- package/dist/components/ui/field-addons/value-mode-indicator.d.ts +13 -0
- package/dist/components/ui/field-addons/value-mode-indicator.js +23 -0
- package/dist/components/ui/field-addons/value-mode-menu.cjs +149 -0
- package/dist/components/ui/field-addons/value-mode-menu.d.ts +69 -0
- package/dist/components/ui/field-addons/value-mode-menu.js +112 -0
- package/dist/components/ui/field-addons/value-mode-strings.cjs +69 -0
- package/dist/components/ui/field-addons/value-mode-strings.d.ts +32 -0
- package/dist/components/ui/field-addons/value-mode-strings.js +29 -0
- package/dist/components/ui/form-field.cjs +42 -5
- package/dist/components/ui/form-field.d.ts +21 -1
- package/dist/components/ui/form-field.js +36 -2
- package/dist/components/ui/index.cjs +148 -128
- package/dist/components/ui/index.d.ts +2 -0
- package/dist/components/ui/index.js +2 -0
- package/dist/components/ui/input-group-context.cjs +91 -0
- package/dist/components/ui/input-group-context.d.ts +69 -0
- package/dist/components/ui/input-group-context.js +42 -0
- package/dist/components/ui/input-group.cjs +303 -56
- package/dist/components/ui/input-group.d.ts +70 -3
- package/dist/components/ui/input-group.js +285 -56
- package/dist/components/ui/input.cjs +28 -17
- package/dist/components/ui/input.js +28 -17
- package/dist/components/ui/lockable-value-field/components/field-header.cjs +16 -114
- package/dist/components/ui/lockable-value-field/components/field-header.js +14 -112
- package/dist/components/ui/lockable-value-field/lockable-value-field.cjs +4 -12
- package/dist/components/ui/lockable-value-field/lockable-value-field.js +4 -12
- package/dist/components/ui/multi-select.cjs +82 -58
- package/dist/components/ui/multi-select.js +84 -60
- package/dist/components/ui/popover.cjs +13 -9
- package/dist/components/ui/popover.js +13 -9
- package/dist/components/ui/select.cjs +89 -27
- package/dist/components/ui/select.d.ts +4 -0
- package/dist/components/ui/select.js +90 -28
- package/dist/components/ui/textarea.cjs +16 -11
- package/dist/components/ui/textarea.js +16 -11
- package/dist/index.cjs +61 -11
- package/dist/index.d.ts +8 -4
- package/dist/index.js +5 -3
- package/dist/styles.css +242 -5
- package/package.json +1 -1
- package/dist/components/ui/lockable-value-field/components/mode-menu-item.cjs +0 -63
- package/dist/components/ui/lockable-value-field/components/mode-menu-item.d.ts +0 -9
- package/dist/components/ui/lockable-value-field/components/mode-menu-item.js +0 -29
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ChevronsUpDown, X } from "lucide-react";
|
|
3
3
|
import { forwardRef, useId, useState } from "react";
|
|
4
4
|
import { Badge } from "./badge.js";
|
|
5
5
|
import { Button } from "./button.js";
|
|
6
6
|
import { Checkbox } from "./checkbox.js";
|
|
7
7
|
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "./command.js";
|
|
8
|
-
import {
|
|
8
|
+
import { InputGroupTrigger } from "./input-group.js";
|
|
9
|
+
import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
9
10
|
import { cn } from "../../lib/index.js";
|
|
10
11
|
import { FormFieldError } from "./form-field.js";
|
|
12
|
+
import { useControlValidation, useInputGroup } from "./input-group-context.js";
|
|
11
13
|
const MultiSelect = /*#__PURE__*/ forwardRef(({ id, options, selected, onChange, placeholder = 'Select items...', emptyMessage = 'No items found.', className, maxSelected, disabled = false, searchPlaceholder = 'Search...', clearAllText, onBlur, error, errorId, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref)=>{
|
|
12
14
|
const [open, setOpen] = useState(false);
|
|
15
|
+
const group = useInputGroup();
|
|
16
|
+
const groupAnchor = group.anchor;
|
|
17
|
+
const grouped = group.inGroup;
|
|
13
18
|
const generatedId = useId();
|
|
14
19
|
const validationId = errorId ?? `${id ?? `multi-select-${generatedId.replace(/:/g, '')}`}-error`;
|
|
15
|
-
const describedBy = [
|
|
16
|
-
ariaDescribedBy,
|
|
17
|
-
error ? validationId : void 0
|
|
18
|
-
].filter(Boolean).join(' ');
|
|
19
20
|
const handleUnselect = (value)=>{
|
|
20
21
|
onChange(selected.filter((s)=>s !== value));
|
|
21
22
|
};
|
|
@@ -32,10 +33,74 @@ const MultiSelect = /*#__PURE__*/ forwardRef(({ id, options, selected, onChange,
|
|
|
32
33
|
const handleClearAll = ()=>{
|
|
33
34
|
onChange([]);
|
|
34
35
|
};
|
|
36
|
+
const validation = useControlValidation(group, {
|
|
37
|
+
error,
|
|
38
|
+
errorId: validationId,
|
|
39
|
+
'aria-invalid': ariaInvalid,
|
|
40
|
+
'aria-describedby': ariaDescribedBy,
|
|
41
|
+
'aria-errormessage': ariaErrorMessage
|
|
42
|
+
});
|
|
43
|
+
const triggerProps = {
|
|
44
|
+
id,
|
|
45
|
+
role: 'combobox',
|
|
46
|
+
'aria-expanded': open,
|
|
47
|
+
...validation.aria,
|
|
48
|
+
'aria-label': id ? void 0 : selected.length > 0 ? `${selected.length} ${1 === selected.length ? 'item' : 'items'} selected` : placeholder,
|
|
49
|
+
disabled: disabled || group.disabled
|
|
50
|
+
};
|
|
51
|
+
const triggerContent = /*#__PURE__*/ jsxs(Fragment, {
|
|
52
|
+
children: [
|
|
53
|
+
/*#__PURE__*/ jsx("div", {
|
|
54
|
+
className: cn('flex flex-wrap gap-1 flex-1', grouped && 'min-h-6.5 items-center py-0.5 future:min-h-6 future:py-px'),
|
|
55
|
+
children: 0 === selected.length ? /*#__PURE__*/ jsx("span", {
|
|
56
|
+
className: "text-foreground-muted",
|
|
57
|
+
children: placeholder
|
|
58
|
+
}) : selected.map((value)=>{
|
|
59
|
+
const option = options.find((opt)=>opt.value === value);
|
|
60
|
+
return /*#__PURE__*/ jsxs(Badge, {
|
|
61
|
+
variant: "secondary",
|
|
62
|
+
className: "mr-1 future:bg-surface-raised future:hover:bg-surface-raised",
|
|
63
|
+
onClick: (e)=>{
|
|
64
|
+
e.stopPropagation();
|
|
65
|
+
handleUnselect(value);
|
|
66
|
+
},
|
|
67
|
+
children: [
|
|
68
|
+
option?.label,
|
|
69
|
+
/*#__PURE__*/ jsx("button", {
|
|
70
|
+
type: "button",
|
|
71
|
+
"aria-label": `Remove ${option?.label}`,
|
|
72
|
+
className: "ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2 cursor-pointer bg-transparent border-0 p-0 inline-flex items-center",
|
|
73
|
+
onMouseDown: (e)=>{
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
e.stopPropagation();
|
|
76
|
+
},
|
|
77
|
+
onClick: (e)=>{
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
e.stopPropagation();
|
|
80
|
+
handleUnselect(value);
|
|
81
|
+
},
|
|
82
|
+
children: /*#__PURE__*/ jsx(X, {
|
|
83
|
+
className: "h-3 w-3 text-muted-foreground hover:text-foreground"
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
}, value);
|
|
88
|
+
})
|
|
89
|
+
}),
|
|
90
|
+
grouped ? /*#__PURE__*/ jsx("span", {
|
|
91
|
+
className: "flex h-6.5 shrink-0 items-center self-start future:h-6",
|
|
92
|
+
children: /*#__PURE__*/ jsx(ChevronsUpDown, {
|
|
93
|
+
className: "h-4 w-4 opacity-50"
|
|
94
|
+
})
|
|
95
|
+
}) : /*#__PURE__*/ jsx(ChevronsUpDown, {
|
|
96
|
+
className: "h-4 w-4 shrink-0 opacity-50"
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
});
|
|
35
100
|
return /*#__PURE__*/ jsxs("div", {
|
|
36
101
|
ref: ref,
|
|
37
102
|
"data-slot": "multi-select",
|
|
38
|
-
className: cn('relative', className),
|
|
103
|
+
className: cn('relative', grouped && 'min-w-0 flex-1', className),
|
|
39
104
|
children: [
|
|
40
105
|
/*#__PURE__*/ jsxs(Popover, {
|
|
41
106
|
open: open,
|
|
@@ -46,63 +111,22 @@ const MultiSelect = /*#__PURE__*/ forwardRef(({ id, options, selected, onChange,
|
|
|
46
111
|
children: [
|
|
47
112
|
/*#__PURE__*/ jsx(PopoverTrigger, {
|
|
48
113
|
asChild: true,
|
|
49
|
-
children: /*#__PURE__*/
|
|
50
|
-
|
|
114
|
+
children: grouped ? /*#__PURE__*/ jsx(InputGroupTrigger, {
|
|
115
|
+
...triggerProps,
|
|
116
|
+
className: cn('items-start', selected.length > 0 && 'h-auto'),
|
|
117
|
+
children: triggerContent
|
|
118
|
+
}) : /*#__PURE__*/ jsx(Button, {
|
|
51
119
|
variant: "outline",
|
|
52
|
-
|
|
53
|
-
"aria-expanded": open,
|
|
54
|
-
"aria-invalid": error ? true : ariaInvalid,
|
|
55
|
-
"aria-describedby": describedBy || void 0,
|
|
56
|
-
"aria-errormessage": error ? validationId : ariaErrorMessage,
|
|
57
|
-
"aria-label": id ? void 0 : selected.length > 0 ? `${selected.length} ${1 === selected.length ? 'item' : 'items'} selected` : placeholder,
|
|
120
|
+
...triggerProps,
|
|
58
121
|
className: cn('w-full justify-between future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:hover:bg-surface-hover future:font-normal future:text-foreground future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', selected.length > 0 ? 'h-auto min-h-10' : 'h-10'),
|
|
59
|
-
|
|
60
|
-
children: [
|
|
61
|
-
/*#__PURE__*/ jsx("div", {
|
|
62
|
-
className: "flex flex-wrap gap-1 flex-1",
|
|
63
|
-
children: 0 === selected.length ? /*#__PURE__*/ jsx("span", {
|
|
64
|
-
className: "text-foreground-muted",
|
|
65
|
-
children: placeholder
|
|
66
|
-
}) : selected.map((value)=>{
|
|
67
|
-
const option = options.find((opt)=>opt.value === value);
|
|
68
|
-
return /*#__PURE__*/ jsxs(Badge, {
|
|
69
|
-
variant: "secondary",
|
|
70
|
-
className: "mr-1 future:bg-surface-raised future:hover:bg-surface-raised",
|
|
71
|
-
onClick: (e)=>{
|
|
72
|
-
e.stopPropagation();
|
|
73
|
-
handleUnselect(value);
|
|
74
|
-
},
|
|
75
|
-
children: [
|
|
76
|
-
option?.label,
|
|
77
|
-
/*#__PURE__*/ jsx("button", {
|
|
78
|
-
type: "button",
|
|
79
|
-
"aria-label": `Remove ${option?.label}`,
|
|
80
|
-
className: "ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2 cursor-pointer bg-transparent border-0 p-0 inline-flex items-center",
|
|
81
|
-
onMouseDown: (e)=>{
|
|
82
|
-
e.preventDefault();
|
|
83
|
-
e.stopPropagation();
|
|
84
|
-
},
|
|
85
|
-
onClick: (e)=>{
|
|
86
|
-
e.preventDefault();
|
|
87
|
-
e.stopPropagation();
|
|
88
|
-
handleUnselect(value);
|
|
89
|
-
},
|
|
90
|
-
children: /*#__PURE__*/ jsx(X, {
|
|
91
|
-
className: "h-3 w-3 text-muted-foreground hover:text-foreground"
|
|
92
|
-
})
|
|
93
|
-
})
|
|
94
|
-
]
|
|
95
|
-
}, value);
|
|
96
|
-
})
|
|
97
|
-
}),
|
|
98
|
-
/*#__PURE__*/ jsx(ChevronsUpDown, {
|
|
99
|
-
className: "h-4 w-4 shrink-0 opacity-50"
|
|
100
|
-
})
|
|
101
|
-
]
|
|
122
|
+
children: triggerContent
|
|
102
123
|
})
|
|
103
124
|
}),
|
|
125
|
+
groupAnchor && /*#__PURE__*/ jsx(PopoverAnchor, {
|
|
126
|
+
virtualRef: groupAnchor
|
|
127
|
+
}),
|
|
104
128
|
/*#__PURE__*/ jsxs(PopoverContent, {
|
|
105
|
-
className: "w-
|
|
129
|
+
className: "w-(--radix-popover-trigger-width) p-0",
|
|
106
130
|
align: "start",
|
|
107
131
|
children: [
|
|
108
132
|
/*#__PURE__*/ jsxs(Command, {
|
|
@@ -156,7 +180,7 @@ const MultiSelect = /*#__PURE__*/ forwardRef(({ id, options, selected, onChange,
|
|
|
156
180
|
})
|
|
157
181
|
]
|
|
158
182
|
}),
|
|
159
|
-
/*#__PURE__*/ jsx(FormFieldError, {
|
|
183
|
+
validation.ownMessage && /*#__PURE__*/ jsx(FormFieldError, {
|
|
160
184
|
id: validationId,
|
|
161
185
|
children: error
|
|
162
186
|
})
|
|
@@ -35,6 +35,7 @@ const react_popover_namespaceObject = require("@radix-ui/react-popover");
|
|
|
35
35
|
const external_react_namespaceObject = require("react");
|
|
36
36
|
const external_portal_container_cjs_namespaceObject = require("./portal-container.cjs");
|
|
37
37
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
38
|
+
const external_input_group_context_cjs_namespaceObject = require("./input-group-context.cjs");
|
|
38
39
|
const Popover = (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_popover_namespaceObject.Root, {
|
|
39
40
|
"data-slot": "popover",
|
|
40
41
|
...props
|
|
@@ -54,15 +55,18 @@ const PopoverAnchor = /*#__PURE__*/ external_react_namespaceObject.forwardRef((p
|
|
|
54
55
|
PopoverAnchor.displayName = react_popover_namespaceObject.Anchor.displayName;
|
|
55
56
|
const PopoverContent = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, align = 'center', sideOffset = 4, container, ...props }, ref)=>{
|
|
56
57
|
const resolvedContainer = (0, external_portal_container_cjs_namespaceObject.useResolvedPortalContainer)(container);
|
|
57
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
58
|
-
|
|
59
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_popover_namespaceObject.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_context_cjs_namespaceObject.InputGroupContext.Provider, {
|
|
59
|
+
value: external_input_group_context_cjs_namespaceObject.NO_GROUP,
|
|
60
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_popover_namespaceObject.Portal, {
|
|
61
|
+
container: resolvedContainer,
|
|
62
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_popover_namespaceObject.Content, {
|
|
63
|
+
ref: ref,
|
|
64
|
+
"data-slot": "popover-content",
|
|
65
|
+
align: align,
|
|
66
|
+
sideOffset: sideOffset,
|
|
67
|
+
className: (0, index_cjs_namespaceObject.cn)('z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none future:rounded-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]', className),
|
|
68
|
+
...props
|
|
69
|
+
})
|
|
66
70
|
})
|
|
67
71
|
});
|
|
68
72
|
});
|
|
@@ -4,6 +4,7 @@ import { Anchor, Content, Portal, Root, Trigger } from "@radix-ui/react-popover"
|
|
|
4
4
|
import { forwardRef } from "react";
|
|
5
5
|
import { useResolvedPortalContainer } from "./portal-container.js";
|
|
6
6
|
import { cn } from "../../lib/index.js";
|
|
7
|
+
import { InputGroupContext, NO_GROUP } from "./input-group-context.js";
|
|
7
8
|
const Popover = (props)=>/*#__PURE__*/ jsx(Root, {
|
|
8
9
|
"data-slot": "popover",
|
|
9
10
|
...props
|
|
@@ -23,15 +24,18 @@ const PopoverAnchor = /*#__PURE__*/ forwardRef((props, ref)=>/*#__PURE__*/ jsx(A
|
|
|
23
24
|
PopoverAnchor.displayName = Anchor.displayName;
|
|
24
25
|
const PopoverContent = /*#__PURE__*/ forwardRef(({ className, align = 'center', sideOffset = 4, container, ...props }, ref)=>{
|
|
25
26
|
const resolvedContainer = useResolvedPortalContainer(container);
|
|
26
|
-
return /*#__PURE__*/ jsx(
|
|
27
|
-
|
|
28
|
-
children: /*#__PURE__*/ jsx(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
return /*#__PURE__*/ jsx(InputGroupContext.Provider, {
|
|
28
|
+
value: NO_GROUP,
|
|
29
|
+
children: /*#__PURE__*/ jsx(Portal, {
|
|
30
|
+
container: resolvedContainer,
|
|
31
|
+
children: /*#__PURE__*/ jsx(Content, {
|
|
32
|
+
ref: ref,
|
|
33
|
+
"data-slot": "popover-content",
|
|
34
|
+
align: align,
|
|
35
|
+
sideOffset: sideOffset,
|
|
36
|
+
className: cn('z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none future:rounded-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]', className),
|
|
37
|
+
...props
|
|
38
|
+
})
|
|
35
39
|
})
|
|
36
40
|
});
|
|
37
41
|
});
|
|
@@ -38,11 +38,13 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
38
38
|
});
|
|
39
39
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
40
40
|
const react_select_namespaceObject = require("@radix-ui/react-select");
|
|
41
|
+
const external_class_variance_authority_namespaceObject = require("class-variance-authority");
|
|
41
42
|
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
42
43
|
const external_react_namespaceObject = require("react");
|
|
43
44
|
const external_portal_container_cjs_namespaceObject = require("./portal-container.cjs");
|
|
44
45
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
45
46
|
const external_form_field_cjs_namespaceObject = require("./form-field.cjs");
|
|
47
|
+
const external_input_group_context_cjs_namespaceObject = require("./input-group-context.cjs");
|
|
46
48
|
const Select = (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_select_namespaceObject.Root, {
|
|
47
49
|
"data-slot": "select",
|
|
48
50
|
...props
|
|
@@ -60,24 +62,40 @@ const SelectValue = /*#__PURE__*/ external_react_namespaceObject.forwardRef((pro
|
|
|
60
62
|
...props
|
|
61
63
|
}));
|
|
62
64
|
SelectValue.displayName = react_select_namespaceObject.Value.displayName;
|
|
65
|
+
const selectTriggerVariants = (0, external_class_variance_authority_namespaceObject.cva)('flex w-full cursor-pointer items-center justify-between bg-transparent text-base transition-colors data-[placeholder]:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm [&>span]:line-clamp-1 future:font-normal', {
|
|
66
|
+
variants: {
|
|
67
|
+
grouped: {
|
|
68
|
+
false: 'h-9 rounded-md border border-input px-3 py-1 focus:outline-none focus:ring-2 focus:ring-ring focus-visible:ring-2 focus-visible:ring-ring future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:hover:bg-surface-hover future:px-4 future:gap-4 aria-invalid:border-error aria-invalid:focus-visible:ring-error future:aria-invalid:ring-1 future:aria-invalid:ring-error/40',
|
|
69
|
+
true: 'h-full min-h-5 min-w-0 flex-1 gap-2 p-0'
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
defaultVariants: {
|
|
73
|
+
grouped: false
|
|
74
|
+
}
|
|
75
|
+
});
|
|
63
76
|
const SelectTrigger = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage, 'aria-invalid': ariaInvalid, className, children, error, errorId, id, ...props }, ref)=>{
|
|
77
|
+
const group = (0, external_input_group_context_cjs_namespaceObject.useInputGroup)();
|
|
64
78
|
const generatedId = external_react_namespaceObject.useId();
|
|
65
79
|
const validationId = errorId ?? `${id ?? `select-${generatedId.replace(/:/g, '')}`}-error`;
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
80
|
+
const validation = (0, external_input_group_context_cjs_namespaceObject.useControlValidation)(group, {
|
|
81
|
+
error,
|
|
82
|
+
errorId: validationId,
|
|
83
|
+
'aria-invalid': ariaInvalid,
|
|
84
|
+
'aria-describedby': ariaDescribedBy,
|
|
85
|
+
'aria-errormessage': ariaErrorMessage
|
|
86
|
+
});
|
|
70
87
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
71
88
|
children: [
|
|
72
89
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(react_select_namespaceObject.Trigger, {
|
|
73
90
|
ref: ref,
|
|
74
91
|
id: id,
|
|
75
|
-
"data-slot":
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
92
|
+
"data-slot": group.inGroup ? 'input-group-control' : 'select-trigger',
|
|
93
|
+
...validation.aria,
|
|
94
|
+
className: (0, index_cjs_namespaceObject.cn)(selectTriggerVariants({
|
|
95
|
+
grouped: group.inGroup
|
|
96
|
+
}), className),
|
|
80
97
|
...props,
|
|
98
|
+
disabled: props.disabled || group.disabled,
|
|
81
99
|
children: [
|
|
82
100
|
children,
|
|
83
101
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_select_namespaceObject.Icon, {
|
|
@@ -88,7 +106,7 @@ const SelectTrigger = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({
|
|
|
88
106
|
})
|
|
89
107
|
]
|
|
90
108
|
}),
|
|
91
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
109
|
+
validation.ownMessage && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
92
110
|
id: validationId,
|
|
93
111
|
children: error
|
|
94
112
|
})
|
|
@@ -116,24 +134,68 @@ const SelectScrollDownButton = /*#__PURE__*/ external_react_namespaceObject.forw
|
|
|
116
134
|
})
|
|
117
135
|
}));
|
|
118
136
|
SelectScrollDownButton.displayName = react_select_namespaceObject.ScrollDownButton.displayName;
|
|
119
|
-
|
|
137
|
+
function useInputGroupFit(enabled) {
|
|
138
|
+
const groupAnchor = (0, external_input_group_context_cjs_namespaceObject.useInputGroup)().anchor;
|
|
139
|
+
const [offsets, setOffsets] = external_react_namespaceObject.useState(null);
|
|
140
|
+
const measure = external_react_namespaceObject.useCallback((content)=>{
|
|
141
|
+
const box = groupAnchor?.current;
|
|
142
|
+
if (!enabled || !content || !box) return;
|
|
143
|
+
const trigger = box.querySelector('[data-slot="input-group-control"][aria-expanded="true"]');
|
|
144
|
+
if (!trigger) return;
|
|
145
|
+
const boxRect = box.getBoundingClientRect();
|
|
146
|
+
const triggerRect = trigger.getBoundingClientRect();
|
|
147
|
+
const next = {
|
|
148
|
+
sideOffset: boxRect.bottom - triggerRect.bottom,
|
|
149
|
+
alignOffset: boxRect.left - triggerRect.left,
|
|
150
|
+
width: boxRect.width
|
|
151
|
+
};
|
|
152
|
+
setOffsets((prev)=>prev && prev.sideOffset === next.sideOffset && prev.alignOffset === next.alignOffset && prev.width === next.width ? prev : next);
|
|
153
|
+
}, [
|
|
154
|
+
enabled,
|
|
155
|
+
groupAnchor
|
|
156
|
+
]);
|
|
157
|
+
return {
|
|
158
|
+
measure,
|
|
159
|
+
offsets: enabled && groupAnchor ? offsets : null
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const SelectContent = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, children, position = 'popper', container, style, ...props }, ref)=>{
|
|
120
163
|
const resolvedContainer = (0, external_portal_container_cjs_namespaceObject.useResolvedPortalContainer)(container);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
164
|
+
const fit = useInputGroupFit('popper' === position && (props.align ?? 'start') === 'start');
|
|
165
|
+
const setContent = external_react_namespaceObject.useCallback((node)=>{
|
|
166
|
+
fit.measure(node);
|
|
167
|
+
if ('function' == typeof ref) ref(node);
|
|
168
|
+
else if (ref) ref.current = node;
|
|
169
|
+
}, [
|
|
170
|
+
fit.measure,
|
|
171
|
+
ref
|
|
172
|
+
]);
|
|
173
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_context_cjs_namespaceObject.InputGroupContext.Provider, {
|
|
174
|
+
value: external_input_group_context_cjs_namespaceObject.NO_GROUP,
|
|
175
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_select_namespaceObject.Portal, {
|
|
176
|
+
container: resolvedContainer,
|
|
177
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(react_select_namespaceObject.Content, {
|
|
178
|
+
ref: setContent,
|
|
179
|
+
"data-slot": "select-content",
|
|
180
|
+
className: (0, index_cjs_namespaceObject.cn)('relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md future:rounded-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]', 'popper' === position && 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1', className),
|
|
181
|
+
position: position,
|
|
182
|
+
...props,
|
|
183
|
+
sideOffset: (props.sideOffset ?? 0) + (fit.offsets?.sideOffset ?? 0),
|
|
184
|
+
alignOffset: (props.alignOffset ?? 0) + (fit.offsets?.alignOffset ?? 0),
|
|
185
|
+
collisionPadding: props.collisionPadding ?? (fit.offsets ? 0 : void 0),
|
|
186
|
+
style: fit.offsets ? {
|
|
187
|
+
width: fit.offsets.width,
|
|
188
|
+
...style
|
|
189
|
+
} : style,
|
|
190
|
+
children: [
|
|
191
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SelectScrollUpButton, {}),
|
|
192
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_select_namespaceObject.Viewport, {
|
|
193
|
+
className: (0, index_cjs_namespaceObject.cn)('p-1', 'popper' === position && 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]'),
|
|
194
|
+
children: children
|
|
195
|
+
}),
|
|
196
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SelectScrollDownButton, {})
|
|
197
|
+
]
|
|
198
|
+
})
|
|
137
199
|
})
|
|
138
200
|
});
|
|
139
201
|
});
|
|
@@ -19,6 +19,10 @@ export interface SelectTriggerProps extends React.ComponentPropsWithoutRef<typeo
|
|
|
19
19
|
declare const SelectTrigger: React.ForwardRefExoticComponent<SelectTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
20
20
|
declare const SelectScrollUpButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollUpButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
21
21
|
declare const SelectScrollDownButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollDownButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
22
|
+
/**
|
|
23
|
+
* Inside an InputGroup, a `popper` panel aligned to `start` is fitted to the group's box, with its
|
|
24
|
+
* width set inline. Size it with `style.width` there, since a width class loses to the inline one.
|
|
25
|
+
*/
|
|
22
26
|
declare const SelectContent: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
23
27
|
container?: PortalContainerOverride;
|
|
24
28
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Content, Group, Icon, Item, ItemIndicator, ItemText, Label, Portal, Root, ScrollDownButton, ScrollUpButton, Separator, Trigger, Value, Viewport } from "@radix-ui/react-select";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
4
5
|
import { Check, ChevronDown, ChevronUp } from "lucide-react";
|
|
5
|
-
import { forwardRef, useId } from "react";
|
|
6
|
+
import { forwardRef, useCallback, useId, useState } from "react";
|
|
6
7
|
import { useResolvedPortalContainer } from "./portal-container.js";
|
|
7
8
|
import { cn } from "../../lib/index.js";
|
|
8
9
|
import { FormFieldError } from "./form-field.js";
|
|
10
|
+
import { InputGroupContext, NO_GROUP, useControlValidation, useInputGroup } from "./input-group-context.js";
|
|
9
11
|
const Select = (props)=>/*#__PURE__*/ jsx(Root, {
|
|
10
12
|
"data-slot": "select",
|
|
11
13
|
...props
|
|
@@ -23,24 +25,40 @@ const SelectValue = /*#__PURE__*/ forwardRef((props, ref)=>/*#__PURE__*/ jsx(Val
|
|
|
23
25
|
...props
|
|
24
26
|
}));
|
|
25
27
|
SelectValue.displayName = Value.displayName;
|
|
28
|
+
const selectTriggerVariants = cva('flex w-full cursor-pointer items-center justify-between bg-transparent text-base transition-colors data-[placeholder]:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm [&>span]:line-clamp-1 future:font-normal', {
|
|
29
|
+
variants: {
|
|
30
|
+
grouped: {
|
|
31
|
+
false: 'h-9 rounded-md border border-input px-3 py-1 focus:outline-none focus:ring-2 focus:ring-ring focus-visible:ring-2 focus-visible:ring-ring future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:hover:bg-surface-hover future:px-4 future:gap-4 aria-invalid:border-error aria-invalid:focus-visible:ring-error future:aria-invalid:ring-1 future:aria-invalid:ring-error/40',
|
|
32
|
+
true: 'h-full min-h-5 min-w-0 flex-1 gap-2 p-0'
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
defaultVariants: {
|
|
36
|
+
grouped: false
|
|
37
|
+
}
|
|
38
|
+
});
|
|
26
39
|
const SelectTrigger = /*#__PURE__*/ forwardRef(({ 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage, 'aria-invalid': ariaInvalid, className, children, error, errorId, id, ...props }, ref)=>{
|
|
40
|
+
const group = useInputGroup();
|
|
27
41
|
const generatedId = useId();
|
|
28
42
|
const validationId = errorId ?? `${id ?? `select-${generatedId.replace(/:/g, '')}`}-error`;
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
43
|
+
const validation = useControlValidation(group, {
|
|
44
|
+
error,
|
|
45
|
+
errorId: validationId,
|
|
46
|
+
'aria-invalid': ariaInvalid,
|
|
47
|
+
'aria-describedby': ariaDescribedBy,
|
|
48
|
+
'aria-errormessage': ariaErrorMessage
|
|
49
|
+
});
|
|
33
50
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
34
51
|
children: [
|
|
35
52
|
/*#__PURE__*/ jsxs(Trigger, {
|
|
36
53
|
ref: ref,
|
|
37
54
|
id: id,
|
|
38
|
-
"data-slot":
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
55
|
+
"data-slot": group.inGroup ? 'input-group-control' : 'select-trigger',
|
|
56
|
+
...validation.aria,
|
|
57
|
+
className: cn(selectTriggerVariants({
|
|
58
|
+
grouped: group.inGroup
|
|
59
|
+
}), className),
|
|
43
60
|
...props,
|
|
61
|
+
disabled: props.disabled || group.disabled,
|
|
44
62
|
children: [
|
|
45
63
|
children,
|
|
46
64
|
/*#__PURE__*/ jsx(Icon, {
|
|
@@ -51,7 +69,7 @@ const SelectTrigger = /*#__PURE__*/ forwardRef(({ 'aria-describedby': ariaDescri
|
|
|
51
69
|
})
|
|
52
70
|
]
|
|
53
71
|
}),
|
|
54
|
-
/*#__PURE__*/ jsx(FormFieldError, {
|
|
72
|
+
validation.ownMessage && /*#__PURE__*/ jsx(FormFieldError, {
|
|
55
73
|
id: validationId,
|
|
56
74
|
children: error
|
|
57
75
|
})
|
|
@@ -79,24 +97,68 @@ const SelectScrollDownButton = /*#__PURE__*/ forwardRef(({ className, ...props }
|
|
|
79
97
|
})
|
|
80
98
|
}));
|
|
81
99
|
SelectScrollDownButton.displayName = ScrollDownButton.displayName;
|
|
82
|
-
|
|
100
|
+
function useInputGroupFit(enabled) {
|
|
101
|
+
const groupAnchor = useInputGroup().anchor;
|
|
102
|
+
const [offsets, setOffsets] = useState(null);
|
|
103
|
+
const measure = useCallback((content)=>{
|
|
104
|
+
const box = groupAnchor?.current;
|
|
105
|
+
if (!enabled || !content || !box) return;
|
|
106
|
+
const trigger = box.querySelector('[data-slot="input-group-control"][aria-expanded="true"]');
|
|
107
|
+
if (!trigger) return;
|
|
108
|
+
const boxRect = box.getBoundingClientRect();
|
|
109
|
+
const triggerRect = trigger.getBoundingClientRect();
|
|
110
|
+
const next = {
|
|
111
|
+
sideOffset: boxRect.bottom - triggerRect.bottom,
|
|
112
|
+
alignOffset: boxRect.left - triggerRect.left,
|
|
113
|
+
width: boxRect.width
|
|
114
|
+
};
|
|
115
|
+
setOffsets((prev)=>prev && prev.sideOffset === next.sideOffset && prev.alignOffset === next.alignOffset && prev.width === next.width ? prev : next);
|
|
116
|
+
}, [
|
|
117
|
+
enabled,
|
|
118
|
+
groupAnchor
|
|
119
|
+
]);
|
|
120
|
+
return {
|
|
121
|
+
measure,
|
|
122
|
+
offsets: enabled && groupAnchor ? offsets : null
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const SelectContent = /*#__PURE__*/ forwardRef(({ className, children, position = 'popper', container, style, ...props }, ref)=>{
|
|
83
126
|
const resolvedContainer = useResolvedPortalContainer(container);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
127
|
+
const fit = useInputGroupFit('popper' === position && (props.align ?? 'start') === 'start');
|
|
128
|
+
const setContent = useCallback((node)=>{
|
|
129
|
+
fit.measure(node);
|
|
130
|
+
if ('function' == typeof ref) ref(node);
|
|
131
|
+
else if (ref) ref.current = node;
|
|
132
|
+
}, [
|
|
133
|
+
fit.measure,
|
|
134
|
+
ref
|
|
135
|
+
]);
|
|
136
|
+
return /*#__PURE__*/ jsx(InputGroupContext.Provider, {
|
|
137
|
+
value: NO_GROUP,
|
|
138
|
+
children: /*#__PURE__*/ jsx(Portal, {
|
|
139
|
+
container: resolvedContainer,
|
|
140
|
+
children: /*#__PURE__*/ jsxs(Content, {
|
|
141
|
+
ref: setContent,
|
|
142
|
+
"data-slot": "select-content",
|
|
143
|
+
className: cn('relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md future:rounded-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]', 'popper' === position && 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1', className),
|
|
144
|
+
position: position,
|
|
145
|
+
...props,
|
|
146
|
+
sideOffset: (props.sideOffset ?? 0) + (fit.offsets?.sideOffset ?? 0),
|
|
147
|
+
alignOffset: (props.alignOffset ?? 0) + (fit.offsets?.alignOffset ?? 0),
|
|
148
|
+
collisionPadding: props.collisionPadding ?? (fit.offsets ? 0 : void 0),
|
|
149
|
+
style: fit.offsets ? {
|
|
150
|
+
width: fit.offsets.width,
|
|
151
|
+
...style
|
|
152
|
+
} : style,
|
|
153
|
+
children: [
|
|
154
|
+
/*#__PURE__*/ jsx(SelectScrollUpButton, {}),
|
|
155
|
+
/*#__PURE__*/ jsx(Viewport, {
|
|
156
|
+
className: cn('p-1', 'popper' === position && 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]'),
|
|
157
|
+
children: children
|
|
158
|
+
}),
|
|
159
|
+
/*#__PURE__*/ jsx(SelectScrollDownButton, {})
|
|
160
|
+
]
|
|
161
|
+
})
|
|
100
162
|
})
|
|
101
163
|
});
|
|
102
164
|
});
|