@radix-ui/react-dismissable-layer
Advanced tools
+3
-1
@@ -59,3 +59,5 @@ import * as React from 'react'; | ||
| }>; | ||
| declare const Root: React.ForwardRefExoticComponent<DismissableLayerProps & React.RefAttributes<HTMLDivElement>>; | ||
| declare const Branch: React.ForwardRefExoticComponent<DismissableLayerBranchProps & React.RefAttributes<HTMLDivElement>>; | ||
| export { DismissableLayerBranch as Branch, DismissableLayer, DismissableLayerBranch, type DismissableLayerProps, DismissableLayer as Root, useDismissableLayerSurface }; | ||
| export { Branch, DismissableLayer, DismissableLayerBranch, type DismissableLayerProps, Root, useDismissableLayerSurface }; |
+3
-1
@@ -59,3 +59,5 @@ import * as React from 'react'; | ||
| }>; | ||
| declare const Root: React.ForwardRefExoticComponent<DismissableLayerProps & React.RefAttributes<HTMLDivElement>>; | ||
| declare const Branch: React.ForwardRefExoticComponent<DismissableLayerBranchProps & React.RefAttributes<HTMLDivElement>>; | ||
| export { DismissableLayerBranch as Branch, DismissableLayer, DismissableLayerBranch, type DismissableLayerProps, DismissableLayer as Root, useDismissableLayerSurface }; | ||
| export { Branch, DismissableLayer, DismissableLayerBranch, type DismissableLayerProps, Root, useDismissableLayerSurface }; |
+4
-2
@@ -35,6 +35,6 @@ "use strict"; | ||
| __export(index_exports, { | ||
| Branch: () => DismissableLayerBranch, | ||
| Branch: () => Branch, | ||
| DismissableLayer: () => DismissableLayer, | ||
| DismissableLayerBranch: () => DismissableLayerBranch, | ||
| Root: () => DismissableLayer, | ||
| Root: () => Root, | ||
| useDismissableLayerSurface: () => useDismissableLayerSurface | ||
@@ -394,2 +394,4 @@ }); | ||
| __name(handleAndDispatchCustomEvent, "handleAndDispatchCustomEvent"); | ||
| var Root = DismissableLayer; | ||
| var Branch = DismissableLayerBranch; | ||
| //# sourceMappingURL=index.js.map |
| { | ||
| "version": 3, | ||
| "sources": ["../src/index.ts", "../src/dismissable-layer.tsx"], | ||
| "sourcesContent": ["'use client';\nexport {\n DismissableLayer,\n DismissableLayerBranch,\n //\n Root,\n Branch,\n /** @internal */\n useDismissableLayerSurface,\n} from './dismissable-layer';\nexport type { DismissableLayerProps } from './dismissable-layer';\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { Primitive, dispatchDiscreteCustomEvent } from '@radix-ui/react-primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\n\n/* -------------------------------------------------------------------------------------------------\n * DismissableLayer\n * -----------------------------------------------------------------------------------------------*/\nconst CONTEXT_UPDATE = 'dismissableLayer.update';\nconst POINTER_DOWN_OUTSIDE = 'dismissableLayer.pointerDownOutside';\nconst FOCUS_OUTSIDE = 'dismissableLayer.focusOutside';\n\nlet originalBodyPointerEvents: string;\n\nconst DismissableLayerContext = React.createContext({\n layers: new Set<DismissableLayerElement>(),\n layersWithOutsidePointerEventsDisabled: new Set<DismissableLayerElement>(),\n branches: new Set<DismissableLayerBranchElement>(),\n\n // Outside elements that belong to a layer's own dismiss affordance (eg, a\n // dialog overlay). Pressing them should dismiss the layer regardless of\n // whether or not they stop propagation.\n //\n // See https://github.com/radix-ui/primitives/issues/3346\n dismissableSurfaces: new Set<DismissableLayerBranchElement>(),\n});\n\ntype DismissableLayerElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface DismissableLayerProps extends PrimitiveDivProps {\n /**\n * When `true`, hover/focus/click interactions will be disabled on elements outside\n * the `DismissableLayer`. Users will need to click twice on outside elements to\n * interact with them: once to close the `DismissableLayer`, and again to trigger the element.\n */\n disableOutsidePointerEvents?: boolean;\n /**\n * When `true`, a `'pointerdown'` event outside of the layered element will\n * wait for the interaction's click event before dispatching, allowing\n * third-party code to stop propagation of later events and cancel dismissal.\n */\n deferPointerDownOutside?: boolean;\n /**\n * Event handler called when the escape key is down.\n * Can be prevented.\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void;\n /**\n * Event handler called when the a `pointerdown` event happens outside of the `DismissableLayer`.\n * Can be prevented.\n */\n onPointerDownOutside?: (event: PointerDownOutsideEvent) => void;\n /**\n * Event handler called when the focus moves outside of the `DismissableLayer`.\n * Can be prevented.\n */\n onFocusOutside?: (event: FocusOutsideEvent) => void;\n /**\n * Event handler called when an interaction happens outside the `DismissableLayer`.\n * Specifically, when a `pointerdown` event happens outside or focus moves outside of it.\n * Can be prevented.\n */\n onInteractOutside?: (event: PointerDownOutsideEvent | FocusOutsideEvent) => void;\n /**\n * Handler called when the `DismissableLayer` should be dismissed\n */\n onDismiss?: () => void;\n}\n\nconst DismissableLayer = /* @__PURE__ */ React.forwardRef<\n DismissableLayerElement,\n DismissableLayerProps\n>(\n // blank line to reduce diff noise\n function DismissableLayer(props, forwardedRef) {\n const {\n disableOutsidePointerEvents = false,\n deferPointerDownOutside = false,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n onDismiss,\n ...layerProps\n } = props;\n const context = React.useContext(DismissableLayerContext);\n const [node, setNode] = React.useState<DismissableLayerElement | null>(null);\n const ownerDocument = node?.ownerDocument ?? globalThis?.document;\n const [, force] = React.useState({});\n const composedRefs = useComposedRefs(forwardedRef, setNode);\n const layers = Array.from(context.layers);\n const [highestLayerWithOutsidePointerEventsDisabled] = [\n ...context.layersWithOutsidePointerEventsDisabled,\n ].slice(-1);\n const highestLayerWithOutsidePointerEventsDisabledIndex =\n highestLayerWithOutsidePointerEventsDisabled\n ? layers.indexOf(highestLayerWithOutsidePointerEventsDisabled)\n : -1;\n const index = node ? layers.indexOf(node) : -1;\n const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;\n const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;\n const isDeferredPointerDownOutsideRef = React.useRef(false);\n\n const pointerDownOutside = usePointerDownOutside(\n (event) => {\n onPointerDownOutside?.(event);\n onInteractOutside?.(event);\n if (!event.defaultPrevented) onDismiss?.();\n },\n {\n ownerDocument,\n deferPointerDownOutside,\n isDeferredPointerDownOutsideRef,\n dismissableSurfaces: context.dismissableSurfaces,\n shouldHandlePointerDownOutside: React.useCallback(\n (target: EventTarget | null) => {\n if (!(target instanceof Node)) {\n return false;\n }\n\n const isPointerDownOnBranch = [...context.branches].some((branch) =>\n branch.contains(target),\n );\n return isPointerEventsEnabled && !isPointerDownOnBranch;\n },\n [context.branches, isPointerEventsEnabled],\n ),\n },\n );\n\n const focusOutside = useFocusOutside((event) => {\n if (deferPointerDownOutside && isDeferredPointerDownOutsideRef.current) {\n return;\n }\n\n const target = event.target as HTMLElement;\n const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));\n if (isFocusInBranch) return;\n onFocusOutside?.(event);\n onInteractOutside?.(event);\n if (!event.defaultPrevented) onDismiss?.();\n }, ownerDocument);\n\n const isHighestLayer = node ? index === layers.length - 1 : false;\n\n // Stabilize via `useCallbackRef` rather than `useEffectEvent`: React's\n // native `useEffectEvent` returns a stale closure inside `forwardRef`\n // components on React 19.2.x, which caused escape handlers to observe\n // mount-time props/state instead of the latest values.\n //\n // We should revert this to use useEffectEvent when the fix lands in React.\n //\n // - https://github.com/radix-ui/primitives/issues/4014\n // - https://github.com/react/react/pull/34831\n const handleKeyDown = useCallbackRef((event: KeyboardEvent) => {\n if (event.key !== 'Escape') {\n return;\n }\n\n onEscapeKeyDown?.(event);\n if (!event.defaultPrevented && onDismiss) {\n event.preventDefault();\n onDismiss();\n }\n });\n\n React.useEffect(() => {\n if (!isHighestLayer) {\n return;\n }\n\n ownerDocument.addEventListener('keydown', handleKeyDown, { capture: true });\n return () => ownerDocument.removeEventListener('keydown', handleKeyDown, { capture: true });\n }, [ownerDocument, isHighestLayer, handleKeyDown]);\n\n React.useEffect(() => {\n if (!node) return;\n if (disableOutsidePointerEvents) {\n if (context.layersWithOutsidePointerEventsDisabled.size === 0) {\n originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;\n ownerDocument.body.style.pointerEvents = 'none';\n }\n context.layersWithOutsidePointerEventsDisabled.add(node);\n }\n context.layers.add(node);\n dispatchUpdate();\n return () => {\n // We must remove this layer from the disabled set whenever\n // `disableOutsidePointerEvents` becomes `false` (eg, when a modal\n // closes but stays mounted during an exit animation) and not only on\n // unmount. Otherwise the `body` `pointer-events` could be left as\n // `none` when multiple layers overlap.\n // See: https://github.com/radix-ui/primitives/issues/3645\n if (disableOutsidePointerEvents) {\n context.layersWithOutsidePointerEventsDisabled.delete(node);\n if (context.layersWithOutsidePointerEventsDisabled.size === 0) {\n ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;\n }\n }\n };\n }, [node, ownerDocument, disableOutsidePointerEvents, context]);\n\n /**\n * We purposefully prevent combining this effect with the `disableOutsidePointerEvents` effect\n * because a change to `disableOutsidePointerEvents` would remove this layer from the stack\n * and add it to the end again so the layering order wouldn't be _creation order_.\n * We only want them to be removed from context stacks when unmounted.\n */\n React.useEffect(() => {\n return () => {\n if (!node) return;\n context.layers.delete(node);\n context.layersWithOutsidePointerEventsDisabled.delete(node);\n dispatchUpdate();\n };\n }, [node, context]);\n\n React.useEffect(() => {\n const handleUpdate = () => force({});\n document.addEventListener(CONTEXT_UPDATE, handleUpdate);\n return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);\n }, []);\n\n return (\n <Primitive.div\n {...layerProps}\n ref={composedRefs}\n style={{\n pointerEvents: isBodyPointerEventsDisabled\n ? isPointerEventsEnabled\n ? 'auto'\n : 'none'\n : undefined,\n ...props.style,\n }}\n onFocusCapture={composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture)}\n onBlurCapture={composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture)}\n onPointerDownCapture={composeEventHandlers(\n props.onPointerDownCapture,\n pointerDownOutside.onPointerDownCapture,\n )}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DismissableLayerBranch\n * -----------------------------------------------------------------------------------------------*/\n\ntype DismissableLayerBranchElement = React.ComponentRef<typeof Primitive.div>;\ninterface DismissableLayerBranchProps extends PrimitiveDivProps {}\n\nconst DismissableLayerBranch = /* @__PURE__ */ React.forwardRef<\n DismissableLayerBranchElement,\n DismissableLayerBranchProps\n>(function DismissableLayerBranch(props, forwardedRef) {\n const context = React.useContext(DismissableLayerContext);\n const ref = React.useRef<DismissableLayerBranchElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n\n React.useEffect(() => {\n const node = ref.current;\n if (node) {\n context.branches.add(node);\n return () => {\n context.branches.delete(node);\n };\n }\n }, [context.branches]);\n\n return <Primitive.div {...props} ref={composedRefs} />;\n});\n\n/* -----------------------------------------------------------------------------------------------*/\n\n/**\n * Registers a node as a \"dismiss surface\" for the enclosing DismissableLayer\n */\nfunction useDismissableLayerSurface(): React.RefCallback<DismissableLayerBranchElement> {\n const context = React.useContext(DismissableLayerContext);\n const [node, setNode] = React.useState<DismissableLayerBranchElement | null>(null);\n\n React.useEffect(() => {\n if (!node) {\n return;\n }\n context.dismissableSurfaces.add(node);\n return () => {\n context.dismissableSurfaces.delete(node);\n };\n }, [node, context.dismissableSurfaces]);\n\n return setNode;\n}\n\ntype PointerDownOutsideEvent = CustomEvent<{ originalEvent: PointerEvent }>;\ntype FocusOutsideEvent = CustomEvent<{ originalEvent: FocusEvent }>;\n\nconst IS_TRUE = () => true;\n\n/**\n * Listens for `pointerdown` outside a react subtree. We detect the start of the interaction on\n * `pointerdown`, then wait for `click` so external code can intercept later mouse events.\n * Returns props to pass to the node we want to check for outside events.\n */\nfunction usePointerDownOutside(\n onPointerDownOutside: ((event: PointerDownOutsideEvent) => void) | undefined,\n args: {\n ownerDocument: Document | undefined;\n deferPointerDownOutside: boolean;\n isDeferredPointerDownOutsideRef: React.RefObject<boolean>;\n dismissableSurfaces: Set<DismissableLayerBranchElement>;\n shouldHandlePointerDownOutside?: (target: EventTarget | null) => boolean;\n },\n) {\n const {\n ownerDocument = globalThis?.document,\n deferPointerDownOutside = false,\n isDeferredPointerDownOutsideRef,\n dismissableSurfaces,\n shouldHandlePointerDownOutside = IS_TRUE,\n } = args;\n const handlePointerDownOutside = useCallbackRef(onPointerDownOutside) as EventListener;\n const isPointerInsideReactTreeRef = React.useRef(false);\n const isPointerDownOutsideRef = React.useRef(false);\n const interceptedOutsideInteractionEventsRef = React.useRef<Map<string, boolean>>(new Map());\n const handleClickRef = React.useRef(() => {});\n\n React.useEffect(() => {\n function resetOutsideInteraction() {\n isPointerDownOutsideRef.current = false;\n isDeferredPointerDownOutsideRef.current = false;\n interceptedOutsideInteractionEventsRef.current.clear();\n }\n\n function isOutsideInteractionIntercepted() {\n return Array.from(interceptedOutsideInteractionEventsRef.current.values()).some(Boolean);\n }\n\n function handleInteractionCapture(event: Event) {\n if (!isPointerDownOutsideRef.current) {\n return;\n }\n\n const target = event.target;\n const isDismissableSurface =\n target instanceof Node &&\n [...dismissableSurfaces].some((surface) => surface.contains(target as Node));\n\n if (!isDismissableSurface) {\n interceptedOutsideInteractionEventsRef.current.set(event.type, true);\n }\n\n if (event.type === 'click') {\n window.setTimeout(() => {\n if (isPointerDownOutsideRef.current) {\n handleClickRef.current();\n }\n }, 0);\n }\n }\n\n function handleInteractionBubble(event: Event) {\n if (isPointerDownOutsideRef.current) {\n interceptedOutsideInteractionEventsRef.current.set(event.type, false);\n }\n }\n\n const handlePointerDown = (event: PointerEvent) => {\n if (event.target && !isPointerInsideReactTreeRef.current) {\n if (!shouldHandlePointerDownOutside(event.target)) {\n ownerDocument.removeEventListener('click', handleClickRef.current);\n resetOutsideInteraction();\n isPointerInsideReactTreeRef.current = false;\n return;\n }\n\n const eventDetail = { originalEvent: event };\n isPointerDownOutsideRef.current = true;\n isDeferredPointerDownOutsideRef.current = deferPointerDownOutside && event.button === 0;\n interceptedOutsideInteractionEventsRef.current.clear();\n\n function handleAndDispatchPointerDownOutsideEvent() {\n ownerDocument.removeEventListener('click', handleClickRef.current);\n const wasOutsideInteractionIntercepted = isOutsideInteractionIntercepted();\n resetOutsideInteraction();\n\n if (!wasOutsideInteractionIntercepted) {\n handleAndDispatchCustomEvent(\n POINTER_DOWN_OUTSIDE,\n handlePointerDownOutside,\n eventDetail,\n { discrete: true },\n );\n }\n }\n\n /**\n * When deferring, we need to wait for a click event because:\n *\n * 1. On touch devices, browsers implement a ~350ms delay between the\n * time the user stops touching the display and when the browser\n * executes events. We need to ensure we don't reactivate\n * pointer-events within this timeframe otherwise the browser may\n * execute events that should have been prevented.\n *\n * 2. Browser extensions and other third-party code may call\n * `stopPropagation` on later mouse events like `mousedown`,\n * `mouseup`, or `click`. Waiting lets those intercepted events\n * cancel the outside interaction before we dismiss the layer. See\n * https://github.com/radix-ui/primitives/issues/2055\n *\n * Additionally, this also lets us deal automatically with cancellations\n * when a click event isn't raised because the page was considered\n * scrolled/drag-scrolled, long-pressed, etc.\n *\n * This is why we also continuously remove the previous listener,\n * because we cannot be certain that it was raised, and therefore\n * cleaned-up.\n *\n * For non-primary buttons, we dispatch the event immediately because we\n * cannot be certain that the event was canceled.\n */\n if (!deferPointerDownOutside || event.button !== 0) {\n handleAndDispatchPointerDownOutsideEvent();\n } else {\n ownerDocument.removeEventListener('click', handleClickRef.current);\n handleClickRef.current = handleAndDispatchPointerDownOutsideEvent;\n ownerDocument.addEventListener('click', handleClickRef.current, { once: true });\n }\n } else {\n // We need to remove the event listener in case the outside click has been canceled.\n // See: https://github.com/radix-ui/primitives/issues/2171\n ownerDocument.removeEventListener('click', handleClickRef.current);\n resetOutsideInteraction();\n }\n isPointerInsideReactTreeRef.current = false;\n };\n\n const outsideInteractionEvents = [\n 'pointerup',\n 'mousedown',\n 'mouseup',\n 'touchstart',\n 'touchend',\n 'click',\n ];\n\n for (const eventName of outsideInteractionEvents) {\n ownerDocument.addEventListener(eventName, handleInteractionCapture, true);\n ownerDocument.addEventListener(eventName, handleInteractionBubble);\n }\n\n /**\n * if this hook executes in a component that mounts via a `pointerdown` event, the event\n * would bubble up to the document and trigger a `pointerDownOutside` event. We avoid\n * this by delaying the event listener registration on the document.\n * This is not React specific, but rather how the DOM works, ie:\n * ```\n * button.addEventListener('pointerdown', () => {\n * console.log('I will log');\n * document.addEventListener('pointerdown', () => {\n * console.log('I will also log');\n * })\n * });\n */\n const timerId = window.setTimeout(() => {\n ownerDocument.addEventListener('pointerdown', handlePointerDown);\n }, 0);\n return () => {\n window.clearTimeout(timerId);\n ownerDocument.removeEventListener('pointerdown', handlePointerDown);\n ownerDocument.removeEventListener('click', handleClickRef.current);\n for (const eventName of outsideInteractionEvents) {\n ownerDocument.removeEventListener(eventName, handleInteractionCapture, true);\n ownerDocument.removeEventListener(eventName, handleInteractionBubble);\n }\n };\n }, [\n ownerDocument,\n handlePointerDownOutside,\n deferPointerDownOutside,\n isDeferredPointerDownOutsideRef,\n dismissableSurfaces,\n shouldHandlePointerDownOutside,\n ]);\n\n return {\n // ensures we check React component tree (not just DOM tree)\n onPointerDownCapture: () => (isPointerInsideReactTreeRef.current = true),\n };\n}\n\n/**\n * Listens for when focus happens outside a react subtree.\n * Returns props to pass to the root (node) of the subtree we want to check.\n */\nfunction useFocusOutside(\n onFocusOutside?: (event: FocusOutsideEvent) => void,\n ownerDocument: Document = globalThis?.document,\n) {\n const handleFocusOutside = useCallbackRef(onFocusOutside) as EventListener;\n const isFocusInsideReactTreeRef = React.useRef(false);\n\n React.useEffect(() => {\n const handleFocus = (event: FocusEvent) => {\n if (event.target && !isFocusInsideReactTreeRef.current) {\n const eventDetail = { originalEvent: event };\n handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {\n discrete: false,\n });\n }\n };\n ownerDocument.addEventListener('focusin', handleFocus);\n return () => ownerDocument.removeEventListener('focusin', handleFocus);\n }, [ownerDocument, handleFocusOutside]);\n\n return {\n onFocusCapture: () => (isFocusInsideReactTreeRef.current = true),\n onBlurCapture: () => (isFocusInsideReactTreeRef.current = false),\n };\n}\n\nfunction dispatchUpdate() {\n const event = new CustomEvent(CONTEXT_UPDATE);\n document.dispatchEvent(event);\n}\n\nfunction handleAndDispatchCustomEvent<E extends CustomEvent, OriginalEvent extends Event>(\n name: string,\n handler: ((event: E) => void) | undefined,\n detail: { originalEvent: OriginalEvent } & (E extends CustomEvent<infer D> ? D : never),\n { discrete }: { discrete: boolean },\n) {\n const target = detail.originalEvent.target;\n const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });\n if (handler) target.addEventListener(name, handler as EventListener, { once: true });\n\n if (discrete) {\n dispatchDiscreteCustomEvent(target, event);\n } else {\n target.dispatchEvent(event);\n }\n}\n\nexport {\n DismissableLayer,\n DismissableLayerBranch,\n useDismissableLayerSurface,\n //\n DismissableLayer as Root,\n DismissableLayerBranch as Branch,\n};\nexport type { DismissableLayerProps };\n"], | ||
| "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,uBAAqC;AACrC,6BAAuD;AACvD,gCAAgC;AAChC,oCAA+B;AA6NzB;AAxNN,IAAM,iBAAiB;AACvB,IAAM,uBAAuB;AAC7B,IAAM,gBAAgB;AAEtB,IAAI;AAEJ,IAAM,0BAAgC,oBAAc;AAAA,EAClD,QAAQ,oBAAI,IAA6B;AAAA,EACzC,wCAAwC,oBAAI,IAA6B;AAAA,EACzE,UAAU,oBAAI,IAAmC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOjD,qBAAqB,oBAAI,IAAmC;AAC9D,CAAC;AA4CD,IAAM,mBAAmC,gBAAM;AAAA;AAAA,EAK7C,gCAASA,kBAAiB,OAAO,cAAc;AAC7C,UAAM;AAAA,MACJ,8BAA8B;AAAA,MAC9B,0BAA0B;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AACJ,UAAM,UAAgB,iBAAW,uBAAuB;AACxD,UAAM,CAAC,MAAM,OAAO,IAAU,eAAyC,IAAI;AAC3E,UAAM,g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B,UAAU,MAA3C;AAAA,IAChB,eAAe,6BAAO,0BAA0B,UAAU,OAA3C;AAAA,EACjB;AACF;AAxBS;AA0BT,SAAS,iBAAiB;AACxB,QAAM,QAAQ,IAAI,YAAY,cAAc;AAC5C,WAAS,cAAc,KAAK;AAC9B;AAHS;AAKT,SAAS,6BACP,MACA,SACA,QACA,EAAE,SAAS,GACX;AACA,QAAM,SAAS,OAAO,cAAc;AACpC,QAAM,QAAQ,IAAI,YAAY,MAAM,EAAE,SAAS,OAAO,YAAY,MAAM,OAAO,CAAC;AAChF,MAAI,QAAS,QAAO,iBAAiB,MAAM,SAA0B,EAAE,MAAM,KAAK,CAAC;AAEnF,MAAI,UAAU;AACZ,4DAA4B,QAAQ,KAAK;AAAA,EAC3C,OAAO;AACL,WAAO,cAAc,KAAK;AAAA,EAC5B;AACF;AAfS;", | ||
| "sourcesContent": ["'use client';\nexport {\n DismissableLayer,\n DismissableLayerBranch,\n //\n Root,\n Branch,\n /** @internal */\n useDismissableLayerSurface,\n} from './dismissable-layer';\nexport type { DismissableLayerProps } from './dismissable-layer';\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { Primitive, dispatchDiscreteCustomEvent } from '@radix-ui/react-primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\n\n/* -------------------------------------------------------------------------------------------------\n * DismissableLayer\n * -----------------------------------------------------------------------------------------------*/\nconst CONTEXT_UPDATE = 'dismissableLayer.update';\nconst POINTER_DOWN_OUTSIDE = 'dismissableLayer.pointerDownOutside';\nconst FOCUS_OUTSIDE = 'dismissableLayer.focusOutside';\n\nlet originalBodyPointerEvents: string;\n\nconst DismissableLayerContext = React.createContext({\n layers: new Set<DismissableLayerElement>(),\n layersWithOutsidePointerEventsDisabled: new Set<DismissableLayerElement>(),\n branches: new Set<DismissableLayerBranchElement>(),\n\n // Outside elements that belong to a layer's own dismiss affordance (eg, a\n // dialog overlay). Pressing them should dismiss the layer regardless of\n // whether or not they stop propagation.\n //\n // See https://github.com/radix-ui/primitives/issues/3346\n dismissableSurfaces: new Set<DismissableLayerBranchElement>(),\n});\n\ntype DismissableLayerElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface DismissableLayerProps extends PrimitiveDivProps {\n /**\n * When `true`, hover/focus/click interactions will be disabled on elements outside\n * the `DismissableLayer`. Users will need to click twice on outside elements to\n * interact with them: once to close the `DismissableLayer`, and again to trigger the element.\n */\n disableOutsidePointerEvents?: boolean;\n /**\n * When `true`, a `'pointerdown'` event outside of the layered element will\n * wait for the interaction's click event before dispatching, allowing\n * third-party code to stop propagation of later events and cancel dismissal.\n */\n deferPointerDownOutside?: boolean;\n /**\n * Event handler called when the escape key is down.\n * Can be prevented.\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void;\n /**\n * Event handler called when the a `pointerdown` event happens outside of the `DismissableLayer`.\n * Can be prevented.\n */\n onPointerDownOutside?: (event: PointerDownOutsideEvent) => void;\n /**\n * Event handler called when the focus moves outside of the `DismissableLayer`.\n * Can be prevented.\n */\n onFocusOutside?: (event: FocusOutsideEvent) => void;\n /**\n * Event handler called when an interaction happens outside the `DismissableLayer`.\n * Specifically, when a `pointerdown` event happens outside or focus moves outside of it.\n * Can be prevented.\n */\n onInteractOutside?: (event: PointerDownOutsideEvent | FocusOutsideEvent) => void;\n /**\n * Handler called when the `DismissableLayer` should be dismissed\n */\n onDismiss?: () => void;\n}\n\nconst DismissableLayer = /* @__PURE__ */ React.forwardRef<\n DismissableLayerElement,\n DismissableLayerProps\n>(\n // blank line to reduce diff noise\n function DismissableLayer(props, forwardedRef) {\n const {\n disableOutsidePointerEvents = false,\n deferPointerDownOutside = false,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n onDismiss,\n ...layerProps\n } = props;\n const context = React.useContext(DismissableLayerContext);\n const [node, setNode] = React.useState<DismissableLayerElement | null>(null);\n const ownerDocument = node?.ownerDocument ?? globalThis?.document;\n const [, force] = React.useState({});\n const composedRefs = useComposedRefs(forwardedRef, setNode);\n const layers = Array.from(context.layers);\n const [highestLayerWithOutsidePointerEventsDisabled] = [\n ...context.layersWithOutsidePointerEventsDisabled,\n ].slice(-1);\n const highestLayerWithOutsidePointerEventsDisabledIndex =\n highestLayerWithOutsidePointerEventsDisabled\n ? layers.indexOf(highestLayerWithOutsidePointerEventsDisabled)\n : -1;\n const index = node ? layers.indexOf(node) : -1;\n const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;\n const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;\n const isDeferredPointerDownOutsideRef = React.useRef(false);\n\n const pointerDownOutside = usePointerDownOutside(\n (event) => {\n onPointerDownOutside?.(event);\n onInteractOutside?.(event);\n if (!event.defaultPrevented) onDismiss?.();\n },\n {\n ownerDocument,\n deferPointerDownOutside,\n isDeferredPointerDownOutsideRef,\n dismissableSurfaces: context.dismissableSurfaces,\n shouldHandlePointerDownOutside: React.useCallback(\n (target: EventTarget | null) => {\n if (!(target instanceof Node)) {\n return false;\n }\n\n const isPointerDownOnBranch = [...context.branches].some((branch) =>\n branch.contains(target),\n );\n return isPointerEventsEnabled && !isPointerDownOnBranch;\n },\n [context.branches, isPointerEventsEnabled],\n ),\n },\n );\n\n const focusOutside = useFocusOutside((event) => {\n if (deferPointerDownOutside && isDeferredPointerDownOutsideRef.current) {\n return;\n }\n\n const target = event.target as HTMLElement;\n const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));\n if (isFocusInBranch) return;\n onFocusOutside?.(event);\n onInteractOutside?.(event);\n if (!event.defaultPrevented) onDismiss?.();\n }, ownerDocument);\n\n const isHighestLayer = node ? index === layers.length - 1 : false;\n\n // Stabilize via `useCallbackRef` rather than `useEffectEvent`: React's\n // native `useEffectEvent` returns a stale closure inside `forwardRef`\n // components on React 19.2.x, which caused escape handlers to observe\n // mount-time props/state instead of the latest values.\n //\n // We should revert this to use useEffectEvent when the fix lands in React.\n //\n // - https://github.com/radix-ui/primitives/issues/4014\n // - https://github.com/react/react/pull/34831\n const handleKeyDown = useCallbackRef((event: KeyboardEvent) => {\n if (event.key !== 'Escape') {\n return;\n }\n\n onEscapeKeyDown?.(event);\n if (!event.defaultPrevented && onDismiss) {\n event.preventDefault();\n onDismiss();\n }\n });\n\n React.useEffect(() => {\n if (!isHighestLayer) {\n return;\n }\n\n ownerDocument.addEventListener('keydown', handleKeyDown, { capture: true });\n return () => ownerDocument.removeEventListener('keydown', handleKeyDown, { capture: true });\n }, [ownerDocument, isHighestLayer, handleKeyDown]);\n\n React.useEffect(() => {\n if (!node) return;\n if (disableOutsidePointerEvents) {\n if (context.layersWithOutsidePointerEventsDisabled.size === 0) {\n originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;\n ownerDocument.body.style.pointerEvents = 'none';\n }\n context.layersWithOutsidePointerEventsDisabled.add(node);\n }\n context.layers.add(node);\n dispatchUpdate();\n return () => {\n // We must remove this layer from the disabled set whenever\n // `disableOutsidePointerEvents` becomes `false` (eg, when a modal\n // closes but stays mounted during an exit animation) and not only on\n // unmount. Otherwise the `body` `pointer-events` could be left as\n // `none` when multiple layers overlap.\n // See: https://github.com/radix-ui/primitives/issues/3645\n if (disableOutsidePointerEvents) {\n context.layersWithOutsidePointerEventsDisabled.delete(node);\n if (context.layersWithOutsidePointerEventsDisabled.size === 0) {\n ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;\n }\n }\n };\n }, [node, ownerDocument, disableOutsidePointerEvents, context]);\n\n /**\n * We purposefully prevent combining this effect with the `disableOutsidePointerEvents` effect\n * because a change to `disableOutsidePointerEvents` would remove this layer from the stack\n * and add it to the end again so the layering order wouldn't be _creation order_.\n * We only want them to be removed from context stacks when unmounted.\n */\n React.useEffect(() => {\n return () => {\n if (!node) return;\n context.layers.delete(node);\n context.layersWithOutsidePointerEventsDisabled.delete(node);\n dispatchUpdate();\n };\n }, [node, context]);\n\n React.useEffect(() => {\n const handleUpdate = () => force({});\n document.addEventListener(CONTEXT_UPDATE, handleUpdate);\n return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);\n }, []);\n\n return (\n <Primitive.div\n {...layerProps}\n ref={composedRefs}\n style={{\n pointerEvents: isBodyPointerEventsDisabled\n ? isPointerEventsEnabled\n ? 'auto'\n : 'none'\n : undefined,\n ...props.style,\n }}\n onFocusCapture={composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture)}\n onBlurCapture={composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture)}\n onPointerDownCapture={composeEventHandlers(\n props.onPointerDownCapture,\n pointerDownOutside.onPointerDownCapture,\n )}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DismissableLayerBranch\n * -----------------------------------------------------------------------------------------------*/\n\ntype DismissableLayerBranchElement = React.ComponentRef<typeof Primitive.div>;\ninterface DismissableLayerBranchProps extends PrimitiveDivProps {}\n\nconst DismissableLayerBranch = /* @__PURE__ */ React.forwardRef<\n DismissableLayerBranchElement,\n DismissableLayerBranchProps\n>(function DismissableLayerBranch(props, forwardedRef) {\n const context = React.useContext(DismissableLayerContext);\n const ref = React.useRef<DismissableLayerBranchElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n\n React.useEffect(() => {\n const node = ref.current;\n if (node) {\n context.branches.add(node);\n return () => {\n context.branches.delete(node);\n };\n }\n }, [context.branches]);\n\n return <Primitive.div {...props} ref={composedRefs} />;\n});\n\n/* -----------------------------------------------------------------------------------------------*/\n\n/**\n * Registers a node as a \"dismiss surface\" for the enclosing DismissableLayer\n */\nfunction useDismissableLayerSurface(): React.RefCallback<DismissableLayerBranchElement> {\n const context = React.useContext(DismissableLayerContext);\n const [node, setNode] = React.useState<DismissableLayerBranchElement | null>(null);\n\n React.useEffect(() => {\n if (!node) {\n return;\n }\n context.dismissableSurfaces.add(node);\n return () => {\n context.dismissableSurfaces.delete(node);\n };\n }, [node, context.dismissableSurfaces]);\n\n return setNode;\n}\n\ntype PointerDownOutsideEvent = CustomEvent<{ originalEvent: PointerEvent }>;\ntype FocusOutsideEvent = CustomEvent<{ originalEvent: FocusEvent }>;\n\nconst IS_TRUE = () => true;\n\n/**\n * Listens for `pointerdown` outside a react subtree. We detect the start of the interaction on\n * `pointerdown`, then wait for `click` so external code can intercept later mouse events.\n * Returns props to pass to the node we want to check for outside events.\n */\nfunction usePointerDownOutside(\n onPointerDownOutside: ((event: PointerDownOutsideEvent) => void) | undefined,\n args: {\n ownerDocument: Document | undefined;\n deferPointerDownOutside: boolean;\n isDeferredPointerDownOutsideRef: React.RefObject<boolean>;\n dismissableSurfaces: Set<DismissableLayerBranchElement>;\n shouldHandlePointerDownOutside?: (target: EventTarget | null) => boolean;\n },\n) {\n const {\n ownerDocument = globalThis?.document,\n deferPointerDownOutside = false,\n isDeferredPointerDownOutsideRef,\n dismissableSurfaces,\n shouldHandlePointerDownOutside = IS_TRUE,\n } = args;\n const handlePointerDownOutside = useCallbackRef(onPointerDownOutside) as EventListener;\n const isPointerInsideReactTreeRef = React.useRef(false);\n const isPointerDownOutsideRef = React.useRef(false);\n const interceptedOutsideInteractionEventsRef = React.useRef<Map<string, boolean>>(new Map());\n const handleClickRef = React.useRef(() => {});\n\n React.useEffect(() => {\n function resetOutsideInteraction() {\n isPointerDownOutsideRef.current = false;\n isDeferredPointerDownOutsideRef.current = false;\n interceptedOutsideInteractionEventsRef.current.clear();\n }\n\n function isOutsideInteractionIntercepted() {\n return Array.from(interceptedOutsideInteractionEventsRef.current.values()).some(Boolean);\n }\n\n function handleInteractionCapture(event: Event) {\n if (!isPointerDownOutsideRef.current) {\n return;\n }\n\n const target = event.target;\n const isDismissableSurface =\n target instanceof Node &&\n [...dismissableSurfaces].some((surface) => surface.contains(target as Node));\n\n if (!isDismissableSurface) {\n interceptedOutsideInteractionEventsRef.current.set(event.type, true);\n }\n\n if (event.type === 'click') {\n window.setTimeout(() => {\n if (isPointerDownOutsideRef.current) {\n handleClickRef.current();\n }\n }, 0);\n }\n }\n\n function handleInteractionBubble(event: Event) {\n if (isPointerDownOutsideRef.current) {\n interceptedOutsideInteractionEventsRef.current.set(event.type, false);\n }\n }\n\n const handlePointerDown = (event: PointerEvent) => {\n if (event.target && !isPointerInsideReactTreeRef.current) {\n if (!shouldHandlePointerDownOutside(event.target)) {\n ownerDocument.removeEventListener('click', handleClickRef.current);\n resetOutsideInteraction();\n isPointerInsideReactTreeRef.current = false;\n return;\n }\n\n const eventDetail = { originalEvent: event };\n isPointerDownOutsideRef.current = true;\n isDeferredPointerDownOutsideRef.current = deferPointerDownOutside && event.button === 0;\n interceptedOutsideInteractionEventsRef.current.clear();\n\n function handleAndDispatchPointerDownOutsideEvent() {\n ownerDocument.removeEventListener('click', handleClickRef.current);\n const wasOutsideInteractionIntercepted = isOutsideInteractionIntercepted();\n resetOutsideInteraction();\n\n if (!wasOutsideInteractionIntercepted) {\n handleAndDispatchCustomEvent(\n POINTER_DOWN_OUTSIDE,\n handlePointerDownOutside,\n eventDetail,\n { discrete: true },\n );\n }\n }\n\n /**\n * When deferring, we need to wait for a click event because:\n *\n * 1. On touch devices, browsers implement a ~350ms delay between the\n * time the user stops touching the display and when the browser\n * executes events. We need to ensure we don't reactivate\n * pointer-events within this timeframe otherwise the browser may\n * execute events that should have been prevented.\n *\n * 2. Browser extensions and other third-party code may call\n * `stopPropagation` on later mouse events like `mousedown`,\n * `mouseup`, or `click`. Waiting lets those intercepted events\n * cancel the outside interaction before we dismiss the layer. See\n * https://github.com/radix-ui/primitives/issues/2055\n *\n * Additionally, this also lets us deal automatically with cancellations\n * when a click event isn't raised because the page was considered\n * scrolled/drag-scrolled, long-pressed, etc.\n *\n * This is why we also continuously remove the previous listener,\n * because we cannot be certain that it was raised, and therefore\n * cleaned-up.\n *\n * For non-primary buttons, we dispatch the event immediately because we\n * cannot be certain that the event was canceled.\n */\n if (!deferPointerDownOutside || event.button !== 0) {\n handleAndDispatchPointerDownOutsideEvent();\n } else {\n ownerDocument.removeEventListener('click', handleClickRef.current);\n handleClickRef.current = handleAndDispatchPointerDownOutsideEvent;\n ownerDocument.addEventListener('click', handleClickRef.current, { once: true });\n }\n } else {\n // We need to remove the event listener in case the outside click has been canceled.\n // See: https://github.com/radix-ui/primitives/issues/2171\n ownerDocument.removeEventListener('click', handleClickRef.current);\n resetOutsideInteraction();\n }\n isPointerInsideReactTreeRef.current = false;\n };\n\n const outsideInteractionEvents = [\n 'pointerup',\n 'mousedown',\n 'mouseup',\n 'touchstart',\n 'touchend',\n 'click',\n ];\n\n for (const eventName of outsideInteractionEvents) {\n ownerDocument.addEventListener(eventName, handleInteractionCapture, true);\n ownerDocument.addEventListener(eventName, handleInteractionBubble);\n }\n\n /**\n * if this hook executes in a component that mounts via a `pointerdown` event, the event\n * would bubble up to the document and trigger a `pointerDownOutside` event. We avoid\n * this by delaying the event listener registration on the document.\n * This is not React specific, but rather how the DOM works, ie:\n * ```\n * button.addEventListener('pointerdown', () => {\n * console.log('I will log');\n * document.addEventListener('pointerdown', () => {\n * console.log('I will also log');\n * })\n * });\n */\n const timerId = window.setTimeout(() => {\n ownerDocument.addEventListener('pointerdown', handlePointerDown);\n }, 0);\n return () => {\n window.clearTimeout(timerId);\n ownerDocument.removeEventListener('pointerdown', handlePointerDown);\n ownerDocument.removeEventListener('click', handleClickRef.current);\n for (const eventName of outsideInteractionEvents) {\n ownerDocument.removeEventListener(eventName, handleInteractionCapture, true);\n ownerDocument.removeEventListener(eventName, handleInteractionBubble);\n }\n };\n }, [\n ownerDocument,\n handlePointerDownOutside,\n deferPointerDownOutside,\n isDeferredPointerDownOutsideRef,\n dismissableSurfaces,\n shouldHandlePointerDownOutside,\n ]);\n\n return {\n // ensures we check React component tree (not just DOM tree)\n onPointerDownCapture: () => (isPointerInsideReactTreeRef.current = true),\n };\n}\n\n/**\n * Listens for when focus happens outside a react subtree.\n * Returns props to pass to the root (node) of the subtree we want to check.\n */\nfunction useFocusOutside(\n onFocusOutside?: (event: FocusOutsideEvent) => void,\n ownerDocument: Document = globalThis?.document,\n) {\n const handleFocusOutside = useCallbackRef(onFocusOutside) as EventListener;\n const isFocusInsideReactTreeRef = React.useRef(false);\n\n React.useEffect(() => {\n const handleFocus = (event: FocusEvent) => {\n if (event.target && !isFocusInsideReactTreeRef.current) {\n const eventDetail = { originalEvent: event };\n handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {\n discrete: false,\n });\n }\n };\n ownerDocument.addEventListener('focusin', handleFocus);\n return () => ownerDocument.removeEventListener('focusin', handleFocus);\n }, [ownerDocument, handleFocusOutside]);\n\n return {\n onFocusCapture: () => (isFocusInsideReactTreeRef.current = true),\n onBlurCapture: () => (isFocusInsideReactTreeRef.current = false),\n };\n}\n\nfunction dispatchUpdate() {\n const event = new CustomEvent(CONTEXT_UPDATE);\n document.dispatchEvent(event);\n}\n\nfunction handleAndDispatchCustomEvent<E extends CustomEvent, OriginalEvent extends Event>(\n name: string,\n handler: ((event: E) => void) | undefined,\n detail: { originalEvent: OriginalEvent } & (E extends CustomEvent<infer D> ? D : never),\n { discrete }: { discrete: boolean },\n) {\n const target = detail.originalEvent.target;\n const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });\n if (handler) target.addEventListener(name, handler as EventListener, { once: true });\n\n if (discrete) {\n dispatchDiscreteCustomEvent(target, event);\n } else {\n target.dispatchEvent(event);\n }\n}\n\nconst Root = DismissableLayer;\nconst Branch = DismissableLayerBranch;\n\nexport {\n DismissableLayer,\n DismissableLayerBranch,\n useDismissableLayerSurface,\n //\n Root,\n Branch,\n};\nexport type { DismissableLayerProps };\n"], | ||
| "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,uBAAqC;AACrC,6BAAuD;AACvD,gCAAgC;AAChC,oCAA+B;AA6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vent"] | ||
| } |
+4
-2
@@ -355,9 +355,11 @@ "use client"; | ||
| __name(handleAndDispatchCustomEvent, "handleAndDispatchCustomEvent"); | ||
| var Root = DismissableLayer; | ||
| var Branch = DismissableLayerBranch; | ||
| export { | ||
| DismissableLayerBranch as Branch, | ||
| Branch, | ||
| DismissableLayer, | ||
| DismissableLayerBranch, | ||
| DismissableLayer as Root, | ||
| Root, | ||
| useDismissableLayerSurface | ||
| }; | ||
| //# sourceMappingURL=index.mjs.map |
| { | ||
| "version": 3, | ||
| "sources": ["../src/dismissable-layer.tsx"], | ||
| "sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { Primitive, dispatchDiscreteCustomEvent } from '@radix-ui/react-primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\n\n/* -------------------------------------------------------------------------------------------------\n * DismissableLayer\n * -----------------------------------------------------------------------------------------------*/\nconst CONTEXT_UPDATE = 'dismissableLayer.update';\nconst POINTER_DOWN_OUTSIDE = 'dismissableLayer.pointerDownOutside';\nconst FOCUS_OUTSIDE = 'dismissableLayer.focusOutside';\n\nlet originalBodyPointerEvents: string;\n\nconst DismissableLayerContext = React.createContext({\n layers: new Set<DismissableLayerElement>(),\n layersWithOutsidePointerEventsDisabled: new Set<DismissableLayerElement>(),\n branches: new Set<DismissableLayerBranchElement>(),\n\n // Outside elements that belong to a layer's own dismiss affordance (eg, a\n // dialog overlay). Pressing them should dismiss the layer regardless of\n // whether or not they stop propagation.\n //\n // See https://github.com/radix-ui/primitives/issues/3346\n dismissableSurfaces: new Set<DismissableLayerBranchElement>(),\n});\n\ntype DismissableLayerElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface DismissableLayerProps extends PrimitiveDivProps {\n /**\n * When `true`, hover/focus/click interactions will be disabled on elements outside\n * the `DismissableLayer`. Users will need to click twice on outside elements to\n * interact with them: once to close the `DismissableLayer`, and again to trigger the element.\n */\n disableOutsidePointerEvents?: boolean;\n /**\n * When `true`, a `'pointerdown'` event outside of the layered element will\n * wait for the interaction's click event before dispatching, allowing\n * third-party code to stop propagation of later events and cancel dismissal.\n */\n deferPointerDownOutside?: boolean;\n /**\n * Event handler called when the escape key is down.\n * Can be prevented.\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void;\n /**\n * Event handler called when the a `pointerdown` event happens outside of the `DismissableLayer`.\n * Can be prevented.\n */\n onPointerDownOutside?: (event: PointerDownOutsideEvent) => void;\n /**\n * Event handler called when the focus moves outside of the `DismissableLayer`.\n * Can be prevented.\n */\n onFocusOutside?: (event: FocusOutsideEvent) => void;\n /**\n * Event handler called when an interaction happens outside the `DismissableLayer`.\n * Specifically, when a `pointerdown` event happens outside or focus moves outside of it.\n * Can be prevented.\n */\n onInteractOutside?: (event: PointerDownOutsideEvent | FocusOutsideEvent) => void;\n /**\n * Handler called when the `DismissableLayer` should be dismissed\n */\n onDismiss?: () => void;\n}\n\nconst DismissableLayer = /* @__PURE__ */ React.forwardRef<\n DismissableLayerElement,\n DismissableLayerProps\n>(\n // blank line to reduce diff noise\n function DismissableLayer(props, forwardedRef) {\n const {\n disableOutsidePointerEvents = false,\n deferPointerDownOutside = false,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n onDismiss,\n ...layerProps\n } = props;\n const context = React.useContext(DismissableLayerContext);\n const [node, setNode] = React.useState<DismissableLayerElement | null>(null);\n const ownerDocument = node?.ownerDocument ?? globalThis?.document;\n const [, force] = React.useState({});\n const composedRefs = useComposedRefs(forwardedRef, setNode);\n const layers = Array.from(context.layers);\n const [highestLayerWithOutsidePointerEventsDisabled] = [\n ...context.layersWithOutsidePointerEventsDisabled,\n ].slice(-1);\n const highestLayerWithOutsidePointerEventsDisabledIndex =\n highestLayerWithOutsidePointerEventsDisabled\n ? layers.indexOf(highestLayerWithOutsidePointerEventsDisabled)\n : -1;\n const index = node ? layers.indexOf(node) : -1;\n const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;\n const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;\n const isDeferredPointerDownOutsideRef = React.useRef(false);\n\n const pointerDownOutside = usePointerDownOutside(\n (event) => {\n onPointerDownOutside?.(event);\n onInteractOutside?.(event);\n if (!event.defaultPrevented) onDismiss?.();\n },\n {\n ownerDocument,\n deferPointerDownOutside,\n isDeferredPointerDownOutsideRef,\n dismissableSurfaces: context.dismissableSurfaces,\n shouldHandlePointerDownOutside: React.useCallback(\n (target: EventTarget | null) => {\n if (!(target instanceof Node)) {\n return false;\n }\n\n const isPointerDownOnBranch = [...context.branches].some((branch) =>\n branch.contains(target),\n );\n return isPointerEventsEnabled && !isPointerDownOnBranch;\n },\n [context.branches, isPointerEventsEnabled],\n ),\n },\n );\n\n const focusOutside = useFocusOutside((event) => {\n if (deferPointerDownOutside && isDeferredPointerDownOutsideRef.current) {\n return;\n }\n\n const target = event.target as HTMLElement;\n const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));\n if (isFocusInBranch) return;\n onFocusOutside?.(event);\n onInteractOutside?.(event);\n if (!event.defaultPrevented) onDismiss?.();\n }, ownerDocument);\n\n const isHighestLayer = node ? index === layers.length - 1 : false;\n\n // Stabilize via `useCallbackRef` rather than `useEffectEvent`: React's\n // native `useEffectEvent` returns a stale closure inside `forwardRef`\n // components on React 19.2.x, which caused escape handlers to observe\n // mount-time props/state instead of the latest values.\n //\n // We should revert this to use useEffectEvent when the fix lands in React.\n //\n // - https://github.com/radix-ui/primitives/issues/4014\n // - https://github.com/react/react/pull/34831\n const handleKeyDown = useCallbackRef((event: KeyboardEvent) => {\n if (event.key !== 'Escape') {\n return;\n }\n\n onEscapeKeyDown?.(event);\n if (!event.defaultPrevented && onDismiss) {\n event.preventDefault();\n onDismiss();\n }\n });\n\n React.useEffect(() => {\n if (!isHighestLayer) {\n return;\n }\n\n ownerDocument.addEventListener('keydown', handleKeyDown, { capture: true });\n return () => ownerDocument.removeEventListener('keydown', handleKeyDown, { capture: true });\n }, [ownerDocument, isHighestLayer, handleKeyDown]);\n\n React.useEffect(() => {\n if (!node) return;\n if (disableOutsidePointerEvents) {\n if (context.layersWithOutsidePointerEventsDisabled.size === 0) {\n originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;\n ownerDocument.body.style.pointerEvents = 'none';\n }\n context.layersWithOutsidePointerEventsDisabled.add(node);\n }\n context.layers.add(node);\n dispatchUpdate();\n return () => {\n // We must remove this layer from the disabled set whenever\n // `disableOutsidePointerEvents` becomes `false` (eg, when a modal\n // closes but stays mounted during an exit animation) and not only on\n // unmount. Otherwise the `body` `pointer-events` could be left as\n // `none` when multiple layers overlap.\n // See: https://github.com/radix-ui/primitives/issues/3645\n if (disableOutsidePointerEvents) {\n context.layersWithOutsidePointerEventsDisabled.delete(node);\n if (context.layersWithOutsidePointerEventsDisabled.size === 0) {\n ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;\n }\n }\n };\n }, [node, ownerDocument, disableOutsidePointerEvents, context]);\n\n /**\n * We purposefully prevent combining this effect with the `disableOutsidePointerEvents` effect\n * because a change to `disableOutsidePointerEvents` would remove this layer from the stack\n * and add it to the end again so the layering order wouldn't be _creation order_.\n * We only want them to be removed from context stacks when unmounted.\n */\n React.useEffect(() => {\n return () => {\n if (!node) return;\n context.layers.delete(node);\n context.layersWithOutsidePointerEventsDisabled.delete(node);\n dispatchUpdate();\n };\n }, [node, context]);\n\n React.useEffect(() => {\n const handleUpdate = () => force({});\n document.addEventListener(CONTEXT_UPDATE, handleUpdate);\n return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);\n }, []);\n\n return (\n <Primitive.div\n {...layerProps}\n ref={composedRefs}\n style={{\n pointerEvents: isBodyPointerEventsDisabled\n ? isPointerEventsEnabled\n ? 'auto'\n : 'none'\n : undefined,\n ...props.style,\n }}\n onFocusCapture={composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture)}\n onBlurCapture={composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture)}\n onPointerDownCapture={composeEventHandlers(\n props.onPointerDownCapture,\n pointerDownOutside.onPointerDownCapture,\n )}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DismissableLayerBranch\n * -----------------------------------------------------------------------------------------------*/\n\ntype DismissableLayerBranchElement = React.ComponentRef<typeof Primitive.div>;\ninterface DismissableLayerBranchProps extends PrimitiveDivProps {}\n\nconst DismissableLayerBranch = /* @__PURE__ */ React.forwardRef<\n DismissableLayerBranchElement,\n DismissableLayerBranchProps\n>(function DismissableLayerBranch(props, forwardedRef) {\n const context = React.useContext(DismissableLayerContext);\n const ref = React.useRef<DismissableLayerBranchElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n\n React.useEffect(() => {\n const node = ref.current;\n if (node) {\n context.branches.add(node);\n return () => {\n context.branches.delete(node);\n };\n }\n }, [context.branches]);\n\n return <Primitive.div {...props} ref={composedRefs} />;\n});\n\n/* -----------------------------------------------------------------------------------------------*/\n\n/**\n * Registers a node as a \"dismiss surface\" for the enclosing DismissableLayer\n */\nfunction useDismissableLayerSurface(): React.RefCallback<DismissableLayerBranchElement> {\n const context = React.useContext(DismissableLayerContext);\n const [node, setNode] = React.useState<DismissableLayerBranchElement | null>(null);\n\n React.useEffect(() => {\n if (!node) {\n return;\n }\n context.dismissableSurfaces.add(node);\n return () => {\n context.dismissableSurfaces.delete(node);\n };\n }, [node, context.dismissableSurfaces]);\n\n return setNode;\n}\n\ntype PointerDownOutsideEvent = CustomEvent<{ originalEvent: PointerEvent }>;\ntype FocusOutsideEvent = CustomEvent<{ originalEvent: FocusEvent }>;\n\nconst IS_TRUE = () => true;\n\n/**\n * Listens for `pointerdown` outside a react subtree. We detect the start of the interaction on\n * `pointerdown`, then wait for `click` so external code can intercept later mouse events.\n * Returns props to pass to the node we want to check for outside events.\n */\nfunction usePointerDownOutside(\n onPointerDownOutside: ((event: PointerDownOutsideEvent) => void) | undefined,\n args: {\n ownerDocument: Document | undefined;\n deferPointerDownOutside: boolean;\n isDeferredPointerDownOutsideRef: React.RefObject<boolean>;\n dismissableSurfaces: Set<DismissableLayerBranchElement>;\n shouldHandlePointerDownOutside?: (target: EventTarget | null) => boolean;\n },\n) {\n const {\n ownerDocument = globalThis?.document,\n deferPointerDownOutside = false,\n isDeferredPointerDownOutsideRef,\n dismissableSurfaces,\n shouldHandlePointerDownOutside = IS_TRUE,\n } = args;\n const handlePointerDownOutside = useCallbackRef(onPointerDownOutside) as EventListener;\n const isPointerInsideReactTreeRef = React.useRef(false);\n const isPointerDownOutsideRef = React.useRef(false);\n const interceptedOutsideInteractionEventsRef = React.useRef<Map<string, boolean>>(new Map());\n const handleClickRef = React.useRef(() => {});\n\n React.useEffect(() => {\n function resetOutsideInteraction() {\n isPointerDownOutsideRef.current = false;\n isDeferredPointerDownOutsideRef.current = false;\n interceptedOutsideInteractionEventsRef.current.clear();\n }\n\n function isOutsideInteractionIntercepted() {\n return Array.from(interceptedOutsideInteractionEventsRef.current.values()).some(Boolean);\n }\n\n function handleInteractionCapture(event: Event) {\n if (!isPointerDownOutsideRef.current) {\n return;\n }\n\n const target = event.target;\n const isDismissableSurface =\n target instanceof Node &&\n [...dismissableSurfaces].some((surface) => surface.contains(target as Node));\n\n if (!isDismissableSurface) {\n interceptedOutsideInteractionEventsRef.current.set(event.type, true);\n }\n\n if (event.type === 'click') {\n window.setTimeout(() => {\n if (isPointerDownOutsideRef.current) {\n handleClickRef.current();\n }\n }, 0);\n }\n }\n\n function handleInteractionBubble(event: Event) {\n if (isPointerDownOutsideRef.current) {\n interceptedOutsideInteractionEventsRef.current.set(event.type, false);\n }\n }\n\n const handlePointerDown = (event: PointerEvent) => {\n if (event.target && !isPointerInsideReactTreeRef.current) {\n if (!shouldHandlePointerDownOutside(event.target)) {\n ownerDocument.removeEventListener('click', handleClickRef.current);\n resetOutsideInteraction();\n isPointerInsideReactTreeRef.current = false;\n return;\n }\n\n const eventDetail = { originalEvent: event };\n isPointerDownOutsideRef.current = true;\n isDeferredPointerDownOutsideRef.current = deferPointerDownOutside && event.button === 0;\n interceptedOutsideInteractionEventsRef.current.clear();\n\n function handleAndDispatchPointerDownOutsideEvent() {\n ownerDocument.removeEventListener('click', handleClickRef.current);\n const wasOutsideInteractionIntercepted = isOutsideInteractionIntercepted();\n resetOutsideInteraction();\n\n if (!wasOutsideInteractionIntercepted) {\n handleAndDispatchCustomEvent(\n POINTER_DOWN_OUTSIDE,\n handlePointerDownOutside,\n eventDetail,\n { discrete: true },\n );\n }\n }\n\n /**\n * When deferring, we need to wait for a click event because:\n *\n * 1. On touch devices, browsers implement a ~350ms delay between the\n * time the user stops touching the display and when the browser\n * executes events. We need to ensure we don't reactivate\n * pointer-events within this timeframe otherwise the browser may\n * execute events that should have been prevented.\n *\n * 2. Browser extensions and other third-party code may call\n * `stopPropagation` on later mouse events like `mousedown`,\n * `mouseup`, or `click`. Waiting lets those intercepted events\n * cancel the outside interaction before we dismiss the layer. See\n * https://github.com/radix-ui/primitives/issues/2055\n *\n * Additionally, this also lets us deal automatically with cancellations\n * when a click event isn't raised because the page was considered\n * scrolled/drag-scrolled, long-pressed, etc.\n *\n * This is why we also continuously remove the previous listener,\n * because we cannot be certain that it was raised, and therefore\n * cleaned-up.\n *\n * For non-primary buttons, we dispatch the event immediately because we\n * cannot be certain that the event was canceled.\n */\n if (!deferPointerDownOutside || event.button !== 0) {\n handleAndDispatchPointerDownOutsideEvent();\n } else {\n ownerDocument.removeEventListener('click', handleClickRef.current);\n handleClickRef.current = handleAndDispatchPointerDownOutsideEvent;\n ownerDocument.addEventListener('click', handleClickRef.current, { once: true });\n }\n } else {\n // We need to remove the event listener in case the outside click has been canceled.\n // See: https://github.com/radix-ui/primitives/issues/2171\n ownerDocument.removeEventListener('click', handleClickRef.current);\n resetOutsideInteraction();\n }\n isPointerInsideReactTreeRef.current = false;\n };\n\n const outsideInteractionEvents = [\n 'pointerup',\n 'mousedown',\n 'mouseup',\n 'touchstart',\n 'touchend',\n 'click',\n ];\n\n for (const eventName of outsideInteractionEvents) {\n ownerDocument.addEventListener(eventName, handleInteractionCapture, true);\n ownerDocument.addEventListener(eventName, handleInteractionBubble);\n }\n\n /**\n * if this hook executes in a component that mounts via a `pointerdown` event, the event\n * would bubble up to the document and trigger a `pointerDownOutside` event. We avoid\n * this by delaying the event listener registration on the document.\n * This is not React specific, but rather how the DOM works, ie:\n * ```\n * button.addEventListener('pointerdown', () => {\n * console.log('I will log');\n * document.addEventListener('pointerdown', () => {\n * console.log('I will also log');\n * })\n * });\n */\n const timerId = window.setTimeout(() => {\n ownerDocument.addEventListener('pointerdown', handlePointerDown);\n }, 0);\n return () => {\n window.clearTimeout(timerId);\n ownerDocument.removeEventListener('pointerdown', handlePointerDown);\n ownerDocument.removeEventListener('click', handleClickRef.current);\n for (const eventName of outsideInteractionEvents) {\n ownerDocument.removeEventListener(eventName, handleInteractionCapture, true);\n ownerDocument.removeEventListener(eventName, handleInteractionBubble);\n }\n };\n }, [\n ownerDocument,\n handlePointerDownOutside,\n deferPointerDownOutside,\n isDeferredPointerDownOutsideRef,\n dismissableSurfaces,\n shouldHandlePointerDownOutside,\n ]);\n\n return {\n // ensures we check React component tree (not just DOM tree)\n onPointerDownCapture: () => (isPointerInsideReactTreeRef.current = true),\n };\n}\n\n/**\n * Listens for when focus happens outside a react subtree.\n * Returns props to pass to the root (node) of the subtree we want to check.\n */\nfunction useFocusOutside(\n onFocusOutside?: (event: FocusOutsideEvent) => void,\n ownerDocument: Document = globalThis?.document,\n) {\n const handleFocusOutside = useCallbackRef(onFocusOutside) as EventListener;\n const isFocusInsideReactTreeRef = React.useRef(false);\n\n React.useEffect(() => {\n const handleFocus = (event: FocusEvent) => {\n if (event.target && !isFocusInsideReactTreeRef.current) {\n const eventDetail = { originalEvent: event };\n handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {\n discrete: false,\n });\n }\n };\n ownerDocument.addEventListener('focusin', handleFocus);\n return () => ownerDocument.removeEventListener('focusin', handleFocus);\n }, [ownerDocument, handleFocusOutside]);\n\n return {\n onFocusCapture: () => (isFocusInsideReactTreeRef.current = true),\n onBlurCapture: () => (isFocusInsideReactTreeRef.current = false),\n };\n}\n\nfunction dispatchUpdate() {\n const event = new CustomEvent(CONTEXT_UPDATE);\n document.dispatchEvent(event);\n}\n\nfunction handleAndDispatchCustomEvent<E extends CustomEvent, OriginalEvent extends Event>(\n name: string,\n handler: ((event: E) => void) | undefined,\n detail: { originalEvent: OriginalEvent } & (E extends CustomEvent<infer D> ? D : never),\n { discrete }: { discrete: boolean },\n) {\n const target = detail.originalEvent.target;\n const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });\n if (handler) target.addEventListener(name, handler as EventListener, { once: true });\n\n if (discrete) {\n dispatchDiscreteCustomEvent(target, event);\n } else {\n target.dispatchEvent(event);\n }\n}\n\nexport {\n DismissableLayer,\n DismissableLayerBranch,\n useDismissableLayerSurface,\n //\n DismissableLayer as Root,\n DismissableLayerBranch as Branch,\n};\nexport type { DismissableLayerProps };\n"], | ||
| "mappings": ";;;;;AAAA,YAAY,WAAW;AACvB,SAAS,4BAA4B;AACrC,SAAS,WAAW,mCAAmC;AACvD,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AA6NzB;AAxNN,IAAM,iBAAiB;AACvB,IAAM,uBAAuB;AAC7B,IAAM,gBAAgB;AAEtB,IAAI;AAEJ,IAAM,0BAAgC,oBAAc;AAAA,EAClD,QAAQ,oBAAI,IAA6B;AAAA,EACzC,wCAAwC,oBAAI,IAA6B;AAAA,EACzE,UAAU,oBAAI,IAAmC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOjD,qBAAqB,oBAAI,IAAmC;AAC9D,CAAC;AA4CD,IAAM,mBAAmC,gBAAM;AAAA;AAAA,EAK7C,gCAASA,kBAAiB,OAAO,cAAc;AAC7C,UAAM;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AAU;AAAA,QACZ,CAAC;AAAA,MACH;AAAA,IACF,GAPoB;AAQpB,kBAAc,iBAAiB,WAAW,WAAW;AACrD,WAAO,MAAM,cAAc,oBAAoB,WAAW,WAAW;AAAA,EACvE,GAAG,CAAC,eAAe,kBAAkB,CAAC;AAEtC,SAAO;AAAA,IACL,gBAAgB,6BAAO,0BAA0B,UAAU,MAA3C;AAAA,IAChB,eAAe,6BAAO,0BAA0B,UAAU,OAA3C;AAAA,EACjB;AACF;AAxBS;AA0BT,SAAS,iBAAiB;AACxB,QAAM,QAAQ,IAAI,YAAY,cAAc;AAC5C,WAAS,cAAc,KAAK;AAC9B;AAHS;AAKT,SAAS,6BACP,MACA,SACA,QACA,EAAE,SAAS,GACX;AACA,QAAM,SAAS,OAAO,cAAc;AACpC,QAAM,QAAQ,IAAI,YAAY,MAAM,EAAE,SAAS,OAAO,YAAY,MAAM,OAAO,CAAC;AAChF,MAAI,QAAS,QAAO,iBAAiB,MAAM,SAA0B,EAAE,MAAM,KAAK,CAAC;AAEnF,MAAI,UAAU;AACZ,gCAA4B,QAAQ,KAAK;AAAA,EAC3C,OAAO;AACL,WAAO,cAAc,KAAK;AAAA,EAC5B;AACF;AAfS;", | ||
| "sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { Primitive, dispatchDiscreteCustomEvent } from '@radix-ui/react-primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\n\n/* -------------------------------------------------------------------------------------------------\n * DismissableLayer\n * -----------------------------------------------------------------------------------------------*/\nconst CONTEXT_UPDATE = 'dismissableLayer.update';\nconst POINTER_DOWN_OUTSIDE = 'dismissableLayer.pointerDownOutside';\nconst FOCUS_OUTSIDE = 'dismissableLayer.focusOutside';\n\nlet originalBodyPointerEvents: string;\n\nconst DismissableLayerContext = React.createContext({\n layers: new Set<DismissableLayerElement>(),\n layersWithOutsidePointerEventsDisabled: new Set<DismissableLayerElement>(),\n branches: new Set<DismissableLayerBranchElement>(),\n\n // Outside elements that belong to a layer's own dismiss affordance (eg, a\n // dialog overlay). Pressing them should dismiss the layer regardless of\n // whether or not they stop propagation.\n //\n // See https://github.com/radix-ui/primitives/issues/3346\n dismissableSurfaces: new Set<DismissableLayerBranchElement>(),\n});\n\ntype DismissableLayerElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface DismissableLayerProps extends PrimitiveDivProps {\n /**\n * When `true`, hover/focus/click interactions will be disabled on elements outside\n * the `DismissableLayer`. Users will need to click twice on outside elements to\n * interact with them: once to close the `DismissableLayer`, and again to trigger the element.\n */\n disableOutsidePointerEvents?: boolean;\n /**\n * When `true`, a `'pointerdown'` event outside of the layered element will\n * wait for the interaction's click event before dispatching, allowing\n * third-party code to stop propagation of later events and cancel dismissal.\n */\n deferPointerDownOutside?: boolean;\n /**\n * Event handler called when the escape key is down.\n * Can be prevented.\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void;\n /**\n * Event handler called when the a `pointerdown` event happens outside of the `DismissableLayer`.\n * Can be prevented.\n */\n onPointerDownOutside?: (event: PointerDownOutsideEvent) => void;\n /**\n * Event handler called when the focus moves outside of the `DismissableLayer`.\n * Can be prevented.\n */\n onFocusOutside?: (event: FocusOutsideEvent) => void;\n /**\n * Event handler called when an interaction happens outside the `DismissableLayer`.\n * Specifically, when a `pointerdown` event happens outside or focus moves outside of it.\n * Can be prevented.\n */\n onInteractOutside?: (event: PointerDownOutsideEvent | FocusOutsideEvent) => void;\n /**\n * Handler called when the `DismissableLayer` should be dismissed\n */\n onDismiss?: () => void;\n}\n\nconst DismissableLayer = /* @__PURE__ */ React.forwardRef<\n DismissableLayerElement,\n DismissableLayerProps\n>(\n // blank line to reduce diff noise\n function DismissableLayer(props, forwardedRef) {\n const {\n disableOutsidePointerEvents = false,\n deferPointerDownOutside = false,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n onDismiss,\n ...layerProps\n } = props;\n const context = React.useContext(DismissableLayerContext);\n const [node, setNode] = React.useState<DismissableLayerElement | null>(null);\n const ownerDocument = node?.ownerDocument ?? globalThis?.document;\n const [, force] = React.useState({});\n const composedRefs = useComposedRefs(forwardedRef, setNode);\n const layers = Array.from(context.layers);\n const [highestLayerWithOutsidePointerEventsDisabled] = [\n ...context.layersWithOutsidePointerEventsDisabled,\n ].slice(-1);\n const highestLayerWithOutsidePointerEventsDisabledIndex =\n highestLayerWithOutsidePointerEventsDisabled\n ? layers.indexOf(highestLayerWithOutsidePointerEventsDisabled)\n : -1;\n const index = node ? layers.indexOf(node) : -1;\n const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;\n const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;\n const isDeferredPointerDownOutsideRef = React.useRef(false);\n\n const pointerDownOutside = usePointerDownOutside(\n (event) => {\n onPointerDownOutside?.(event);\n onInteractOutside?.(event);\n if (!event.defaultPrevented) onDismiss?.();\n },\n {\n ownerDocument,\n deferPointerDownOutside,\n isDeferredPointerDownOutsideRef,\n dismissableSurfaces: context.dismissableSurfaces,\n shouldHandlePointerDownOutside: React.useCallback(\n (target: EventTarget | null) => {\n if (!(target instanceof Node)) {\n return false;\n }\n\n const isPointerDownOnBranch = [...context.branches].some((branch) =>\n branch.contains(target),\n );\n return isPointerEventsEnabled && !isPointerDownOnBranch;\n },\n [context.branches, isPointerEventsEnabled],\n ),\n },\n );\n\n const focusOutside = useFocusOutside((event) => {\n if (deferPointerDownOutside && isDeferredPointerDownOutsideRef.current) {\n return;\n }\n\n const target = event.target as HTMLElement;\n const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));\n if (isFocusInBranch) return;\n onFocusOutside?.(event);\n onInteractOutside?.(event);\n if (!event.defaultPrevented) onDismiss?.();\n }, ownerDocument);\n\n const isHighestLayer = node ? index === layers.length - 1 : false;\n\n // Stabilize via `useCallbackRef` rather than `useEffectEvent`: React's\n // native `useEffectEvent` returns a stale closure inside `forwardRef`\n // components on React 19.2.x, which caused escape handlers to observe\n // mount-time props/state instead of the latest values.\n //\n // We should revert this to use useEffectEvent when the fix lands in React.\n //\n // - https://github.com/radix-ui/primitives/issues/4014\n // - https://github.com/react/react/pull/34831\n const handleKeyDown = useCallbackRef((event: KeyboardEvent) => {\n if (event.key !== 'Escape') {\n return;\n }\n\n onEscapeKeyDown?.(event);\n if (!event.defaultPrevented && onDismiss) {\n event.preventDefault();\n onDismiss();\n }\n });\n\n React.useEffect(() => {\n if (!isHighestLayer) {\n return;\n }\n\n ownerDocument.addEventListener('keydown', handleKeyDown, { capture: true });\n return () => ownerDocument.removeEventListener('keydown', handleKeyDown, { capture: true });\n }, [ownerDocument, isHighestLayer, handleKeyDown]);\n\n React.useEffect(() => {\n if (!node) return;\n if (disableOutsidePointerEvents) {\n if (context.layersWithOutsidePointerEventsDisabled.size === 0) {\n originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;\n ownerDocument.body.style.pointerEvents = 'none';\n }\n context.layersWithOutsidePointerEventsDisabled.add(node);\n }\n context.layers.add(node);\n dispatchUpdate();\n return () => {\n // We must remove this layer from the disabled set whenever\n // `disableOutsidePointerEvents` becomes `false` (eg, when a modal\n // closes but stays mounted during an exit animation) and not only on\n // unmount. Otherwise the `body` `pointer-events` could be left as\n // `none` when multiple layers overlap.\n // See: https://github.com/radix-ui/primitives/issues/3645\n if (disableOutsidePointerEvents) {\n context.layersWithOutsidePointerEventsDisabled.delete(node);\n if (context.layersWithOutsidePointerEventsDisabled.size === 0) {\n ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;\n }\n }\n };\n }, [node, ownerDocument, disableOutsidePointerEvents, context]);\n\n /**\n * We purposefully prevent combining this effect with the `disableOutsidePointerEvents` effect\n * because a change to `disableOutsidePointerEvents` would remove this layer from the stack\n * and add it to the end again so the layering order wouldn't be _creation order_.\n * We only want them to be removed from context stacks when unmounted.\n */\n React.useEffect(() => {\n return () => {\n if (!node) return;\n context.layers.delete(node);\n context.layersWithOutsidePointerEventsDisabled.delete(node);\n dispatchUpdate();\n };\n }, [node, context]);\n\n React.useEffect(() => {\n const handleUpdate = () => force({});\n document.addEventListener(CONTEXT_UPDATE, handleUpdate);\n return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);\n }, []);\n\n return (\n <Primitive.div\n {...layerProps}\n ref={composedRefs}\n style={{\n pointerEvents: isBodyPointerEventsDisabled\n ? isPointerEventsEnabled\n ? 'auto'\n : 'none'\n : undefined,\n ...props.style,\n }}\n onFocusCapture={composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture)}\n onBlurCapture={composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture)}\n onPointerDownCapture={composeEventHandlers(\n props.onPointerDownCapture,\n pointerDownOutside.onPointerDownCapture,\n )}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DismissableLayerBranch\n * -----------------------------------------------------------------------------------------------*/\n\ntype DismissableLayerBranchElement = React.ComponentRef<typeof Primitive.div>;\ninterface DismissableLayerBranchProps extends PrimitiveDivProps {}\n\nconst DismissableLayerBranch = /* @__PURE__ */ React.forwardRef<\n DismissableLayerBranchElement,\n DismissableLayerBranchProps\n>(function DismissableLayerBranch(props, forwardedRef) {\n const context = React.useContext(DismissableLayerContext);\n const ref = React.useRef<DismissableLayerBranchElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n\n React.useEffect(() => {\n const node = ref.current;\n if (node) {\n context.branches.add(node);\n return () => {\n context.branches.delete(node);\n };\n }\n }, [context.branches]);\n\n return <Primitive.div {...props} ref={composedRefs} />;\n});\n\n/* -----------------------------------------------------------------------------------------------*/\n\n/**\n * Registers a node as a \"dismiss surface\" for the enclosing DismissableLayer\n */\nfunction useDismissableLayerSurface(): React.RefCallback<DismissableLayerBranchElement> {\n const context = React.useContext(DismissableLayerContext);\n const [node, setNode] = React.useState<DismissableLayerBranchElement | null>(null);\n\n React.useEffect(() => {\n if (!node) {\n return;\n }\n context.dismissableSurfaces.add(node);\n return () => {\n context.dismissableSurfaces.delete(node);\n };\n }, [node, context.dismissableSurfaces]);\n\n return setNode;\n}\n\ntype PointerDownOutsideEvent = CustomEvent<{ originalEvent: PointerEvent }>;\ntype FocusOutsideEvent = CustomEvent<{ originalEvent: FocusEvent }>;\n\nconst IS_TRUE = () => true;\n\n/**\n * Listens for `pointerdown` outside a react subtree. We detect the start of the interaction on\n * `pointerdown`, then wait for `click` so external code can intercept later mouse events.\n * Returns props to pass to the node we want to check for outside events.\n */\nfunction usePointerDownOutside(\n onPointerDownOutside: ((event: PointerDownOutsideEvent) => void) | undefined,\n args: {\n ownerDocument: Document | undefined;\n deferPointerDownOutside: boolean;\n isDeferredPointerDownOutsideRef: React.RefObject<boolean>;\n dismissableSurfaces: Set<DismissableLayerBranchElement>;\n shouldHandlePointerDownOutside?: (target: EventTarget | null) => boolean;\n },\n) {\n const {\n ownerDocument = globalThis?.document,\n deferPointerDownOutside = false,\n isDeferredPointerDownOutsideRef,\n dismissableSurfaces,\n shouldHandlePointerDownOutside = IS_TRUE,\n } = args;\n const handlePointerDownOutside = useCallbackRef(onPointerDownOutside) as EventListener;\n const isPointerInsideReactTreeRef = React.useRef(false);\n const isPointerDownOutsideRef = React.useRef(false);\n const interceptedOutsideInteractionEventsRef = React.useRef<Map<string, boolean>>(new Map());\n const handleClickRef = React.useRef(() => {});\n\n React.useEffect(() => {\n function resetOutsideInteraction() {\n isPointerDownOutsideRef.current = false;\n isDeferredPointerDownOutsideRef.current = false;\n interceptedOutsideInteractionEventsRef.current.clear();\n }\n\n function isOutsideInteractionIntercepted() {\n return Array.from(interceptedOutsideInteractionEventsRef.current.values()).some(Boolean);\n }\n\n function handleInteractionCapture(event: Event) {\n if (!isPointerDownOutsideRef.current) {\n return;\n }\n\n const target = event.target;\n const isDismissableSurface =\n target instanceof Node &&\n [...dismissableSurfaces].some((surface) => surface.contains(target as Node));\n\n if (!isDismissableSurface) {\n interceptedOutsideInteractionEventsRef.current.set(event.type, true);\n }\n\n if (event.type === 'click') {\n window.setTimeout(() => {\n if (isPointerDownOutsideRef.current) {\n handleClickRef.current();\n }\n }, 0);\n }\n }\n\n function handleInteractionBubble(event: Event) {\n if (isPointerDownOutsideRef.current) {\n interceptedOutsideInteractionEventsRef.current.set(event.type, false);\n }\n }\n\n const handlePointerDown = (event: PointerEvent) => {\n if (event.target && !isPointerInsideReactTreeRef.current) {\n if (!shouldHandlePointerDownOutside(event.target)) {\n ownerDocument.removeEventListener('click', handleClickRef.current);\n resetOutsideInteraction();\n isPointerInsideReactTreeRef.current = false;\n return;\n }\n\n const eventDetail = { originalEvent: event };\n isPointerDownOutsideRef.current = true;\n isDeferredPointerDownOutsideRef.current = deferPointerDownOutside && event.button === 0;\n interceptedOutsideInteractionEventsRef.current.clear();\n\n function handleAndDispatchPointerDownOutsideEvent() {\n ownerDocument.removeEventListener('click', handleClickRef.current);\n const wasOutsideInteractionIntercepted = isOutsideInteractionIntercepted();\n resetOutsideInteraction();\n\n if (!wasOutsideInteractionIntercepted) {\n handleAndDispatchCustomEvent(\n POINTER_DOWN_OUTSIDE,\n handlePointerDownOutside,\n eventDetail,\n { discrete: true },\n );\n }\n }\n\n /**\n * When deferring, we need to wait for a click event because:\n *\n * 1. On touch devices, browsers implement a ~350ms delay between the\n * time the user stops touching the display and when the browser\n * executes events. We need to ensure we don't reactivate\n * pointer-events within this timeframe otherwise the browser may\n * execute events that should have been prevented.\n *\n * 2. Browser extensions and other third-party code may call\n * `stopPropagation` on later mouse events like `mousedown`,\n * `mouseup`, or `click`. Waiting lets those intercepted events\n * cancel the outside interaction before we dismiss the layer. See\n * https://github.com/radix-ui/primitives/issues/2055\n *\n * Additionally, this also lets us deal automatically with cancellations\n * when a click event isn't raised because the page was considered\n * scrolled/drag-scrolled, long-pressed, etc.\n *\n * This is why we also continuously remove the previous listener,\n * because we cannot be certain that it was raised, and therefore\n * cleaned-up.\n *\n * For non-primary buttons, we dispatch the event immediately because we\n * cannot be certain that the event was canceled.\n */\n if (!deferPointerDownOutside || event.button !== 0) {\n handleAndDispatchPointerDownOutsideEvent();\n } else {\n ownerDocument.removeEventListener('click', handleClickRef.current);\n handleClickRef.current = handleAndDispatchPointerDownOutsideEvent;\n ownerDocument.addEventListener('click', handleClickRef.current, { once: true });\n }\n } else {\n // We need to remove the event listener in case the outside click has been canceled.\n // See: https://github.com/radix-ui/primitives/issues/2171\n ownerDocument.removeEventListener('click', handleClickRef.current);\n resetOutsideInteraction();\n }\n isPointerInsideReactTreeRef.current = false;\n };\n\n const outsideInteractionEvents = [\n 'pointerup',\n 'mousedown',\n 'mouseup',\n 'touchstart',\n 'touchend',\n 'click',\n ];\n\n for (const eventName of outsideInteractionEvents) {\n ownerDocument.addEventListener(eventName, handleInteractionCapture, true);\n ownerDocument.addEventListener(eventName, handleInteractionBubble);\n }\n\n /**\n * if this hook executes in a component that mounts via a `pointerdown` event, the event\n * would bubble up to the document and trigger a `pointerDownOutside` event. We avoid\n * this by delaying the event listener registration on the document.\n * This is not React specific, but rather how the DOM works, ie:\n * ```\n * button.addEventListener('pointerdown', () => {\n * console.log('I will log');\n * document.addEventListener('pointerdown', () => {\n * console.log('I will also log');\n * })\n * });\n */\n const timerId = window.setTimeout(() => {\n ownerDocument.addEventListener('pointerdown', handlePointerDown);\n }, 0);\n return () => {\n window.clearTimeout(timerId);\n ownerDocument.removeEventListener('pointerdown', handlePointerDown);\n ownerDocument.removeEventListener('click', handleClickRef.current);\n for (const eventName of outsideInteractionEvents) {\n ownerDocument.removeEventListener(eventName, handleInteractionCapture, true);\n ownerDocument.removeEventListener(eventName, handleInteractionBubble);\n }\n };\n }, [\n ownerDocument,\n handlePointerDownOutside,\n deferPointerDownOutside,\n isDeferredPointerDownOutsideRef,\n dismissableSurfaces,\n shouldHandlePointerDownOutside,\n ]);\n\n return {\n // ensures we check React component tree (not just DOM tree)\n onPointerDownCapture: () => (isPointerInsideReactTreeRef.current = true),\n };\n}\n\n/**\n * Listens for when focus happens outside a react subtree.\n * Returns props to pass to the root (node) of the subtree we want to check.\n */\nfunction useFocusOutside(\n onFocusOutside?: (event: FocusOutsideEvent) => void,\n ownerDocument: Document = globalThis?.document,\n) {\n const handleFocusOutside = useCallbackRef(onFocusOutside) as EventListener;\n const isFocusInsideReactTreeRef = React.useRef(false);\n\n React.useEffect(() => {\n const handleFocus = (event: FocusEvent) => {\n if (event.target && !isFocusInsideReactTreeRef.current) {\n const eventDetail = { originalEvent: event };\n handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {\n discrete: false,\n });\n }\n };\n ownerDocument.addEventListener('focusin', handleFocus);\n return () => ownerDocument.removeEventListener('focusin', handleFocus);\n }, [ownerDocument, handleFocusOutside]);\n\n return {\n onFocusCapture: () => (isFocusInsideReactTreeRef.current = true),\n onBlurCapture: () => (isFocusInsideReactTreeRef.current = false),\n };\n}\n\nfunction dispatchUpdate() {\n const event = new CustomEvent(CONTEXT_UPDATE);\n document.dispatchEvent(event);\n}\n\nfunction handleAndDispatchCustomEvent<E extends CustomEvent, OriginalEvent extends Event>(\n name: string,\n handler: ((event: E) => void) | undefined,\n detail: { originalEvent: OriginalEvent } & (E extends CustomEvent<infer D> ? D : never),\n { discrete }: { discrete: boolean },\n) {\n const target = detail.originalEvent.target;\n const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });\n if (handler) target.addEventListener(name, handler as EventListener, { once: true });\n\n if (discrete) {\n dispatchDiscreteCustomEvent(target, event);\n } else {\n target.dispatchEvent(event);\n }\n}\n\nconst Root = DismissableLayer;\nconst Branch = DismissableLayerBranch;\n\nexport {\n DismissableLayer,\n DismissableLayerBranch,\n useDismissableLayerSurface,\n //\n Root,\n Branch,\n};\nexport type { DismissableLayerProps };\n"], | ||
| "mappings": ";;;;;AAAA,YAAY,WAAW;AACvB,SAAS,4BAA4B;AACrC,SAAS,WAAW,mCAAmC;AACvD,SAAS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", "handleAndDispatchPointerDownOutsideEvent"] | ||
| } |
+9
-9
| { | ||
| "name": "@radix-ui/react-dismissable-layer", | ||
| "version": "1.1.18", | ||
| "version": "1.1.19", | ||
| "license": "MIT", | ||
@@ -15,12 +15,12 @@ "source": "./src/index.ts", | ||
| "@radix-ui/primitive": "1.1.7", | ||
| "@radix-ui/react-compose-refs": "1.1.4", | ||
| "@radix-ui/react-primitive": "2.1.9", | ||
| "@radix-ui/react-use-callback-ref": "1.1.3", | ||
| "@radix-ui/react-use-effect-event": "0.0.4" | ||
| "@radix-ui/react-compose-refs": "1.1.5", | ||
| "@radix-ui/react-primitive": "2.1.10", | ||
| "@radix-ui/react-use-callback-ref": "1.1.4", | ||
| "@radix-ui/react-use-effect-event": "0.0.5" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/react": "^19.2.17", | ||
| "@types/react-dom": "^19.2.3", | ||
| "react": "^19.2.7", | ||
| "react-dom": "^19.2.7", | ||
| "@types/react": "^19.2.2", | ||
| "@types/react-dom": "^19.2.2", | ||
| "react": "^19.2.0", | ||
| "react-dom": "^19.2.0", | ||
| "react-remove-scroll": "^2.7.2", | ||
@@ -27,0 +27,0 @@ "typescript": "^5.9.3", |
100069
0.56%816
0.74%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed