@fuentis/phoenix-ui 0.0.9-alpha.591 → 0.0.9-alpha.592
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.
|
@@ -9165,8 +9165,8 @@ class MetaSwitchV2Component {
|
|
|
9165
9165
|
dataCy;
|
|
9166
9166
|
cdr = inject(ChangeDetectorRef);
|
|
9167
9167
|
/**
|
|
9168
|
-
* Current boolean value.
|
|
9169
|
-
*
|
|
9168
|
+
* Current boolean value stored inside the component.
|
|
9169
|
+
* This value is synchronized with the parent FormControl through CVA.
|
|
9170
9170
|
*/
|
|
9171
9171
|
value = false;
|
|
9172
9172
|
/**
|
|
@@ -9221,18 +9221,22 @@ class MetaSwitchV2Component {
|
|
|
9221
9221
|
* Handler for switch change.
|
|
9222
9222
|
* Propagates value to the parent form control.
|
|
9223
9223
|
*
|
|
9224
|
-
*
|
|
9224
|
+
* Important note:
|
|
9225
|
+
* We intentionally use [ngModel] instead of [(ngModel)] in the template.
|
|
9226
|
+
* Two-way binding would update the local value BEFORE this handler runs,
|
|
9227
|
+
* which would prevent correct change detection and CVA propagation.
|
|
9225
9228
|
*/
|
|
9226
9229
|
onSwitchChange(next) {
|
|
9227
9230
|
if (this.disabled)
|
|
9228
9231
|
return;
|
|
9229
9232
|
const normalized = this.normalizeBool(next);
|
|
9230
|
-
|
|
9231
|
-
|
|
9233
|
+
if (normalized !== this.value) {
|
|
9234
|
+
this.value = normalized;
|
|
9235
|
+
this.onChange(normalized);
|
|
9232
9236
|
this.cdr.markForCheck();
|
|
9233
9237
|
return;
|
|
9234
9238
|
}
|
|
9235
|
-
|
|
9239
|
+
// ensure the form control still receives the value
|
|
9236
9240
|
this.onChange(normalized);
|
|
9237
9241
|
this.cdr.markForCheck();
|
|
9238
9242
|
}
|
|
@@ -9274,7 +9278,7 @@ class MetaSwitchV2Component {
|
|
|
9274
9278
|
], ngImport: i0, template: `
|
|
9275
9279
|
<p-toggleSwitch
|
|
9276
9280
|
class="phoenix-switch-v2"
|
|
9277
|
-
[
|
|
9281
|
+
[ngModel]="value"
|
|
9278
9282
|
(ngModelChange)="onSwitchChange($event)"
|
|
9279
9283
|
(onBlur)="handleBlur()"
|
|
9280
9284
|
[disabled]="disabled"
|
|
@@ -9288,7 +9292,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
9288
9292
|
args: [{ selector: 'phoenix-meta-switch-v2', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [CommonModule, FormsModule, ToggleSwitchModule], template: `
|
|
9289
9293
|
<p-toggleSwitch
|
|
9290
9294
|
class="phoenix-switch-v2"
|
|
9291
|
-
[
|
|
9295
|
+
[ngModel]="value"
|
|
9292
9296
|
(ngModelChange)="onSwitchChange($event)"
|
|
9293
9297
|
(onBlur)="handleBlur()"
|
|
9294
9298
|
[disabled]="disabled"
|