@mirohq/design-system-dropdown-menu 3.4.0 → 3.4.1

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
@@ -13,6 +13,7 @@ var designSystemStyles = require('@mirohq/design-system-styles');
13
13
  var designSystemUseLayoutEffect = require('@mirohq/design-system-use-layout-effect');
14
14
  var designSystemScrollArea = require('@mirohq/design-system-scroll-area');
15
15
  var designSystemBaseSwitch = require('@mirohq/design-system-base-switch');
16
+ var utils = require('@react-aria/utils');
16
17
  var designSystemBaseIcon = require('@mirohq/design-system-base-icon');
17
18
 
18
19
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -105,7 +106,7 @@ const ContentProvider = ({
105
106
  );
106
107
  const formattedChildren = designSystemUtils.addPropsToChildren(children, () => true, {
107
108
  UNSAFE_style: {
108
- "--right-slot-max-width": `${Math.ceil(maxWidth)}px`
109
+ "--right-slot-max-width": "".concat(Math.ceil(maxWidth), "px")
109
110
  }
110
111
  });
111
112
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -167,8 +168,7 @@ const itemDefaults = {
167
168
  display: "grid",
168
169
  gridTemplateColumns: "auto 1fr minmax(min-content, var(--right-slot-max-width))",
169
170
  gridTemplateRows: "auto 1fr",
170
- gridTemplateAreas: `'left-slot item-text right-slot'
171
- 'left-slot item-description right-slot'`,
171
+ gridTemplateAreas: "'left-slot item-text right-slot'\n 'left-slot item-description right-slot'",
172
172
  alignItems: "start",
173
173
  padding: "10px $100",
174
174
  position: "relative",
@@ -176,8 +176,7 @@ const itemDefaults = {
176
176
  cursor: "pointer",
177
177
  "&[data-no-left-slot]": {
178
178
  gridTemplateColumns: "1fr minmax(auto, var(--right-slot-max-width))",
179
- gridTemplateAreas: `'item-text right-slot'
180
- 'item-description right-slot'`
179
+ gridTemplateAreas: "'item-text right-slot'\n 'item-description right-slot'"
181
180
  },
182
181
  "&:not(:last-child)": {
183
182
  marginBottom: "$50"
@@ -191,10 +190,10 @@ const itemDefaults = {
191
190
  }),
192
191
  '&:disabled, &[aria-disabled="true"], &[data-disabled]': {
193
192
  cursor: "default",
194
- [`&, & ${ItemDescription}, & ${HotkeySlot}`]: {
193
+ ["&, & ".concat(ItemDescription, ", & ").concat(HotkeySlot)]: {
195
194
  color: "$text-neutrals-disabled"
196
195
  },
197
- [`& ${StyledIllustrationSlot}`]: {
196
+ ["& ".concat(StyledIllustrationSlot)]: {
198
197
  filter: "grayscale(1)"
199
198
  }
200
199
  },
@@ -225,16 +224,13 @@ const StyledIndicator = designSystemStitches.styled(designSystemPrimitive.Primit
225
224
  });
226
225
  const StyledCheckboxItem = designSystemStitches.styled(RadixDropdownMenu__namespace.CheckboxItem, {
227
226
  ...itemDefaults,
228
- [`&[data-state="checked"] ${StyledIndicator}`]: {
227
+ ['&[data-state="checked"] '.concat(StyledIndicator)]: {
229
228
  color: "$icon-primary"
230
229
  },
231
- [`&[data-state="checked"]:hover:not([aria-disabled="true"]) ${StyledIndicator}`]: {
230
+ ['&[data-state="checked"]:hover:not([aria-disabled="true"]) '.concat(StyledIndicator)]: {
232
231
  color: "$icon-primary-hover"
233
232
  },
234
- [`
235
- &[aria-disabled="true"] ${StyledIndicator},
236
- &[data-disabled] ${StyledIndicator}
237
- `]: {
233
+ ['\n &[aria-disabled="true"] '.concat(StyledIndicator, ",\n &[data-disabled] ").concat(StyledIndicator, "\n ")]: {
238
234
  color: "$icon-neutrals-disabled"
239
235
  }
240
236
  });
@@ -368,7 +364,7 @@ const contentDefaults = {
368
364
  borderRadius: "$50",
369
365
  boxShadow: "$50",
370
366
  "& [data-radix-scroll-area-viewport]": {
371
- padding: `${CONTENT_BORDER_FOCUS_ITEM} $50 ${CONTENT_BORDER_FOCUS_ITEM} ${CONTENT_BORDER_FOCUS_ITEM}`,
367
+ padding: "".concat(CONTENT_BORDER_FOCUS_ITEM, " $50 ").concat(CONTENT_BORDER_FOCUS_ITEM, " ").concat(CONTENT_BORDER_FOCUS_ITEM),
372
368
  boxSizing: "border-box"
373
369
  },
374
370
  "@media (prefers-reduced-motion: no-preference)": {
@@ -433,9 +429,9 @@ const ScrollableContent = ({
433
429
  }) => {
434
430
  const getOverflowMaxHeight = React.useCallback(() => {
435
431
  const [top, , bottom] = CONTENT_PADDING[containerSpacing].split(" ").map((value) => value.replace("$", ""));
436
- const topBottom = top !== void 0 && bottom !== void 0 ? `var(--space-${top}) + var(--space-${bottom})` : `var(--space-${top}) + var(--space-${top})`;
437
- const overflowMaxHeigh = overflow === "auto" ? `calc(var(--radix-dropdown-menu-content-available-height) - (${topBottom}))` : "auto";
438
- const newMaxHeight = `calc(${maxHeight} - (${topBottom}))`;
432
+ const topBottom = top !== void 0 && bottom !== void 0 ? "var(--space-".concat(top, ") + var(--space-").concat(bottom, ")") : "var(--space-".concat(top, ") + var(--space-").concat(top, ")");
433
+ const overflowMaxHeigh = overflow === "auto" ? "calc(var(--radix-dropdown-menu-content-available-height) - (".concat(topBottom, "))") : "auto";
434
+ const newMaxHeight = "calc(".concat(maxHeight, " - (").concat(topBottom, "))");
439
435
  return {
440
436
  maxHeight: maxHeight === void 0 ? overflowMaxHeigh : newMaxHeight
441
437
  };
@@ -444,7 +440,7 @@ const ScrollableContent = ({
444
440
  return /* @__PURE__ */ jsxRuntime.jsxs(
445
441
  designSystemScrollArea.ScrollArea,
446
442
  {
447
- css: { margin: `-${CONTENT_BORDER_FOCUS_ITEM}` },
443
+ css: { margin: "-".concat(CONTENT_BORDER_FOCUS_ITEM) },
448
444
  type: "always",
449
445
  children: [
450
446
  /* @__PURE__ */ jsxRuntime.jsx(designSystemScrollArea.ScrollArea.Viewport, { css: { ...getOverflowMaxHeight() }, children }),
@@ -563,35 +559,29 @@ const StyledProhibited = designSystemStitches.styled(designSystemIcons.IconProhi
563
559
  });
564
560
  const StyledRadioItem = designSystemStitches.styled(RadixDropdownMenu__namespace.RadioItem, {
565
561
  ...itemDefaults,
566
- [`&[data-state="checked"] ${StyledRadioContainer}`]: {
562
+ ['&[data-state="checked"] '.concat(StyledRadioContainer)]: {
567
563
  color: "$icon-primary",
568
564
  borderColor: "$border-primary",
569
- [`& ${StyledPill}`]: {
565
+ ["& ".concat(StyledPill)]: {
570
566
  display: "block",
571
567
  backgroundColor: "$background-primary-prominent-selected"
572
568
  }
573
569
  },
574
- [`&:hover:not([aria-disabled="true"]) ${StyledRadioContainer}`]: {
570
+ ['&:hover:not([aria-disabled="true"]) '.concat(StyledRadioContainer)]: {
575
571
  borderColor: "$border-primary-hover",
576
- [`& ${StyledPill}`]: {
572
+ ["& ".concat(StyledPill)]: {
577
573
  backgroundColor: "$background-primary-prominent-hover"
578
574
  }
579
575
  },
580
- [`
581
- &[aria-disabled="true"] ${StyledRadioContainer},
582
- &[data-disabled] ${StyledRadioContainer}
583
- `]: {
576
+ ['\n &[aria-disabled="true"] '.concat(StyledRadioContainer, ",\n &[data-disabled] ").concat(StyledRadioContainer, "\n ")]: {
584
577
  color: "$icon-neutrals-disabled",
585
578
  borderColor: "$border-neutrals-disabled",
586
- [`& ${StyledPill}`]: {
579
+ ["& ".concat(StyledPill)]: {
587
580
  backgroundColor: "$icon-neutrals-disabled"
588
581
  }
589
582
  },
590
583
  '&[data-state="unchecked"]': {
591
- [`
592
- &[aria-disabled="true"] ${StyledProhibited},
593
- &[data-disabled] ${StyledProhibited}
594
- `]: {
584
+ ['\n &[aria-disabled="true"] '.concat(StyledProhibited, ",\n &[data-disabled] ").concat(StyledProhibited, "\n ")]: {
595
585
  display: "flex"
596
586
  }
597
587
  }
@@ -630,13 +620,10 @@ const StyledSwitch = designSystemStitches.styled(designSystemPrimitive.Primitive
630
620
  });
631
621
  const StyledSwitchItem = designSystemStitches.styled(RadixDropdownMenu__namespace.CheckboxItem, {
632
622
  ...itemDefaults,
633
- [`&[data-state="checked"] ${StyledSwitch}`]: designSystemBaseSwitch.styles.checked,
634
- [`&[data-state="checked"]:hover:not([aria-disabled="true"]) ${StyledSwitch}`]: designSystemBaseSwitch.styles.checkedHovered,
635
- [`&:hover:not([aria-disabled="true"]) ${StyledSwitch}`]: designSystemBaseSwitch.styles.hovered,
636
- [`
637
- &[aria-disabled="true"] ${StyledSwitch},
638
- &[data-disabled] ${StyledSwitch}
639
- `]: designSystemBaseSwitch.styles.disabled
623
+ ['&[data-state="checked"] '.concat(StyledSwitch)]: designSystemBaseSwitch.styles.checked,
624
+ ['&[data-state="checked"]:hover:not([aria-disabled="true"]) '.concat(StyledSwitch)]: designSystemBaseSwitch.styles.checkedHovered,
625
+ ['&:hover:not([aria-disabled="true"]) '.concat(StyledSwitch)]: designSystemBaseSwitch.styles.hovered,
626
+ ['\n &[aria-disabled="true"] '.concat(StyledSwitch, ",\n &[data-disabled] ").concat(StyledSwitch, "\n ")]: designSystemBaseSwitch.styles.disabled
640
627
  });
641
628
 
642
629
  const SwitchItem = React__default["default"].forwardRef(
@@ -686,16 +673,32 @@ const StyledTrigger = designSystemStitches.styled(RadixDropdownMenu__namespace.T
686
673
  }
687
674
  });
688
675
 
689
- const Trigger = React__default["default"].forwardRef(({ asChild = false, onPress, onClick, ...restProps }, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(
690
- StyledTrigger,
691
- {
692
- ...restProps,
693
- onClick: onPress != null ? onPress : onClick,
694
- ref: forwardRef,
695
- unstyled: !asChild,
696
- asChild
697
- }
698
- ));
676
+ const Trigger = React__default["default"].forwardRef(({ asChild = false, onPress, onClick, ...restProps }, forwardRef) => {
677
+ const ref = React.useRef(null);
678
+ const handleVirtualClick = (e) => {
679
+ var _a;
680
+ if (utils.isVirtualClick(e.nativeEvent) && ref.current !== null) {
681
+ const pointerDownEvent = new MouseEvent("pointerdown", {
682
+ bubbles: true,
683
+ cancelable: true
684
+ });
685
+ (_a = ref.current) == null ? void 0 : _a.dispatchEvent(pointerDownEvent);
686
+ }
687
+ };
688
+ return /* @__PURE__ */ jsxRuntime.jsx(
689
+ StyledTrigger,
690
+ {
691
+ ...restProps,
692
+ onClick: (e) => {
693
+ handleVirtualClick(e);
694
+ onClick == null ? void 0 : onClick(e);
695
+ },
696
+ ref: designSystemUtils.mergeRefs([ref, forwardRef]),
697
+ unstyled: !asChild,
698
+ asChild
699
+ }
700
+ );
701
+ });
699
702
 
700
703
  const StyledIconContainer = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
701
704
  color: "$icon-neutrals-with-text",
@@ -705,7 +708,7 @@ const StyledIconContainer = designSystemStitches.styled(designSystemPrimitive.Pr
705
708
  const StyledSubTrigger = designSystemStitches.styled(RadixDropdownMenu__namespace.SubTrigger, {
706
709
  ...itemDefaults,
707
710
  '&[data-state="open"]': itemDefaults['&:hover:not([aria-disabled="true"])'],
708
- [`&[data-state="open"] ${StyledIconContainer}, &:hover:not([aria-disabled="true"]) ${StyledIconContainer}`]: {
711
+ ['&[data-state="open"] '.concat(StyledIconContainer, ', &:hover:not([aria-disabled="true"]) ').concat(StyledIconContainer)]: {
709
712
  color: "$icon-primary-hover"
710
713
  }
711
714
  });