UNPKG

ivt

Version:

Ivt Components Library

3 lines (2 loc) 4.66 kB
import*as e from"react";import t from"react";import{c as r}from"../chunks/index-BXKQJZ6z.mjs";import{u as n}from"../chunks/index-DwSoQWco.mjs";import{u as a}from"../chunks/index-C99OdH8-.mjs";import{P as o}from"../chunks/index-Bj6b6xW8.mjs";import{jsx as u}from"react/jsx-runtime";import{c as s}from"../chunks/utils-B4HRExF_.mjs";import"react-dom";import"@radix-ui/react-slot";import"../chunks/bundle-mjs-DdsKEIOo.mjs";var i,c={exports:{}},l={};var d,f,m={};var v=(f||(f=1,"production"===process.env.NODE_ENV?c.exports=function(){if(i)return l;i=1;var e=t,r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},n=e.useState,a=e.useEffect,o=e.useLayoutEffect,u=e.useDebugValue;function s(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch(e){return!0}}var c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var r=t(),i=n({inst:{value:r,getSnapshot:t}}),c=i[0].inst,l=i[1];return o((function(){c.value=r,c.getSnapshot=t,s(c)&&l({inst:c})}),[e,r,t]),a((function(){return s(c)&&l({inst:c}),e((function(){s(c)&&l({inst:c})}))}),[e]),u(r),r};return l.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:c,l}():c.exports=(d||(d=1,"production"!==process.env.NODE_ENV&&function(){function e(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!n(e,r)}catch(e){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var r=t,n="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},a=r.useState,o=r.useEffect,u=r.useLayoutEffect,s=r.useDebugValue,i=!1,c=!1,l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(t,l){i||void 0===r.startTransition||(i=!0);var d=l();if(!c){var f=l();n(d,f)||(c=!0)}var m=(f=a({inst:{value:d,getSnapshot:l}}))[0].inst,v=f[1];return u((function(){m.value=d,m.getSnapshot=l,e(m)&&v({inst:m})}),[t,d,l]),o((function(){return e(m)&&v({inst:m}),t((function(){e(m)&&v({inst:m})}))}),[t]),s(d),d};m.useSyncExternalStore=void 0!==r.useSyncExternalStore?r.useSyncExternalStore:l,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),m)),c.exports);function _(){return()=>{}}var p="Avatar",[S,E]=r(p),[O,g]=S(p),L=e.forwardRef(((t,r)=>{const{__scopeAvatar:n,...a}=t,[s,i]=e.useState("idle");return u(O,{scope:n,imageLoadingStatus:s,onImageLoadingStatusChange:i,children:u(o.span,{...a,ref:r})})}));L.displayName=p;var y="AvatarImage",w=e.forwardRef(((t,r)=>{const{__scopeAvatar:s,src:i,onLoadingStatusChange:c=()=>{},...l}=t,d=g(y,s),f=function(t,{referrerPolicy:r,crossOrigin:n}){const o=v.useSyncExternalStore(_,(()=>!0),(()=>!1)),u=e.useRef(null),s=o?(u.current||(u.current=new window.Image),u.current):null,[i,c]=e.useState((()=>A(s,t)));return a((()=>{c(A(s,t))}),[s,t]),a((()=>{const e=e=>()=>{c(e)};if(!s)return;const t=e("loaded"),a=e("error");return s.addEventListener("load",t),s.addEventListener("error",a),r&&(s.referrerPolicy=r),"string"==typeof n&&(s.crossOrigin=n),()=>{s.removeEventListener("load",t),s.removeEventListener("error",a)}}),[s,n,r]),i}(i,l),m=n((e=>{c(e),d.onImageLoadingStatusChange(e)}));return a((()=>{"idle"!==f&&m(f)}),[f,m]),"loaded"===f?u(o.img,{...l,ref:r,src:i}):null}));w.displayName=y;var h="AvatarFallback",x=e.forwardRef(((t,r)=>{const{__scopeAvatar:n,delayMs:a,...s}=t,i=g(h,n),[c,l]=e.useState(void 0===a);return e.useEffect((()=>{if(void 0!==a){const e=window.setTimeout((()=>l(!0)),a);return()=>window.clearTimeout(e)}}),[a]),c&&"loaded"!==i.imageLoadingStatus?u(o.span,{...s,ref:r}):null}));function A(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}x.displayName=h;var T=L,j=w,N=x;function b({className:t,...r}){return e.createElement(T,{"data-slot":"avatar",className:s("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...r})}function D({className:t,...r}){return e.createElement(j,{"data-slot":"avatar-image",className:s("aspect-square h-full w-full",t),...r})}function R({className:t,...r}){return e.createElement(N,{"data-slot":"avatar-fallback",className:s("bg-muted flex h-full w-full items-center justify-center rounded-full",t),...r})}export{b as Avatar,R as AvatarFallback,D as AvatarImage}; //# sourceMappingURL=index.mjs.map