@one-paragon/angular-utilities 2.0.12 → 2.0.13

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Directive, Input, inject, Injector, TemplateRef, ViewContainerRef, NgModule, assertInInjectionContext, DestroyRef, computed, isSignal, Injectable, Pipe, input, signal, Renderer2, ElementRef, booleanAttribute, InjectionToken, makeEnvironmentProviders, Component, ChangeDetectionStrategy, HostListener, EventEmitter, untracked, Output, ContentChildren, ChangeDetectorRef, output, ViewChild, EnvironmentInjector, createComponent, viewChild, linkedSignal, effect, contentChild, forwardRef, contentChildren, model, runInInjectionContext, provideAppInitializer } from '@angular/core';
2
+ import { Directive, Input, inject, Injector, TemplateRef, ViewContainerRef, NgModule, assertInInjectionContext, DestroyRef, computed, isSignal, Injectable, Pipe, input, signal, Renderer2, ElementRef, booleanAttribute, InjectionToken, makeEnvironmentProviders, Component, ChangeDetectionStrategy, HostListener, EventEmitter, untracked, Output, effect, ContentChildren, ChangeDetectorRef, output, ViewChild, EnvironmentInjector, createComponent, viewChild, linkedSignal, contentChild, forwardRef, contentChildren, model, runInInjectionContext, provideAppInitializer } from '@angular/core';
3
3
  import { shareReplay, switchAll, map, filter, tap, catchError, startWith, switchMap, mergeMap, concatMap as concatMap$1, takeUntil, distinctUntilChanged, observeOn, debounceTime, scan as scan$1, timestamp as timestamp$1, first as first$1 } from 'rxjs/operators';
4
4
  import * as i1 from 'rxjs';
5
5
  import { Subject, isObservable, of, ReplaySubject, filter as filter$1, first, map as map$1, Observable, combineLatest, Subscription, startWith as startWith$1, pairwise, concatMap, merge, delay, fromEvent, takeUntil as takeUntil$1, tap as tap$1, switchMap as switchMap$1, scan, timestamp, animationFrameScheduler, debounceTime as debounceTime$1, BehaviorSubject } from 'rxjs';
@@ -2554,40 +2554,40 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImpor
2554
2554
  class StylerDirective {
2555
2555
  el = inject(ElementRef);
2556
2556
  renderer = inject(Renderer2);
2557
- stylesApplied = {};
2558
- element;
2559
- set styler(styles) {
2560
- const toApply = Object.entries(styles ?? {}).reduce((acc, [key, val]) => {
2561
- if (typeof (val) === 'string') {
2562
- acc[key] = val;
2563
- this.el.nativeElement.style[key] = val;
2564
- }
2565
- else if (val?.condition === true || val?.condition(this.element)) {
2566
- const value = typeof (val.value) === 'string' ? val.value : val?.value(this.element);
2567
- acc[key] = value;
2568
- this.el.nativeElement.style[key] = value;
2569
- }
2570
- return acc;
2571
- }, {});
2572
- Object.keys(this.stylesApplied).filter(key => !Object.keys(toApply).includes(key)).forEach(key => {
2573
- this.renderer.removeStyle(this.el.nativeElement, key);
2557
+ $stylesApplied = signal({});
2558
+ $element = input.required({ alias: 'element' });
2559
+ $styler = input.required({ alias: 'styler' });
2560
+ #stylerEffect = effect(() => {
2561
+ const styles = this.$styler();
2562
+ untracked(() => {
2563
+ const element = this.$element();
2564
+ const toApply = Object.entries(styles ?? {}).reduce((acc, [key, val]) => {
2565
+ if (!val)
2566
+ return acc;
2567
+ if (typeof (val) === 'string') {
2568
+ acc[key] = val;
2569
+ this.el.nativeElement.style[key] = val;
2570
+ }
2571
+ else if (!val?.condition || val?.condition === true || val?.condition(element)) {
2572
+ const value = typeof (val.value) === 'string' ? val.value : val?.value(element);
2573
+ acc[key] = value;
2574
+ this.el.nativeElement.style[key] = value;
2575
+ }
2576
+ return acc;
2577
+ }, {});
2578
+ Object.keys(this.$stylesApplied()).filter(key => !Object.keys(toApply).includes(key)).forEach(key => {
2579
+ this.renderer.removeStyle(this.el.nativeElement, key);
2580
+ });
2581
+ this.$stylesApplied.set(toApply);
2574
2582
  });
2575
- this.stylesApplied = toApply;
2576
- }
2577
- ;
2583
+ });
2578
2584
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: StylerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2579
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0", type: StylerDirective, isStandalone: true, selector: "[styler]", inputs: { element: "element", styler: "styler" }, ngImport: i0 });
2585
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.0", type: StylerDirective, isStandalone: true, selector: "[styler]", inputs: { $element: { classPropertyName: "$element", publicName: "element", isSignal: true, isRequired: true, transformFunction: null }, $styler: { classPropertyName: "$styler", publicName: "styler", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 });
2580
2586
  }
