@parrot-co/parrot-ui 0.0.53 → 0.0.54
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/main.js +16 -17
- package/dist/main.js.map +1 -1
- package/dist/module.js +16 -17
- package/dist/module.js.map +1 -1
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -3377,33 +3377,32 @@ function $e12b0eb570e3e94c$export$d41d9ab3de2def3d(text) {
|
|
|
3377
3377
|
|
|
3378
3378
|
|
|
3379
3379
|
const $53cff1de4d77d0c5$export$e2255cf6045e8d47 = /*#__PURE__*/ $E4F9t$react.forwardRef(({ src: src , alt: alt , name: name , color: color , variant: variant = "light" , fallback: fallback , children: children , ...props }, ref)=>{
|
|
3380
|
-
const [
|
|
3380
|
+
const [imageError, setImageError] = $E4F9t$react.useState(false);
|
|
3381
3381
|
const defaultColor = $E4F9t$react.useMemo(()=>{
|
|
3382
3382
|
const hash = (0, $e12b0eb570e3e94c$export$d41d9ab3de2def3d)(name || "");
|
|
3383
3383
|
return (0, $02a166a5043d2558$export$36308cce1deef340)[hash % (0, $02a166a5043d2558$export$36308cce1deef340).length];
|
|
3384
3384
|
}, [
|
|
3385
3385
|
name
|
|
3386
3386
|
]);
|
|
3387
|
-
const
|
|
3388
|
-
|
|
3389
|
-
|
|
3387
|
+
const renderContent = ()=>{
|
|
3388
|
+
if (src && !imageError) return /*#__PURE__*/ (0, $E4F9t$reactjsxruntime.jsx)("img", {
|
|
3389
|
+
onLoad: ()=>setImageError(false),
|
|
3390
|
+
onError: ()=>setImageError(true),
|
|
3391
|
+
src: src,
|
|
3392
|
+
alt: alt
|
|
3393
|
+
});
|
|
3394
|
+
if (imageError && !children) return fallback;
|
|
3395
|
+
if (!src && !children && name) return /*#__PURE__*/ (0, $E4F9t$reactjsxruntime.jsx)("span", {
|
|
3396
|
+
children: name.charAt(0)
|
|
3397
|
+
});
|
|
3398
|
+
return children;
|
|
3399
|
+
};
|
|
3400
|
+
return /*#__PURE__*/ (0, $E4F9t$reactjsxruntime.jsx)((0, $8fff24416ec1775a$export$f7513421c53ce141), {
|
|
3390
3401
|
color: color ?? defaultColor,
|
|
3391
3402
|
variant: variant,
|
|
3392
3403
|
ref: ref,
|
|
3393
3404
|
...props,
|
|
3394
|
-
children:
|
|
3395
|
-
showImage && /*#__PURE__*/ (0, $E4F9t$reactjsxruntime.jsx)("img", {
|
|
3396
|
-
onLoad: ()=>setShowFallback(false),
|
|
3397
|
-
onError: ()=>setShowFallback(true),
|
|
3398
|
-
src: src,
|
|
3399
|
-
alt: alt
|
|
3400
|
-
}),
|
|
3401
|
-
(showFallback || name) && !fallback && /*#__PURE__*/ (0, $E4F9t$reactjsxruntime.jsx)("span", {
|
|
3402
|
-
children: name?.charAt(0)
|
|
3403
|
-
}),
|
|
3404
|
-
_showFallback && fallback,
|
|
3405
|
-
children
|
|
3406
|
-
]
|
|
3405
|
+
children: renderContent()
|
|
3407
3406
|
});
|
|
3408
3407
|
});
|
|
3409
3408
|
$53cff1de4d77d0c5$export$e2255cf6045e8d47.displayName = "Avatar";
|