@mirohq/design-system-dropdown-menu 4.4.7 → 4.4.9
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 +47 -76
- package/dist/main.js.map +1 -1
- package/dist/module.js +48 -77
- package/dist/module.js.map +1 -1
- package/package.json +7 -6
package/dist/module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import React, { createContext, useState, useRef, useCallback, useContext,
|
|
2
|
+
import React, { createContext, useState, useRef, useCallback, useContext, 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';
|
|
@@ -11,6 +11,7 @@ import { styled, theme } from '@mirohq/design-system-stitches';
|
|
|
11
11
|
import { focus, animations } from '@mirohq/design-system-styles';
|
|
12
12
|
import { Hotkey as Hotkey$1 } from '@mirohq/design-system-base-hotkey';
|
|
13
13
|
import { useLayoutEffect } from '@mirohq/design-system-use-layout-effect';
|
|
14
|
+
import { useAriaDisabled as useAriaDisabled$1 } from '@mirohq/design-system-use-aria-disabled';
|
|
14
15
|
import { ScrollArea } from '@mirohq/design-system-scroll-area';
|
|
15
16
|
import { styles, Thumb } from '@mirohq/design-system-base-switch';
|
|
16
17
|
import { isVirtualClick } from '@react-aria/utils';
|
|
@@ -247,29 +248,24 @@ const RightSlot = (props) => {
|
|
|
247
248
|
return /* @__PURE__ */ jsx(StyledRightSlot, { ref, ...props });
|
|
248
249
|
};
|
|
249
250
|
|
|
250
|
-
const useAriaDisabled = ({
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
onClick
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
e.stopPropagation();
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
266
|
-
},
|
|
251
|
+
const useAriaDisabled = ({ onSelect, ...restProps }, { exceptions, closeOnSelect = true } = {}) => {
|
|
252
|
+
const elementProps = useAriaDisabled$1(restProps, {
|
|
253
|
+
...exceptions,
|
|
254
|
+
allowArrows: true
|
|
255
|
+
});
|
|
256
|
+
const { "aria-disabled": ariaDisabled, onPointerMove, onClick } = elementProps;
|
|
257
|
+
return {
|
|
258
|
+
...elementProps,
|
|
259
|
+
// these events need to be manually included
|
|
260
|
+
// bacause useAriaDisabled only removes the events from the props.
|
|
261
|
+
// Radix uses these events to handle the dropdown menu so we need to prevent
|
|
262
|
+
// it from being called when the item is aria-disabled.
|
|
267
263
|
onSelect: (e) => {
|
|
268
264
|
if (booleanify(ariaDisabled)) {
|
|
269
265
|
e.preventDefault();
|
|
270
266
|
return;
|
|
271
267
|
}
|
|
272
|
-
if (!
|
|
268
|
+
if (!closeOnSelect) {
|
|
273
269
|
e.preventDefault();
|
|
274
270
|
}
|
|
275
271
|
onSelect == null ? void 0 : onSelect(e);
|
|
@@ -288,9 +284,8 @@ const useAriaDisabled = ({
|
|
|
288
284
|
}
|
|
289
285
|
onClick == null ? void 0 : onClick(e);
|
|
290
286
|
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
);
|
|
287
|
+
};
|
|
288
|
+
};
|
|
294
289
|
|
|
295
290
|
const Context = createContext({
|
|
296
291
|
leftSlotMount: () => {
|
|
@@ -334,16 +329,15 @@ const CheckboxItem = React.forwardRef(
|
|
|
334
329
|
variant = "ghost",
|
|
335
330
|
...restProps
|
|
336
331
|
}, forwardRef) => {
|
|
337
|
-
const
|
|
338
|
-
const { "aria-disabled": ariaDisabled } =
|
|
332
|
+
const elementProps = useAriaDisabled(restProps, { closeOnSelect });
|
|
333
|
+
const { "aria-disabled": ariaDisabled } = restProps;
|
|
339
334
|
const iconCss = { square: "100%", display: "block" };
|
|
340
335
|
const isAriaDisabled = booleanify(ariaDisabled != null ? ariaDisabled : false);
|
|
341
336
|
const disabledUnchecked = (disabled === true || isAriaDisabled) && checked === false;
|
|
342
337
|
return /* @__PURE__ */ jsx(ItemProvider, { children: /* @__PURE__ */ jsxs(
|
|
343
338
|
StyledCheckboxItem,
|
|
344
339
|
{
|
|
345
|
-
...
|
|
346
|
-
...ariaDisabledProps,
|
|
340
|
+
...elementProps,
|
|
347
341
|
ref: forwardRef,
|
|
348
342
|
checked,
|
|
349
343
|
disabled,
|
|
@@ -549,12 +543,11 @@ const StyledItem = styled(RadixDropdownMenu.Item, {
|
|
|
549
543
|
|
|
550
544
|
const Item = React.forwardRef(
|
|
551
545
|
({ disabled = false, variant = "subtle", ...restProps }, forwardRef) => {
|
|
552
|
-
const
|
|
546
|
+
const elementProps = useAriaDisabled(restProps);
|
|
553
547
|
return /* @__PURE__ */ jsx(ItemProvider, { children: /* @__PURE__ */ jsx(
|
|
554
548
|
StyledItem,
|
|
555
549
|
{
|
|
556
|
-
...
|
|
557
|
-
...ariaDisabledProps,
|
|
550
|
+
...elementProps,
|
|
558
551
|
variant,
|
|
559
552
|
disabled,
|
|
560
553
|
ref: forwardRef
|
|
@@ -563,10 +556,7 @@ const Item = React.forwardRef(
|
|
|
563
556
|
}
|
|
564
557
|
);
|
|
565
558
|
|
|
566
|
-
const LinkItem = React.forwardRef(({ children, href, ...restProps }, forwardRef) => {
|
|
567
|
-
const ariaDisabledProps = useAriaDisabled(restProps);
|
|
568
|
-
return /* @__PURE__ */ jsx(Item, { asChild: true, ref: forwardRef, ...restProps, ...ariaDisabledProps, children: /* @__PURE__ */ jsx("a", { href, children }) });
|
|
569
|
-
});
|
|
559
|
+
const LinkItem = React.forwardRef(({ children, href, ...restProps }, forwardRef) => /* @__PURE__ */ jsx(Item, { asChild: true, ref: forwardRef, ...restProps, children: /* @__PURE__ */ jsx("a", { href, children }) }));
|
|
570
560
|
|
|
571
561
|
const StyledRadioGroup = styled(RadixDropdownMenu.RadioGroup, {
|
|
572
562
|
display: "grid",
|
|
@@ -636,23 +626,16 @@ const StyledRadioItem = styled(RadixDropdownMenu.RadioItem, {
|
|
|
636
626
|
});
|
|
637
627
|
|
|
638
628
|
const RadioItem = React.forwardRef(({ disabled, children, closeOnSelect = false, ...restProps }, forwardRef) => {
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
/* @__PURE__ */ jsx(RightSlot, { children: /* @__PURE__ */ jsxs(StyledRadioContainer, { children: [
|
|
650
|
-
/* @__PURE__ */ jsx(StyledPill, {}),
|
|
651
|
-
/* @__PURE__ */ jsx(StyledProhibited, { weight: "thin" })
|
|
652
|
-
] }) })
|
|
653
|
-
]
|
|
654
|
-
}
|
|
655
|
-
) });
|
|
629
|
+
const elementProps = useAriaDisabled(restProps, {
|
|
630
|
+
closeOnSelect
|
|
631
|
+
});
|
|
632
|
+
return /* @__PURE__ */ jsx(ItemProvider, { children: /* @__PURE__ */ jsxs(StyledRadioItem, { ...elementProps, disabled, ref: forwardRef, children: [
|
|
633
|
+
children,
|
|
634
|
+
/* @__PURE__ */ jsx(RightSlot, { children: /* @__PURE__ */ jsxs(StyledRadioContainer, { children: [
|
|
635
|
+
/* @__PURE__ */ jsx(StyledPill, {}),
|
|
636
|
+
/* @__PURE__ */ jsx(StyledProhibited, { weight: "thin" })
|
|
637
|
+
] }) })
|
|
638
|
+
] }) });
|
|
656
639
|
});
|
|
657
640
|
|
|
658
641
|
const StyledSeparator = styled(RadixDropdownMenu.Separator, {
|
|
@@ -679,16 +662,15 @@ const SwitchItem = React.forwardRef(
|
|
|
679
662
|
disabled,
|
|
680
663
|
checked,
|
|
681
664
|
onChange,
|
|
682
|
-
children,
|
|
683
665
|
closeOnSelect = false,
|
|
666
|
+
children,
|
|
684
667
|
...restProps
|
|
685
668
|
}, forwardRef) => {
|
|
686
|
-
const
|
|
669
|
+
const elementProps = useAriaDisabled(restProps, { closeOnSelect });
|
|
687
670
|
return /* @__PURE__ */ jsx(ItemProvider, { children: /* @__PURE__ */ jsxs(
|
|
688
671
|
StyledSwitchItem,
|
|
689
672
|
{
|
|
690
|
-
...
|
|
691
|
-
...ariaDisabledProps,
|
|
673
|
+
...elementProps,
|
|
692
674
|
disabled,
|
|
693
675
|
checked,
|
|
694
676
|
onCheckedChange: onChange,
|
|
@@ -772,29 +754,18 @@ const StyledSubTrigger = styled(RadixDropdownMenu.SubTrigger, {
|
|
|
772
754
|
});
|
|
773
755
|
|
|
774
756
|
const SubTrigger = React.forwardRef(({ children, disabled = false, ...restProps }, forwardRef) => {
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
children,
|
|
788
|
-
/* @__PURE__ */ jsx(RightSlot, { children: /* @__PURE__ */ jsx(
|
|
789
|
-
StyledIconContainer,
|
|
790
|
-
{
|
|
791
|
-
"data-testid": process.env.NODE_ENV === "test" ? "submenu-arrow-icon" : void 0,
|
|
792
|
-
children: /* @__PURE__ */ jsx(IconChevronRight, { size: "small", weight: "thin" })
|
|
793
|
-
}
|
|
794
|
-
) })
|
|
795
|
-
]
|
|
796
|
-
}
|
|
797
|
-
);
|
|
757
|
+
let { onSelect, ...elementProps } = restProps;
|
|
758
|
+
elementProps = useAriaDisabled(elementProps);
|
|
759
|
+
return /* @__PURE__ */ jsxs(StyledSubTrigger, { ...elementProps, disabled, ref: forwardRef, children: [
|
|
760
|
+
children,
|
|
761
|
+
/* @__PURE__ */ jsx(RightSlot, { children: /* @__PURE__ */ jsx(
|
|
762
|
+
StyledIconContainer,
|
|
763
|
+
{
|
|
764
|
+
"data-testid": process.env.NODE_ENV === "test" ? "submenu-arrow-icon" : void 0,
|
|
765
|
+
children: /* @__PURE__ */ jsx(IconChevronRight, { size: "small", weight: "thin" })
|
|
766
|
+
}
|
|
767
|
+
) })
|
|
768
|
+
] });
|
|
798
769
|
});
|
|
799
770
|
|
|
800
771
|
const StyledSubContent = styled(
|