@mirohq/design-system-combobox 0.1.0-combobox.6 → 0.1.0-combobox.7

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 CHANGED
@@ -6,8 +6,8 @@ var jsxRuntime = require('react/jsx-runtime');
6
6
  var React = require('react');
7
7
  var react = require('@ariakit/react');
8
8
  var designSystemBaseForm = require('@mirohq/design-system-base-form');
9
- var designSystemUtils = require('@mirohq/design-system-utils');
10
9
  var RadixPopover = require('@radix-ui/react-popover');
10
+ var designSystemUtils = require('@mirohq/design-system-utils');
11
11
  var designSystemStitches = require('@mirohq/design-system-stitches');
12
12
  var designSystemInput = require('@mirohq/design-system-input');
13
13
  var reactUseControllableState = require('@radix-ui/react-use-controllable-state');
@@ -42,6 +42,10 @@ function _interopNamespace(e) {
42
42
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
43
43
  var RadixPopover__namespace = /*#__PURE__*/_interopNamespace(RadixPopover);
44
44
 
45
+ const StyledAnchor = designSystemStitches.styled(RadixPopover.Anchor, {
46
+ position: "relative",
47
+ width: "100%"
48
+ });
45
49
  const StyledInput = designSystemStitches.styled(designSystemInput.Input, {
46
50
  flexWrap: "wrap",
47
51
  flexGrow: 1,
@@ -195,6 +199,7 @@ const Trigger = React__default["default"].forwardRef(
195
199
  openActionLabel,
196
200
  clearActionLabel,
197
201
  onChange,
202
+ css,
198
203
  ...restProps
199
204
  }, forwardRef) => {
200
205
  const {
@@ -202,11 +207,13 @@ const Trigger = React__default["default"].forwardRef(
202
207
  valid: comboboxValid,
203
208
  disabled,
204
209
  value = [],
210
+ readOnly,
205
211
  triggerRef,
206
212
  inputRef,
207
213
  onSearchValueChange,
208
214
  searchValue,
209
- setSearchValue
215
+ setSearchValue,
216
+ setOpenState
210
217
  } = useComboboxContext();
211
218
  const {
212
219
  formElementId,
@@ -228,12 +235,13 @@ const Trigger = React__default["default"].forwardRef(
228
235
  ),
229
236
  valid,
230
237
  disabled,
238
+ readOnly,
231
239
  invalid: designSystemUtils.booleanishAttrValue(valid),
232
240
  id: id != null ? id : formElementId,
233
241
  placeholder: value.length === 0 ? placeholder : void 0
234
242
  };
235
243
  const shouldUseFloatingLabel = label !== null && isFloatingLabel;
236
- const isFloating = placeholder !== void 0 || value.length !== 0 || focused;
244
+ const isFloating = placeholder !== void 0 || value.length !== 0 || focused || searchValue !== "";
237
245
  const scrollIntoView = (event) => {
238
246
  var _a;
239
247
  const trigger = triggerRef == null ? void 0 : triggerRef.current;
@@ -253,36 +261,48 @@ const Trigger = React__default["default"].forwardRef(
253
261
  onSearchValueChange == null ? void 0 : onSearchValueChange(e.target.value);
254
262
  onChange == null ? void 0 : onChange(e);
255
263
  };
256
- return /* @__PURE__ */ jsxRuntime.jsxs(RadixPopover__namespace.Anchor, { ref: designSystemUtils.mergeRefs([triggerRef, forwardRef]), children: [
257
- shouldUseFloatingLabel && /* @__PURE__ */ jsxRuntime.jsx(designSystemBaseForm.FloatingLabel, { floating: isFloating, size, children: label }),
258
- /* @__PURE__ */ jsxRuntime.jsx(
259
- react.Combobox,
260
- {
261
- render: /* @__PURE__ */ jsxRuntime.jsxs(
262
- StyledInput,
264
+ return /* @__PURE__ */ jsxRuntime.jsxs(
265
+ StyledAnchor,
266
+ {
267
+ ref: designSystemUtils.mergeRefs([triggerRef, forwardRef]),
268
+ css,
269
+ onClick: () => {
270
+ if (!designSystemUtils.booleanify(disabled) && !designSystemUtils.booleanify(ariaDisabled) && !designSystemUtils.booleanify(readOnly)) {
271
+ setOpenState(true);
272
+ }
273
+ },
274
+ children: [
275
+ shouldUseFloatingLabel && /* @__PURE__ */ jsxRuntime.jsx(designSystemBaseForm.FloatingLabel, { floating: isFloating, size, children: label }),
276
+ /* @__PURE__ */ jsxRuntime.jsx(
277
+ react.Combobox,
263
278
  {
264
- ...inputProps,
265
- value: searchValue,
266
- size,
267
- ref: inputRef,
268
- onChange: onInputChange,
269
- onFocus: scrollIntoView,
270
- children: [
271
- children,
272
- /* @__PURE__ */ jsxRuntime.jsx(
273
- TriggerActionButton,
274
- {
275
- openActionLabel,
276
- clearActionLabel,
277
- size
278
- }
279
- )
280
- ]
279
+ render: /* @__PURE__ */ jsxRuntime.jsxs(
280
+ StyledInput,
281
+ {
282
+ ...inputProps,
283
+ value: searchValue,
284
+ size,
285
+ ref: inputRef,
286
+ onChange: onInputChange,
287
+ onFocus: scrollIntoView,
288
+ children: [
289
+ children,
290
+ /* @__PURE__ */ jsxRuntime.jsx(
291
+ TriggerActionButton,
292
+ {
293
+ openActionLabel,
294
+ clearActionLabel,
295
+ size
296
+ }
297
+ )
298
+ ]
299
+ }
300
+ )
281
301
  }
282
302
  )
283
- }
284
- )
285
- ] });
303
+ ]
304
+ }
305
+ );
286
306
  }
287
307
  );
288
308
 
@@ -292,34 +312,30 @@ const StyledContent = designSystemStitches.styled(RadixPopover__namespace.Conten
292
312
  boxShadow: "$50",
293
313
  fontSize: "$175",
294
314
  fontWeight: "normal",
295
- lineHeight: "1.5",
315
+ lineHeight: "20px",
296
316
  width: "var(--radix-popover-trigger-width)",
297
317
  zIndex: "$select",
298
318
  overflowY: "auto",
299
- padding: "$150",
319
+ padding: "$50",
300
320
  boxSizing: "border-box",
301
321
  outline: "1px solid transparent"
302
322
  });
303
323
 
304
324
  const StyledItemCheck = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
305
- color: "$icon-primary",
306
- paddingX: "$100"
325
+ color: "$icon-primary"
307
326
  });
308
327
  const StyledItem = designSystemStitches.styled(react.ComboboxItem, {
309
- display: "flex",
310
- alignItems: "center",
311
- justifyContent: "space-between",
312
- gap: "$200",
328
+ display: "grid",
329
+ gridTemplateColumns: "20px 1fr",
313
330
  borderRadius: "$50",
314
331
  boxSizing: "border-box",
315
332
  color: "$text-neutrals",
316
333
  cursor: "pointer",
317
334
  fontSize: "$175",
318
- lineHeight: 1.5,
335
+ lineHeight: "20px",
319
336
  position: "relative",
320
337
  userSelect: "none",
321
- paddingX: "$100",
322
- paddingY: "10px",
338
+ padding: "6px $100 6px $150",
323
339
  ...designSystemStyles.focus.css({
324
340
  boxShadow: "$focus-small"
325
341
  }),
@@ -334,7 +350,13 @@ const StyledItem = designSystemStitches.styled(react.ComboboxItem, {
334
350
  },
335
351
  "&:disabled, &[aria-disabled=true], &[data-disabled]": {
336
352
  cursor: "default",
337
- color: "$text-neutrals-disabled"
353
+ color: "$text-neutrals-disabled",
354
+ ["".concat(StyledItemCheck)]: {
355
+ color: "$icon-neutrals-disabled"
356
+ }
357
+ },
358
+ '&[aria-selected="true"]:not(:disabled,[aria-disabled=true],[data-disabled])': {
359
+ color: "$text-primary-selected"
338
360
  }
339
361
  });
340
362
 
@@ -361,13 +383,13 @@ const Item = React__default["default"].forwardRef(
361
383
  {
362
384
  ...utils.mergeProps(restProps, restAriaDisabledProps),
363
385
  focusable: true,
364
- accessibleWhenDisabled: ariaDisabled === true,
365
- disabled: ariaDisabled === true || disabled,
386
+ hideOnClick: false,
387
+ accessibleWhenDisabled: designSystemUtils.booleanify(ariaDisabled),
388
+ disabled: designSystemUtils.booleanify(ariaDisabled) || disabled,
366
389
  ref: forwardRef,
367
390
  value,
368
391
  onClick: scrollIntoView,
369
392
  children: [
370
- children,
371
393
  /* @__PURE__ */ jsxRuntime.jsx(
372
394
  react.ComboboxItemCheck,
373
395
  {
@@ -383,7 +405,8 @@ const Item = React__default["default"].forwardRef(
383
405
  }
384
406
  )
385
407
  }
386
- )
408
+ ),
409
+ children
387
410
  ]
388
411
  }
389
412
  );
