@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/module.js
CHANGED
|
@@ -14,8 +14,6 @@ import { useLayoutEffect } from '@mirohq/design-system-use-layout-effect';
|
|
|
14
14
|
import { useAriaDisabled as useAriaDisabled$1 } from '@mirohq/design-system-use-aria-disabled';
|
|
15
15
|
import { ScrollArea } from '@mirohq/design-system-scroll-area';
|
|
16
16
|
import { styles, Thumb } from '@mirohq/design-system-base-switch';
|
|
17
|
-
import { mergeProps } from '@react-aria/utils';
|
|
18
|
-
import { usePress } from '@mirohq/design-system-use-press';
|
|
19
17
|
import { styles as styles$1, isIconComponent } from '@mirohq/design-system-base-icon';
|
|
20
18
|
|
|
21
19
|
const Context$1 = createContext({
|
|
@@ -461,25 +459,16 @@ const ScrollableContent = ({
|
|
|
461
459
|
const DropdownContext = createContext({});
|
|
462
460
|
const DropdownProvider = ({
|
|
463
461
|
children,
|
|
464
|
-
open: rootOpen,
|
|
465
462
|
...restProps
|
|
466
|
-
}) =>
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
open,
|
|
476
|
-
setOpen,
|
|
477
|
-
triggerRef
|
|
478
|
-
},
|
|
479
|
-
children
|
|
480
|
-
}
|
|
481
|
-
);
|
|
482
|
-
};
|
|
463
|
+
}) => /* @__PURE__ */ jsx(
|
|
464
|
+
DropdownContext.Provider,
|
|
465
|
+
{
|
|
466
|
+
value: {
|
|
467
|
+
...restProps
|
|
468
|
+
},
|
|
469
|
+
children
|
|
470
|
+
}
|
|
471
|
+
);
|
|
483
472
|
const useDropdownContext = () => useContext(DropdownContext);
|
|
484
473
|
|
|
485
474
|
const Content = React.forwardRef(
|
|
@@ -496,11 +485,10 @@ const Content = React.forwardRef(
|
|
|
496
485
|
containerSpacing = "medium",
|
|
497
486
|
overflow = "visible",
|
|
498
487
|
maxHeight,
|
|
499
|
-
onInteractOutside,
|
|
500
488
|
children,
|
|
501
489
|
...restProps
|
|
502
490
|
}, forwardRef) => {
|
|
503
|
-
const { direction
|
|
491
|
+
const { direction } = useDropdownContext();
|
|
504
492
|
const preventScrollOnFocus = (ref) => {
|
|
505
493
|
if (ref === null || "_autoScrollPrevented" in ref.focus) {
|
|
506
494
|
return;
|
|
@@ -533,12 +521,6 @@ const Content = React.forwardRef(
|
|
|
533
521
|
collisionPadding,
|
|
534
522
|
sticky,
|
|
535
523
|
hideWhenDetached,
|
|
536
|
-
onInteractOutside: (e) => {
|
|
537
|
-
if (e.target === triggerRef.current) {
|
|
538
|
-
e.preventDefault();
|
|
539
|
-
}
|
|
540
|
-
onInteractOutside == null ? void 0 : onInteractOutside(e);
|
|
541
|
-
},
|
|
542
524
|
children: /* @__PURE__ */ jsx(
|
|
543
525
|
ScrollableContent,
|
|
544
526
|
{
|
|
@@ -744,52 +726,17 @@ const StyledTrigger = styled(RadixDropdownMenu.Trigger, {
|
|
|
744
726
|
}
|
|
745
727
|
});
|
|
746
728
|
|
|
747
|
-
const Trigger = React.forwardRef(({ asChild = false, ...restProps }, forwardRef) => {
|
|
729
|
+
const Trigger = React.forwardRef(({ asChild = false, onClick, ...restProps }, forwardRef) => {
|
|
748
730
|
const ref = useRef(null);
|
|
749
|
-
const { setOpen, rootOpen, triggerRef } = useDropdownContext();
|
|
750
|
-
const { pressProps } = usePress({
|
|
751
|
-
onPress: () => {
|
|
752
|
-
if (rootOpen === void 0) {
|
|
753
|
-
setOpen((open) => !booleanify(open));
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
});
|
|
757
|
-
const elementProps = mergeProps(restProps, pressProps);
|
|
758
|
-
const onClickHandler = useCallback(
|
|
759
|
-
(e) => {
|
|
760
|
-
var _a, _b;
|
|
761
|
-
if ((e == null ? void 0 : e.nativeEvent) === void 0) {
|
|
762
|
-
console.error(
|
|
763
|
-
"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))
|
|
764
|
-
);
|
|
765
|
-
(_a = restProps.onClick) == null ? void 0 : _a.call(restProps, e);
|
|
766
|
-
return;
|
|
767
|
-
}
|
|
768
|
-
handleVirtualClick(e, ref);
|
|
769
|
-
(_b = elementProps.onClick) == null ? void 0 : _b.call(elementProps, e);
|
|
770
|
-
},
|
|
771
|
-
[restProps, elementProps]
|
|
772
|
-
);
|
|
773
731
|
return /* @__PURE__ */ jsx(
|
|
774
732
|
StyledTrigger,
|
|
775
733
|
{
|
|
776
|
-
...
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
onClickHandler(e);
|
|
781
|
-
}
|
|
782
|
-
(_a = elementProps.onPointerDown) == null ? void 0 : _a.call(elementProps, e);
|
|
783
|
-
},
|
|
784
|
-
onClick: onClickHandler,
|
|
785
|
-
onKeyDown: (e) => {
|
|
786
|
-
var _a;
|
|
787
|
-
if (!/^(Arrow|Tab|Escape)/.test(e.key)) {
|
|
788
|
-
e.preventDefault();
|
|
789
|
-
}
|
|
790
|
-
(_a = elementProps.onKeyDown) == null ? void 0 : _a.call(elementProps, e);
|
|
734
|
+
...restProps,
|
|
735
|
+
onClick: (e) => {
|
|
736
|
+
handleVirtualClick(e, ref);
|
|
737
|
+
onClick == null ? void 0 : onClick(e);
|
|
791
738
|
},
|
|
792
|
-
ref: mergeRefs([ref,
|
|
739
|
+
ref: mergeRefs([ref, forwardRef]),
|
|
793
740
|
unstyled: !asChild,
|
|
794
741
|
asChild
|
|
795
742
|
}
|
|
@@ -944,48 +891,36 @@ const Root = ({
|
|
|
944
891
|
defaultOpen = false,
|
|
945
892
|
direction,
|
|
946
893
|
interactOutside = false,
|
|
894
|
+
open,
|
|
947
895
|
onOpen,
|
|
948
896
|
onClose,
|
|
949
897
|
...restProps
|
|
950
898
|
}) => {
|
|
951
899
|
const { ignoreNextTooltip } = useBaseTooltipContext();
|
|
952
|
-
const { rootOpen, open, setOpen } = useDropdownContext();
|
|
953
900
|
const prevOpen = usePrevious(open);
|
|
954
901
|
useEffect(() => {
|
|
955
|
-
if (prevOpen
|
|
956
|
-
|
|
957
|
-
onOpen == null ? void 0 : onOpen();
|
|
958
|
-
} else {
|
|
959
|
-
if (prevOpen === true) {
|
|
960
|
-
ignoreNextTooltip();
|
|
961
|
-
}
|
|
962
|
-
onClose == null ? void 0 : onClose();
|
|
963
|
-
}
|
|
902
|
+
if (prevOpen === true && open === false) {
|
|
903
|
+
ignoreNextTooltip();
|
|
964
904
|
}
|
|
965
|
-
}, [open, prevOpen
|
|
905
|
+
}, [ignoreNextTooltip, open, prevOpen]);
|
|
966
906
|
return /* @__PURE__ */ jsx(
|
|
967
907
|
RadixDropdownMenu.Root,
|
|
968
908
|
{
|
|
969
909
|
...restProps,
|
|
970
910
|
dir: direction,
|
|
971
911
|
modal: interactOutside,
|
|
972
|
-
open
|
|
973
|
-
// use the root open state if it is defined
|
|
974
|
-
rootOpen != null ? rootOpen : defaultOpen && (prevOpen === void 0 || prevOpen === open) ? (
|
|
975
|
-
// only use defaultOpen in the first render then use the context open state
|
|
976
|
-
// 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
|
|
977
|
-
void 0
|
|
978
|
-
) : (
|
|
979
|
-
// otherwise, use the user open state
|
|
980
|
-
open
|
|
981
|
-
)
|
|
982
|
-
),
|
|
912
|
+
open,
|
|
983
913
|
defaultOpen,
|
|
984
|
-
onOpenChange:
|
|
914
|
+
onOpenChange: (newOpen) => {
|
|
915
|
+
if (!newOpen && open === void 0) {
|
|
916
|
+
ignoreNextTooltip();
|
|
917
|
+
}
|
|
918
|
+
newOpen ? onOpen == null ? void 0 : onOpen() : onClose == null ? void 0 : onClose();
|
|
919
|
+
}
|
|
985
920
|
}
|
|
986
921
|
);
|
|
987
922
|
};
|
|
988
|
-
const DropdownMenu = ({ direction = "ltr",
|
|
923
|
+
const DropdownMenu = ({ direction = "ltr", ...restProps }) => /* @__PURE__ */ jsx(DropdownProvider, { direction, children: /* @__PURE__ */ jsx(BaseTooltipProvider, { children: /* @__PURE__ */ jsx(Root, { direction, ...restProps }) }) });
|
|
989
924
|
DropdownMenu.CheckboxItem = CheckboxItem;
|
|
990
925
|
DropdownMenu.Content = Content;
|
|
991
926
|
DropdownMenu.Hotkey = Hotkey;
|