@mirohq/design-system-combobox 0.1.0-combobox.3 → 0.1.0-combobox.5
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/main.js +335 -81
- package/dist/main.js.map +1 -1
- package/dist/module.js +336 -82
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +459 -1154
- package/package.json +11 -13
package/dist/module.js
CHANGED
|
@@ -1,37 +1,51 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import React, { createContext, useRef, useState, useContext, useEffect } from 'react';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { useFormFieldContext } from '@mirohq/design-system-base-form';
|
|
2
|
+
import React, { createContext, useRef, useState, useContext, useCallback, useEffect, useMemo } from 'react';
|
|
3
|
+
import { Combobox as Combobox$1, ComboboxItem, ComboboxItemCheck, Group as Group$1, GroupLabel as GroupLabel$1, ComboboxProvider as ComboboxProvider$1 } from '@ariakit/react';
|
|
4
|
+
import { useFormFieldContext, FloatingLabel } from '@mirohq/design-system-base-form';
|
|
6
5
|
import * as RadixPopover from '@radix-ui/react-popover';
|
|
7
6
|
import { Portal as Portal$1 } from '@radix-ui/react-popover';
|
|
8
7
|
import { stringAttrValue, booleanishAttrValue, mergeRefs, booleanify } from '@mirohq/design-system-utils';
|
|
9
|
-
import { IconChevronDown, IconCross } from '@mirohq/design-system-icons';
|
|
10
8
|
import { styled } from '@mirohq/design-system-stitches';
|
|
11
9
|
import { Input } from '@mirohq/design-system-input';
|
|
10
|
+
import { IconChevronDown, IconCross, IconCheckMark } from '@mirohq/design-system-icons';
|
|
11
|
+
import { mergeProps } from '@react-aria/utils';
|
|
12
12
|
import { useAriaDisabled } from '@mirohq/design-system-use-aria-disabled';
|
|
13
13
|
import { focus } from '@mirohq/design-system-styles';
|
|
14
|
-
import { BaseButton } from '@mirohq/design-system-base-button';
|
|
15
14
|
import { Primitive } from '@mirohq/design-system-primitive';
|
|
15
|
+
import { BaseButton } from '@mirohq/design-system-base-button';
|
|
16
16
|
|
|
17
|
-
const StyledActionButton = styled(Input.ActionButton, {
|
|
18
|
-
position: "absolute",
|
|
19
|
-
right: "$100",
|
|
20
|
-
top: "10px"
|
|
21
|
-
});
|
|
22
17
|
const StyledInput = styled(Input, {
|
|
23
18
|
flexWrap: "wrap",
|
|
24
19
|
flexGrow: 1,
|
|
25
|
-
gap: "$50",
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
gap: "0 $50",
|
|
21
|
+
overflowY: "scroll",
|
|
22
|
+
"&[data-valid], &[data-invalid]": {
|
|
23
|
+
// we don't need a bigger padding here as Input component will render its own icon
|
|
24
|
+
paddingRight: "$100"
|
|
30
25
|
},
|
|
31
26
|
"& input": {
|
|
32
|
-
minWidth: "
|
|
27
|
+
minWidth: "$8",
|
|
33
28
|
flexBasis: 0,
|
|
34
29
|
flexGrow: 1
|
|
30
|
+
},
|
|
31
|
+
variants: {
|
|
32
|
+
size: {
|
|
33
|
+
large: {
|
|
34
|
+
minHeight: "$10",
|
|
35
|
+
height: "auto",
|
|
36
|
+
padding: "5px $100",
|
|
37
|
+
paddingRight: "$500"
|
|
38
|
+
},
|
|
39
|
+
"x-large": {
|
|
40
|
+
minHeight: "$12",
|
|
41
|
+
height: "auto",
|
|
42
|
+
padding: "5px $100",
|
|
43
|
+
paddingRight: "$500"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
defaultVariants: {
|
|
48
|
+
size: "large"
|
|
35
49
|
}
|
|
36
50
|
});
|
|
37
51
|
|
|
@@ -42,14 +56,18 @@ const ComboboxProvider = ({
|
|
|
42
56
|
valid,
|
|
43
57
|
value: valueProp,
|
|
44
58
|
defaultValue: defaultValueProp,
|
|
59
|
+
onSearchValueChange,
|
|
60
|
+
autoFilter = true,
|
|
45
61
|
...restProps
|
|
46
62
|
}) => {
|
|
47
63
|
const triggerRef = useRef(null);
|
|
64
|
+
const inputRef = useRef(null);
|
|
48
65
|
const contentRef = useRef(null);
|
|
49
|
-
const [openState, setOpenState] = useState(defaultOpen);
|
|
66
|
+
const [openState, setOpenState] = useState(defaultOpen != null ? defaultOpen : false);
|
|
50
67
|
const [value, setValue] = useState(valueProp != null ? valueProp : []);
|
|
51
68
|
const [defaultValue, setDefaultValue] = useState(defaultValueProp);
|
|
52
|
-
const [
|
|
69
|
+
const [filteredItems, setFilteredItems] = useState(/* @__PURE__ */ new Set());
|
|
70
|
+
const [searchValue, setSearchValue] = useState("");
|
|
53
71
|
const { valid: formFieldValid } = useFormFieldContext();
|
|
54
72
|
return /* @__PURE__ */ jsx(
|
|
55
73
|
ComboboxContext.Provider,
|
|
@@ -63,10 +81,15 @@ const ComboboxProvider = ({
|
|
|
63
81
|
setValue,
|
|
64
82
|
setDefaultValue,
|
|
65
83
|
defaultValue,
|
|
84
|
+
onSearchValueChange,
|
|
85
|
+
triggerRef,
|
|
86
|
+
inputRef,
|
|
87
|
+
contentRef,
|
|
88
|
+
autoFilter,
|
|
66
89
|
searchValue,
|
|
67
90
|
setSearchValue,
|
|
68
|
-
|
|
69
|
-
|
|
91
|
+
filteredItems,
|
|
92
|
+
setFilteredItems
|
|
70
93
|
},
|
|
71
94
|
children
|
|
72
95
|
}
|
|
@@ -74,6 +97,47 @@ const ComboboxProvider = ({
|
|
|
74
97
|
};
|
|
75
98
|
const useComboboxContext = () => useContext(ComboboxContext);
|
|
76
99
|
|
|
100
|
+
const StyledActionButton = styled(Input.ActionButton, {
|
|
101
|
+
position: "absolute",
|
|
102
|
+
right: "$100",
|
|
103
|
+
variants: {
|
|
104
|
+
size: {
|
|
105
|
+
large: {
|
|
106
|
+
top: "5px"
|
|
107
|
+
},
|
|
108
|
+
"x-large": {
|
|
109
|
+
top: "9px"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
defaultVariants: {
|
|
114
|
+
size: "large"
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const TriggerActionButton = ({
|
|
119
|
+
openActionLabel,
|
|
120
|
+
clearActionLabel,
|
|
121
|
+
size
|
|
122
|
+
}) => {
|
|
123
|
+
const { setOpenState, value, setValue } = useComboboxContext();
|
|
124
|
+
const isEmpty = value.length === 0;
|
|
125
|
+
const ActionButtonIcon = isEmpty ? IconChevronDown : IconCross;
|
|
126
|
+
const label = isEmpty ? openActionLabel : clearActionLabel;
|
|
127
|
+
const onActionButtonClick = useCallback(
|
|
128
|
+
(event) => {
|
|
129
|
+
if (!isEmpty) {
|
|
130
|
+
setValue([]);
|
|
131
|
+
} else {
|
|
132
|
+
setOpenState((prevOpen) => !prevOpen);
|
|
133
|
+
}
|
|
134
|
+
event.stopPropagation();
|
|
135
|
+
},
|
|
136
|
+
[isEmpty, setValue, setOpenState]
|
|
137
|
+
);
|
|
138
|
+
return /* @__PURE__ */ jsx(StyledActionButton, { label, size, onClick: onActionButtonClick, children: /* @__PURE__ */ jsx(ActionButtonIcon, { size: "small", weight: "thin" }) });
|
|
139
|
+
};
|
|
140
|
+
|
|
77
141
|
const Trigger = React.forwardRef(
|
|
78
142
|
({
|
|
79
143
|
id,
|
|
@@ -82,6 +146,9 @@ const Trigger = React.forwardRef(
|
|
|
82
146
|
"aria-describedby": ariaDescribedBy,
|
|
83
147
|
"aria-invalid": ariaInvalid,
|
|
84
148
|
placeholder,
|
|
149
|
+
openActionLabel,
|
|
150
|
+
clearActionLabel,
|
|
151
|
+
onChange,
|
|
85
152
|
...restProps
|
|
86
153
|
}, forwardRef) => {
|
|
87
154
|
const {
|
|
@@ -89,13 +156,20 @@ const Trigger = React.forwardRef(
|
|
|
89
156
|
valid: comboboxValid,
|
|
90
157
|
disabled,
|
|
91
158
|
value,
|
|
92
|
-
triggerRef
|
|
159
|
+
triggerRef,
|
|
160
|
+
inputRef,
|
|
161
|
+
onSearchValueChange,
|
|
162
|
+
searchValue,
|
|
163
|
+
setSearchValue
|
|
93
164
|
} = useComboboxContext();
|
|
94
165
|
const {
|
|
95
166
|
formElementId,
|
|
96
167
|
ariaDescribedBy: formFieldContextDescribedBy,
|
|
97
168
|
ariaInvalid: formFieldAriaInvalid,
|
|
98
|
-
valid: formFieldValid
|
|
169
|
+
valid: formFieldValid,
|
|
170
|
+
label,
|
|
171
|
+
isFloatingLabel,
|
|
172
|
+
focused
|
|
99
173
|
} = useFormFieldContext();
|
|
100
174
|
const valid = formFieldValid != null ? formFieldValid : comboboxValid;
|
|
101
175
|
const inputProps = {
|
|
@@ -110,20 +184,59 @@ const Trigger = React.forwardRef(
|
|
|
110
184
|
disabled,
|
|
111
185
|
invalid: booleanishAttrValue(valid),
|
|
112
186
|
id: id != null ? id : formElementId,
|
|
113
|
-
placeholder:
|
|
187
|
+
placeholder: value.length === 0 ? placeholder : void 0
|
|
114
188
|
};
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
189
|
+
const shouldUseFloatingLabel = label !== null && isFloatingLabel;
|
|
190
|
+
const isFloating = placeholder !== void 0 || value.length !== 0 || focused;
|
|
191
|
+
const scrollIntoView = (event) => {
|
|
192
|
+
var _a;
|
|
193
|
+
const trigger = triggerRef == null ? void 0 : triggerRef.current;
|
|
194
|
+
const baseInput = (_a = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a.parentElement;
|
|
195
|
+
if (baseInput != null && trigger != null) {
|
|
196
|
+
event.preventDefault();
|
|
197
|
+
baseInput.scrollTo({
|
|
198
|
+
top: trigger.scrollHeight
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (restProps.onFocus !== void 0) {
|
|
202
|
+
restProps.onFocus(event);
|
|
125
203
|
}
|
|
126
|
-
|
|
204
|
+
};
|
|
205
|
+
const onInputChange = (e) => {
|
|
206
|
+
setSearchValue(e.target.value);
|
|
207
|
+
onSearchValueChange == null ? void 0 : onSearchValueChange(e.target.value);
|
|
208
|
+
onChange == null ? void 0 : onChange(e);
|
|
209
|
+
};
|
|
210
|
+
return /* @__PURE__ */ jsxs(RadixPopover.Anchor, { ref: mergeRefs([triggerRef, forwardRef]), children: [
|
|
211
|
+
shouldUseFloatingLabel && /* @__PURE__ */ jsx(FloatingLabel, { floating: isFloating, size, children: label }),
|
|
212
|
+
/* @__PURE__ */ jsx(
|
|
213
|
+
Combobox$1,
|
|
214
|
+
{
|
|
215
|
+
render: /* @__PURE__ */ jsxs(
|
|
216
|
+
StyledInput,
|
|
217
|
+
{
|
|
218
|
+
...inputProps,
|
|
219
|
+
value: searchValue,
|
|
220
|
+
size,
|
|
221
|
+
ref: inputRef,
|
|
222
|
+
onChange: onInputChange,
|
|
223
|
+
onFocus: scrollIntoView,
|
|
224
|
+
children: [
|
|
225
|
+
children,
|
|
226
|
+
/* @__PURE__ */ jsx(
|
|
227
|
+
TriggerActionButton,
|
|
228
|
+
{
|
|
229
|
+
openActionLabel,
|
|
230
|
+
clearActionLabel,
|
|
231
|
+
size
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
)
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
] });
|
|
127
240
|
}
|
|
128
241
|
);
|
|
129
242
|
|
|
@@ -134,37 +247,24 @@ const StyledContent = styled(RadixPopover.Content, {
|
|
|
134
247
|
fontSize: "$175",
|
|
135
248
|
fontWeight: "normal",
|
|
136
249
|
lineHeight: "1.5",
|
|
137
|
-
|
|
250
|
+
width: "var(--radix-popover-trigger-width)",
|
|
138
251
|
zIndex: "$select",
|
|
139
252
|
overflowY: "auto",
|
|
140
|
-
marginTop: "$200"
|
|
253
|
+
marginTop: "$200",
|
|
254
|
+
padding: "$150",
|
|
255
|
+
boxSizing: "border-box",
|
|
256
|
+
outline: "1px solid transparent"
|
|
141
257
|
});
|
|
142
258
|
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
StyledContent,
|
|
147
|
-
{
|
|
148
|
-
...restProps,
|
|
149
|
-
ref: mergeRefs([forwardRef, contentRef]),
|
|
150
|
-
onOpenAutoFocus: (event) => event.preventDefault(),
|
|
151
|
-
onInteractOutside: (event) => {
|
|
152
|
-
var _a, _b;
|
|
153
|
-
const target = event.target;
|
|
154
|
-
const isTrigger = target === triggerRef.current;
|
|
155
|
-
const isContent = (_b = target != null && ((_a = contentRef.current) == null ? void 0 : _a.contains(target))) != null ? _b : false;
|
|
156
|
-
if (isTrigger || isContent) {
|
|
157
|
-
event.preventDefault();
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
children
|
|
161
|
-
}
|
|
162
|
-
);
|
|
259
|
+
const StyledItemCheck = styled(Primitive.span, {
|
|
260
|
+
color: "$icon-primary",
|
|
261
|
+
paddingX: "$100"
|
|
163
262
|
});
|
|
164
|
-
|
|
165
263
|
const StyledItem = styled(ComboboxItem, {
|
|
166
264
|
display: "flex",
|
|
167
265
|
alignItems: "center",
|
|
266
|
+
justifyContent: "space-between",
|
|
267
|
+
gap: "$200",
|
|
168
268
|
borderRadius: "$50",
|
|
169
269
|
boxSizing: "border-box",
|
|
170
270
|
color: "$text-neutrals",
|
|
@@ -173,15 +273,19 @@ const StyledItem = styled(ComboboxItem, {
|
|
|
173
273
|
lineHeight: 1.5,
|
|
174
274
|
position: "relative",
|
|
175
275
|
userSelect: "none",
|
|
176
|
-
|
|
177
|
-
|
|
276
|
+
paddingX: "$100",
|
|
277
|
+
paddingY: "10px",
|
|
178
278
|
...focus.css({
|
|
179
|
-
boxShadow: "$focus-small"
|
|
180
|
-
outline: "1px solid transparent"
|
|
279
|
+
boxShadow: "$focus-small"
|
|
181
280
|
}),
|
|
182
|
-
'&:
|
|
183
|
-
|
|
184
|
-
|
|
281
|
+
'&:not([aria-disabled="true"])': {
|
|
282
|
+
_hover: {
|
|
283
|
+
background: "$background-primary-subtle-hover",
|
|
284
|
+
color: "$text-primary-hover",
|
|
285
|
+
["".concat(StyledItemCheck)]: {
|
|
286
|
+
color: "$icon-primary-hover"
|
|
287
|
+
}
|
|
288
|
+
}
|
|
185
289
|
},
|
|
186
290
|
"&:disabled, &[aria-disabled=true], &[data-disabled]": {
|
|
187
291
|
cursor: "default",
|
|
@@ -192,39 +296,150 @@ const StyledItem = styled(ComboboxItem, {
|
|
|
192
296
|
const Item = React.forwardRef(
|
|
193
297
|
({ disabled = false, value, textValue, children, ...restProps }, forwardRef) => {
|
|
194
298
|
const { "aria-disabled": ariaDisabled, ...restAriaDisabledProps } = useAriaDisabled(restProps, { allowArrows: true });
|
|
299
|
+
const { autoFilter, filteredItems, triggerRef, inputRef } = useComboboxContext();
|
|
300
|
+
if (autoFilter !== false && !filteredItems.has(value)) {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
const scrollIntoView = (event) => {
|
|
304
|
+
var _a;
|
|
305
|
+
if (((_a = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a.parentElement) != null && (triggerRef == null ? void 0 : triggerRef.current) != null) {
|
|
306
|
+
inputRef.current.parentElement.scrollTo({
|
|
307
|
+
top: triggerRef.current.scrollHeight
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
if (restProps.onClick !== void 0) {
|
|
311
|
+
restProps.onClick(event);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
195
314
|
return /* @__PURE__ */ jsxs(
|
|
196
315
|
StyledItem,
|
|
197
316
|
{
|
|
198
|
-
...restProps,
|
|
199
|
-
...restAriaDisabledProps,
|
|
317
|
+
...mergeProps(restProps, restAriaDisabledProps),
|
|
200
318
|
focusable: true,
|
|
201
319
|
accessibleWhenDisabled: ariaDisabled === true,
|
|
202
320
|
disabled: ariaDisabled === true || disabled,
|
|
203
321
|
ref: forwardRef,
|
|
204
322
|
value,
|
|
323
|
+
onClick: scrollIntoView,
|
|
205
324
|
children: [
|
|
206
|
-
|
|
207
|
-
|
|
325
|
+
children,
|
|
326
|
+
/* @__PURE__ */ jsx(
|
|
327
|
+
ComboboxItemCheck,
|
|
328
|
+
{
|
|
329
|
+
render: ({ style, ...props }) => (
|
|
330
|
+
// AriakitComboboxItemCheck adds its owm inline styles which we want to omit here
|
|
331
|
+
/* @__PURE__ */ jsx(StyledItemCheck, { ...props })
|
|
332
|
+
),
|
|
333
|
+
children: /* @__PURE__ */ jsx(IconCheckMark, { size: "small" })
|
|
334
|
+
}
|
|
335
|
+
)
|
|
208
336
|
]
|
|
209
337
|
}
|
|
210
338
|
);
|
|
211
339
|
}
|
|
212
340
|
);
|
|
213
341
|
|
|
214
|
-
const
|
|
342
|
+
const itemType = React.createElement(Item).type;
|
|
343
|
+
const getChildrenItemValues = (componentChildren) => {
|
|
344
|
+
const values = [];
|
|
345
|
+
const recurse = (children) => {
|
|
346
|
+
React.Children.forEach(children, (child) => {
|
|
347
|
+
if (!React.isValidElement(child)) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
if (child.type === itemType) {
|
|
351
|
+
const props = child.props;
|
|
352
|
+
values.push(props.value);
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
if (child.props.children) {
|
|
356
|
+
recurse(child.props.children);
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
};
|
|
360
|
+
recurse(componentChildren);
|
|
361
|
+
return values;
|
|
362
|
+
};
|
|
215
363
|
|
|
216
|
-
const
|
|
364
|
+
const isInsideRef = (element, ref) => {
|
|
365
|
+
var _a, _b;
|
|
366
|
+
return (_b = element != null && ((_a = ref.current) == null ? void 0 : _a.contains(element))) != null ? _b : false;
|
|
367
|
+
};
|
|
368
|
+
const Content = React.forwardRef(({ children, ...restProps }, forwardRef) => {
|
|
369
|
+
const {
|
|
370
|
+
triggerRef,
|
|
371
|
+
contentRef,
|
|
372
|
+
autoFilter,
|
|
373
|
+
filteredItems,
|
|
374
|
+
setFilteredItems,
|
|
375
|
+
searchValue,
|
|
376
|
+
noResultsText
|
|
377
|
+
} = useComboboxContext();
|
|
378
|
+
useEffect(() => {
|
|
379
|
+
const childrenItemValues = getChildrenItemValues(children);
|
|
380
|
+
setFilteredItems(
|
|
381
|
+
new Set(
|
|
382
|
+
autoFilter === false ? childrenItemValues : childrenItemValues.filter(
|
|
383
|
+
(child) => child.toLowerCase().includes(searchValue.toLowerCase())
|
|
384
|
+
)
|
|
385
|
+
)
|
|
386
|
+
);
|
|
387
|
+
}, [children, autoFilter, setFilteredItems, searchValue]);
|
|
388
|
+
return /* @__PURE__ */ jsx(
|
|
389
|
+
StyledContent,
|
|
390
|
+
{
|
|
391
|
+
...restProps,
|
|
392
|
+
ref: mergeRefs([forwardRef, contentRef]),
|
|
393
|
+
onOpenAutoFocus: (event) => event.preventDefault(),
|
|
394
|
+
onInteractOutside: (event) => {
|
|
395
|
+
const target = event.target;
|
|
396
|
+
const isTrigger = isInsideRef(target, triggerRef);
|
|
397
|
+
const isContent = isInsideRef(target, contentRef);
|
|
398
|
+
if (isTrigger || isContent) {
|
|
399
|
+
event.preventDefault();
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
children: filteredItems.size === 0 ? noResultsText : children
|
|
403
|
+
}
|
|
404
|
+
);
|
|
405
|
+
});
|
|
217
406
|
|
|
218
|
-
const
|
|
407
|
+
const Portal = (props) => /* @__PURE__ */ jsx(Portal$1, { ...props });
|
|
219
408
|
|
|
220
|
-
const
|
|
409
|
+
const Group = React.forwardRef(({ children, ...rest }, forwardRef) => {
|
|
410
|
+
const { autoFilter, filteredItems } = useComboboxContext();
|
|
411
|
+
const childValues = useMemo(
|
|
412
|
+
// don't perform calculation if auto filter is disabled
|
|
413
|
+
() => autoFilter !== false ? getChildrenItemValues(children) : [],
|
|
414
|
+
[children, autoFilter]
|
|
415
|
+
);
|
|
416
|
+
const hasVisibleChildren = useMemo(
|
|
417
|
+
() => (
|
|
418
|
+
// don't perform calculation if auto filter is disabled
|
|
419
|
+
autoFilter !== false ? childValues.some((value) => filteredItems.has(value)) : true
|
|
420
|
+
),
|
|
421
|
+
[childValues, filteredItems, autoFilter]
|
|
422
|
+
);
|
|
423
|
+
if (!hasVisibleChildren) {
|
|
424
|
+
return null;
|
|
425
|
+
}
|
|
426
|
+
return /* @__PURE__ */ jsx(Group$1, { ...rest, ref: forwardRef, children });
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
const StyledGroupLabel = styled(GroupLabel$1, {
|
|
430
|
+
padding: "$100",
|
|
431
|
+
color: "$text-neutrals-subtle",
|
|
432
|
+
fontSize: "$150",
|
|
433
|
+
textTransform: "uppercase",
|
|
434
|
+
fontWeight: 650
|
|
435
|
+
});
|
|
221
436
|
|
|
222
437
|
const GroupLabel = React.forwardRef((props, forwardRef) => /* @__PURE__ */ jsx(StyledGroupLabel, { ...props, ref: forwardRef }));
|
|
223
438
|
|
|
224
439
|
const StyledChip = styled(Primitive.div, {
|
|
225
440
|
fontSize: "$150",
|
|
226
441
|
padding: "$50 $100",
|
|
227
|
-
borderRadius: "$
|
|
442
|
+
borderRadius: "$round",
|
|
228
443
|
display: "flex",
|
|
229
444
|
alignItems: "center",
|
|
230
445
|
gap: "$50",
|
|
@@ -233,6 +448,12 @@ const StyledChip = styled(Primitive.div, {
|
|
|
233
448
|
background: "$gray-100",
|
|
234
449
|
color: "$gray-900"
|
|
235
450
|
});
|
|
451
|
+
const StyledChipButton = styled(BaseButton, {
|
|
452
|
+
...focus.css({
|
|
453
|
+
boxShadow: "$focus-small-outline",
|
|
454
|
+
borderColor: "$blue-400 !important"
|
|
455
|
+
})
|
|
456
|
+
});
|
|
236
457
|
const StyledChipContent = styled(Primitive.div, {
|
|
237
458
|
textOverflow: "ellipsis",
|
|
238
459
|
whiteSpace: "nowrap",
|
|
@@ -250,11 +471,15 @@ const LeftSlot = StyledLeftSlot;
|
|
|
250
471
|
const Chip = React.forwardRef(
|
|
251
472
|
({ children, disabled = false, onRemove, removeChipAriaLabel, ...restProps }, forwardRef) => /* @__PURE__ */ jsxs(StyledChip, { ...restProps, ref: forwardRef, children: [
|
|
252
473
|
/* @__PURE__ */ jsx(StyledChipContent, { children }),
|
|
253
|
-
!booleanify(disabled) && /* @__PURE__ */ jsx(
|
|
474
|
+
!booleanify(disabled) && /* @__PURE__ */ jsx(StyledChipButton, { onClick: onRemove, "aria-label": removeChipAriaLabel, children: /* @__PURE__ */ jsx(IconCross, { size: "small", weight: "thin", color: "gray-500" }) })
|
|
254
475
|
] })
|
|
255
476
|
);
|
|
256
477
|
Chip.LeftSlot = LeftSlot;
|
|
257
478
|
|
|
479
|
+
const StyledValue = styled(Chip, {
|
|
480
|
+
marginTop: "$50"
|
|
481
|
+
});
|
|
482
|
+
|
|
258
483
|
const Value = ({ removeChipAriaLabel }) => {
|
|
259
484
|
const {
|
|
260
485
|
value,
|
|
@@ -262,16 +487,15 @@ const Value = ({ removeChipAriaLabel }) => {
|
|
|
262
487
|
disabled,
|
|
263
488
|
"aria-disabled": ariaDisabled
|
|
264
489
|
} = useComboboxContext();
|
|
265
|
-
const isEmpty = value === void 0 || value.length === 0;
|
|
266
490
|
const isDisabled = ariaDisabled === true || disabled;
|
|
267
491
|
const onItemRemove = (item) => {
|
|
268
492
|
setValue((prevValue) => prevValue.filter((value2) => value2 !== item));
|
|
269
493
|
};
|
|
270
|
-
if (
|
|
494
|
+
if (value.length === 0) {
|
|
271
495
|
return null;
|
|
272
496
|
}
|
|
273
497
|
return /* @__PURE__ */ jsx(Fragment, { children: value.map((item) => /* @__PURE__ */ jsx(
|
|
274
|
-
|
|
498
|
+
StyledValue,
|
|
275
499
|
{
|
|
276
500
|
onRemove: () => onItemRemove(item),
|
|
277
501
|
disabled: isDisabled,
|
|
@@ -282,7 +506,18 @@ const Value = ({ removeChipAriaLabel }) => {
|
|
|
282
506
|
)) });
|
|
283
507
|
};
|
|
284
508
|
|
|
285
|
-
const
|
|
509
|
+
const StyledSeparator = styled(Primitive.div, {
|
|
510
|
+
backgroundColor: "$border-neutrals-subtle",
|
|
511
|
+
height: "1px",
|
|
512
|
+
width: "100%",
|
|
513
|
+
margin: "$100 0"
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
const Separator = React.forwardRef((props, forwardRef) => /* @__PURE__ */ jsx(StyledSeparator, { ...props, ref: forwardRef, "aria-hidden": true }));
|
|
517
|
+
|
|
518
|
+
const StyledComboboxContent = styled(Primitive.div, {
|
|
519
|
+
position: "relative"
|
|
520
|
+
});
|
|
286
521
|
|
|
287
522
|
const Root = React.forwardRef(({ value: valueProp, onValueChange, children, ...restProps }, forwardRef) => {
|
|
288
523
|
const {
|
|
@@ -318,7 +553,7 @@ const Root = React.forwardRef(({ value: valueProp, onValueChange, children, ...r
|
|
|
318
553
|
setValue(newValue);
|
|
319
554
|
};
|
|
320
555
|
return /* @__PURE__ */ jsx(RadixPopover.Root, { open: openState, onOpenChange: setOpenState, children: /* @__PURE__ */ jsx(
|
|
321
|
-
|
|
556
|
+
ComboboxProvider$1,
|
|
322
557
|
{
|
|
323
558
|
open: openState,
|
|
324
559
|
setOpen: setOpenState,
|
|
@@ -340,15 +575,19 @@ const Combobox = React.forwardRef(
|
|
|
340
575
|
required,
|
|
341
576
|
value,
|
|
342
577
|
defaultValue,
|
|
578
|
+
onSearchValueChange,
|
|
343
579
|
onOpen,
|
|
344
580
|
onValueChange,
|
|
345
581
|
direction = "ltr",
|
|
582
|
+
autoFilter = true,
|
|
583
|
+
noResultsText,
|
|
346
584
|
...restProps
|
|
347
585
|
}, forwardRef) => /* @__PURE__ */ jsx(
|
|
348
586
|
ComboboxProvider,
|
|
349
587
|
{
|
|
350
588
|
defaultValue,
|
|
351
589
|
value,
|
|
590
|
+
onSearchValueChange,
|
|
352
591
|
defaultOpen,
|
|
353
592
|
open,
|
|
354
593
|
valid,
|
|
@@ -357,7 +596,17 @@ const Combobox = React.forwardRef(
|
|
|
357
596
|
readOnly,
|
|
358
597
|
"aria-disabled": ariaDisabled,
|
|
359
598
|
direction,
|
|
360
|
-
|
|
599
|
+
autoFilter,
|
|
600
|
+
noResultsText,
|
|
601
|
+
children: /* @__PURE__ */ jsx(
|
|
602
|
+
Root,
|
|
603
|
+
{
|
|
604
|
+
...restProps,
|
|
605
|
+
noResultsText,
|
|
606
|
+
value,
|
|
607
|
+
ref: forwardRef
|
|
608
|
+
}
|
|
609
|
+
)
|
|
361
610
|
}
|
|
362
611
|
)
|
|
363
612
|
);
|
|
@@ -368,6 +617,11 @@ Combobox.Item = Item;
|
|
|
368
617
|
Combobox.Group = Group;
|
|
369
618
|
Combobox.GroupLabel = GroupLabel;
|
|
370
619
|
Combobox.Value = Value;
|
|
620
|
+
Combobox.Separator = Separator;
|
|
621
|
+
|
|
622
|
+
var types = /*#__PURE__*/Object.freeze({
|
|
623
|
+
__proto__: null
|
|
624
|
+
});
|
|
371
625
|
|
|
372
|
-
export {
|
|
626
|
+
export { Combobox, types as ComboboxTypes };
|
|
373
627
|
//# sourceMappingURL=module.js.map
|