@mirohq/design-system-dropdown-menu 4.5.0-new-focus-keyboard.1 → 5.0.0-v1.0
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 +71 -59
- package/dist/main.js.map +1 -1
- package/dist/module.js +72 -60
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +33 -29
- package/package.json +10 -10
package/dist/module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import React, { createContext, useState,
|
|
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';
|
|
@@ -17,7 +17,37 @@ import { styles, Thumb } from '@mirohq/design-system-base-switch';
|
|
|
17
17
|
import { isVirtualClick } from '@react-aria/utils';
|
|
18
18
|
import { styles as styles$1, isIconComponent } from '@mirohq/design-system-base-icon';
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const Context$1 = createContext({
|
|
21
|
+
leftSlotMount: () => {
|
|
22
|
+
},
|
|
23
|
+
leftSlotDestroy: () => {
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const ItemProvider = ({ children }) => {
|
|
27
|
+
const [hasSlot, setHasSlot] = useState(false);
|
|
28
|
+
const leftSlotMount = useCallback(() => {
|
|
29
|
+
setHasSlot(true);
|
|
30
|
+
}, []);
|
|
31
|
+
const leftSlotDestroy = useCallback(() => {
|
|
32
|
+
setHasSlot(false);
|
|
33
|
+
}, []);
|
|
34
|
+
const formattedChildren = hasSlot ? children : addPropsToChildren(children, () => true, {
|
|
35
|
+
"data-no-left-slot": ""
|
|
36
|
+
});
|
|
37
|
+
return /* @__PURE__ */ jsx(
|
|
38
|
+
Context$1.Provider,
|
|
39
|
+
{
|
|
40
|
+
value: {
|
|
41
|
+
leftSlotMount,
|
|
42
|
+
leftSlotDestroy
|
|
43
|
+
},
|
|
44
|
+
children: formattedChildren
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
const useItem = () => useContext(Context$1);
|
|
49
|
+
|
|
50
|
+
const StyledItemDescription = styled(Primitive.div, {
|
|
21
51
|
display: "-webkit-box",
|
|
22
52
|
width: "100%",
|
|
23
53
|
WebkitBoxOrient: "vertical",
|
|
@@ -26,8 +56,16 @@ const ItemDescription = styled(Primitive.div, {
|
|
|
26
56
|
gridArea: "item-description",
|
|
27
57
|
fontSize: "$150",
|
|
28
58
|
lineHeight: 1.5,
|
|
29
|
-
color: "$text-neutrals-subtle"
|
|
59
|
+
color: "$text-neutrals-subtle",
|
|
60
|
+
'&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled])': {
|
|
61
|
+
background: "$background-neutrals-hover",
|
|
62
|
+
color: "$text-neutrals-hover",
|
|
63
|
+
'&:not([aria-disabled="true"])': {
|
|
64
|
+
boxShadow: "none"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
30
67
|
});
|
|
68
|
+
const ItemDescription = React.forwardRef(({ ...props }, forwardRef) => /* @__PURE__ */ jsx(ItemProvider, { children: /* @__PURE__ */ jsx(StyledItemDescription, { ...props, ref: forwardRef }) }));
|
|
31
69
|
|
|
32
70
|
const LeftSlot = styled(Primitive.div, {
|
|
33
71
|
display: "flex",
|
|
@@ -41,13 +79,6 @@ const StyledIllustrationSlot = styled(LeftSlot, {
|
|
|
41
79
|
width: "$13"
|
|
42
80
|
});
|
|
43
81
|
|
|
44
|
-
const hoverStyles = {
|
|
45
|
-
background: "$background-primary-subtle-hover",
|
|
46
|
-
color: "$text-primary-hover",
|
|
47
|
-
'&:not([aria-disabled="true"])': {
|
|
48
|
-
boxShadow: "none"
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
82
|
const itemDefaults = {
|
|
52
83
|
all: "unset",
|
|
53
84
|
boxSizing: "border-box",
|
|
@@ -69,12 +100,12 @@ const itemDefaults = {
|
|
|
69
100
|
gridTemplateAreas: "'item-text right-slot'\n 'item-description right-slot'"
|
|
70
101
|
},
|
|
71
102
|
...focus.css({
|
|
72
|
-
boxShadow: "$focus
|
|
103
|
+
boxShadow: "$focus",
|
|
73
104
|
outline: "1px solid transparent"
|
|
74
105
|
}),
|
|
75
106
|
'&:disabled, &[aria-disabled="true"], &[data-disabled]': {
|
|
76
107
|
cursor: "default",
|
|
77
|
-
["&, & ".concat(
|
|
108
|
+
["&, & ".concat(StyledItemDescription, ", & ").concat(Hotkey$1)]: {
|
|
78
109
|
color: "$text-neutrals-disabled"
|
|
79
110
|
},
|
|
80
111
|
["& ".concat(StyledIllustrationSlot)]: {
|
|
@@ -84,7 +115,13 @@ const itemDefaults = {
|
|
|
84
115
|
"&:disabled, &[data-disabled]": {
|
|
85
116
|
pointerEvents: "none"
|
|
86
117
|
},
|
|
87
|
-
'&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled])':
|
|
118
|
+
'&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled])': {
|
|
119
|
+
background: "$background-neutrals-hover",
|
|
120
|
+
color: "$text-neutrals-hover",
|
|
121
|
+
'&:not([aria-disabled="true"])': {
|
|
122
|
+
boxShadow: "none"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
88
125
|
'&:active:not([aria-disabled="true"])': {
|
|
89
126
|
background: "$background-primary-subtle-active",
|
|
90
127
|
boxShadow: "none",
|
|
@@ -157,7 +194,7 @@ const StyledCheckboxItem = styled(RadixDropdownMenu.CheckboxItem, {
|
|
|
157
194
|
}
|
|
158
195
|
});
|
|
159
196
|
|
|
160
|
-
const Context
|
|
197
|
+
const Context = createContext({
|
|
161
198
|
rightSlotMount: () => 0,
|
|
162
199
|
rightSlotDestroy: () => {
|
|
163
200
|
},
|
|
@@ -204,7 +241,7 @@ const ContentProvider = ({
|
|
|
204
241
|
}
|
|
205
242
|
});
|
|
206
243
|
return /* @__PURE__ */ jsx(
|
|
207
|
-
Context
|
|
244
|
+
Context.Provider,
|
|
208
245
|
{
|
|
209
246
|
value: {
|
|
210
247
|
rightSlotMount,
|
|
@@ -215,7 +252,7 @@ const ContentProvider = ({
|
|
|
215
252
|
}
|
|
216
253
|
);
|
|
217
254
|
};
|
|
218
|
-
const useContent = () => useContext(Context
|
|
255
|
+
const useContent = () => useContext(Context);
|
|
219
256
|
|
|
220
257
|
const StyledRightSlot = styled(Primitive.div, {
|
|
221
258
|
display: "flex",
|
|
@@ -287,38 +324,6 @@ const useAriaDisabled = ({ onSelect, ...restProps }, { exceptions, closeOnSelect
|
|
|
287
324
|
};
|
|
288
325
|
};
|
|
289
326
|
|
|
290
|
-
const Context = createContext({
|
|
291
|
-
leftSlotMount: () => {
|
|
292
|
-
},
|
|
293
|
-
leftSlotDestroy: () => {
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
const ItemProvider = ({
|
|
297
|
-
children
|
|
298
|
-
}) => {
|
|
299
|
-
const [hasSlot, setHasSlot] = useState(false);
|
|
300
|
-
const leftSlotMount = useCallback(() => {
|
|
301
|
-
setHasSlot(true);
|
|
302
|
-
}, []);
|
|
303
|
-
const leftSlotDestroy = useCallback(() => {
|
|
304
|
-
setHasSlot(false);
|
|
305
|
-
}, []);
|
|
306
|
-
const formattedChildren = hasSlot ? children : addPropsToChildren(children, () => true, {
|
|
307
|
-
"data-no-left-slot": ""
|
|
308
|
-
});
|
|
309
|
-
return /* @__PURE__ */ jsx(
|
|
310
|
-
Context.Provider,
|
|
311
|
-
{
|
|
312
|
-
value: {
|
|
313
|
-
leftSlotMount,
|
|
314
|
-
leftSlotDestroy
|
|
315
|
-
},
|
|
316
|
-
children: formattedChildren
|
|
317
|
-
}
|
|
318
|
-
);
|
|
319
|
-
};
|
|
320
|
-
const useItem = () => useContext(Context);
|
|
321
|
-
|
|
322
327
|
const CheckboxItem = React.forwardRef(
|
|
323
328
|
({
|
|
324
329
|
children,
|
|
@@ -370,9 +375,6 @@ const CONTENT_PADDING = {
|
|
|
370
375
|
};
|
|
371
376
|
const contentDefaults = {
|
|
372
377
|
maxWidth: "$125",
|
|
373
|
-
backgroundColor: "$background-neutrals-container",
|
|
374
|
-
borderRadius: "$50",
|
|
375
|
-
boxShadow: "$50",
|
|
376
378
|
"@media (prefers-reduced-motion: no-preference)": {
|
|
377
379
|
animationDuration: "150ms",
|
|
378
380
|
animationTimingFunction: "cubic-bezier(0.25, 0.5, 0.5, 0.9)",
|
|
@@ -402,8 +404,12 @@ const contentDefaults = {
|
|
|
402
404
|
},
|
|
403
405
|
position: "relative",
|
|
404
406
|
zIndex: "$dropdown-menu",
|
|
405
|
-
outline: "1px solid transparent !important"
|
|
407
|
+
outline: "1px solid transparent !important",
|
|
406
408
|
// important because Radix overrides outline in element styles
|
|
409
|
+
borderRadius: "$100",
|
|
410
|
+
backgroundColor: "$background-neutrals-layout",
|
|
411
|
+
border: ".5px solid $border-neutrals-subtle",
|
|
412
|
+
boxShadow: "$elevation-200"
|
|
407
413
|
};
|
|
408
414
|
|
|
409
415
|
const StyledItemsContainer = styled("div", {
|
|
@@ -621,7 +627,6 @@ const StyledRadioItem = styled(RadixDropdownMenu.RadioItem, {
|
|
|
621
627
|
}
|
|
622
628
|
},
|
|
623
629
|
['&:is(:hover,[data-hovered]):not([aria-disabled="true"],[data-disabled]) '.concat(StyledRadioContainer)]: {
|
|
624
|
-
borderColor: "$border-primary-hover",
|
|
625
630
|
["& ".concat(StyledPill)]: {
|
|
626
631
|
backgroundColor: "$background-primary-prominent-hover"
|
|
627
632
|
}
|
|
@@ -637,6 +642,10 @@ const StyledRadioItem = styled(RadixDropdownMenu.RadioItem, {
|
|
|
637
642
|
['\n &[aria-disabled="true"] '.concat(StyledProhibited, ",\n &[data-disabled] ").concat(StyledProhibited, "\n ")]: {
|
|
638
643
|
display: "flex"
|
|
639
644
|
}
|
|
645
|
+
},
|
|
646
|
+
["".concat(StyledRadioContainer)]: {
|
|
647
|
+
borderWidth: "2px",
|
|
648
|
+
borderColor: "$border-neutrals-controls"
|
|
640
649
|
}
|
|
641
650
|
});
|
|
642
651
|
|
|
@@ -707,7 +716,7 @@ const StyledTrigger = styled(RadixDropdownMenu.Trigger, {
|
|
|
707
716
|
boxSizing: "border-box",
|
|
708
717
|
cursor: "pointer",
|
|
709
718
|
...focus.css({
|
|
710
|
-
boxShadow: "$focus
|
|
719
|
+
boxShadow: "$focus",
|
|
711
720
|
outline: "1px solid transparent"
|
|
712
721
|
})
|
|
713
722
|
},
|
|
@@ -762,9 +771,15 @@ const StyledIconContainer = styled(Primitive.span, {
|
|
|
762
771
|
});
|
|
763
772
|
const StyledSubTrigger = styled(RadixDropdownMenu.SubTrigger, {
|
|
764
773
|
...itemDefaults,
|
|
765
|
-
'&[data-state="open"]':
|
|
774
|
+
'&[data-state="open"]': {
|
|
775
|
+
background: "$background-neutrals-hover",
|
|
776
|
+
color: "$text-neutrals-hover",
|
|
777
|
+
'&:not([aria-disabled="true"])': {
|
|
778
|
+
boxShadow: "none"
|
|
779
|
+
}
|
|
780
|
+
},
|
|
766
781
|
['&[data-state="open"] '.concat(StyledIconContainer, ', &:is(:hover,[data-hovered]):not([aria-disabled="true"]) ').concat(StyledIconContainer)]: {
|
|
767
|
-
color: "$icon-
|
|
782
|
+
color: "$icon-neutrals-hover"
|
|
768
783
|
}
|
|
769
784
|
});
|
|
770
785
|
|
|
@@ -928,10 +943,7 @@ const Root = ({
|
|
|
928
943
|
}
|
|
929
944
|
);
|
|
930
945
|
};
|
|
931
|
-
const DropdownMenu = ({
|
|
932
|
-
direction = "ltr",
|
|
933
|
-
...restProps
|
|
934
|
-
}) => /* @__PURE__ */ jsx(DropdownProvider, { direction, children: /* @__PURE__ */ jsx(BaseTooltipProvider, { children: /* @__PURE__ */ jsx(Root, { direction, ...restProps }) }) });
|
|
946
|
+
const DropdownMenu = ({ direction = "ltr", ...restProps }) => /* @__PURE__ */ jsx(DropdownProvider, { direction, children: /* @__PURE__ */ jsx(BaseTooltipProvider, { children: /* @__PURE__ */ jsx(Root, { direction, ...restProps }) }) });
|
|
935
947
|
DropdownMenu.CheckboxItem = CheckboxItem;
|
|
936
948
|
DropdownMenu.Content = Content;
|
|
937
949
|
DropdownMenu.Hotkey = Hotkey;
|