dgz-ui
Version:
Custom ui library using React.js, Shadcn/ui, TailwindCSS, Typescript
18 lines (17 loc) • 6.04 kB
JavaScript
;const x=require("./jsx-runtime-DUiatUiq.cjs"),O=require("react"),g=require("./index-DcWZbXs6.cjs"),K=require("./index-hwV4SK1V.cjs"),R=require("./index-CMmIsz5H.cjs"),F=require("./index-DQ3cz9n7.cjs"),w=require("./utils-C1Nf1RtL.cjs");function W(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 v=W(O);var y={exports:{}},L={};/**
* @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 b;function Y(){if(b)return L;b=1;var e=O;function t(s,d){return s===d&&(s!==0||1/s===1/d)||s!==s&&d!==d}var r=typeof Object.is=="function"?Object.is:t,o=e.useState,u=e.useEffect,n=e.useLayoutEffect,S=e.useDebugValue;function l(s,d){var a=d(),i=o({inst:{value:a,getSnapshot:d}}),c=i[0].inst,m=i[1];return n(function(){c.value=a,c.getSnapshot=d,f(c)&&m({inst:c})},[s,a,d]),u(function(){return f(c)&&m({inst:c}),s(function(){f(c)&&m({inst:c})})},[s]),S(a),a}function f(s){var d=s.getSnapshot;s=s.value;try{var a=d();return!r(s,a)}catch{return!0}}function p(s,d){return d()}var _=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?p:l;return L.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:_,L}var A={};/**
* @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 I;function J(){return I||(I=1,process.env.NODE_ENV!=="production"&&function(){function e(a,i){return a===i&&(a!==0||1/a===1/i)||a!==a&&i!==i}function t(a,i){_||u.startTransition===void 0||(_=!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 c=i();if(!s){var m=i();n(c,m)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),s=!0)}m=S({inst:{value:c,getSnapshot:i}});var E=m[0].inst,h=m[1];return f(function(){E.value=c,E.getSnapshot=i,r(E)&&h({inst:E})},[a,c,i]),l(function(){return r(E)&&h({inst:E}),a(function(){r(E)&&h({inst:E})})},[a]),p(c),c}function r(a){var i=a.getSnapshot;a=a.value;try{var c=i();return!n(a,c)}catch{return!0}}function o(a,i){return i()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var u=O,n=typeof Object.is=="function"?Object.is:e,S=u.useState,l=u.useEffect,f=u.useLayoutEffect,p=u.useDebugValue,_=!1,s=!1,d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o:t;A.useSyncExternalStore=u.useSyncExternalStore!==void 0?u.useSyncExternalStore:d,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),A}var N;function Q(){return N||(N=1,process.env.NODE_ENV==="production"?y.exports=Y():y.exports=J()),y.exports}var X=Q();function Z(){return X.useSyncExternalStore(ee,()=>!0,()=>!1)}function ee(){return()=>{}}var j="Avatar",[te,ae]=g.createContextScope(j),[re,C]=te(j),q=v.forwardRef((e,t)=>{const{__scopeAvatar:r,...o}=e,[u,n]=v.useState("idle");return x.jsxRuntimeExports.jsx(re,{scope:r,imageLoadingStatus:u,onImageLoadingStatusChange:n,children:x.jsxRuntimeExports.jsx(R.Primitive.span,{...o,ref:t})})});q.displayName=j;var D="AvatarImage",V=v.forwardRef((e,t)=>{const{__scopeAvatar:r,src:o,onLoadingStatusChange:u=()=>{},...n}=e,S=C(D,r),l=ne(o,n),f=K.useCallbackRef(p=>{u(p),S.onImageLoadingStatusChange(p)});return g.useLayoutEffect2(()=>{l!=="idle"&&f(l)},[l,f]),l==="loaded"?x.jsxRuntimeExports.jsx(R.Primitive.img,{...n,ref:t,src:o}):null});V.displayName=D;var k="AvatarFallback",z=v.forwardRef((e,t)=>{const{__scopeAvatar:r,delayMs:o,...u}=e,n=C(k,r),[S,l]=v.useState(o===void 0);return v.useEffect(()=>{if(o!==void 0){const f=window.setTimeout(()=>l(!0),o);return()=>window.clearTimeout(f)}},[o]),S&&n.imageLoadingStatus!=="loaded"?x.jsxRuntimeExports.jsx(R.Primitive.span,{...u,ref:t}):null});z.displayName=k;function T(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function ne(e,{referrerPolicy:t,crossOrigin:r}){const o=Z(),u=v.useRef(null),n=o?(u.current||(u.current=new window.Image),u.current):null,[S,l]=v.useState(()=>T(n,e));return g.useLayoutEffect2(()=>{l(T(n,e))},[n,e]),g.useLayoutEffect2(()=>{const f=s=>()=>{l(s)};if(!n)return;const p=f("loaded"),_=f("error");return n.addEventListener("load",p),n.addEventListener("error",_),t&&(n.referrerPolicy=t),typeof r=="string"&&(n.crossOrigin=r),()=>{n.removeEventListener("load",p),n.removeEventListener("error",_)}},[n,r,t]),S}var G=q,M=V,$=z;const H=F.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"}}),P=v.forwardRef(({className:e,size:t,...r},o)=>x.jsxRuntimeExports.jsx(G,{ref:o,className:w.cn(H({size:t}),e),...r}));P.displayName=G.displayName;const U=v.forwardRef(({className:e,...t},r)=>x.jsxRuntimeExports.jsx(M,{ref:r,className:w.cn("aspect-square size-full",e),...t}));U.displayName=M.displayName;const B=v.forwardRef(({className:e,...t},r)=>x.jsxRuntimeExports.jsx($,{ref:r,className:w.cn("flex size-full items-center justify-center rounded-full bg-muted",e),...t}));B.displayName=$.displayName;exports.Avatar=P;exports.AvatarFallback=B;exports.AvatarImage=U;exports.avatarVariants=H;