the-omelet-ui 1.8.13 → 1.8.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/entries/avatar.d.ts
CHANGED
|
@@ -7,19 +7,12 @@ declare const avatarStyles: (props?: ({
|
|
|
7
7
|
ringed?: boolean | null | undefined;
|
|
8
8
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
9
9
|
interface AvatarProps extends Omit<HTMLAttributes<HTMLDivElement>, "children">, VariantProps<typeof avatarStyles> {
|
|
10
|
-
/** รูปหลัก */
|
|
11
10
|
src?: string;
|
|
12
|
-
/** รูปสำรอง (ใช้เมื่อ src โหลดไม่สำเร็จ) */
|
|
13
11
|
defaultSrc?: string;
|
|
14
|
-
/** alt สำหรับรูป (เพื่อการเข้าถึง) */
|
|
15
12
|
alt?: string;
|
|
16
|
-
/** โหนด fallback ถ้าไม่มี defaultSrc หรือโหลดรูปไม่ได้ */
|
|
17
13
|
fallback?: ReactNode;
|
|
18
|
-
/** แสดงขณะโหลดรูป */
|
|
19
14
|
loadingIndicator?: ReactNode;
|
|
20
|
-
/** ปรับคลาสของ <img> */
|
|
21
15
|
imageClassName?: string;
|
|
22
|
-
/** รับอีเวนต์โหลด/เออเรอร์จาก <img> */
|
|
23
16
|
onImageLoad?: () => void;
|
|
24
17
|
onImageError?: () => void;
|
|
25
18
|
}
|
package/dist/entries/avatar.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a}from'../chunk-6GLPXMGB.js';import
|
|
1
|
+
import {a}from'../chunk-6GLPXMGB.js';import M,{forwardRef,useState,useRef,useEffect}from'react';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';var W=cva("relative inline-flex items-center justify-center overflow-hidden rounded-full bg-black/5 text-black/50 select-none",{variants:{size:{sm:"h-8 w-8 text-xs",md:"h-10 w-10 text-sm",lg:"h-12 w-12 text-base",xl:"h-16 w-16 text-lg"},ringed:{true:"ring-2 ring-black/10",false:""}},defaultVariants:{size:"md",ringed:false}});function c(s){if(typeof window>"u")return false;let r=new Image;return r.src=s,r.complete&&r.naturalWidth>0}var g=forwardRef(({className:s,imageClassName:r,size:v,ringed:p,src:e,defaultSrc:n,alt:h="",fallback:x,loadingIndicator:y,onImageLoad:k,onImageError:w,...b},L)=>{let N=()=>e?c(e)?"loaded":"loading":"error",[o,t]=useState(N),[i,u]=useState(e),f=useRef(e);useEffect(()=>{f.current!==e&&(f.current=e,u(e),e?c(e)?t("loaded"):t("loading"):t("error"));},[e]);let R=()=>{t("loaded"),k?.();},E=()=>{if(n&&i!==n){u(n),t(c(n)?"loaded":"loading");return}t("error"),w?.();},H=x??jsxs("svg",{className:"h-1/2 w-1/2",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[jsx("circle",{cx:"12",cy:"8",r:"4",stroke:"currentColor",strokeWidth:"2"}),jsx("path",{d:"M4 20c1.5-3.5 4.6-5 8-5s6.5 1.5 8 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),I=y??jsxs("svg",{className:"h-5 w-5 animate-spin",viewBox:"0 0 24 24","aria-hidden":"true",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),jsx("path",{className:"opacity-90",d:"M4 12a8 8 0 0 1 8-8",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",fill:"none"})]});return jsxs("div",{ref:L,className:a(W({size:v,ringed:p}),s),"aria-busy":o==="loading"||void 0,...b,children:[i?jsx("img",{src:i,alt:h,onLoad:R,onError:E,className:a("absolute inset-0 h-full w-full object-cover transition-opacity",o==="loaded"?"opacity-100":"opacity-0",r),draggable:false}):null,jsxs("div",{className:"relative flex h-full w-full items-center justify-center",children:[o==="loading"?I:null,o==="error"||!i?H:null]})]})});g.displayName="Avatar";var D=M.memo(g);export{D as default};
|