1781 lines
70 KiB
JavaScript
1781 lines
70 KiB
JavaScript
"use client";
|
|
import {
|
|
FocusScope,
|
|
RemoveScrollBar,
|
|
__assign,
|
|
__rest,
|
|
__spreadArray,
|
|
createSidecarMedium,
|
|
exportSidecar,
|
|
fullWidthClassName,
|
|
hideOthers,
|
|
styleSingleton,
|
|
useMergeRefs,
|
|
zeroRightClassName
|
|
} from "./chunk-QYKEMCE4.js";
|
|
import {
|
|
Item,
|
|
Root,
|
|
createRovingFocusGroupScope
|
|
} from "./chunk-ENGL2KVA.js";
|
|
import {
|
|
createCollection
|
|
} from "./chunk-6SPNF6KQ.js";
|
|
import {
|
|
Anchor,
|
|
Arrow,
|
|
Content,
|
|
Root2,
|
|
createPopperScope
|
|
} from "./chunk-6UE7W7QM.js";
|
|
import "./chunk-MR3TNHRB.js";
|
|
import {
|
|
useEscapeKeydown
|
|
} from "./chunk-J3JCCWF4.js";
|
|
import {
|
|
useId
|
|
} from "./chunk-5I6CIHEW.js";
|
|
import {
|
|
useControllableState
|
|
} from "./chunk-H4VE5LV5.js";
|
|
import {
|
|
useDirection
|
|
} from "./chunk-O2UA4OQB.js";
|
|
import {
|
|
Presence
|
|
} from "./chunk-TZDCYJOT.js";
|
|
import {
|
|
createContextScope
|
|
} from "./chunk-OAV3HHWW.js";
|
|
import {
|
|
composeEventHandlers,
|
|
useCallbackRef,
|
|
useLayoutEffect2
|
|
} from "./chunk-SZRZRZSM.js";
|
|
import {
|
|
Primitive,
|
|
dispatchDiscreteCustomEvent
|
|
} from "./chunk-H55D7VYG.js";
|
|
import {
|
|
require_react_dom
|
|
} from "./chunk-R6S4VRB5.js";
|
|
import {
|
|
Slot,
|
|
composeRefs,
|
|
useComposedRefs
|
|
} from "./chunk-4WIT4MX7.js";
|
|
import {
|
|
require_jsx_runtime
|
|
} from "./chunk-S77I6LSE.js";
|
|
import {
|
|
require_react
|
|
} from "./chunk-3TFVT2CW.js";
|
|
import {
|
|
__toESM
|
|
} from "./chunk-4MBMRILA.js";
|
|
|
|
// node_modules/@radix-ui/react-dropdown-menu/dist/index.mjs
|
|
var React8 = __toESM(require_react(), 1);
|
|
|
|
// node_modules/@radix-ui/react-menu/dist/index.mjs
|
|
var React7 = __toESM(require_react(), 1);
|
|
|
|
// node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs
|
|
var React = __toESM(require_react(), 1);
|
|
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
var DISMISSABLE_LAYER_NAME = "DismissableLayer";
|
|
var CONTEXT_UPDATE = "dismissableLayer.update";
|
|
var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
|
|
var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
|
|
var originalBodyPointerEvents;
|
|
var DismissableLayerContext = React.createContext({
|
|
layers: /* @__PURE__ */ new Set(),
|
|
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
|
|
branches: /* @__PURE__ */ new Set()
|
|
});
|
|
var DismissableLayer = React.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const {
|
|
disableOutsidePointerEvents = false,
|
|
onEscapeKeyDown,
|
|
onPointerDownOutside,
|
|
onFocusOutside,
|
|
onInteractOutside,
|
|
onDismiss,
|
|
...layerProps
|
|
} = props;
|
|
const context = React.useContext(DismissableLayerContext);
|
|
const [node, setNode] = React.useState(null);
|
|
const ownerDocument = (node == null ? void 0 : node.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document);
|
|
const [, force] = React.useState({});
|
|
const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
|
|
const layers = Array.from(context.layers);
|
|
const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
|
|
const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
|
|
const index = node ? layers.indexOf(node) : -1;
|
|
const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
|
|
const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
|
|
const pointerDownOutside = usePointerDownOutside((event) => {
|
|
const target = event.target;
|
|
const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
|
|
onPointerDownOutside == null ? void 0 : onPointerDownOutside(event);
|
|
onInteractOutside == null ? void 0 : onInteractOutside(event);
|
|
if (!event.defaultPrevented) onDismiss == null ? void 0 : onDismiss();
|
|
}, ownerDocument);
|
|
const focusOutside = useFocusOutside((event) => {
|
|
const target = event.target;
|
|
const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
if (isFocusInBranch) return;
|
|
onFocusOutside == null ? void 0 : onFocusOutside(event);
|
|
onInteractOutside == null ? void 0 : onInteractOutside(event);
|
|
if (!event.defaultPrevented) onDismiss == null ? void 0 : onDismiss();
|
|
}, ownerDocument);
|
|
useEscapeKeydown((event) => {
|
|
const isHighestLayer = index === context.layers.size - 1;
|
|
if (!isHighestLayer) return;
|
|
onEscapeKeyDown == null ? void 0 : onEscapeKeyDown(event);
|
|
if (!event.defaultPrevented && onDismiss) {
|
|
event.preventDefault();
|
|
onDismiss();
|
|
}
|
|
}, ownerDocument);
|
|
React.useEffect(() => {
|
|
if (!node) return;
|
|
if (disableOutsidePointerEvents) {
|
|
if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
|
|
originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
|
|
ownerDocument.body.style.pointerEvents = "none";
|
|
}
|
|
context.layersWithOutsidePointerEventsDisabled.add(node);
|
|
}
|
|
context.layers.add(node);
|
|
dispatchUpdate();
|
|
return () => {
|
|
if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
|
|
ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
|
|
}
|
|
};
|
|
}, [node, ownerDocument, disableOutsidePointerEvents, context]);
|
|
React.useEffect(() => {
|
|
return () => {
|
|
if (!node) return;
|
|
context.layers.delete(node);
|
|
context.layersWithOutsidePointerEventsDisabled.delete(node);
|
|
dispatchUpdate();
|
|
};
|
|
}, [node, context]);
|
|
React.useEffect(() => {
|
|
const handleUpdate = () => force({});
|
|
document.addEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
}, []);
|
|
return (0, import_jsx_runtime.jsx)(
|
|
Primitive.div,
|
|
{
|
|
...layerProps,
|
|
ref: composedRefs,
|
|
style: {
|
|
pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
|
|
...props.style
|
|
},
|
|
onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
|
|
onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
|
|
onPointerDownCapture: composeEventHandlers(
|
|
props.onPointerDownCapture,
|
|
pointerDownOutside.onPointerDownCapture
|
|
)
|
|
}
|
|
);
|
|
}
|
|
);
|
|
DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
|
|
var BRANCH_NAME = "DismissableLayerBranch";
|
|
var DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {
|
|
const context = React.useContext(DismissableLayerContext);
|
|
const ref = React.useRef(null);
|
|
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
React.useEffect(() => {
|
|
const node = ref.current;
|
|
if (node) {
|
|
context.branches.add(node);
|
|
return () => {
|
|
context.branches.delete(node);
|
|
};
|
|
}
|
|
}, [context.branches]);
|
|
return (0, import_jsx_runtime.jsx)(Primitive.div, { ...props, ref: composedRefs });
|
|
});
|
|
DismissableLayerBranch.displayName = BRANCH_NAME;
|
|
function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
|
|
const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
|
|
const isPointerInsideReactTreeRef = React.useRef(false);
|
|
const handleClickRef = React.useRef(() => {
|
|
});
|
|
React.useEffect(() => {
|
|
const handlePointerDown = (event) => {
|
|
if (event.target && !isPointerInsideReactTreeRef.current) {
|
|
let handleAndDispatchPointerDownOutsideEvent2 = function() {
|
|
handleAndDispatchCustomEvent(
|
|
POINTER_DOWN_OUTSIDE,
|
|
handlePointerDownOutside,
|
|
eventDetail,
|
|
{ discrete: true }
|
|
);
|
|
};
|
|
var handleAndDispatchPointerDownOutsideEvent = handleAndDispatchPointerDownOutsideEvent2;
|
|
const eventDetail = { originalEvent: event };
|
|
if (event.pointerType === "touch") {
|
|
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
|
|
ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
|
|
} else {
|
|
handleAndDispatchPointerDownOutsideEvent2();
|
|
}
|
|
} else {
|
|
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
}
|
|
isPointerInsideReactTreeRef.current = false;
|
|
};
|
|
const timerId = window.setTimeout(() => {
|
|
ownerDocument.addEventListener("pointerdown", handlePointerDown);
|
|
}, 0);
|
|
return () => {
|
|
window.clearTimeout(timerId);
|
|
ownerDocument.removeEventListener("pointerdown", handlePointerDown);
|
|
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
};
|
|
}, [ownerDocument, handlePointerDownOutside]);
|
|
return {
|
|
// ensures we check React component tree (not just DOM tree)
|
|
onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
|
|
};
|
|
}
|
|
function useFocusOutside(onFocusOutside, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
|
|
const handleFocusOutside = useCallbackRef(onFocusOutside);
|
|
const isFocusInsideReactTreeRef = React.useRef(false);
|
|
React.useEffect(() => {
|
|
const handleFocus = (event) => {
|
|
if (event.target && !isFocusInsideReactTreeRef.current) {
|
|
const eventDetail = { originalEvent: event };
|
|
handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
|
|
discrete: false
|
|
});
|
|
}
|
|
};
|
|
ownerDocument.addEventListener("focusin", handleFocus);
|
|
return () => ownerDocument.removeEventListener("focusin", handleFocus);
|
|
}, [ownerDocument, handleFocusOutside]);
|
|
return {
|
|
onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
|
|
onBlurCapture: () => isFocusInsideReactTreeRef.current = false
|
|
};
|
|
}
|
|
function dispatchUpdate() {
|
|
const event = new CustomEvent(CONTEXT_UPDATE);
|
|
document.dispatchEvent(event);
|
|
}
|
|
function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
const target = detail.originalEvent.target;
|
|
const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
|
|
if (handler) target.addEventListener(name, handler, { once: true });
|
|
if (discrete) {
|
|
dispatchDiscreteCustomEvent(target, event);
|
|
} else {
|
|
target.dispatchEvent(event);
|
|
}
|
|
}
|
|
|
|
// node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-focus-guards/dist/index.mjs
|
|
var React2 = __toESM(require_react(), 1);
|
|
var count = 0;
|
|
function useFocusGuards() {
|
|
React2.useEffect(() => {
|
|
const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
|
|
document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard());
|
|
document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard());
|
|
count++;
|
|
return () => {
|
|
if (count === 1) {
|
|
document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
|
|
}
|
|
count--;
|
|
};
|
|
}, []);
|
|
}
|
|
function createFocusGuard() {
|
|
const element = document.createElement("span");
|
|
element.setAttribute("data-radix-focus-guard", "");
|
|
element.tabIndex = 0;
|
|
element.style.cssText = "outline: none; opacity: 0; position: fixed; pointer-events: none";
|
|
return element;
|
|
}
|
|
|
|
// node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-portal/dist/index.mjs
|
|
var React3 = __toESM(require_react(), 1);
|
|
var import_react_dom = __toESM(require_react_dom(), 1);
|
|
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
|
|
var PORTAL_NAME = "Portal";
|
|
var Portal = React3.forwardRef((props, forwardedRef) => {
|
|
var _a;
|
|
const { container: containerProp, ...portalProps } = props;
|
|
const [mounted, setMounted] = React3.useState(false);
|
|
useLayoutEffect2(() => setMounted(true), []);
|
|
const container = containerProp || mounted && ((_a = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : _a.body);
|
|
return container ? import_react_dom.default.createPortal((0, import_jsx_runtime2.jsx)(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
|
|
});
|
|
Portal.displayName = PORTAL_NAME;
|
|
|
|
// node_modules/@radix-ui/react-menu/node_modules/react-remove-scroll/dist/es2015/Combination.js
|
|
var React6 = __toESM(require_react());
|
|
|
|
// node_modules/@radix-ui/react-menu/node_modules/react-remove-scroll/dist/es2015/UI.js
|
|
var React4 = __toESM(require_react());
|
|
|
|
// node_modules/@radix-ui/react-menu/node_modules/react-remove-scroll/dist/es2015/medium.js
|
|
var effectCar = createSidecarMedium();
|
|
|
|
// node_modules/@radix-ui/react-menu/node_modules/react-remove-scroll/dist/es2015/UI.js
|
|
var nothing = function() {
|
|
return;
|
|
};
|
|
var RemoveScroll = React4.forwardRef(function(props, parentRef) {
|
|
var ref = React4.useRef(null);
|
|
var _a = React4.useState({
|
|
onScrollCapture: nothing,
|
|
onWheelCapture: nothing,
|
|
onTouchMoveCapture: nothing
|
|
}), callbacks = _a[0], setCallbacks = _a[1];
|
|
var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? "div" : _b, gapMode = props.gapMode, rest = __rest(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
|
|
var SideCar = sideCar;
|
|
var containerRef = useMergeRefs([ref, parentRef]);
|
|
var containerProps = __assign(__assign({}, rest), callbacks);
|
|
return React4.createElement(
|
|
React4.Fragment,
|
|
null,
|
|
enabled && React4.createElement(SideCar, { sideCar: effectCar, removeScrollBar, shards, noIsolation, inert, setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode }),
|
|
forwardProps ? React4.cloneElement(React4.Children.only(children), __assign(__assign({}, containerProps), { ref: containerRef })) : React4.createElement(Container, __assign({}, containerProps, { className, ref: containerRef }), children)
|
|
);
|
|
});
|
|
RemoveScroll.defaultProps = {
|
|
enabled: true,
|
|
removeScrollBar: true,
|
|
inert: false
|
|
};
|
|
RemoveScroll.classNames = {
|
|
fullWidth: fullWidthClassName,
|
|
zeroRight: zeroRightClassName
|
|
};
|
|
|
|
// node_modules/@radix-ui/react-menu/node_modules/react-remove-scroll/dist/es2015/SideEffect.js
|
|
var React5 = __toESM(require_react());
|
|
|
|
// node_modules/@radix-ui/react-menu/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js
|
|
var passiveSupported = false;
|
|
if (typeof window !== "undefined") {
|
|
try {
|
|
options = Object.defineProperty({}, "passive", {
|
|
get: function() {
|
|
passiveSupported = true;
|
|
return true;
|
|
}
|
|
});
|
|
window.addEventListener("test", options, options);
|
|
window.removeEventListener("test", options, options);
|
|
} catch (err) {
|
|
passiveSupported = false;
|
|
}
|
|
}
|
|
var options;
|
|
var nonPassive = passiveSupported ? { passive: false } : false;
|
|
|
|
// node_modules/@radix-ui/react-menu/node_modules/react-remove-scroll/dist/es2015/handleScroll.js
|
|
var alwaysContainsScroll = function(node) {
|
|
return node.tagName === "TEXTAREA";
|
|
};
|
|
var elementCanBeScrolled = function(node, overflow) {
|
|
var styles = window.getComputedStyle(node);
|
|
return (
|
|
// not-not-scrollable
|
|
styles[overflow] !== "hidden" && // contains scroll inside self
|
|
!(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === "visible")
|
|
);
|
|
};
|
|
var elementCouldBeVScrolled = function(node) {
|
|
return elementCanBeScrolled(node, "overflowY");
|
|
};
|
|
var elementCouldBeHScrolled = function(node) {
|
|
return elementCanBeScrolled(node, "overflowX");
|
|
};
|
|
var locationCouldBeScrolled = function(axis, node) {
|
|
var ownerDocument = node.ownerDocument;
|
|
var current = node;
|
|
do {
|
|
if (typeof ShadowRoot !== "undefined" && current instanceof ShadowRoot) {
|
|
current = current.host;
|
|
}
|
|
var isScrollable = elementCouldBeScrolled(axis, current);
|
|
if (isScrollable) {
|
|
var _a = getScrollVariables(axis, current), s = _a[1], d = _a[2];
|
|
if (s > d) {
|
|
return true;
|
|
}
|
|
}
|
|
current = current.parentNode;
|
|
} while (current && current !== ownerDocument.body);
|
|
return false;
|
|
};
|
|
var getVScrollVariables = function(_a) {
|
|
var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
|
|
return [
|
|
scrollTop,
|
|
scrollHeight,
|
|
clientHeight
|
|
];
|
|
};
|
|
var getHScrollVariables = function(_a) {
|
|
var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
|
|
return [
|
|
scrollLeft,
|
|
scrollWidth,
|
|
clientWidth
|
|
];
|
|
};
|
|
var elementCouldBeScrolled = function(axis, node) {
|
|
return axis === "v" ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
|
|
};
|
|
var getScrollVariables = function(axis, node) {
|
|
return axis === "v" ? getVScrollVariables(node) : getHScrollVariables(node);
|
|
};
|
|
var getDirectionFactor = function(axis, direction) {
|
|
return axis === "h" && direction === "rtl" ? -1 : 1;
|
|
};
|
|
var handleScroll = function(axis, endTarget, event, sourceDelta, noOverscroll) {
|
|
var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
|
|
var delta = directionFactor * sourceDelta;
|
|
var target = event.target;
|
|
var targetInLock = endTarget.contains(target);
|
|
var shouldCancelScroll = false;
|
|
var isDeltaPositive = delta > 0;
|
|
var availableScroll = 0;
|
|
var availableScrollTop = 0;
|
|
do {
|
|
var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2];
|
|
var elementScroll = scroll_1 - capacity - directionFactor * position;
|
|
if (position || elementScroll) {
|
|
if (elementCouldBeScrolled(axis, target)) {
|
|
availableScroll += elementScroll;
|
|
availableScrollTop += position;
|
|
}
|
|
}
|
|
if (target instanceof ShadowRoot) {
|
|
target = target.host;
|
|
} else {
|
|
target = target.parentNode;
|
|
}
|
|
} while (
|
|
// portaled content
|
|
!targetInLock && target !== document.body || // self content
|
|
targetInLock && (endTarget.contains(target) || endTarget === target)
|
|
);
|
|
if (isDeltaPositive && (noOverscroll && Math.abs(availableScroll) < 1 || !noOverscroll && delta > availableScroll)) {
|
|
shouldCancelScroll = true;
|
|
} else if (!isDeltaPositive && (noOverscroll && Math.abs(availableScrollTop) < 1 || !noOverscroll && -delta > availableScrollTop)) {
|
|
shouldCancelScroll = true;
|
|
}
|
|
return shouldCancelScroll;
|
|
};
|
|
|
|
// node_modules/@radix-ui/react-menu/node_modules/react-remove-scroll/dist/es2015/SideEffect.js
|
|
var getTouchXY = function(event) {
|
|
return "changedTouches" in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
|
|
};
|
|
var getDeltaXY = function(event) {
|
|
return [event.deltaX, event.deltaY];
|
|
};
|
|
var extractRef = function(ref) {
|
|
return ref && "current" in ref ? ref.current : ref;
|
|
};
|
|
var deltaCompare = function(x, y) {
|
|
return x[0] === y[0] && x[1] === y[1];
|
|
};
|
|
var generateStyle = function(id) {
|
|
return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n");
|
|
};
|
|
var idCounter = 0;
|
|
var lockStack = [];
|
|
function RemoveScrollSideCar(props) {
|
|
var shouldPreventQueue = React5.useRef([]);
|
|
var touchStartRef = React5.useRef([0, 0]);
|
|
var activeAxis = React5.useRef();
|
|
var id = React5.useState(idCounter++)[0];
|
|
var Style = React5.useState(styleSingleton)[0];
|
|
var lastProps = React5.useRef(props);
|
|
React5.useEffect(function() {
|
|
lastProps.current = props;
|
|
}, [props]);
|
|
React5.useEffect(function() {
|
|
if (props.inert) {
|
|
document.body.classList.add("block-interactivity-".concat(id));
|
|
var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
|
|
allow_1.forEach(function(el) {
|
|
return el.classList.add("allow-interactivity-".concat(id));
|
|
});
|
|
return function() {
|
|
document.body.classList.remove("block-interactivity-".concat(id));
|
|
allow_1.forEach(function(el) {
|
|
return el.classList.remove("allow-interactivity-".concat(id));
|
|
});
|
|
};
|
|
}
|
|
return;
|
|
}, [props.inert, props.lockRef.current, props.shards]);
|
|
var shouldCancelEvent = React5.useCallback(function(event, parent) {
|
|
if ("touches" in event && event.touches.length === 2) {
|
|
return !lastProps.current.allowPinchZoom;
|
|
}
|
|
var touch = getTouchXY(event);
|
|
var touchStart = touchStartRef.current;
|
|
var deltaX = "deltaX" in event ? event.deltaX : touchStart[0] - touch[0];
|
|
var deltaY = "deltaY" in event ? event.deltaY : touchStart[1] - touch[1];
|
|
var currentAxis;
|
|
var target = event.target;
|
|
var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? "h" : "v";
|
|
if ("touches" in event && moveDirection === "h" && target.type === "range") {
|
|
return false;
|
|
}
|
|
var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
|
|
if (!canBeScrolledInMainDirection) {
|
|
return true;
|
|
}
|
|
if (canBeScrolledInMainDirection) {
|
|
currentAxis = moveDirection;
|
|
} else {
|
|
currentAxis = moveDirection === "v" ? "h" : "v";
|
|
canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
|
|
}
|
|
if (!canBeScrolledInMainDirection) {
|
|
return false;
|
|
}
|
|
if (!activeAxis.current && "changedTouches" in event && (deltaX || deltaY)) {
|
|
activeAxis.current = currentAxis;
|
|
}
|
|
if (!currentAxis) {
|
|
return true;
|
|
}
|
|
var cancelingAxis = activeAxis.current || currentAxis;
|
|
return handleScroll(cancelingAxis, parent, event, cancelingAxis === "h" ? deltaX : deltaY, true);
|
|
}, []);
|
|
var shouldPrevent = React5.useCallback(function(_event) {
|
|
var event = _event;
|
|
if (!lockStack.length || lockStack[lockStack.length - 1] !== Style) {
|
|
return;
|
|
}
|
|
var delta = "deltaY" in event ? getDeltaXY(event) : getTouchXY(event);
|
|
var sourceEvent = shouldPreventQueue.current.filter(function(e) {
|
|
return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta);
|
|
})[0];
|
|
if (sourceEvent && sourceEvent.should) {
|
|
if (event.cancelable) {
|
|
event.preventDefault();
|
|
}
|
|
return;
|
|
}
|
|
if (!sourceEvent) {
|
|
var shardNodes = (lastProps.current.shards || []).map(extractRef).filter(Boolean).filter(function(node) {
|
|
return node.contains(event.target);
|
|
});
|
|
var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
|
|
if (shouldStop) {
|
|
if (event.cancelable) {
|
|
event.preventDefault();
|
|
}
|
|
}
|
|
}
|
|
}, []);
|
|
var shouldCancel = React5.useCallback(function(name, delta, target, should) {
|
|
var event = { name, delta, target, should, shadowParent: getOutermostShadowParent(target) };
|
|
shouldPreventQueue.current.push(event);
|
|
setTimeout(function() {
|
|
shouldPreventQueue.current = shouldPreventQueue.current.filter(function(e) {
|
|
return e !== event;
|
|
});
|
|
}, 1);
|
|
}, []);
|
|
var scrollTouchStart = React5.useCallback(function(event) {
|
|
touchStartRef.current = getTouchXY(event);
|
|
activeAxis.current = void 0;
|
|
}, []);
|
|
var scrollWheel = React5.useCallback(function(event) {
|
|
shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
|
}, []);
|
|
var scrollTouchMove = React5.useCallback(function(event) {
|
|
shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
|
}, []);
|
|
React5.useEffect(function() {
|
|
lockStack.push(Style);
|
|
props.setCallbacks({
|
|
onScrollCapture: scrollWheel,
|
|
onWheelCapture: scrollWheel,
|
|
onTouchMoveCapture: scrollTouchMove
|
|
});
|
|
document.addEventListener("wheel", shouldPrevent, nonPassive);
|
|
document.addEventListener("touchmove", shouldPrevent, nonPassive);
|
|
document.addEventListener("touchstart", scrollTouchStart, nonPassive);
|
|
return function() {
|
|
lockStack = lockStack.filter(function(inst) {
|
|
return inst !== Style;
|
|
});
|
|
document.removeEventListener("wheel", shouldPrevent, nonPassive);
|
|
document.removeEventListener("touchmove", shouldPrevent, nonPassive);
|
|
document.removeEventListener("touchstart", scrollTouchStart, nonPassive);
|
|
};
|
|
}, []);
|
|
var removeScrollBar = props.removeScrollBar, inert = props.inert;
|
|
return React5.createElement(
|
|
React5.Fragment,
|
|
null,
|
|
inert ? React5.createElement(Style, { styles: generateStyle(id) }) : null,
|
|
removeScrollBar ? React5.createElement(RemoveScrollBar, { gapMode: props.gapMode }) : null
|
|
);
|
|
}
|
|
function getOutermostShadowParent(node) {
|
|
var shadowParent = null;
|
|
while (node !== null) {
|
|
if (node instanceof ShadowRoot) {
|
|
shadowParent = node.host;
|
|
node = node.host;
|
|
}
|
|
node = node.parentNode;
|
|
}
|
|
return shadowParent;
|
|
}
|
|
|
|
// node_modules/@radix-ui/react-menu/node_modules/react-remove-scroll/dist/es2015/sidecar.js
|
|
var sidecar_default = exportSidecar(effectCar, RemoveScrollSideCar);
|
|
|
|
// node_modules/@radix-ui/react-menu/node_modules/react-remove-scroll/dist/es2015/Combination.js
|
|
var ReactRemoveScroll = React6.forwardRef(function(props, ref) {
|
|
return React6.createElement(RemoveScroll, __assign({}, props, { ref, sideCar: sidecar_default }));
|
|
});
|
|
ReactRemoveScroll.classNames = RemoveScroll.classNames;
|
|
var Combination_default = ReactRemoveScroll;
|
|
|
|
// node_modules/@radix-ui/react-menu/dist/index.mjs
|
|
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
|
|
var SELECTION_KEYS = ["Enter", " "];
|
|
var FIRST_KEYS = ["ArrowDown", "PageUp", "Home"];
|
|
var LAST_KEYS = ["ArrowUp", "PageDown", "End"];
|
|
var FIRST_LAST_KEYS = [...FIRST_KEYS, ...LAST_KEYS];
|
|
var SUB_OPEN_KEYS = {
|
|
ltr: [...SELECTION_KEYS, "ArrowRight"],
|
|
rtl: [...SELECTION_KEYS, "ArrowLeft"]
|
|
};
|
|
var SUB_CLOSE_KEYS = {
|
|
ltr: ["ArrowLeft"],
|
|
rtl: ["ArrowRight"]
|
|
};
|
|
var MENU_NAME = "Menu";
|
|
var [Collection, useCollection, createCollectionScope] = createCollection(MENU_NAME);
|
|
var [createMenuContext, createMenuScope] = createContextScope(MENU_NAME, [
|
|
createCollectionScope,
|
|
createPopperScope,
|
|
createRovingFocusGroupScope
|
|
]);
|
|
var usePopperScope = createPopperScope();
|
|
var useRovingFocusGroupScope = createRovingFocusGroupScope();
|
|
var [MenuProvider, useMenuContext] = createMenuContext(MENU_NAME);
|
|
var [MenuRootProvider, useMenuRootContext] = createMenuContext(MENU_NAME);
|
|
var Menu = (props) => {
|
|
const { __scopeMenu, open = false, children, dir, onOpenChange, modal = true } = props;
|
|
const popperScope = usePopperScope(__scopeMenu);
|
|
const [content, setContent] = React7.useState(null);
|
|
const isUsingKeyboardRef = React7.useRef(false);
|
|
const handleOpenChange = useCallbackRef(onOpenChange);
|
|
const direction = useDirection(dir);
|
|
React7.useEffect(() => {
|
|
const handleKeyDown = () => {
|
|
isUsingKeyboardRef.current = true;
|
|
document.addEventListener("pointerdown", handlePointer, { capture: true, once: true });
|
|
document.addEventListener("pointermove", handlePointer, { capture: true, once: true });
|
|
};
|
|
const handlePointer = () => isUsingKeyboardRef.current = false;
|
|
document.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
return () => {
|
|
document.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
document.removeEventListener("pointerdown", handlePointer, { capture: true });
|
|
document.removeEventListener("pointermove", handlePointer, { capture: true });
|
|
};
|
|
}, []);
|
|
return (0, import_jsx_runtime3.jsx)(Root2, { ...popperScope, children: (0, import_jsx_runtime3.jsx)(
|
|
MenuProvider,
|
|
{
|
|
scope: __scopeMenu,
|
|
open,
|
|
onOpenChange: handleOpenChange,
|
|
content,
|
|
onContentChange: setContent,
|
|
children: (0, import_jsx_runtime3.jsx)(
|
|
MenuRootProvider,
|
|
{
|
|
scope: __scopeMenu,
|
|
onClose: React7.useCallback(() => handleOpenChange(false), [handleOpenChange]),
|
|
isUsingKeyboardRef,
|
|
dir: direction,
|
|
modal,
|
|
children
|
|
}
|
|
)
|
|
}
|
|
) });
|
|
};
|
|
Menu.displayName = MENU_NAME;
|
|
var ANCHOR_NAME = "MenuAnchor";
|
|
var MenuAnchor = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeMenu, ...anchorProps } = props;
|
|
const popperScope = usePopperScope(__scopeMenu);
|
|
return (0, import_jsx_runtime3.jsx)(Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });
|
|
}
|
|
);
|
|
MenuAnchor.displayName = ANCHOR_NAME;
|
|
var PORTAL_NAME2 = "MenuPortal";
|
|
var [PortalProvider, usePortalContext] = createMenuContext(PORTAL_NAME2, {
|
|
forceMount: void 0
|
|
});
|
|
var MenuPortal = (props) => {
|
|
const { __scopeMenu, forceMount, children, container } = props;
|
|
const context = useMenuContext(PORTAL_NAME2, __scopeMenu);
|
|
return (0, import_jsx_runtime3.jsx)(PortalProvider, { scope: __scopeMenu, forceMount, children: (0, import_jsx_runtime3.jsx)(Presence, { present: forceMount || context.open, children: (0, import_jsx_runtime3.jsx)(Portal, { asChild: true, container, children }) }) });
|
|
};
|
|
MenuPortal.displayName = PORTAL_NAME2;
|
|
var CONTENT_NAME = "MenuContent";
|
|
var [MenuContentProvider, useMenuContentContext] = createMenuContext(CONTENT_NAME);
|
|
var MenuContent = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeMenu);
|
|
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
const context = useMenuContext(CONTENT_NAME, props.__scopeMenu);
|
|
const rootContext = useMenuRootContext(CONTENT_NAME, props.__scopeMenu);
|
|
return (0, import_jsx_runtime3.jsx)(Collection.Provider, { scope: props.__scopeMenu, children: (0, import_jsx_runtime3.jsx)(Presence, { present: forceMount || context.open, children: (0, import_jsx_runtime3.jsx)(Collection.Slot, { scope: props.__scopeMenu, children: rootContext.modal ? (0, import_jsx_runtime3.jsx)(MenuRootContentModal, { ...contentProps, ref: forwardedRef }) : (0, import_jsx_runtime3.jsx)(MenuRootContentNonModal, { ...contentProps, ref: forwardedRef }) }) }) });
|
|
}
|
|
);
|
|
var MenuRootContentModal = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const context = useMenuContext(CONTENT_NAME, props.__scopeMenu);
|
|
const ref = React7.useRef(null);
|
|
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
React7.useEffect(() => {
|
|
const content = ref.current;
|
|
if (content) return hideOthers(content);
|
|
}, []);
|
|
return (0, import_jsx_runtime3.jsx)(
|
|
MenuContentImpl,
|
|
{
|
|
...props,
|
|
ref: composedRefs,
|
|
trapFocus: context.open,
|
|
disableOutsidePointerEvents: context.open,
|
|
disableOutsideScroll: true,
|
|
onFocusOutside: composeEventHandlers(
|
|
props.onFocusOutside,
|
|
(event) => event.preventDefault(),
|
|
{ checkForDefaultPrevented: false }
|
|
),
|
|
onDismiss: () => context.onOpenChange(false)
|
|
}
|
|
);
|
|
}
|
|
);
|
|
var MenuRootContentNonModal = React7.forwardRef((props, forwardedRef) => {
|
|
const context = useMenuContext(CONTENT_NAME, props.__scopeMenu);
|
|
return (0, import_jsx_runtime3.jsx)(
|
|
MenuContentImpl,
|
|
{
|
|
...props,
|
|
ref: forwardedRef,
|
|
trapFocus: false,
|
|
disableOutsidePointerEvents: false,
|
|
disableOutsideScroll: false,
|
|
onDismiss: () => context.onOpenChange(false)
|
|
}
|
|
);
|
|
});
|
|
var MenuContentImpl = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const {
|
|
__scopeMenu,
|
|
loop = false,
|
|
trapFocus,
|
|
onOpenAutoFocus,
|
|
onCloseAutoFocus,
|
|
disableOutsidePointerEvents,
|
|
onEntryFocus,
|
|
onEscapeKeyDown,
|
|
onPointerDownOutside,
|
|
onFocusOutside,
|
|
onInteractOutside,
|
|
onDismiss,
|
|
disableOutsideScroll,
|
|
...contentProps
|
|
} = props;
|
|
const context = useMenuContext(CONTENT_NAME, __scopeMenu);
|
|
const rootContext = useMenuRootContext(CONTENT_NAME, __scopeMenu);
|
|
const popperScope = usePopperScope(__scopeMenu);
|
|
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
|
|
const getItems = useCollection(__scopeMenu);
|
|
const [currentItemId, setCurrentItemId] = React7.useState(null);
|
|
const contentRef = React7.useRef(null);
|
|
const composedRefs = useComposedRefs(forwardedRef, contentRef, context.onContentChange);
|
|
const timerRef = React7.useRef(0);
|
|
const searchRef = React7.useRef("");
|
|
const pointerGraceTimerRef = React7.useRef(0);
|
|
const pointerGraceIntentRef = React7.useRef(null);
|
|
const pointerDirRef = React7.useRef("right");
|
|
const lastPointerXRef = React7.useRef(0);
|
|
const ScrollLockWrapper = disableOutsideScroll ? Combination_default : React7.Fragment;
|
|
const scrollLockWrapperProps = disableOutsideScroll ? { as: Slot, allowPinchZoom: true } : void 0;
|
|
const handleTypeaheadSearch = (key) => {
|
|
var _a, _b;
|
|
const search = searchRef.current + key;
|
|
const items = getItems().filter((item) => !item.disabled);
|
|
const currentItem = document.activeElement;
|
|
const currentMatch = (_a = items.find((item) => item.ref.current === currentItem)) == null ? void 0 : _a.textValue;
|
|
const values = items.map((item) => item.textValue);
|
|
const nextMatch = getNextMatch(values, search, currentMatch);
|
|
const newItem = (_b = items.find((item) => item.textValue === nextMatch)) == null ? void 0 : _b.ref.current;
|
|
(function updateSearch(value) {
|
|
searchRef.current = value;
|
|
window.clearTimeout(timerRef.current);
|
|
if (value !== "") timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
|
|
})(search);
|
|
if (newItem) {
|
|
setTimeout(() => newItem.focus());
|
|
}
|
|
};
|
|
React7.useEffect(() => {
|
|
return () => window.clearTimeout(timerRef.current);
|
|
}, []);
|
|
useFocusGuards();
|
|
const isPointerMovingToSubmenu = React7.useCallback((event) => {
|
|
var _a, _b;
|
|
const isMovingTowards = pointerDirRef.current === ((_a = pointerGraceIntentRef.current) == null ? void 0 : _a.side);
|
|
return isMovingTowards && isPointerInGraceArea(event, (_b = pointerGraceIntentRef.current) == null ? void 0 : _b.area);
|
|
}, []);
|
|
return (0, import_jsx_runtime3.jsx)(
|
|
MenuContentProvider,
|
|
{
|
|
scope: __scopeMenu,
|
|
searchRef,
|
|
onItemEnter: React7.useCallback(
|
|
(event) => {
|
|
if (isPointerMovingToSubmenu(event)) event.preventDefault();
|
|
},
|
|
[isPointerMovingToSubmenu]
|
|
),
|
|
onItemLeave: React7.useCallback(
|
|
(event) => {
|
|
var _a;
|
|
if (isPointerMovingToSubmenu(event)) return;
|
|
(_a = contentRef.current) == null ? void 0 : _a.focus();
|
|
setCurrentItemId(null);
|
|
},
|
|
[isPointerMovingToSubmenu]
|
|
),
|
|
onTriggerLeave: React7.useCallback(
|
|
(event) => {
|
|
if (isPointerMovingToSubmenu(event)) event.preventDefault();
|
|
},
|
|
[isPointerMovingToSubmenu]
|
|
),
|
|
pointerGraceTimerRef,
|
|
onPointerGraceIntentChange: React7.useCallback((intent) => {
|
|
pointerGraceIntentRef.current = intent;
|
|
}, []),
|
|
children: (0, import_jsx_runtime3.jsx)(ScrollLockWrapper, { ...scrollLockWrapperProps, children: (0, import_jsx_runtime3.jsx)(
|
|
FocusScope,
|
|
{
|
|
asChild: true,
|
|
trapped: trapFocus,
|
|
onMountAutoFocus: composeEventHandlers(onOpenAutoFocus, (event) => {
|
|
var _a;
|
|
event.preventDefault();
|
|
(_a = contentRef.current) == null ? void 0 : _a.focus({ preventScroll: true });
|
|
}),
|
|
onUnmountAutoFocus: onCloseAutoFocus,
|
|
children: (0, import_jsx_runtime3.jsx)(
|
|
DismissableLayer,
|
|
{
|
|
asChild: true,
|
|
disableOutsidePointerEvents,
|
|
onEscapeKeyDown,
|
|
onPointerDownOutside,
|
|
onFocusOutside,
|
|
onInteractOutside,
|
|
onDismiss,
|
|
children: (0, import_jsx_runtime3.jsx)(
|
|
Root,
|
|
{
|
|
asChild: true,
|
|
...rovingFocusGroupScope,
|
|
dir: rootContext.dir,
|
|
orientation: "vertical",
|
|
loop,
|
|
currentTabStopId: currentItemId,
|
|
onCurrentTabStopIdChange: setCurrentItemId,
|
|
onEntryFocus: composeEventHandlers(onEntryFocus, (event) => {
|
|
if (!rootContext.isUsingKeyboardRef.current) event.preventDefault();
|
|
}),
|
|
preventScrollOnEntryFocus: true,
|
|
children: (0, import_jsx_runtime3.jsx)(
|
|
Content,
|
|
{
|
|
role: "menu",
|
|
"aria-orientation": "vertical",
|
|
"data-state": getOpenState(context.open),
|
|
"data-radix-menu-content": "",
|
|
dir: rootContext.dir,
|
|
...popperScope,
|
|
...contentProps,
|
|
ref: composedRefs,
|
|
style: { outline: "none", ...contentProps.style },
|
|
onKeyDown: composeEventHandlers(contentProps.onKeyDown, (event) => {
|
|
const target = event.target;
|
|
const isKeyDownInside = target.closest("[data-radix-menu-content]") === event.currentTarget;
|
|
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
|
const isCharacterKey = event.key.length === 1;
|
|
if (isKeyDownInside) {
|
|
if (event.key === "Tab") event.preventDefault();
|
|
if (!isModifierKey && isCharacterKey) handleTypeaheadSearch(event.key);
|
|
}
|
|
const content = contentRef.current;
|
|
if (event.target !== content) return;
|
|
if (!FIRST_LAST_KEYS.includes(event.key)) return;
|
|
event.preventDefault();
|
|
const items = getItems().filter((item) => !item.disabled);
|
|
const candidateNodes = items.map((item) => item.ref.current);
|
|
if (LAST_KEYS.includes(event.key)) candidateNodes.reverse();
|
|
focusFirst(candidateNodes);
|
|
}),
|
|
onBlur: composeEventHandlers(props.onBlur, (event) => {
|
|
if (!event.currentTarget.contains(event.target)) {
|
|
window.clearTimeout(timerRef.current);
|
|
searchRef.current = "";
|
|
}
|
|
}),
|
|
onPointerMove: composeEventHandlers(
|
|
props.onPointerMove,
|
|
whenMouse((event) => {
|
|
const target = event.target;
|
|
const pointerXHasChanged = lastPointerXRef.current !== event.clientX;
|
|
if (event.currentTarget.contains(target) && pointerXHasChanged) {
|
|
const newDir = event.clientX > lastPointerXRef.current ? "right" : "left";
|
|
pointerDirRef.current = newDir;
|
|
lastPointerXRef.current = event.clientX;
|
|
}
|
|
})
|
|
)
|
|
}
|
|
)
|
|
}
|
|
)
|
|
}
|
|
)
|
|
}
|
|
) })
|
|
}
|
|
);
|
|
}
|
|
);
|
|
MenuContent.displayName = CONTENT_NAME;
|
|
var GROUP_NAME = "MenuGroup";
|
|
var MenuGroup = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeMenu, ...groupProps } = props;
|
|
return (0, import_jsx_runtime3.jsx)(Primitive.div, { role: "group", ...groupProps, ref: forwardedRef });
|
|
}
|
|
);
|
|
MenuGroup.displayName = GROUP_NAME;
|
|
var LABEL_NAME = "MenuLabel";
|
|
var MenuLabel = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeMenu, ...labelProps } = props;
|
|
return (0, import_jsx_runtime3.jsx)(Primitive.div, { ...labelProps, ref: forwardedRef });
|
|
}
|
|
);
|
|
MenuLabel.displayName = LABEL_NAME;
|
|
var ITEM_NAME = "MenuItem";
|
|
var ITEM_SELECT = "menu.itemSelect";
|
|
var MenuItem = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { disabled = false, onSelect, ...itemProps } = props;
|
|
const ref = React7.useRef(null);
|
|
const rootContext = useMenuRootContext(ITEM_NAME, props.__scopeMenu);
|
|
const contentContext = useMenuContentContext(ITEM_NAME, props.__scopeMenu);
|
|
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
const isPointerDownRef = React7.useRef(false);
|
|
const handleSelect = () => {
|
|
const menuItem = ref.current;
|
|
if (!disabled && menuItem) {
|
|
const itemSelectEvent = new CustomEvent(ITEM_SELECT, { bubbles: true, cancelable: true });
|
|
menuItem.addEventListener(ITEM_SELECT, (event) => onSelect == null ? void 0 : onSelect(event), { once: true });
|
|
dispatchDiscreteCustomEvent(menuItem, itemSelectEvent);
|
|
if (itemSelectEvent.defaultPrevented) {
|
|
isPointerDownRef.current = false;
|
|
} else {
|
|
rootContext.onClose();
|
|
}
|
|
}
|
|
};
|
|
return (0, import_jsx_runtime3.jsx)(
|
|
MenuItemImpl,
|
|
{
|
|
...itemProps,
|
|
ref: composedRefs,
|
|
disabled,
|
|
onClick: composeEventHandlers(props.onClick, handleSelect),
|
|
onPointerDown: (event) => {
|
|
var _a;
|
|
(_a = props.onPointerDown) == null ? void 0 : _a.call(props, event);
|
|
isPointerDownRef.current = true;
|
|
},
|
|
onPointerUp: composeEventHandlers(props.onPointerUp, (event) => {
|
|
var _a;
|
|
if (!isPointerDownRef.current) (_a = event.currentTarget) == null ? void 0 : _a.click();
|
|
}),
|
|
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
const isTypingAhead = contentContext.searchRef.current !== "";
|
|
if (disabled || isTypingAhead && event.key === " ") return;
|
|
if (SELECTION_KEYS.includes(event.key)) {
|
|
event.currentTarget.click();
|
|
event.preventDefault();
|
|
}
|
|
})
|
|
}
|
|
);
|
|
}
|
|
);
|
|
MenuItem.displayName = ITEM_NAME;
|
|
var MenuItemImpl = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeMenu, disabled = false, textValue, ...itemProps } = props;
|
|
const contentContext = useMenuContentContext(ITEM_NAME, __scopeMenu);
|
|
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
|
|
const ref = React7.useRef(null);
|
|
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
const [isFocused, setIsFocused] = React7.useState(false);
|
|
const [textContent, setTextContent] = React7.useState("");
|
|
React7.useEffect(() => {
|
|
const menuItem = ref.current;
|
|
if (menuItem) {
|
|
setTextContent((menuItem.textContent ?? "").trim());
|
|
}
|
|
}, [itemProps.children]);
|
|
return (0, import_jsx_runtime3.jsx)(
|
|
Collection.ItemSlot,
|
|
{
|
|
scope: __scopeMenu,
|
|
disabled,
|
|
textValue: textValue ?? textContent,
|
|
children: (0, import_jsx_runtime3.jsx)(Item, { asChild: true, ...rovingFocusGroupScope, focusable: !disabled, children: (0, import_jsx_runtime3.jsx)(
|
|
Primitive.div,
|
|
{
|
|
role: "menuitem",
|
|
"data-highlighted": isFocused ? "" : void 0,
|
|
"aria-disabled": disabled || void 0,
|
|
"data-disabled": disabled ? "" : void 0,
|
|
...itemProps,
|
|
ref: composedRefs,
|
|
onPointerMove: composeEventHandlers(
|
|
props.onPointerMove,
|
|
whenMouse((event) => {
|
|
if (disabled) {
|
|
contentContext.onItemLeave(event);
|
|
} else {
|
|
contentContext.onItemEnter(event);
|
|
if (!event.defaultPrevented) {
|
|
const item = event.currentTarget;
|
|
item.focus({ preventScroll: true });
|
|
}
|
|
}
|
|
})
|
|
),
|
|
onPointerLeave: composeEventHandlers(
|
|
props.onPointerLeave,
|
|
whenMouse((event) => contentContext.onItemLeave(event))
|
|
),
|
|
onFocus: composeEventHandlers(props.onFocus, () => setIsFocused(true)),
|
|
onBlur: composeEventHandlers(props.onBlur, () => setIsFocused(false))
|
|
}
|
|
) })
|
|
}
|
|
);
|
|
}
|
|
);
|
|
var CHECKBOX_ITEM_NAME = "MenuCheckboxItem";
|
|
var MenuCheckboxItem = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { checked = false, onCheckedChange, ...checkboxItemProps } = props;
|
|
return (0, import_jsx_runtime3.jsx)(ItemIndicatorProvider, { scope: props.__scopeMenu, checked, children: (0, import_jsx_runtime3.jsx)(
|
|
MenuItem,
|
|
{
|
|
role: "menuitemcheckbox",
|
|
"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
|
|
...checkboxItemProps,
|
|
ref: forwardedRef,
|
|
"data-state": getCheckedState(checked),
|
|
onSelect: composeEventHandlers(
|
|
checkboxItemProps.onSelect,
|
|
() => onCheckedChange == null ? void 0 : onCheckedChange(isIndeterminate(checked) ? true : !checked),
|
|
{ checkForDefaultPrevented: false }
|
|
)
|
|
}
|
|
) });
|
|
}
|
|
);
|
|
MenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
|
|
var RADIO_GROUP_NAME = "MenuRadioGroup";
|
|
var [RadioGroupProvider, useRadioGroupContext] = createMenuContext(
|
|
RADIO_GROUP_NAME,
|
|
{ value: void 0, onValueChange: () => {
|
|
} }
|
|
);
|
|
var MenuRadioGroup = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { value, onValueChange, ...groupProps } = props;
|
|
const handleValueChange = useCallbackRef(onValueChange);
|
|
return (0, import_jsx_runtime3.jsx)(RadioGroupProvider, { scope: props.__scopeMenu, value, onValueChange: handleValueChange, children: (0, import_jsx_runtime3.jsx)(MenuGroup, { ...groupProps, ref: forwardedRef }) });
|
|
}
|
|
);
|
|
MenuRadioGroup.displayName = RADIO_GROUP_NAME;
|
|
var RADIO_ITEM_NAME = "MenuRadioItem";
|
|
var MenuRadioItem = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { value, ...radioItemProps } = props;
|
|
const context = useRadioGroupContext(RADIO_ITEM_NAME, props.__scopeMenu);
|
|
const checked = value === context.value;
|
|
return (0, import_jsx_runtime3.jsx)(ItemIndicatorProvider, { scope: props.__scopeMenu, checked, children: (0, import_jsx_runtime3.jsx)(
|
|
MenuItem,
|
|
{
|
|
role: "menuitemradio",
|
|
"aria-checked": checked,
|
|
...radioItemProps,
|
|
ref: forwardedRef,
|
|
"data-state": getCheckedState(checked),
|
|
onSelect: composeEventHandlers(
|
|
radioItemProps.onSelect,
|
|
() => {
|
|
var _a;
|
|
return (_a = context.onValueChange) == null ? void 0 : _a.call(context, value);
|
|
},
|
|
{ checkForDefaultPrevented: false }
|
|
)
|
|
}
|
|
) });
|
|
}
|
|
);
|
|
MenuRadioItem.displayName = RADIO_ITEM_NAME;
|
|
var ITEM_INDICATOR_NAME = "MenuItemIndicator";
|
|
var [ItemIndicatorProvider, useItemIndicatorContext] = createMenuContext(
|
|
ITEM_INDICATOR_NAME,
|
|
{ checked: false }
|
|
);
|
|
var MenuItemIndicator = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeMenu, forceMount, ...itemIndicatorProps } = props;
|
|
const indicatorContext = useItemIndicatorContext(ITEM_INDICATOR_NAME, __scopeMenu);
|
|
return (0, import_jsx_runtime3.jsx)(
|
|
Presence,
|
|
{
|
|
present: forceMount || isIndeterminate(indicatorContext.checked) || indicatorContext.checked === true,
|
|
children: (0, import_jsx_runtime3.jsx)(
|
|
Primitive.span,
|
|
{
|
|
...itemIndicatorProps,
|
|
ref: forwardedRef,
|
|
"data-state": getCheckedState(indicatorContext.checked)
|
|
}
|
|
)
|
|
}
|
|
);
|
|
}
|
|
);
|
|
MenuItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
|
var SEPARATOR_NAME = "MenuSeparator";
|
|
var MenuSeparator = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeMenu, ...separatorProps } = props;
|
|
return (0, import_jsx_runtime3.jsx)(
|
|
Primitive.div,
|
|
{
|
|
role: "separator",
|
|
"aria-orientation": "horizontal",
|
|
...separatorProps,
|
|
ref: forwardedRef
|
|
}
|
|
);
|
|
}
|
|
);
|
|
MenuSeparator.displayName = SEPARATOR_NAME;
|
|
var ARROW_NAME = "MenuArrow";
|
|
var MenuArrow = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeMenu, ...arrowProps } = props;
|
|
const popperScope = usePopperScope(__scopeMenu);
|
|
return (0, import_jsx_runtime3.jsx)(Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
|
|
}
|
|
);
|
|
MenuArrow.displayName = ARROW_NAME;
|
|
var SUB_NAME = "MenuSub";
|
|
var [MenuSubProvider, useMenuSubContext] = createMenuContext(SUB_NAME);
|
|
var MenuSub = (props) => {
|
|
const { __scopeMenu, children, open = false, onOpenChange } = props;
|
|
const parentMenuContext = useMenuContext(SUB_NAME, __scopeMenu);
|
|
const popperScope = usePopperScope(__scopeMenu);
|
|
const [trigger, setTrigger] = React7.useState(null);
|
|
const [content, setContent] = React7.useState(null);
|
|
const handleOpenChange = useCallbackRef(onOpenChange);
|
|
React7.useEffect(() => {
|
|
if (parentMenuContext.open === false) handleOpenChange(false);
|
|
return () => handleOpenChange(false);
|
|
}, [parentMenuContext.open, handleOpenChange]);
|
|
return (0, import_jsx_runtime3.jsx)(Root2, { ...popperScope, children: (0, import_jsx_runtime3.jsx)(
|
|
MenuProvider,
|
|
{
|
|
scope: __scopeMenu,
|
|
open,
|
|
onOpenChange: handleOpenChange,
|
|
content,
|
|
onContentChange: setContent,
|
|
children: (0, import_jsx_runtime3.jsx)(
|
|
MenuSubProvider,
|
|
{
|
|
scope: __scopeMenu,
|
|
contentId: useId(),
|
|
triggerId: useId(),
|
|
trigger,
|
|
onTriggerChange: setTrigger,
|
|
children
|
|
}
|
|
)
|
|
}
|
|
) });
|
|
};
|
|
MenuSub.displayName = SUB_NAME;
|
|
var SUB_TRIGGER_NAME = "MenuSubTrigger";
|
|
var MenuSubTrigger = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const context = useMenuContext(SUB_TRIGGER_NAME, props.__scopeMenu);
|
|
const rootContext = useMenuRootContext(SUB_TRIGGER_NAME, props.__scopeMenu);
|
|
const subContext = useMenuSubContext(SUB_TRIGGER_NAME, props.__scopeMenu);
|
|
const contentContext = useMenuContentContext(SUB_TRIGGER_NAME, props.__scopeMenu);
|
|
const openTimerRef = React7.useRef(null);
|
|
const { pointerGraceTimerRef, onPointerGraceIntentChange } = contentContext;
|
|
const scope = { __scopeMenu: props.__scopeMenu };
|
|
const clearOpenTimer = React7.useCallback(() => {
|
|
if (openTimerRef.current) window.clearTimeout(openTimerRef.current);
|
|
openTimerRef.current = null;
|
|
}, []);
|
|
React7.useEffect(() => clearOpenTimer, [clearOpenTimer]);
|
|
React7.useEffect(() => {
|
|
const pointerGraceTimer = pointerGraceTimerRef.current;
|
|
return () => {
|
|
window.clearTimeout(pointerGraceTimer);
|
|
onPointerGraceIntentChange(null);
|
|
};
|
|
}, [pointerGraceTimerRef, onPointerGraceIntentChange]);
|
|
return (0, import_jsx_runtime3.jsx)(MenuAnchor, { asChild: true, ...scope, children: (0, import_jsx_runtime3.jsx)(
|
|
MenuItemImpl,
|
|
{
|
|
id: subContext.triggerId,
|
|
"aria-haspopup": "menu",
|
|
"aria-expanded": context.open,
|
|
"aria-controls": subContext.contentId,
|
|
"data-state": getOpenState(context.open),
|
|
...props,
|
|
ref: composeRefs(forwardedRef, subContext.onTriggerChange),
|
|
onClick: (event) => {
|
|
var _a;
|
|
(_a = props.onClick) == null ? void 0 : _a.call(props, event);
|
|
if (props.disabled || event.defaultPrevented) return;
|
|
event.currentTarget.focus();
|
|
if (!context.open) context.onOpenChange(true);
|
|
},
|
|
onPointerMove: composeEventHandlers(
|
|
props.onPointerMove,
|
|
whenMouse((event) => {
|
|
contentContext.onItemEnter(event);
|
|
if (event.defaultPrevented) return;
|
|
if (!props.disabled && !context.open && !openTimerRef.current) {
|
|
contentContext.onPointerGraceIntentChange(null);
|
|
openTimerRef.current = window.setTimeout(() => {
|
|
context.onOpenChange(true);
|
|
clearOpenTimer();
|
|
}, 100);
|
|
}
|
|
})
|
|
),
|
|
onPointerLeave: composeEventHandlers(
|
|
props.onPointerLeave,
|
|
whenMouse((event) => {
|
|
var _a, _b;
|
|
clearOpenTimer();
|
|
const contentRect = (_a = context.content) == null ? void 0 : _a.getBoundingClientRect();
|
|
if (contentRect) {
|
|
const side = (_b = context.content) == null ? void 0 : _b.dataset.side;
|
|
const rightSide = side === "right";
|
|
const bleed = rightSide ? -5 : 5;
|
|
const contentNearEdge = contentRect[rightSide ? "left" : "right"];
|
|
const contentFarEdge = contentRect[rightSide ? "right" : "left"];
|
|
contentContext.onPointerGraceIntentChange({
|
|
area: [
|
|
// Apply a bleed on clientX to ensure that our exit point is
|
|
// consistently within polygon bounds
|
|
{ x: event.clientX + bleed, y: event.clientY },
|
|
{ x: contentNearEdge, y: contentRect.top },
|
|
{ x: contentFarEdge, y: contentRect.top },
|
|
{ x: contentFarEdge, y: contentRect.bottom },
|
|
{ x: contentNearEdge, y: contentRect.bottom }
|
|
],
|
|
side
|
|
});
|
|
window.clearTimeout(pointerGraceTimerRef.current);
|
|
pointerGraceTimerRef.current = window.setTimeout(
|
|
() => contentContext.onPointerGraceIntentChange(null),
|
|
300
|
|
);
|
|
} else {
|
|
contentContext.onTriggerLeave(event);
|
|
if (event.defaultPrevented) return;
|
|
contentContext.onPointerGraceIntentChange(null);
|
|
}
|
|
})
|
|
),
|
|
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
var _a;
|
|
const isTypingAhead = contentContext.searchRef.current !== "";
|
|
if (props.disabled || isTypingAhead && event.key === " ") return;
|
|
if (SUB_OPEN_KEYS[rootContext.dir].includes(event.key)) {
|
|
context.onOpenChange(true);
|
|
(_a = context.content) == null ? void 0 : _a.focus();
|
|
event.preventDefault();
|
|
}
|
|
})
|
|
}
|
|
) });
|
|
}
|
|
);
|
|
MenuSubTrigger.displayName = SUB_TRIGGER_NAME;
|
|
var SUB_CONTENT_NAME = "MenuSubContent";
|
|
var MenuSubContent = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeMenu);
|
|
const { forceMount = portalContext.forceMount, ...subContentProps } = props;
|
|
const context = useMenuContext(CONTENT_NAME, props.__scopeMenu);
|
|
const rootContext = useMenuRootContext(CONTENT_NAME, props.__scopeMenu);
|
|
const subContext = useMenuSubContext(SUB_CONTENT_NAME, props.__scopeMenu);
|
|
const ref = React7.useRef(null);
|
|
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
return (0, import_jsx_runtime3.jsx)(Collection.Provider, { scope: props.__scopeMenu, children: (0, import_jsx_runtime3.jsx)(Presence, { present: forceMount || context.open, children: (0, import_jsx_runtime3.jsx)(Collection.Slot, { scope: props.__scopeMenu, children: (0, import_jsx_runtime3.jsx)(
|
|
MenuContentImpl,
|
|
{
|
|
id: subContext.contentId,
|
|
"aria-labelledby": subContext.triggerId,
|
|
...subContentProps,
|
|
ref: composedRefs,
|
|
align: "start",
|
|
side: rootContext.dir === "rtl" ? "left" : "right",
|
|
disableOutsidePointerEvents: false,
|
|
disableOutsideScroll: false,
|
|
trapFocus: false,
|
|
onOpenAutoFocus: (event) => {
|
|
var _a;
|
|
if (rootContext.isUsingKeyboardRef.current) (_a = ref.current) == null ? void 0 : _a.focus();
|
|
event.preventDefault();
|
|
},
|
|
onCloseAutoFocus: (event) => event.preventDefault(),
|
|
onFocusOutside: composeEventHandlers(props.onFocusOutside, (event) => {
|
|
if (event.target !== subContext.trigger) context.onOpenChange(false);
|
|
}),
|
|
onEscapeKeyDown: composeEventHandlers(props.onEscapeKeyDown, (event) => {
|
|
rootContext.onClose();
|
|
event.preventDefault();
|
|
}),
|
|
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
var _a;
|
|
const isKeyDownInside = event.currentTarget.contains(event.target);
|
|
const isCloseKey = SUB_CLOSE_KEYS[rootContext.dir].includes(event.key);
|
|
if (isKeyDownInside && isCloseKey) {
|
|
context.onOpenChange(false);
|
|
(_a = subContext.trigger) == null ? void 0 : _a.focus();
|
|
event.preventDefault();
|
|
}
|
|
})
|
|
}
|
|
) }) }) });
|
|
}
|
|
);
|
|
MenuSubContent.displayName = SUB_CONTENT_NAME;
|
|
function getOpenState(open) {
|
|
return open ? "open" : "closed";
|
|
}
|
|
function isIndeterminate(checked) {
|
|
return checked === "indeterminate";
|
|
}
|
|
function getCheckedState(checked) {
|
|
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
}
|
|
function focusFirst(candidates) {
|
|
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
|
for (const candidate of candidates) {
|
|
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
candidate.focus();
|
|
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
}
|
|
}
|
|
function wrapArray(array, startIndex) {
|
|
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
|
}
|
|
function getNextMatch(values, search, currentMatch) {
|
|
const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
|
|
const normalizedSearch = isRepeated ? search[0] : search;
|
|
const currentMatchIndex = currentMatch ? values.indexOf(currentMatch) : -1;
|
|
let wrappedValues = wrapArray(values, Math.max(currentMatchIndex, 0));
|
|
const excludeCurrentMatch = normalizedSearch.length === 1;
|
|
if (excludeCurrentMatch) wrappedValues = wrappedValues.filter((v) => v !== currentMatch);
|
|
const nextMatch = wrappedValues.find(
|
|
(value) => value.toLowerCase().startsWith(normalizedSearch.toLowerCase())
|
|
);
|
|
return nextMatch !== currentMatch ? nextMatch : void 0;
|
|
}
|
|
function isPointInPolygon(point, polygon) {
|
|
const { x, y } = point;
|
|
let inside = false;
|
|
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
const xi = polygon[i].x;
|
|
const yi = polygon[i].y;
|
|
const xj = polygon[j].x;
|
|
const yj = polygon[j].y;
|
|
const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
|
|
if (intersect) inside = !inside;
|
|
}
|
|
return inside;
|
|
}
|
|
function isPointerInGraceArea(event, area) {
|
|
if (!area) return false;
|
|
const cursorPos = { x: event.clientX, y: event.clientY };
|
|
return isPointInPolygon(cursorPos, area);
|
|
}
|
|
function whenMouse(handler) {
|
|
return (event) => event.pointerType === "mouse" ? handler(event) : void 0;
|
|
}
|
|
var Root3 = Menu;
|
|
var Anchor2 = MenuAnchor;
|
|
var Portal2 = MenuPortal;
|
|
var Content2 = MenuContent;
|
|
var Group = MenuGroup;
|
|
var Label = MenuLabel;
|
|
var Item2 = MenuItem;
|
|
var CheckboxItem = MenuCheckboxItem;
|
|
var RadioGroup = MenuRadioGroup;
|
|
var RadioItem = MenuRadioItem;
|
|
var ItemIndicator = MenuItemIndicator;
|
|
var Separator = MenuSeparator;
|
|
var Arrow2 = MenuArrow;
|
|
var Sub = MenuSub;
|
|
var SubTrigger = MenuSubTrigger;
|
|
var SubContent = MenuSubContent;
|
|
|
|
// node_modules/@radix-ui/react-dropdown-menu/dist/index.mjs
|
|
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
|
|
var DROPDOWN_MENU_NAME = "DropdownMenu";
|
|
var [createDropdownMenuContext, createDropdownMenuScope] = createContextScope(
|
|
DROPDOWN_MENU_NAME,
|
|
[createMenuScope]
|
|
);
|
|
var useMenuScope = createMenuScope();
|
|
var [DropdownMenuProvider, useDropdownMenuContext] = createDropdownMenuContext(DROPDOWN_MENU_NAME);
|
|
var DropdownMenu = (props) => {
|
|
const {
|
|
__scopeDropdownMenu,
|
|
children,
|
|
dir,
|
|
open: openProp,
|
|
defaultOpen,
|
|
onOpenChange,
|
|
modal = true
|
|
} = props;
|
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
const triggerRef = React8.useRef(null);
|
|
const [open = false, setOpen] = useControllableState({
|
|
prop: openProp,
|
|
defaultProp: defaultOpen,
|
|
onChange: onOpenChange
|
|
});
|
|
return (0, import_jsx_runtime4.jsx)(
|
|
DropdownMenuProvider,
|
|
{
|
|
scope: __scopeDropdownMenu,
|
|
triggerId: useId(),
|
|
triggerRef,
|
|
contentId: useId(),
|
|
open,
|
|
onOpenChange: setOpen,
|
|
onOpenToggle: React8.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
modal,
|
|
children: (0, import_jsx_runtime4.jsx)(Root3, { ...menuScope, open, onOpenChange: setOpen, dir, modal, children })
|
|
}
|
|
);
|
|
};
|
|
DropdownMenu.displayName = DROPDOWN_MENU_NAME;
|
|
var TRIGGER_NAME = "DropdownMenuTrigger";
|
|
var DropdownMenuTrigger = React8.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeDropdownMenu, disabled = false, ...triggerProps } = props;
|
|
const context = useDropdownMenuContext(TRIGGER_NAME, __scopeDropdownMenu);
|
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
return (0, import_jsx_runtime4.jsx)(Anchor2, { asChild: true, ...menuScope, children: (0, import_jsx_runtime4.jsx)(
|
|
Primitive.button,
|
|
{
|
|
type: "button",
|
|
id: context.triggerId,
|
|
"aria-haspopup": "menu",
|
|
"aria-expanded": context.open,
|
|
"aria-controls": context.open ? context.contentId : void 0,
|
|
"data-state": context.open ? "open" : "closed",
|
|
"data-disabled": disabled ? "" : void 0,
|
|
disabled,
|
|
...triggerProps,
|
|
ref: composeRefs(forwardedRef, context.triggerRef),
|
|
onPointerDown: composeEventHandlers(props.onPointerDown, (event) => {
|
|
if (!disabled && event.button === 0 && event.ctrlKey === false) {
|
|
context.onOpenToggle();
|
|
if (!context.open) event.preventDefault();
|
|
}
|
|
}),
|
|
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
if (disabled) return;
|
|
if (["Enter", " "].includes(event.key)) context.onOpenToggle();
|
|
if (event.key === "ArrowDown") context.onOpenChange(true);
|
|
if (["Enter", " ", "ArrowDown"].includes(event.key)) event.preventDefault();
|
|
})
|
|
}
|
|
) });
|
|
}
|
|
);
|
|
DropdownMenuTrigger.displayName = TRIGGER_NAME;
|
|
var PORTAL_NAME3 = "DropdownMenuPortal";
|
|
var DropdownMenuPortal = (props) => {
|
|
const { __scopeDropdownMenu, ...portalProps } = props;
|
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
return (0, import_jsx_runtime4.jsx)(Portal2, { ...menuScope, ...portalProps });
|
|
};
|
|
DropdownMenuPortal.displayName = PORTAL_NAME3;
|
|
var CONTENT_NAME2 = "DropdownMenuContent";
|
|
var DropdownMenuContent = React8.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeDropdownMenu, ...contentProps } = props;
|
|
const context = useDropdownMenuContext(CONTENT_NAME2, __scopeDropdownMenu);
|
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
const hasInteractedOutsideRef = React8.useRef(false);
|
|
return (0, import_jsx_runtime4.jsx)(
|
|
Content2,
|
|
{
|
|
id: context.contentId,
|
|
"aria-labelledby": context.triggerId,
|
|
...menuScope,
|
|
...contentProps,
|
|
ref: forwardedRef,
|
|
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
|
|
var _a;
|
|
if (!hasInteractedOutsideRef.current) (_a = context.triggerRef.current) == null ? void 0 : _a.focus();
|
|
hasInteractedOutsideRef.current = false;
|
|
event.preventDefault();
|
|
}),
|
|
onInteractOutside: composeEventHandlers(props.onInteractOutside, (event) => {
|
|
const originalEvent = event.detail.originalEvent;
|
|
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
if (!context.modal || isRightClick) hasInteractedOutsideRef.current = true;
|
|
}),
|
|
style: {
|
|
...props.style,
|
|
// re-namespace exposed content custom properties
|
|
...{
|
|
"--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
"--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
|
|
"--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
|
|
"--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
|
|
"--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
|
|
}
|
|
}
|
|
}
|
|
);
|
|
}
|
|
);
|
|
DropdownMenuContent.displayName = CONTENT_NAME2;
|
|
var GROUP_NAME2 = "DropdownMenuGroup";
|
|
var DropdownMenuGroup = React8.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeDropdownMenu, ...groupProps } = props;
|
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
return (0, import_jsx_runtime4.jsx)(Group, { ...menuScope, ...groupProps, ref: forwardedRef });
|
|
}
|
|
);
|
|
DropdownMenuGroup.displayName = GROUP_NAME2;
|
|
var LABEL_NAME2 = "DropdownMenuLabel";
|
|
var DropdownMenuLabel = React8.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeDropdownMenu, ...labelProps } = props;
|
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
return (0, import_jsx_runtime4.jsx)(Label, { ...menuScope, ...labelProps, ref: forwardedRef });
|
|
}
|
|
);
|
|
DropdownMenuLabel.displayName = LABEL_NAME2;
|
|
var ITEM_NAME2 = "DropdownMenuItem";
|
|
var DropdownMenuItem = React8.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeDropdownMenu, ...itemProps } = props;
|
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
return (0, import_jsx_runtime4.jsx)(Item2, { ...menuScope, ...itemProps, ref: forwardedRef });
|
|
}
|
|
);
|
|
DropdownMenuItem.displayName = ITEM_NAME2;
|
|
var CHECKBOX_ITEM_NAME2 = "DropdownMenuCheckboxItem";
|
|
var DropdownMenuCheckboxItem = React8.forwardRef((props, forwardedRef) => {
|
|
const { __scopeDropdownMenu, ...checkboxItemProps } = props;
|
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
return (0, import_jsx_runtime4.jsx)(CheckboxItem, { ...menuScope, ...checkboxItemProps, ref: forwardedRef });
|
|
});
|
|
DropdownMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME2;
|
|
var RADIO_GROUP_NAME2 = "DropdownMenuRadioGroup";
|
|
var DropdownMenuRadioGroup = React8.forwardRef((props, forwardedRef) => {
|
|
const { __scopeDropdownMenu, ...radioGroupProps } = props;
|
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
return (0, import_jsx_runtime4.jsx)(RadioGroup, { ...menuScope, ...radioGroupProps, ref: forwardedRef });
|
|
});
|
|
DropdownMenuRadioGroup.displayName = RADIO_GROUP_NAME2;
|
|
var RADIO_ITEM_NAME2 = "DropdownMenuRadioItem";
|
|
var DropdownMenuRadioItem = React8.forwardRef((props, forwardedRef) => {
|
|
const { __scopeDropdownMenu, ...radioItemProps } = props;
|
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
return (0, import_jsx_runtime4.jsx)(RadioItem, { ...menuScope, ...radioItemProps, ref: forwardedRef });
|
|
});
|
|
DropdownMenuRadioItem.displayName = RADIO_ITEM_NAME2;
|
|
var INDICATOR_NAME = "DropdownMenuItemIndicator";
|
|
var DropdownMenuItemIndicator = React8.forwardRef((props, forwardedRef) => {
|
|
const { __scopeDropdownMenu, ...itemIndicatorProps } = props;
|
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
return (0, import_jsx_runtime4.jsx)(ItemIndicator, { ...menuScope, ...itemIndicatorProps, ref: forwardedRef });
|
|
});
|
|
DropdownMenuItemIndicator.displayName = INDICATOR_NAME;
|
|
var SEPARATOR_NAME2 = "DropdownMenuSeparator";
|
|
var DropdownMenuSeparator = React8.forwardRef((props, forwardedRef) => {
|
|
const { __scopeDropdownMenu, ...separatorProps } = props;
|
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
return (0, import_jsx_runtime4.jsx)(Separator, { ...menuScope, ...separatorProps, ref: forwardedRef });
|
|
});
|
|
DropdownMenuSeparator.displayName = SEPARATOR_NAME2;
|
|
var ARROW_NAME2 = "DropdownMenuArrow";
|
|
var DropdownMenuArrow = React8.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeDropdownMenu, ...arrowProps } = props;
|
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
return (0, import_jsx_runtime4.jsx)(Arrow2, { ...menuScope, ...arrowProps, ref: forwardedRef });
|
|
}
|
|
);
|
|
DropdownMenuArrow.displayName = ARROW_NAME2;
|
|
var DropdownMenuSub = (props) => {
|
|
const { __scopeDropdownMenu, children, open: openProp, onOpenChange, defaultOpen } = props;
|
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
const [open = false, setOpen] = useControllableState({
|
|
prop: openProp,
|
|
defaultProp: defaultOpen,
|
|
onChange: onOpenChange
|
|
});
|
|
return (0, import_jsx_runtime4.jsx)(Sub, { ...menuScope, open, onOpenChange: setOpen, children });
|
|
};
|
|
var SUB_TRIGGER_NAME2 = "DropdownMenuSubTrigger";
|
|
var DropdownMenuSubTrigger = React8.forwardRef((props, forwardedRef) => {
|
|
const { __scopeDropdownMenu, ...subTriggerProps } = props;
|
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
return (0, import_jsx_runtime4.jsx)(SubTrigger, { ...menuScope, ...subTriggerProps, ref: forwardedRef });
|
|
});
|
|
DropdownMenuSubTrigger.displayName = SUB_TRIGGER_NAME2;
|
|
var SUB_CONTENT_NAME2 = "DropdownMenuSubContent";
|
|
var DropdownMenuSubContent = React8.forwardRef((props, forwardedRef) => {
|
|
const { __scopeDropdownMenu, ...subContentProps } = props;
|
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
return (0, import_jsx_runtime4.jsx)(
|
|
SubContent,
|
|
{
|
|
...menuScope,
|
|
...subContentProps,
|
|
ref: forwardedRef,
|
|
style: {
|
|
...props.style,
|
|
// re-namespace exposed content custom properties
|
|
...{
|
|
"--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
"--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
|
|
"--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
|
|
"--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
|
|
"--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
|
|
}
|
|
}
|
|
}
|
|
);
|
|
});
|
|
DropdownMenuSubContent.displayName = SUB_CONTENT_NAME2;
|
|
var Root22 = DropdownMenu;
|
|
var Trigger = DropdownMenuTrigger;
|
|
var Portal22 = DropdownMenuPortal;
|
|
var Content22 = DropdownMenuContent;
|
|
var Group2 = DropdownMenuGroup;
|
|
var Label2 = DropdownMenuLabel;
|
|
var Item22 = DropdownMenuItem;
|
|
var CheckboxItem2 = DropdownMenuCheckboxItem;
|
|
var RadioGroup2 = DropdownMenuRadioGroup;
|
|
var RadioItem2 = DropdownMenuRadioItem;
|
|
var ItemIndicator2 = DropdownMenuItemIndicator;
|
|
var Separator2 = DropdownMenuSeparator;
|
|
var Arrow22 = DropdownMenuArrow;
|
|
var Sub2 = DropdownMenuSub;
|
|
var SubTrigger2 = DropdownMenuSubTrigger;
|
|
var SubContent2 = DropdownMenuSubContent;
|
|
export {
|
|
Arrow22 as Arrow,
|
|
CheckboxItem2 as CheckboxItem,
|
|
Content22 as Content,
|
|
DropdownMenu,
|
|
DropdownMenuArrow,
|
|
DropdownMenuCheckboxItem,
|
|
DropdownMenuContent,
|
|
DropdownMenuGroup,
|
|
DropdownMenuItem,
|
|
DropdownMenuItemIndicator,
|
|
DropdownMenuLabel,
|
|
DropdownMenuPortal,
|
|
DropdownMenuRadioGroup,
|
|
DropdownMenuRadioItem,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuSub,
|
|
DropdownMenuSubContent,
|
|
DropdownMenuSubTrigger,
|
|
DropdownMenuTrigger,
|
|
Group2 as Group,
|
|
Item22 as Item,
|
|
ItemIndicator2 as ItemIndicator,
|
|
Label2 as Label,
|
|
Portal22 as Portal,
|
|
RadioGroup2 as RadioGroup,
|
|
RadioItem2 as RadioItem,
|
|
Root22 as Root,
|
|
Separator2 as Separator,
|
|
Sub2 as Sub,
|
|
SubContent2 as SubContent,
|
|
SubTrigger2 as SubTrigger,
|
|
Trigger,
|
|
createDropdownMenuScope
|
|
};
|
|
//# sourceMappingURL=@radix-ui_react-dropdown-menu.js.map
|