@mirohq/design-system-combobox 0.1.0-combobox.6 → 0.1.0-combobox.8
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 +191 -146
- package/dist/main.js.map +1 -1
- package/dist/module.js +194 -149
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +18 -18
- package/package.json +11 -11
package/dist/module.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import React, { createContext, useRef, useState,
|
|
3
|
-
import { Combobox as Combobox$1, ComboboxItem, ComboboxItemCheck, Group as Group$1, GroupLabel as GroupLabel$1, ComboboxProvider as ComboboxProvider$1 } from '@ariakit/react';
|
|
2
|
+
import React, { createContext, useContext, useRef, useState, useCallback, useEffect, useMemo } from 'react';
|
|
3
|
+
import { Combobox as Combobox$1, ComboboxItem, ComboboxItemCheck, ComboboxList, Group as Group$1, GroupLabel as GroupLabel$1, ComboboxProvider as ComboboxProvider$1 } from '@ariakit/react';
|
|
4
4
|
import { useFormFieldContext, FloatingLabel } from '@mirohq/design-system-base-form';
|
|
5
|
-
import { stringAttrValue, booleanishAttrValue, mergeRefs, booleanify } from '@mirohq/design-system-utils';
|
|
6
5
|
import * as RadixPopover from '@radix-ui/react-popover';
|
|
7
|
-
import { Portal as Portal$1 } from '@radix-ui/react-popover';
|
|
6
|
+
import { Anchor, Trigger as Trigger$1, Portal as Portal$1 } from '@radix-ui/react-popover';
|
|
7
|
+
import { booleanishAttrValue, mergeRefs, booleanify } from '@mirohq/design-system-utils';
|
|
8
8
|
import { styled, theme } from '@mirohq/design-system-stitches';
|
|
9
9
|
import { Input } from '@mirohq/design-system-input';
|
|
10
10
|
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
11
11
|
import { IconChevronDown, IconCross, IconCheckMark } from '@mirohq/design-system-icons';
|
|
12
12
|
import { ScrollArea } from '@mirohq/design-system-scroll-area';
|
|
13
|
+
import { Primitive } from '@mirohq/design-system-primitive';
|
|
13
14
|
import { mergeProps } from '@react-aria/utils';
|
|
14
15
|
import { useAriaDisabled } from '@mirohq/design-system-use-aria-disabled';
|
|
15
16
|
import { focus } from '@mirohq/design-system-styles';
|
|
16
|
-
import { Primitive } from '@mirohq/design-system-primitive';
|
|
17
17
|
import { BaseButton } from '@mirohq/design-system-base-button';
|
|
18
18
|
|
|
19
|
+
const StyledAnchor = styled(Anchor, {
|
|
20
|
+
position: "relative",
|
|
21
|
+
width: "100%"
|
|
22
|
+
});
|
|
19
23
|
const StyledInput = styled(Input, {
|
|
20
24
|
flexWrap: "wrap",
|
|
21
25
|
flexGrow: 1,
|
|
@@ -137,25 +141,48 @@ const StyledActionButton = styled(Input.ActionButton, {
|
|
|
137
141
|
|
|
138
142
|
const TriggerActionButton = ({
|
|
139
143
|
openActionLabel,
|
|
144
|
+
closeActionLabel,
|
|
140
145
|
clearActionLabel,
|
|
141
146
|
size
|
|
142
147
|
}) => {
|
|
143
|
-
const { setOpenState, value = [], setValue } = useComboboxContext();
|
|
148
|
+
const { openState, setOpenState, value = [], setValue } = useComboboxContext();
|
|
144
149
|
const isEmpty = value.length === 0;
|
|
145
|
-
const
|
|
146
|
-
const label = isEmpty ? openActionLabel : clearActionLabel;
|
|
147
|
-
const onActionButtonClick = useCallback(
|
|
150
|
+
const onToggleClick = useCallback(
|
|
148
151
|
(event) => {
|
|
149
|
-
if (
|
|
150
|
-
|
|
151
|
-
} else {
|
|
152
|
-
setOpenState((prevOpen = false) => !prevOpen);
|
|
152
|
+
if (openState) {
|
|
153
|
+
setOpenState(false);
|
|
153
154
|
}
|
|
154
155
|
event.stopPropagation();
|
|
155
156
|
},
|
|
156
|
-
[
|
|
157
|
+
[setOpenState, openState]
|
|
158
|
+
);
|
|
159
|
+
const onClearClick = useCallback(
|
|
160
|
+
(event) => {
|
|
161
|
+
setValue([]);
|
|
162
|
+
event.stopPropagation();
|
|
163
|
+
},
|
|
164
|
+
[setValue]
|
|
165
|
+
);
|
|
166
|
+
if (isEmpty) {
|
|
167
|
+
return /* @__PURE__ */ jsx(Trigger$1, { asChild: true, "aria-haspopup": "listbox", children: /* @__PURE__ */ jsx(
|
|
168
|
+
StyledActionButton,
|
|
169
|
+
{
|
|
170
|
+
label: openState ? closeActionLabel : openActionLabel,
|
|
171
|
+
size,
|
|
172
|
+
onClick: onToggleClick,
|
|
173
|
+
children: /* @__PURE__ */ jsx(IconChevronDown, { size: "small", weight: "thin" })
|
|
174
|
+
}
|
|
175
|
+
) });
|
|
176
|
+
}
|
|
177
|
+
return /* @__PURE__ */ jsx(
|
|
178
|
+
StyledActionButton,
|
|
179
|
+
{
|
|
180
|
+
label: clearActionLabel,
|
|
181
|
+
size,
|
|
182
|
+
onClick: onClearClick,
|
|
183
|
+
children: /* @__PURE__ */ jsx(IconCross, { size: "small", weight: "thin" })
|
|
184
|
+
}
|
|
157
185
|
);
|
|
158
|
-
return /* @__PURE__ */ jsx(StyledActionButton, { label, size, onClick: onActionButtonClick, children: /* @__PURE__ */ jsx(ActionButtonIcon, { size: "small", weight: "thin" }) });
|
|
159
186
|
};
|
|
160
187
|
|
|
161
188
|
const Trigger = React.forwardRef(
|
|
@@ -167,8 +194,10 @@ const Trigger = React.forwardRef(
|
|
|
167
194
|
"aria-invalid": ariaInvalid,
|
|
168
195
|
placeholder,
|
|
169
196
|
openActionLabel,
|
|
197
|
+
closeActionLabel,
|
|
170
198
|
clearActionLabel,
|
|
171
199
|
onChange,
|
|
200
|
+
css,
|
|
172
201
|
...restProps
|
|
173
202
|
}, forwardRef) => {
|
|
174
203
|
const {
|
|
@@ -176,15 +205,16 @@ const Trigger = React.forwardRef(
|
|
|
176
205
|
valid: comboboxValid,
|
|
177
206
|
disabled,
|
|
178
207
|
value = [],
|
|
208
|
+
readOnly,
|
|
179
209
|
triggerRef,
|
|
180
210
|
inputRef,
|
|
181
211
|
onSearchValueChange,
|
|
182
212
|
searchValue,
|
|
183
|
-
setSearchValue
|
|
213
|
+
setSearchValue,
|
|
214
|
+
setOpenState
|
|
184
215
|
} = useComboboxContext();
|
|
185
216
|
const {
|
|
186
217
|
formElementId,
|
|
187
|
-
ariaDescribedBy: formFieldContextDescribedBy,
|
|
188
218
|
ariaInvalid: formFieldAriaInvalid,
|
|
189
219
|
valid: formFieldValid,
|
|
190
220
|
label,
|
|
@@ -196,18 +226,17 @@ const Trigger = React.forwardRef(
|
|
|
196
226
|
...restProps,
|
|
197
227
|
"aria-disabled": ariaDisabled,
|
|
198
228
|
"aria-invalid": ariaInvalid != null ? ariaInvalid : formFieldAriaInvalid,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
formFieldContextDescribedBy
|
|
202
|
-
),
|
|
229
|
+
// todo MDS-1011: use formFieldContextDescribedBy after removing form context from BaseInput
|
|
230
|
+
"aria-describedby": ariaDescribedBy,
|
|
203
231
|
valid,
|
|
204
232
|
disabled,
|
|
233
|
+
readOnly,
|
|
205
234
|
invalid: booleanishAttrValue(valid),
|
|
206
235
|
id: id != null ? id : formElementId,
|
|
207
236
|
placeholder: value.length === 0 ? placeholder : void 0
|
|
208
237
|
};
|
|
209
238
|
const shouldUseFloatingLabel = label !== null && isFloatingLabel;
|
|
210
|
-
const isFloating = placeholder !== void 0 || value.length !== 0 || focused;
|
|
239
|
+
const isFloating = placeholder !== void 0 || value.length !== 0 || focused || searchValue !== "";
|
|
211
240
|
const scrollIntoView = (event) => {
|
|
212
241
|
var _a;
|
|
213
242
|
const trigger = triggerRef == null ? void 0 : triggerRef.current;
|
|
@@ -227,73 +256,85 @@ const Trigger = React.forwardRef(
|
|
|
227
256
|
onSearchValueChange == null ? void 0 : onSearchValueChange(e.target.value);
|
|
228
257
|
onChange == null ? void 0 : onChange(e);
|
|
229
258
|
};
|
|
230
|
-
return /* @__PURE__ */ jsxs(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
259
|
+
return /* @__PURE__ */ jsxs(
|
|
260
|
+
StyledAnchor,
|
|
261
|
+
{
|
|
262
|
+
ref: mergeRefs([triggerRef, forwardRef]),
|
|
263
|
+
css,
|
|
264
|
+
onClick: () => {
|
|
265
|
+
if (!booleanify(disabled) && !booleanify(ariaDisabled) && !booleanify(readOnly)) {
|
|
266
|
+
setOpenState(true);
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
children: [
|
|
270
|
+
shouldUseFloatingLabel && /* @__PURE__ */ jsx(FloatingLabel, { floating: isFloating, size, children: label }),
|
|
271
|
+
/* @__PURE__ */ jsx(
|
|
272
|
+
Combobox$1,
|
|
237
273
|
{
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
274
|
+
render: /* @__PURE__ */ jsxs(
|
|
275
|
+
StyledInput,
|
|
276
|
+
{
|
|
277
|
+
...inputProps,
|
|
278
|
+
value: searchValue,
|
|
279
|
+
size,
|
|
280
|
+
ref: inputRef,
|
|
281
|
+
onChange: onInputChange,
|
|
282
|
+
onFocus: scrollIntoView,
|
|
283
|
+
children: [
|
|
284
|
+
children,
|
|
285
|
+
/* @__PURE__ */ jsx(
|
|
286
|
+
TriggerActionButton,
|
|
287
|
+
{
|
|
288
|
+
openActionLabel,
|
|
289
|
+
closeActionLabel,
|
|
290
|
+
clearActionLabel,
|
|
291
|
+
size
|
|
292
|
+
}
|
|
293
|
+
)
|
|
294
|
+
]
|
|
295
|
+
}
|
|
296
|
+
)
|
|
255
297
|
}
|
|
256
298
|
)
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
299
|
+
]
|
|
300
|
+
}
|
|
301
|
+
);
|
|
260
302
|
}
|
|
261
303
|
);
|
|
262
304
|
|
|
305
|
+
const NoResultPlaceholder = styled(Primitive.div, {
|
|
306
|
+
padding: "$100"
|
|
307
|
+
});
|
|
263
308
|
const StyledContent = styled(RadixPopover.Content, {
|
|
264
309
|
backgroundColor: "$background-neutrals-container",
|
|
265
310
|
borderRadius: "$50",
|
|
266
311
|
boxShadow: "$50",
|
|
267
312
|
fontSize: "$175",
|
|
268
313
|
fontWeight: "normal",
|
|
269
|
-
lineHeight: "
|
|
314
|
+
lineHeight: "20px",
|
|
270
315
|
width: "var(--radix-popover-trigger-width)",
|
|
271
316
|
zIndex: "$select",
|
|
272
317
|
overflowY: "auto",
|
|
273
|
-
padding: "$
|
|
318
|
+
padding: "$50",
|
|
274
319
|
boxSizing: "border-box",
|
|
275
320
|
outline: "1px solid transparent"
|
|
276
321
|
});
|
|
277
322
|
|
|
278
323
|
const StyledItemCheck = styled(Primitive.span, {
|
|
279
|
-
color: "$icon-primary"
|
|
280
|
-
paddingX: "$100"
|
|
324
|
+
color: "$icon-primary"
|
|
281
325
|
});
|
|
282
326
|
const StyledItem = styled(ComboboxItem, {
|
|
283
|
-
display: "
|
|
284
|
-
|
|
285
|
-
justifyContent: "space-between",
|
|
286
|
-
gap: "$200",
|
|
327
|
+
display: "grid",
|
|
328
|
+
gridTemplateColumns: "20px 1fr",
|
|
287
329
|
borderRadius: "$50",
|
|
288
330
|
boxSizing: "border-box",
|
|
289
331
|
color: "$text-neutrals",
|
|
290
332
|
cursor: "pointer",
|
|
291
333
|
fontSize: "$175",
|
|
292
|
-
lineHeight:
|
|
334
|
+
lineHeight: "20px",
|
|
293
335
|
position: "relative",
|
|
294
336
|
userSelect: "none",
|
|
295
|
-
|
|
296
|
-
paddingY: "10px",
|
|
337
|
+
padding: "6px $100 6px $150",
|
|
297
338
|
...focus.css({
|
|
298
339
|
boxShadow: "$focus-small"
|
|
299
340
|
}),
|
|
@@ -308,7 +349,13 @@ const StyledItem = styled(ComboboxItem, {
|
|
|
308
349
|
},
|
|
309
350
|
"&:disabled, &[aria-disabled=true], &[data-disabled]": {
|
|
310
351
|
cursor: "default",
|
|
311
|
-
color: "$text-neutrals-disabled"
|
|
352
|
+
color: "$text-neutrals-disabled",
|
|
353
|
+
["".concat(StyledItemCheck)]: {
|
|
354
|
+
color: "$icon-neutrals-disabled"
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
'&[aria-selected="true"]:not(:disabled,[aria-disabled=true],[data-disabled])': {
|
|
358
|
+
color: "$text-primary-selected"
|
|
312
359
|
}
|
|
313
360
|
});
|
|
314
361
|
|
|
@@ -335,13 +382,13 @@ const Item = React.forwardRef(
|
|
|
335
382
|
{
|
|
336
383
|
...mergeProps(restProps, restAriaDisabledProps),
|
|
337
384
|
focusable: true,
|
|
338
|
-
|
|
339
|
-
|
|
385
|
+
hideOnClick: false,
|
|
386
|
+
accessibleWhenDisabled: booleanify(ariaDisabled),
|
|
387
|
+
disabled: booleanify(ariaDisabled) || disabled,
|
|
340
388
|
ref: forwardRef,
|
|
341
389
|
value,
|
|
342
390
|
onClick: scrollIntoView,
|
|
343
391
|
children: [
|
|
344
|
-
children,
|
|
345
392
|
/* @__PURE__ */ jsx(
|
|
346
393
|
ComboboxItemCheck,
|
|
347
394
|
{
|
|
@@ -357,7 +404,8 @@ const Item = React.forwardRef(
|
|
|
357
404
|
}
|
|
358
405
|
)
|
|
359
406
|
}
|
|
360
|
-
)
|
|
407
|
+
),
|
|
408
|
+
children
|
|
361
409
|
]
|
|
362
410
|
}
|
|
363
411
|
);
|
|
@@ -392,7 +440,13 @@ const isInsideRef = (element, ref) => {
|
|
|
392
440
|
return (_b = element != null && ((_a = ref.current) == null ? void 0 : _a.contains(element))) != null ? _b : false;
|
|
393
441
|
};
|
|
394
442
|
const Content = React.forwardRef(
|
|
395
|
-
({
|
|
443
|
+
({
|
|
444
|
+
sideOffset = CONTENT_OFFSET,
|
|
445
|
+
maxHeight,
|
|
446
|
+
overflow,
|
|
447
|
+
children,
|
|
448
|
+
...restProps
|
|
449
|
+
}, forwardRef) => {
|
|
396
450
|
const {
|
|
397
451
|
triggerRef,
|
|
398
452
|
contentRef,
|
|
@@ -413,11 +467,13 @@ const Content = React.forwardRef(
|
|
|
413
467
|
)
|
|
414
468
|
);
|
|
415
469
|
}, [children, autoFilter, setFilteredItems, searchValue]);
|
|
416
|
-
const content = filteredItems.size === 0 ? noResultsText : children;
|
|
470
|
+
const content = filteredItems.size === 0 ? /* @__PURE__ */ jsx(NoResultPlaceholder, { children: noResultsText }) : children;
|
|
417
471
|
return /* @__PURE__ */ jsx(
|
|
418
472
|
StyledContent,
|
|
419
473
|
{
|
|
474
|
+
asChild: true,
|
|
420
475
|
...restProps,
|
|
476
|
+
dir: direction,
|
|
421
477
|
sideOffset,
|
|
422
478
|
ref: mergeRefs([forwardRef, contentRef]),
|
|
423
479
|
onOpenAutoFocus: (event) => event.preventDefault(),
|
|
@@ -429,18 +485,18 @@ const Content = React.forwardRef(
|
|
|
429
485
|
event.preventDefault();
|
|
430
486
|
}
|
|
431
487
|
},
|
|
432
|
-
children: /* @__PURE__ */ jsxs(ScrollArea, { type: "always", dir: direction, children: [
|
|
488
|
+
children: /* @__PURE__ */ jsx(ComboboxList, { role: "listbox", children: overflow === "auto" ? /* @__PURE__ */ jsxs(ScrollArea, { type: "always", dir: direction, children: [
|
|
433
489
|
/* @__PURE__ */ jsx(
|
|
434
490
|
ScrollArea.Viewport,
|
|
435
491
|
{
|
|
436
492
|
availableHeight: "var(--radix-popover-content-available-height)",
|
|
437
|
-
verticalGap: "
|
|
493
|
+
verticalGap: "var(--space-50) * 2",
|
|
438
494
|
maxHeight,
|
|
439
495
|
children: content
|
|
440
496
|
}
|
|
441
497
|
),
|
|
442
498
|
/* @__PURE__ */ jsx(ScrollArea.Scrollbar, { orientation: "vertical", children: /* @__PURE__ */ jsx(ScrollArea.Thumb, {}) })
|
|
443
|
-
] })
|
|
499
|
+
] }) : content })
|
|
444
500
|
}
|
|
445
501
|
);
|
|
446
502
|
}
|
|
@@ -448,6 +504,8 @@ const Content = React.forwardRef(
|
|
|
448
504
|
|
|
449
505
|
const Portal = (props) => /* @__PURE__ */ jsx(Portal$1, { ...props });
|
|
450
506
|
|
|
507
|
+
const StyledGroup = styled(Group$1);
|
|
508
|
+
|
|
451
509
|
const Group = React.forwardRef(({ children, ...rest }, forwardRef) => {
|
|
452
510
|
const { autoFilter, filteredItems } = useComboboxContext();
|
|
453
511
|
const childValues = useMemo(
|
|
@@ -465,15 +523,12 @@ const Group = React.forwardRef(({ children, ...rest }, forwardRef) => {
|
|
|
465
523
|
if (!hasVisibleChildren) {
|
|
466
524
|
return null;
|
|
467
525
|
}
|
|
468
|
-
return /* @__PURE__ */ jsx(
|
|
526
|
+
return /* @__PURE__ */ jsx(StyledGroup, { ...rest, ref: forwardRef, children });
|
|
469
527
|
});
|
|
470
528
|
|
|
471
529
|
const StyledGroupLabel = styled(GroupLabel$1, {
|
|
472
|
-
padding: "$100",
|
|
473
|
-
color: "$text-neutrals-subtle"
|
|
474
|
-
fontSize: "$150",
|
|
475
|
-
textTransform: "uppercase",
|
|
476
|
-
fontWeight: 650
|
|
530
|
+
padding: "6px $100",
|
|
531
|
+
color: "$text-neutrals-subtle"
|
|
477
532
|
});
|
|
478
533
|
|
|
479
534
|
const GroupLabel = React.forwardRef((props, forwardRef) => /* @__PURE__ */ jsx(StyledGroupLabel, { ...props, ref: forwardRef }));
|
|
@@ -487,13 +542,13 @@ const StyledChip = styled(Primitive.div, {
|
|
|
487
542
|
gap: "$50",
|
|
488
543
|
whiteSpace: "nowrap",
|
|
489
544
|
maxWidth: "$35",
|
|
490
|
-
|
|
491
|
-
color: "$
|
|
545
|
+
backgroundColor: "$background-neutrals-subtle",
|
|
546
|
+
color: "$text-neutrals"
|
|
492
547
|
});
|
|
493
548
|
const StyledChipButton = styled(BaseButton, {
|
|
549
|
+
color: "$icon-neutrals-inactive",
|
|
494
550
|
...focus.css({
|
|
495
|
-
boxShadow: "$focus-small-outline"
|
|
496
|
-
borderColor: "$blue-400 !important"
|
|
551
|
+
boxShadow: "$focus-small-outline"
|
|
497
552
|
})
|
|
498
553
|
});
|
|
499
554
|
const StyledChipContent = styled(Primitive.div, {
|
|
@@ -511,9 +566,9 @@ const StyledLeftSlot = styled(Primitive.span, {
|
|
|
511
566
|
const LeftSlot = StyledLeftSlot;
|
|
512
567
|
|
|
513
568
|
const Chip = React.forwardRef(
|
|
514
|
-
({ children, disabled = false, onRemove,
|
|
569
|
+
({ children, disabled = false, onRemove, removeAriaLabel, ...restProps }, forwardRef) => /* @__PURE__ */ jsxs(StyledChip, { ...restProps, ref: forwardRef, children: [
|
|
515
570
|
/* @__PURE__ */ jsx(StyledChipContent, { children }),
|
|
516
|
-
!booleanify(disabled) && /* @__PURE__ */ jsx(StyledChipButton, { onClick: onRemove, "aria-label":
|
|
571
|
+
!booleanify(disabled) && /* @__PURE__ */ jsx(StyledChipButton, { onClick: onRemove, "aria-label": removeAriaLabel, children: /* @__PURE__ */ jsx(IconCross, { size: "small", weight: "thin", "aria-hidden": true }) })
|
|
517
572
|
] })
|
|
518
573
|
);
|
|
519
574
|
Chip.LeftSlot = LeftSlot;
|
|
@@ -522,7 +577,7 @@ const StyledValue = styled(Chip, {
|
|
|
522
577
|
marginTop: "$50"
|
|
523
578
|
});
|
|
524
579
|
|
|
525
|
-
const Value = ({
|
|
580
|
+
const Value = ({ unselectAriaLabel }) => {
|
|
526
581
|
const {
|
|
527
582
|
value = [],
|
|
528
583
|
setValue,
|
|
@@ -541,7 +596,7 @@ const Value = ({ removeChipAriaLabel }) => {
|
|
|
541
596
|
{
|
|
542
597
|
onRemove: () => onItemRemove(item),
|
|
543
598
|
disabled: isDisabled,
|
|
544
|
-
|
|
599
|
+
removeAriaLabel: "".concat(unselectAriaLabel, " ").concat(item),
|
|
545
600
|
"data-testid": process.env.NODE_ENV === "test" ? "combobox-value-".concat(item) : void 0,
|
|
546
601
|
children: item
|
|
547
602
|
},
|
|
@@ -564,12 +619,11 @@ const Separator = React.forwardRef((props, forwardRef) => {
|
|
|
564
619
|
return /* @__PURE__ */ jsx(StyledSeparator, { ...props, ref: forwardRef, "aria-hidden": true });
|
|
565
620
|
});
|
|
566
621
|
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
const Root = React.forwardRef(({ value: valueProp, onValueChange, children, ...restProps }, forwardRef) => {
|
|
622
|
+
const Root = ({
|
|
623
|
+
value: valueProp,
|
|
624
|
+
children,
|
|
625
|
+
...restProps
|
|
626
|
+
}) => {
|
|
573
627
|
const {
|
|
574
628
|
openState,
|
|
575
629
|
setOpenState,
|
|
@@ -579,8 +633,7 @@ const Root = React.forwardRef(({ value: valueProp, onValueChange, children, ...r
|
|
|
579
633
|
required,
|
|
580
634
|
readOnly,
|
|
581
635
|
"aria-disabled": ariaDisabled,
|
|
582
|
-
disabled
|
|
583
|
-
direction
|
|
636
|
+
disabled
|
|
584
637
|
} = useComboboxContext();
|
|
585
638
|
const { setRequired, setDisabled, setAriaDisabled, setReadOnly } = useFormFieldContext();
|
|
586
639
|
useEffect(() => {
|
|
@@ -601,78 +654,70 @@ const Root = React.forwardRef(({ value: valueProp, onValueChange, children, ...r
|
|
|
601
654
|
const onSetSelectedValue = (newValue) => {
|
|
602
655
|
setValue(typeof newValue === "string" ? [newValue] : newValue);
|
|
603
656
|
};
|
|
604
|
-
const
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
if (!booleanify(disabled)) {
|
|
608
|
-
setOpenState(true);
|
|
609
|
-
}
|
|
610
|
-
if (restProps.onClick !== void 0) {
|
|
611
|
-
restProps.onClick(event);
|
|
612
|
-
}
|
|
657
|
+
const onOpenChange = (value2) => {
|
|
658
|
+
if (!booleanify(readOnly)) {
|
|
659
|
+
setOpenState(value2);
|
|
613
660
|
}
|
|
614
661
|
};
|
|
615
|
-
return /* @__PURE__ */ jsx(
|
|
616
|
-
|
|
662
|
+
return /* @__PURE__ */ jsx(
|
|
663
|
+
RadixPopover.Root,
|
|
617
664
|
{
|
|
618
665
|
open: openState,
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
selectedValue: value,
|
|
622
|
-
setSelectedValue: onSetSelectedValue,
|
|
666
|
+
onOpenChange,
|
|
667
|
+
...restProps,
|
|
623
668
|
children: /* @__PURE__ */ jsx(
|
|
624
|
-
|
|
669
|
+
ComboboxProvider$1,
|
|
625
670
|
{
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
671
|
+
open: openState,
|
|
672
|
+
setOpen: onOpenChange,
|
|
673
|
+
defaultSelectedValue: defaultValue,
|
|
674
|
+
selectedValue: value,
|
|
675
|
+
setSelectedValue: onSetSelectedValue,
|
|
629
676
|
children
|
|
630
677
|
}
|
|
631
678
|
)
|
|
632
679
|
}
|
|
633
|
-
)
|
|
634
|
-
}
|
|
635
|
-
const Combobox =
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
680
|
+
);
|
|
681
|
+
};
|
|
682
|
+
const Combobox = ({
|
|
683
|
+
"aria-disabled": ariaDisabled,
|
|
684
|
+
defaultOpen = false,
|
|
685
|
+
open,
|
|
686
|
+
valid,
|
|
687
|
+
disabled,
|
|
688
|
+
readOnly,
|
|
689
|
+
required,
|
|
690
|
+
value,
|
|
691
|
+
defaultValue,
|
|
692
|
+
onOpen,
|
|
693
|
+
onClose,
|
|
694
|
+
onSearchValueChange,
|
|
695
|
+
onValueChange,
|
|
696
|
+
direction = "ltr",
|
|
697
|
+
autoFilter = true,
|
|
698
|
+
noResultsText,
|
|
699
|
+
...restProps
|
|
700
|
+
}) => /* @__PURE__ */ jsx(
|
|
701
|
+
ComboboxProvider,
|
|
702
|
+
{
|
|
703
|
+
defaultValue,
|
|
704
|
+
value,
|
|
705
|
+
onValueChange,
|
|
706
|
+
onSearchValueChange,
|
|
707
|
+
defaultOpen,
|
|
639
708
|
open,
|
|
709
|
+
onOpen,
|
|
710
|
+
onClose,
|
|
640
711
|
valid,
|
|
712
|
+
required,
|
|
641
713
|
disabled,
|
|
642
714
|
readOnly,
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
onOpen,
|
|
647
|
-
onClose,
|
|
648
|
-
onSearchValueChange,
|
|
649
|
-
onValueChange,
|
|
650
|
-
direction = "ltr",
|
|
651
|
-
autoFilter = true,
|
|
715
|
+
"aria-disabled": ariaDisabled,
|
|
716
|
+
direction,
|
|
717
|
+
autoFilter,
|
|
652
718
|
noResultsText,
|
|
653
|
-
...restProps
|
|
654
|
-
}
|
|
655
|
-
ComboboxProvider,
|
|
656
|
-
{
|
|
657
|
-
defaultValue,
|
|
658
|
-
value,
|
|
659
|
-
onValueChange,
|
|
660
|
-
onSearchValueChange,
|
|
661
|
-
defaultOpen,
|
|
662
|
-
open,
|
|
663
|
-
onOpen,
|
|
664
|
-
onClose,
|
|
665
|
-
valid,
|
|
666
|
-
required,
|
|
667
|
-
disabled,
|
|
668
|
-
readOnly,
|
|
669
|
-
"aria-disabled": ariaDisabled,
|
|
670
|
-
direction,
|
|
671
|
-
autoFilter,
|
|
672
|
-
noResultsText,
|
|
673
|
-
children: /* @__PURE__ */ jsx(Root, { ...restProps, value, ref: forwardRef })
|
|
674
|
-
}
|
|
675
|
-
)
|
|
719
|
+
children: /* @__PURE__ */ jsx(Root, { ...restProps, value })
|
|
720
|
+
}
|
|
676
721
|
);
|
|
677
722
|
Combobox.Portal = Portal;
|
|
678
723
|
Combobox.Trigger = Trigger;
|