@mirohq/design-system-dropdown-menu 4.4.27 → 4.4.29

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
@@ -9,6 +9,7 @@ var designSystemBaseTooltip = require('@mirohq/design-system-base-tooltip');
9
9
  var designSystemUsePrevious = require('@mirohq/design-system-use-previous');
10
10
  var designSystemIcons = require('@mirohq/design-system-icons');
11
11
  var designSystemUtils = require('@mirohq/design-system-utils');
12
+ var designSystemExperiments = require('@mirohq/design-system-experiments');
12
13
  var designSystemPrimitive = require('@mirohq/design-system-primitive');
13
14
  var designSystemStitches = require('@mirohq/design-system-stitches');
14
15
  var designSystemStyles = require('@mirohq/design-system-styles');
@@ -43,7 +44,37 @@ function _interopNamespace(e) {
43
44
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
44
45
  var RadixDropdownMenu__namespace = /*#__PURE__*/_interopNamespace(RadixDropdownMenu);
45
46
 
46
- const ItemDescription = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
47
+ const Context$1 = React.createContext({
48
+ leftSlotMount: () => {
49
+ },
50
+ leftSlotDestroy: () => {
51
+ }
52
+ });
53
+ const ItemProvider = ({ children }) => {
54
+ const [hasSlot, setHasSlot] = React.useState(false);
55
+ const leftSlotMount = React.useCallback(() => {
56
+ setHasSlot(true);
57
+ }, []);
58
+ const leftSlotDestroy = React.useCallback(() => {
59
+ setHasSlot(false);
60
+ }, []);
61
+ const formattedChildren = hasSlot ? children : designSystemUtils.addPropsToChildren(children, () => true, {
62
+ "data-no-left-slot": ""
63
+ });
64
+ return /* @__PURE__ */ jsxRuntime.jsx(
65
+ Context$1.Provider,
66
+ {
67
+ value: {
68
+ leftSlotMount,
69
+ leftSlotDestroy
70
+ },
71
+ children: formattedChildren
72
+ }
73
+ );
74
+ };
75
+ const useItem = () => React.useContext(Context$1);
76
+
77
+ const StyledItemDescription = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
47
78
  display: "-webkit-box",
48
79
  width: "100%",
49
80
  WebkitBoxOrient: "vertical",
@@ -52,7 +83,33 @@ const ItemDescription = designSystemStitches.styled(designSystemPrimitive.Primit
52
83
  gridArea: "item-description",
53
84
  fontSize: "$150",
54
85
  lineHeight: 1.5,
55
- color: "$text-neutrals-subtle"
86
+ color: "$text-neutrals-subtle",
87
+ variants: {
88
+ v1: {
89
+ true: {
90
+ '&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled])': {
91
+ background: "$background-neutrals-hover",
92
+ color: "$text-neutrals-hover",
93
+ '&:not([aria-disabled="true"])': {
94
+ boxShadow: "none"
95
+ }
96
+ }
97
+ },
98
+ false: {
99
+ '&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled])': {
100
+ background: "$background-primary-subtle-hover",
101
+ color: "$text-primary-hover",
102
+ '&:not([aria-disabled="true"])': {
103
+ boxShadow: "none"
104
+ }
105
+ }
106
+ }
107
+ }
108
+ }
109
+ });
110
+ const ItemDescription = React__default["default"].forwardRef(({ ...props }, forwardRef) => {
111
+ const [v1] = designSystemExperiments.useNewDesignLanguage();
112
+ return /* @__PURE__ */ jsxRuntime.jsx(ItemProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(StyledItemDescription, { ...props, v1, ref: forwardRef }) });
56
113
  });
57
114
 
58
115
  const LeftSlot = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
@@ -74,6 +131,28 @@ const hoverStyles = {
74
131
  boxShadow: "none"
75
132
  }
76
133
  };
134
+ const itemVariantsDefaults = {
135
+ v1: {
136
+ true: {
137
+ '&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled])': {
138
+ background: "$background-neutrals-hover",
139
+ color: "$text-neutrals-hover",
140
+ '&:not([aria-disabled="true"])': {
141
+ boxShadow: "none"
142
+ }
143
+ }
144
+ },
145
+ false: {
146
+ '&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled])': {
147
+ background: "$background-primary-subtle-hover",
148
+ color: "$text-primary-hover",
149
+ '&:not([aria-disabled="true"])': {
150
+ boxShadow: "none"
151
+ }
152
+ }
153
+ }
154
+ }
155
+ };
77
156
  const itemDefaults = {
78
157
  all: "unset",
79
158
  boxSizing: "border-box",
@@ -100,7 +179,7 @@ const itemDefaults = {
100
179
  }),
