1114 lines
44 KiB
JavaScript
1114 lines
44 KiB
JavaScript
"use client";
|
|
import {
|
|
FocusScope,
|
|
RemoveScrollBar,
|
|
__assign,
|
|
__rest,
|
|
__spreadArray,
|
|
createSidecarMedium,
|
|
exportSidecar,
|
|
fullWidthClassName,
|
|
hideOthers,
|
|
styleSingleton,
|
|
useMergeRefs,
|
|
zeroRightClassName
|
|
} from "./chunk-QYKEMCE4.js";
|
|
import {
|
|
useEscapeKeydown
|
|
} from "./chunk-J3JCCWF4.js";
|
|
import {
|
|
useId
|
|
} from "./chunk-5I6CIHEW.js";
|
|
import {
|
|
useControllableState
|
|
} from "./chunk-H4VE5LV5.js";
|
|
import {
|
|
Presence
|
|
} from "./chunk-TZDCYJOT.js";
|
|
import {
|
|
createContext2,
|
|
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,
|
|
Slottable,
|
|
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-alert-dialog/dist/index.mjs
|
|
var React8 = __toESM(require_react(), 1);
|
|
|
|
// node_modules/@radix-ui/react-alert-dialog/node_modules/@radix-ui/react-dialog/dist/index.mjs
|
|
var React7 = __toESM(require_react(), 1);
|
|
|
|
// node_modules/@radix-ui/react-alert-dialog/node_modules/@radix-ui/react-dialog/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-alert-dialog/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-portal/dist/index.mjs
|
|
var React2 = __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 = React2.forwardRef((props, forwardedRef) => {
|
|
var _a;
|
|
const { container: containerProp, ...portalProps } = props;
|
|
const [mounted, setMounted] = React2.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-alert-dialog/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-focus-guards/dist/index.mjs
|
|
var React3 = __toESM(require_react(), 1);
|
|
var count = 0;
|
|
function useFocusGuards() {
|
|
React3.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-alert-dialog/node_modules/@radix-ui/react-dialog/node_modules/react-remove-scroll/dist/es2015/Combination.js
|
|
var React6 = __toESM(require_react());
|
|
|
|
// node_modules/@radix-ui/react-alert-dialog/node_modules/@radix-ui/react-dialog/node_modules/react-remove-scroll/dist/es2015/UI.js
|
|
var React4 = __toESM(require_react());
|
|
|
|
// node_modules/@radix-ui/react-alert-dialog/node_modules/@radix-ui/react-dialog/node_modules/react-remove-scroll/dist/es2015/medium.js
|
|
var effectCar = createSidecarMedium();
|
|
|
|
// node_modules/@radix-ui/react-alert-dialog/node_modules/@radix-ui/react-dialog/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-alert-dialog/node_modules/@radix-ui/react-dialog/node_modules/react-remove-scroll/dist/es2015/SideEffect.js
|
|
var React5 = __toESM(require_react());
|
|
|
|
// node_modules/@radix-ui/react-alert-dialog/node_modules/@radix-ui/react-dialog/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-alert-dialog/node_modules/@radix-ui/react-dialog/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-alert-dialog/node_modules/@radix-ui/react-dialog/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-alert-dialog/node_modules/@radix-ui/react-dialog/node_modules/react-remove-scroll/dist/es2015/sidecar.js
|
|
var sidecar_default = exportSidecar(effectCar, RemoveScrollSideCar);
|
|
|
|
// node_modules/@radix-ui/react-alert-dialog/node_modules/@radix-ui/react-dialog/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-alert-dialog/node_modules/@radix-ui/react-dialog/dist/index.mjs
|
|
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
|
|
var DIALOG_NAME = "Dialog";
|
|
var [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);
|
|
var [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
|
|
var Dialog = (props) => {
|
|
const {
|
|
__scopeDialog,
|
|
children,
|
|
open: openProp,
|
|
defaultOpen,
|
|
onOpenChange,
|
|
modal = true
|
|
} = props;
|
|
const triggerRef = React7.useRef(null);
|
|
const contentRef = React7.useRef(null);
|
|
const [open = false, setOpen] = useControllableState({
|
|
prop: openProp,
|
|
defaultProp: defaultOpen,
|
|
onChange: onOpenChange
|
|
});
|
|
return (0, import_jsx_runtime3.jsx)(
|
|
DialogProvider,
|
|
{
|
|
scope: __scopeDialog,
|
|
triggerRef,
|
|
contentRef,
|
|
contentId: useId(),
|
|
titleId: useId(),
|
|
descriptionId: useId(),
|
|
open,
|
|
onOpenChange: setOpen,
|
|
onOpenToggle: React7.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
modal,
|
|
children
|
|
}
|
|
);
|
|
};
|
|
Dialog.displayName = DIALOG_NAME;
|
|
var TRIGGER_NAME = "DialogTrigger";
|
|
var DialogTrigger = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeDialog, ...triggerProps } = props;
|
|
const context = useDialogContext(TRIGGER_NAME, __scopeDialog);
|
|
const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
|
|
return (0, import_jsx_runtime3.jsx)(
|
|
Primitive.button,
|
|
{
|
|
type: "button",
|
|
"aria-haspopup": "dialog",
|
|
"aria-expanded": context.open,
|
|
"aria-controls": context.contentId,
|
|
"data-state": getState(context.open),
|
|
...triggerProps,
|
|
ref: composedTriggerRef,
|
|
onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
|
|
}
|
|
);
|
|
}
|
|
);
|
|
DialogTrigger.displayName = TRIGGER_NAME;
|
|
var PORTAL_NAME2 = "DialogPortal";
|
|
var [PortalProvider, usePortalContext] = createDialogContext(PORTAL_NAME2, {
|
|
forceMount: void 0
|
|
});
|
|
var DialogPortal = (props) => {
|
|
const { __scopeDialog, forceMount, children, container } = props;
|
|
const context = useDialogContext(PORTAL_NAME2, __scopeDialog);
|
|
return (0, import_jsx_runtime3.jsx)(PortalProvider, { scope: __scopeDialog, forceMount, children: React7.Children.map(children, (child) => (0, import_jsx_runtime3.jsx)(Presence, { present: forceMount || context.open, children: (0, import_jsx_runtime3.jsx)(Portal, { asChild: true, container, children: child }) })) });
|
|
};
|
|
DialogPortal.displayName = PORTAL_NAME2;
|
|
var OVERLAY_NAME = "DialogOverlay";
|
|
var DialogOverlay = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);
|
|
const { forceMount = portalContext.forceMount, ...overlayProps } = props;
|
|
const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);
|
|
return context.modal ? (0, import_jsx_runtime3.jsx)(Presence, { present: forceMount || context.open, children: (0, import_jsx_runtime3.jsx)(DialogOverlayImpl, { ...overlayProps, ref: forwardedRef }) }) : null;
|
|
}
|
|
);
|
|
DialogOverlay.displayName = OVERLAY_NAME;
|
|
var DialogOverlayImpl = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeDialog, ...overlayProps } = props;
|
|
const context = useDialogContext(OVERLAY_NAME, __scopeDialog);
|
|
return (
|
|
// Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
|
|
// ie. when `Overlay` and `Content` are siblings
|
|
(0, import_jsx_runtime3.jsx)(Combination_default, { as: Slot, allowPinchZoom: true, shards: [context.contentRef], children: (0, import_jsx_runtime3.jsx)(
|
|
Primitive.div,
|
|
{
|
|
"data-state": getState(context.open),
|
|
...overlayProps,
|
|
ref: forwardedRef,
|
|
style: { pointerEvents: "auto", ...overlayProps.style }
|
|
}
|
|
) })
|
|
);
|
|
}
|
|
);
|
|
var CONTENT_NAME = "DialogContent";
|
|
var DialogContent = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);
|
|
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
return (0, import_jsx_runtime3.jsx)(Presence, { present: forceMount || context.open, children: context.modal ? (0, import_jsx_runtime3.jsx)(DialogContentModal, { ...contentProps, ref: forwardedRef }) : (0, import_jsx_runtime3.jsx)(DialogContentNonModal, { ...contentProps, ref: forwardedRef }) });
|
|
}
|
|
);
|
|
DialogContent.displayName = CONTENT_NAME;
|
|
var DialogContentModal = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
const contentRef = React7.useRef(null);
|
|
const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);
|
|
React7.useEffect(() => {
|
|
const content = contentRef.current;
|
|
if (content) return hideOthers(content);
|
|
}, []);
|
|
return (0, import_jsx_runtime3.jsx)(
|
|
DialogContentImpl,
|
|
{
|
|
...props,
|
|
ref: composedRefs,
|
|
trapFocus: context.open,
|
|
disableOutsidePointerEvents: true,
|
|
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
|
|
var _a;
|
|
event.preventDefault();
|
|
(_a = context.triggerRef.current) == null ? void 0 : _a.focus();
|
|
}),
|
|
onPointerDownOutside: composeEventHandlers(props.onPointerDownOutside, (event) => {
|
|
const originalEvent = event.detail.originalEvent;
|
|
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
if (isRightClick) event.preventDefault();
|
|
}),
|
|
onFocusOutside: composeEventHandlers(
|
|
props.onFocusOutside,
|
|
(event) => event.preventDefault()
|
|
)
|
|
}
|
|
);
|
|
}
|
|
);
|
|
var DialogContentNonModal = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
const hasInteractedOutsideRef = React7.useRef(false);
|
|
const hasPointerDownOutsideRef = React7.useRef(false);
|
|
return (0, import_jsx_runtime3.jsx)(
|
|
DialogContentImpl,
|
|
{
|
|
...props,
|
|
ref: forwardedRef,
|
|
trapFocus: false,
|
|
disableOutsidePointerEvents: false,
|
|
onCloseAutoFocus: (event) => {
|
|
var _a, _b;
|
|
(_a = props.onCloseAutoFocus) == null ? void 0 : _a.call(props, event);
|
|
if (!event.defaultPrevented) {
|
|
if (!hasInteractedOutsideRef.current) (_b = context.triggerRef.current) == null ? void 0 : _b.focus();
|
|
event.preventDefault();
|
|
}
|
|
hasInteractedOutsideRef.current = false;
|
|
hasPointerDownOutsideRef.current = false;
|
|
},
|
|
onInteractOutside: (event) => {
|
|
var _a, _b;
|
|
(_a = props.onInteractOutside) == null ? void 0 : _a.call(props, event);
|
|
if (!event.defaultPrevented) {
|
|
hasInteractedOutsideRef.current = true;
|
|
if (event.detail.originalEvent.type === "pointerdown") {
|
|
hasPointerDownOutsideRef.current = true;
|
|
}
|
|
}
|
|
const target = event.target;
|
|
const targetIsTrigger = (_b = context.triggerRef.current) == null ? void 0 : _b.contains(target);
|
|
if (targetIsTrigger) event.preventDefault();
|
|
if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
|
|
event.preventDefault();
|
|
}
|
|
}
|
|
}
|
|
);
|
|
}
|
|
);
|
|
var DialogContentImpl = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeDialog, trapFocus, onOpenAutoFocus, onCloseAutoFocus, ...contentProps } = props;
|
|
const context = useDialogContext(CONTENT_NAME, __scopeDialog);
|
|
const contentRef = React7.useRef(null);
|
|
const composedRefs = useComposedRefs(forwardedRef, contentRef);
|
|
useFocusGuards();
|
|
return (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
(0, import_jsx_runtime3.jsx)(
|
|
FocusScope,
|
|
{
|
|
asChild: true,
|
|
loop: true,
|
|
trapped: trapFocus,
|
|
onMountAutoFocus: onOpenAutoFocus,
|
|
onUnmountAutoFocus: onCloseAutoFocus,
|
|
children: (0, import_jsx_runtime3.jsx)(
|
|
DismissableLayer,
|
|
{
|
|
role: "dialog",
|
|
id: context.contentId,
|
|
"aria-describedby": context.descriptionId,
|
|
"aria-labelledby": context.titleId,
|
|
"data-state": getState(context.open),
|
|
...contentProps,
|
|
ref: composedRefs,
|
|
onDismiss: () => context.onOpenChange(false)
|
|
}
|
|
)
|
|
}
|
|
),
|
|
(0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
(0, import_jsx_runtime3.jsx)(TitleWarning, { titleId: context.titleId }),
|
|
(0, import_jsx_runtime3.jsx)(DescriptionWarning, { contentRef, descriptionId: context.descriptionId })
|
|
] })
|
|
] });
|
|
}
|
|
);
|
|
var TITLE_NAME = "DialogTitle";
|
|
var DialogTitle = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeDialog, ...titleProps } = props;
|
|
const context = useDialogContext(TITLE_NAME, __scopeDialog);
|
|
return (0, import_jsx_runtime3.jsx)(Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
|
|
}
|
|
);
|
|
DialogTitle.displayName = TITLE_NAME;
|
|
var DESCRIPTION_NAME = "DialogDescription";
|
|
var DialogDescription = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeDialog, ...descriptionProps } = props;
|
|
const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
|
|
return (0, import_jsx_runtime3.jsx)(Primitive.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef });
|
|
}
|
|
);
|
|
DialogDescription.displayName = DESCRIPTION_NAME;
|
|
var CLOSE_NAME = "DialogClose";
|
|
var DialogClose = React7.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeDialog, ...closeProps } = props;
|
|
const context = useDialogContext(CLOSE_NAME, __scopeDialog);
|
|
return (0, import_jsx_runtime3.jsx)(
|
|
Primitive.button,
|
|
{
|
|
type: "button",
|
|
...closeProps,
|
|
ref: forwardedRef,
|
|
onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))
|
|
}
|
|
);
|
|
}
|
|
);
|
|
DialogClose.displayName = CLOSE_NAME;
|
|
function getState(open) {
|
|
return open ? "open" : "closed";
|
|
}
|
|
var TITLE_WARNING_NAME = "DialogTitleWarning";
|
|
var [WarningProvider, useWarningContext] = createContext2(TITLE_WARNING_NAME, {
|
|
contentName: CONTENT_NAME,
|
|
titleName: TITLE_NAME,
|
|
docsSlug: "dialog"
|
|
});
|
|
var TitleWarning = ({ titleId }) => {
|
|
const titleWarningContext = useWarningContext(TITLE_WARNING_NAME);
|
|
const MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
|
|
|
|
If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
|
|
For more information, see https://radix-ui.com/primitives/docs/components/${titleWarningContext.docsSlug}`;
|
|
React7.useEffect(() => {
|
|
if (titleId) {
|
|
const hasTitle = document.getElementById(titleId);
|
|
if (!hasTitle) console.error(MESSAGE);
|
|
}
|
|
}, [MESSAGE, titleId]);
|
|
return null;
|
|
};
|
|
var DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning";
|
|
var DescriptionWarning = ({ contentRef, descriptionId }) => {
|
|
const descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME);
|
|
const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`;
|
|
React7.useEffect(() => {
|
|
var _a;
|
|
const describedById = (_a = contentRef.current) == null ? void 0 : _a.getAttribute("aria-describedby");
|
|
if (descriptionId && describedById) {
|
|
const hasDescription = document.getElementById(descriptionId);
|
|
if (!hasDescription) console.warn(MESSAGE);
|
|
}
|
|
}, [MESSAGE, contentRef, descriptionId]);
|
|
return null;
|
|
};
|
|
var Root = Dialog;
|
|
var Trigger = DialogTrigger;
|
|
var Portal2 = DialogPortal;
|
|
var Overlay = DialogOverlay;
|
|
var Content = DialogContent;
|
|
var Title = DialogTitle;
|
|
var Description = DialogDescription;
|
|
var Close = DialogClose;
|
|
|
|
// node_modules/@radix-ui/react-alert-dialog/dist/index.mjs
|
|
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
|
|
var ROOT_NAME = "AlertDialog";
|
|
var [createAlertDialogContext, createAlertDialogScope] = createContextScope(ROOT_NAME, [
|
|
createDialogScope
|
|
]);
|
|
var useDialogScope = createDialogScope();
|
|
var AlertDialog = (props) => {
|
|
const { __scopeAlertDialog, ...alertDialogProps } = props;
|
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
return (0, import_jsx_runtime4.jsx)(Root, { ...dialogScope, ...alertDialogProps, modal: true });
|
|
};
|
|
AlertDialog.displayName = ROOT_NAME;
|
|
var TRIGGER_NAME2 = "AlertDialogTrigger";
|
|
var AlertDialogTrigger = React8.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeAlertDialog, ...triggerProps } = props;
|
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
return (0, import_jsx_runtime4.jsx)(Trigger, { ...dialogScope, ...triggerProps, ref: forwardedRef });
|
|
}
|
|
);
|
|
AlertDialogTrigger.displayName = TRIGGER_NAME2;
|
|
var PORTAL_NAME3 = "AlertDialogPortal";
|
|
var AlertDialogPortal = (props) => {
|
|
const { __scopeAlertDialog, ...portalProps } = props;
|
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
return (0, import_jsx_runtime4.jsx)(Portal2, { ...dialogScope, ...portalProps });
|
|
};
|
|
AlertDialogPortal.displayName = PORTAL_NAME3;
|
|
var OVERLAY_NAME2 = "AlertDialogOverlay";
|
|
var AlertDialogOverlay = React8.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeAlertDialog, ...overlayProps } = props;
|
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
return (0, import_jsx_runtime4.jsx)(Overlay, { ...dialogScope, ...overlayProps, ref: forwardedRef });
|
|
}
|
|
);
|
|
AlertDialogOverlay.displayName = OVERLAY_NAME2;
|
|
var CONTENT_NAME2 = "AlertDialogContent";
|
|
var [AlertDialogContentProvider, useAlertDialogContentContext] = createAlertDialogContext(CONTENT_NAME2);
|
|
var AlertDialogContent = React8.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeAlertDialog, children, ...contentProps } = props;
|
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
const contentRef = React8.useRef(null);
|
|
const composedRefs = useComposedRefs(forwardedRef, contentRef);
|
|
const cancelRef = React8.useRef(null);
|
|
return (0, import_jsx_runtime4.jsx)(
|
|
WarningProvider,
|
|
{
|
|
contentName: CONTENT_NAME2,
|
|
titleName: TITLE_NAME2,
|
|
docsSlug: "alert-dialog",
|
|
children: (0, import_jsx_runtime4.jsx)(AlertDialogContentProvider, { scope: __scopeAlertDialog, cancelRef, children: (0, import_jsx_runtime4.jsxs)(
|
|
Content,
|
|
{
|
|
role: "alertdialog",
|
|
...dialogScope,
|
|
...contentProps,
|
|
ref: composedRefs,
|
|
onOpenAutoFocus: composeEventHandlers(contentProps.onOpenAutoFocus, (event) => {
|
|
var _a;
|
|
event.preventDefault();
|
|
(_a = cancelRef.current) == null ? void 0 : _a.focus({ preventScroll: true });
|
|
}),
|
|
onPointerDownOutside: (event) => event.preventDefault(),
|
|
onInteractOutside: (event) => event.preventDefault(),
|
|
children: [
|
|
(0, import_jsx_runtime4.jsx)(Slottable, { children }),
|
|
(0, import_jsx_runtime4.jsx)(DescriptionWarning2, { contentRef })
|
|
]
|
|
}
|
|
) })
|
|
}
|
|
);
|
|
}
|
|
);
|
|
AlertDialogContent.displayName = CONTENT_NAME2;
|
|
var TITLE_NAME2 = "AlertDialogTitle";
|
|
var AlertDialogTitle = React8.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeAlertDialog, ...titleProps } = props;
|
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
return (0, import_jsx_runtime4.jsx)(Title, { ...dialogScope, ...titleProps, ref: forwardedRef });
|
|
}
|
|
);
|
|
AlertDialogTitle.displayName = TITLE_NAME2;
|
|
var DESCRIPTION_NAME2 = "AlertDialogDescription";
|
|
var AlertDialogDescription = React8.forwardRef((props, forwardedRef) => {
|
|
const { __scopeAlertDialog, ...descriptionProps } = props;
|
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
return (0, import_jsx_runtime4.jsx)(Description, { ...dialogScope, ...descriptionProps, ref: forwardedRef });
|
|
});
|
|
AlertDialogDescription.displayName = DESCRIPTION_NAME2;
|
|
var ACTION_NAME = "AlertDialogAction";
|
|
var AlertDialogAction = React8.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeAlertDialog, ...actionProps } = props;
|
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
return (0, import_jsx_runtime4.jsx)(Close, { ...dialogScope, ...actionProps, ref: forwardedRef });
|
|
}
|
|
);
|
|
AlertDialogAction.displayName = ACTION_NAME;
|
|
var CANCEL_NAME = "AlertDialogCancel";
|
|
var AlertDialogCancel = React8.forwardRef(
|
|
(props, forwardedRef) => {
|
|
const { __scopeAlertDialog, ...cancelProps } = props;
|
|
const { cancelRef } = useAlertDialogContentContext(CANCEL_NAME, __scopeAlertDialog);
|
|
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
const ref = useComposedRefs(forwardedRef, cancelRef);
|
|
return (0, import_jsx_runtime4.jsx)(Close, { ...dialogScope, ...cancelProps, ref });
|
|
}
|
|
);
|
|
AlertDialogCancel.displayName = CANCEL_NAME;
|
|
var DescriptionWarning2 = ({ contentRef }) => {
|
|
const MESSAGE = `\`${CONTENT_NAME2}\` requires a description for the component to be accessible for screen reader users.
|
|
|
|
You can add a description to the \`${CONTENT_NAME2}\` by passing a \`${DESCRIPTION_NAME2}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
|
|
|
|
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${CONTENT_NAME2}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
|
|
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;
|
|
React8.useEffect(() => {
|
|
var _a;
|
|
const hasDescription = document.getElementById(
|
|
(_a = contentRef.current) == null ? void 0 : _a.getAttribute("aria-describedby")
|
|
);
|
|
if (!hasDescription) console.warn(MESSAGE);
|
|
}, [MESSAGE, contentRef]);
|
|
return null;
|
|
};
|
|
var Root2 = AlertDialog;
|
|
var Trigger2 = AlertDialogTrigger;
|
|
var Portal22 = AlertDialogPortal;
|
|
var Overlay2 = AlertDialogOverlay;
|
|
var Content2 = AlertDialogContent;
|
|
var Action = AlertDialogAction;
|
|
var Cancel = AlertDialogCancel;
|
|
var Title2 = AlertDialogTitle;
|
|
var Description2 = AlertDialogDescription;
|
|
export {
|
|
Action,
|
|
AlertDialog,
|
|
AlertDialogAction,
|
|
AlertDialogCancel,
|
|
AlertDialogContent,
|
|
AlertDialogDescription,
|
|
AlertDialogOverlay,
|
|
AlertDialogPortal,
|
|
AlertDialogTitle,
|
|
AlertDialogTrigger,
|
|
Cancel,
|
|
Content2 as Content,
|
|
Description2 as Description,
|
|
Overlay2 as Overlay,
|
|
Portal22 as Portal,
|
|
Root2 as Root,
|
|
Title2 as Title,
|
|
Trigger2 as Trigger,
|
|
createAlertDialogScope
|
|
};
|
|
//# sourceMappingURL=@radix-ui_react-alert-dialog.js.map
|