2581
2587
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: StylerDirective, decorators: [{
2582
2588
  type: Directive,
2583
- args: [{
2584
- selector: '[styler]',
2585
- }]
2586
- }], propDecorators: { element: [{
2587
- type: Input
2588
- }], styler: [{
2589
- type: Input
2590
- }] } });
2589
+ args: [{ selector: '[styler]' }]
2590
+ }] });
2591
2591
 
2592
2592
  class MatSlideToggleGroupDirective {
2593
2593
  allowMultiple = false;
@@ -2690,35 +2690,34 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImpor
2690
2690
  class ConditionalClassesDirective {
2691
2691
  el = inject(ElementRef);
2692
2692
  renderer = inject(Renderer2);
2693
- element;
2694
- classes;
2693
+ $element = input.required({ alias: 'element' });
2694
+ $classes = input(undefined, { alias: 'conditionalClasses' });
2695
2695
  classesApplied = [];
2696
- ngOnChanges(changes) {
2697
- let toApply = [];
2698
- if (this.classes) {
2699
- toApply = Object.keys(this.classes)
2700
- .filter(key => this.classes[key](this.element));
2701
- }
2702
- var classesNotYetApplied = toApply.filter(c => !this.classesApplied.includes(c));
2703
- var classesToRemove = this.classesApplied.filter(c => !toApply.includes(c));
2704
- classesToRemove.forEach(c => this.renderer.removeClass(this.el.nativeElement, c));
2705
- classesNotYetApplied.forEach(c => this.renderer.addClass(this.el.nativeElement, c));
2706
- this.classesApplied = toApply;
2707
- }
2696
+ #onClasses = effect(() => {
2697
+ const classes = this.$classes();
2698
+ untracked(() => {
2699
+ const element = this.$element();
2700
+ let toApply = [];
2701
+ if (classes) {
2702
+ toApply = Object.keys(classes)
2703
+ .filter(key => (classes[key] === true) || classes[key](element));
2704
+ }
2705
+ var classesNotYetApplied = toApply.filter(c => !this.classesApplied.includes(c));
2706
+ var classesToRemove = this.classesApplied.filter(c => !toApply.includes(c));
2707
+ classesToRemove.forEach(c => this.renderer.removeClass(this.el.nativeElement, c));
2708
+ classesNotYetApplied.forEach(c => this.renderer.addClass(this.el.nativeElement, c));
2709
+ this.classesApplied = toApply;
2710
+ });
2711
+ });
2708
2712
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ConditionalClassesDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2709
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0", type: ConditionalClassesDirective, isStandalone: true, selector: "[conditionalClasses]", inputs: { element: "element", classes: ["conditionalClasses", "classes"] }, usesOnChanges: true, ngImport: i0 });
2713
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.0", type: ConditionalClassesDirective, isStandalone: true, selector: "[conditionalClasses]", inputs: { $element: { classPropertyName: "$element", publicName: "element", isSignal: true, isRequired: true, transformFunction: null }, $classes: { classPropertyName: "$classes", publicName: "conditionalClasses", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
2710
2714
  }
2711
2715
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ConditionalClassesDirective, decorators: [{
2712
2716
  type: Directive,
2713
2717
  args: [{
2714
2718
  selector: '[conditionalClasses]',
2715
2719
  }]
2716
- }], propDecorators: { element: [{
2717
- type: Input
2718
- }], classes: [{
2719
- type: Input,
2720
- args: ['conditionalClasses']
2721
- }] } });
2720
+ }] });
2722
2721
 
2723
2722
  class UtilitiesModule {
2724
2723
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: UtilitiesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });