| 1286 | // --- 1. Component Setup --- |
| 1287 | // An FVC custom control designed for Signal Forms, used inside a legacy template-driven `ngModel`. |
| 1288 | @Component({ |
| 1289 | selector: 'legacy-parsing-input', |
| 1290 | template: `<input #i [value]="rawValue()" (input)="rawValue.set(i.value)" />`, |
| 1291 | }) |
| 1292 | class LegacyParsingInput { |
| 1293 | readonly value = model<number | null>(null); |
| 1294 | protected readonly rawValue = transformedValue(this.value, { |
| 1295 | parse: (val) => { |
| 1296 | if (val === '') return {value: null}; |
| 1297 | const num = Number(val); |
| 1298 | if (Number.isNaN(num)) { |
| 1299 | return {error: {kind: 'parse', message: `${val} is not numeric`}}; |
| 1300 | } |
| 1301 | return {value: num}; |
| 1302 | }, |
| 1303 | format: (val) => val?.toString() ?? '', |
| 1304 | }); |
| 1305 | getRawValueSignal() { |
| 1306 | return this.rawValue; |
| 1307 | } |
| 1308 | } |
| 1309 | |
| 1310 | @Component({ |
| 1311 | template: `<legacy-parsing-input [(ngModel)]="val" #model="ngModel" />`, |
nothing calls this directly
no test coverage detected
searching dependent graphs…