@@ -460,7 +483,7 @@ const Content = React__default["default"].forwardRef(
460
483
  designSystemScrollArea.ScrollArea.Viewport,
461
484
  {
462
485
  availableHeight: "var(--radix-popover-content-available-height)",
463
- verticalGap: "calc(var(--space-150) * 2)",
486
+ verticalGap: "var(--space-50) * 2",
464
487
  maxHeight,
465
488
  children: content
466
489
  }
@@ -495,11 +518,8 @@ const Group = React__default["default"].forwardRef(({ children, ...rest }, forwa
495
518
  });
496
519
 
497
520
  const StyledGroupLabel = designSystemStitches.styled(react.GroupLabel, {
498
- padding: "$100",
499
- color: "$text-neutrals-subtle",
500
- fontSize: "$150",
501
- textTransform: "uppercase",
502
- fontWeight: 650
521
+ padding: "6px $100",
522
+ color: "$text-neutrals-subtle"
503
523
  });
504
524
 
505
525
  const GroupLabel = React__default["default"].forwardRef((props, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(StyledGroupLabel, { ...props, ref: forwardRef }));
@@ -590,12 +610,11 @@ const Separator = React__default["default"].forwardRef((props, forwardRef) => {
590
610
  return /* @__PURE__ */ jsxRuntime.jsx(StyledSeparator, { ...props, ref: forwardRef, "aria-hidden": true });
591
611
  });
592
612
 
593
- const StyledComboboxContent = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
594
- position: "relative",
595
- width: "100%"
596
- });
597
-
598
- const Root = React__default["default"].forwardRef(({ value: valueProp, onValueChange, children, ...restProps }, forwardRef) => {
613
+ const Root = ({
614
+ value: valueProp,
615
+ children,
616
+ ...restProps
617
+ }) => {
599
618
  const {
600
619
  openState,
601
620
  setOpenState,
@@ -605,8 +624,7 @@ const Root = React__default["default"].forwardRef(({ value: valueProp, onValueCh
605
624
  required,
606
625
  readOnly,
607
626
  "aria-disabled": ariaDisabled,
608
- disabled,
609
- direction
627
+ disabled
610
628
  } = useComboboxContext();
611
629
  const { setRequired, setDisabled, setAriaDisabled, setReadOnly } = designSystemBaseForm.useFormFieldContext();
612
630
  React.useEffect(() => {
@@ -627,78 +645,70 @@ const Root = React__default["default"].forwardRef(({ value: valueProp, onValueCh
627
645
  const onSetSelectedValue = (newValue) => {
628
646
  setValue(typeof newValue === "string" ? [newValue] : newValue);
629
647
  };
630
- const comboboxProps = {
631
- ...restProps,
632
- onClick: (event) => {
633
- if (!designSystemUtils.booleanify(disabled)) {
634
- setOpenState(true);
635
- }
636
- if (restProps.onClick !== void 0) {
637
- restProps.onClick(event);
638
- }
648
+ const onOpenChange = (value2) => {
649
+ if (!designSystemUtils.booleanify(readOnly)) {
650
+ setOpenState(value2);
639
651
  }
640
652
  };
641
- return /* @__PURE__ */ jsxRuntime.jsx(RadixPopover__namespace.Root, { open: openState, onOpenChange: setOpenState, children: /* @__PURE__ */ jsxRuntime.jsx(
642
- react.ComboboxProvider,
653
+ return /* @__PURE__ */ jsxRuntime.jsx(
654
+ RadixPopover__namespace.Root,
643
655
  {
644
656
  open: openState,
645
- setOpen: setOpenState,
646
- defaultSelectedValue: defaultValue,
647
- selectedValue: value,
648
- setSelectedValue: onSetSelectedValue,
657
+ onOpenChange,
658
+ ...restProps,
649
659
  children: /* @__PURE__ */ jsxRuntime.jsx(
650
- StyledComboboxContent,
660
+ react.ComboboxProvider,
651
661
  {
652
- ...comboboxProps,
653
- ref: forwardRef,
654
- dir: direction,
662
+ open: openState,
663
+ setOpen: onOpenChange,
664
+ defaultSelectedValue: defaultValue,
665
+ selectedValue: value,
666
+ setSelectedValue: onSetSelectedValue,
655
667
  children
656
668
  }
657
669
  )
658
670
  }
659
- ) });
660
- });
661
- const Combobox = React__default["default"].forwardRef(
662
- ({
663
- "aria-disabled": ariaDisabled,
664
- defaultOpen = false,
671
+ );
672
+ };
673
+ const Combobox = ({
674
+ "aria-disabled": ariaDisabled,
675
+ defaultOpen = false,
676
+ open,
677
+ valid,
678
+ disabled,
679
+ readOnly,
680
+ required,
681
+ value,
682
+ defaultValue,
683
+ onOpen,
684
+ onClose,
685
+ onSearchValueChange,
686
+ onValueChange,
687
+ direction = "ltr",
688
+ autoFilter = true,
689
+ noResultsText,
690
+ ...restProps
691
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
692
+ ComboboxProvider,
693
+ {
694
+ defaultValue,
695
+ value,
696
+ onValueChange,
697
+ onSearchValueChange,
698
+ defaultOpen,
665
699
  open,
700
+ onOpen,
701
+ onClose,
666
702
  valid,
703
+ required,
667
704
  disabled,
668
705
  readOnly,
669
- required,
670
- value,
671
- defaultValue,
672
- onOpen,
673
- onClose,
674
- onSearchValueChange,
675
- onValueChange,
676
- direction = "ltr",
677
- autoFilter = true,
706
+ "aria-disabled": ariaDisabled,
707
+ direction,
708
+ autoFilter,
678
709
  noResultsText,
679
- ...restProps
680
- }, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(
681
- ComboboxProvider,
682
- {
683
- defaultValue,
684
- value,
685
- onValueChange,
686
- onSearchValueChange,
687
- defaultOpen,
688
- open,
689
- onOpen,
690
- onClose,
691
- valid,
692
- required,
693
- disabled,
694
- readOnly,
695
- "aria-disabled": ariaDisabled,
696
- direction,
697
- autoFilter,
698
- noResultsText,
699
- children: /* @__PURE__ */ jsxRuntime.jsx(Root, { ...restProps, value, ref: forwardRef })
700
- }
701
- )
710
+ children: /* @__PURE__ */ jsxRuntime.jsx(Root, { ...restProps, value })
711
+ }
702
712
  );
703
713
  Combobox.Portal = Portal;
704
714
  Combobox.Trigger = Trigger;