@ibragim-dev-org/ui-forge-library 1.1.8 → 1.2.0
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.
|
@@ -329,6 +329,89 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
329
329
|
}]
|
|
330
330
|
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }] });
|
|
331
331
|
|
|
332
|
+
class SkeletonDirective {
|
|
333
|
+
el;
|
|
334
|
+
renderer;
|
|
335
|
+
$isLoading = input.required({ ...(ngDevMode ? { debugName: "$isLoading" } : {}), alias: 'appSkeleton' });
|
|
336
|
+
$lightColor = input.required(...(ngDevMode ? [{ debugName: "$lightColor" }] : []));
|
|
337
|
+
$darkColor = input.required(...(ngDevMode ? [{ debugName: "$darkColor" }] : []));
|
|
338
|
+
constructor(el, renderer) {
|
|
339
|
+
this.el = el;
|
|
340
|
+
this.renderer = renderer;
|
|
341
|
+
effect(() => {
|
|
342
|
+
if (this.$isLoading()) {
|
|
343
|
+
this.applyHostSkeletonStyles();
|
|
344
|
+
this.applySkeletonRecursive(this.el.nativeElement, 0);
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
this.removeSkeletonRecursive(this.el.nativeElement);
|
|
348
|
+
this.removeHostSkeletonStyles();
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
ngAfterViewInit() {
|
|
353
|
+
this.injectKeyframes();
|
|
354
|
+
}
|
|
355
|
+
applyHostSkeletonStyles() {
|
|
356
|
+
this.renderer.setStyle(this.el.nativeElement, 'position', 'relative');
|
|
357
|
+
this.renderer.setStyle(this.el.nativeElement, 'overflow', 'hidden');
|
|
358
|
+
}
|
|
359
|
+
removeHostSkeletonStyles() {
|
|
360
|
+
this.renderer.removeStyle(this.el.nativeElement, 'position');
|
|
361
|
+
this.renderer.removeStyle(this.el.nativeElement, 'overflow');
|
|
362
|
+
}
|
|
363
|
+
injectKeyframes() {
|
|
364
|
+
const styleSheet = document.styleSheets[0];
|
|
365
|
+
if (!styleSheet)
|
|
366
|
+
return;
|
|
367
|
+
const parentPulse = `
|
|
368
|
+
@keyframes skeletonPulseParent {
|
|
369
|
+
0% { background-color: ${this.$lightColor()}; }
|
|
370
|
+
50% { background-color: ${this.$darkColor()}; }
|
|
371
|
+
100% { background-color: ${this.$lightColor()}; }
|
|
372
|
+
}
|
|
373
|
+
`;
|
|
374
|
+
const childPulse = `
|
|
375
|
+
@keyframes skeletonPulseChild {
|
|
376
|
+
0% { background-color: ${this.$darkColor()}; }
|
|
377
|
+
50% { background-color: ${this.$lightColor()}; }
|
|
378
|
+
100% { background-color: ${this.$darkColor()}; }
|
|
379
|
+
}
|
|
380
|
+
`;
|
|
381
|
+
if (![...styleSheet.cssRules].some((r) => r.cssText.includes('skeletonPulseParent'))) {
|
|
382
|
+
styleSheet.insertRule(parentPulse, styleSheet.cssRules.length);
|
|
383
|
+
}
|
|
384
|
+
if (![...styleSheet.cssRules].some((r) => r.cssText.includes('skeletonPulseChild'))) {
|
|
385
|
+
styleSheet.insertRule(childPulse, styleSheet.cssRules.length);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
applySkeletonRecursive(element, depth) {
|
|
389
|
+
const animationName = depth % 2 === 0 ? 'skeletonPulseParent' : 'skeletonPulseChild';
|
|
390
|
+
this.renderer.setStyle(element, 'color', 'transparent'); // hide text
|
|
391
|
+
this.renderer.setStyle(element, 'animation', `${animationName} 1.5s infinite`);
|
|
392
|
+
this.renderer.setStyle(element, 'border-radius', getComputedStyle(element).borderRadius);
|
|
393
|
+
Array.from(element.children).forEach((child) => {
|
|
394
|
+
this.applySkeletonRecursive(child, depth + 1);
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
removeSkeletonRecursive(element) {
|
|
398
|
+
this.renderer.removeStyle(element, 'color');
|
|
399
|
+
this.renderer.removeStyle(element, 'animation');
|
|
400
|
+
this.renderer.removeStyle(element, 'background-color');
|
|
401
|
+
Array.from(element.children).forEach((child) => {
|
|
402
|
+
this.removeSkeletonRecursive(child);
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: SkeletonDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
|
|
406
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.1", type: SkeletonDirective, isStandalone: true, selector: "[appSkeleton]", inputs: { $isLoading: { classPropertyName: "$isLoading", publicName: "appSkeleton", isSignal: true, isRequired: true, transformFunction: null }, $lightColor: { classPropertyName: "$lightColor", publicName: "$lightColor", isSignal: true, isRequired: true, transformFunction: null }, $darkColor: { classPropertyName: "$darkColor", publicName: "$darkColor", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 });
|
|
407
|
+
}
|
|
408
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: SkeletonDirective, decorators: [{
|
|
409
|
+
type: Directive,
|
|
410
|
+
args: [{
|
|
411
|
+
selector: '[appSkeleton]',
|
|
412
|
+
}]
|
|
413
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { $isLoading: [{ type: i0.Input, args: [{ isSignal: true, alias: "appSkeleton", required: true }] }], $lightColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "$lightColor", required: true }] }], $darkColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "$darkColor", required: true }] }] } });
|
|
414
|
+
|
|
332
415
|
class CenterEllipsisPipe {
|
|
333
416
|
transform(value, visibleStart = 4, visibleEnd = 4) {
|
|
334
417
|
if (!value) {
|
|
@@ -3213,5 +3296,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
3213
3296
|
* Generated bundle index. Do not edit.
|
|
3214
3297
|
*/
|
|
3215
3298
|
|
|
3216
|
-
export { Alert, AlertType, AppIconsLibrary, AutoFocusDirective, CenterEllipsisPipe, CountryService, DateUtils, EMAIL, HAS_CAPITAL_CASE, HAS_NUMBER, HAS_SMALL_CASE, HAS_SPECIAL_CHARTERS, HoverTipDirective, IconComponent, LazyImgDirective, MIN_LENGTH, MaskGradientDirective, StickyObserverDirective, ThemeService, TrackLifecycleDirective, UIInputDateDirective, UIPhoneNumberDirective, UiAccordionComponent, UiAlertMessagesService, UiAvatarDirective, UiButtonDirective, UiCodeDirective, UiCopyButtonDirective, UiDailyCalendarDirective, UiDropdownContainerDirective, UiDropdownService, UiFieldBaseDirective, UiImageDirective, UiInputCheckboxDirective, UiInputCountryDirective, UiInputDirective, UiInputSelectDirective, UiInputSequenceDirective, UiInputTimeDirective, UiMonthlyCalendarDirective, UiPaginationDirective, UiPopupBackdropDirective, UiPopupContainerDirective, UiPopupImageDirective, UiPopupInstance, UiPopupService, UiSelectButtonsDirective, UiTabsDirective, UiValidationErrorsDirective, UiYearlyCalendarDirective, emptyCountry, getAspectRatioFit, stringToHslColor };
|
|
3299
|
+
export { Alert, AlertType, AppIconsLibrary, AutoFocusDirective, CenterEllipsisPipe, CountryService, DateUtils, EMAIL, HAS_CAPITAL_CASE, HAS_NUMBER, HAS_SMALL_CASE, HAS_SPECIAL_CHARTERS, HoverTipDirective, IconComponent, LazyImgDirective, MIN_LENGTH, MaskGradientDirective, SkeletonDirective, StickyObserverDirective, ThemeService, TrackLifecycleDirective, UIInputDateDirective, UIPhoneNumberDirective, UiAccordionComponent, UiAlertMessagesService, UiAvatarDirective, UiButtonDirective, UiCodeDirective, UiCopyButtonDirective, UiDailyCalendarDirective, UiDropdownContainerDirective, UiDropdownService, UiFieldBaseDirective, UiImageDirective, UiInputCheckboxDirective, UiInputCountryDirective, UiInputDirective, UiInputSelectDirective, UiInputSequenceDirective, UiInputTimeDirective, UiMonthlyCalendarDirective, UiPaginationDirective, UiPopupBackdropDirective, UiPopupContainerDirective, UiPopupImageDirective, UiPopupInstance, UiPopupService, UiSelectButtonsDirective, UiTabsDirective, UiValidationErrorsDirective, UiYearlyCalendarDirective, emptyCountry, getAspectRatioFit, stringToHslColor };
|
|
3217
3300
|
//# sourceMappingURL=ibragim-dev-org-ui-forge-library.mjs.map
|