@mirohq/design-system-dropdown-menu 5.3.2-dropdown-on-pointerup.4 → 5.3.3
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 +28 -93
- package/dist/main.js.map +1 -1
- package/dist/module.js +28 -93
- package/dist/module.js.map +1 -1
- package/package.json +11 -13
package/dist/main.js
CHANGED
|
@@ -15,8 +15,6 @@ var designSystemUseLayoutEffect = require('@mirohq/design-system-use-layout-effe
|
|
|
15
15
|
var designSystemUseAriaDisabled = require('@mirohq/design-system-use-aria-disabled');
|
|
16
16
|
var designSystemScrollArea = require('@mirohq/design-system-scroll-area');
|
|
17
17
|
var designSystemBaseSwitch = require('@mirohq/design-system-base-switch');
|
|
18
|
-
var utils = require('@react-aria/utils');
|
|
19
|
-
var designSystemUsePress = require('@mirohq/design-system-use-press');
|
|
20
18
|
var designSystemBaseIcon = require('@mirohq/design-system-base-icon');
|
|
21
19
|
|
|
22
20
|
function _interopNamespaceDefault(e) {
|
|
@@ -481,25 +479,16 @@ const ScrollableContent = ({
|
|
|
481
479
|
const DropdownContext = React.createContext({});
|
|
482
480
|
const DropdownProvider = ({
|
|
483
481
|
children,
|
|
484
|
-
open: rootOpen,
|
|
485
482
|
...restProps
|
|
486
|
-
}) =>
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
open,
|
|
496
|
-
setOpen,
|
|
497
|
-
triggerRef
|
|
498
|
-
},
|
|
499
|
-
children
|
|
500
|
-
}
|
|
501
|
-
);
|
|
502
|
-
};
|
|
483
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
484
|
+
DropdownContext.Provider,
|
|
485
|
+
{
|
|
486
|
+
value: {
|
|
487
|
+
...restProps
|
|
488
|
+
},
|
|
489
|
+
children
|
|
490
|
+
}
|
|
491
|
+
);
|
|
503
492
|
const useDropdownContext = () => React.useContext(DropdownContext);
|
|
504
493
|
|
|
505
494
|
const Content = React.forwardRef(
|
|
@@ -516,11 +505,10 @@ const Content = React.forwardRef(
|
|
|
516
505
|
containerSpacing = "medium",
|
|
517
506
|
overflow = "visible",
|
|
518
507
|
maxHeight,
|
|
519
|
-
onInteractOutside,
|
|
520
508
|
children,
|
|
521
509
|
...restProps
|
|
522
510
|
}, forwardRef) => {
|
|
523
|
-
const { direction
|
|
511
|
+
const { direction } = useDropdownContext();
|
|
524
512
|
const preventScrollOnFocus = (ref) => {
|
|
525
513
|
if (ref === null || "_autoScrollPrevented" in ref.focus) {
|
|
526
514
|
return;
|
|
@@ -553,12 +541,6 @@ const Content = React.forwardRef(
|
|
|
553
541
|
collisionPadding,
|
|
554
542
|
sticky,
|
|
555
543
|
hideWhenDetached,
|
|
556
|
-
onInteractOutside: (e) => {
|
|
557
|
-
if (e.target === triggerRef.current) {
|
|
558
|
-
e.preventDefault();
|
|
559
|
-
}
|
|
560
|
-
onInteractOutside == null ? void 0 : onInteractOutside(e);
|
|
561
|
-
},
|
|
562
544
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
563
545
|
ScrollableContent,
|
|
564
546
|
{
|
|
@@ -764,52 +746,17 @@ const StyledTrigger = designSystemStitches.styled(RadixDropdownMenu__namespace.T
|
|
|
764
746
|
}
|
|
765
747
|
});
|
|
766
748
|
|
|
767
|
-
const Trigger = React.forwardRef(({ asChild = false, ...restProps }, forwardRef) => {
|
|
749
|
+
const Trigger = React.forwardRef(({ asChild = false, onClick, ...restProps }, forwardRef) => {
|
|
768
750
|
const ref = React.useRef(null);
|
|
769
|
-
const { setOpen, rootOpen, triggerRef } = useDropdownContext();
|
|
770
|
-
const { pressProps } = designSystemUsePress.usePress({
|
|
771
|
-
onPress: () => {
|
|
772
|
-
if (rootOpen === void 0) {
|
|
773
|
-
setOpen((open) => !designSystemUtils.booleanify(open));
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
});
|
|
777
|
-
const elementProps = utils.mergeProps(restProps, pressProps);
|
|
778
|
-
const onClickHandler = React.useCallback(
|
|
779
|
-
(e) => {
|
|
780
|
-
var _a, _b;
|
|
781
|
-
if ((e == null ? void 0 : e.nativeEvent) === void 0) {
|
|
782
|
-
console.error(
|
|
783
|
-
"DropdownMenu.Trigger onClick expected a MouseEvent but got different one. It usually happens due to a element used asChild with a different onClick interface.\n" + "Event: ".concat(JSON.stringify(e, null, 2))
|
|
784
|
-
);
|
|
785
|
-
(_a = restProps.onClick) == null ? void 0 : _a.call(restProps, e);
|
|
786
|
-
return;
|
|
787
|
-
}
|
|
788
|
-
designSystemUtils.handleVirtualClick(e, ref);
|
|
789
|
-
(_b = elementProps.onClick) == null ? void 0 : _b.call(elementProps, e);
|
|
790
|
-
},
|
|
791
|
-
[restProps, elementProps]
|
|
792
|
-
);
|
|
793
751
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
794
752
|
StyledTrigger,
|
|
795
753
|
{
|
|
796
|
-
...
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
onClickHandler(e);
|
|
801
|
-
}
|
|
802
|
-
(_a = elementProps.onPointerDown) == null ? void 0 : _a.call(elementProps, e);
|
|
803
|
-
},
|
|
804
|
-
onClick: onClickHandler,
|
|
805
|
-
onKeyDown: (e) => {
|
|
806
|
-
var _a;
|
|
807
|
-
if (!/^(Arrow|Tab|Escape)/.test(e.key)) {
|
|
808
|
-
e.preventDefault();
|
|
809
|
-
}
|
|
810
|
-
(_a = elementProps.onKeyDown) == null ? void 0 : _a.call(elementProps, e);
|
|
754
|
+
...restProps,
|
|
755
|
+
onClick: (e) => {
|
|
756
|
+
designSystemUtils.handleVirtualClick(e, ref);
|
|
757
|
+
onClick == null ? void 0 : onClick(e);
|
|
811
758
|
},
|
|
812
|
-
ref: designSystemUtils.mergeRefs([ref,
|
|
759
|
+
ref: designSystemUtils.mergeRefs([ref, forwardRef]),
|
|
813
760
|
unstyled: !asChild,
|
|
814
761
|
asChild
|
|
815
762
|
}
|
|
@@ -964,48 +911,36 @@ const Root = ({
|
|
|
964
911
|
defaultOpen = false,
|
|
965
912
|
direction,
|
|
966
913
|
interactOutside = false,
|
|
914
|
+
open,
|
|
967
915
|
onOpen,
|
|
968
916
|
onClose,
|
|
969
917
|
...restProps
|
|
970
918
|
}) => {
|
|
971
919
|
const { ignoreNextTooltip } = designSystemBaseTooltip.useBaseTooltipContext();
|
|
972
|
-
const { rootOpen, open, setOpen } = useDropdownContext();
|
|
973
920
|
const prevOpen = designSystemUsePrevious.usePrevious(open);
|
|
974
921
|
React.useEffect(() => {
|
|
975
|
-
if (prevOpen
|
|
976
|
-
|
|
977
|
-
onOpen == null ? void 0 : onOpen();
|
|
978
|
-
} else {
|
|
979
|
-
if (prevOpen === true) {
|
|
980
|
-
ignoreNextTooltip();
|
|
981
|
-
}
|
|
982
|
-
onClose == null ? void 0 : onClose();
|
|
983
|
-
}
|
|
922
|
+
if (prevOpen === true && open === false) {
|
|
923
|
+
ignoreNextTooltip();
|
|
984
924
|
}
|
|
985
|
-
}, [open, prevOpen
|
|
925
|
+
}, [ignoreNextTooltip, open, prevOpen]);
|
|
986
926
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
987
927
|
RadixDropdownMenu__namespace.Root,
|
|
988
928
|
{
|
|
989
929
|
...restProps,
|
|
990
930
|
dir: direction,
|
|
991
931
|
modal: interactOutside,
|
|
992
|
-
open
|
|
993
|
-
// use the root open state if it is defined
|
|
994
|
-
rootOpen != null ? rootOpen : defaultOpen && (prevOpen === void 0 || prevOpen === open) ? (
|
|
995
|
-
// only use defaultOpen in the first render then use the context open state
|
|
996
|
-
// if the open state is the same as the previous one, it is most likely a re-render and we should still use the defaultOpen
|
|
997
|
-
void 0
|
|
998
|
-
) : (
|
|
999
|
-
// otherwise, use the user open state
|
|
1000
|
-
open
|
|
1001
|
-
)
|
|
1002
|
-
),
|
|
932
|
+
open,
|
|
1003
933
|
defaultOpen,
|
|
1004
|
-
onOpenChange:
|
|
934
|
+
onOpenChange: (newOpen) => {
|
|
935
|
+
if (!newOpen && open === void 0) {
|
|
936
|
+
ignoreNextTooltip();
|
|
937
|
+
}
|
|
938
|
+
newOpen ? onOpen == null ? void 0 : onOpen() : onClose == null ? void 0 : onClose();
|
|
939
|
+
}
|
|
1005
940
|
}
|
|
1006
941
|
);
|
|
1007
942
|
};
|
|
1008
|
-
const DropdownMenu = ({ direction = "ltr",
|
|
943
|
+
const DropdownMenu = ({ direction = "ltr", ...restProps }) => /* @__PURE__ */ jsxRuntime.jsx(DropdownProvider, { direction, children: /* @__PURE__ */ jsxRuntime.jsx(designSystemBaseTooltip.BaseTooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(Root, { direction, ...restProps }) }) });
|
|
1009
944
|
DropdownMenu.CheckboxItem = CheckboxItem;
|
|
1010
945
|
DropdownMenu.Content = Content;
|
|
1011
946
|
DropdownMenu.Hotkey = Hotkey;
|