codexly-ui 0.13.2 → 0.13.3

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.
@@ -1349,13 +1349,28 @@ class ClxAvatarComponent {
1349
1349
  shape = input('circle', ...(ngDevMode ? [{ debugName: "shape" }] : /* istanbul ignore next */ []));
1350
1350
  alt = input('Avatar', ...(ngDevMode ? [{ debugName: "alt" }] : /* istanbul ignore next */ []));
1351
1351
  _color = computed(() => this.color() ?? this._themeSvc.config().primaryColor, ...(ngDevMode ? [{ debugName: "_color" }] : /* istanbul ignore next */ []));
1352
+ /** Set by (error) on the <img> when src() fails to load (404, expired/broken URL, CORS, wrong
1353
+ * host, ...) — without this, _contentType() would keep returning 'image' forever since it only
1354
+ * checks whether src() is truthy, never whether it actually loaded, and the browser renders the
1355
+ * alt() text raw inside the small circular avatar container ("Avatar" clipped into "Avata").
1356
+ * Reset by the effect below whenever src() itself changes, so a later successful URL (e.g. after
1357
+ * uploading a new profile photo) gets a fresh chance to load instead of staying stuck on the
1358
+ * fallback from a previous broken one. */
1359
+ _imgFailed = signal(false, ...(ngDevMode ? [{ debugName: "_imgFailed" }] : /* istanbul ignore next */ []));
1360
+ _resetImgFailedOnSrcChange = effect(() => {
1361
+ this.src();
1362
+ this._imgFailed.set(false);
1363
+ }, ...(ngDevMode ? [{ debugName: "_resetImgFailedOnSrcChange" }] : /* istanbul ignore next */ []));
1352
1364
  _contentType = computed(() => {
1353
- if (this.src())
1365
+ if (this.src() && !this._imgFailed())
1354
1366
  return 'image';
1355
1367
  if (this.initials())
1356
1368
  return 'text';
1357
1369
  return 'icon';
1358
1370
  }, ...(ngDevMode ? [{ debugName: "_contentType" }] : /* istanbul ignore next */ []));
1371
+ _onImgError() {
1372
+ this._imgFailed.set(true);
1373
+ }
1359
1374
  _initials = computed(() => (this.initials() ?? '').slice(0, 3).toUpperCase(), ...(ngDevMode ? [{ debugName: "_initials" }] : /* istanbul ignore next */ []));
1360
1375
  _iconSize = computed(() => AVATAR_ICON_SIZE_MAP[this.size()], ...(ngDevMode ? [{ debugName: "_iconSize" }] : /* istanbul ignore next */ []));
1361
1376
  _shapeClass = computed(() => {
@@ -1386,7 +1401,7 @@ class ClxAvatarComponent {
1386
1401
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.15", type: ClxAvatarComponent, isStandalone: true, selector: "clx-avatar", inputs: { src: { classPropertyName: "src", publicName: "src", isSignal: true, isRequired: false, transformFunction: null }, initials: { classPropertyName: "initials", publicName: "initials", isSignal: true, isRequired: false, transformFunction: null }, iconName: { classPropertyName: "iconName", publicName: "iconName", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, shape: { classPropertyName: "shape", publicName: "shape", isSignal: true, isRequired: false, transformFunction: null }, alt: { classPropertyName: "alt", publicName: "alt", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "img" }, properties: { "class": "_hostClass()", "attr.aria-label": "alt()" } }, ngImport: i0, template: `
1387
1402
  @switch (_contentType()) {
1388
1403
  @case ('image') {
1389
- <img [src]="src()" [alt]="alt()" class="w-full h-full object-cover" />
1404
+ <img [src]="src()" [alt]="alt()" class="w-full h-full object-cover" (error)="_onImgError()" />
1390
1405
  }
1391
1406
  @case ('text') {
1392
1407
  <span [class]="_textClass()">{{ _initials() }}</span>
@@ -1406,7 +1421,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.15", ngImpo
1406
1421
  template: `
1407
1422
  @switch (_contentType()) {
1408
1423
  @case ('image') {
1409
- <img [src]="src()" [alt]="alt()" class="w-full h-full object-cover" />
1424
+ <img [src]="src()" [alt]="alt()" class="w-full h-full object-cover" (error)="_onImgError()" />
1410
1425
  }
1411
1426
  @case ('text') {
1412
1427
  <span [class]="_textClass()">{{ _initials() }}</span>