@mirohq/design-system-combobox 1.6.2 → 1.7.0-filter-chip.2

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
@@ -390,6 +390,12 @@ const StyledContent = designSystemStitches.styled(RadixPopover__namespace.Conten
390
390
  boxSizing: "border-box"
391
391
  });
392
392
 
393
+ const List = ({ children }) => (
394
+ // Role must be set explicitly; Radix Content can overwrite Ariakit's default.
395
+ /* @__PURE__ */ jsxRuntime.jsx(react.ComboboxList, { role: "listbox", children: /* @__PURE__ */ jsxRuntime.jsx(StyledItemsContainer, { children }) })
396
+ );
397
+ List.displayName = "Combobox.List";
398
+
393
399
  const useDocumentFragment = () => {
394
400
  const [fragment, setFragment] = React.useState();
395
401
  designSystemUseLayoutEffect.useLayoutEffect(() => {
@@ -412,6 +418,11 @@ const isInsideRef = (element, ref) => {
412
418
  var _a, _b;
413
419
  return (_b = element != null && ((_a = ref.current) == null ? void 0 : _a.contains(element))) != null ? _b : false;
414
420
  };
421
+ const isComboboxList = (child) => {
422
+ var _a;
423
+ return React.isValidElement(child) && ((_a = child.type) == null ? void 0 : _a.displayName) === "Combobox.List";
424
+ };
425
+ const hasComboboxList = (children) => React.Children.toArray(children).some(isComboboxList);
415
426
  const Content = React.forwardRef(
416
427
  ({
417
428
  side = "bottom",
@@ -434,7 +445,22 @@ const Content = React.forwardRef(
434
445
  if (!openState) {
435
446
  return getInvisibleContent(children);
436
447
  }
437
- const content = /* @__PURE__ */ jsxRuntime.jsx(StyledItemsContainer, { children });
448
+ const listContent = hasComboboxList(children) ? children : /* @__PURE__ */ jsxRuntime.jsx(List, { children });
449
+ let content = listContent;
450
+ if (overflow === "auto") {
451
+ content = /* @__PURE__ */ jsxRuntime.jsxs(designSystemScrollArea.ScrollArea, { type: "always", dir: direction, children: [
452
+ /* @__PURE__ */ jsxRuntime.jsx(
453
+ designSystemScrollArea.ScrollArea.Viewport,
454
+ {
455
+ css: {
456
+ maxHeight: maxHeight !== void 0 ? "min(".concat(RADIX_CONTENT_AVAILABLE_HEIGHT, ", ").concat(typeof maxHeight === "number" ? "".concat(maxHeight, "px") : maxHeight, ")") : RADIX_CONTENT_AVAILABLE_HEIGHT
457
+ },
458
+ children: listContent
459
+ }
460
+ ),
461
+ /* @__PURE__ */ jsxRuntime.jsx(designSystemScrollArea.ScrollArea.Scrollbar, { orientation: "vertical", children: /* @__PURE__ */ jsxRuntime.jsx(designSystemScrollArea.ScrollArea.Thumb, {}) })
462
+ ] });
463
+ }
438
464
  return /* @__PURE__ */ jsxRuntime.jsx(
439
465
  StyledContent,
440
466
  {
@@ -449,6 +475,7 @@ const Content = React.forwardRef(
449
475
  sticky,
450
476
  hideWhenDetached,
451
477
  onOpenAutoFocus: (event) => {
478
+ var _a;
452
479
  if (onOpenAutoFocus != null) {
453
480
  onOpenAutoFocus(event);
454
481
  return;
@@ -456,6 +483,13 @@ const Content = React.forwardRef(
456
483
  event == null ? void 0 : event.preventDefault();
457
484
  if (externalOpenedRef.current !== true) return;
458
485
  const baseElement = ariakitStore == null ? void 0 : ariakitStore.getState().baseElement;
486
+ if (!(baseElement instanceof HTMLInputElement)) {
487
+ const searchInput = (_a = contentRef.current) == null ? void 0 : _a.querySelector("input");
488
+ if (searchInput != null) {
489
+ searchInput.focus();
490
+ return;
491
+ }
492
+ }
459
493
  baseElement == null ? void 0 : baseElement.focus();
460
494
  },
461
495
  ref: designSystemUtils.mergeRefs([forwardRef, contentRef]),
@@ -467,18 +501,7 @@ const Content = React.forwardRef(
467
501
  event.preventDefault();
468
502
  }
469
503
  },
470
- children: /* @__PURE__ */ jsxRuntime.jsx(react.ComboboxList, { role: "listbox", children: overflow === "auto" ? /* @__PURE__ */ jsxRuntime.jsxs(designSystemScrollArea.ScrollArea, { type: "always", dir: direction, children: [
471
- /* @__PURE__ */ jsxRuntime.jsx(
472
- designSystemScrollArea.ScrollArea.Viewport,
473
- {
474
- css: {
475
- maxHeight: maxHeight !== void 0 ? "min(".concat(RADIX_CONTENT_AVAILABLE_HEIGHT, ", ").concat(typeof maxHeight === "number" ? "".concat(maxHeight, "px") : maxHeight, ")") : RADIX_CONTENT_AVAILABLE_HEIGHT
476
- },
477
- children: content
478
- }
479
- ),
480
- /* @__PURE__ */ jsxRuntime.jsx(designSystemScrollArea.ScrollArea.Scrollbar, { orientation: "vertical", children: /* @__PURE__ */ jsxRuntime.jsx(designSystemScrollArea.ScrollArea.Thumb, {}) })
481
- ] }) : content })
504
+ children: content
482
505
  }
483
506
  );
484
507
  }
@@ -645,6 +668,7 @@ const Value = ({
645
668
  return /* @__PURE__ */ jsxRuntime.jsx(
646
669
  designSystemChip.Chip,
647
670
  {
671
+ size: "small",
648
672
  disabled: isDisabled,
649
673
  onRemove: (e) => {
650
674
  onItemRemove(itemValue);
@@ -707,39 +731,71 @@ const StyledInputSearch = designSystemStitches.styled(designSystemInput.InputSea
707
731
  "&&": {
708
732
  border: "1px solid $border-neutrals",
709
733
  backgroundColor: "$background-control"
734
+ },
735
+ variants: {
736
+ // Lay selected chips (passed as children, typically `<Combobox.Value />`)
737
+ // out inside the field alongside the text input, matching the multiselect
738
+ // trigger. The leading magnifier is pulled ahead of the chips so the field
739
+ // still reads as a search.
740
+ inlineChips: {
741
+ true: {
742
+ "&&": {
743
+ flexWrap: "wrap",
744
+ height: "auto",
745
+ minHeight: "$10",
746
+ paddingBlock: "$50",
747
+ gap: "$50"
748
+ },
749
+ // The magnifier icon slot (the only direct child that wraps a bare svg)
750
+ // leads the field, before the chips.
751
+ "& > div:has(> svg)": {
752
+ order: -1
753
+ },
754
+ "& input": {
755
+ width: "auto",
756
+ flexGrow: 1,
757
+ flexBasis: "$8",
758
+ minWidth: "$8"
759
+ }
760
+ }
761
+ }
710
762
  }
711
763
  });
712
- const SearchInput = React.forwardRef((props, ref) => {
713
- const { setSearchValue, contentRef } = useComboboxContext();
714
- const handleSearchChange = React.useCallback(
715
- (event) => {
764
+ const SearchInput = React.forwardRef(
765
+ ({ children, onChange, onKeyDown, inlineChips = false, ...rest }, ref) => {
766
+ const { setSearchValue, contentRef } = useComboboxContext();
767
+ const handleSearchChange = React.useCallback(
768
+ (event) => {
769
+ setSearchValue(event.target.value);
770
+ onChange == null ? void 0 : onChange(event);
771
+ },
772
+ [onChange, setSearchValue]
773
+ );
774
+ const handleKeyDown = (event) => {
716
775
  var _a;
717
- setSearchValue(event.target.value);
718
- (_a = props.onChange) == null ? void 0 : _a.call(props, event);
719
- },
720
- [props, setSearchValue]
721
- );
722
- const handleKeyDown = (event) => {
723
- var _a, _b;
724
- if (event.key === "ArrowDown") {
725
- event.preventDefault();
726
- const firstItem = (_a = contentRef.current) == null ? void 0 : _a.querySelector(
727
- '[role="option"]:not([aria-disabled="true"])'
728
- );
729
- firstItem == null ? void 0 : firstItem.focus();
730
- }
731
- (_b = props.onKeyDown) == null ? void 0 : _b.call(props, event);
732
- };
733
- return /* @__PURE__ */ jsxRuntime.jsx(
734
- StyledInputSearch,
735
- {
736
- ...props,
737
- ref,
738
- onKeyDown: handleKeyDown,
739
- onChange: handleSearchChange
740
- }
741
- );
742
- });
776
+ if (event.key === "ArrowDown") {
777
+ event.preventDefault();
778
+ const firstItem = (_a = contentRef.current) == null ? void 0 : _a.querySelector(
779
+ '[role="option"]:not([aria-disabled="true"])'
780
+ );
781
+ firstItem == null ? void 0 : firstItem.focus();
782
+ }
783
+ onKeyDown == null ? void 0 : onKeyDown(event);
784
+ };
785
+ return /* @__PURE__ */ jsxRuntime.jsx(
786
+ StyledInputSearch,
787
+ {
788
+ ...rest,
789
+ ref,
790
+ inlineChips,
791
+ onKeyDown: handleKeyDown,
792
+ onChange: handleSearchChange,
793
+ children
794
+ }
795
+ );
796
+ }
797
+ );
798
+ SearchInput.displayName = "Combobox.SearchInput";
743
799
 
744
800
  const StyledCompositeItem = designSystemStitches.styled(react.CompositeItem, {
745
801
  ...designSystemBaseSelect.itemStyles,
@@ -749,7 +805,7 @@ const StyledCompositeItem = designSystemStitches.styled(react.CompositeItem, {
749
805
 
750
806
  const CompositeItem = ({
751
807
  asChild = true,
752
- role = "menuitem",
808
+ role,
753
809
  textValue,
754
810
  disabled = false,
755
811
  tabbable,
@@ -968,6 +1024,7 @@ Combobox.Portal = Portal;
968
1024
  Combobox.Trigger = Trigger;
969
1025
  Combobox.Input = Input;
970
1026
  Combobox.Content = Content;
1027
+ Combobox.List = List;
971
1028
  Combobox.Item = Item;
972
1029
  Combobox.CompositeItem = CompositeItem;
973
1030
  Combobox.Group = Group;