dgz-ui
Version:
Custom ui library using React.js, Shadcn/ui, TailwindCSS, Typescript
19 lines (18 loc) • 7.43 kB
JavaScript
;const y=require("react/jsx-runtime"),U=require("react"),K=require("./index-CN4RxFxN.cjs.js"),O=require("./index-pQxT4IlV.cjs.js");require("react-dom");const F=require("./index-CMEUY8i_.cjs.js"),W=require("./index-x_Mxo00P.cjs.js"),A=require("./utils-C4d7Ql9-.cjs.js");function Y(e){if(e&&e.__esModule)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const S=Y(U);function J(e,t=[]){let r=[];function o(n,f){const s=S.createContext(f);s.displayName=n+"Context";const d=r.length;r=[...r,f];const p=i=>{var _;const{scope:l,children:u,...c}=i,v=((_=l==null?void 0:l[e])==null?void 0:_[d])||s,m=S.useMemo(()=>c,Object.values(c));return y.jsx(v.Provider,{value:m,children:u})};p.displayName=n+"Provider";function E(i,l){var v;const u=((v=l==null?void 0:l[e])==null?void 0:v[d])||s,c=S.useContext(u);if(c)return c;if(f!==void 0)return f;throw new Error(`\`${i}\` must be used within \`${n}\``)}return[p,E]}const a=()=>{const n=r.map(f=>S.createContext(f));return function(s){const d=(s==null?void 0:s[e])||n;return S.useMemo(()=>({[`__scope${e}`]:{...s,[e]:d}}),[s,d])}};return a.scopeName=e,[o,Q(a,...t)]}function Q(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(n){const f=o.reduce((s,{useScope:d,scopeName:p})=>{const i=d(n)[`__scope${p}`];return{...s,...i}},{});return S.useMemo(()=>({[`__scope${t.scopeName}`]:f}),[f])}};return r.scopeName=t.scopeName,r}var X=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],w=X.reduce((e,t)=>{const r=F.createSlot(`Primitive.${t}`),o=S.forwardRef((a,n)=>{const{asChild:f,...s}=a,d=f?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(d,{...s,ref:n})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{}),x={exports:{}},h={};/**
* @license React
* use-sync-external-store-shim.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var C;function Z(){if(C)return h;C=1;var e=S.default;function t(i,l){return i===l&&(i!==0||1/i===1/l)||i!==i&&l!==l}var r=typeof Object.is=="function"?Object.is:t,o=e.useState,a=e.useEffect,n=e.useLayoutEffect,f=e.useDebugValue;function s(i,l){var u=l(),c=o({inst:{value:u,getSnapshot:l}}),v=c[0].inst,m=c[1];return n(function(){v.value=u,v.getSnapshot=l,d(v)&&m({inst:v})},[i,u,l]),a(function(){return d(v)&&m({inst:v}),i(function(){d(v)&&m({inst:v})})},[i]),f(u),u}function d(i){var l=i.getSnapshot;i=i.value;try{var u=l();return!r(i,u)}catch{return!0}}function p(i,l){return l()}var E=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?p:s;return h.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:E,h}var L={};/**
* @license React
* use-sync-external-store-shim.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var R;function ee(){return R||(R=1,process.env.NODE_ENV!=="production"&&(function(){function e(u,c){return u===c&&(u!==0||1/u===1/c)||u!==u&&c!==c}function t(u,c){E||a.startTransition===void 0||(E=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var v=c();if(!i){var m=c();n(v,m)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),i=!0)}m=f({inst:{value:v,getSnapshot:c}});var _=m[0].inst,g=m[1];return d(function(){_.value=v,_.getSnapshot=c,r(_)&&g({inst:_})},[u,v,c]),s(function(){return r(_)&&g({inst:_}),u(function(){r(_)&&g({inst:_})})},[u]),p(v),v}function r(u){var c=u.getSnapshot;u=u.value;try{var v=c();return!n(u,v)}catch{return!0}}function o(u,c){return c()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var a=S.default,n=typeof Object.is=="function"?Object.is:e,f=a.useState,s=a.useEffect,d=a.useLayoutEffect,p=a.useDebugValue,E=!1,i=!1,l=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o:t;L.useSyncExternalStore=a.useSyncExternalStore!==void 0?a.useSyncExternalStore:l,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),L}var N;function te(){return N||(N=1,process.env.NODE_ENV==="production"?x.exports=Z():x.exports=ee()),x.exports}var re=te();function ne(){return re.useSyncExternalStore(ae,()=>!0,()=>!1)}function ae(){return()=>{}}var b="Avatar",[oe]=J(b),[se,I]=oe(b),T=S.forwardRef((e,t)=>{const{__scopeAvatar:r,...o}=e,[a,n]=S.useState("idle");return y.jsx(se,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:n,children:y.jsx(w.span,{...o,ref:t})})});T.displayName=b;var $="AvatarImage",q=S.forwardRef((e,t)=>{const{__scopeAvatar:r,src:o,onLoadingStatusChange:a=()=>{},...n}=e,f=I($,r),s=ue(o,n),d=K.useCallbackRef(p=>{a(p),f.onImageLoadingStatusChange(p)});return O.useLayoutEffect2(()=>{s!=="idle"&&d(s)},[s,d]),s==="loaded"?y.jsx(w.img,{...n,ref:t,src:o}):null});q.displayName=$;var D="AvatarFallback",M=S.forwardRef((e,t)=>{const{__scopeAvatar:r,delayMs:o,...a}=e,n=I(D,r),[f,s]=S.useState(o===void 0);return S.useEffect(()=>{if(o!==void 0){const d=window.setTimeout(()=>s(!0),o);return()=>window.clearTimeout(d)}},[o]),f&&n.imageLoadingStatus!=="loaded"?y.jsx(w.span,{...a,ref:t}):null});M.displayName=D;function j(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function ue(e,{referrerPolicy:t,crossOrigin:r}){const o=ne(),a=S.useRef(null),n=o?(a.current||(a.current=new window.Image),a.current):null,[f,s]=S.useState(()=>j(n,e));return O.useLayoutEffect2(()=>{s(j(n,e))},[n,e]),O.useLayoutEffect2(()=>{const d=i=>()=>{s(i)};if(!n)return;const p=d("loaded"),E=d("error");return n.addEventListener("load",p),n.addEventListener("error",E),t&&(n.referrerPolicy=t),typeof r=="string"&&(n.crossOrigin=r),()=>{n.removeEventListener("load",p),n.removeEventListener("error",E)}},[n,r,t]),f}var P=T,k=q,V=M;const z=W.cva("relative flex shrink-0 overflow-hidden rounded-full",{variants:{size:{sm:"size-8",default:"size-10",md:"size-13",lg:"size-16",xl:"size-20"}},defaultVariants:{size:"default"}}),G=S.forwardRef(({className:e,size:t,...r},o)=>y.jsx(P,{ref:o,className:A.cn(z({size:t}),e),...r}));G.displayName=P.displayName;const H=S.forwardRef(({className:e,...t},r)=>y.jsx(k,{ref:r,className:A.cn("aspect-square size-full",e),...t}));H.displayName=k.displayName;const B=S.forwardRef(({className:e,...t},r)=>y.jsx(V,{ref:r,className:A.cn("bg-muted flex size-full items-center justify-center rounded-full",e),...t}));B.displayName=V.displayName;exports.Avatar=G;exports.AvatarFallback=B;exports.AvatarImage=H;exports.avatarVariants=z;
//# sourceMappingURL=avatar-CQMWDnOM.cjs.js.map