@hexdspace/react 0.1.35 → 0.1.37
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/index.d.ts +2 -1
- package/dist/index.js +86 -45
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -687,6 +687,7 @@ interface DropdownMenuProps extends VariantProps<typeof dropdownMenuContentVaria
|
|
|
687
687
|
children: React.ReactNode;
|
|
688
688
|
open?: boolean;
|
|
689
689
|
defaultOpen?: boolean;
|
|
690
|
+
keepMounted?: boolean;
|
|
690
691
|
onOpenChange?: (open: boolean) => void;
|
|
691
692
|
hoverOpen?: boolean;
|
|
692
693
|
hoverCloseDelayMs?: number;
|
|
@@ -703,7 +704,7 @@ interface DropdownMenuProps extends VariantProps<typeof dropdownMenuContentVaria
|
|
|
703
704
|
style?: React.CSSProperties;
|
|
704
705
|
contentProps?: DropdownMenuContentProps;
|
|
705
706
|
}
|
|
706
|
-
declare function DropdownMenu({ trigger, children, open, defaultOpen, onOpenChange, hoverOpen, hoverCloseDelayMs, modal, side, align, sideOffset, alignOffset, collisionPadding, portalContainer, ariaLabel, ariaLabelledBy, chrome, orientation, className, style, contentProps, }: DropdownMenuProps): react_jsx_runtime.JSX.Element;
|
|
707
|
+
declare function DropdownMenu({ trigger, children, open, defaultOpen, keepMounted, onOpenChange, hoverOpen, hoverCloseDelayMs, modal, side, align, sideOffset, alignOffset, collisionPadding, portalContainer, ariaLabel, ariaLabelledBy, chrome, orientation, className, style, contentProps, }: DropdownMenuProps): react_jsx_runtime.JSX.Element;
|
|
707
708
|
interface DropdownMenuItemProps extends React.ComponentPropsWithoutRef<typeof DropdownMenu$1.Item>, Omit<VariantProps<typeof dropdownMenuItemVariants>, 'orientation'> {
|
|
708
709
|
}
|
|
709
710
|
declare const DropdownMenuItem: React.ForwardRefExoticComponent<DropdownMenuItemProps & React.RefAttributes<HTMLDivElement>>;
|
package/dist/index.js
CHANGED
|
@@ -2884,6 +2884,7 @@ function DropdownMenu({
|
|
|
2884
2884
|
children,
|
|
2885
2885
|
open: open2,
|
|
2886
2886
|
defaultOpen,
|
|
2887
|
+
keepMounted = false,
|
|
2887
2888
|
onOpenChange,
|
|
2888
2889
|
hoverOpen = false,
|
|
2889
2890
|
hoverCloseDelayMs = 50,
|
|
@@ -2989,9 +2990,43 @@ function DropdownMenu({
|
|
|
2989
2990
|
);
|
|
2990
2991
|
const onPointerDownOutside = (event) => {
|
|
2991
2992
|
restContentProps.onPointerDownOutside?.(event);
|
|
2993
|
+
if (keepMounted) {
|
|
2994
|
+
const target = event.target;
|
|
2995
|
+
const isTriggerEvent = target instanceof Node && triggerRef.current?.contains(target);
|
|
2996
|
+
if (!resolvedOpen || isTriggerEvent) {
|
|
2997
|
+
event.preventDefault();
|
|
2998
|
+
}
|
|
2999
|
+
}
|
|
3000
|
+
};
|
|
3001
|
+
const keepMountedClassName = keepMounted && !resolvedOpen ? "pointer-events-none" : void 0;
|
|
3002
|
+
const initialMotionState = {
|
|
3003
|
+
opacity: 0,
|
|
3004
|
+
scale: 0.98,
|
|
3005
|
+
x: "var(--menu-x)",
|
|
3006
|
+
y: "var(--menu-y)"
|
|
3007
|
+
};
|
|
3008
|
+
const openMotionState = {
|
|
3009
|
+
opacity: 1,
|
|
3010
|
+
scale: 1,
|
|
3011
|
+
x: 0,
|
|
3012
|
+
y: 0
|
|
3013
|
+
};
|
|
3014
|
+
const closedMotionState = {
|
|
3015
|
+
opacity: 0,
|
|
3016
|
+
scale: 0.98,
|
|
3017
|
+
x: "var(--menu-x)",
|
|
3018
|
+
y: "var(--menu-y)"
|
|
2992
3019
|
};
|
|
3020
|
+
const motionEase = keepMounted ? resolvedOpen ? "easeOut" : "easeIn" : "easeOut";
|
|
2993
3021
|
const onInteractOutside = (event) => {
|
|
2994
3022
|
restContentProps.onInteractOutside?.(event);
|
|
3023
|
+
if (keepMounted) {
|
|
3024
|
+
const target = event.target;
|
|
3025
|
+
const isTriggerEvent = target instanceof Node && triggerRef.current?.contains(target);
|
|
3026
|
+
if (!resolvedOpen || isTriggerEvent) {
|
|
3027
|
+
event.preventDefault();
|
|
3028
|
+
}
|
|
3029
|
+
}
|
|
2995
3030
|
};
|
|
2996
3031
|
const resolvedContentProps = hoverOpen ? {
|
|
2997
3032
|
...restContentProps,
|
|
@@ -3013,53 +3048,55 @@ function DropdownMenu({
|
|
|
3013
3048
|
onInteractOutside
|
|
3014
3049
|
} : {
|
|
3015
3050
|
...restContentProps,
|
|
3016
|
-
onKeyDown: handleContentKeyDown
|
|
3051
|
+
onKeyDown: handleContentKeyDown,
|
|
3052
|
+
...keepMounted ? { onPointerDownOutside, onInteractOutside } : void 0
|
|
3017
3053
|
};
|
|
3054
|
+
const contentNode = /* @__PURE__ */ jsx19(
|
|
3055
|
+
DropdownMenuPrimitive.Content,
|
|
3056
|
+
{
|
|
3057
|
+
asChild: true,
|
|
3058
|
+
forceMount: true,
|
|
3059
|
+
side,
|
|
3060
|
+
align,
|
|
3061
|
+
sideOffset,
|
|
3062
|
+
alignOffset,
|
|
3063
|
+
collisionPadding,
|
|
3064
|
+
"aria-label": ariaLabelledBy ? void 0 : ariaLabel,
|
|
3065
|
+
"aria-labelledby": ariaLabelledBy,
|
|
3066
|
+
...resolvedContentProps,
|
|
3067
|
+
children: /* @__PURE__ */ jsx19(
|
|
3068
|
+
motion4.div,
|
|
3069
|
+
{
|
|
3070
|
+
"aria-hidden": keepMounted ? !resolvedOpen : void 0,
|
|
3071
|
+
className: cn(
|
|
3072
|
+
dropdownMenuContentVariants({ chrome, orientation }),
|
|
3073
|
+
keepMountedClassName,
|
|
3074
|
+
className,
|
|
3075
|
+
contentClassName
|
|
3076
|
+
),
|
|
3077
|
+
ref: composedContentRef,
|
|
3078
|
+
initial: initialMotionState,
|
|
3079
|
+
animate: keepMounted ? resolvedOpen ? openMotionState : closedMotionState : openMotionState,
|
|
3080
|
+
exit: keepMounted ? void 0 : {
|
|
3081
|
+
opacity: 0,
|
|
3082
|
+
scale: 0.98,
|
|
3083
|
+
x: "var(--menu-x)",
|
|
3084
|
+
y: "var(--menu-y)",
|
|
3085
|
+
transition: { duration: motionDuration, ease: "easeIn" }
|
|
3086
|
+
},
|
|
3087
|
+
transition: {
|
|
3088
|
+
duration: motionDuration,
|
|
3089
|
+
ease: motionEase
|
|
3090
|
+
},
|
|
3091
|
+
style: { ...style, ...contentStyle },
|
|
3092
|
+
children
|
|
3093
|
+
}
|
|
3094
|
+
)
|
|
3095
|
+
}
|
|
3096
|
+
);
|
|
3018
3097
|
return /* @__PURE__ */ jsx19(DropdownMenuOrientationContext.Provider, { value: resolvedItemsOrientation, children: /* @__PURE__ */ jsxs11(DropdownMenuPrimitive.Root, { open: resolvedOpen, onOpenChange: handleOpenChange, modal, children: [
|
|
3019
3098
|
/* @__PURE__ */ jsx19(DropdownMenuPrimitive.Trigger, { asChild: true, children: resolvedTrigger }),
|
|
3020
|
-
/* @__PURE__ */ jsx19(DropdownMenuPrimitive.Portal, { forceMount: true, container: portalContainer, children: /* @__PURE__ */ jsx19(AnimatePresence4, { children: resolvedOpen ?
|
|
3021
|
-
DropdownMenuPrimitive.Content,
|
|
3022
|
-
{
|
|
3023
|
-
asChild: true,
|
|
3024
|
-
forceMount: true,
|
|
3025
|
-
side,
|
|
3026
|
-
align,
|
|
3027
|
-
sideOffset,
|
|
3028
|
-
alignOffset,
|
|
3029
|
-
collisionPadding,
|
|
3030
|
-
"aria-label": ariaLabelledBy ? void 0 : ariaLabel,
|
|
3031
|
-
"aria-labelledby": ariaLabelledBy,
|
|
3032
|
-
...resolvedContentProps,
|
|
3033
|
-
children: /* @__PURE__ */ jsx19(
|
|
3034
|
-
motion4.div,
|
|
3035
|
-
{
|
|
3036
|
-
className: cn(
|
|
3037
|
-
dropdownMenuContentVariants({ chrome, orientation }),
|
|
3038
|
-
className,
|
|
3039
|
-
contentClassName
|
|
3040
|
-
),
|
|
3041
|
-
ref: composedContentRef,
|
|
3042
|
-
initial: {
|
|
3043
|
-
opacity: 0,
|
|
3044
|
-
scale: 0.98,
|
|
3045
|
-
x: "var(--menu-x)",
|
|
3046
|
-
y: "var(--menu-y)"
|
|
3047
|
-
},
|
|
3048
|
-
animate: { opacity: 1, scale: 1, x: 0, y: 0 },
|
|
3049
|
-
exit: {
|
|
3050
|
-
opacity: 0,
|
|
3051
|
-
scale: 0.98,
|
|
3052
|
-
x: "var(--menu-x)",
|
|
3053
|
-
y: "var(--menu-y)",
|
|
3054
|
-
transition: { duration: motionDuration, ease: "easeIn" }
|
|
3055
|
-
},
|
|
3056
|
-
transition: { duration: motionDuration, ease: "easeOut" },
|
|
3057
|
-
style: { ...style, ...contentStyle },
|
|
3058
|
-
children
|
|
3059
|
-
}
|
|
3060
|
-
)
|
|
3061
|
-
}
|
|
3062
|
-
) : null }) })
|
|
3099
|
+
/* @__PURE__ */ jsx19(DropdownMenuPrimitive.Portal, { forceMount: true, container: portalContainer, children: keepMounted ? contentNode : /* @__PURE__ */ jsx19(AnimatePresence4, { children: resolvedOpen ? contentNode : null }) })
|
|
3063
3100
|
] }) });
|
|
3064
3101
|
}
|
|
3065
3102
|
var DropdownMenuItem = React13.forwardRef(
|
|
@@ -3076,7 +3113,11 @@ var DropdownMenuItem = React13.forwardRef(
|
|
|
3076
3113
|
}
|
|
3077
3114
|
);
|
|
3078
3115
|
DropdownMenuItem.displayName = "DropdownMenuItem";
|
|
3079
|
-
var DropdownMenuSeparator = React13.forwardRef(({ className, ...props }, ref) =>
|
|
3116
|
+
var DropdownMenuSeparator = React13.forwardRef(({ className, ...props }, ref) => {
|
|
3117
|
+
const orientation = React13.useContext(DropdownMenuOrientationContext);
|
|
3118
|
+
const orientationClassName = orientation === "horizontal" ? "mx-1 w-px self-stretch bg-(--divider)" : "my-1 h-px bg-(--divider)";
|
|
3119
|
+
return /* @__PURE__ */ jsx19(DropdownMenuPrimitive.Separator, { ref, className: cn(orientationClassName, className), ...props });
|
|
3120
|
+
});
|
|
3080
3121
|
DropdownMenuSeparator.displayName = "DropdownMenuSeparator";
|
|
3081
3122
|
|
|
3082
3123
|
// src/ui/components/Kbd.tsx
|