@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/main.js
CHANGED
|
@@ -14,6 +14,7 @@ var designSystemStitches = require('@mirohq/design-system-stitches');
|
|
|
14
14
|
var designSystemStyles = require('@mirohq/design-system-styles');
|
|
15
15
|
var designSystemBaseHotkey = require('@mirohq/design-system-base-hotkey');
|
|
16
16
|
var designSystemUseLayoutEffect = require('@mirohq/design-system-use-layout-effect');
|
|
17
|
+
var designSystemUseAriaDisabled = require('@mirohq/design-system-use-aria-disabled');
|
|
17
18
|
var designSystemScrollArea = require('@mirohq/design-system-scroll-area');
|
|
18
19
|
var designSystemBaseSwitch = require('@mirohq/design-system-base-switch');
|
|
19
20
|
var utils = require('@react-aria/utils');
|
|
@@ -273,29 +274,24 @@ const RightSlot = (props) => {
|
|
|
273
274
|
return /* @__PURE__ */ jsxRuntime.jsx(StyledRightSlot, { ref, ...props });
|
|
274
275
|
};
|
|
275
276
|
|
|
276
|
-
const useAriaDisabled = ({
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
onClick
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
e.stopPropagation();
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
292
|
-
},
|
|
277
|
+
const useAriaDisabled = ({ onSelect, ...restProps }, { exceptions, closeOnSelect = true } = {}) => {
|
|
278
|
+
const elementProps = designSystemUseAriaDisabled.useAriaDisabled(restProps, {
|
|
279
|
+
...exceptions,
|
|
280
|
+
allowArrows: true
|
|
281
|
+
});
|
|
282
|
+
const { "aria-disabled": ariaDisabled, onPointerMove, onClick } = elementProps;
|
|
283
|
+
return {
|
|
284
|
+
...elementProps,
|
|
285
|
+
// these events need to be manually included
|
|
286
|
+
// bacause useAriaDisabled only removes the events from the props.
|
|
287
|
+
// Radix uses these events to handle the dropdown menu so we need to prevent
|
|
288
|
+
// it from being called when the item is aria-disabled.
|
|
293
289
|
onSelect: (e) => {
|
|
294
290
|
if (designSystemUtils.booleanify(ariaDisabled)) {
|
|
295
291
|
e.preventDefault();
|
|
296
292
|
return;
|
|
297
293
|
}
|
|
298
|
-
if (!
|
|
294
|
+
if (!closeOnSelect) {
|
|
299
295
|
e.preventDefault();
|
|
300
296
|
}
|
|
301
297
|
onSelect == null ? void 0 : onSelect(e);
|
|
@@ -314,9 +310,8 @@ const useAriaDisabled = ({
|
|
|
314
310
|
}
|
|
315
311
|
onClick == null ? void 0 : onClick(e);
|
|
316
312
|
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
);
|
|
313
|
+
};
|
|
314
|
+
};
|
|
320
315
|
|
|
321
316
|
const Context = React.createContext({
|
|
322
317
|
leftSlotMount: () => {
|
|
@@ -360,16 +355,15 @@ const CheckboxItem = React__default["default"].forwardRef(
|
|
|
360
355
|
variant = "ghost",
|
|
361
356
|
...restProps
|
|
362
357
|
}, forwardRef) => {
|
|
363
|
-
const
|
|
364
|
-
const { "aria-disabled": ariaDisabled } =
|
|
358
|
+
const elementProps = useAriaDisabled(restProps, { closeOnSelect });
|
|
359
|
+
const { "aria-disabled": ariaDisabled } = restProps;
|
|
365
360
|
const iconCss = { square: "100%", display: "block" };
|
|
366
361
|
const isAriaDisabled = designSystemUtils.booleanify(ariaDisabled != null ? ariaDisabled : false);
|
|
367
362
|
const disabledUnchecked = (disabled === true || isAriaDisabled) && checked === false;
|
|
368
363
|
return /* @__PURE__ */ jsxRuntime.jsx(ItemProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
369
364
|
StyledCheckboxItem,
|
|
370
365
|
{
|
|
371
|
-
...
|
|
372
|
-
...ariaDisabledProps,
|
|
366
|
+
...elementProps,
|
|
373
367
|
ref: forwardRef,
|
|
374
368
|
checked,
|
|
375
369
|
disabled,
|
|
@@ -575,12 +569,11 @@ const StyledItem = designSystemStitches.styled(RadixDropdownMenu__namespace.Item
|
|
|
575
569
|
|
|
576
570
|
const Item = React__default["default"].forwardRef(
|
|
577
571
|
({ disabled = false, variant = "subtle", ...restProps }, forwardRef) => {
|
|
578
|
-
const
|
|
572
|
+
const elementProps = useAriaDisabled(restProps);
|
|
579
573
|
return /* @__PURE__ */ jsxRuntime.jsx(ItemProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
580
574
|
StyledItem,
|
|
581
575
|
{
|
|
582
|
-
...
|
|
583
|
-
...ariaDisabledProps,
|
|
576
|
+
...elementProps,
|
|
584
577
|
variant,
|
|
585
578
|
disabled,
|
|
586
579
|
ref: forwardRef
|
|
@@ -589,10 +582,7 @@ const Item = React__default["default"].forwardRef(
|
|
|
589
582
|
}
|
|
590
583
|
);
|
|
591
584
|
|
|
592
|
-
const LinkItem = React__default["default"].forwardRef(({ children, href, ...restProps }, forwardRef) => {
|
|
593
|
-
const ariaDisabledProps = useAriaDisabled(restProps);
|
|
594
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Item, { asChild: true, ref: forwardRef, ...restProps, ...ariaDisabledProps, children: /* @__PURE__ */ jsxRuntime.jsx("a", { href, children }) });
|
|
595
|
-
});
|
|
585
|
+
const LinkItem = React__default["default"].forwardRef(({ children, href, ...restProps }, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(Item, { asChild: true, ref: forwardRef, ...restProps, children: /* @__PURE__ */ jsxRuntime.jsx("a", { href, children }) }));
|
|
596
586
|
|
|
597
587
|
const StyledRadioGroup = designSystemStitches.styled(RadixDropdownMenu__namespace.RadioGroup, {
|
|
598
588
|
display: "grid",
|
|
@@ -662,23 +652,16 @@ const StyledRadioItem = designSystemStitches.styled(RadixDropdownMenu__namespace
|
|
|
662
652
|
});
|
|
663
653
|
|
|
664
654
|
const RadioItem = React__default["default"].forwardRef(({ disabled, children, closeOnSelect = false, ...restProps }, forwardRef) => {
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
/* @__PURE__ */ jsxRuntime.jsx(RightSlot, { children: /* @__PURE__ */ jsxRuntime.jsxs(StyledRadioContainer, { children: [
|
|
676
|
-
/* @__PURE__ */ jsxRuntime.jsx(StyledPill, {}),
|
|
677
|
-
/* @__PURE__ */ jsxRuntime.jsx(StyledProhibited, { weight: "thin" })
|
|
678
|
-
] }) })
|
|
679
|
-
]
|
|
680
|
-
}
|
|
681
|
-
) });
|
|
655
|
+
const elementProps = useAriaDisabled(restProps, {
|
|
656
|
+
closeOnSelect
|
|
657
|
+
});
|
|
658
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ItemProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(StyledRadioItem, { ...elementProps, disabled, ref: forwardRef, children: [
|
|
659
|
+
children,
|
|
660
|
+
/* @__PURE__ */ jsxRuntime.jsx(RightSlot, { children: /* @__PURE__ */ jsxRuntime.jsxs(StyledRadioContainer, { children: [
|
|
661
|
+
/* @__PURE__ */ jsxRuntime.jsx(StyledPill, {}),
|
|
662
|
+
/* @__PURE__ */ jsxRuntime.jsx(StyledProhibited, { weight: "thin" })
|
|
663
|
+
] }) })
|
|
664
|
+
] }) });
|
|
682
665
|
});
|
|
683
666
|
|
|
684
667
|
const StyledSeparator = designSystemStitches.styled(RadixDropdownMenu__namespace.Separator, {
|
|
@@ -705,16 +688,15 @@ const SwitchItem = React__default["default"].forwardRef(
|
|
|
705
688
|
disabled,
|
|
706
689
|
checked,
|
|
707
690
|
onChange,
|
|
708
|
-
children,
|
|
709
691
|
closeOnSelect = false,
|
|
692
|
+
children,
|
|
710
693
|
...restProps
|
|
711
694
|
}, forwardRef) => {
|
|
712
|
-
const
|
|
695
|
+
const elementProps = useAriaDisabled(restProps, { closeOnSelect });
|
|
713
696
|
return /* @__PURE__ */ jsxRuntime.jsx(ItemProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
714
697
|
StyledSwitchItem,
|
|
715
698
|
{
|
|
716
|
-
...
|
|
717
|
-
...ariaDisabledProps,
|
|
699
|
+
...elementProps,
|
|
718
700
|
disabled,
|
|
719
701
|
checked,
|
|
720
702
|
onCheckedChange: onChange,
|
|
@@ -798,29 +780,18 @@ const StyledSubTrigger = designSystemStitches.styled(RadixDropdownMenu__namespac
|
|
|
798
780
|
});
|
|
799
781
|
|
|
800
782
|
const SubTrigger = React__default["default"].forwardRef(({ children, disabled = false, ...restProps }, forwardRef) => {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
children,
|
|
814
|
-
/* @__PURE__ */ jsxRuntime.jsx(RightSlot, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
815
|
-
StyledIconContainer,
|
|
816
|
-
{
|
|
817
|
-
"data-testid": process.env.NODE_ENV === "test" ? "submenu-arrow-icon" : void 0,
|
|
818
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(designSystemIcons.IconChevronRight, { size: "small", weight: "thin" })
|
|
819
|
-
}
|
|
820
|
-
) })
|
|
821
|
-
]
|
|
822
|
-
}
|
|
823
|
-
);
|
|
783
|
+
let { onSelect, ...elementProps } = restProps;
|
|
784
|
+
elementProps = useAriaDisabled(elementProps);
|
|
785
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(StyledSubTrigger, { ...elementProps, disabled, ref: forwardRef, children: [
|
|
786
|
+
children,
|
|
787
|
+
/* @__PURE__ */ jsxRuntime.jsx(RightSlot, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
788
|
+
StyledIconContainer,
|
|
789
|
+
{
|
|
790
|
+
"data-testid": process.env.NODE_ENV === "test" ? "submenu-arrow-icon" : void 0,
|
|
791
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystemIcons.IconChevronRight, { size: "small", weight: "thin" })
|
|
792
|
+
}
|
|
793
|
+
) })
|
|
794
|
+
] });
|
|
824
795
|
});
|
|
825
796
|
|
|
826
797
|
const StyledSubContent = designSystemStitches.styled(
|