UNPKG

dgz-ui

Version:

Custom ui library using React.js, Shadcn/ui, TailwindCSS, Typescript

3 lines (2 loc) 7.58 kB
"use strict";const l=require("react/jsx-runtime"),$=require("react"),d=require("./index-D9zW9Tk7.cjs.js"),_=require("./index-jFOWwfD3.cjs.js"),q=require("./index-CItoM52t.cjs.js"),C=require("./index-DG15yxNP.cjs.js"),y=require("./index-BruMW80s.cjs.js"),g=require("./index-CGLGXpw0.cjs.js"),H=require("./utils-C4d7Ql9-.cjs.js");function V(e){if(e&&e.__esModule)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const a=V($);function L(e){const r=W(e),t=a.forwardRef((n,o)=>{const{children:s,...c}=n,i=a.Children.toArray(s),u=i.find(G);if(u){const p=u.props.children,m=i.map(v=>v===u?a.Children.count(p)>1?a.Children.only(null):a.isValidElement(p)?p.props.children:null:v);return l.jsx(r,{...c,ref:o,children:a.isValidElement(p)?a.cloneElement(p,void 0,m):null})}return l.jsx(r,{...c,ref:o,children:s})});return t.displayName=`${e}.Slot`,t}function W(e){const r=a.forwardRef((t,n)=>{const{children:o,...s}=t;if(a.isValidElement(o)){const c=K(o),i=B(s,o.props);return o.type!==a.Fragment&&(i.ref=n?_.composeRefs(n,c):c),a.cloneElement(o,i)}return a.Children.count(o)>1?a.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var z=Symbol("radix.slottable");function G(e){return a.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===z}function B(e,r){const t={...r};for(const n in r){const o=e[n],s=r[n];/^on[A-Z]/.test(n)?o&&s?t[n]=(...i)=>{const u=s(...i);return o(...i),u}:o&&(t[n]=o):n==="style"?t[n]={...o,...s}:n==="className"&&(t[n]=[o,s].filter(Boolean).join(" "))}return{...e,...t}}function K(e){var n,o;let r=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,t=r&&"isReactWarning"in r&&r.isReactWarning;return t?e.ref:(r=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,t=r&&"isReactWarning"in r&&r.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var R="Popover",[E]=d.createContextScope(R,[g.createPopperScope]),x=g.createPopperScope(),[Z,f]=E(R),b=e=>{const{__scopePopover:r,children:t,open:n,defaultOpen:o,onOpenChange:s,modal:c=!1}=e,i=x(r),u=a.useRef(null),[p,m]=a.useState(!1),[v,P]=y.useControllableState({prop:n,defaultProp:o??!1,onChange:s,caller:R});return l.jsx(g.Root2,{...i,children:l.jsx(Z,{scope:r,contentId:y.useId(),triggerRef:u,open:v,onOpenChange:P,onOpenToggle:a.useCallback(()=>P(O=>!O),[P]),hasCustomAnchor:p,onCustomAnchorAdd:a.useCallback(()=>m(!0),[]),onCustomAnchorRemove:a.useCallback(()=>m(!1),[]),modal:c,children:t})})};b.displayName=R;var j="PopoverAnchor",U=a.forwardRef((e,r)=>{const{__scopePopover:t,...n}=e,o=f(j,t),s=x(t),{onCustomAnchorAdd:c,onCustomAnchorRemove:i}=o;return a.useEffect(()=>(c(),()=>i()),[c,i]),l.jsx(g.Anchor,{...s,...n,ref:r})});U.displayName=j;var w="PopoverTrigger",S=a.forwardRef((e,r)=>{const{__scopePopover:t,...n}=e,o=f(w,t),s=x(t),c=_.useComposedRefs(r,o.triggerRef),i=l.jsx(d.Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":I(o.open),...n,ref:c,onClick:d.composeEventHandlers(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?i:l.jsx(g.Anchor,{asChild:!0,...s,children:i})});S.displayName=w;var A="PopoverPortal",[J,Q]=E(A,{forceMount:void 0}),N=e=>{const{__scopePopover:r,forceMount:t,children:n,container:o}=e,s=f(A,r);return l.jsx(J,{scope:r,forceMount:t,children:l.jsx(d.Presence,{present:t||s.open,children:l.jsx(C.Portal,{asChild:!0,container:o,children:n})})})};N.displayName=A;var h="PopoverContent",F=a.forwardRef((e,r)=>{const t=Q(h,e.__scopePopover),{forceMount:n=t.forceMount,...o}=e,s=f(h,e.__scopePopover);return l.jsx(d.Presence,{present:n||s.open,children:s.modal?l.jsx(Y,{...o,ref:r}):l.jsx(ee,{...o,ref:r})})});F.displayName=h;var X=L("PopoverContent.RemoveScroll"),Y=a.forwardRef((e,r)=>{const t=f(h,e.__scopePopover),n=a.useRef(null),o=_.useComposedRefs(r,n),s=a.useRef(!1);return a.useEffect(()=>{const c=n.current;if(c)return C.hideOthers(c)},[]),l.jsx(C.ReactRemoveScroll,{as:X,allowPinchZoom:!0,children:l.jsx(D,{...e,ref:o,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:d.composeEventHandlers(e.onCloseAutoFocus,c=>{var i;c.preventDefault(),s.current||(i=t.triggerRef.current)==null||i.focus()}),onPointerDownOutside:d.composeEventHandlers(e.onPointerDownOutside,c=>{const i=c.detail.originalEvent,u=i.button===0&&i.ctrlKey===!0,p=i.button===2||u;s.current=p},{checkForDefaultPrevented:!1}),onFocusOutside:d.composeEventHandlers(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1})})})}),ee=a.forwardRef((e,r)=>{const t=f(h,e.__scopePopover),n=a.useRef(!1),o=a.useRef(!1);return l.jsx(D,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var c,i;(c=e.onCloseAutoFocus)==null||c.call(e,s),s.defaultPrevented||(n.current||(i=t.triggerRef.current)==null||i.focus(),s.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:s=>{var u,p;(u=e.onInteractOutside)==null||u.call(e,s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const c=s.target;((p=t.triggerRef.current)==null?void 0:p.contains(c))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),D=a.forwardRef((e,r)=>{const{__scopePopover:t,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEscapeKeyDown:i,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:m,...v}=e,P=f(h,t),O=x(t);return C.useFocusGuards(),l.jsx(C.FocusScope,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:l.jsx(q.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:m,onEscapeKeyDown:i,onPointerDownOutside:u,onFocusOutside:p,onDismiss:()=>P.onOpenChange(!1),children:l.jsx(g.Content,{"data-state":I(P.open),role:"dialog",id:P.contentId,...O,...v,ref:r,style:{...v.style,"--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)"}})})})}),T="PopoverClose",oe=a.forwardRef((e,r)=>{const{__scopePopover:t,...n}=e,o=f(T,t);return l.jsx(d.Primitive.button,{type:"button",...n,ref:r,onClick:d.composeEventHandlers(e.onClick,()=>o.onOpenChange(!1))})});oe.displayName=T;var te="PopoverArrow",re=a.forwardRef((e,r)=>{const{__scopePopover:t,...n}=e,o=x(t);return l.jsx(g.Arrow,{...o,...n,ref:r})});re.displayName=te;function I(e){return e?"open":"closed"}var ne=b,se=S,ae=N,M=F;const ce=ne,ie=se,k=a.forwardRef(({className:e,align:r="center",sideOffset:t=4,...n},o)=>l.jsx(ae,{children:l.jsx(M,{ref:o,align:r,sideOffset:t,className:H.cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 rounded-md border p-4 shadow-md outline-none",e),...n})}));k.displayName=M.displayName;exports.Popover=ce;exports.PopoverContent=k;exports.PopoverTrigger=ie; //# sourceMappingURL=popover-Bh6emR_J.cjs.js.map