Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@radix-ui/react-popover

Package Overview
Dependencies
Maintainers
6
Versions
247
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-popover - npm Package Compare versions

Comparing version 1.1.0-rc.2 to 1.1.0-rc.3

650

dist/index.js
"use strict";
"use client";
(() => {
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined") return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// packages/react/popover/src/index.ts
var src_exports = {};
__export(src_exports, {
Anchor: () => Anchor2,
Arrow: () => Arrow2,
Close: () => Close,
Content: () => Content2,
Popover: () => Popover,
PopoverAnchor: () => PopoverAnchor,
PopoverArrow: () => PopoverArrow,
PopoverClose: () => PopoverClose,
PopoverContent: () => PopoverContent,
PopoverPortal: () => PopoverPortal,
PopoverTrigger: () => PopoverTrigger,
Portal: () => Portal,
Root: () => Root2,
Trigger: () => Trigger,
createPopoverScope: () => createPopoverScope
});
module.exports = __toCommonJS(src_exports);
// packages/react/popover/src/Popover.tsx
var React = __toESM(require("react"));
var import_primitive = require("@radix-ui/primitive");
var import_react_compose_refs = require("@radix-ui/react-compose-refs");
var import_react_context = require("@radix-ui/react-context");
var import_react_dismissable_layer = require("@radix-ui/react-dismissable-layer");
var import_react_focus_guards = require("@radix-ui/react-focus-guards");
var import_react_focus_scope = require("@radix-ui/react-focus-scope");
var import_react_id = require("@radix-ui/react-id");
var PopperPrimitive = __toESM(require("@radix-ui/react-popper"));
var import_react_popper = require("@radix-ui/react-popper");
var import_react_portal = require("@radix-ui/react-portal");
var import_react_presence = require("@radix-ui/react-presence");
var import_react_primitive = require("@radix-ui/react-primitive");
var import_react_slot = require("@radix-ui/react-slot");
var import_react_use_controllable_state = require("@radix-ui/react-use-controllable-state");
var import_aria_hidden = require("aria-hidden");
var import_react_remove_scroll = require("react-remove-scroll");
var import_jsx_runtime = require("react/jsx-runtime");
var POPOVER_NAME = "Popover";
var [createPopoverContext, createPopoverScope] = (0, import_react_context.createContextScope)(POPOVER_NAME, [
import_react_popper.createPopperScope
]);
var usePopperScope = (0, import_react_popper.createPopperScope)();
var [PopoverProvider, usePopoverContext] = createPopoverContext(POPOVER_NAME);
var Popover = (props) => {
const {
__scopePopover,
children,
open: openProp,
defaultOpen,
onOpenChange,
modal = false
} = props;
const popperScope = usePopperScope(__scopePopover);
const triggerRef = React.useRef(null);
const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
const [open = false, setOpen] = (0, import_react_use_controllable_state.useControllableState)({
prop: openProp,
defaultProp: defaultOpen,
onChange: onOpenChange
});
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Root, { ...popperScope, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
PopoverProvider,
{
scope: __scopePopover,
contentId: (0, import_react_id.useId)(),
triggerRef,
open,
onOpenChange: setOpen,
onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
hasCustomAnchor,
onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),
onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), []),
modal,
children
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
// packages/react/popover/src/Popover.tsx
var React = __toESM(__require("react"));
var import_primitive = __require("@radix-ui/primitive");
var import_react_compose_refs = __require("@radix-ui/react-compose-refs");
var import_react_context = __require("@radix-ui/react-context");
var import_react_dismissable_layer = __require("@radix-ui/react-dismissable-layer");
var import_react_focus_guards = __require("@radix-ui/react-focus-guards");
var import_react_focus_scope = __require("@radix-ui/react-focus-scope");
var import_react_id = __require("@radix-ui/react-id");
var PopperPrimitive = __toESM(__require("@radix-ui/react-popper"));
var import_react_popper = __require("@radix-ui/react-popper");
var import_react_portal = __require("@radix-ui/react-portal");
var import_react_presence = __require("@radix-ui/react-presence");
var import_react_primitive = __require("@radix-ui/react-primitive");
var import_react_slot = __require("@radix-ui/react-slot");
var import_react_use_controllable_state = __require("@radix-ui/react-use-controllable-state");
var import_aria_hidden = __require("aria-hidden");
var import_react_remove_scroll = __require("react-remove-scroll");
var import_jsx_runtime = __require("react/jsx-runtime");
var POPOVER_NAME = "Popover";
var [createPopoverContext, createPopoverScope] = (0, import_react_context.createContextScope)(POPOVER_NAME, [
import_react_popper.createPopperScope
]);
var usePopperScope = (0, import_react_popper.createPopperScope)();
var [PopoverProvider, usePopoverContext] = createPopoverContext(POPOVER_NAME);
var Popover = (props) => {
const {
__scopePopover,
children,
open: openProp,
defaultOpen,
onOpenChange,
modal = false
} = props;
) });
};
Popover.displayName = POPOVER_NAME;
var ANCHOR_NAME = "PopoverAnchor";
var PopoverAnchor = React.forwardRef(
(props, forwardedRef) => {
const { __scopePopover, ...anchorProps } = props;
const context = usePopoverContext(ANCHOR_NAME, __scopePopover);
const popperScope = usePopperScope(__scopePopover);
const triggerRef = React.useRef(null);
const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
const [open = false, setOpen] = (0, import_react_use_controllable_state.useControllableState)({
prop: openProp,
defaultProp: defaultOpen,
onChange: onOpenChange
});
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Root, { ...popperScope, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
PopoverProvider,
const { onCustomAnchorAdd, onCustomAnchorRemove } = context;
React.useEffect(() => {
onCustomAnchorAdd();
return () => onCustomAnchorRemove();
}, [onCustomAnchorAdd, onCustomAnchorRemove]);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });
}
);
PopoverAnchor.displayName = ANCHOR_NAME;
var TRIGGER_NAME = "PopoverTrigger";
var PopoverTrigger = React.forwardRef(
(props, forwardedRef) => {
const { __scopePopover, ...triggerProps } = props;
const context = usePopoverContext(TRIGGER_NAME, __scopePopover);
const popperScope = usePopperScope(__scopePopover);
const composedTriggerRef = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, context.triggerRef);
const trigger = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_react_primitive.Primitive.button,
{
scope: __scopePopover,
contentId: (0, import_react_id.useId)(),
triggerRef,
open,
onOpenChange: setOpen,
onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
hasCustomAnchor,
onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),
onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), []),
modal,
children
type: "button",
"aria-haspopup": "dialog",
"aria-expanded": context.open,
"aria-controls": context.contentId,
"data-state": getState(context.open),
...triggerProps,
ref: composedTriggerRef,
onClick: (0, import_primitive.composeEventHandlers)(props.onClick, context.onOpenToggle)
}
);
return context.hasCustomAnchor ? trigger : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Anchor, { asChild: true, ...popperScope, children: trigger });
}
);
PopoverTrigger.displayName = TRIGGER_NAME;
var PORTAL_NAME = "PopoverPortal";
var [PortalProvider, usePortalContext] = createPopoverContext(PORTAL_NAME, {
forceMount: void 0
});
var PopoverPortal = (props) => {
const { __scopePopover, forceMount, children, container } = props;
const context = usePopoverContext(PORTAL_NAME, __scopePopover);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PortalProvider, { scope: __scopePopover, forceMount, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || context.open, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_portal.Portal, { asChild: true, container, children }) }) });
};
PopoverPortal.displayName = PORTAL_NAME;
var CONTENT_NAME = "PopoverContent";
var PopoverContent = React.forwardRef(
(props, forwardedRef) => {
const portalContext = usePortalContext(CONTENT_NAME, props.__scopePopover);
const { forceMount = portalContext.forceMount, ...contentProps } = props;
const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContentNonModal, { ...contentProps, ref: forwardedRef }) });
}
);
PopoverContent.displayName = CONTENT_NAME;
var PopoverContentModal = React.forwardRef(
(props, forwardedRef) => {
const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
const contentRef = React.useRef(null);
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, contentRef);
const isRightClickOutsideRef = React.useRef(false);
React.useEffect(() => {
const content = contentRef.current;
if (content) return (0, import_aria_hidden.hideOthers)(content);
}, []);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_remove_scroll.RemoveScroll, { as: import_react_slot.Slot, allowPinchZoom: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
PopoverContentImpl,
{
...props,
ref: composedRefs,
trapFocus: context.open,
disableOutsidePointerEvents: true,
onCloseAutoFocus: (0, import_primitive.composeEventHandlers)(props.onCloseAutoFocus, (event) => {
event.preventDefault();
if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();
}),
onPointerDownOutside: (0, import_primitive.composeEventHandlers)(
props.onPointerDownOutside,
(event) => {
const originalEvent = event.detail.originalEvent;
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
isRightClickOutsideRef.current = isRightClick;
},
{ checkForDefaultPrevented: false }
),
onFocusOutside: (0, import_primitive.composeEventHandlers)(
props.onFocusOutside,
(event) => event.preventDefault(),
{ checkForDefaultPrevented: false }
)
}
) });
};
Popover.displayName = POPOVER_NAME;
var ANCHOR_NAME = "PopoverAnchor";
var PopoverAnchor = React.forwardRef(
(props, forwardedRef) => {
const { __scopePopover, ...anchorProps } = props;
const context = usePopoverContext(ANCHOR_NAME, __scopePopover);
const popperScope = usePopperScope(__scopePopover);
const { onCustomAnchorAdd, onCustomAnchorRemove } = context;
React.useEffect(() => {
onCustomAnchorAdd();
return () => onCustomAnchorRemove();
}, [onCustomAnchorAdd, onCustomAnchorRemove]);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });
}
);
PopoverAnchor.displayName = ANCHOR_NAME;
var TRIGGER_NAME = "PopoverTrigger";
var PopoverTrigger = React.forwardRef(
(props, forwardedRef) => {
const { __scopePopover, ...triggerProps } = props;
const context = usePopoverContext(TRIGGER_NAME, __scopePopover);
const popperScope = usePopperScope(__scopePopover);
const composedTriggerRef = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, context.triggerRef);
const trigger = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_react_primitive.Primitive.button,
{
type: "button",
"aria-haspopup": "dialog",
"aria-expanded": context.open,
"aria-controls": context.contentId,
"data-state": getState(context.open),
...triggerProps,
ref: composedTriggerRef,
onClick: (0, import_primitive.composeEventHandlers)(props.onClick, context.onOpenToggle)
}
);
return context.hasCustomAnchor ? trigger : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Anchor, { asChild: true, ...popperScope, children: trigger });
}
);
PopoverTrigger.displayName = TRIGGER_NAME;
var PORTAL_NAME = "PopoverPortal";
var [PortalProvider, usePortalContext] = createPopoverContext(PORTAL_NAME, {
forceMount: void 0
});
var PopoverPortal = (props) => {
const { __scopePopover, forceMount, children, container } = props;
const context = usePopoverContext(PORTAL_NAME, __scopePopover);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PortalProvider, { scope: __scopePopover, forceMount, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || context.open, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_portal.Portal, { asChild: true, container, children }) }) });
};
PopoverPortal.displayName = PORTAL_NAME;
var CONTENT_NAME = "PopoverContent";
var PopoverContent = React.forwardRef(
(props, forwardedRef) => {
const portalContext = usePortalContext(CONTENT_NAME, props.__scopePopover);
const { forceMount = portalContext.forceMount, ...contentProps } = props;
const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContentNonModal, { ...contentProps, ref: forwardedRef }) });
}
);
PopoverContent.displayName = CONTENT_NAME;
var PopoverContentModal = React.forwardRef(
(props, forwardedRef) => {
const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
const contentRef = React.useRef(null);
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, contentRef);
const isRightClickOutsideRef = React.useRef(false);
React.useEffect(() => {
const content = contentRef.current;
if (content) return (0, import_aria_hidden.hideOthers)(content);
}, []);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_remove_scroll.RemoveScroll, { as: import_react_slot.Slot, allowPinchZoom: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
PopoverContentImpl,
{
...props,
ref: composedRefs,
trapFocus: context.open,
disableOutsidePointerEvents: true,
onCloseAutoFocus: (0, import_primitive.composeEventHandlers)(props.onCloseAutoFocus, (event) => {
}
);
var PopoverContentNonModal = React.forwardRef(
(props, forwardedRef) => {
const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
const hasInteractedOutsideRef = React.useRef(false);
const hasPointerDownOutsideRef = React.useRef(false);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
PopoverContentImpl,
{
...props,
ref: forwardedRef,
trapFocus: false,
disableOutsidePointerEvents: false,
onCloseAutoFocus: (event) => {
props.onCloseAutoFocus?.(event);
if (!event.defaultPrevented) {
if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
event.preventDefault();
if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();
}),
onPointerDownOutside: (0, import_primitive.composeEventHandlers)(
props.onPointerDownOutside,
(event) => {
const originalEvent = event.detail.originalEvent;
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
isRightClickOutsideRef.current = isRightClick;
},
{ checkForDefaultPrevented: false }
),
onFocusOutside: (0, import_primitive.composeEventHandlers)(
props.onFocusOutside,
(event) => event.preventDefault(),
{ checkForDefaultPrevented: false }
)
}
) });
}
);
var PopoverContentNonModal = React.forwardRef(
(props, forwardedRef) => {
const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
const hasInteractedOutsideRef = React.useRef(false);
const hasPointerDownOutsideRef = React.useRef(false);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
PopoverContentImpl,
{
...props,
ref: forwardedRef,
trapFocus: false,
disableOutsidePointerEvents: false,
onCloseAutoFocus: (event) => {
props.onCloseAutoFocus?.(event);
if (!event.defaultPrevented) {
if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
event.preventDefault();
}
hasInteractedOutsideRef.current = false;
hasPointerDownOutsideRef.current = false;
},
onInteractOutside: (event) => {
props.onInteractOutside?.(event);
if (!event.defaultPrevented) {
hasInteractedOutsideRef.current = true;
if (event.detail.originalEvent.type === "pointerdown") {
hasPointerDownOutsideRef.current = true;
}
hasInteractedOutsideRef.current = false;
hasPointerDownOutsideRef.current = false;
},
onInteractOutside: (event) => {
props.onInteractOutside?.(event);
if (!event.defaultPrevented) {
hasInteractedOutsideRef.current = true;
if (event.detail.originalEvent.type === "pointerdown") {
hasPointerDownOutsideRef.current = true;
}
}
const target = event.target;
const targetIsTrigger = context.triggerRef.current?.contains(target);
if (targetIsTrigger) event.preventDefault();
if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
event.preventDefault();
}
}
const target = event.target;
const targetIsTrigger = context.triggerRef.current?.contains(target);
if (targetIsTrigger) event.preventDefault();
if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
event.preventDefault();
}
}
);
}
);
var PopoverContentImpl = React.forwardRef(
(props, forwardedRef) => {
const {
__scopePopover,
trapFocus,
onOpenAutoFocus,
onCloseAutoFocus,
disableOutsidePointerEvents,
onEscapeKeyDown,
onPointerDownOutside,
onFocusOutside,
onInteractOutside,
...contentProps
} = props;
const context = usePopoverContext(CONTENT_NAME, __scopePopover);
const popperScope = usePopperScope(__scopePopover);
(0, import_react_focus_guards.useFocusGuards)();
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_react_focus_scope.FocusScope,
{
asChild: true,
loop: true,
trapped: trapFocus,
onMountAutoFocus: onOpenAutoFocus,
onUnmountAutoFocus: onCloseAutoFocus,
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_react_dismissable_layer.DismissableLayer,
{
asChild: true,
disableOutsidePointerEvents,
onInteractOutside,
onEscapeKeyDown,
onPointerDownOutside,
onFocusOutside,
onDismiss: () => context.onOpenChange(false),
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
PopperPrimitive.Content,
{
"data-state": getState(context.open),
role: "dialog",
id: context.contentId,
...popperScope,
...contentProps,
ref: forwardedRef,
style: {
...contentProps.style,
// re-namespace exposed content custom properties
...{
"--radix-popover-content-transform-origin": "var(--radix-popper-transform-origin)",
"--radix-popover-content-available-width": "var(--radix-popper-available-width)",
"--radix-popover-content-available-height": "var(--radix-popper-available-height)",
"--radix-popover-trigger-width": "var(--radix-popper-anchor-width)",
"--radix-popover-trigger-height": "var(--radix-popper-anchor-height)"
}
}
);
}
);
var PopoverContentImpl = React.forwardRef(
(props, forwardedRef) => {
const {
__scopePopover,
trapFocus,
onOpenAutoFocus,
onCloseAutoFocus,
disableOutsidePointerEvents,
onEscapeKeyDown,
onPointerDownOutside,
onFocusOutside,
onInteractOutside,
...contentProps
} = props;
const context = usePopoverContext(CONTENT_NAME, __scopePopover);
const popperScope = usePopperScope(__scopePopover);
(0, import_react_focus_guards.useFocusGuards)();
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_react_focus_scope.FocusScope,
{
asChild: true,
loop: true,
trapped: trapFocus,
onMountAutoFocus: onOpenAutoFocus,
onUnmountAutoFocus: onCloseAutoFocus,
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_react_dismissable_layer.DismissableLayer,
{
asChild: true,
disableOutsidePointerEvents,
onInteractOutside,
onEscapeKeyDown,
onPointerDownOutside,
onFocusOutside,
onDismiss: () => context.onOpenChange(false),
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
PopperPrimitive.Content,
{
"data-state": getState(context.open),
role: "dialog",
id: context.contentId,
...popperScope,
...contentProps,
ref: forwardedRef,
style: {
...contentProps.style,
// re-namespace exposed content custom properties
...{
"--radix-popover-content-transform-origin": "var(--radix-popper-transform-origin)",
"--radix-popover-content-available-width": "var(--radix-popper-available-width)",
"--radix-popover-content-available-height": "var(--radix-popper-available-height)",
"--radix-popover-trigger-width": "var(--radix-popper-anchor-width)",
"--radix-popover-trigger-height": "var(--radix-popper-anchor-height)"
}
}
)
}
)
}
);
}
);
var CLOSE_NAME = "PopoverClose";
var PopoverClose = React.forwardRef(
(props, forwardedRef) => {
const { __scopePopover, ...closeProps } = props;
const context = usePopoverContext(CLOSE_NAME, __scopePopover);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_react_primitive.Primitive.button,
{
type: "button",
...closeProps,
ref: forwardedRef,
onClick: (0, import_primitive.composeEventHandlers)(props.onClick, () => context.onOpenChange(false))
}
);
}
);
PopoverClose.displayName = CLOSE_NAME;
var ARROW_NAME = "PopoverArrow";
var PopoverArrow = React.forwardRef(
(props, forwardedRef) => {
const { __scopePopover, ...arrowProps } = props;
const popperScope = usePopperScope(__scopePopover);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
}
);
PopoverArrow.displayName = ARROW_NAME;
function getState(open) {
return open ? "open" : "closed";
}
)
}
)
}
);
}
var Root2 = Popover;
var Anchor2 = PopoverAnchor;
var Trigger = PopoverTrigger;
var Portal = PopoverPortal;
var Content2 = PopoverContent;
var Close = PopoverClose;
var Arrow2 = PopoverArrow;
})();
);
var CLOSE_NAME = "PopoverClose";
var PopoverClose = React.forwardRef(
(props, forwardedRef) => {
const { __scopePopover, ...closeProps } = props;
const context = usePopoverContext(CLOSE_NAME, __scopePopover);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_react_primitive.Primitive.button,
{
type: "button",
...closeProps,
ref: forwardedRef,
onClick: (0, import_primitive.composeEventHandlers)(props.onClick, () => context.onOpenChange(false))
}
);
}
);
PopoverClose.displayName = CLOSE_NAME;
var ARROW_NAME = "PopoverArrow";
var PopoverArrow = React.forwardRef(
(props, forwardedRef) => {
const { __scopePopover, ...arrowProps } = props;
const popperScope = usePopperScope(__scopePopover);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
}
);
PopoverArrow.displayName = ARROW_NAME;
function getState(open) {
return open ? "open" : "closed";
}
var Root2 = Popover;
var Anchor2 = PopoverAnchor;
var Trigger = PopoverTrigger;
var Portal = PopoverPortal;
var Content2 = PopoverContent;
var Close = PopoverClose;
var Arrow2 = PopoverArrow;
//# sourceMappingURL=index.js.map
{
"name": "@radix-ui/react-popover",
"version": "1.1.0-rc.2",
"version": "1.1.0-rc.3",
"license": "MIT",

@@ -31,15 +31,15 @@ "exports": {

"dependencies": {
"@radix-ui/primitive": "1.1.0-rc.2",
"@radix-ui/react-compose-refs": "1.1.0-rc.2",
"@radix-ui/react-context": "1.1.0-rc.2",
"@radix-ui/react-dismissable-layer": "1.1.0-rc.2",
"@radix-ui/react-focus-guards": "1.1.0-rc.2",
"@radix-ui/react-focus-scope": "1.1.0-rc.2",
"@radix-ui/react-id": "1.1.0-rc.2",
"@radix-ui/react-popper": "1.2.0-rc.2",
"@radix-ui/react-portal": "1.1.0-rc.2",
"@radix-ui/react-presence": "1.1.0-rc.2",
"@radix-ui/react-primitive": "1.1.0-rc.2",
"@radix-ui/react-slot": "1.1.0-rc.2",
"@radix-ui/react-use-controllable-state": "1.1.0-rc.2",
"@radix-ui/primitive": "1.1.0-rc.3",
"@radix-ui/react-compose-refs": "1.1.0-rc.3",
"@radix-ui/react-context": "1.1.0-rc.3",
"@radix-ui/react-dismissable-layer": "1.1.0-rc.3",
"@radix-ui/react-focus-guards": "1.1.0-rc.3",
"@radix-ui/react-focus-scope": "1.1.0-rc.3",
"@radix-ui/react-id": "1.1.0-rc.3",
"@radix-ui/react-popper": "1.2.0-rc.3",
"@radix-ui/react-portal": "1.1.0-rc.3",
"@radix-ui/react-presence": "1.1.0-rc.3",
"@radix-ui/react-primitive": "1.1.0-rc.3",
"@radix-ui/react-slot": "1.1.0-rc.3",
"@radix-ui/react-use-controllable-state": "1.1.0-rc.3",
"aria-hidden": "^1.1.1",

@@ -46,0 +46,0 @@ "react-remove-scroll": "2.5.7"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc