@spw-ds/spw-angular-library 1.6.1-alpha.0 → 1.6.2

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 { ChangeDetectionStrategy, Component, HostListener, Directive, NgModule, APP_INITIALIZER } from '@angular/core';
2
+ import { ChangeDetectionStrategy, Component, HostListener, Directive, Input, NgModule, APP_INITIALIZER } from '@angular/core';
3
3
  import { defineCustomElements } from '@spw-ds/spw-stencil-library/loader';
4
4
  import { __decorate } from 'tslib';
5
5
  import { fromEvent } from 'rxjs';
@@ -2579,17 +2579,7 @@ class TabsValueAccessor {
2579
2579
  this.lastValue = '';
2580
2580
  }
2581
2581
  writeValue(value) {
2582
- this.lastValue = value == null ? '' : value;
2583
- const el = this.el.nativeElement;
2584
- // Attendre que le composant Stencil soit prêt avant d'assigner la valeur
2585
- if (typeof el.componentOnReady === 'function') {
2586
- el.componentOnReady().then(() => {
2587
- el.activeTab = this.lastValue;
2588
- });
2589
- }
2590
- else {
2591
- el.activeTab = this.lastValue;
2592
- }
2582
+ this.el.nativeElement.activeTab = this.lastValue = value == null ? '' : value;
2593
2583
  }
2594
2584
  handleTabChanged(event) {
2595
2585
  const value = event.detail;
@@ -2650,16 +2640,7 @@ class CheckboxValueAccessor {
2650
2640
  this.lastValue = false;
2651
2641
  }
2652
2642
  writeValue(value) {
2653
- this.lastValue = value ?? false;
2654
- const el = this.el.nativeElement;
2655
- if (typeof el.componentOnReady === 'function') {
2656
- el.componentOnReady().then(() => {
2657
- el.checked = this.lastValue;
2658
- });
2659
- }
2660
- else {
2661
- el.checked = this.lastValue;
2662
- }
2643
+ this.el.nativeElement.checked = this.lastValue = value ?? false;
2663
2644
  }
2664
2645
  handleChange(event) {
2665
2646
  const value = event.detail;
@@ -2717,26 +2698,25 @@ class RadioValueAccessor {
2717
2698
  this.el = el;
2718
2699
  this.onChange = () => { };
2719
2700
  this.onTouched = () => { };
2720
- this.lastValue = false;
2721
2701
  }
2722
2702
  writeValue(value) {
2723
- this.lastValue = value ?? false;
2724
2703
  const el = this.el.nativeElement;
2704
+ // Compare with loose equality to handle number/string comparison (e.g., 1 vs "1")
2705
+ const isChecked = value == this.value;
2725
2706
  if (typeof el.componentOnReady === 'function') {
2726
2707
  el.componentOnReady().then(() => {
2727
- el.checked = this.lastValue;
2708
+ el.checked = isChecked;
2728
2709
  });
2729
2710
  }
2730
2711
  else {
2731
- el.checked = this.lastValue;
2712
+ el.checked = isChecked;
2732
2713
  }
2733
2714
  }
2734
2715
  handleChange(event) {
2735
- const value = event.detail.checked;
2736
- if (value !== this.lastValue) {
2737
- this.lastValue = value;
2738
- this.onChange(value);
2716
+ if (event.detail.checked) {
2717
+ this.onChange(this.value);
2739
2718
  }
2719
+ this.onTouched();
2740
2720
  }
2741
2721
  handleBlurEvent() {
2742
2722
  this.onTouched();
@@ -2751,7 +2731,7 @@ class RadioValueAccessor {
2751
2731
  this.el.nativeElement.disabled = isDisabled;
2752
2732
  }
2753
2733
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: RadioValueAccessor, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
2754
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.18", type: RadioValueAccessor, isStandalone: true, selector: "spw-radio", host: { listeners: { "spwChange": "handleChange($event)", "focusout": "handleBlurEvent()" } }, providers: [
2734
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.18", type: RadioValueAccessor, isStandalone: true, selector: "spw-radio", inputs: { value: "value" }, host: { listeners: { "spwChange": "handleChange($event)", "focusout": "handleBlurEvent()" } }, providers: [
2755
2735
  {
2756
2736
  provide: NG_VALUE_ACCESSOR,
2757
2737
  useExisting: RadioValueAccessor,
@@ -2773,7 +2753,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
2773
2753
  ],
2774
2754
  standalone: true,
2775
2755
  }]
2776
- }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { handleChange: [{
2756
+ }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { value: [{
2757
+ type: Input
2758
+ }], handleChange: [{
2777
2759
  type: HostListener,
2778
2760
  args: ['spwChange', ['$event']]
2779
2761
  }], handleBlurEvent: [{
@@ -2790,16 +2772,7 @@ class DatePickerValueAccessor {
2790
2772
  this.lastValue = '';
2791
2773
  }
2792
2774
  writeValue(value) {
2793
- this.lastValue = value ?? '';
2794
- const el = this.el.nativeElement;
2795
- if (typeof el.componentOnReady === 'function') {
2796
- el.componentOnReady().then(() => {
2797
- el.value = this.lastValue;
2798
- });
2799
- }
2800
- else {
2801
- el.value = this.lastValue;
2802
- }
2775
+ this.el.nativeElement.value = this.lastValue = value ?? '';
2803
2776
  }
2804
2777
  handleChange(event) {
2805
2778
  const value = event.detail.value;
@@ -2860,16 +2833,7 @@ class InputSliderValueAccessor {
2860
2833
  this.lastValue = 0;
2861
2834
  }
2862
2835
  writeValue(value) {
2863
- this.lastValue = value ?? 0;
2864
- const el = this.el.nativeElement;
2865
- if (typeof el.componentOnReady === 'function') {
2866
- el.componentOnReady().then(() => {
2867
- el.value = this.lastValue;
2868
- });
2869
- }
2870
- else {
2871
- el.value = this.lastValue;
2872
- }
2836
+ this.el.nativeElement.value = this.lastValue = value ?? 0;
2873
2837
  }
2874
2838
  handleChange(event) {
2875
2839
  const value = event.detail.value;
@@ -2930,16 +2894,7 @@ class SearchFieldValueAccessor {
2930
2894
  this.lastValue = '';
2931
2895
  }
2932
2896
  writeValue(value) {
2933
- this.lastValue = value == null ? '' : value;
2934
- const el = this.el.nativeElement;
2935
- if (typeof el.componentOnReady === 'function') {
2936
- el.componentOnReady().then(() => {
2937
- el.value = this.lastValue;
2938
- });
2939
- }
2940
- else {
2941
- el.value = this.lastValue;
2942
- }
2897
+ this.el.nativeElement.value = this.lastValue = value == null ? '' : value;
2943
2898
  }
2944
2899
  handleValueChanged(event) {
2945
2900
  const value = event.detail;