@parrot-co/parrot-ui 0.0.53 → 0.0.55

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 CHANGED
@@ -3374,36 +3374,38 @@ function $e12b0eb570e3e94c$export$d41d9ab3de2def3d(text) {
3374
3374
  }
3375
3375
  return Math.abs(hash);
3376
3376
  }
3377
+ function $e12b0eb570e3e94c$export$d560c7e4a29451c2() {
3378
+ return Math.random().toString(36);
3379
+ }
3377
3380
 
3378
3381
 
3379
3382
  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 [showFallback, setShowFallback] = $E4F9t$react.useState(false);
3383
+ const [imageError, setImageError] = $E4F9t$react.useState(false);
3381
3384
  const defaultColor = $E4F9t$react.useMemo(()=>{
3382
3385
  const hash = (0, $e12b0eb570e3e94c$export$d41d9ab3de2def3d)(name || "");
3383
3386
  return (0, $02a166a5043d2558$export$36308cce1deef340)[hash % (0, $02a166a5043d2558$export$36308cce1deef340).length];
3384
3387
  }, [
3385
3388
  name
3386
3389
  ]);
3387
- const showImage = src && !showFallback && !children;
3388
- const _showFallback = fallback && showFallback && !children;
3389
- return /*#__PURE__*/ (0, $E4F9t$reactjsxruntime.jsxs)((0, $8fff24416ec1775a$export$f7513421c53ce141), {
3390
+ const renderContent = ()=>{
3391
+ if (src && !imageError) return /*#__PURE__*/ (0, $E4F9t$reactjsxruntime.jsx)("img", {
3392
+ onLoad: ()=>setImageError(false),
3393
+ onError: ()=>setImageError(true),
3394
+ src: src,
3395
+ alt: alt
3396
+ });
3397
+ if (imageError && !children) return fallback;
3398
+ if (!src && !children && name) return /*#__PURE__*/ (0, $E4F9t$reactjsxruntime.jsx)("span", {
3399
+ children: name.charAt(0)
3400
+ });
3401
+ return children;
3402
+ };
3403
+ return /*#__PURE__*/ (0, $E4F9t$reactjsxruntime.jsx)((0, $8fff24416ec1775a$export$f7513421c53ce141), {
3390
3404
  color: color ?? defaultColor,
3391
3405
  variant: variant,
3392
3406
  ref: ref,
3393
3407
  ...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
- ]
3408
+ children: renderContent()
3407
3409
  });
3408
3410
  });
3409
3411
  $53cff1de4d77d0c5$export$e2255cf6045e8d47.displayName = "Avatar";
@@ -3457,6 +3459,7 @@ const $a0d465526c944113$export$f911245fef99627e = (0, $80923bc9c1ba824c$export$3
3457
3459
 
3458
3460
 
3459
3461
 
3462
+
3460
3463
  const $5bdc448a87fb1cbf$export$1a5cb5295a7d2749 = /*#__PURE__*/ $E4F9t$react.forwardRef(({ onFileUpload: onFileUpload , onRemoveFile: onRemoveFile , error: error , label: label , allowMultiple: allowMultiple , uploads: controlledUploads , hideFileList: hideFileList }, ref)=>{
3461
3464
  const [_uploads, setUploads] = $E4F9t$react.useState([]);
3462
3465
  const uploads = controlledUploads ?? _uploads;
@@ -3490,7 +3493,7 @@ const $5bdc448a87fb1cbf$export$1a5cb5295a7d2749 = /*#__PURE__*/ $E4F9t$react.for
3490
3493
  function convertFileToUpload(file) {
3491
3494
  return {
3492
3495
  name: file.name,
3493
- id: file.name,
3496
+ id: (0, $e12b0eb570e3e94c$export$d560c7e4a29451c2)(),
3494
3497
  url: URL.createObjectURL(file),
3495
3498
  status: "success",
3496
3499
  file: file