@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 +52 -49
- package/dist/main.js.map +1 -1
- package/dist/module.js +53 -50
- package/dist/module.js.map +1 -1
- package/package.json +10 -9
package/dist/module.js
CHANGED
|
@@ -3,13 +3,14 @@ import React, { createContext, useState, useRef, useCallback, useContext, useMem
|
|
|
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 { IconProhibit, IconCheckMark, IconChevronRight } from '@mirohq/design-system-icons';
|
|
6
|
-
import { addPropsToChildren, booleanify } from '@mirohq/design-system-utils';
|
|
6
|
+
import { addPropsToChildren, booleanify, mergeRefs } from '@mirohq/design-system-utils';
|
|
7
7
|
import { Primitive } from '@mirohq/design-system-primitive';
|
|
8
8
|
import { styled, theme } from '@mirohq/design-system-stitches';
|
|
9
9
|
import { focus, animations } from '@mirohq/design-system-styles';
|
|
10
10
|
import { useLayoutEffect } from '@mirohq/design-system-use-layout-effect';
|
|
11
11
|
import { ScrollArea } from '@mirohq/design-system-scroll-area';
|
|
12
12
|
import { styles, Thumb } from '@mirohq/design-system-base-switch';
|
|
13
|
+
import { isVirtualClick } from '@react-aria/utils';
|
|
13
14
|
import { styles as styles$1, isIconComponent } from '@mirohq/design-system-base-icon';
|
|
14
15
|
|
|
15
16
|
const ItemDescription = styled(Primitive.div, {
|
|
@@ -79,7 +80,7 @@ const ContentProvider = ({
|
|
|
79
80
|
);
|
|
80
81
|
const formattedChildren = addPropsToChildren(children, () => true, {
|
|
81
82
|
UNSAFE_style: {
|
|
82
|
-
"--right-slot-max-width":
|
|
83
|
+
"--right-slot-max-width": "".concat(Math.ceil(maxWidth), "px")
|
|
83
84
|
}
|
|
84
85
|
});
|
|
85
86
|
return /* @__PURE__ */ jsx(
|
|
@@ -141,8 +142,7 @@ const itemDefaults = {
|
|
|
141
142
|
display: "grid",
|
|
142
143
|
gridTemplateColumns: "auto 1fr minmax(min-content, var(--right-slot-max-width))",
|
|
143
144
|
gridTemplateRows: "auto 1fr",
|
|
144
|
-
gridTemplateAreas:
|
|
145
|
-
'left-slot item-description right-slot'`,
|
|
145
|
+
gridTemplateAreas: "'left-slot item-text right-slot'\n 'left-slot item-description right-slot'",
|
|
146
146
|
alignItems: "start",
|
|
147
147
|
padding: "10px $100",
|
|
148
148
|
position: "relative",
|
|
@@ -150,8 +150,7 @@ const itemDefaults = {
|
|
|
150
150
|
cursor: "pointer",
|
|
151
151
|
"&[data-no-left-slot]": {
|
|
152
152
|
gridTemplateColumns: "1fr minmax(auto, var(--right-slot-max-width))",
|
|
153
|
-
gridTemplateAreas:
|
|
154
|
-
'item-description right-slot'`
|
|
153
|
+
gridTemplateAreas: "'item-text right-slot'\n 'item-description right-slot'"
|
|
155
154
|
},
|
|
156
155
|
"&:not(:last-child)": {
|
|
157
156
|
marginBottom: "$50"
|
|
@@ -165,10 +164,10 @@ const itemDefaults = {
|
|
|
165
164
|
}),
|
|
166
165
|
'&:disabled, &[aria-disabled="true"], &[data-disabled]': {
|
|
167
166
|
cursor: "default",
|
|
168
|
-
[
|
|
167
|
+
["&, & ".concat(ItemDescription, ", & ").concat(HotkeySlot)]: {
|
|
169
168
|
color: "$text-neutrals-disabled"
|
|
170
169
|
},
|
|
171
|
-
[
|
|
170
|
+
["& ".concat(StyledIllustrationSlot)]: {
|
|
172
171
|
filter: "grayscale(1)"
|
|
173
172
|
}
|
|
174
173
|
},
|
|
@@ -199,16 +198,13 @@ const StyledIndicator = styled(Primitive.span, {
|
|
|
199
198
|
});
|
|
200
199
|
const StyledCheckboxItem = styled(RadixDropdownMenu.CheckboxItem, {
|
|
201
200
|
...itemDefaults,
|
|
202
|
-
[
|
|
201
|
+
['&[data-state="checked"] '.concat(StyledIndicator)]: {
|
|
203
202
|
color: "$icon-primary"
|
|
204
203
|
},
|
|
205
|
-
[
|
|
204
|
+
['&[data-state="checked"]:hover:not([aria-disabled="true"]) '.concat(StyledIndicator)]: {
|
|
206
205
|
color: "$icon-primary-hover"
|
|
207
206
|
},
|
|
208
|
-
[
|
|
209
|
-
&[aria-disabled="true"] ${StyledIndicator},
|
|
210
|
-
&[data-disabled] ${StyledIndicator}
|
|
211
|
-
`]: {
|
|
207
|
+
['\n &[aria-disabled="true"] '.concat(StyledIndicator, ",\n &[data-disabled] ").concat(StyledIndicator, "\n ")]: {
|
|
212
208
|
color: "$icon-neutrals-disabled"
|
|
213
209
|
}
|
|
214
210
|
});
|
|
@@ -342,7 +338,7 @@ const contentDefaults = {
|
|
|
342
338
|
borderRadius: "$50",
|
|
343
339
|
boxShadow: "$50",
|
|
344
340
|
"& [data-radix-scroll-area-viewport]": {
|
|
345
|
-
padding:
|
|
341
|
+
padding: "".concat(CONTENT_BORDER_FOCUS_ITEM, " $50 ").concat(CONTENT_BORDER_FOCUS_ITEM, " ").concat(CONTENT_BORDER_FOCUS_ITEM),
|
|
346
342
|
boxSizing: "border-box"
|
|
347
343
|
},
|
|
348
344
|
"@media (prefers-reduced-motion: no-preference)": {
|
|
@@ -407,9 +403,9 @@ const ScrollableContent = ({
|
|
|
407
403
|
}) => {
|
|
408
404
|
const getOverflowMaxHeight = useCallback(() => {
|
|
409
405
|
const [top, , bottom] = CONTENT_PADDING[containerSpacing].split(" ").map((value) => value.replace("$", ""));
|
|
410
|
-
const topBottom = top !== void 0 && bottom !== void 0 ?
|
|
411
|
-
const overflowMaxHeigh = overflow === "auto" ?
|
|
412
|
-
const newMaxHeight =
|
|
406
|
+
const topBottom = top !== void 0 && bottom !== void 0 ? "var(--space-".concat(top, ") + var(--space-").concat(bottom, ")") : "var(--space-".concat(top, ") + var(--space-").concat(top, ")");
|
|
407
|
+
const overflowMaxHeigh = overflow === "auto" ? "calc(var(--radix-dropdown-menu-content-available-height) - (".concat(topBottom, "))") : "auto";
|
|
408
|
+
const newMaxHeight = "calc(".concat(maxHeight, " - (").concat(topBottom, "))");
|
|
413
409
|
return {
|
|
414
410
|
maxHeight: maxHeight === void 0 ? overflowMaxHeigh : newMaxHeight
|
|
415
411
|
};
|
|
@@ -418,7 +414,7 @@ const ScrollableContent = ({
|
|
|
418
414
|
return /* @__PURE__ */ jsxs(
|
|
419
415
|
ScrollArea,
|
|
420
416
|
{
|
|
421
|
-
css: { margin:
|
|
417
|
+
css: { margin: "-".concat(CONTENT_BORDER_FOCUS_ITEM) },
|
|
422
418
|
type: "always",
|
|
423
419
|
children: [
|
|
424
420
|
/* @__PURE__ */ jsx(ScrollArea.Viewport, { css: { ...getOverflowMaxHeight() }, children }),
|
|
@@ -537,35 +533,29 @@ const StyledProhibited = styled(IconProhibit, {
|
|
|
537
533
|
});
|
|
538
534
|
const StyledRadioItem = styled(RadixDropdownMenu.RadioItem, {
|
|
539
535
|
...itemDefaults,
|
|
540
|
-
[
|
|
536
|
+
['&[data-state="checked"] '.concat(StyledRadioContainer)]: {
|
|
541
537
|
color: "$icon-primary",
|
|
542
538
|
borderColor: "$border-primary",
|
|
543
|
-
[
|
|
539
|
+
["& ".concat(StyledPill)]: {
|
|
544
540
|
display: "block",
|
|
545
541
|
backgroundColor: "$background-primary-prominent-selected"
|
|
546
542
|
}
|
|
547
543
|
},
|
|
548
|
-
[
|
|
544
|
+
['&:hover:not([aria-disabled="true"]) '.concat(StyledRadioContainer)]: {
|
|
549
545
|
borderColor: "$border-primary-hover",
|
|
550
|
-
[
|
|
546
|
+
["& ".concat(StyledPill)]: {
|
|
551
547
|
backgroundColor: "$background-primary-prominent-hover"
|
|
552
548
|
}
|
|
553
549
|
},
|
|
554
|
-
[
|
|
555
|
-
&[aria-disabled="true"] ${StyledRadioContainer},
|
|
556
|
-
&[data-disabled] ${StyledRadioContainer}
|
|
557
|
-
`]: {
|
|
550
|
+
['\n &[aria-disabled="true"] '.concat(StyledRadioContainer, ",\n &[data-disabled] ").concat(StyledRadioContainer, "\n ")]: {
|
|
558
551
|
color: "$icon-neutrals-disabled",
|
|
559
552
|
borderColor: "$border-neutrals-disabled",
|
|
560
|
-
[
|
|
553
|
+
["& ".concat(StyledPill)]: {
|
|
561
554
|
backgroundColor: "$icon-neutrals-disabled"
|
|
562
555
|
}
|
|
563
556
|
},
|
|
564
557
|
'&[data-state="unchecked"]': {
|
|
565
|
-
[
|
|
566
|
-
&[aria-disabled="true"] ${StyledProhibited},
|
|
567
|
-
&[data-disabled] ${StyledProhibited}
|
|
568
|
-
`]: {
|
|
558
|
+
['\n &[aria-disabled="true"] '.concat(StyledProhibited, ",\n &[data-disabled] ").concat(StyledProhibited, "\n ")]: {
|
|
569
559
|
display: "flex"
|
|
570
560
|
}
|
|
571
561
|
}
|
|
@@ -604,13 +594,10 @@ const StyledSwitch = styled(Primitive.span, {
|
|
|
604
594
|
});
|
|
605
595
|
const StyledSwitchItem = styled(RadixDropdownMenu.CheckboxItem, {
|
|
606
596
|
...itemDefaults,
|
|
607
|
-
[
|
|
608
|
-
[
|
|
609
|
-
[
|
|
610
|
-
[
|
|
611
|
-
&[aria-disabled="true"] ${StyledSwitch},
|
|
612
|
-
&[data-disabled] ${StyledSwitch}
|
|
613
|
-
`]: styles.disabled
|
|
597
|
+
['&[data-state="checked"] '.concat(StyledSwitch)]: styles.checked,
|
|
598
|
+
['&[data-state="checked"]:hover:not([aria-disabled="true"]) '.concat(StyledSwitch)]: styles.checkedHovered,
|
|
599
|
+
['&:hover:not([aria-disabled="true"]) '.concat(StyledSwitch)]: styles.hovered,
|
|
600
|
+
['\n &[aria-disabled="true"] '.concat(StyledSwitch, ",\n &[data-disabled] ").concat(StyledSwitch, "\n ")]: styles.disabled
|
|
614
601
|
});
|
|
615
602
|
|
|
616
603
|
const SwitchItem = React.forwardRef(
|
|
@@ -660,16 +647,32 @@ const StyledTrigger = styled(RadixDropdownMenu.Trigger, {
|
|
|
660
647
|
}
|
|
661
648
|
});
|
|
662
649
|
|
|
663
|
-
const Trigger = React.forwardRef(({ asChild = false, onPress, onClick, ...restProps }, forwardRef) =>
|
|
664
|
-
|
|
665
|
-
{
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
));
|
|
650
|
+
const Trigger = React.forwardRef(({ asChild = false, onPress, onClick, ...restProps }, forwardRef) => {
|
|
651
|
+
const ref = useRef(null);
|
|
652
|
+
const handleVirtualClick = (e) => {
|
|
653
|
+
var _a;
|
|
654
|
+
if (isVirtualClick(e.nativeEvent) && ref.current !== null) {
|
|
655
|
+
const pointerDownEvent = new MouseEvent("pointerdown", {
|
|
656
|
+
bubbles: true,
|
|
657
|
+
cancelable: true
|
|
658
|
+
});
|
|
659
|
+
(_a = ref.current) == null ? void 0 : _a.dispatchEvent(pointerDownEvent);
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
return /* @__PURE__ */ jsx(
|
|
663
|
+
StyledTrigger,
|
|
664
|
+
{
|
|
665
|
+
...restProps,
|
|
666
|
+
onClick: (e) => {
|
|
667
|
+
handleVirtualClick(e);
|
|
668
|
+
onClick == null ? void 0 : onClick(e);
|
|
669
|
+
},
|
|
670
|
+
ref: mergeRefs([ref, forwardRef]),
|
|
671
|
+
unstyled: !asChild,
|
|
672
|
+
asChild
|
|
673
|
+
}
|
|
674
|
+
);
|
|
675
|
+
});
|
|
673
676
|
|
|
674
677
|
const StyledIconContainer = styled(Primitive.span, {
|
|
675
678
|
color: "$icon-neutrals-with-text",
|
|
@@ -679,7 +682,7 @@ const StyledIconContainer = styled(Primitive.span, {
|
|
|
679
682
|
const StyledSubTrigger = styled(RadixDropdownMenu.SubTrigger, {
|
|
680
683
|
...itemDefaults,
|
|
681
684
|
'&[data-state="open"]': itemDefaults['&:hover:not([aria-disabled="true"])'],
|
|
682
|
-
[
|
|
685
|
+
['&[data-state="open"] '.concat(StyledIconContainer, ', &:hover:not([aria-disabled="true"]) ').concat(StyledIconContainer)]: {
|
|
683
686
|
color: "$icon-primary-hover"
|
|
684
687
|
}
|
|
685
688
|
});
|