UNPKG

nextuiq

Version:

NextUIQ is a modern, lightweight, and developer-friendly UI component library for React and Next.js. Built with TypeScript and Tailwind CSS, it offers customizable, accessible, and performance-optimized components with built-in dark mode, theme customizat

2 lines (1 loc) 2.57 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index46.js"),t=require("react"),r=require("react-dom"),n=require("./index38.js");function o(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const r in e)if("default"!==r){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}return t.default=e,Object.freeze(t)}const i=o(t),s=i.createContext(null),c=i.forwardRef((({children:t,className:r,asChild:o,...c},u)=>{const a=i.useContext(s);if(!a)throw new Error("PopoverTrigger must be used within Popover");const{open:d,setOpen:l,triggerRef:f}=a,p=i.useCallback((e=>{e&&(f.current=e,"function"==typeof u?u(e):u&&(u.current=e))}),[u,f]),m=o?i.Fragment:"button",g=o?{}:{ref:p,className:n.cn("inline-flex items-center justify-center",r),onClick:()=>l(!d),"aria-expanded":d,"aria-haspopup":!0,...c};return e.jsxRuntimeExports.jsx(m,{...g,children:t})})),u=i.forwardRef((({children:t,className:o,...c},u)=>{const a=i.useContext(s);if(!a)throw new Error("PopoverContent must be used within Popover");const{open:d,contentRef:l,triggerRef:f}=a,[p,m]=i.useState({top:0,left:0});return i.useEffect((()=>{if(d&&f.current){const e=f.current.getBoundingClientRect();m({top:e.bottom+window.scrollY+8,left:e.left+window.scrollX})}}),[d]),d&&"undefined"!=typeof document?r.createPortal(e.jsxRuntimeExports.jsx("div",{ref(e){l.current=e,"function"==typeof u?u(e):u&&(u.current=e)},style:{position:"absolute",top:p.top,left:p.left},className:n.cn("z-50 min-w-[8rem] overflow-hidden rounded-md","border border-[oklch(var(--theme-border))]","bg-[oklch(var(--theme-background))]","text-[oklch(var(--theme-foreground))]","shadow-md outline-none","animate-in fade-in-0 zoom-in-95",o),role:"dialog","aria-modal":"true",tabIndex:-1,...c,children:t}),document.body):null}));c.displayName="PopoverTrigger",u.displayName="PopoverContent",exports.Popover=({children:t,open:r,onOpenChange:n})=>{const[o,c]=i.useState(!1),u=r??o,a=n??c,d=i.useRef(null),l=i.useRef(null);return i.useEffect((()=>{const e=e=>{l.current&&d.current&&!l.current.contains(e.target)&&!d.current.contains(e.target)&&a(!1)},t=e=>{"Escape"===e.key&&a(!1)};return u&&(document.addEventListener("mousedown",e),document.addEventListener("keydown",t)),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}}),[u,a]),e.jsxRuntimeExports.jsx(s.Provider,{value:{open:u,setOpen:a,triggerRef:d,contentRef:l},children:t})},exports.PopoverContent=u,exports.PopoverTrigger=c;