101
180
  '&:disabled, &[aria-disabled="true"], &[data-disabled]': {
102
181
  cursor: "default",
103
- ["&, & ".concat(ItemDescription, ", & ").concat(designSystemBaseHotkey.Hotkey)]: {
182
+ ["&, & ".concat(StyledItemDescription, ", & ").concat(designSystemBaseHotkey.Hotkey)]: {
104
183
  color: "$text-neutrals-disabled"
105
184
  },
106
185
  ["& ".concat(StyledIllustrationSlot)]: {
@@ -110,7 +189,6 @@ const itemDefaults = {
110
189
  "&:disabled, &[data-disabled]": {
111
190
  pointerEvents: "none"
112
191
  },
113
- '&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled])': hoverStyles,
114
192
  '&:active:not([aria-disabled="true"])': {
115
193
  background: "$background-primary-subtle-active",
116
194
  boxShadow: "none",
@@ -139,6 +217,7 @@ const StyledCheckboxItem = designSystemStitches.styled(RadixDropdownMenu__namesp
139
217
  boxSizing: "border-box"
140
218
  },
141
219
  variants: {
220
+ ...itemVariantsDefaults,
142
221
  variant: {
143
222
  "solid-prominent": {
144
223
  ["".concat(StyledIndicator)]: {
@@ -183,7 +262,7 @@ const StyledCheckboxItem = designSystemStitches.styled(RadixDropdownMenu__namesp
183
262
  }
184
263
  });
185
264
 
186
- const Context$1 = React.createContext({
265
+ const Context = React.createContext({
187
266
  rightSlotMount: () => 0,
188
267
  rightSlotDestroy: () => {
189
268
  },
@@ -230,7 +309,7 @@ const ContentProvider = ({
230
309
  }
231
310
  });
232
311
  return /* @__PURE__ */ jsxRuntime.jsx(
233
- Context$1.Provider,
312
+ Context.Provider,
234
313
  {
235
314
  value: {
236
315
  rightSlotMount,
@@ -241,7 +320,7 @@ const ContentProvider = ({
241
320
  }
242
321
  );
243
322
  };
244
- const useContent = () => React.useContext(Context$1);
323
+ const useContent = () => React.useContext(Context);
245
324
 
246
325
  const StyledRightSlot = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
247
326
  display: "flex",
@@ -313,36 +392,6 @@ const useAriaDisabled = ({ onSelect, ...restProps }, { exceptions, closeOnSelect
313
392
  };
314
393
  };
315
394
 
316
- const Context = React.createContext({
317
- leftSlotMount: () => {
318
- },
319
- leftSlotDestroy: () => {
320
- }
321
- });
322
- const ItemProvider = ({ children }) => {
323
- const [hasSlot, setHasSlot] = React.useState(false);
324
- const leftSlotMount = React.useCallback(() => {
325
- setHasSlot(true);
326
- }, []);
327
- const leftSlotDestroy = React.useCallback(() => {
328
- setHasSlot(false);
329
- }, []);
330
- const formattedChildren = hasSlot ? children : designSystemUtils.addPropsToChildren(children, () => true, {
331
- "data-no-left-slot": ""
332
- });
333
- return /* @__PURE__ */ jsxRuntime.jsx(
334
- Context.Provider,
335
- {
336
- value: {
337
- leftSlotMount,
338
- leftSlotDestroy
339
- },
340
- children: formattedChildren
341
- }
342
- );
343
- };
344
- const useItem = () => React.useContext(Context);
345
-
346
395
  const CheckboxItem = React__default["default"].forwardRef(
347
396
  ({
348
397
  children,
@@ -358,6 +407,7 @@ const CheckboxItem = React__default["default"].forwardRef(
358
407
  const iconCss = { square: "100%", display: "block" };
359
408
  const isAriaDisabled = designSystemUtils.booleanify(ariaDisabled != null ? ariaDisabled : false);
360
409
  const disabledUnchecked = (disabled === true || isAriaDisabled) && checked === false;
410
+ const [v1] = designSystemExperiments.useNewDesignLanguage();
361
411
  return /* @__PURE__ */ jsxRuntime.jsx(ItemProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(
362
412
  StyledCheckboxItem,
363
413
  {
@@ -367,6 +417,7 @@ const CheckboxItem = React__default["default"].forwardRef(
367
417
  disabled,
368
418
  onCheckedChange: onChange,
369
419
  variant,
420
+ v1,
370
421
  children: [
371
422
  children,
372
423
  /* @__PURE__ */ jsxRuntime.jsx(RightSlot, { children: /* @__PURE__ */ jsxRuntime.jsxs(StyledIndicator, { children: [
@@ -394,8 +445,6 @@ const CONTENT_PADDING = {
394
445
  };
395
446
  const contentDefaults = {
396
447
  maxWidth: "$125",
397
- backgroundColor: "$background-neutrals-container",
398
- borderRadius: "$50",
399
448
  boxShadow: "$50",
400
449
  "@media (prefers-reduced-motion: no-preference)": {
401
450
  animationDuration: "150ms",
@@ -426,8 +475,22 @@ const contentDefaults = {
426
475
  },
427
476
  position: "relative",
428
477
  zIndex: "$dropdown-menu",
429
- outline: "1px solid transparent !important"
478
+ outline: "1px solid transparent !important",
430
479
  // important because Radix overrides outline in element styles
480
+ variants: {
481
+ v1: {
482
+ true: {
483
+ borderRadius: "$100",
484
+ backgroundColor: "$background-neutrals-layout",
485
+ border: ".5px solid $border-neutrals",
486
+ boxShadow: "0px 1px 8px 0px rgba(34, 36, 40, 0.05);"
487
+ },
488
+ false: {
489
+ borderRadius: "$50",
490
+ backgroundColor: "$background-neutrals-container"
491
+ }
492
+ }
493
+ }
431
494
  };
432
495
 
433
496
  const StyledItemsContainer = designSystemStitches.styled("div", {
@@ -526,6 +589,7 @@ const Content = React__default["default"].forwardRef(
526
589
  focusWithouAutoScroll._autoScrollPrevented = true;
527
590
  ref.focus = focusWithouAutoScroll;
528
591
  };
592
+ const [v1] = designSystemExperiments.useNewDesignLanguage();
529
593
  return /* @__PURE__ */ jsxRuntime.jsx(ContentProvider, { containerSpacing, children: /* @__PURE__ */ jsxRuntime.jsx(
530
594
  StyledContent,
531
595
  {
@@ -540,6 +604,7 @@ const Content = React__default["default"].forwardRef(
540
604
  collisionPadding,
541
605
  sticky,
542
606
  hideWhenDetached,
607
+ v1,
543
608
  children: /* @__PURE__ */ jsxRuntime.jsx(
544
609
  ScrollableContent,
545
610
  {
@@ -557,6 +622,7 @@ const Content = React__default["default"].forwardRef(
557
622
  const StyledItem = designSystemStitches.styled(RadixDropdownMenu__namespace.Item, {
558
623
  ...itemDefaults,
559
624
  variants: {
625
+ ...itemVariantsDefaults,
560
626
  // This is a hack for the :has() selector
561
627
  // Remove it after Firefox implements it
562
628
  hasRightSlot: {
@@ -583,12 +649,14 @@ const StyledItem = designSystemStitches.styled(RadixDropdownMenu__namespace.Item
583
649
  const Item = React__default["default"].forwardRef(
584
650
  ({ disabled = false, variant = "subtle", ...restProps }, forwardRef) => {
585
651
  const elementProps = useAriaDisabled(restProps);
652
+ const [v1] = designSystemExperiments.useNewDesignLanguage();
586
653
  return /* @__PURE__ */ jsxRuntime.jsx(ItemProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(
587
654
  StyledItem,
588
655
  {
589
656
  ...elementProps,
590
657
  variant,
591
658
  disabled,
659
+ v1,
592
660
  ref: forwardRef
593
661
  }
594
662
  ) });
@@ -645,7 +713,6 @@ const StyledRadioItem = designSystemStitches.styled(RadixDropdownMenu__namespace
645
713
  }
646
714
  },
647
715
  ['&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled]) '.concat(StyledRadioContainer)]: {
648
- borderColor: "$border-primary-hover",
649
716
  ["& ".concat(StyledPill)]: {
650
717
  backgroundColor: "$background-primary-prominent-hover"
651
718
  }
@@ -661,6 +728,23 @@ const StyledRadioItem = designSystemStitches.styled(RadixDropdownMenu__namespace
661
728
  ['\n &[aria-disabled="true"] '.concat(StyledProhibited, ",\n &[data-disabled] ").concat(StyledProhibited, "\n ")]: {
662
729
  display: "flex"
663
730
  }
731
+ },
732
+ variants: {
733
+ v1: {
734
+ true: {
735
+ ...itemVariantsDefaults.v1.true,
736
+ ["".concat(StyledRadioContainer)]: {
737
+ borderWidth: "2px",
738
+ borderColor: "$border-neutrals-controls"
739
+ }
740
+ },
741
+ false: {
742
+ ...itemVariantsDefaults.v1.false,
743
+ ['&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled]) '.concat(StyledRadioContainer)]: {
744
+ borderColor: "$border-primary-hover"
745
+ }
746
+ }
747
+ }
664
748
  }
665
749
  });
666
750
 
@@ -668,13 +752,23 @@ const RadioItem = React__default["default"].forwardRef(({ disabled, children, cl
668
752
  const elementProps = useAriaDisabled(restProps, {
669
753
  closeOnSelect
670
754
  });
671
- return /* @__PURE__ */ jsxRuntime.jsx(ItemProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(StyledRadioItem, { ...elementProps, disabled, ref: forwardRef, children: [
672
- children,
673
- /* @__PURE__ */ jsxRuntime.jsx(RightSlot, { children: /* @__PURE__ */ jsxRuntime.jsxs(StyledRadioContainer, { children: [
674
- /* @__PURE__ */ jsxRuntime.jsx(StyledPill, {}),
675
- /* @__PURE__ */ jsxRuntime.jsx(StyledProhibited, { weight: "thin" })
676
- ] }) })
677
- ] }) });
755
+ const [v1] = designSystemExperiments.useNewDesignLanguage();
756
+ return /* @__PURE__ */ jsxRuntime.jsx(ItemProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(
757
+ StyledRadioItem,
758
+ {
759
+ ...elementProps,
760
+ disabled,
761
+ v1,
762
+ ref: forwardRef,
763
+ children: [
764
+ children,
765
+ /* @__PURE__ */ jsxRuntime.jsx(RightSlot, { children: /* @__PURE__ */ jsxRuntime.jsxs(StyledRadioContainer, { children: [
766
+ /* @__PURE__ */ jsxRuntime.jsx(StyledPill, {}),
767
+ /* @__PURE__ */ jsxRuntime.jsx(StyledProhibited, { weight: "thin" })
768
+ ] }) })
769
+ ]
770
+ }
771
+ ) });
678
772
  });
679
773
 
680
774
  const StyledSeparator = designSystemStitches.styled(RadixDropdownMenu__namespace.Separator, {
@@ -693,7 +787,10 @@ const StyledSwitchItem = designSystemStitches.styled(RadixDropdownMenu__namespac
693
787
  ["&[aria-checked=true] ".concat(StyledSwitch)]: designSystemBaseSwitch.styles.checked,
694
788
  ['&[aria-checked=true]:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled]) '.concat(StyledSwitch)]: designSystemBaseSwitch.styles.checkedHovered,
695
789
  ['&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled]) '.concat(StyledSwitch)]: designSystemBaseSwitch.styles.hovered,
696
- ['\n &[aria-disabled="true"] '.concat(StyledSwitch, ",\n &[data-disabled] ").concat(StyledSwitch, "\n ")]: designSystemBaseSwitch.styles.disabled
790
+ ['\n &[aria-disabled="true"] '.concat(StyledSwitch, ",\n &[data-disabled] ").concat(StyledSwitch, "\n ")]: designSystemBaseSwitch.styles.disabled,
791
+ variants: {
792
+ ...itemVariantsDefaults
793
+ }
697
794
  });
698
795
 
699
796
  const SwitchItem = React__default["default"].forwardRef(
@@ -706,10 +803,12 @@ const SwitchItem = React__default["default"].forwardRef(
706
803
  ...restProps
707
804
  }, forwardRef) => {
708
805
  const elementProps = useAriaDisabled(restProps, { closeOnSelect });
806
+ const [v1] = designSystemExperiments.useNewDesignLanguage();
709
807
  return /* @__PURE__ */ jsxRuntime.jsx(ItemProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(
710
808
  StyledSwitchItem,
711
809
  {
712
810
  ...elementProps,
811
+ v1,
713
812
  disabled,
714
813
  checked,
715
814
  onCheckedChange: onChange,
@@ -786,25 +885,53 @@ const StyledIconContainer = designSystemStitches.styled(designSystemPrimitive.Pr
786
885
  });
787
886
  const StyledSubTrigger = designSystemStitches.styled(RadixDropdownMenu__namespace.SubTrigger, {
788
887
  ...itemDefaults,
789
- '&[data-state="open"]': hoverStyles,
790
- ['&[data-state="open"] '.concat(StyledIconContainer, ', &:is(:hover,[data-hovered]):not([aria-disabled="true"]) ').concat(StyledIconContainer)]: {
791
- color: "$icon-primary-hover"
888
+ variants: {
889
+ v1: {
890
+ true: {
891
+ '&[data-state="open"]': {
892
+ background: "$background-neutrals-hover",
893
+ color: "$text-neutrals-hover",
894
+ '&:not([aria-disabled="true"])': {
895
+ boxShadow: "none"
896
+ }
897
+ },
898
+ ['&[data-state="open"] '.concat(StyledIconContainer, ', &:is(:hover,[data-hovered]):not([aria-disabled="true"]) ').concat(StyledIconContainer)]: {
899
+ color: "$icon-neutrals-hover"
900
+ }
901
+ },
902
+ false: {
903
+ '&[data-state="open"]': hoverStyles,
904
+ ['&[data-state="open"] '.concat(StyledIconContainer, ', &:is(:hover,[data-hovered]):not([aria-disabled="true"]) ').concat(StyledIconContainer)]: {
905
+ color: "$icon-primary-hover"
906
+ }
907
+ }
908
+ }
792
909
  }
793
910
  });
794
911
 
795
912
  const SubTrigger = React__default["default"].forwardRef(({ children, disabled = false, ...restProps }, forwardRef) => {
796
913
  let { onSelect, ...elementProps } = restProps;
797
914
  elementProps = useAriaDisabled(elementProps);
798
- return /* @__PURE__ */ jsxRuntime.jsxs(StyledSubTrigger, { ...elementProps, disabled, ref: forwardRef, children: [
799
- children,
800
- /* @__PURE__ */ jsxRuntime.jsx(RightSlot, { children: /* @__PURE__ */ jsxRuntime.jsx(
801
- StyledIconContainer,
802
- {
803
- "data-testid": process.env.NODE_ENV === "test" ? "submenu-arrow-icon" : void 0,
804
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystemIcons.IconChevronRight, { size: "small", weight: "thin" })
805
- }
806
- ) })
807
- ] });
915
+ const [v1] = designSystemExperiments.useNewDesignLanguage();
916
+ return /* @__PURE__ */ jsxRuntime.jsxs(
917
+ StyledSubTrigger,
918
+ {
919
+ ...elementProps,
920
+ v1,
921
+ disabled,
922
+ ref: forwardRef,
923
+ children: [
924
+ children,
925
+ /* @__PURE__ */ jsxRuntime.jsx(RightSlot, { children: /* @__PURE__ */ jsxRuntime.jsx(
926
+ StyledIconContainer,
927
+ {
928
+ "data-testid": process.env.NODE_ENV === "test" ? "submenu-arrow-icon" : void 0,
929
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystemIcons.IconChevronRight, { size: "small", weight: "thin" })
930
+ }
931
+ ) })
932
+ ]
933
+ }
934
+ );
808
935
  });
809
936
 
810
937
  const StyledSubContent = designSystemStitches.styled(
@@ -832,6 +959,7 @@ const SubContent = React__default["default"].forwardRef(
832
959
  const contentSideOffset = CONTENT_OFFSET + parseInt(designSystemStitches.theme.space[paddingToken.x]);
833
960
  const contentAlignOffset = -parseInt(designSystemStitches.theme.space[paddingToken.y]);
834
961
  const availableHeight = collisionBoundary != null ? getComputedStyle(collisionBoundary).getPropertyValue("height") : RADIX_CONTENT_AVAILABLE_HEIGHT;
962
+ const [v1] = designSystemExperiments.useNewDesignLanguage();
835
963
  return /* @__PURE__ */ jsxRuntime.jsx(ContentProvider, { containerSpacing, children: /* @__PURE__ */ jsxRuntime.jsx(
836
964
  StyledSubContent,
837
965
  {
@@ -844,6 +972,7 @@ const SubContent = React__default["default"].forwardRef(
844
972
  hideWhenDetached,
845
973
  sticky,
846
974
  collisionBoundary,
975
+ v1,
847
976
  children: /* @__PURE__ */ jsxRuntime.jsx(
848
977
  ScrollableContent,
849
978
  {