UNPKG

@ariakit/react-core

Version:

Ariakit React core

59 lines (40 loc) 1.89 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _LJMK4VH7cjs = require('./LJMK4VH7.cjs'); var _LEJFGVJWcjs = require('./LEJFGVJW.cjs'); var _QXXNZT2Icjs = require('./QXXNZT2I.cjs'); var _WBFXWJUHcjs = require('./WBFXWJUH.cjs'); var _MZ2HG624cjs = require('./MZ2HG624.cjs'); // src/popover/popover-disclosure.tsx var _misc = require('@ariakit/core/utils/misc'); var _jsxruntime = require('react/jsx-runtime'); var TagName = "button"; var usePopoverDisclosure = _WBFXWJUHcjs.createHook.call(void 0, function usePopoverDisclosure2({ store, ...props }) { const context = _QXXNZT2Icjs.usePopoverProviderContext.call(void 0, ); store = store || context; _misc.invariant.call(void 0, store, process.env.NODE_ENV !== "production" && "PopoverDisclosure must receive a `store` prop or be wrapped in a PopoverProvider component." ); const onClickProp = props.onClick; const onClick = _MZ2HG624cjs.useEvent.call(void 0, (event) => { store == null ? void 0 : store.setAnchorElement(event.currentTarget); onClickProp == null ? void 0 : onClickProp(event); }); props = _MZ2HG624cjs.useWrapElement.call(void 0, props, (element) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _QXXNZT2Icjs.PopoverScopedContextProvider, { value: store, children: element }), [store] ); props = { ...props, onClick }; props = _LJMK4VH7cjs.usePopoverAnchor.call(void 0, { store, ...props }); props = _LEJFGVJWcjs.useDialogDisclosure.call(void 0, { store, ...props }); return props; }); var PopoverDisclosure = _WBFXWJUHcjs.forwardRef.call(void 0, function PopoverDisclosure2(props) { const htmlProps = usePopoverDisclosure(props); return _WBFXWJUHcjs.createElement.call(void 0, TagName, htmlProps); }); exports.usePopoverDisclosure = usePopoverDisclosure; exports.PopoverDisclosure = PopoverDisclosure;