@mirohq/design-system-dropdown-menu 4.4.26 → 4.4.28

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/module.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import React, { createContext, useState, useRef, useCallback, useContext, useEffect } from 'react';
2
+ import React, { createContext, useState, useCallback, useContext, useRef, useEffect } from 'react';
3
3
  import * as RadixDropdownMenu from '@radix-ui/react-dropdown-menu';
4
4
  import { Portal as Portal$1 } from '@radix-ui/react-dropdown-menu';
5
5
  import { BaseTooltipProvider, useBaseTooltipContext } from '@mirohq/design-system-base-tooltip';
6
6
  import { usePrevious } from '@mirohq/design-system-use-previous';
7
7
  import { IconProhibit, IconCheckMark, IconMinus, IconChevronRight } from '@mirohq/design-system-icons';
8
8
  import { addPropsToChildren, booleanify, mergeRefs } from '@mirohq/design-system-utils';
9
+ import { useNewDesignLanguage } from '@mirohq/design-system-experiments';
9
10
  import { Primitive } from '@mirohq/design-system-primitive';
10
11
  import { styled, theme } from '@mirohq/design-system-stitches';
11
12
  import { focus, animations } from '@mirohq/design-system-styles';
@@ -17,7 +18,37 @@ import { styles, Thumb } from '@mirohq/design-system-base-switch';
17
18
  import { isVirtualClick } from '@react-aria/utils';
18
19
  import { styles as styles$1, isIconComponent } from '@mirohq/design-system-base-icon';
19
20
 
20
- const ItemDescription = styled(Primitive.div, {
21
+ const Context$1 = createContext({
22
+ leftSlotMount: () => {
23
+ },
24
+ leftSlotDestroy: () => {
25
+ }
26
+ });
27
+ const ItemProvider = ({ children }) => {
28
+ const [hasSlot, setHasSlot] = useState(false);
29
+ const leftSlotMount = useCallback(() => {
30
+ setHasSlot(true);
31
+ }, []);
32
+ const leftSlotDestroy = useCallback(() => {
33
+ setHasSlot(false);
34
+ }, []);
35
+ const formattedChildren = hasSlot ? children : addPropsToChildren(children, () => true, {
36
+ "data-no-left-slot": ""
37
+ });
38
+ return /* @__PURE__ */ jsx(
39
+ Context$1.Provider,
40
+ {
41
+ value: {
42
+ leftSlotMount,
43
+ leftSlotDestroy
44
+ },
45
+ children: formattedChildren
46
+ }
47
+ );
48
+ };
49
+ const useItem = () => useContext(Context$1);
50
+
51
+ const StyledItemDescription = styled(Primitive.div, {
21
52
  display: "-webkit-box",
22
53
  width: "100%",
23
54
  WebkitBoxOrient: "vertical",
@@ -26,7 +57,33 @@ const ItemDescription = styled(Primitive.div, {
26
57
  gridArea: "item-description",
27
58
  fontSize: "$150",
28
59
  lineHeight: 1.5,
29
- color: "$text-neutrals-subtle"
60
+ color: "$text-neutrals-subtle",
61
+ variants: {
62
+ v1: {
63
+ true: {
64
+ '&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled])': {
65
+ background: "$background-neutrals-hover",
66
+ color: "$text-neutrals-hover",
67
+ '&:not([aria-disabled="true"])': {
68
+ boxShadow: "none"
69
+ }
70
+ }
71
+ },
72
+ false: {
73
+ '&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled])': {
74
+ background: "$background-primary-subtle-hover",
75
+ color: "$text-primary-hover",
76
+ '&:not([aria-disabled="true"])': {
77
+ boxShadow: "none"
78
+ }
79
+ }
80
+ }
81
+ }
82
+ }
83
+ });
84
+ const ItemDescription = React.forwardRef(({ ...props }, forwardRef) => {
85
+ const [v1] = useNewDesignLanguage();
86
+ return /* @__PURE__ */ jsx(ItemProvider, { children: /* @__PURE__ */ jsx(StyledItemDescription, { ...props, v1, ref: forwardRef }) });
30
87
  });
31
88
 
32
89
  const LeftSlot = styled(Primitive.div, {
@@ -48,6 +105,28 @@ const hoverStyles = {
48
105
  boxShadow: "none"
49
106
  }
50
107
  };
108
+ const itemVariantsDefaults = {
109
+ v1: {
110
+ true: {
111
+ '&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled])': {
112
+ background: "$background-neutrals-hover",
113
+ color: "$text-neutrals-hover",
114
+ '&:not([aria-disabled="true"])': {
115
+ boxShadow: "none"
116
+ }
117
+ }
118
+ },
119
+ false: {
120
+ '&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled])': {
121
+ background: "$background-primary-subtle-hover",
122
+ color: "$text-primary-hover",
123
+ '&:not([aria-disabled="true"])': {
124
+ boxShadow: "none"
125
+ }
126
+ }
127
+ }
128
+ }
129
+ };
51
130
  const itemDefaults = {
52
131
  all: "unset",
53
132
  boxSizing: "border-box",
@@ -74,7 +153,7 @@ const itemDefaults = {
74
153
  }),
75
154
  '&:disabled, &[aria-disabled="true"], &[data-disabled]': {
76
155
  cursor: "default",
77
- ["&, & ".concat(ItemDescription, ", & ").concat(Hotkey$1)]: {
156
+ ["&, & ".concat(StyledItemDescription, ", & ").concat(Hotkey$1)]: {
78
157
  color: "$text-neutrals-disabled"
79
158
  },
80
159
  ["& ".concat(StyledIllustrationSlot)]: {
@@ -84,7 +163,6 @@ const itemDefaults = {
84
163
  "&:disabled, &[data-disabled]": {
85
164
  pointerEvents: "none"
86
165
  },
87
- '&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled])': hoverStyles,
88
166
  '&:active:not([aria-disabled="true"])': {
89
167
  background: "$background-primary-subtle-active",
90
168
  boxShadow: "none",
@@ -113,6 +191,7 @@ const StyledCheckboxItem = styled(RadixDropdownMenu.CheckboxItem, {
113
191
  boxSizing: "border-box"
114
192
  },
115
193
  variants: {
194
+ ...itemVariantsDefaults,
116
195
  variant: {
117
196
  "solid-prominent": {
118
197
  ["".concat(StyledIndicator)]: {
@@ -157,7 +236,7 @@ const StyledCheckboxItem = styled(RadixDropdownMenu.CheckboxItem, {
157
236
  }
158
237
  });
159
238
 
160
- const Context$1 = createContext({
239
+ const Context = createContext({
161
240
  rightSlotMount: () => 0,
162
241
  rightSlotDestroy: () => {
163
242
  },
@@ -204,7 +283,7 @@ const ContentProvider = ({
204
283
  }
205
284
  });
206
285
  return /* @__PURE__ */ jsx(
207
- Context$1.Provider,
286
+ Context.Provider,
208
287
  {
209
288
  value: {
210
289
  rightSlotMount,
@@ -215,7 +294,7 @@ const ContentProvider = ({
215
294
  }
216
295
  );
217
296
  };
218
- const useContent = () => useContext(Context$1);
297
+ const useContent = () => useContext(Context);
219
298
 
220
299
  const StyledRightSlot = styled(Primitive.div, {
221
300
  display: "flex",
@@ -287,36 +366,6 @@ const useAriaDisabled = ({ onSelect, ...restProps }, { exceptions, closeOnSelect
287
366
  };
288
367
  };
289
368
 
290
- const Context = createContext({
291
- leftSlotMount: () => {
292
- },
293
- leftSlotDestroy: () => {
294
- }
295
- });
296
- const ItemProvider = ({ children }) => {
297
- const [hasSlot, setHasSlot] = useState(false);
298
- const leftSlotMount = useCallback(() => {
299
- setHasSlot(true);
300
- }, []);
301
- const leftSlotDestroy = useCallback(() => {
302
- setHasSlot(false);
303
- }, []);
304
- const formattedChildren = hasSlot ? children : addPropsToChildren(children, () => true, {
305
- "data-no-left-slot": ""
306
- });
307
- return /* @__PURE__ */ jsx(
308
- Context.Provider,
309
- {
310
- value: {
311
- leftSlotMount,
312
- leftSlotDestroy
313
- },
314
- children: formattedChildren
315
- }
316
- );
317
- };
318
- const useItem = () => useContext(Context);
319
-
320
369
  const CheckboxItem = React.forwardRef(
321
370
  ({
322
371
  children,
@@ -332,6 +381,7 @@ const CheckboxItem = React.forwardRef(
332
381
  const iconCss = { square: "100%", display: "block" };
333
382
  const isAriaDisabled = booleanify(ariaDisabled != null ? ariaDisabled : false);
334
383
  const disabledUnchecked = (disabled === true || isAriaDisabled) && checked === false;
384
+ const [v1] = useNewDesignLanguage();
335
385
  return /* @__PURE__ */ jsx(ItemProvider, { children: /* @__PURE__ */ jsxs(
336
386
  StyledCheckboxItem,
337
387
  {
@@ -341,6 +391,7 @@ const CheckboxItem = React.forwardRef(
341
391
  disabled,
342
392
  onCheckedChange: onChange,
343
393
  variant,
394
+ v1,
344
395
  children: [
345
396
  children,
346
397
  /* @__PURE__ */ jsx(RightSlot, { children: /* @__PURE__ */ jsxs(StyledIndicator, { children: [
@@ -368,8 +419,6 @@ const CONTENT_PADDING = {
368
419
  };
369
420
  const contentDefaults = {
370
421
  maxWidth: "$125",
371
- backgroundColor: "$background-neutrals-container",
372
- borderRadius: "$50",
373
422
  boxShadow: "$50",
374
423
  "@media (prefers-reduced-motion: no-preference)": {
375
424
  animationDuration: "150ms",
@@ -400,8 +449,22 @@ const contentDefaults = {
400
449
  },
401
450
  position: "relative",
402
451
  zIndex: "$dropdown-menu",
403
- outline: "1px solid transparent !important"
452
+ outline: "1px solid transparent !important",
404
453
  // important because Radix overrides outline in element styles
454
+ variants: {
455
+ v1: {
456
+ true: {
457
+ borderRadius: "$100",
458
+ backgroundColor: "$background-neutrals-layout",
459
+ border: ".5px solid $border-neutrals",
460
+ boxShadow: "0px 1px 8px 0px rgba(34, 36, 40, 0.05);"
461
+ },
462
+ false: {
463
+ borderRadius: "$50",
464
+ backgroundColor: "$background-neutrals-container"
465
+ }
466
+ }
467
+ }
405
468
  };
406
469
 
407
470
  const StyledItemsContainer = styled("div", {
@@ -500,6 +563,7 @@ const Content = React.forwardRef(
500
563
  focusWithouAutoScroll._autoScrollPrevented = true;
501
564
  ref.focus = focusWithouAutoScroll;
502
565
  };
566
+ const [v1] = useNewDesignLanguage();
503
567
  return /* @__PURE__ */ jsx(ContentProvider, { containerSpacing, children: /* @__PURE__ */ jsx(
504
568
  StyledContent,
505
569
  {
@@ -514,6 +578,7 @@ const Content = React.forwardRef(
514
578
  collisionPadding,
515
579
  sticky,
516
580
  hideWhenDetached,
581
+ v1,
517
582
  children: /* @__PURE__ */ jsx(
518
583
  ScrollableContent,
519
584
  {
@@ -531,6 +596,7 @@ const Content = React.forwardRef(
531
596
  const StyledItem = styled(RadixDropdownMenu.Item, {
532
597
  ...itemDefaults,
533
598
  variants: {
599
+ ...itemVariantsDefaults,
534
600
  // This is a hack for the :has() selector
535
601
  // Remove it after Firefox implements it
536
602
  hasRightSlot: {
@@ -557,12 +623,14 @@ const StyledItem = styled(RadixDropdownMenu.Item, {
557
623
  const Item = React.forwardRef(
558
624
  ({ disabled = false, variant = "subtle", ...restProps }, forwardRef) => {
559
625
  const elementProps = useAriaDisabled(restProps);
626
+ const [v1] = useNewDesignLanguage();
560
627
  return /* @__PURE__ */ jsx(ItemProvider, { children: /* @__PURE__ */ jsx(
561
628
  StyledItem,
562
629
  {
563
630
  ...elementProps,
564
631
  variant,
565
632
  disabled,
633
+ v1,
566
634
  ref: forwardRef
567
635
  }
568
636
  ) });
@@ -619,7 +687,6 @@ const StyledRadioItem = styled(RadixDropdownMenu.RadioItem, {
619
687
  }
620
688
  },
621
689
  ['&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled]) '.concat(StyledRadioContainer)]: {
622
- borderColor: "$border-primary-hover",
623
690
  ["& ".concat(StyledPill)]: {
624
691
  backgroundColor: "$background-primary-prominent-hover"
625
692
  }
@@ -635,6 +702,23 @@ const StyledRadioItem = styled(RadixDropdownMenu.RadioItem, {
635
702
  ['\n &[aria-disabled="true"] '.concat(StyledProhibited, ",\n &[data-disabled] ").concat(StyledProhibited, "\n ")]: {
636
703
  display: "flex"
637
704
  }
705
+ },
706
+ variants: {
707
+ v1: {
708
+ true: {
709
+ ...itemVariantsDefaults.v1.true,
710
+ ["".concat(StyledRadioContainer)]: {
711
+ borderWidth: "2px",
712
+ borderColor: "$border-neutrals-controls"
713
+ }
714
+ },
715
+ false: {
716
+ ...itemVariantsDefaults.v1.false,
717
+ ['&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled]) '.concat(StyledRadioContainer)]: {
718
+ borderColor: "$border-primary-hover"
719
+ }
720
+ }
721
+ }
638
722
  }
639
723
  });
640
724
 
@@ -642,13 +726,23 @@ const RadioItem = React.forwardRef(({ disabled, children, closeOnSelect = false,
642
726
  const elementProps = useAriaDisabled(restProps, {
643
727
  closeOnSelect
644
728
  });
645
- return /* @__PURE__ */ jsx(ItemProvider, { children: /* @__PURE__ */ jsxs(StyledRadioItem, { ...elementProps, disabled, ref: forwardRef, children: [
646
- children,
647
- /* @__PURE__ */ jsx(RightSlot, { children: /* @__PURE__ */ jsxs(StyledRadioContainer, { children: [
648
- /* @__PURE__ */ jsx(StyledPill, {}),
649
- /* @__PURE__ */ jsx(StyledProhibited, { weight: "thin" })
650
- ] }) })
651
- ] }) });
729
+ const [v1] = useNewDesignLanguage();
730
+ return /* @__PURE__ */ jsx(ItemProvider, { children: /* @__PURE__ */ jsxs(
731
+ StyledRadioItem,
732
+ {
733
+ ...elementProps,
734
+ disabled,
735
+ v1,
736
+ ref: forwardRef,
737
+ children: [
738
+ children,
739
+ /* @__PURE__ */ jsx(RightSlot, { children: /* @__PURE__ */ jsxs(StyledRadioContainer, { children: [
740
+ /* @__PURE__ */ jsx(StyledPill, {}),
741
+ /* @__PURE__ */ jsx(StyledProhibited, { weight: "thin" })
742
+ ] }) })
743
+ ]
744
+ }
745
+ ) });
652
746
  });
653
747
 
654
748
  const StyledSeparator = styled(RadixDropdownMenu.Separator, {
@@ -667,7 +761,10 @@ const StyledSwitchItem = styled(RadixDropdownMenu.CheckboxItem, {
667
761
  ["&[aria-checked=true] ".concat(StyledSwitch)]: styles.checked,
668
762
  ['&[aria-checked=true]:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled]) '.concat(StyledSwitch)]: styles.checkedHovered,
669
763
  ['&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled]) '.concat(StyledSwitch)]: styles.hovered,
670
- ['\n &[aria-disabled="true"] '.concat(StyledSwitch, ",\n &[data-disabled] ").concat(StyledSwitch, "\n ")]: styles.disabled
764
+ ['\n &[aria-disabled="true"] '.concat(StyledSwitch, ",\n &[data-disabled] ").concat(StyledSwitch, "\n ")]: styles.disabled,
765
+ variants: {
766
+ ...itemVariantsDefaults
767
+ }
671
768
  });
672
769
 
673
770
  const SwitchItem = React.forwardRef(
@@ -680,10 +777,12 @@ const SwitchItem = React.forwardRef(
680
777
  ...restProps
681
778
  }, forwardRef) => {
682
779
  const elementProps = useAriaDisabled(restProps, { closeOnSelect });
780
+ const [v1] = useNewDesignLanguage();
683
781
  return /* @__PURE__ */ jsx(ItemProvider, { children: /* @__PURE__ */ jsxs(
684
782
  StyledSwitchItem,
685
783
  {
686
784
  ...elementProps,
785
+ v1,
687
786
  disabled,
688
787
  checked,
689
788
  onCheckedChange: onChange,
@@ -760,25 +859,53 @@ const StyledIconContainer = styled(Primitive.span, {
760
859
  });
761
860
  const StyledSubTrigger = styled(RadixDropdownMenu.SubTrigger, {
762
861
  ...itemDefaults,
763
- '&[data-state="open"]': hoverStyles,
764
- ['&[data-state="open"] '.concat(StyledIconContainer, ', &:is(:hover,[data-hovered]):not([aria-disabled="true"]) ').concat(StyledIconContainer)]: {
765
- color: "$icon-primary-hover"
862
+ variants: {
863
+ v1: {
864
+ true: {
865
+ '&[data-state="open"]': {
866
+ background: "$background-neutrals-hover",
867
+ color: "$text-neutrals-hover",
868
+ '&:not([aria-disabled="true"])': {
869
+ boxShadow: "none"
870
+ }
871
+ },
872
+ ['&[data-state="open"] '.concat(StyledIconContainer, ', &:is(:hover,[data-hovered]):not([aria-disabled="true"]) ').concat(StyledIconContainer)]: {
873
+ color: "$icon-neutrals-hover"
874
+ }
875
+ },
876
+ false: {
877
+ '&[data-state="open"]': hoverStyles,
878
+ ['&[data-state="open"] '.concat(StyledIconContainer, ', &:is(:hover,[data-hovered]):not([aria-disabled="true"]) ').concat(StyledIconContainer)]: {
879
+ color: "$icon-primary-hover"
880
+ }
881
+ }
882
+ }
766
883
  }
767
884
  });
768
885
 
769
886
  const SubTrigger = React.forwardRef(({ children, disabled = false, ...restProps }, forwardRef) => {
770
887
  let { onSelect, ...elementProps } = restProps;
771
888
  elementProps = useAriaDisabled(elementProps);
772
- return /* @__PURE__ */ jsxs(StyledSubTrigger, { ...elementProps, disabled, ref: forwardRef, children: [
773
- children,
774
- /* @__PURE__ */ jsx(RightSlot, { children: /* @__PURE__ */ jsx(
775
- StyledIconContainer,
776
- {
777
- "data-testid": process.env.NODE_ENV === "test" ? "submenu-arrow-icon" : void 0,
778
- children: /* @__PURE__ */ jsx(IconChevronRight, { size: "small", weight: "thin" })
779
- }
780
- ) })
781
- ] });
889
+ const [v1] = useNewDesignLanguage();
890
+ return /* @__PURE__ */ jsxs(
891
+ StyledSubTrigger,
892
+ {
893
+ ...elementProps,
894
+ v1,
895
+ disabled,
896
+ ref: forwardRef,
897
+ children: [
898
+ children,
899
+ /* @__PURE__ */ jsx(RightSlot, { children: /* @__PURE__ */ jsx(
900
+ StyledIconContainer,
901
+ {
902
+ "data-testid": process.env.NODE_ENV === "test" ? "submenu-arrow-icon" : void 0,
903
+ children: /* @__PURE__ */ jsx(IconChevronRight, { size: "small", weight: "thin" })
904
+ }
905
+ ) })
906
+ ]
907
+ }
908
+ );
782
909
  });
783
910
 
784
911
  const StyledSubContent = styled(
@@ -806,6 +933,7 @@ const SubContent = React.forwardRef(
806
933
  const contentSideOffset = CONTENT_OFFSET + parseInt(theme.space[paddingToken.x]);
807
934
  const contentAlignOffset = -parseInt(theme.space[paddingToken.y]);
808
935
  const availableHeight = collisionBoundary != null ? getComputedStyle(collisionBoundary).getPropertyValue("height") : RADIX_CONTENT_AVAILABLE_HEIGHT;
936
+ const [v1] = useNewDesignLanguage();
809
937
  return /* @__PURE__ */ jsx(ContentProvider, { containerSpacing, children: /* @__PURE__ */ jsx(
810
938
  StyledSubContent,
811
939
  {
@@ -818,6 +946,7 @@ const SubContent = React.forwardRef(
818
946
  hideWhenDetached,
819
947
  sticky,
820
948
  collisionBoundary,
949
+ v1,
821
950
  children: /* @__PURE__ */ jsx(
822
951
  ScrollableContent,
823
952
  {