@ibragim-dev-org/ui-forge-library 1.3.7 → 1.3.9

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.
@@ -800,6 +800,9 @@ const COLOR_FAMILIES = [
800
800
  { solid: '#FF86E4', gradientStart: '#FF64DD', gradientEnd: '#F599C4' }, // Pink (exact)
801
801
  ];
802
802
  const hashValue = (value) => {
803
+ if (!value || typeof value !== 'string') {
804
+ return 0;
805
+ }
803
806
  let hash = 0;
804
807
  for (let i = 0; i < value.length; i++) {
805
808
  hash = value.charCodeAt(i) + ((hash << 5) - hash);
@@ -1334,13 +1337,14 @@ class UiAvatarDirective {
1334
1337
  this.elementRef = elementRef;
1335
1338
  this.renderer = renderer;
1336
1339
  effect(() => {
1337
- let acronym = '';
1338
- this.$acronym()
1339
- .split(' ')
1340
- .forEach((v) => {
1341
- acronym = acronym + v[0];
1342
- });
1343
- this.renderer.setStyle(this.elementRef.nativeElement, 'background', stringToColorGradient(acronym[0]));
1340
+ const acronym = this.$acronym()
1341
+ .trim()
1342
+ .split(/\s+/)
1343
+ .slice(0, 2)
1344
+ .map((word) => word[0]?.toUpperCase() || '')
1345
+ .join('');
1346
+ const colorValue = acronym[0] || ' ';
1347
+ this.renderer.setStyle(this.elementRef.nativeElement, 'background', stringToColorGradient(colorValue));
1344
1348
  this.$text.set(acronym);
1345
1349
  });
1346
1350
  effect(() => {