vendor: 9,663 bytes, lines 1-277
1import { 2 ChangeDetectorRef, 3 Directive, 4 ElementRef, 5 EventEmitter, 6 Host, 7 Inject, 8 Injectable, 9 InjectionToken, 10 Injector, 11 Input, 12 NgModule, 13 Optional, 14 Output, 15 Renderer2, 16 RuntimeError, 17 Self, 18 SkipSelf, 19 Subject, 20 Version, 21 booleanAttribute, 22 computed, 23 forkJoin, 24 forwardRef, 25 from, 26 getDOM, 27 inject, 28 isPromise, 29 isSubscribable, 30 map, 31 setClassMetadata, 32 signal, 33 untracked, 34 ɵɵInheritDefinitionFeature, 35 ɵɵNgOnChangesFeature, 36 ɵɵProvidersFeature, 37 ɵɵattribute, 38 ɵɵclassProp, 39 ɵɵdefineDirective, 40 ɵɵdefineInjectable, 41 ɵɵdefineInjector, 42 ɵɵdefineNgModule, 43 ɵɵdirectiveInject, 44 ɵɵgetInheritedFactory, 45 ɵɵlistener 46} from "./chunk-6GJQIPT2.js"; 47import { 48 __spreadProps, 49 __spreadValues 50} from "./chunk-RK4NW2NR.js"; 51 52// node_modules/@angular/forms/fesm2022/forms.mjs 53var BaseControlValueAccessor = class _BaseControlValueAccessor { 54 _renderer; 55 _elementRef; 56 /** 57 * The registered callback function called when a change or input event occurs on the input 58 * element. 59 * @docs-private 60 */ 61 onChange = (_) => { 62 }; 63 /** 64 * The registered callback function called when a blur event occurs on the input element. 65 * @docs-private 66 */ 67 onTouched = () => { 68 }; 69 constructor(_renderer, _elementRef) { 70 this._renderer = _renderer; 71 this._elementRef = _elementRef; 72 } 73 /** 74 * Helper method that sets a property on a target element using the current Renderer 75 * implementation. 76 * @docs-private 77 */ 78 setProperty(key, value) { 79 this._renderer.setProperty(this._elementRef.nativeElement, key, value); 80 } 81 /** 82 * Registers a function called when the control is touched. 83 * @docs-private 84 */ 85 registerOnTouched(fn) { 86 this.onTouched = fn; 87 } 88 /** 89 * Registers a function called when the control value changes. 90 * @docs-private 91 */ 92 registerOnChange(fn) { 93 this.onChange = fn; 94 } 95 /** 96 * Sets the "disabled" property on the range input element. 97 * @docs-private 98 */ 99 setDisabledState(isDisabled) { 100 this.setProperty("disabled", isDisabled); 101 } 102 static \u0275fac = function BaseControlValueAccessor_Factory(__ngFactoryType__) { 103 return new (__ngFactoryType__ || _BaseControlValueAccessor)(\u0275\u0275directiveInject(Renderer2), \u0275\u0275directiveInject(ElementRef)); 104 }; 105 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 106 type: _BaseControlValueAccessor 107 }); 108}; 109(() => { 110 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(BaseControlValueAccessor, [{ 111 type: Directive 112 }], () => [{ 113 type: Renderer2 114 }, { 115 type: ElementRef 116 }], null); 117})(); 118var BuiltInControlValueAccessor = class _BuiltInControlValueAccessor extends BaseControlValueAccessor { 119 static \u0275fac = /* @__PURE__ */ (() => { 120 let \u0275BuiltInControlValueAccessor_BaseFactory; 121 return function BuiltInControlValueAccessor_Factory(__ngFactoryType__) { 122 return (\u0275BuiltInControlValueAccessor_BaseFactory || (\u0275BuiltInControlValueAccessor_BaseFactory = \u0275\u0275getInheritedFactory(_BuiltInControlValueAccessor)))(__ngFactoryType__ || _BuiltInControlValueAccessor); 123 }; 124 })(); 125 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 126 type: _BuiltInControlValueAccessor, 127 features: [\u0275\u0275InheritDefinitionFeature] 128 }); 129}; 130(() => { 131 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(BuiltInControlValueAccessor, [{ 132 type: Directive 133 }], null, null); 134})(); 135var NG_VALUE_ACCESSOR = new InjectionToken(ngDevMode ? "NgValueAccessor" : ""); 136var CHECKBOX_VALUE_ACCESSOR = { 137 provide: NG_VALUE_ACCESSOR, 138 useExisting: forwardRef(() => CheckboxControlValueAccessor), 139 multi: true 140}; 141var CheckboxControlValueAccessor = class _CheckboxControlValueAccessor extends BuiltInControlValueAccessor { 142 /** 143 * Sets the "checked" property on the input element. 144 * @docs-private 145 */ 146 writeValue(value) { 147 this.setProperty("checked", value); 148 } 149 static \u0275fac = /* @__PURE__ */ (() => { 150 let \u0275CheckboxControlValueAccessor_BaseFactory; 151 return function CheckboxControlValueAccessor_Factory(__ngFactoryType__) { 152 return (\u0275CheckboxControlValueAccessor_BaseFactory || (\u0275CheckboxControlValueAccessor_BaseFactory = \u0275\u0275getInheritedFactory(_CheckboxControlValueAccessor)))(__ngFactoryType__ || _CheckboxControlValueAccessor); 153 }; 154 })(); 155 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 156 type: _CheckboxControlValueAccessor, 157 selectors: [["input", "type", "checkbox", "formControlName", ""], ["input", "type", "checkbox", "formControl", ""], ["input", "type", "checkbox", "ngModel", ""]], 158 hostBindings: function CheckboxControlValueAccessor_HostBindings(rf, ctx) { 159 if (rf & 1) { 160 \u0275\u0275listener("change", function CheckboxControlValueAccessor_change_HostBindingHandler($event) { 161 return ctx.onChange($event.target.checked); 162 })("blur", function CheckboxControlValueAccessor_blur_HostBindingHandler() { 163 return ctx.onTouched(); 164 }); 165 } 166 }, 167 standalone: false, 168 features: [\u0275\u0275ProvidersFeature([CHECKBOX_VALUE_ACCESSOR]), \u0275\u0275InheritDefinitionFeature] 169 }); 170}; 171(() => { 172 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(CheckboxControlValueAccessor, [{ 173 type: Directive, 174 args: [{ 175 selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]", 176 host: { 177 "(change)": "onChange($event.target.checked)", 178 "(blur)": "onTouched()" 179 }, 180 providers: [CHECKBOX_VALUE_ACCESSOR], 181 standalone: false 182 }] 183 }], null, null); 184})(); 185var DEFAULT_VALUE_ACCESSOR = { 186 provide: NG_VALUE_ACCESSOR, 187 useExisting: forwardRef(() => DefaultValueAccessor), 188 multi: true 189}; 190function _isAndroid() { 191 const userAgent = getDOM() ? getDOM().getUserAgent() : ""; 192 return /android (\d+)/.test(userAgent.toLowerCase()); 193} 194var COMPOSITION_BUFFER_MODE = new InjectionToken(ngDevMode ? "CompositionEventMode" : ""); 195var DefaultValueAccessor = class _DefaultValueAccessor extends BaseControlValueAccessor { 196 _compositionMode; 197 /** Whether the user is creating a composition string (IME events). */ 198 _composing = false; 199 constructor(renderer, elementRef, _compositionMode) { 200 super(renderer, elementRef); 201 this._compositionMode = _compositionMode; 202 if (this._compositionMode == null) { 203 this._compositionMode = !_isAndroid(); 204 } 205 } 206 /** 207 * Sets the "value" property on the input element. 208 * @docs-private 209 */ 210 writeValue(value) { 211 const normalizedValue = value == null ? "" : value; 212 this.setProperty("value", normalizedValue); 213 } 214 /** @internal */ 215 _handleInput(value) { 216 if (!this._compositionMode || this._compositionMode && !this._composing) { 217 this.onChange(value); 218 } 219 } 220 /** @internal */ 221 _compositionStart() { 222 this._composing = true; 223 } 224 /** @internal */ 225 _compositionEnd(value) { 226 this._composing = false; 227 this._compositionMode && this.onChange(value); 228 } 229 static \u0275fac = function DefaultValueAccessor_Factory(__ngFactoryType__) { 230 return new (__ngFactoryType__ || _DefaultValueAccessor)(\u0275\u0275directiveInject(Renderer2), \u0275\u0275directiveInject(ElementRef), \u0275\u0275directiveInject(COMPOSITION_BUFFER_MODE, 8)); 231 }; 232 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 233 type: _DefaultValueAccessor, 234 selectors: [["input", "formControlName", "", 3, "type", "checkbox"], ["textarea", "formControlName", ""], ["input", "formControl", "", 3, "type", "checkbox"], ["textarea", "formControl", ""], ["input", "ngModel", "", 3, "type", "checkbox"], ["textarea", "ngModel", ""], ["", "ngDefaultControl", ""]], 235 hostBindings: function DefaultValueAccessor_HostBindings(rf, ctx) { 236 if (rf & 1) { 237 \u0275\u0275listener("input", function DefaultValueAccessor_input_HostBindingHandler($event) { 238 return ctx._handleInput($event.target.value); 239 })("blur", function DefaultValueAccessor_blur_HostBindingHandler() { 240 return ctx.onTouched(); 241 })("compositionstart", function DefaultValueAccessor_compositionstart_HostBindingHandler() { 242 return ctx._compositionStart(); 243 })("compositionend", function DefaultValueAccessor_compositionend_HostBindingHandler($event) { 244 return ctx._compositionEnd($event.target.value); 245 }); 246 } 247 }, 248 standalone: false, 249 features: [\u0275\u0275ProvidersFeature([DEFAULT_VALUE_ACCESSOR]), \u0275\u0275InheritDefinitionFeature] 250 }); 251}; 252(() => { 253 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(DefaultValueAccessor, [{ 254 type: Directive, 255 args: [{ 256 selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]", 257 // TODO: vsavkin replace the above selector with the one below it once 258 // https://github.com/angular/angular/issues/3011 is implemented 259 // selector: '[ngModel],[formControl],[formControlName]', 260 host: { 261 "(input)": "$any(this)._handleInput($event.target.value)", 262 "(blur)": "onTouched()", 263 "(compositionstart)": "$any(this)._compositionStart()", 264 "(compositionend)": "$any(this)._compositionEnd($event.target.value)" 265 }, 266 providers: [DEFAULT_VALUE_ACCESSOR], 267 standalone: false 268 }] 269 }], () => [{ 270 type: Renderer2 271 }, { 272 type: ElementRef 273 }, { 274 type: void 0, 275 decorators: [{ 276 type: Optional 277 }, {
278 type: Inject, 279 args: [COMPOSITION_BUFFER_MODE] 280 }] 281 }], null); 282})(); 283function isEmptyInputValue(value) { 284 return value == null || lengthOrSize(value) === 0; 285} 286function lengthOrSize(value) { 287 if (value == null) { 288 return null; 289 } else if (Array.isArray(value) || typeof value === "string") { 290 return value.length; 291 } else if (value instanceof Set) { 292 return value.size; 293 } 294 return null; 295} 296var NG_VALIDATORS = new InjectionToken(ngDevMode ? "NgValidators" : ""); 297var NG_ASYNC_VALIDATORS = new InjectionToken(ngDevMode ? "NgAsyncValidators" : ""); 298var EMAIL_REGEXP = /^(?=.{1,254}$)(?=.{1,64}@)[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; 299var Validators = class { 300 /** 301 * @description 302 * Validator that requires the control's value to be greater than or equal to the provided number. 303 * 304 * @usageNotes 305 * 306 * ### Validate against a minimum of 3 307 * 308 * ```ts 309 * const control = new FormControl(2, Validators.min(3)); 310 * 311 * console.log(control.errors); // {min: {min: 3, actual: 2}} 312 * ``` 313 * 314 * @returns A validator function that returns an error map with the 315 * `min` property if the validation check fails, otherwise `null`. 316 * 317 * @see {@link /api/forms/AbstractControl#updateValueAndValidity updateValueAndValidity} 318 * 319 */ 320 static min(min) { 321 return minValidator(min); 322 } 323 /** 324 * @description 325 * Validator that requires the control's value to be less than or equal to the provided number. 326 * 327 * @usageNotes 328 * 329 * ### Validate against a maximum of 15 330 * 331 * ```ts 332 * const control = new FormControl(16, Validators.max(15)); 333 * 334 * console.log(control.errors); // {max: {max: 15, actual: 16}} 335 * ``` 336 * 337 * @returns A validator function that returns an error map with the 338 * `max` property if the validation check fails, otherwise `null`. 339 * 340 * @see {@link /api/forms/AbstractControl#updateValueAndValidity updateValueAndValidity} 341 * 342 */ 343 static max(max) { 344 return maxValidator(max); 345 } 346 /** 347 * @description 348 * Validator that requires the control have a non-empty value. 349 * 350 * @usageNotes 351 * 352 * ### Validate that the field is non-empty 353 * 354 * ```ts 355 * const control = new FormControl('', Validators.required); 356 * 357 * console.log(control.errors); // {required: true} 358 * ``` 359 * 360 * @returns An error map with the `required` property 361 * if the validation check fails, otherwise `null`. 362 * 363 * @see {@link /api/forms/AbstractControl#updateValueAndValidity updateValueAndValidity} 364 * 365 */ 366 static required(control) { 367 return requiredValidator(control); 368 } 369 /** 370 * @description 371 * Validator that requires the control's value be true. This validator is commonly 372 * used for required checkboxes. 373 * 374 * @usageNotes 375 * 376 * ### Validate that the field value is true 377 * 378 * ```ts 379 * const control = new FormControl('some value', Validators.requiredTrue); 380 * 381 * console.log(control.errors); // {required: true} 382 * ``` 383 * 384 * @returns An error map that contains the `required` property 385 * set to `true` if the validation check fails, otherwise `null`. 386 * 387 * @see {@link /api/forms/AbstractControl#updateValueAndValidity updateValueAndValidity} 388 * 389 */ 390 static requiredTrue(control) { 391 return requiredTrueValidator(control); 392 } 393 /** 394 * @description 395 * Validator that requires the control's value pass an email validation test. 396 * 397 * Tests the value using a [regular 398 * expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) 399 * pattern suitable for common use cases. The pattern is based on the definition of a valid email 400 * address in the [WHATWG HTML 401 * specification](https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address) with 402 * some enhancements to incorporate more RFC rules (such as rules related to domain names and the 403 * lengths of different parts of the address). 404 * 405 * The differences from the WHATWG version include: 406 * - Disallow `local-part` (the part before the `@` symbol) to begin or end with a period (`.`). 407 * - Disallow `local-part` to be longer than 64 characters. 408 * - Disallow the whole address to be longer than 254 characters. 409 * 410 * If this pattern does not satisfy your business needs, you can use `Validators.pattern()` to 411 * validate the value against a different pattern. 412 * 413 * @usageNotes 414 * 415 * ### Validate that the field matches a valid email pattern 416 * 417 * ```ts 418 * const control = new FormControl('bad@', Validators.email); 419 * 420 * console.log(control.errors); // {email: true} 421 * ``` 422 * 423 * @returns An error map with the `email` property 424 * if the validation check fails, otherwise `null`. 425 * 426 * @see {@link /api/forms/AbstractControl#updateValueAndValidity updateValueAndValidity} 427 * 428 */ 429 static email(control) { 430 return emailValidator(control); 431 } 432 /** 433 * @description 434 * Validator that requires the number of items in the control's value to be greater than or equal 435 * to the provided minimum length. This validator is also provided by default if you use 436 * the HTML5 `minlength` attribute. Note that the `minLength` validator is intended to be used 437 * only for types that have a numeric `length` or `size` property, such as strings, arrays or 438 * sets. The `minLength` validator logic is also not invoked for values when their `length` or 439 * `size` property is 0 (for example in case of an empty string or an empty array), to supp
439ort 440 * optional controls. You can use the standard `required` validator if empty values should not be 441 * considered valid. 442 * 443 * @usageNotes 444 * 445 * ### Validate that the field has a minimum of 3 characters 446 * 447 * ```ts 448 * const control = new FormControl('ng', Validators.minLength(3)); 449 * 450 * console.log(control.errors); // {minlength: {requiredLength: 3, actualLength: 2}} 451 * ``` 452 * 453 * ```html 454 * <input minlength="5"> 455 * ``` 456 * 457 * @returns A validator function that returns an error map with the 458 * `minlength` property if the validation check fails, otherwise `null`. 459 * 460 * @see {@link /api/forms/AbstractControl#updateValueAndValidity updateValueAndValidity} 461 * 462 */ 463 static minLength(minLength) { 464 return minLengthValidator(minLength); 465 } 466 /** 467 * @description 468 * Validator that requires the number of items in the control's value to be less than or equal 469 * to the provided maximum length. This validator is also provided by default if you use 470 * the HTML5 `maxlength` attribute. Note that the `maxLength` validator is intended to be used 471 * only for types that have a numeric `length` or `size` property, such as strings, arrays or 472 * sets. 473 * 474 * @usageNotes 475 * 476 * ### Validate that the field has maximum of 5 characters 477 * 478 * ```ts 479 * const control = new FormControl('Angular', Validators.maxLength(5)); 480 * 481 * console.log(control.errors); // {maxlength: {requiredLength: 5, actualLength: 7}} 482 * ``` 483 * 484 * ```html 485 * <input maxlength="5"> 486 * ``` 487 * 488 * @returns A validator function that returns an error map with the 489 * `maxlength` property if the validation check fails, otherwise `null`. 490 * 491 * @see {@link /api/forms/AbstractControl#updateValueAndValidity updateValueAndValidity} 492 * 493 */ 494 static maxLength(maxLength) { 495 return maxLengthValidator(maxLength); 496 } 497 /** 498 * @description 499 * Validator that requires the control's value to match a regex pattern. This validator is also 500 * provided by default if you use the HTML5 `pattern` attribute. 501 * 502 * @usageNotes 503 * 504 * ### Validate that the field only contains letters or spaces 505 * 506 * ```ts 507 * const control = new FormControl('1', Validators.pattern('[a-zA-Z ]*')); 508 * 509 * console.log(control.errors); // {pattern: {requiredPattern: '^[a-zA-Z ]*$', actualValue: '1'}} 510 * ``` 511 * 512 * ```html 513 * <input pattern="[a-zA-Z ]*"> 514 * ``` 515 * 516 * ### Pattern matching with the global or sticky flag 517 * 518 * `RegExp` objects created with the `g` or `y` flags that are passed into `Validators.pattern` 519 * can produce different results on the same input when validations are run consecutively. This is 520 * due to how the behavior of `RegExp.prototype.test` is 521 * specified in [ECMA-262](https://tc39.es/ecma262/#sec-regexpbuiltinexec) 522 * (`RegExp` preserves the index of the last match when the global or sticky flag is used). 523 * Due to this behavior, it is recommended that when using 524 * `Validators.pattern` you **do not** pass in a `RegExp` object with either the global or sticky 525 * flag enabled. 526 * 527 * ```ts 528 * // Not recommended (since the `g` flag is used) 529 * const controlOne = new FormControl('1', Validators.pattern(/foo/g)); 530 * 531 * // Good 532 * const controlTwo = new FormControl('1', Validators.pattern(/foo/)); 533 * ``` 534 * 535 * @param pattern A regular expression to be used as is to test the values, or a string. 536 * If a string is passed, the `^` character is prepended and the `$` character is 537 * appended to the provided string (if not already present), and the resulting regular 538 * expression is used to test the values. 539 * 540 * @returns A validator function that returns an error map with the 541 * `pattern` property if the validation check fails, otherwise `null`. 542 * 543 * @see {@link /api/forms/AbstractControl#updateValueAndValidity updateValueAndValidity} 544 * 545 */ 546 static pattern(pattern) { 547 return patternValidator(pattern); 548 } 549 /** 550 * @description 551 * Validator that performs no operation. 552 * 553 * @see {@link /api/forms/AbstractControl#updateValueAndValidity updateValueAndValidity} 554 * 555 */ 556 static nullValidator(control) { 557 return nullValidator(); 558 } 559 static compose(validators) { 560 return compose(validators); 561 } 562 /** 563 * @description 564 * Compose multiple async validators into a single function that returns the union 565 * of the individual error objects for the provided control. 566 * 567 * @returns A validator function that returns an error map with the 568 * merged error objects of the async validators if the validation check fails, otherwise `null`. 569 * 570 * @see {@link /api/forms/AbstractControl#updateValueAndValidity updateValueAndValidity} 571 * 572 */ 573 static composeAsync(validators) { 574 return composeAsync(validators); 575 } 576}; 577function minValidator(min) {
578 return (control) => { 579 if (control.value == null || min == null) { 580 return null; 581 } 582 const value = parseFloat(control.value); 583 return !isNaN(value) && value < min ? { 584 "min": { 585 "min": min, 586 "actual": control.value 587 } 588 } : null; 589 }; 590} 591function maxValidator(max) { 592 return (control) => { 593 if (control.value == null || max == null) { 594 return null; 595 } 596 const value = parseFloat(control.value); 597 return !isNaN(value) && value > max ? { 598 "max": { 599 "max": max, 600 "actual": control.value 601 } 602 } : null; 603 }; 604} 605function requiredValidator(control) { 606 return isEmptyInputValue(control.value) ? { 607 "required": true 608 } : null; 609} 610function requiredTrueValidator(control) { 611 return control.value === true ? null : { 612 "required": true 613 }; 614} 615function emailValidator(control) { 616 if (isEmptyInputValue(control.value)) { 617 return null; 618 } 619 return EMAIL_REGEXP.test(control.value) ? null : { 620 "email": true 621 }; 622} 623function minLengthValidator(minLength) { 624 return (control) => { 625 const length = control.value?.length ?? lengthOrSize(control.value); 626 if (length === null || length === 0) { 627 return null; 628 } 629 return length < minLength ? { 630 "minlength": { 631 "requiredLength": minLength, 632 "actualLength": length 633 } 634 } : null; 635 }; 636} 637function maxLengthValidator(maxLength) { 638 return (control) => { 639 const length = control.value?.length ?? lengthOrSize(control.value); 640 if (length !== null && length > maxLength) { 641 return { 642 "maxlength": { 643 "requiredLength": maxLength, 644 "actualLength": length 645 } 646 }; 647 } 648 return
vendor: 34,249 bytes, lines 648-1708
648 null; 649 }; 650} 651function patternValidator(pattern) { 652 if (!pattern) return nullValidator; 653 let regex; 654 let regexStr; 655 if (typeof pattern === "string") { 656 regexStr = ""; 657 if (pattern.charAt(0) !== "^") regexStr += "^"; 658 regexStr += pattern; 659 if (pattern.charAt(pattern.length - 1) !== "$") regexStr += "$"; 660 regex = new RegExp(regexStr); 661 } else { 662 regexStr = pattern.toString(); 663 regex = pattern; 664 } 665 return (control) => { 666 if (isEmptyInputValue(control.value)) { 667 return null; 668 } 669 const value = control.value; 670 return regex.test(value) ? null : { 671 "pattern": { 672 "requiredPattern": regexStr, 673 "actualValue": value 674 } 675 }; 676 }; 677} 678function nullValidator(control) { 679 return null; 680} 681function isPresent(o) { 682 return o != null; 683} 684function toObservable(value) { 685 const obs = isPromise(value) ? from(value) : value; 686 if ((typeof ngDevMode === "undefined" || ngDevMode) && !isSubscribable(obs)) { 687 let errorMessage = `Expected async validator to return Promise or Observable.`; 688 if (typeof value === "object") { 689 errorMessage += " Are you using a synchronous validator where an async validator is expected?"; 690 } 691 throw new RuntimeError(-1101, errorMessage); 692 } 693 return obs; 694} 695function mergeErrors(arrayOfErrors) { 696 let res = {}; 697 arrayOfErrors.forEach((errors) => { 698 res = errors != null ? __spreadValues(__spreadValues({}, res), errors) : res; 699 }); 700 return Object.keys(res).length === 0 ? null : res; 701} 702function executeValidators(control, validators) { 703 return validators.map((validator) => validator(control)); 704} 705function isValidatorFn(validator) { 706 return !validator.validate; 707} 708function normalizeValidators(validators) { 709 return validators.map((validator) => { 710 return isValidatorFn(validator) ? validator : (c) => validator.validate(c); 711 }); 712} 713function compose(validators) { 714 if (!validators) return null; 715 const presentValidators = validators.filter(isPresent); 716 if (presentValidators.length == 0) return null; 717 return function(control) { 718 return mergeErrors(executeValidators(control, presentValidators)); 719 }; 720} 721function composeValidators(validators) { 722 return validators != null ? compose(normalizeValidators(validators)) : null; 723} 724function composeAsync(validators) { 725 if (!validators) return null; 726 const presentValidators = validators.filter(isPresent); 727 if (presentValidators.length == 0) return null; 728 return function(control) { 729 const observables = executeValidators(control, presentValidators).map(toObservable); 730 return forkJoin(observables).pipe(map(mergeErrors)); 731 }; 732} 733function composeAsyncValidators(validators) { 734 return validators != null ? composeAsync(normalizeValidators(validators)) : null; 735} 736function mergeValidators(controlValidators, dirValidator) { 737 if (controlValidators === null) return [dirValidator]; 738 return Array.isArray(controlValidators) ? [...controlValidators, dirValidator] : [controlValidators, dirValidator]; 739} 740function getControlValidators(control) { 741 return control._rawValidators; 742} 743function getControlAsyncValidators(control) { 744 return control._rawAsyncValidators; 745} 746function makeValidatorsArray(validators) { 747 if (!validators) return []; 748 return Array.isArray(validators) ? validators : [validators]; 749} 750function hasValidator(validators, validator) { 751 return Array.isArray(validators) ? validators.includes(validator) : validators === validator; 752} 753function addValidators(validators, currentValidators) { 754 const current = makeValidatorsArray(currentValidators); 755 const validatorsToAdd = makeValidatorsArray(validators); 756 validatorsToAdd.forEach((v) => { 757 if (!hasValidator(current, v)) { 758 current.push(v); 759 } 760 }); 761 return current; 762} 763function removeValidators(validators, currentValidators) { 764 return makeValidatorsArray(currentValidators).filter((v) => !hasValidator(validators, v)); 765} 766var AbstractControlDirective = class { 767 /** 768 * @description 769 * Reports the value of the control if it is present, otherwise null. 770 */ 771 get value() { 772 return this.control ? this.control.value : null; 773 } 774 /** 775 * @description 776 * Reports whether the control is valid. A control is considered valid if no 777 * validation errors exist with the current value. 778 * If the control is not present, null is returned. 779 */ 780 get valid() { 781 return this.control ? this.control.valid : null; 782 } 783 /** 784 * @description 785 * Reports whether the control is invalid, meaning that an error exists in the input value. 786 * If the control is not present, null is returned. 787 */ 788 get invalid() { 789 return this.control ? this.control.invalid : null; 790 } 791 /** 792 * @description 793 * Reports whether a control is pending, meaning that async validation is occurring and 794 * errors are not yet available for the input value. If the control is not present, null is 795 * returned. 796 */ 797 get pending() { 798 return this.control ? this.control.pending : null; 799 } 800 /** 801 * @description 802 * Reports whether the control is disabled, meaning that the control is disabled 803 * in the UI and is exempt from validation checks and excluded from aggregate 804 * values of ancestor controls. If the control is not present, null is returned. 805 */ 806 get disabled() { 807 return this.control ? this.control.disabled : null; 808 } 809 /** 810 * @description 811 * Reports whether the control is enabled, meaning that the control is included in ancestor 812 * calculations of validity or value. If the control is not present, null is returned. 813 */ 814 get enabled() { 815 return this.control ? this.control.enabled : null; 816 } 817 /** 818 * @description 819 * Reports the control's validation errors. If the control is not present, null is returned. 820 */ 821 get errors() { 822 return this.control ? this.control.errors : null; 823 } 824 /** 825 * @description 826 * Reports whether the control is pristine, meaning that the user has not yet changed 827 * the value in the UI. If the control is not present, null is returned. 828 */ 829 get pristine() { 830 return this.control ? this.control.pristine : null; 831 } 832 /** 833 * @description 834 * Reports whether the control is dirty, meaning that the user has changed 835 * the value in the UI. If the control is not present, null is returned. 836 */ 837 get dirty() { 838 return this.control ? this.control.dirty : null; 839 } 840 /** 841 * @description 842 * Reports whether the control is touched, meaning that the user has triggered 843 * a `blur` event on it. If the control is not present, null is returned. 844 */ 845 get touched() { 846 return this.control ? this.control.touched : null; 847 } 848 /** 849 * @description 850 * Reports the validation status of the control. Possible values include: 851 * 'VALID', 'INVALID', 'DISABLED', and 'PENDING'. 852 * If the control is not present, null is returned. 853 */ 854 get status() { 855 return this.control ? this.control.status : null; 856 } 857 /** 858 * @description 859 * Reports whether the control is untouched, meaning that the user has not yet triggered 860 * a `blur` event on it. If the control is not present, null is returned. 861 */ 862 get untouched() { 863 return this.control ? this.control.untouched : null; 864 } 865 /** 866 * @description 867 * Returns a multicasting observable that emits a validation status whenever it is 868 * calculated for the control. If the control is not present, null is returned. 869 */ 870 get statusChanges() { 871 return this.control ? this.control.statusChanges : null; 872 } 873 /** 874 * @description 875 * Returns a multicasting observable of value changes for the control that emits every time the 876 * value of the control changes in the UI or programmatically. 877 * If the control is not present, null is returned. 878 */ 879 get valueChanges() { 880 return this.control ? this.control.valueChanges : null; 881 } 882 /** 883 * @description 884 * Returns an array that represents the path from the top-level form to this control. 885 * Each index is the string name of the control on that level. 886 */ 887 get path() { 888 return null; 889 } 890 /** 891 * Contains the result of merging synchronous validators into a single validator function 892 * (combined using `Validators.compose`). 893 */ 894 _composedValidatorFn; 895 /** 896 * Contains the result of merging asynchronous validators into a single validator function 897 * (combined using `Validators.composeAsync`). 898 */ 899 _composedAsyncValidatorFn; 900 /** 901 * Set of synchronous validators as they were provided while calling `setValidators` function. 902 * @internal 903 */ 904 _rawValidators = []; 905 /** 906 * Set of asynchronous validators as they were provided while calling `setAsyncValidators` 907 * function. 908 * @internal 909 */ 910 _rawAsyncValidators = []; 911 /** 912 * Sets synchronous validators for this directive. 913 * @internal 914 */ 915 _setValidators(validators) { 916 this._rawValidators = validators || []; 917 this._composedValidatorFn = composeValidators(this._rawValidators); 918 } 919 /** 920 * Sets asynchronous validators for this directive. 921 * @internal 922 */ 923 _setAsyncValidators(validators) { 924 this._rawAsyncValidators = validators || []; 925 this._composedAsyncValidatorFn = composeAsyncValidators(this._rawAsyncValidators); 926 } 927 /** 928 * @description 929 * Synchronous validator function composed of all the synchronous validators registered with this 930 * directive. 931 */ 932 get validator() { 933 return this._composedValidatorFn || null; 934 } 935 /** 936 * @description 937 * Asynchronous validator function composed of all the asynchronous validators registered with 938 * this directive. 939 */ 940 get asyncValidator() { 941 return this._composedAsyncValidatorFn || null; 942 } 943 /* 944 * The set of callbacks to be invoked when directive instance is being destroyed. 945 */ 946 _onDestroyCallbacks = []; 947 /** 948 * Internal function to register callbacks that should be invoked 949 * when directive instance is being destroyed. 950 * @internal 951 */ 952 _registerOnDestroy(fn) { 953 this._onDestroyCallbacks.push(fn); 954 } 955 /** 956 * Internal function to invoke all registered "on destroy" callbacks. 957 * Note: calling this function also clears the list of callbacks. 958 * @internal 959 */ 960 _invokeOnDestroyCallbacks() { 961 this._onDestroyCallbacks.forEach((fn) => fn()); 962 this._onDestroyCallbacks = []; 963 } 964 /** 965 * @description 966 * Resets the control with the provided value if the control is present. 967 */ 968 reset(value = void 0) { 969 if (this.control) this.control.reset(value); 970 } 971 /** 972 * @description 973 * Reports whether the control with the given path has the error specified. 974 * 975 * @param errorCode The code of the error to check 976 * @param path A list of control names that designates how to move from the current control 977 * to the control that should be queried for errors. 978 * 979 * @usageNotes 980 * For example, for the following `FormGroup`: 981 * 982 * ```ts 983 * form = new FormGroup({ 984 * address: new FormGroup({ street: new FormControl() }) 985 * }); 986 * ``` 987 * 988 * The path to the 'street' control from the root form would be 'address' -> 'street'. 989 * 990 * It can be provided to this method in one of two formats: 991 * 992 * 1. An array of string control names, e.g. `['address', 'street']` 993 * 1. A period-delimited list of control names in one string, e.g. `'address.street'` 994 * 995 * If no path is given, this method checks for the error on the current control. 996 * 997 * @returns whether the given error is present in the control at the given path. 998 * 999 * If the control is not present, false is returned. 1000 */ 1001 hasError(errorCode, path) { 1002 return this.control ? this.control.hasError(errorCode, path) : false; 1003 } 1004 /** 1005 * @description 1006 * Reports error data for the control with the given path. 1007 * 1008 * @param errorCode The code of the error to check 1009 * @param path A list of control names that designates how to move from the current control 1010 * to the control that should be queried for errors. 1011 * 1012 * @usageNotes 1013 * For example, for the following `FormGroup`: 1014 * 1015 * ```ts 1016 * form = new FormGroup({ 1017 * address: new FormGroup({ street: new FormControl() }) 1018 * }); 1019 * ``` 1020 * 1021 * The path to the 'street' control from the root form would be 'address' -> 'street'. 1022 * 1023 * It can be provided to this method in one of two formats: 1024 * 1025 * 1. An array of string control names, e.g. `['address', 'street']` 1026 * 1. A period-delimited list of control names in one string, e.g. `'address.street'` 1027 * 1028 * @returns error data for that particular error. If the control or error is not present, 1029 * null is returned. 1030 */ 1031 getError(errorCode, path) { 1032 return this.control ? this.control.getError(errorCode, path) : null; 1033 } 1034}; 1035var ControlContainer = class extends AbstractControlDirective { 1036 /** 1037 * @description 1038 * The name for the control 1039 */ 1040 name; 1041 /** 1042 * @description 1043 * The top-level form directive for the control. 1044 */ 1045 get formDirective() { 1046 return null; 1047 } 1048 /** 1049 * @description 1050 * The path to this group. 1051 */ 1052 get path() { 1053 return null; 1054 } 1055}; 1056var NgControl = class extends AbstractControlDirective { 1057 /** 1058 * @description 1059 * The parent form for the control. 1060 * 1061 * @internal 1062 */ 1063 _parent = null; 1064 /** 1065 * @description 1066 * The name for the control 1067 */ 1068 name = null; 1069 /** 1070 * @description 1071 * The value accessor for the control 1072 */ 1073 valueAccessor = null; 1074}; 1075var AbstractControlStatus = class { 1076 _cd; 1077 constructor(cd) { 1078 this._cd = cd; 1079 } 1080 get isTouched() { 1081 this._cd?.control?._touched?.(); 1082 return !!this._cd?.control?.touched; 1083 } 1084 get isUntouched() { 1085 return !!this._cd?.control?.untouched; 1086 } 1087 get isPristine() { 1088 this._cd?.control?._pristine?.(); 1089 return !!this._cd?.control?.pristine; 1090 } 1091 get isDirty() { 1092 return !!this._cd?.control?.dirty; 1093 } 1094 get isValid() { 1095 this._cd?.control?._status?.(); 1096 return !!this._cd?.control?.valid; 1097 } 1098 get isInvalid() { 1099 return !!this._cd?.control?.invalid; 1100 } 1101 get isPending() { 1102 return !!this._cd?.control?.pending; 1103 } 1104 get isSubmitted() { 1105 this._cd?._submitted?.(); 1106 return !!this._cd?.submitted; 1107 } 1108}; 1109var ngControlStatusHost = { 1110 "[class.ng-untouched]": "isUntouched", 1111 "[class.ng-touched]": "isTouched", 1112 "[class.ng-pristine]": "isPristine", 1113 "[class.ng-dirty]": "isDirty", 1114 "[class.ng-valid]": "isValid", 1115 "[class.ng-invalid]": "isInvalid", 1116 "[class.ng-pending]": "isPending" 1117}; 1118var ngGroupStatusHost = __spreadProps(__spreadValues({}, ngControlStatusHost), { 1119 "[class.ng-submitted]": "isSubmitted" 1120}); 1121var NgControlStatus = class _NgControlStatus extends AbstractControlStatus { 1122 constructor(cd) { 1123 super(cd); 1124 } 1125 static \u0275fac = function NgControlStatus_Factory(__ngFactoryType__) { 1126 return new (__ngFactoryType__ || _NgControlStatus)(\u0275\u0275directiveInject(NgControl, 2)); 1127 }; 1128 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 1129 type: _NgControlStatus, 1130 selectors: [["", "formControlName", ""], ["", "ngModel", ""], ["", "formControl", ""]], 1131 hostVars: 14, 1132 hostBindings: function NgControlStatus_HostBindings(rf, ctx) { 1133 if (rf & 2) { 1134 \u0275\u0275classProp("ng-untouched", ctx.isUntouched)("ng-touched", ctx.isTouched)("ng-pristine", ctx.isPristine)("ng-dirty", ctx.isDirty)("ng-valid", ctx.isValid)("ng-invalid", ctx.isInvalid)("ng-pending", ctx.isPending); 1135 } 1136 }, 1137 standalone: false, 1138 features: [\u0275\u0275InheritDefinitionFeature] 1139 }); 1140}; 1141(() => { 1142 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(NgControlStatus, [{ 1143 type: Directive, 1144 args: [{ 1145 selector: "[formControlName],[ngModel],[formControl]", 1146 host: ngControlStatusHost, 1147 standalone: false 1148 }] 1149 }], () => [{ 1150 type: NgControl, 1151 decorators: [{ 1152 type: Self 1153 }] 1154 }], null); 1155})(); 1156var NgControlStatusGroup = class _NgControlStatusGroup extends AbstractControlStatus { 1157 constructor(cd) { 1158 super(cd); 1159 } 1160 static \u0275fac = function NgControlStatusGroup_Factory(__ngFactoryType__) { 1161 return new (__ngFactoryType__ || _NgControlStatusGroup)(\u0275\u0275directiveInject(ControlContainer, 10)); 1162 }; 1163 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 1164 type: _NgControlStatusGroup, 1165 selectors: [["", "formGroupName", ""], ["", "formArrayName", ""], ["", "ngModelGroup", ""], ["", "formGroup", ""], ["form", 3, "ngNoForm", ""], ["", "ngForm", ""]], 1166 hostVars: 16, 1167 hostBindings: function NgControlStatusGroup_HostBindings(rf, ctx) { 1168 if (rf & 2) { 1169 \u0275\u0275classProp("ng-untouched", ctx.isUntouched)("ng-touched", ctx.isTouched)("ng-pristine", ctx.isPristine)("ng-dirty", ctx.isDirty)("ng-valid", ctx.isValid)("ng-invalid", ctx.isInvalid)("ng-pending", ctx.isPending)("ng-submitted", ctx.isSubmitted); 1170 } 1171 }, 1172 standalone: false, 1173 features: [\u0275\u0275InheritDefinitionFeature] 1174 }); 1175}; 1176(() => { 1177 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(NgControlStatusGroup, [{ 1178 type: Directive, 1179 args: [{ 1180 selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]", 1181 host: ngGroupStatusHost, 1182 standalone: false 1183 }] 1184 }], () => [{ 1185 type: ControlContainer, 1186 decorators: [{ 1187 type: Optional 1188 }, { 1189 type: Self 1190 }] 1191 }], null); 1192})(); 1193var formControlNameExample = ` 1194 <div [formGroup]="myGroup"> 1195 <input formControlName="firstName"> 1196 </div> 1197 1198 In your class: 1199 1200 this.myGroup = new FormGroup({ 1201 firstName: new FormControl() 1202 });`; 1203var formGroupNameExample = ` 1204 <div [formGroup]="myGroup"> 1205 <div formGroupName="person"> 1206 <input formControlName="firstName"> 1207 </div> 1208 </div> 1209 1210 In your class: 1211 1212 this.myGroup = new FormGroup({ 1213 person: new FormGroup({ firstName: new FormControl() }) 1214 });`; 1215var formArrayNameExample = ` 1216 <div [formGroup]="myGroup"> 1217 <div formArrayName="cities"> 1218 <div *ngFor="let city of cityArray.controls; index as i"> 1219 <input [formControlName]="i"> 1220 </div> 1221 </div> 1222 </div> 1223 1224 In your class: 1225 1226 this.cityArray = new FormArray([new FormControl('SF')]); 1227 this.myGroup = new FormGroup({ 1228 cities: this.cityArray 1229 });`; 1230var ngModelGroupExample = ` 1231 <form> 1232 <div ngModelGroup="person"> 1233 <input [(ngModel)]="person.name" name="firstName"> 1234 </div> 1235 </form>`; 1236var ngModelWithFormGroupExample = ` 1237 <div [formGroup]="myGroup"> 1238 <input formControlName="firstName"> 1239 <input [(ngModel)]="showMoreControls" [ngModelOptions]="{standalone: true}"> 1240 </div> 1241`; 1242function controlParentException(nameOrIndex) { 1243 return new RuntimeError(1050, `formControlName must be used with a parent formGroup directive. You'll want to add a formGroup 1244 directive and pass it an existing FormGroup instance (you can create one in your class). 1245 1246 ${describeFormControl(nameOrIndex)} 1247 1248 Example: 1249 1250 ${formControlNameExample}`); 1251} 1252function describeFormControl(nameOrIndex) { 1253 if (nameOrIndex == null || nameOrIndex === "") { 1254 return ""; 1255 } 1256 const valueType = typeof nameOrIndex === "string" ? "name" : "index"; 1257 return `Affected Form Control ${valueType}: "${nameOrIndex}"`; 1258} 1259function ngModelGroupException() { 1260 return new RuntimeError(1051, `formControlName cannot be used with an ngModelGroup parent. It is only compatible with parents 1261 that also have a "form" prefix: formGroupName, formArrayName, or formGroup. 1262 1263 Option 1: Update the parent to be formGroupName (reactive form strategy) 1264 1265 ${formGroupNameExample} 1266 1267 Option 2: Use ngModel instead of formControlName (template-driven strategy) 1268 1269 ${ngModelGroupExample}`); 1270} 1271function missingFormException() { 1272 return new RuntimeError(1052, `formGroup expects a FormGroup instance. Please pass one in. 1273 1274 Example: 1275 1276 ${formControlNameExample}`); 1277} 1278function groupParentException() { 1279 return new RuntimeError(1053, `formGroupName must be used with a parent formGroup directive. You'll want to add a formGroup 1280 directive and pass it an existing FormGroup instance (you can create one in your class). 1281 1282 Example: 1283 1284 ${formGroupNameExample}`); 1285} 1286function arrayParentException() { 1287 return new RuntimeError(1054, `formArrayName must be used with a parent formGroup directive. You'll want to add a formGroup 1288 directive and pass it an existing FormGroup instance (you can create one in your class). 1289 1290 Example: 1291 1292 ${formArrayNameExample}`); 1293} 1294var disabledAttrWarning = ` 1295 It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true 1296 when you set up this control in your component class, the disabled attribute will actually be set in the DOM for 1297 you. We recommend using this approach to avoid 'changed after checked' errors. 1298 1299 Example: 1300 // Specify the \`disabled\` property at control creation time: 1301 form = new FormGroup({ 1302 first: new FormControl({value: 'Nancy', disabled: true}, Validators.required), 1303 last: new FormControl('Drew', Validators.required) 1304 }); 1305 1306 // Controls can also be enabled/disabled after creation: 1307 form.get('first')?.enable(); 1308 form.get('last')?.disable(); 1309`; 1310var asyncValidatorsDroppedWithOptsWarning = ` 1311 It looks like you're constructing using a FormControl with both an options argument and an 1312 async validators argument. Mixing these arguments will cause your async validators to be dropped. 1313 You should either put all your validators in the options object, or in separate validators 1314 arguments. For example: 1315 1316 // Using validators arguments 1317 fc = new FormControl(42, Validators.required, myAsyncValidator); 1318 1319 // Using AbstractControlOptions 1320 fc = new FormControl(42, {validators: Validators.required, asyncValidators: myAV}); 1321 1322 // Do NOT mix them: async validators will be dropped! 1323 fc = new FormControl(42, {validators: Validators.required}, /* Oops! */ myAsyncValidator); 1324`; 1325function ngModelWarning(directiveName) { 1326 return ` 1327 It looks like you're using ngModel on the same form field as ${directiveName}. 1328 Support for using the ngModel input property and ngModelChange event with 1329 reactive form directives has been deprecated in Angular v6 and will be removed 1330 in a future version of Angular. 1331 1332 For more information on this, see our API docs here: 1333 https://angular.io/api/forms/${directiveName === "formControl" ? "FormControlDirective" : "FormControlName"}#use-with-ngmodel 1334 `; 1335} 1336function describeKey(isFormGroup, key) { 1337 return isFormGroup ? `with name: '${key}'` : `at index: ${key}`; 1338} 1339function noControlsError(isFormGroup) { 1340 return ` 1341 There are no form controls registered with this ${isFormGroup ? "group" : "array"} yet. If you're using ngModel, 1342 you may want to check next tick (e.g. use setTimeout). 1343 `; 1344} 1345function missingControlError(isFormGroup, key) { 1346 return `Cannot find form control ${describeKey(isFormGroup, key)}`; 1347} 1348function missingControlValueError(isFormGroup, key) { 1349 return `Must supply a value for form control ${describeKey(isFormGroup, key)}`; 1350} 1351var VALID = "VALID"; 1352var INVALID = "INVALID"; 1353var PENDING = "PENDING"; 1354var DISABLED = "DISABLED"; 1355var ControlEvent = class { 1356}; 1357var ValueChangeEvent = class extends ControlEvent { 1358 value; 1359 source; 1360 constructor(value, source) { 1361 super(); 1362 this.value = value; 1363 this.source = source; 1364 } 1365}; 1366var PristineChangeEvent = class extends ControlEvent { 1367 pristine; 1368 source; 1369 constructor(pristine, source) { 1370 super(); 1371 this.pristine = pristine; 1372 this.source = source; 1373 } 1374}; 1375var TouchedChangeEvent = class extends ControlEvent { 1376 touched; 1377 source; 1378 constructor(touched, source) { 1379 super(); 1380 this.touched = touched; 1381 this.source = source; 1382 } 1383}; 1384var StatusChangeEvent = class extends ControlEvent { 1385 status; 1386 source; 1387 constructor(status, source) { 1388 super(); 1389 this.status = status; 1390 this.source = source; 1391 } 1392}; 1393var FormSubmittedEvent = class extends ControlEvent { 1394 source; 1395 constructor(source) { 1396 super(); 1397 this.source = source; 1398 } 1399}; 1400var FormResetEvent = class extends ControlEvent { 1401 source; 1402 constructor(source) { 1403 super(); 1404 this.source = source; 1405 } 1406}; 1407function pickValidators(validatorOrOpts) { 1408 return (isOptionsObj(validatorOrOpts) ? validatorOrOpts.validators : validatorOrOpts) || null; 1409} 1410function coerceToValidator(validator) { 1411 return Array.isArray(validator) ? composeValidators(validator) : validator || null; 1412} 1413function pickAsyncValidators(asyncValidator, validatorOrOpts) { 1414 if (typeof ngDevMode === "undefined" || ngDevMode) { 1415 if (isOptionsObj(validatorOrOpts) && asyncValidator) { 1416 console.warn(asyncValidatorsDroppedWithOptsWarning); 1417 } 1418 } 1419 return (isOptionsObj(validatorOrOpts) ? validatorOrOpts.asyncValidators : asyncValidator) || null; 1420} 1421function coerceToAsyncValidator(asyncValidator) { 1422 return Array.isArray(asyncValidator) ? composeAsyncValidators(asyncValidator) : asyncValidator || null; 1423} 1424function isOptionsObj(validatorOrOpts) { 1425 return validatorOrOpts != null && !Array.isArray(validatorOrOpts) && typeof validatorOrOpts === "object"; 1426} 1427function assertControlPresent(parent, isGroup, key) { 1428 const controls = parent.controls; 1429 const collection = isGroup ? Object.keys(controls) : controls; 1430 if (!collection.length) { 1431 throw new RuntimeError(1e3, typeof ngDevMode === "undefined" || ngDevMode ? noControlsError(isGroup) : ""); 1432 } 1433 if (!controls[key]) { 1434 throw new RuntimeError(1001, typeof ngDevMode === "undefined" || ngDevMode ? missingControlError(isGroup, key) : ""); 1435 } 1436} 1437function assertAllValuesPresent(control, isGroup, value) { 1438 control._forEachChild((_, key) => { 1439 if (value[key] === void 0) { 1440 throw new RuntimeError(1002, typeof ngDevMode === "undefined" || ngDevMode ? missingControlValueError(isGroup, key) : ""); 1441 } 1442 }); 1443} 1444var AbstractControl = class { 1445 /** @internal */ 1446 _pendingDirty = false; 1447 /** 1448 * Indicates that a control has its own pending asynchronous validation in progress. 1449 * It also stores if the control should emit events when the validation status changes. 1450 * 1451 * @internal 1452 */ 1453 _hasOwnPendingAsyncValidator = null; 1454 /** @internal */ 1455 _pendingTouched = false; 1456 /** @internal */ 1457 _onCollectionChange = () => { 1458 }; 1459 /** @internal */ 1460 _updateOn; 1461 _parent = null; 1462 _asyncValidationSubscription; 1463 /** 1464 * Contains the result of merging synchronous validators into a single validator function 1465 * (combined using `Validators.compose`). 1466 * 1467 * @internal 1468 */ 1469 _composedValidatorFn; 1470 /** 1471 * Contains the result of merging asynchronous validators into a single validator function 1472 * (combined using `Validators.composeAsync`). 1473 * 1474 * @internal 1475 */ 1476 _composedAsyncValidatorFn; 1477 /** 1478 * Synchronous validators as they were provided: 1479 * - in `AbstractControl` constructor 1480 * - as an argument while calling `setValidators` function 1481 * - while calling the setter on the `validator` field (e.g. `control.validator = validatorFn`) 1482 * 1483 * @internal 1484 */ 1485 _rawValidators; 1486 /** 1487 * Asynchronous validators as they were provided: 1488 * - in `AbstractControl` constructor 1489 * - as an argument while calling `setAsyncValidators` function 1490 * - while calling the setter on the `asyncValidator` field (e.g. `control.asyncValidator = 1491 * asyncValidatorFn`) 1492 * 1493 * @internal 1494 */ 1495 _rawAsyncValidators; 1496 /** 1497 * The current value of the control. 1498 * 1499 * * For a `FormControl`, the current value. 1500 * * For an enabled `FormGroup`, the values of enabled controls as an object 1501 * with a key-value pair for each member of the group. 1502 * * For a disabled `FormGroup`, the values of all controls as an object 1503 * with a key-value pair for each member of the group. 1504 * * For a `FormArray`, the values of enabled controls as an array. 1505 * 1506 */ 1507 value; 1508 /** 1509 * Initialize the AbstractControl instance. 1510 * 1511 * @param validators The function or array of functions that is used to determine the validity of 1512 * this control synchronously. 1513 * @param asyncValidators The function or array of functions that is used to determine validity of 1514 * this control asynchronously. 1515 */ 1516 constructor(validators, asyncValidators) { 1517 this._assignValidators(validators); 1518 this._assignAsyncValidators(asyncValidators); 1519 } 1520 /** 1521 * Returns the function that is used to determine the validity of this control synchronously. 1522 * If multiple validators have been added, this will be a single composed function. 1523 * See `Validators.compose()` for additional information. 1524 */ 1525 get validator() { 1526 return this._composedValidatorFn; 1527 } 1528 set validator(validatorFn) { 1529 this._rawValidators = this._composedValidatorFn = validatorFn; 1530 } 1531 /** 1532 * Returns the function that is used to determine the validity of this control asynchronously. 1533 * If multiple validators have been added, this will be a single composed function. 1534 * See `Validators.compose()` for additional information. 1535 */ 1536 get asyncValidator() { 1537 return this._composedAsyncValidatorFn; 1538 } 1539 set asyncValidator(asyncValidatorFn) { 1540 this._rawAsyncValidators = this._composedAsyncValidatorFn = asyncValidatorFn; 1541 } 1542 /** 1543 * The parent control. 1544 */ 1545 get parent() { 1546 return this._parent; 1547 } 1548 /** 1549 * The validation status of the control. 1550 * 1551 * @see {@link FormControlStatus} 1552 * 1553 * These status values are mutually exclusive, so a control cannot be 1554 * both valid AND invalid or invalid AND disabled. 1555 */ 1556 get status() { 1557 return untracked(this.statusReactive); 1558 } 1559 set status(v) { 1560 untracked(() => this.statusReactive.set(v)); 1561 } 1562 /** @internal */ 1563 _status = computed(() => this.statusReactive()); 1564 statusReactive = signal(void 0); 1565 /** 1566 * A control is `valid` when its `status` is `VALID`. 1567 * 1568 * @see {@link AbstractControl.status} 1569 * 1570 * @returns True if the control has passed all of its validation tests, 1571 * false otherwise. 1572 */ 1573 get valid() { 1574 return this.status === VALID; 1575 } 1576 /** 1577 * A control is `invalid` when its `status` is `INVALID`. 1578 * 1579 * @see {@link AbstractControl.status} 1580 * 1581 * @returns True if this control has failed one or more of its validation checks, 1582 * false otherwise. 1583 */ 1584 get invalid() { 1585 return this.status === INVALID; 1586 } 1587 /** 1588 * A control is `pending` when its `status` is `PENDING`. 1589 * 1590 * @see {@link AbstractControl.status} 1591 * 1592 * @returns True if this control is in the process of conducting a validation check, 1593 * false otherwise. 1594 */ 1595 get pending() { 1596 return this.status == PENDING; 1597 } 1598 /** 1599 * A control is `disabled` when its `status` is `DISABLED`. 1600 * 1601 * Disabled controls are exempt from validation checks and 1602 * are not included in the aggregate value of their ancestor 1603 * controls. 1604 * 1605 * @see {@link AbstractControl.status} 1606 * 1607 * @returns True if the control is disabled, false otherwise. 1608 */ 1609 get disabled() { 1610 return this.status === DISABLED; 1611 } 1612 /** 1613 * A control is `enabled` as long as its `status` is not `DISABLED`. 1614 * 1615 * @returns True if the control has any status other than 'DISABLED', 1616 * false if the status is 'DISABLED'. 1617 * 1618 * @see {@link AbstractControl.status} 1619 * 1620 */ 1621 get enabled() { 1622 return this.status !== DISABLED; 1623 } 1624 /** 1625 * An object containing any errors generated by failing validation, 1626 * or null if there are no errors. 1627 */ 1628 errors; 1629 /** 1630 * A control is `pristine` if the user has not yet changed 1631 * the value in the UI. 1632 * 1633 * @returns True if the user has not yet changed the value in the UI; compare `dirty`. 1634 * Programmatic changes to a control's value do not mark it dirty. 1635 */ 1636 get pristine() { 1637 return untracked(this.pristineReactive); 1638 } 1639 set pristine(v) { 1640 untracked(() => this.pristineReactive.set(v)); 1641 } 1642 /** @internal */ 1643 _pristine = computed(() => this.pristineReactive()); 1644 pristineReactive = signal(true); 1645 /** 1646 * A control is `dirty` if the user has changed the value 1647 * in the UI. 1648 * 1649 * @returns True if the user has changed the value of this control in the UI; compare `pristine`. 1650 * Programmatic changes to a control's value do not mark it dirty. 1651 */ 1652 get dirty() { 1653 return !this.pristine; 1654 } 1655 /** 1656 * True if the control is marked as `touched`. 1657 * 1658 * A control is marked `touched` once the user has triggered 1659 * a `blur` event on it. 1660 */ 1661 get touched() { 1662 return untracked(this.touchedReactive); 1663 } 1664 set touched(v) { 1665 untracked(() => this.touchedReactive.set(v)); 1666 } 1667 /** @internal */ 1668 _touched = computed(() => this.touchedReactive()); 1669 touchedReactive = signal(false); 1670 /** 1671 * True if the control has not been marked as touched 1672 * 1673 * A control is `untouched` if the user has not yet triggered 1674 * a `blur` event on it. 1675 */ 1676 get untouched() { 1677 return !this.touched; 1678 } 1679 /** 1680 * Exposed as observable, see below. 1681 * 1682 * @internal 1683 */ 1684 _events = new Subject(); 1685 /** 1686 * A multicasting observable that emits an event every time the state of the control changes. 1687 * It emits for value, status, pristine or touched changes. 1688 * 1689 * **Note**: On value change, the emit happens right after a value of this control is updated. The 1690 * value of a parent control (for example if this FormControl is a part of a FormGroup) is updated 1691 * later, so accessing a value of a parent control (using the `value` property) from the callback 1692 * of this event might result in getting a value that has not been updated yet. Subscribe to the 1693 * `events` of the parent control instead. 1694 * For other event types, the events are emitted after the parent control has been updated. 1695 * 1696 */ 1697 events = this._events.asObservable(); 1698 /** 1699 * A multicasting observable that emits an event every time the value of the control changes, in 1700 * the UI or programmatically. It also emits an event each time you call enable() or disable() 1701 * without passing along {emitEvent: false} as a function argument. 1702 * 1703 * **Note**: the emit happens right after a value of this control is updated. The value of a 1704 * parent control (for example if this FormControl is a part of a FormGroup) is updated later, so 1705 * accessing a value of a parent control (using the `value` property) from the callback of this 1706 * event might result in getting a value that has not been updated yet. Subscribe to the 1707 * `valueChanges` event of the parent control instead. 1708 *
1708/ 1709 valueChanges; 1710 /** 1711 * A multicasting observable that emits an event every time the validation `status` of the control 1712 * recalculates. 1713 * 1714 * @see {@link FormControlStatus} 1715 * @see {@link AbstractControl.status}
vendor: 43,359 bytes, lines 1715-2927
1715 1716 */ 1717 statusChanges; 1718 /** 1719 * Reports the update strategy of the `AbstractControl` (meaning 1720 * the event on which the control updates itself). 1721 * Possible values: `'change'` | `'blur'` | `'submit'` 1722 * Default value: `'change'` 1723 */ 1724 get updateOn() { 1725 return this._updateOn ? this._updateOn : this.parent ? this.parent.updateOn : "change"; 1726 } 1727 /** 1728 * Sets the synchronous validators that are active on this control. Calling 1729 * this overwrites any existing synchronous validators. 1730 * 1731 * When you add or remove a validator at run time, you must call 1732 * `updateValueAndValidity()` for the new validation to take effect. 1733 * 1734 * If you want to add a new validator without affecting existing ones, consider 1735 * using `addValidators()` method instead. 1736 */ 1737 setValidators(validators) { 1738 this._assignValidators(validators); 1739 } 1740 /** 1741 * Sets the asynchronous validators that are active on this control. Calling this 1742 * overwrites any existing asynchronous validators. 1743 * 1744 * When you add or remove a validator at run time, you must call 1745 * `updateValueAndValidity()` for the new validation to take effect. 1746 * 1747 * If you want to add a new validator without affecting existing ones, consider 1748 * using `addAsyncValidators()` method instead. 1749 */ 1750 setAsyncValidators(validators) { 1751 this._assignAsyncValidators(validators); 1752 } 1753 /** 1754 * Add a synchronous validator or validators to this control, without affecting other validators. 1755 * 1756 * When you add or remove a validator at run time, you must call 1757 * `updateValueAndValidity()` for the new validation to take effect. 1758 * 1759 * Adding a validator that already exists will have no effect. If duplicate validator functions 1760 * are present in the `validators` array, only the first instance would be added to a form 1761 * control. 1762 * 1763 * @param validators The new validator function or functions to add to this control. 1764 */ 1765 addValidators(validators) { 1766 this.setValidators(addValidators(validators, this._rawValidators)); 1767 } 1768 /** 1769 * Add an asynchronous validator or validators to this control, without affecting other 1770 * validators. 1771 * 1772 * When you add or remove a validator at run time, you must call 1773 * `updateValueAndValidity()` for the new validation to take effect. 1774 * 1775 * Adding a validator that already exists will have no effect. 1776 * 1777 * @param validators The new asynchronous validator function or functions to add to this control. 1778 */ 1779 addAsyncValidators(validators) { 1780 this.setAsyncValidators(addValidators(validators, this._rawAsyncValidators)); 1781 } 1782 /** 1783 * Remove a synchronous validator from this control, without affecting other validators. 1784 * Validators are compared by function reference; you must pass a reference to the exact same 1785 * validator function as the one that was originally set. If a provided validator is not found, 1786 * it is ignored. 1787 * 1788 * @usageNotes 1789 * 1790 * ### Reference to a ValidatorFn 1791 * 1792 * ``` 1793 * // Reference to the RequiredValidator 1794 * const ctrl = new FormControl<string | null>('', Validators.required); 1795 * ctrl.removeValidators(Validators.required); 1796 * 1797 * // Reference to anonymous function inside MinValidator 1798 * const minValidator = Validators.min(3); 1799 * const ctrl = new FormControl<string | null>('', minValidator); 1800 * expect(ctrl.hasValidator(minValidator)).toEqual(true) 1801 * expect(ctrl.hasValidator(Validators.min(3))).toEqual(false) 1802 * 1803 * ctrl.removeValidators(minValidator); 1804 * ``` 1805 * 1806 * When you add or remove a validator at run time, you must call 1807 * `updateValueAndValidity()` for the new validation to take effect. 1808 * 1809 * @param validators The validator or validators to remove. 1810 */ 1811 removeValidators(validators) { 1812 this.setValidators(removeValidators(validators, this._rawValidators)); 1813 } 1814 /** 1815 * Remove an asynchronous validator from this control, without affecting other validators. 1816 * Validators are compared by function reference; you must pass a reference to the exact same 1817 * validator function as the one that was originally set. If a provided validator is not found, it 1818 * is ignored. 1819 * 1820 * When you add or remove a validator at run time, you must call 1821 * `updateValueAndValidity()` for the new validation to take effect. 1822 * 1823 * @param validators The asynchronous validator or validators to remove. 1824 */ 1825 removeAsyncValidators(validators) { 1826 this.setAsyncValidators(removeValidators(validators, this._rawAsyncValidators)); 1827 } 1828 /** 1829 * Check whether a synchronous validator function is present on this control. The provided 1830 * validator must be a reference to the exact same function that was provided. 1831 * 1832 * @usageNotes 1833 * 1834 * ### Reference to a ValidatorFn 1835 * 1836 * ``` 1837 * // Reference to the RequiredValidator 1838 * const ctrl = new FormControl<number | null>(0, Validators.required); 1839 * expect(ctrl.hasValidator(Validators.required)).toEqual(true) 1840 * 1841 * // Reference to anonymous function inside MinValidator 1842 * const minValidator = Validators.min(3); 1843 * const ctrl = new FormControl<number | null>(0, minValidator); 1844 * expect(ctrl.hasValidator(minValidator)).toEqual(true) 1845 * expect(ctrl.hasValidator(Validators.min(3))).toEqual(false) 1846 * ``` 1847 * 1848 * @param validator The validator to check for presence. Compared by function reference. 1849 * @returns Whether the provided validator was found on this control. 1850 */ 1851 hasValidator(validator) { 1852 return hasValidator(this._rawValidators, validator); 1853 } 1854 /** 1855 * Check whether an asynchronous validator function is present on this control. The provided 1856 * validator must be a reference to the exact same function that was provided. 1857 * 1858 * @param validator The asynchronous validator to check for presence. Compared by function 1859 * reference. 1860 * @returns Whether the provided asynchronous validator was found on this control. 1861 */ 1862 hasAsyncValidator(validator) { 1863 return hasValidator(this._rawAsyncValidators, validator); 1864 } 1865 /** 1866 * Empties out the synchronous validator list. 1867 * 1868 * When you add or remove a validator at run time, you must call 1869 * `updateValueAndValidity()` for the new validation to take effect. 1870 * 1871 */ 1872 clearValidators() { 1873 this.validator = null; 1874 } 1875 /** 1876 * Empties out the async validator list. 1877 * 1878 * When you add or remove a validator at run time, you must call 1879 * `updateValueAndValidity()` for the new validation to take effect. 1880 * 1881 */ 1882 clearAsyncValidators() { 1883 this.asyncValidator = null; 1884 } 1885 markAsTouched(opts = {}) { 1886 const changed = this.touched === false; 1887 this.touched = true; 1888 const sourceControl = opts.sourceControl ?? this; 1889 if (this._parent && !opts.onlySelf) { 1890 this._parent.markAsTouched(__spreadProps(__spreadValues({}, opts), { 1891 sourceControl 1892 })); 1893 } 1894 if (changed && opts.emitEvent !== false) { 1895 this._events.next(new TouchedChangeEvent(true, sourceControl)); 1896 } 1897 } 1898 /** 1899 * Marks the control and all its descendant controls as `touched`. 1900 * @see {@link markAsTouched()} 1901 * 1902 * @param opts Configuration options that determine how the control propagates changes 1903 * and emits events after marking is applied. 1904 * * `emitEvent`: When true or not supplied (the default), the `events` 1905 * observable emits a `TouchedChangeEvent` with the `touched` property being `true`. 1906 * When false, no events are emitted. 1907 */ 1908 markAllAsTouched(opts = {}) { 1909 this.markAsTouched({ 1910 onlySelf: true, 1911 emitEvent: opts.emitEvent, 1912 sourceControl: this 1913 }); 1914 this._forEachChild((control) => control.markAllAsTouched(opts)); 1915 } 1916 markAsUntouched(opts = {}) { 1917 const changed = this.touched === true; 1918 this.touched = false; 1919 this._pendingTouched = false; 1920 const sourceControl = opts.sourceControl ?? this; 1921 this._forEachChild((control) => { 1922 control.markAsUntouched({ 1923 onlySelf: true, 1924 emitEvent: opts.emitEvent, 1925 sourceControl 1926 }); 1927 }); 1928 if (this._parent && !opts.onlySelf) { 1929 this._parent._updateTouched(opts, sourceControl); 1930 } 1931 if (changed && opts.emitEvent !== false) { 1932 this._events.next(new TouchedChangeEvent(false, sourceControl)); 1933 } 1934 } 1935 markAsDirty(opts = {}) { 1936 const changed = this.pristine === true; 1937 this.pristine = false; 1938 const sourceControl = opts.sourceControl ?? this; 1939 if (this._parent && !opts.onlySelf) { 1940 this._parent.markAsDirty(__spreadProps(__spreadValues({}, opts), { 1941 sourceControl 1942 })); 1943 } 1944 if (changed && opts.emitEvent !== false) { 1945 this._events.next(new PristineChangeEvent(false, sourceControl)); 1946 } 1947 } 1948 markAsPristine(opts = {}) { 1949 const changed = this.pristine === false; 1950 this.pristine = true; 1951 this._pendingDirty = false; 1952 const sourceControl = opts.sourceControl ?? this; 1953 this._forEachChild((control) => { 1954 control.markAsPristine({ 1955 onlySelf: true, 1956 emitEvent: opts.emitEvent 1957 }); 1958 }); 1959 if (this._parent && !opts.onlySelf) { 1960 this._parent._updatePristine(opts, sourceControl); 1961 } 1962 if (changed && opts.emitEvent !== false) { 1963 this._events.next(new PristineChangeEvent(true, sourceControl)); 1964 } 1965 } 1966 markAsPending(opts = {}) { 1967 this.status = PENDING; 1968 const sourceControl = opts.sourceControl ?? this; 1969 if (opts.emitEvent !== false) { 1970 this._events.next(new StatusChangeEvent(this.status, sourceControl)); 1971 this.statusChanges.emit(this.status); 1972 } 1973 if (this._parent && !opts.onlySelf) { 1974 this._parent.markAsPending(__spreadProps(__spreadValues({}, opts), { 1975 sourceControl 1976 })); 1977 } 1978 } 1979 disable(opts = {}) { 1980 const skipPristineCheck = this._parentMarkedDirty(opts.onlySelf); 1981 this.status = DISABLED; 1982 this.errors = null; 1983 this._forEachChild((control) => { 1984 control.disable(__spreadProps(__spreadValues({}, opts), { 1985 onlySelf: true 1986 })); 1987 }); 1988 this._updateValue(); 1989 const sourceControl = opts.sourceControl ?? this; 1990 if (opts.emitEvent !== false) { 1991 this._events.next(new ValueChangeEvent(this.value, sourceControl)); 1992 this._events.next(new StatusChangeEvent(this.status, sourceControl)); 1993 this.valueChanges.emit(this.value); 1994 this.statusChanges.emit(this.status); 1995 } 1996 this._updateAncestors(__spreadProps(__spreadValues({}, opts), { 1997 skipPristineCheck 1998 }), this); 1999 this._onDisabledChange.forEach((changeFn) => changeFn(true)); 2000 } 2001 /** 2002 * Enables the control. This means the control is included in validation checks and 2003 * the aggregate value of its parent. Its status recalculates based on its value and 2004 * its validators. 2005 * 2006 * By default, if the control has children, all children are enabled. 2007 * 2008 * @see {@link AbstractControl.status} 2009 * 2010 * @param opts Configure options that control how the control propagates changes and 2011 * emits events when marked as untouched 2012 * * `onlySelf`: When true, mark only this control. When false or not supplied, 2013 * marks all direct ancestors. Default is false. 2014 * * `emitEvent`: When true or not supplied (the default), the `statusChanges`, 2015 * `valueChanges` and `events` 2016 * observables emit events with the latest status and value when the control is enabled. 2017 * When false, no events are emitted. 2018 */ 2019 enable(opts = {}) { 2020 const skipPristineCheck = this._parentMarkedDirty(opts.onlySelf); 2021 this.status = VALID; 2022 this._forEachChild((control) => { 2023 control.enable(__spreadProps(__spreadValues({}, opts), { 2024 onlySelf: true 2025 })); 2026 }); 2027 this.updateValueAndValidity({ 2028 onlySelf: true, 2029 emitEvent: opts.emitEvent 2030 }); 2031 this._updateAncestors(__spreadProps(__spreadValues({}, opts), { 2032 skipPristineCheck 2033 }), this); 2034 this._onDisabledChange.forEach((changeFn) => changeFn(false)); 2035 } 2036 _updateAncestors(opts, sourceControl) { 2037 if (this._parent && !opts.onlySelf) { 2038 this._parent.updateValueAndValidity(opts); 2039 if (!opts.skipPristineCheck) { 2040 this._parent._updatePristine({}, sourceControl); 2041 } 2042 this._parent._updateTouched({}, sourceControl); 2043 } 2044 } 2045 /** 2046 * Sets the parent of the control 2047 * 2048 * @param parent The new parent. 2049 */ 2050 setParent(parent) { 2051 this._parent = parent; 2052 } 2053 /** 2054 * The raw value of this control. For most control implementations, the raw value will include 2055 * disabled children. 2056 */ 2057 getRawValue() { 2058 return this.value; 2059 } 2060 updateValueAndValidity(opts = {}) { 2061 this._setInitialStatus(); 2062 this._updateValue(); 2063 if (this.enabled) { 2064 const shouldHaveEmitted = this._cancelExistingSubscription(); 2065 this.errors = this._runValidator(); 2066 this.status = this._calculateStatus(); 2067 if (this.status === VALID || this.status === PENDING) { 2068 this._runAsyncValidator(shouldHaveEmitted, opts.emitEvent); 2069 } 2070 } 2071 const sourceControl = opts.sourceControl ?? this; 2072 if (opts.emitEvent !== false) { 2073 this._events.next(new ValueChangeEvent(this.value, sourceControl)); 2074 this._events.next(new StatusChangeEvent(this.status, sourceControl)); 2075 this.valueChanges.emit(this.value); 2076 this.statusChanges.emit(this.status); 2077 } 2078 if (this._parent && !opts.onlySelf) { 2079 this._parent.updateValueAndValidity(__spreadProps(__spreadValues({}, opts), { 2080 sourceControl 2081 })); 2082 } 2083 } 2084 /** @internal */ 2085 _updateTreeValidity(opts = { 2086 emitEvent: true 2087 }) { 2088 this._forEachChild((ctrl) => ctrl._updateTreeValidity(opts)); 2089 this.updateValueAndValidity({ 2090 onlySelf: true, 2091 emitEvent: opts.emitEvent 2092 }); 2093 } 2094 _setInitialStatus() { 2095 this.status = this._allControlsDisabled() ? DISABLED : VALID; 2096 } 2097 _runValidator() { 2098 return this.validator ? this.validator(this) : null; 2099 } 2100 _runAsyncValidator(shouldHaveEmitted, emitEvent) { 2101 if (this.asyncValidator) { 2102 this.status = PENDING; 2103 this._hasOwnPendingAsyncValidator = { 2104 emitEvent: emitEvent !== false 2105 }; 2106 const obs = toObservable(this.asyncValidator(this)); 2107 this._asyncValidationSubscription = obs.subscribe((errors) => { 2108 this._hasOwnPendingAsyncValidator = null; 2109 this.setErrors(errors, { 2110 emitEvent, 2111 shouldHaveEmitted 2112 }); 2113 }); 2114 } 2115 } 2116 _cancelExistingSubscription() { 2117 if (this._asyncValidationSubscription) { 2118 this._asyncValidationSubscription.unsubscribe(); 2119 const shouldHaveEmitted = this._hasOwnPendingAsyncValidator?.emitEvent ?? false; 2120 this._hasOwnPendingAsyncValidator = null; 2121 return shouldHaveEmitted; 2122 } 2123 return false; 2124 } 2125 setErrors(errors, opts = {}) { 2126 this.errors = errors; 2127 this._updateControlsErrors(opts.emitEvent !== false, this, opts.shouldHaveEmitted); 2128 } 2129 /** 2130 * Retrieves a child control given the control's name or path. 2131 * 2132 * @param path A dot-delimited string or array of string/number values that define the path to the 2133 * control. If a string is provided, passing it as a string literal will result in improved type 2134 * information. Likewise, if an array is provided, passing it `as const` will cause improved type 2135 * information to be available. 2136 * 2137 * @usageNotes 2138 * ### Retrieve a nested control 2139 * 2140 * For example, to get a `name` control nested within a `person` sub-group: 2141 * 2142 * * `this.form.get('person.name');` 2143 * 2144 * -OR- 2145 * 2146 * * `this.form.get(['person', 'name'] as const);` // `as const` gives improved typings 2147 * 2148 * ### Retrieve a control in a FormArray 2149 * 2150 * When accessing an element inside a FormArray, you can use an element index. 2151 * For example, to get a `price` control from the first element in an `items` array you can use: 2152 * 2153 * * `this.form.get('items.0.price');` 2154 * 2155 * -OR- 2156 * 2157 * * `this.form.get(['items', 0, 'price']);` 2158 */ 2159 get(path) { 2160 let currPath = path; 2161 if (currPath == null) return null; 2162 if (!Array.isArray(currPath)) currPath = currPath.split("."); 2163 if (currPath.length === 0) return null; 2164 return currPath.reduce((control, name) => control && control._find(name), this); 2165 } 2166 /** 2167 * @description 2168 * Reports error data for the control with the given path. 2169 * 2170 * @param errorCode The code of the error to check 2171 * @param path A list of control names that designates how to move from the current control 2172 * to the control that should be queried for errors. 2173 * 2174 * @usageNotes 2175 * For example, for the following `FormGroup`: 2176 * 2177 * ```ts 2178 * form = new FormGroup({ 2179 * address: new FormGroup({ street: new FormControl() }) 2180 * }); 2181 * ``` 2182 * 2183 * The path to the 'street' control from the root form would be 'address' -> 'street'. 2184 * 2185 * It can be provided to this method in one of two formats: 2186 * 2187 * 1. An array of string control names, e.g. `['address', 'street']` 2188 * 1. A period-delimited list of control names in one string, e.g. `'address.street'` 2189 * 2190 * @returns error data for that particular error. If the control or error is not present, 2191 * null is returned. 2192 */ 2193 getError(errorCode, path) { 2194 const control = path ? this.get(path) : this; 2195 return control && control.errors ? control.errors[errorCode] : null; 2196 } 2197 /** 2198 * @description 2199 * Reports whether the control with the given path has the error specified. 2200 * 2201 * @param errorCode The code of the error to check 2202 * @param path A list of control names that designates how to move from the current control 2203 * to the control that should be queried for errors. 2204 * 2205 * @usageNotes 2206 * For example, for the following `FormGroup`: 2207 * 2208 * ```ts 2209 * form = new FormGroup({ 2210 * address: new FormGroup({ street: new FormControl() }) 2211 * }); 2212 * ``` 2213 * 2214 * The path to the 'street' control from the root form would be 'address' -> 'street'. 2215 * 2216 * It can be provided to this method in one of two formats: 2217 * 2218 * 1. An array of string control names, e.g. `['address', 'street']` 2219 * 1. A period-delimited list of control names in one string, e.g. `'address.street'` 2220 * 2221 * If no path is given, this method checks for the error on the current control. 2222 * 2223 * @returns whether the given error is present in the control at the given path. 2224 * 2225 * If the control is not present, false is returned. 2226 */ 2227 hasError(errorCode, path) { 2228 return !!this.getError(errorCode, path); 2229 } 2230 /** 2231 * Retrieves the top-level ancestor of this control. 2232 */ 2233 get root() { 2234 let x = this; 2235 while (x._parent) { 2236 x = x._parent; 2237 } 2238 return x; 2239 } 2240 /** @internal */ 2241 _updateControlsErrors(emitEvent, changedControl, shouldHaveEmitted) { 2242 this.status = this._calculateStatus(); 2243 if (emitEvent) { 2244 this.statusChanges.emit(this.status); 2245 } 2246 if (emitEvent || shouldHaveEmitted) { 2247 this._events.next(new StatusChangeEvent(this.status, changedControl)); 2248 } 2249 if (this._parent) { 2250 this._parent._updateControlsErrors(emitEvent, changedControl, shouldHaveEmitted); 2251 } 2252 } 2253 /** @internal */ 2254 _initObservables() { 2255 this.valueChanges = new EventEmitter(); 2256 this.statusChanges = new EventEmitter(); 2257 } 2258 _calculateStatus() { 2259 if (this._allControlsDisabled()) return DISABLED; 2260 if (this.errors) return INVALID; 2261 if (this._hasOwnPendingAsyncValidator || this._anyControlsHaveStatus(PENDING)) return PENDING; 2262 if (this._anyControlsHaveStatus(INVALID)) return INVALID; 2263 return VALID; 2264 } 2265 /** @internal */ 2266 _anyControlsHaveStatus(status) { 2267 return this._anyControls((control) => control.status === status); 2268 } 2269 /** @internal */ 2270 _anyControlsDirty() { 2271 return this._anyControls((control) => control.dirty); 2272 } 2273 /** @internal */ 2274 _anyControlsTouched() { 2275 return this._anyControls((control) => control.touched); 2276 } 2277 /** @internal */ 2278 _updatePristine(opts, changedControl) { 2279 const newPristine = !this._anyControlsDirty(); 2280 const changed = this.pristine !== newPristine; 2281 this.pristine = newPristine; 2282 if (this._parent && !opts.onlySelf) { 2283 this._parent._updatePristine(opts, changedControl); 2284 } 2285 if (changed) { 2286 this._events.next(new PristineChangeEvent(this.pristine, changedControl)); 2287 } 2288 } 2289 /** @internal */ 2290 _updateTouched(opts = {}, changedControl) { 2291 this.touched = this._anyControlsTouched(); 2292 this._events.next(new TouchedChangeEvent(this.touched, changedControl)); 2293 if (this._parent && !opts.onlySelf) { 2294 this._parent._updateTouched(opts, changedControl); 2295 } 2296 } 2297 /** @internal */ 2298 _onDisabledChange = []; 2299 /** @internal */ 2300 _registerOnCollectionChange(fn) { 2301 this._onCollectionChange = fn; 2302 } 2303 /** @internal */ 2304 _setUpdateStrategy(opts) { 2305 if (isOptionsObj(opts) && opts.updateOn != null) { 2306 this._updateOn = opts.updateOn; 2307 } 2308 } 2309 /** 2310 * Check to see if parent has been marked artificially dirty. 2311 * 2312 * @internal 2313 */ 2314 _parentMarkedDirty(onlySelf) { 2315 const parentDirty = this._parent && this._parent.dirty; 2316 return !onlySelf && !!parentDirty && !this._parent._anyControlsDirty(); 2317 } 2318 /** @internal */ 2319 _find(name) { 2320 return null; 2321 } 2322 /** 2323 * Internal implementation of the `setValidators` method. Needs to be separated out into a 2324 * different method, because it is called in the constructor and it can break cases where 2325 * a control is extended. 2326 */ 2327 _assignValidators(validators) { 2328 this._rawValidators = Array.isArray(validators) ? validators.slice() : validators; 2329 this._composedValidatorFn = coerceToValidator(this._rawValidators); 2330 } 2331 /** 2332 * Internal implementation of the `setAsyncValidators` method. Needs to be separated out into a 2333 * different method, because it is called in the constructor and it can break cases where 2334 * a control is extended. 2335 */ 2336 _assignAsyncValidators(validators) { 2337 this._rawAsyncValidators = Array.isArray(validators) ? validators.slice() : validators; 2338 this._composedAsyncValidatorFn = coerceToAsyncValidator(this._rawAsyncValidators); 2339 } 2340}; 2341var FormGroup = class extends AbstractControl { 2342 /** 2343 * Creates a new `FormGroup` instance. 2344 * 2345 * @param controls A collection of child controls. The key for each child is the name 2346 * under which it is registered. 2347 * 2348 * @param validatorOrOpts A synchronous validator function, or an array of 2349 * such functions, or an `AbstractControlOptions` object that contains validation functions 2350 * and a validation trigger. 2351 * 2352 * @param asyncValidator A single async validator or array of async validator functions 2353 * 2354 */ 2355 constructor(controls, validatorOrOpts, asyncValidator) { 2356 super(pickValidators(validatorOrOpts), pickAsyncValidators(asyncValidator, validatorOrOpts)); 2357 (typeof ngDevMode === "undefined" || ngDevMode) && validateFormGroupControls(controls); 2358 this.controls = controls; 2359 this._initObservables(); 2360 this._setUpdateStrategy(validatorOrOpts); 2361 this._setUpControls(); 2362 this.updateValueAndValidity({ 2363 onlySelf: true, 2364 // If `asyncValidator` is present, it will trigger control status change from `PENDING` to 2365 // `VALID` or `INVALID`. The status should be broadcasted via the `statusChanges` observable, 2366 // so we set `emitEvent` to `true` to allow that during the control creation process. 2367 emitEvent: !!this.asyncValidator 2368 }); 2369 } 2370 controls; 2371 registerControl(name, control) { 2372 if (this.controls[name]) return this.controls[name]; 2373 this.controls[name] = control; 2374 control.setParent(this); 2375 control._registerOnCollectionChange(this._onCollectionChange); 2376 return control; 2377 } 2378 addControl(name, control, options = {}) { 2379 this.registerControl(name, control); 2380 this.updateValueAndValidity({ 2381 emitEvent: options.emitEvent 2382 }); 2383 this._onCollectionChange(); 2384 } 2385 /** 2386 * Remove a control from this group. In a strongly-typed group, required controls cannot be 2387 * removed. 2388 * 2389 * This method also updates the value and validity of the control. 2390 * 2391 * @param name The control name to remove from the collection 2392 * @param options Specifies whether this FormGroup instance should emit events after a 2393 * control is removed. 2394 * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and 2395 * `valueChanges` observables emit events with the latest status and value when the control is 2396 * removed. When false, no events are emitted. 2397 */ 2398 removeControl(name, options = {}) { 2399 if (this.controls[name]) this.controls[name]._registerOnCollectionChange(() => { 2400 }); 2401 delete this.controls[name]; 2402 this.updateValueAndValidity({ 2403 emitEvent: options.emitEvent 2404 }); 2405 this._onCollectionChange(); 2406 } 2407 setControl(name, control, options = {}) { 2408 if (this.controls[name]) this.controls[name]._registerOnCollectionChange(() => { 2409 }); 2410 delete this.controls[name]; 2411 if (control) this.registerControl(name, control); 2412 this.updateValueAndValidity({ 2413 emitEvent: options.emitEvent 2414 }); 2415 this._onCollectionChange(); 2416 } 2417 contains(controlName) { 2418 return this.controls.hasOwnProperty(controlName) && this.controls[controlName].enabled; 2419 } 2420 /** 2421 * Sets the value of the `FormGroup`. It accepts an object that matches 2422 * the structure of the group, with control names as keys. 2423 * 2424 * @usageNotes 2425 * ### Set the complete value for the form group 2426 * 2427 * ```ts 2428 * const form = new FormGroup({ 2429 * first: new FormControl(), 2430 * last: new FormControl() 2431 * }); 2432 * 2433 * console.log(form.value); // {first: null, last: null} 2434 * 2435 * form.setValue({first: 'Nancy', last: 'Drew'}); 2436 * console.log(form.value); // {first: 'Nancy', last: 'Drew'} 2437 * ``` 2438 * 2439 * @throws When strict checks fail, such as setting the value of a control 2440 * that doesn't exist or if you exclude a value of a control that does exist. 2441 * 2442 * @param value The new value for the control that matches the structure of the group. 2443 * @param options Configuration options that determine how the control propagates changes 2444 * and emits events after the value changes. 2445 * The configuration options are passed to the {@link AbstractControl#updateValueAndValidity 2446 * updateValueAndValidity} method. 2447 * 2448 * * `onlySelf`: When true, each change only affects this control, and not its parent. Default is 2449 * false. 2450 * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and 2451 * `valueChanges` 2452 * observables emit events with the latest status and value when the control value is updated. 2453 * When false, no events are emitted. 2454 */ 2455 setValue(value, options = {}) { 2456 assertAllValuesPresent(this, true, value); 2457 Object.keys(value).forEach((name) => { 2458 assertControlPresent(this, true, name); 2459 this.controls[name].setValue(value[name], { 2460 onlySelf: true, 2461 emitEvent: options.emitEvent 2462 }); 2463 }); 2464 this.updateValueAndValidity(options); 2465 } 2466 /** 2467 * Patches the value of the `FormGroup`. It accepts an object with control 2468 * names as keys, and does its best to match the values to the correct controls 2469 * in the group. 2470 * 2471 * It accepts both super-sets and sub-sets of the group without throwing an error. 2472 * 2473 * @usageNotes 2474 * ### Patch the value for a form group 2475 * 2476 * ```ts 2477 * const form = new FormGroup({ 2478 * first: new FormControl(), 2479 * last: new FormControl() 2480 * }); 2481 * console.log(form.value); // {first: null, last: null} 2482 * 2483 * form.patchValue({first: 'Nancy'}); 2484 * console.log(form.value); // {first: 'Nancy', last: null} 2485 * ``` 2486 * 2487 * @param value The object that matches the structure of the group. 2488 * @param options Configuration options that determine how the control propagates changes and 2489 * emits events after the value is patched. 2490 * * `onlySelf`: When true, each change only affects this control and not its parent. Default is 2491 * true. 2492 * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and 2493 * `valueChanges` observables emit events with the latest status and value when the control value 2494 * is updated. When false, no events are emitted. The configuration options are passed to 2495 * the {@link AbstractControl#updateValueAndValidity updateValueAndValidity} method. 2496 */ 2497 patchValue(value, options = {}) { 2498 if (value == null) return; 2499 Object.keys(value).forEach((name) => { 2500 const control = this.controls[name]; 2501 if (control) { 2502 control.patchValue( 2503 /* Guaranteed to be present, due to the outer forEach. */ 2504 value[name], 2505 { 2506 onlySelf: true, 2507 emitEvent: options.emitEvent 2508 } 2509 ); 2510 } 2511 }); 2512 this.updateValueAndValidity(options); 2513 } 2514 /** 2515 * Resets the `FormGroup`, marks all descendants `pristine` and `untouched` and sets 2516 * the value of all descendants to their default values, or null if no defaults were provided. 2517 * 2518 * You reset to a specific form state by passing in a map of states 2519 * that matches the structure of your form, with control names as keys. The state 2520 * is a standalone value or a form state object with both a value and a disabled 2521 * status. 2522 * 2523 * @param value Resets the control with an initial value, 2524 * or an object that defines the initial value and disabled state. 2525 * 2526 * @param options Configuration options that determine how the control propagates changes 2527 * and emits events when the group is reset. 2528 * * `onlySelf`: When true, each change only affects this control, and not its parent. Default is 2529 * false. 2530 * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and 2531 * `valueChanges` 2532 * observables emit events with the latest status and value when the control is reset. 2533 * When false, no events are emitted. 2534 * The configuration options are passed to the {@link AbstractControl#updateValueAndValidity 2535 * updateValueAndValidity} method. 2536 * 2537 * @usageNotes 2538 * 2539 * ### Reset the form group values 2540 * 2541 * ```ts 2542 * const form = new FormGroup({ 2543 * first: new FormControl('first name'), 2544 * last: new FormControl('last name') 2545 * }); 2546 * 2547 * console.log(form.value); // {first: 'first name', last: 'last name'} 2548 * 2549 * form.reset({ first: 'name', last: 'last name' }); 2550 * 2551 * console.log(form.value); // {first: 'name', last: 'last name'} 2552 * ``` 2553 * 2554 * ### Reset the form group values and disabled status 2555 * 2556 * ```ts 2557 * const form = new FormGroup({ 2558 * first: new FormControl('first name'), 2559 * last: new FormControl('last name') 2560 * }); 2561 * 2562 * form.reset({ 2563 * first: {value: 'name', disabled: true}, 2564 * last: 'last' 2565 * }); 2566 * 2567 * console.log(form.value); // {last: 'last'} 2568 * console.log(form.get('first').status); // 'DISABLED' 2569 * ``` 2570 */ 2571 reset(value = {}, options = {}) { 2572 this._forEachChild((control, name) => { 2573 control.reset(value ? value[name] : null, { 2574 onlySelf: true, 2575 emitEvent: options.emitEvent 2576 }); 2577 }); 2578 this._updatePristine(options, this); 2579 this._updateTouched(options, this); 2580 this.updateValueAndValidity(options); 2581 } 2582 /** 2583 * The aggregate value of the `FormGroup`, including any disabled controls. 2584 * 2585 * Retrieves all values regardless of disabled status. 2586 */ 2587 getRawValue() { 2588 return this._reduceChildren({}, (acc, control, name) => { 2589 acc[name] = control.getRawValue(); 2590 return acc; 2591 }); 2592 } 2593 /** @internal */ 2594 _syncPendingControls() { 2595 let subtreeUpdated = this._reduceChildren(false, (updated, child) => { 2596 return child._syncPendingControls() ? true : updated; 2597 }); 2598 if (subtreeUpdated) this.updateValueAndValidity({ 2599 onlySelf: true 2600 }); 2601 return subtreeUpdated; 2602 } 2603 /** @internal */ 2604 _forEachChild(cb) { 2605 Object.keys(this.controls).forEach((key) => { 2606 const control = this.controls[key]; 2607 control && cb(control, key); 2608 }); 2609 } 2610 /** @internal */ 2611 _setUpControls() { 2612 this._forEachChild((control) => { 2613 control.setParent(this); 2614 control._registerOnCollectionChange(this._onCollectionChange); 2615 }); 2616 } 2617 /** @internal */ 2618 _updateValue() { 2619 this.value = this._reduceValue(); 2620 } 2621 /** @internal */ 2622 _anyControls(condition) { 2623 for (const [controlName, control] of Object.entries(this.controls)) { 2624 if (this.contains(controlName) && condition(control)) { 2625 return true; 2626 } 2627 } 2628 return false; 2629 } 2630 /** @internal */ 2631 _reduceValue() { 2632 let acc = {}; 2633 return this._reduceChildren(acc, (acc2, control, name) => { 2634 if (control.enabled || this.disabled) { 2635 acc2[name] = control.value; 2636 } 2637 return acc2; 2638 }); 2639 } 2640 /** @internal */ 2641 _reduceChildren(initValue, fn) { 2642 let res = initValue; 2643 this._forEachChild((control, name) => { 2644 res = fn(res, control, name); 2645 }); 2646 return res; 2647 } 2648 /** @internal */ 2649 _allControlsDisabled() { 2650 for (const controlName of Object.keys(this.controls)) { 2651 if (this.controls[controlName].enabled) { 2652 return false; 2653 } 2654 } 2655 return Object.keys(this.controls).length > 0 || this.disabled; 2656 } 2657 /** @internal */ 2658 _find(name) { 2659 return this.controls.hasOwnProperty(name) ? this.controls[name] : null; 2660 } 2661}; 2662function validateFormGroupControls(controls) { 2663 const invalidKeys = Object.keys(controls).filter((key) => key.includes(".")); 2664 if (invalidKeys.length > 0) { 2665 console.warn(`FormGroup keys cannot include \`.\`, please replace the keys for: ${invalidKeys.join(",")}.`); 2666 } 2667} 2668var FormRecord = class extends FormGroup { 2669}; 2670var CALL_SET_DISABLED_STATE = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "CallSetDisabledState" : "", { 2671 providedIn: "root", 2672 factory: () => setDisabledStateDefault 2673}); 2674var setDisabledStateDefault = "always"; 2675function controlPath(name, parent) { 2676 return [...parent.path, name]; 2677} 2678function setUpControl(control, dir, callSetDisabledState = setDisabledStateDefault) { 2679 if (typeof ngDevMode === "undefined" || ngDevMode) { 2680 if (!control) _throwError(dir, "Cannot find control with"); 2681 if (!dir.valueAccessor) _throwMissingValueAccessorError(dir); 2682 } 2683 setUpValidators(control, dir); 2684 dir.valueAccessor.writeValue(control.value); 2685 if (control.disabled || callSetDisabledState === "always") { 2686 dir.valueAccessor.setDisabledState?.(control.disabled); 2687 } 2688 setUpViewChangePipeline(control, dir); 2689 setUpModelChangePipeline(control, dir); 2690 setUpBlurPipeline(control, dir); 2691 setUpDisabledChangeHandler(control, dir); 2692} 2693function cleanUpControl(control, dir, validateControlPresenceOnChange = true) { 2694 const noop = () => { 2695 if (validateControlPresenceOnChange && (typeof ngDevMode === "undefined" || ngDevMode)) { 2696 _noControlError(dir); 2697 } 2698 }; 2699 if (dir.valueAccessor) { 2700 dir.valueAccessor.registerOnChange(noop); 2701 dir.valueAccessor.registerOnTouched(noop); 2702 } 2703 cleanUpValidators(control, dir); 2704 if (control) { 2705 dir._invokeOnDestroyCallbacks(); 2706 control._registerOnCollectionChange(() => { 2707 }); 2708 } 2709} 2710function registerOnValidatorChange(validators, onChange) { 2711 validators.forEach((validator) => { 2712 if (validator.registerOnValidatorChange) validator.registerOnValidatorChange(onChange); 2713 }); 2714} 2715function setUpDisabledChangeHandler(control, dir) { 2716 if (dir.valueAccessor.setDisabledState) { 2717 const onDisabledChange = (isDisabled) => { 2718 dir.valueAccessor.setDisabledState(isDisabled); 2719 }; 2720 control.registerOnDisabledChange(onDisabledChange); 2721 dir._registerOnDestroy(() => { 2722 control._unregisterOnDisabledChange(onDisabledChange); 2723 }); 2724 } 2725} 2726function setUpValidators(control, dir) { 2727 const validators = getControlValidators(control); 2728 if (dir.validator !== null) { 2729 control.setValidators(mergeValidators(validators, dir.validator)); 2730 } else if (typeof validators === "function") { 2731 control.setValidators([validators]); 2732 } 2733 const asyncValidators = getControlAsyncValidators(control); 2734 if (dir.asyncValidator !== null) { 2735 control.setAsyncValidators(mergeValidators(asyncValidators, dir.asyncValidator)); 2736 } else if (typeof asyncValidators === "function") { 2737 control.setAsyncValidators([asyncValidators]); 2738 } 2739 const onValidatorChange = () => control.updateValueAndValidity(); 2740 registerOnValidatorChange(dir._rawValidators, onValidatorChange); 2741 registerOnValidatorChange(dir._rawAsyncValidators, onValidatorChange); 2742} 2743function cleanUpValidators(control, dir) { 2744 let isControlUpdated = false; 2745 if (control !== null) { 2746 if (dir.validator !== null) { 2747 const validators = getControlValidators(control); 2748 if (Array.isArray(validators) && validators.length > 0) { 2749 const updatedValidators = validators.filter((validator) => validator !== dir.validator); 2750 if (updatedValidators.length !== validators.length) { 2751 isControlUpdated = true; 2752 control.setValidators(updatedValidators); 2753 } 2754 } 2755 } 2756 if (dir.asyncValidator !== null) { 2757 const asyncValidators = getControlAsyncValidators(control); 2758 if (Array.isArray(asyncValidators) && asyncValidators.length > 0) { 2759 const updatedAsyncValidators = asyncValidators.filter((asyncValidator) => asyncValidator !== dir.asyncValidator); 2760 if (updatedAsyncValidators.length !== asyncValidators.length) { 2761 isControlUpdated = true; 2762 control.setAsyncValidators(updatedAsyncValidators); 2763 } 2764 } 2765 } 2766 } 2767 const noop = () => { 2768 }; 2769 registerOnValidatorChange(dir._rawValidators, noop); 2770 registerOnValidatorChange(dir._rawAsyncValidators, noop); 2771 return isControlUpdated; 2772} 2773function setUpViewChangePipeline(control, dir) { 2774 dir.valueAccessor.registerOnChange((newValue) => { 2775 control._pendingValue = newValue; 2776 control._pendingChange = true; 2777 control._pendingDirty = true; 2778 if (control.updateOn === "change") updateControl(control, dir); 2779 }); 2780} 2781function setUpBlurPipeline(control, dir) { 2782 dir.valueAccessor.registerOnTouched(() => { 2783 control._pendingTouched = true; 2784 if (control.updateOn === "blur" && control._pendingChange) updateControl(control, dir); 2785 if (control.updateOn !== "submit") control.markAsTouched(); 2786 }); 2787} 2788function updateControl(control, dir) { 2789 if (control._pendingDirty) control.markAsDirty(); 2790 control.setValue(control._pendingValue, { 2791 emitModelToViewChange: false 2792 }); 2793 dir.viewToModelUpdate(control._pendingValue); 2794 control._pendingChange = false; 2795} 2796function setUpModelChangePipeline(control, dir) { 2797 const onChange = (newValue, emitModelEvent) => { 2798 dir.valueAccessor.writeValue(newValue); 2799 if (emitModelEvent) dir.viewToModelUpdate(newValue); 2800 }; 2801 control.registerOnChange(onChange); 2802 dir._registerOnDestroy(() => { 2803 control._unregisterOnChange(onChange); 2804 }); 2805} 2806function setUpFormContainer(control, dir) { 2807 if (control == null && (typeof ngDevMode === "undefined" || ngDevMode)) _throwError(dir, "Cannot find control with"); 2808 setUpValidators(control, dir); 2809} 2810function cleanUpFormContainer(control, dir) { 2811 return cleanUpValidators(control, dir); 2812} 2813function _noControlError(dir) { 2814 return _throwError(dir, "There is no FormControl instance attached to form control element with"); 2815} 2816function _throwError(dir, message) { 2817 const messageEnd = _describeControlLocation(dir); 2818 throw new Error(`${message} ${messageEnd}`); 2819} 2820function _describeControlLocation(dir) { 2821 const path = dir.path; 2822 if (path && path.length > 1) return `path: '${path.join(" -> ")}'`; 2823 if (path?.[0]) return `name: '${path}'`; 2824 return "unspecified name attribute"; 2825} 2826function _throwMissingValueAccessorError(dir) { 2827 const loc = _describeControlLocation(dir); 2828 throw new RuntimeError(-1203, `No value accessor for form control ${loc}.`); 2829} 2830function _throwInvalidValueAccessorError(dir) { 2831 const loc = _describeControlLocation(dir); 2832 throw new RuntimeError(1200, `Value accessor was not provided as an array for form control with ${loc}. Check that the \`NG_VALUE_ACCESSOR\` token is configured as a \`multi: true\` provider.`); 2833} 2834function isPropertyUpdated(changes, viewModel) { 2835 if (!changes.hasOwnProperty("model")) return false; 2836 const change = changes["model"]; 2837 if (change.isFirstChange()) return true; 2838 return !Object.is(viewModel, change.currentValue); 2839} 2840function isBuiltInAccessor(valueAccessor) { 2841 return Object.getPrototypeOf(valueAccessor.constructor) === BuiltInControlValueAccessor; 2842} 2843function syncPendingControls(form, directives) { 2844 form._syncPendingControls(); 2845 directives.forEach((dir) => { 2846 const control = dir.control; 2847 if (control.updateOn === "submit" && control._pendingChange) { 2848 dir.viewToModelUpdate(control._pendingValue); 2849 control._pendingChange = false; 2850 } 2851 }); 2852} 2853function selectValueAccessor(dir, valueAccessors) { 2854 if (!valueAccessors) return null; 2855 if (!Array.isArray(valueAccessors) && (typeof ngDevMode === "undefined" || ngDevMode)) _throwInvalidValueAccessorError(dir); 2856 let defaultAccessor = void 0; 2857 let builtinAccessor = void 0; 2858 let customAccessor = void 0; 2859 valueAccessors.forEach((v) => { 2860 if (v.constructor === DefaultValueAccessor) { 2861 defaultAccessor = v; 2862 } else if (isBuiltInAccessor(v)) { 2863 if (builtinAccessor && (typeof ngDevMode === "undefined" || ngDevMode)) _throwError(dir, "More than one built-in value accessor matches form control with"); 2864 builtinAccessor = v; 2865 } else { 2866 if (customAccessor && (typeof ngDevMode === "undefined" || ngDevMode)) _throwError(dir, "More than one custom value accessor matches form control with"); 2867 customAccessor = v; 2868 } 2869 }); 2870 if (customAccessor) return customAccessor; 2871 if (builtinAccessor) return builtinAccessor; 2872 if (defaultAccessor) return defaultAccessor; 2873 if (typeof ngDevMode === "undefined" || ngDevMode) { 2874 _throwError(dir, "No valid value accessor for form control with"); 2875 } 2876 return null; 2877} 2878function removeListItem$1(list, el) { 2879 const index = list.indexOf(el); 2880 if (index > -1) list.splice(index, 1); 2881} 2882function _ngModelWarning(name, type, instance, warningConfig) { 2883 if (warningConfig === "never") return; 2884 if ((warningConfig === null || warningConfig === "once") && !type._ngModelWarningSentOnce || warningConfig === "always" && !instance._ngModelWarningSent) { 2885 console.warn(ngModelWarning(name)); 2886 type._ngModelWarningSentOnce = true; 2887 instance._ngModelWarningSent = true; 2888 } 2889} 2890var formDirectiveProvider$1 = { 2891 provide: ControlContainer, 2892 useExisting: forwardRef(() => NgForm) 2893}; 2894var resolvedPromise$1 = (() => Promise.resolve())(); 2895var NgForm = class _NgForm extends ControlContainer { 2896 callSetDisabledState; 2897 /** 2898 * @description 2899 * Returns whether the form submission has been triggered. 2900 */ 2901 get submitted() { 2902 return untracked(this.submittedReactive); 2903 } 2904 /** @internal */ 2905 _submitted = computed(() => this.submittedReactive()); 2906 submittedReactive = signal(false); 2907 _directives = /* @__PURE__ */ new Set(); 2908 /** 2909 * @description 2910 * The `FormGroup` instance created for this form. 2911 */ 2912 form; 2913 /** 2914 * @description 2915 * Event emitter for the "ngSubmit" event 2916 */ 2917 ngSubmit = new EventEmitter(); 2918 /** 2919 * @description 2920 * Tracks options for the `NgForm` instance. 2921 * 2922 * **updateOn**: Sets the default `updateOn` value for all child `NgModels` below it 2923 * unless explicitly set by a child `NgModel` using `ngModelOptions`). Defaults to 'change'. 2924 * Possible values: `'change'` | `'blur'` | `'submit'`. 2925 * 2926 */ 2927
vendor: 4,653 bytes, lines 2927-3099
2927options; 2928 constructor(validators, asyncValidators, callSetDisabledState) { 2929 super(); 2930 this.callSetDisabledState = callSetDisabledState; 2931 this.form = new FormGroup({}, composeValidators(validators), composeAsyncValidators(asyncValidators)); 2932 } 2933 /** @docs-private */ 2934 ngAfterViewInit() { 2935 this._setUpdateStrategy(); 2936 } 2937 /** 2938 * @description 2939 * The directive instance. 2940 */ 2941 get formDirective() { 2942 return this; 2943 } 2944 /** 2945 * @description 2946 * The internal `FormGroup` instance. 2947 */ 2948 get control() { 2949 return this.form; 2950 } 2951 /** 2952 * @description 2953 * Returns an array representing the path to this group. Because this directive 2954 * always lives at the top level of a form, it is always an empty array. 2955 */ 2956 get path() { 2957 return []; 2958 } 2959 /** 2960 * @description 2961 * Returns a map of the controls in this group. 2962 */ 2963 get controls() { 2964 return this.form.controls; 2965 } 2966 /** 2967 * @description 2968 * Method that sets up the control directive in this group, re-calculates its value 2969 * and validity, and adds the instance to the internal list of directives. 2970 * 2971 * @param dir The `NgModel` directive instance. 2972 */ 2973 addControl(dir) { 2974 resolvedPromise$1.then(() => { 2975 const container = this._findContainer(dir.path); 2976 dir.control = container.registerControl(dir.name, dir.control); 2977 setUpControl(dir.control, dir, this.callSetDisabledState); 2978 dir.control.updateValueAndValidity({ 2979 emitEvent: false 2980 }); 2981 this._directives.add(dir); 2982 }); 2983 } 2984 /** 2985 * @description 2986 * Retrieves the `FormControl` instance from the provided `NgModel` directive. 2987 * 2988 * @param dir The `NgModel` directive instance. 2989 */ 2990 getControl(dir) { 2991 return this.form.get(dir.path); 2992 } 2993 /** 2994 * @description 2995 * Removes the `NgModel` instance from the internal list of directives 2996 * 2997 * @param dir The `NgModel` directive instance. 2998 */ 2999 removeControl(dir) { 3000 resolvedPromise$1.then(() => { 3001 const container = this._findContainer(dir.path); 3002 if (container) { 3003 container.removeControl(dir.name); 3004 } 3005 this._directives.delete(dir); 3006 }); 3007 } 3008 /** 3009 * @description 3010 * Adds a new `NgModelGroup` directive instance to the form. 3011 * 3012 * @param dir The `NgModelGroup` directive instance. 3013 */ 3014 addFormGroup(dir) { 3015 resolvedPromise$1.then(() => { 3016 const container = this._findContainer(dir.path); 3017 const group = new FormGroup({}); 3018 setUpFormContainer(group, dir); 3019 container.registerControl(dir.name, group); 3020 group.updateValueAndValidity({ 3021 emitEvent: false 3022 }); 3023 }); 3024 } 3025 /** 3026 * @description 3027 * Removes the `NgModelGroup` directive instance from the form. 3028 * 3029 * @param dir The `NgModelGroup` directive instance. 3030 */ 3031 removeFormGroup(dir) { 3032 resolvedPromise$1.then(() => { 3033 const container = this._findContainer(dir.path); 3034 if (container) { 3035 container.removeControl(dir.name); 3036 } 3037 }); 3038 } 3039 /** 3040 * @description 3041 * Retrieves the `FormGroup` for a provided `NgModelGroup` directive instance 3042 * 3043 * @param dir The `NgModelGroup` directive instance. 3044 */ 3045 getFormGroup(dir) { 3046 return this.form.get(dir.path); 3047 } 3048 /** 3049 * Sets the new value for the provided `NgControl` directive. 3050 * 3051 * @param dir The `NgControl` directive instance. 3052 * @param value The new value for the directive's control. 3053 */ 3054 updateModel(dir, value) { 3055 resolvedPromise$1.then(() => { 3056 const ctrl = this.form.get(dir.path); 3057 ctrl.setValue(value); 3058 }); 3059 } 3060 /** 3061 * @description 3062 * Sets the value for this `FormGroup`. 3063 * 3064 * @param value The new value 3065 */ 3066 setValue(value) { 3067 this.control.setValue(value); 3068 } 3069 /** 3070 * @description 3071 * Method called when the "submit" event is triggered on the form. 3072 * Triggers the `ngSubmit` emitter to emit the "submit" event as its payload. 3073 * 3074 * @param $event The "submit" event object 3075 */ 3076 onSubmit($event) { 3077 this.submittedReactive.set(true); 3078 syncPendingControls(this.form, this._directives); 3079 this.ngSubmit.emit($event); 3080 this.form._events.next(new FormSubmittedEvent(this.control)); 3081 return $event?.target?.method === "dialog"; 3082 } 3083 /** 3084 * @description 3085 * Method called when the "reset" event is triggered on the form. 3086 */ 3087 onReset() { 3088 this.resetForm(); 3089 } 3090 /** 3091 * @description 3092 * Resets the form to an initial value and resets its submitted status. 3093 * 3094 * @param value The new value for the form. 3095 */ 3096 resetForm(value = void 0) { 3097 this.form.reset(value); 3098 this.submittedReactive.set(false); 3099 this.form._events.next(new FormResetEvent(this.form)
vendor: 6,015 bytes, lines 3099-3305
3099); 3100 } 3101 _setUpdateStrategy() { 3102 if (this.options && this.options.updateOn != null) { 3103 this.form._updateOn = this.options.updateOn; 3104 } 3105 } 3106 _findContainer(path) { 3107 path.pop(); 3108 return path.length ? this.form.get(path) : this.form; 3109 } 3110 static \u0275fac = function NgForm_Factory(__ngFactoryType__) { 3111 return new (__ngFactoryType__ || _NgForm)(\u0275\u0275directiveInject(NG_VALIDATORS, 10), \u0275\u0275directiveInject(NG_ASYNC_VALIDATORS, 10), \u0275\u0275directiveInject(CALL_SET_DISABLED_STATE, 8)); 3112 }; 3113 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 3114 type: _NgForm, 3115 selectors: [["form", 3, "ngNoForm", "", 3, "formGroup", ""], ["ng-form"], ["", "ngForm", ""]], 3116 hostBindings: function NgForm_HostBindings(rf, ctx) { 3117 if (rf & 1) { 3118 \u0275\u0275listener("submit", function NgForm_submit_HostBindingHandler($event) { 3119 return ctx.onSubmit($event); 3120 })("reset", function NgForm_reset_HostBindingHandler() { 3121 return ctx.onReset(); 3122 }); 3123 } 3124 }, 3125 inputs: { 3126 options: [0, "ngFormOptions", "options"] 3127 }, 3128 outputs: { 3129 ngSubmit: "ngSubmit" 3130 }, 3131 exportAs: ["ngForm"], 3132 standalone: false, 3133 features: [\u0275\u0275ProvidersFeature([formDirectiveProvider$1]), \u0275\u0275InheritDefinitionFeature] 3134 }); 3135}; 3136(() => { 3137 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(NgForm, [{ 3138 type: Directive, 3139 args: [{ 3140 selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", 3141 providers: [formDirectiveProvider$1], 3142 host: { 3143 "(submit)": "onSubmit($event)", 3144 "(reset)": "onReset()" 3145 }, 3146 outputs: ["ngSubmit"], 3147 exportAs: "ngForm", 3148 standalone: false 3149 }] 3150 }], () => [{ 3151 type: void 0, 3152 decorators: [{ 3153 type: Optional 3154 }, { 3155 type: Self 3156 }, { 3157 type: Inject, 3158 args: [NG_VALIDATORS] 3159 }] 3160 }, { 3161 type: void 0, 3162 decorators: [{ 3163 type: Optional 3164 }, { 3165 type: Self 3166 }, { 3167 type: Inject, 3168 args: [NG_ASYNC_VALIDATORS] 3169 }] 3170 }, { 3171 type: void 0, 3172 decorators: [{ 3173 type: Optional 3174 }, { 3175 type: Inject, 3176 args: [CALL_SET_DISABLED_STATE] 3177 }] 3178 }], { 3179 options: [{ 3180 type: Input, 3181 args: ["ngFormOptions"] 3182 }] 3183 }); 3184})(); 3185function removeListItem(list, el) { 3186 const index = list.indexOf(el); 3187 if (index > -1) list.splice(index, 1); 3188} 3189function isFormControlState(formState) { 3190 return typeof formState === "object" && formState !== null && Object.keys(formState).length === 2 && "value" in formState && "disabled" in formState; 3191} 3192var FormControl = class FormControl2 extends AbstractControl { 3193 /** @publicApi */ 3194 defaultValue = null; 3195 /** @internal */ 3196 _onChange = []; 3197 /** @internal */ 3198 _pendingValue; 3199 /** @internal */ 3200 _pendingChange = false; 3201 constructor(formState = null, validatorOrOpts, asyncValidator) { 3202 super(pickValidators(validatorOrOpts), pickAsyncValidators(asyncValidator, validatorOrOpts)); 3203 this._applyFormState(formState); 3204 this._setUpdateStrategy(validatorOrOpts); 3205 this._initObservables(); 3206 this.updateValueAndValidity({ 3207 onlySelf: true, 3208 // If `asyncValidator` is present, it will trigger control status change from `PENDING` to 3209 // `VALID` or `INVALID`. 3210 // The status should be broadcasted via the `statusChanges` observable, so we set 3211 // `emitEvent` to `true` to allow that during the control creation process. 3212 emitEvent: !!this.asyncValidator 3213 }); 3214 if (isOptionsObj(validatorOrOpts) && (validatorOrOpts.nonNullable || validatorOrOpts.initialValueIsDefault)) { 3215 if (isFormControlState(formState)) { 3216 this.defaultValue = formState.value; 3217 } else { 3218 this.defaultValue = formState; 3219 } 3220 } 3221 } 3222 setValue(value, options = {}) { 3223 this.value = this._pendingValue = value; 3224 if (this._onChange.length && options.emitModelToViewChange !== false) { 3225 this._onChange.forEach((changeFn) => changeFn(this.value, options.emitViewToModelChange !== false)); 3226 } 3227 this.updateValueAndValidity(options); 3228 } 3229 patchValue(value, options = {}) { 3230 this.setValue(value, options); 3231 } 3232 reset(formState = this.defaultValue, options = {}) { 3233 this._applyFormState(formState); 3234 this.markAsPristine(options); 3235 this.markAsUntouched(options); 3236 this.setValue(this.value, options); 3237 this._pendingChange = false; 3238 } 3239 /** @internal */ 3240 _updateValue() { 3241 } 3242 /** @internal */ 3243 _anyControls(condition) { 3244 return false; 3245 } 3246 /** @internal */ 3247 _allControlsDisabled() { 3248 return this.disabled; 3249 } 3250 registerOnChange(fn) { 3251 this._onChange.push(fn); 3252 } 3253 /** @internal */ 3254 _unregisterOnChange(fn) { 3255 removeListItem(this._onChange, fn); 3256 } 3257 registerOnDisabledChange(fn) { 3258 this._onDisabledChange.push(fn); 3259 } 3260 /** @internal */ 3261 _unregisterOnDisabledChange(fn) { 3262 removeListItem(this._onDisabledChange, fn); 3263 } 3264 /** @internal */ 3265 _forEachChild(cb) { 3266 } 3267 /** @internal */ 3268 _syncPendingControls() { 3269 if (this.updateOn === "submit") { 3270 if (this._pendingDirty) this.markAsDirty(); 3271 if (this._pendingTouched) this.markAsTouched(); 3272 if (this._pendingChange) { 3273 this.setValue(this._pendingValue, { 3274 onlySelf: true, 3275 emitModelToViewChange: false 3276 }); 3277 return true; 3278 } 3279 } 3280 return false; 3281 } 3282 _applyFormState(formState) { 3283 if (isFormControlState(formState)) { 3284 this.value = this._pendingValue = formState.value; 3285 formState.disabled ? this.disable({ 3286 onlySelf: true, 3287 emitEvent: false 3288 }) : this.enable({ 3289 onlySelf: true, 3290 emitEvent: false 3291 }); 3292 } else { 3293 this.value = this._pendingValue = formState; 3294 } 3295 } 3296}; 3297var isFormControl = (control) => control instanceof FormControl; 3298var AbstractFormGroupDirective = class _AbstractFormGroupDirective extends ControlContainer { 3299 /** 3300 * @description 3301 * The parent control for the group 3302 * 3303 * @internal 3304 */ 3305
vendor: 10,309 bytes, lines 3305-3633
3305_parent; 3306 /** @docs-private */ 3307 ngOnInit() { 3308 this._checkParentType(); 3309 this.formDirective.addFormGroup(this); 3310 } 3311 /** @docs-private */ 3312 ngOnDestroy() { 3313 if (this.formDirective) { 3314 this.formDirective.removeFormGroup(this); 3315 } 3316 } 3317 /** 3318 * @description 3319 * The `FormGroup` bound to this directive. 3320 */ 3321 get control() { 3322 return this.formDirective.getFormGroup(this); 3323 } 3324 /** 3325 * @description 3326 * The path to this group from the top-level directive. 3327 */ 3328 get path() { 3329 return controlPath(this.name == null ? this.name : this.name.toString(), this._parent); 3330 } 3331 /** 3332 * @description 3333 * The top-level directive for this group if present, otherwise null. 3334 */ 3335 get formDirective() { 3336 return this._parent ? this._parent.formDirective : null; 3337 } 3338 /** @internal */ 3339 _checkParentType() { 3340 } 3341 static \u0275fac = /* @__PURE__ */ (() => { 3342 let \u0275AbstractFormGroupDirective_BaseFactory; 3343 return function AbstractFormGroupDirective_Factory(__ngFactoryType__) { 3344 return (\u0275AbstractFormGroupDirective_BaseFactory || (\u0275AbstractFormGroupDirective_BaseFactory = \u0275\u0275getInheritedFactory(_AbstractFormGroupDirective)))(__ngFactoryType__ || _AbstractFormGroupDirective); 3345 }; 3346 })(); 3347 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 3348 type: _AbstractFormGroupDirective, 3349 standalone: false, 3350 features: [\u0275\u0275InheritDefinitionFeature] 3351 }); 3352}; 3353(() => { 3354 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(AbstractFormGroupDirective, [{ 3355 type: Directive, 3356 args: [{ 3357 standalone: false 3358 }] 3359 }], null, null); 3360})(); 3361function modelParentException() { 3362 return new RuntimeError(1350, ` 3363 ngModel cannot be used to register form controls with a parent formGroup directive. Try using 3364 formGroup's partner directive "formControlName" instead. Example: 3365 3366 ${formControlNameExample} 3367 3368 Or, if you'd like to avoid registering this form control, indicate that it's standalone in ngModelOptions: 3369 3370 Example: 3371 3372 ${ngModelWithFormGroupExample}`); 3373} 3374function formGroupNameException() { 3375 return new RuntimeError(1351, ` 3376 ngModel cannot be used to register form controls with a parent formGroupName or formArrayName directive. 3377 3378 Option 1: Use formControlName instead of ngModel (reactive strategy): 3379 3380 ${formGroupNameExample} 3381 3382 Option 2: Update ngModel's parent be ngModelGroup (template-driven strategy): 3383 3384 ${ngModelGroupExample}`); 3385} 3386function missingNameException() { 3387 return new RuntimeError(1352, `If ngModel is used within a form tag, either the name attribute must be set or the form 3388 control must be defined as 'standalone' in ngModelOptions. 3389 3390 Example 1: <input [(ngModel)]="person.firstName" name="first"> 3391 Example 2: <input [(ngModel)]="person.firstName" [ngModelOptions]="{standalone: true}">`); 3392} 3393function modelGroupParentException() { 3394 return new RuntimeError(1353, ` 3395 ngModelGroup cannot be used with a parent formGroup directive. 3396 3397 Option 1: Use formGroupName instead of ngModelGroup (reactive strategy): 3398 3399 ${formGroupNameExample} 3400 3401 Option 2: Use a regular form tag instead of the formGroup directive (template-driven strategy): 3402 3403 ${ngModelGroupExample}`); 3404} 3405var modelGroupProvider = { 3406 provide: ControlContainer, 3407 useExisting: forwardRef(() => NgModelGroup) 3408}; 3409var NgModelGroup = class _NgModelGroup extends AbstractFormGroupDirective { 3410 /** 3411 * @description 3412 * Tracks the name of the `NgModelGroup` bound to the directive. The name corresponds 3413 * to a key in the parent `NgForm`. 3414 */ 3415 name = ""; 3416 constructor(parent, validators, asyncValidators) { 3417 super(); 3418 this._parent = parent; 3419 this._setValidators(validators); 3420 this._setAsyncValidators(asyncValidators); 3421 } 3422 /** @internal */ 3423 _checkParentType() { 3424 if (!(this._parent instanceof _NgModelGroup) && !(this._parent instanceof NgForm) && (typeof ngDevMode === "undefined" || ngDevMode)) { 3425 throw modelGroupParentException(); 3426 } 3427 } 3428 static \u0275fac = function NgModelGroup_Factory(__ngFactoryType__) { 3429 return new (__ngFactoryType__ || _NgModelGroup)(\u0275\u0275directiveInject(ControlContainer, 5), \u0275\u0275directiveInject(NG_VALIDATORS, 10), \u0275\u0275directiveInject(NG_ASYNC_VALIDATORS, 10)); 3430 }; 3431 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 3432 type: _NgModelGroup, 3433 selectors: [["", "ngModelGroup", ""]], 3434 inputs: { 3435 name: [0, "ngModelGroup", "name"] 3436 }, 3437 exportAs: ["ngModelGroup"], 3438 standalone: false, 3439 features: [\u0275\u0275ProvidersFeature([modelGroupProvider]), \u0275\u0275InheritDefinitionFeature] 3440 }); 3441}; 3442(() => { 3443 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(NgModelGroup, [{ 3444 type: Directive, 3445 args: [{ 3446 selector: "[ngModelGroup]", 3447 providers: [modelGroupProvider], 3448 exportAs: "ngModelGroup", 3449 standalone: false 3450 }] 3451 }], () => [{ 3452 type: ControlContainer, 3453 decorators: [{ 3454 type: Host 3455 }, { 3456 type: SkipSelf 3457 }] 3458 }, { 3459 type: void 0, 3460 decorators: [{ 3461 type: Optional 3462 }, { 3463 type: Self 3464 }, { 3465 type: Inject, 3466 args: [NG_VALIDATORS] 3467 }] 3468 }, { 3469 type: void 0, 3470 decorators: [{ 3471 type: Optional 3472 }, { 3473 type: Self 3474 }, { 3475 type: Inject, 3476 args: [NG_ASYNC_VALIDATORS] 3477 }] 3478 }], { 3479 name: [{ 3480 type: Input, 3481 args: ["ngModelGroup"] 3482 }] 3483 }); 3484})(); 3485var formControlBinding$1 = { 3486 provide: NgControl, 3487 useExisting: forwardRef(() => NgModel) 3488}; 3489var resolvedPromise = (() => Promise.resolve())(); 3490var NgModel = class _NgModel extends NgControl { 3491 _changeDetectorRef; 3492 callSetDisabledState; 3493 control = new FormControl(); 3494 // At runtime we coerce arbitrary values assigned to the "disabled" input to a "boolean". 3495 // This is not reflected in the type of the property because outside of templates, consumers 3496 // should only deal with booleans. In templates, a string is allowed for convenience and to 3497 // match the native "disabled attribute" semantics which can be observed on input elements. 3498 // This static member tells the compiler that values of type "string" can also be assigned 3499 // to the input in a template. 3500 /** @docs-private */ 3501 static ngAcceptInputType_isDisabled; 3502 /** @internal */ 3503 _registered = false; 3504 /** 3505 * Internal reference to the view model value. 3506 * @docs-private 3507 */ 3508 viewModel; 3509 /** 3510 * @description 3511 * Tracks the name bound to the directive. If a parent form exists, it 3512 * uses this name as a key to retrieve this control's value. 3513 */ 3514 name = ""; 3515 /** 3516 * @description 3517 * Tracks whether the control is disabled. 3518 */ 3519 isDisabled; 3520 /** 3521 * @description 3522 * Tracks the value bound to this directive. 3523 */ 3524 model; 3525 /** 3526 * @description 3527 * Tracks the configuration options for this `ngModel` instance. 3528 * 3529 * **name**: An alternative to setting the name attribute on the form control element. See 3530 * the [example](api/forms/NgModel#using-ngmodel-on-a-standalone-control) for using `NgModel` 3531 * as a standalone control. 3532 * 3533 * **standalone**: When set to true, the `ngModel` will not register itself with its parent form, 3534 * and acts as if it's not in the form. Defaults to false. If no parent form exists, this option 3535 * has no effect. 3536 * 3537 * **updateOn**: Defines the event upon which the form control value and validity update. 3538 * Defaults to 'change'. Possible values: `'change'` | `'blur'` | `'submit'`. 3539 * 3540 */ 3541 options; 3542 /** 3543 * @description 3544 * Event emitter for producing the `ngModelChange` event after 3545 * the view model updates. 3546 */ 3547 update = new EventEmitter(); 3548 constructor(parent, validators, asyncValidators, valueAccessors, _changeDetectorRef, callSetDisabledState) { 3549 super(); 3550 this._changeDetectorRef = _changeDetectorRef; 3551 this.callSetDisabledState = callSetDisabledState; 3552 this._parent = parent; 3553 this._setValidators(validators); 3554 this._setAsyncValidators(asyncValidators); 3555 this.valueAccessor = selectValueAccessor(this, valueAccessors); 3556 } 3557 /** @docs-private */ 3558 ngOnChanges(changes) { 3559 this._checkForErrors(); 3560 if (!this._registered || "name" in changes) { 3561 if (this._registered) { 3562 this._checkName(); 3563 if (this.formDirective) { 3564 const oldName = changes["name"].previousValue; 3565 this.formDirective.removeControl({ 3566 name: oldName, 3567 path: this._getPath(oldName) 3568 }); 3569 } 3570 } 3571 this._setUpControl(); 3572 } 3573 if ("isDisabled" in changes) { 3574 this._updateDisabled(changes); 3575 } 3576 if (isPropertyUpdated(changes, this.viewModel)) { 3577 this._updateValue(this.model); 3578 this.viewModel = this.model; 3579 } 3580 } 3581 /** @docs-private */ 3582 ngOnDestroy() { 3583 this.formDirective && this.formDirective.removeControl(this); 3584 } 3585 /** 3586 * @description 3587 * Returns an array that represents the path from the top-level form to this control. 3588 * Each index is the string name of the control on that level. 3589 */ 3590 get path() { 3591 return this._getPath(this.name); 3592 } 3593 /** 3594 * @description 3595 * The top-level directive for this control if present, otherwise null. 3596 */ 3597 get formDirective() { 3598 return this._parent ? this._parent.formDirective : null; 3599 } 3600 /** 3601 * @description 3602 * Sets the new value for the view model and emits an `ngModelChange` event. 3603 * 3604 * @param newValue The new value emitted by `ngModelChange`. 3605 */ 3606 viewToModelUpdate(newValue) { 3607 this.viewModel = newValue; 3608 this.update.emit(newValue); 3609 } 3610 _setUpControl() { 3611 this._setUpdateStrategy(); 3612 this._isStandalone() ? this._setUpStandalone() : this.formDirective.addControl(this); 3613 this._registered = true; 3614 } 3615 _setUpdateStrategy() { 3616 if (this.options && this.options.updateOn != null) { 3617 this.control._updateOn = this.options.updateOn; 3618 } 3619 } 3620 _isStandalone() { 3621 return !this._parent || !!(this.options && this.options.standalone); 3622 } 3623 _setUpStandalone() { 3624 setUpControl(this.control, this, this.callSetDisabledState); 3625 this.control.updateValueAndValidity({ 3626 emitEvent: false 3627 }); 3628 } 3629 _checkForErrors() { 3630 if ((typeof ngDevMode === "undefined" || ngDevMode) && !this._isStandalone()) { 3631 checkParentType$1(this._parent); 3632 } 3633 this._checkName();
vendor: 3,533 bytes, lines 3633-3767
3633 3634 } 3635 _checkName() { 3636 if (this.options && this.options.name) this.name = this.options.name; 3637 if (!this._isStandalone() && !this.name && (typeof ngDevMode === "undefined" || ngDevMode)) { 3638 throw missingNameException(); 3639 } 3640 } 3641 _updateValue(value) { 3642 resolvedPromise.then(() => { 3643 this.control.setValue(value, { 3644 emitViewToModelChange: false 3645 }); 3646 this._changeDetectorRef?.markForCheck(); 3647 }); 3648 } 3649 _updateDisabled(changes) { 3650 const disabledValue = changes["isDisabled"].currentValue; 3651 const isDisabled = disabledValue !== 0 && booleanAttribute(disabledValue); 3652 resolvedPromise.then(() => { 3653 if (isDisabled && !this.control.disabled) { 3654 this.control.disable(); 3655 } else if (!isDisabled && this.control.disabled) { 3656 this.control.enable(); 3657 } 3658 this._changeDetectorRef?.markForCheck(); 3659 }); 3660 } 3661 _getPath(controlName) { 3662 return this._parent ? controlPath(controlName, this._parent) : [controlName]; 3663 } 3664 static \u0275fac = function NgModel_Factory(__ngFactoryType__) { 3665 return new (__ngFactoryType__ || _NgModel)(\u0275\u0275directiveInject(ControlContainer, 9), \u0275\u0275directiveInject(NG_VALIDATORS, 10), \u0275\u0275directiveInject(NG_ASYNC_VALIDATORS, 10), \u0275\u0275directiveInject(NG_VALUE_ACCESSOR, 10), \u0275\u0275directiveInject(ChangeDetectorRef, 8), \u0275\u0275directiveInject(CALL_SET_DISABLED_STATE, 8)); 3666 }; 3667 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 3668 type: _NgModel, 3669 selectors: [["", "ngModel", "", 3, "formControlName", "", 3, "formControl", ""]], 3670 inputs: { 3671 name: "name", 3672 isDisabled: [0, "disabled", "isDisabled"], 3673 model: [0, "ngModel", "model"], 3674 options: [0, "ngModelOptions", "options"] 3675 }, 3676 outputs: { 3677 update: "ngModelChange" 3678 }, 3679 exportAs: ["ngModel"], 3680 standalone: false, 3681 features: [\u0275\u0275ProvidersFeature([formControlBinding$1]), \u0275\u0275InheritDefinitionFeature, \u0275\u0275NgOnChangesFeature] 3682 }); 3683}; 3684(() => { 3685 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(NgModel, [{ 3686 type: Directive, 3687 args: [{ 3688 selector: "[ngModel]:not([formControlName]):not([formControl])", 3689 providers: [formControlBinding$1], 3690 exportAs: "ngModel", 3691 standalone: false 3692 }] 3693 }], () => [{ 3694 type: ControlContainer, 3695 decorators: [{ 3696 type: Optional 3697 }, { 3698 type: Host 3699 }] 3700 }, { 3701 type: void 0, 3702 decorators: [{ 3703 type: Optional 3704 }, { 3705 type: Self 3706 }, { 3707 type: Inject, 3708 args: [NG_VALIDATORS] 3709 }] 3710 }, { 3711 type: void 0, 3712 decorators: [{ 3713 type: Optional 3714 }, { 3715 type: Self 3716 }, { 3717 type: Inject, 3718 args: [NG_ASYNC_VALIDATORS] 3719 }] 3720 }, { 3721 type: void 0, 3722 decorators: [{ 3723 type: Optional 3724 }, { 3725 type: Self 3726 }, { 3727 type: Inject, 3728 args: [NG_VALUE_ACCESSOR] 3729 }] 3730 }, { 3731 type: ChangeDetectorRef, 3732 decorators: [{ 3733 type: Optional 3734 }, { 3735 type: Inject, 3736 args: [ChangeDetectorRef] 3737 }] 3738 }, { 3739 type: void 0, 3740 decorators: [{ 3741 type: Optional 3742 }, { 3743 type: Inject, 3744 args: [CALL_SET_DISABLED_STATE] 3745 }] 3746 }], { 3747 name: [{ 3748 type: Input 3749 }], 3750 isDisabled: [{ 3751 type: Input, 3752 args: ["disabled"] 3753 }], 3754 model: [{ 3755 type: Input, 3756 args: ["ngModel"] 3757 }], 3758 options: [{ 3759 type: Input, 3760 args: ["ngModelOptions"] 3761 }], 3762 update: [{ 3763 type: Output, 3764 args: ["ngModelChange"] 3765 }] 3766 }); 3767})();
vendor: 72,869 bytes, lines 3768-6063
3768function checkParentType$1(parent) { 3769 if (!(parent instanceof NgModelGroup) && parent instanceof AbstractFormGroupDirective) { 3770 throw formGroupNameException(); 3771 } else if (!(parent instanceof NgModelGroup) && !(parent instanceof NgForm)) { 3772 throw modelParentException(); 3773 } 3774} 3775var \u0275NgNoValidate = class _\u0275NgNoValidate { 3776 static \u0275fac = function \u0275NgNoValidate_Factory(__ngFactoryType__) { 3777 return new (__ngFactoryType__ || _\u0275NgNoValidate)(); 3778 }; 3779 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 3780 type: _\u0275NgNoValidate, 3781 selectors: [["form", 3, "ngNoForm", "", 3, "ngNativeValidate", ""]], 3782 hostAttrs: ["novalidate", ""], 3783 standalone: false 3784 }); 3785}; 3786(() => { 3787 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(\u0275NgNoValidate, [{ 3788 type: Directive, 3789 args: [{ 3790 selector: "form:not([ngNoForm]):not([ngNativeValidate])", 3791 host: { 3792 "novalidate": "" 3793 }, 3794 standalone: false 3795 }] 3796 }], null, null); 3797})(); 3798var NUMBER_VALUE_ACCESSOR = { 3799 provide: NG_VALUE_ACCESSOR, 3800 useExisting: forwardRef(() => NumberValueAccessor), 3801 multi: true 3802}; 3803var NumberValueAccessor = class _NumberValueAccessor extends BuiltInControlValueAccessor { 3804 /** 3805 * Sets the "value" property on the input element. 3806 * @docs-private 3807 */ 3808 writeValue(value) { 3809 const normalizedValue = value == null ? "" : value; 3810 this.setProperty("value", normalizedValue); 3811 } 3812 /** 3813 * Registers a function called when the control value changes. 3814 * @docs-private 3815 */ 3816 registerOnChange(fn) { 3817 this.onChange = (value) => { 3818 fn(value == "" ? null : parseFloat(value)); 3819 }; 3820 } 3821 static \u0275fac = /* @__PURE__ */ (() => { 3822 let \u0275NumberValueAccessor_BaseFactory; 3823 return function NumberValueAccessor_Factory(__ngFactoryType__) { 3824 return (\u0275NumberValueAccessor_BaseFactory || (\u0275NumberValueAccessor_BaseFactory = \u0275\u0275getInheritedFactory(_NumberValueAccessor)))(__ngFactoryType__ || _NumberValueAccessor); 3825 }; 3826 })(); 3827 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 3828 type: _NumberValueAccessor, 3829 selectors: [["input", "type", "number", "formControlName", ""], ["input", "type", "number", "formControl", ""], ["input", "type", "number", "ngModel", ""]], 3830 hostBindings: function NumberValueAccessor_HostBindings(rf, ctx) { 3831 if (rf & 1) { 3832 \u0275\u0275listener("input", function NumberValueAccessor_input_HostBindingHandler($event) { 3833 return ctx.onChange($event.target.value); 3834 })("blur", function NumberValueAccessor_blur_HostBindingHandler() { 3835 return ctx.onTouched(); 3836 }); 3837 } 3838 }, 3839 standalone: false, 3840 features: [\u0275\u0275ProvidersFeature([NUMBER_VALUE_ACCESSOR]), \u0275\u0275InheritDefinitionFeature] 3841 }); 3842}; 3843(() => { 3844 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(NumberValueAccessor, [{ 3845 type: Directive, 3846 args: [{ 3847 selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]", 3848 host: { 3849 "(input)": "onChange($event.target.value)", 3850 "(blur)": "onTouched()" 3851 }, 3852 providers: [NUMBER_VALUE_ACCESSOR], 3853 standalone: false 3854 }] 3855 }], null, null); 3856})(); 3857var RADIO_VALUE_ACCESSOR = { 3858 provide: NG_VALUE_ACCESSOR, 3859 useExisting: forwardRef(() => RadioControlValueAccessor), 3860 multi: true 3861}; 3862function throwNameError() { 3863 throw new RuntimeError(1202, ` 3864 If you define both a name and a formControlName attribute on your radio button, their values 3865 must match. Ex: <input type="radio" formControlName="food" name="food"> 3866 `); 3867} 3868var RadioControlRegistry = class _RadioControlRegistry { 3869 _accessors = []; 3870 /** 3871 * @description 3872 * Adds a control to the internal registry. For internal use only. 3873 */ 3874 add(control, accessor) { 3875 this._accessors.push([control, accessor]); 3876 } 3877 /** 3878 * @description 3879 * Removes a control from the internal registry. For internal use only. 3880 */ 3881 remove(accessor) { 3882 for (let i = this._accessors.length - 1; i >= 0; --i) { 3883 if (this._accessors[i][1] === accessor) { 3884 this._accessors.splice(i, 1); 3885 return; 3886 } 3887 } 3888 } 3889 /** 3890 * @description 3891 * Selects a radio button. For internal use only. 3892 */ 3893 select(accessor) { 3894 this._accessors.forEach((c) => { 3895 if (this._isSameGroup(c, accessor) && c[1] !== accessor) { 3896 c[1].fireUncheck(accessor.value); 3897 } 3898 }); 3899 } 3900 _isSameGroup(controlPair, accessor) { 3901 if (!controlPair[0].control) return false; 3902 return controlPair[0]._parent === accessor._control._parent && controlPair[1].name === accessor.name; 3903 } 3904 static \u0275fac = function RadioControlRegistry_Factory(__ngFactoryType__) { 3905 return new (__ngFactoryType__ || _RadioControlRegistry)(); 3906 }; 3907 static \u0275prov = /* @__PURE__ */ \u0275\u0275defineInjectable({ 3908 token: _RadioControlRegistry, 3909 factory: _RadioControlRegistry.\u0275fac, 3910 providedIn: "root" 3911 }); 3912}; 3913(() => { 3914 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(RadioControlRegistry, [{ 3915 type: Injectable, 3916 args: [{ 3917 providedIn: "root" 3918 }] 3919 }], null, null); 3920})(); 3921var RadioControlValueAccessor = class _RadioControlValueAccessor extends BuiltInControlValueAccessor { 3922 _registry; 3923 _injector; 3924 /** @internal */ 3925 _state; 3926 /** @internal */ 3927 _control; 3928 /** @internal */ 3929 _fn; 3930 setDisabledStateFired = false; 3931 /** 3932 * The registered callback function called when a change event occurs on the input element. 3933 * Note: we declare `onChange` here (also used as host listener) as a function with no arguments 3934 * to override the `onChange` function (which expects 1 argument) in the parent 3935 * `BaseControlValueAccessor` class. 3936 * @docs-private 3937 */ 3938 onChange = () => { 3939 }; 3940 /** 3941 * @description 3942 * Tracks the name of the radio input element. 3943 */ 3944 name; 3945 /** 3946 * @description 3947 * Tracks the name of the `FormControl` bound to the directive. The name corresponds 3948 * to a key in the parent `FormGroup` or `FormArray`. 3949 */ 3950 formControlName; 3951 /** 3952 * @description 3953 * Tracks the value of the radio input element 3954 */ 3955 value; 3956 callSetDisabledState = inject(CALL_SET_DISABLED_STATE, { 3957 optional: true 3958 }) ?? setDisabledStateDefault; 3959 constructor(renderer, elementRef, _registry, _injector) { 3960 super(renderer, elementRef); 3961 this._registry = _registry; 3962 this._injector = _injector; 3963 } 3964 /** @docs-private */ 3965 ngOnInit() { 3966 this._control = this._injector.get(NgControl); 3967 this._checkName(); 3968 this._registry.add(this._control, this); 3969 } 3970 /** @docs-private */ 3971 ngOnDestroy() { 3972 this._registry.remove(this); 3973 } 3974 /** 3975 * Sets the "checked" property value on the radio input element. 3976 * @docs-private 3977 */ 3978 writeValue(value) { 3979 this._state = value === this.value; 3980 this.setProperty("checked", this._state); 3981 } 3982 /** 3983 * Registers a function called when the control value changes. 3984 * @docs-private 3985 */ 3986 registerOnChange(fn) { 3987 this._fn = fn; 3988 this.onChange = () => { 3989 fn(this.value); 3990 this._registry.select(this); 3991 }; 3992 } 3993 /** @docs-private */ 3994 setDisabledState(isDisabled) { 3995 if (this.setDisabledStateFired || isDisabled || this.callSetDisabledState === "whenDisabledForLegacyCode") { 3996 this.setProperty("disabled", isDisabled); 3997 } 3998 this.setDisabledStateFired = true; 3999 } 4000 /** 4001 * Sets the "value" on the radio input element and unchecks it. 4002 * 4003 * @param value 4004 */ 4005 fireUncheck(value) { 4006 this.writeValue(value); 4007 } 4008 _checkName() { 4009 if (this.name && this.formControlName && this.name !== this.formControlName && (typeof ngDevMode === "undefined" || ngDevMode)) { 4010 throwNameError(); 4011 } 4012 if (!this.name && this.formControlName) this.name = this.formControlName; 4013 } 4014 static \u0275fac = function RadioControlValueAccessor_Factory(__ngFactoryType__) { 4015 return new (__ngFactoryType__ || _RadioControlValueAccessor)(\u0275\u0275directiveInject(Renderer2), \u0275\u0275directiveInject(ElementRef), \u0275\u0275directiveInject(RadioControlRegistry), \u0275\u0275directiveInject(Injector)); 4016 }; 4017 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 4018 type: _RadioControlValueAccessor, 4019 selectors: [["input", "type", "radio", "formControlName", ""], ["input", "type", "radio", "formControl", ""], ["input", "type", "radio", "ngModel", ""]], 4020 hostBindings: function RadioControlValueAccessor_HostBindings(rf, ctx) { 4021 if (rf & 1) { 4022 \u0275\u0275listener("change", function RadioControlValueAccessor_change_HostBindingHandler() { 4023 return ctx.onChange(); 4024 })("blur", function RadioControlValueAccessor_blur_HostBindingHandler() { 4025 return ctx.onTouched(); 4026 }); 4027 } 4028 }, 4029 inputs: { 4030 name: "name", 4031 formControlName: "formControlName", 4032 value: "value" 4033 }, 4034 standalone: false, 4035 features: [\u0275\u0275ProvidersFeature([RADIO_VALUE_ACCESSOR]), \u0275\u0275InheritDefinitionFeature] 4036 }); 4037}; 4038(() => { 4039 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(RadioControlValueAccessor, [{ 4040 type: Directive, 4041 args: [{ 4042 selector: "input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]", 4043 host: { 4044 "(change)": "onChange()", 4045 "(blur)": "onTouched()" 4046 }, 4047 providers: [RADIO_VALUE_ACCESSOR], 4048 standalone: false 4049 }] 4050 }], () => [{ 4051 type: Renderer2 4052 }, { 4053 type: ElementRef 4054 }, { 4055 type: RadioControlRegistry 4056 }, { 4057 type: Injector 4058 }], { 4059 name: [{ 4060 type: Input 4061 }], 4062 formControlName: [{ 4063 type: Input 4064 }], 4065 value: [{ 4066 type: Input 4067 }] 4068 }); 4069})(); 4070var RANGE_VALUE_ACCESSOR = { 4071 provide: NG_VALUE_ACCESSOR, 4072 useExisting: forwardRef(() => RangeValueAccessor), 4073 multi: true 4074}; 4075var RangeValueAccessor = class _RangeValueAccessor extends BuiltInControlValueAccessor { 4076 /** 4077 * Sets the "value" property on the input element. 4078 * @docs-private 4079 */ 4080 writeValue(value) { 4081 this.setProperty("value", parseFloat(value)); 4082 } 4083 /** 4084 * Registers a function called when the control value changes. 4085 * @docs-private 4086 */ 4087 registerOnChange(fn) { 4088 this.onChange = (value) => { 4089 fn(value == "" ? null : parseFloat(value)); 4090 }; 4091 } 4092 static \u0275fac = /* @__PURE__ */ (() => { 4093 let \u0275RangeValueAccessor_BaseFactory; 4094 return function RangeValueAccessor_Factory(__ngFactoryType__) { 4095 return (\u0275RangeValueAccessor_BaseFactory || (\u0275RangeValueAccessor_BaseFactory = \u0275\u0275getInheritedFactory(_RangeValueAccessor)))(__ngFactoryType__ || _RangeValueAccessor); 4096 }; 4097 })(); 4098 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 4099 type: _RangeValueAccessor, 4100 selectors: [["input", "type", "range", "formControlName", ""], ["input", "type", "range", "formControl", ""], ["input", "type", "range", "ngModel", ""]], 4101 hostBindings: function RangeValueAccessor_HostBindings(rf, ctx) { 4102 if (rf & 1) { 4103 \u0275\u0275listener("change", function RangeValueAccessor_change_HostBindingHandler($event) { 4104 return ctx.onChange($event.target.value); 4105 })("input", function RangeValueAccessor_input_HostBindingHandler($event) { 4106 return ctx.onChange($event.target.value); 4107 })("blur", function RangeValueAccessor_blur_HostBindingHandler() { 4108 return ctx.onTouched(); 4109 }); 4110 } 4111 }, 4112 standalone: false, 4113 features: [\u0275\u0275ProvidersFeature([RANGE_VALUE_ACCESSOR]), \u0275\u0275InheritDefinitionFeature] 4114 }); 4115}; 4116(() => { 4117 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(RangeValueAccessor, [{ 4118 type: Directive, 4119 args: [{ 4120 selector: "input[type=range][formControlName],input[type=range][formControl],input[type=range][ngModel]", 4121 host: { 4122 "(change)": "onChange($event.target.value)", 4123 "(input)": "onChange($event.target.value)", 4124 "(blur)": "onTouched()" 4125 }, 4126 providers: [RANGE_VALUE_ACCESSOR], 4127 standalone: false 4128 }] 4129 }], null, null); 4130})(); 4131var NG_MODEL_WITH_FORM_CONTROL_WARNING = new InjectionToken(ngDevMode ? "NgModelWithFormControlWarning" : ""); 4132var formControlBinding = { 4133 provide: NgControl, 4134 useExisting: forwardRef(() => FormControlDirective) 4135}; 4136var FormControlDirective = class _FormControlDirective extends NgControl { 4137 _ngModelWarningConfig; 4138 callSetDisabledState; 4139 /** 4140 * Internal reference to the view model value. 4141 * @docs-private 4142 */ 4143 viewModel; 4144 /** 4145 * @description 4146 * Tracks the `FormControl` instance bound to the directive. 4147 */ 4148 form; 4149 /** 4150 * @description 4151 * Triggers a warning in dev mode that this input should not be used with reactive forms. 4152 */ 4153 set isDisabled(isDisabled) { 4154 if (typeof ngDevMode === "undefined" || ngDevMode) { 4155 console.warn(disabledAttrWarning); 4156 } 4157 } 4158 // TODO(kara): remove next 4 properties once deprecation period is over 4159 /** @deprecated as of v6 */ 4160 model; 4161 /** @deprecated as of v6 */ 4162 update = new EventEmitter(); 4163 /** 4164 * @description 4165 * Static property used to track whether any ngModel warnings have been sent across 4166 * all instances of FormControlDirective. Used to support warning config of "once". 4167 * 4168 * @internal 4169 */ 4170 static _ngModelWarningSentOnce = false; 4171 /** 4172 * @description 4173 * Instance property used to track whether an ngModel warning has been sent out for this 4174 * particular `FormControlDirective` instance. Used to support warning config of "always". 4175 * 4176 * @internal 4177 */ 4178 _ngModelWarningSent = false; 4179 constructor(validators, asyncValidators, valueAccessors, _ngModelWarningConfig, callSetDisabledState) { 4180 super(); 4181 this._ngModelWarningConfig = _ngModelWarningConfig; 4182 this.callSetDisabledState = callSetDisabledState; 4183 this._setValidators(validators); 4184 this._setAsyncValidators(asyncValidators); 4185 this.valueAccessor = selectValueAccessor(this, valueAccessors); 4186 } 4187 /** @docs-private */ 4188 ngOnChanges(changes) { 4189 if (this._isControlChanged(changes)) { 4190 const previousForm = changes["form"].previousValue; 4191 if (previousForm) { 4192 cleanUpControl( 4193 previousForm, 4194 this, 4195 /* validateControlPresenceOnChange */ 4196 false 4197 ); 4198 } 4199 setUpControl(this.form, this, this.callSetDisabledState); 4200 this.form.updateValueAndValidity({ 4201 emitEvent: false 4202 }); 4203 } 4204 if (isPropertyUpdated(changes, this.viewModel)) { 4205 if (typeof ngDevMode === "undefined" || ngDevMode) { 4206 _ngModelWarning("formControl", _FormControlDirective, this, this._ngModelWarningConfig); 4207 } 4208 this.form.setValue(this.model); 4209 this.viewModel = this.model; 4210 } 4211 } 4212 /** @docs-private */ 4213 ngOnDestroy() { 4214 if (this.form) { 4215 cleanUpControl( 4216 this.form, 4217 this, 4218 /* validateControlPresenceOnChange */ 4219 false 4220 ); 4221 } 4222 } 4223 /** 4224 * @description 4225 * Returns an array that represents the path from the top-level form to this control. 4226 * Each index is the string name of the control on that level. 4227 */ 4228 get path() { 4229 return []; 4230 } 4231 /** 4232 * @description 4233 * The `FormControl` bound to this directive. 4234 */ 4235 get control() { 4236 return this.form; 4237 } 4238 /** 4239 * @description 4240 * Sets the new value for the view model and emits an `ngModelChange` event. 4241 * 4242 * @param newValue The new value for the view model. 4243 */ 4244 viewToModelUpdate(newValue) { 4245 this.viewModel = newValue; 4246 this.update.emit(newValue); 4247 } 4248 _isControlChanged(changes) { 4249 return changes.hasOwnProperty("form"); 4250 } 4251 static \u0275fac = function FormControlDirective_Factory(__ngFactoryType__) { 4252 return new (__ngFactoryType__ || _FormControlDirective)(\u0275\u0275directiveInject(NG_VALIDATORS, 10), \u0275\u0275directiveInject(NG_ASYNC_VALIDATORS, 10), \u0275\u0275directiveInject(NG_VALUE_ACCESSOR, 10), \u0275\u0275directiveInject(NG_MODEL_WITH_FORM_CONTROL_WARNING, 8), \u0275\u0275directiveInject(CALL_SET_DISABLED_STATE, 8)); 4253 }; 4254 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 4255 type: _FormControlDirective, 4256 selectors: [["", "formControl", ""]], 4257 inputs: { 4258 form: [0, "formControl", "form"], 4259 isDisabled: [0, "disabled", "isDisabled"], 4260 model: [0, "ngModel", "model"] 4261 }, 4262 outputs: { 4263 update: "ngModelChange" 4264 }, 4265 exportAs: ["ngForm"], 4266 standalone: false, 4267 features: [\u0275\u0275ProvidersFeature([formControlBinding]), \u0275\u0275InheritDefinitionFeature, \u0275\u0275NgOnChangesFeature] 4268 }); 4269}; 4270(() => { 4271 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(FormControlDirective, [{ 4272 type: Directive, 4273 args: [{ 4274 selector: "[formControl]", 4275 providers: [formControlBinding], 4276 exportAs: "ngForm", 4277 standalone: false 4278 }] 4279 }], () => [{ 4280 type: void 0, 4281 decorators: [{ 4282 type: Optional 4283 }, { 4284 type: Self 4285 }, { 4286 type: Inject, 4287 args: [NG_VALIDATORS] 4288 }] 4289 }, { 4290 type: void 0, 4291 decorators: [{ 4292 type: Optional 4293 }, { 4294 type: Self 4295 }, { 4296 type: Inject, 4297 args: [NG_ASYNC_VALIDATORS] 4298 }] 4299 }, { 4300 type: void 0, 4301 decorators: [{ 4302 type: Optional 4303 }, { 4304 type: Self 4305 }, { 4306 type: Inject, 4307 args: [NG_VALUE_ACCESSOR] 4308 }] 4309 }, { 4310 type: void 0, 4311 decorators: [{ 4312 type: Optional 4313 }, { 4314 type: Inject, 4315 args: [NG_MODEL_WITH_FORM_CONTROL_WARNING] 4316 }] 4317 }, { 4318 type: void 0, 4319 decorators: [{ 4320 type: Optional 4321 }, { 4322 type: Inject, 4323 args: [CALL_SET_DISABLED_STATE] 4324 }] 4325 }], { 4326 form: [{ 4327 type: Input, 4328 args: ["formControl"] 4329 }], 4330 isDisabled: [{ 4331 type: Input, 4332 args: ["disabled"] 4333 }], 4334 model: [{ 4335 type: Input, 4336 args: ["ngModel"] 4337 }], 4338 update: [{ 4339 type: Output, 4340 args: ["ngModelChange"] 4341 }] 4342 }); 4343})(); 4344var formDirectiveProvider = { 4345 provide: ControlContainer, 4346 useExisting: forwardRef(() => FormGroupDirective) 4347}; 4348var FormGroupDirective = class _FormGroupDirective extends ControlContainer { 4349 callSetDisabledState; 4350 /** 4351 * @description 4352 * Reports whether the form submission has been triggered. 4353 */ 4354 get submitted() { 4355 return untracked(this._submittedReactive); 4356 } 4357 // TODO(atscott): Remove once invalid API usage is cleaned up internally 4358 set submitted(value) { 4359 this._submittedReactive.set(value); 4360 } 4361 /** @internal */ 4362 _submitted = computed(() => this._submittedReactive()); 4363 _submittedReactive = signal(false); 4364 /** 4365 * Reference to an old form group input value, which is needed to cleanup 4366 * old instance in case it was replaced with a new one. 4367 */ 4368 _oldForm; 4369 /** 4370 * Callback that should be invoked when controls in FormGroup or FormArray collection change 4371 * (added or removed). This callback triggers corresponding DOM updates. 4372 */ 4373 _onCollectionChange = () => this._updateDomValue(); 4374 /** 4375 * @description 4376 * Tracks the list of added `FormControlName` instances 4377 */ 4378 directives = []; 4379 /** 4380 * @description 4381 * Tracks the `FormGroup` bound to this directive. 4382 */ 4383 form = null; 4384 /** 4385 * @description 4386 * Emits an event when the form submission has been triggered. 4387 */ 4388 ngSubmit = new EventEmitter(); 4389 constructor(validators, asyncValidators, callSetDisabledState) { 4390 super(); 4391 this.callSetDisabledState = callSetDisabledState; 4392 this._setValidators(validators); 4393 this._setAsyncValidators(asyncValidators); 4394 } 4395 /** @docs-private */ 4396 ngOnChanges(changes) { 4397 if ((typeof ngDevMode === "undefined" || ngDevMode) && !this.form) { 4398 throw missingFormException(); 4399 } 4400 if (changes.hasOwnProperty("form")) { 4401 this._updateValidators(); 4402 this._updateDomValue(); 4403 this._updateRegistrations(); 4404 this._oldForm = this.form; 4405 } 4406 } 4407 /** @docs-private */ 4408 ngOnDestroy() { 4409 if (this.form) { 4410 cleanUpValidators(this.form, this); 4411 if (this.form._onCollectionChange === this._onCollectionChange) { 4412 this.form._registerOnCollectionChange(() => { 4413 }); 4414 } 4415 } 4416 } 4417 /** 4418 * @description 4419 * Returns this directive's instance. 4420 */ 4421 get formDirective() { 4422 return this; 4423 } 4424 /** 4425 * @description 4426 * Returns the `FormGroup` bound to this directive. 4427 */ 4428 get control() { 4429 return this.form; 4430 } 4431 /** 4432 * @description 4433 * Returns an array representing the path to this group. Because this directive 4434 * always lives at the top level of a form, it always an empty array. 4435 */ 4436 get path() { 4437 return []; 4438 } 4439 /** 4440 * @description 4441 * Method that sets up the control directive in this group, re-calculates its value 4442 * and validity, and adds the instance to the internal list of directives. 4443 * 4444 * @param dir The `FormControlName` directive instance. 4445 */ 4446 addControl(dir) { 4447 const ctrl = this.form.get(dir.path); 4448 setUpControl(ctrl, dir, this.callSetDisabledState); 4449 ctrl.updateValueAndValidity({ 4450 emitEvent: false 4451 }); 4452 this.directives.push(dir); 4453 return ctrl; 4454 } 4455 /** 4456 * @description 4457 * Retrieves the `FormControl` instance from the provided `FormControlName` directive 4458 * 4459 * @param dir The `FormControlName` directive instance. 4460 */ 4461 getControl(dir) { 4462 return this.form.get(dir.path); 4463 } 4464 /** 4465 * @description 4466 * Removes the `FormControlName` instance from the internal list of directives 4467 * 4468 * @param dir The `FormControlName` directive instance. 4469 */ 4470 removeControl(dir) { 4471 cleanUpControl( 4472 dir.control || null, 4473 dir, 4474 /* validateControlPresenceOnChange */ 4475 false 4476 ); 4477 removeListItem$1(this.directives, dir); 4478 } 4479 /** 4480 * Adds a new `FormGroupName` directive instance to the form. 4481 * 4482 * @param dir The `FormGroupName` directive instance. 4483 */ 4484 addFormGroup(dir) { 4485 this._setUpFormContainer(dir); 4486 } 4487 /** 4488 * Performs the necessary cleanup when a `FormGroupName` directive instance is removed from the 4489 * view. 4490 * 4491 * @param dir The `FormGroupName` directive instance. 4492 */ 4493 removeFormGroup(dir) { 4494 this._cleanUpFormContainer(dir); 4495 } 4496 /** 4497 * @description 4498 * Retrieves the `FormGroup` for a provided `FormGroupName` directive instance 4499 * 4500 * @param dir The `FormGroupName` directive instance. 4501 */ 4502 getFormGroup(dir) { 4503 return this.form.get(dir.path); 4504 } 4505 /** 4506 * Performs the necessary setup when a `FormArrayName` directive instance is added to the view. 4507 * 4508 * @param dir The `FormArrayName` directive instance. 4509 */ 4510 addFormArray(dir) { 4511 this._setUpFormContainer(dir); 4512 } 4513 /** 4514 * Performs the necessary cleanup when a `FormArrayName` directive instance is removed from the 4515 * view. 4516 * 4517 * @param dir The `FormArrayName` directive instance. 4518 */ 4519 removeFormArray(dir) { 4520 this._cleanUpFormContainer(dir); 4521 } 4522 /** 4523 * @description 4524 * Retrieves the `FormArray` for a provided `FormArrayName` directive instance. 4525 * 4526 * @param dir The `FormArrayName` directive instance. 4527 */ 4528 getFormArray(dir) { 4529 return this.form.get(dir.path); 4530 } 4531 /** 4532 * Sets the new value for the provided `FormControlName` directive. 4533 * 4534 * @param dir The `FormControlName` directive instance. 4535 * @param value The new value for the directive's control. 4536 */ 4537 updateModel(dir, value) { 4538 const ctrl = this.form.get(dir.path); 4539 ctrl.setValue(value); 4540 } 4541 /** 4542 * @description 4543 * Method called with the "submit" event is triggered on the form. 4544 * Triggers the `ngSubmit` emitter to emit the "submit" event as its payload. 4545 * 4546 * @param $event The "submit" event object 4547 */ 4548 onSubmit($event) { 4549 this._submittedReactive.set(true); 4550 syncPendingControls(this.form, this.directives); 4551 this.ngSubmit.emit($event); 4552 this.form._events.next(new FormSubmittedEvent(this.control)); 4553 return $event?.target?.method === "dialog"; 4554 } 4555 /** 4556 * @description 4557 * Method called when the "reset" event is triggered on the form. 4558 */ 4559 onReset() { 4560 this.resetForm(); 4561 } 4562 /** 4563 * @description 4564 * Resets the form to an initial value and resets its submitted status. 4565 * 4566 * @param value The new value for the form. 4567 */ 4568 resetForm(value = void 0) { 4569 this.form.reset(value); 4570 this._submittedReactive.set(false); 4571 this.form._events.next(new FormResetEvent(this.form)); 4572 } 4573 /** @internal */ 4574 _updateDomValue() { 4575 this.directives.forEach((dir) => { 4576 const oldCtrl = dir.control; 4577 const newCtrl = this.form.get(dir.path); 4578 if (oldCtrl !== newCtrl) { 4579 cleanUpControl(oldCtrl || null, dir); 4580 if (isFormControl(newCtrl)) { 4581 setUpControl(newCtrl, dir, this.callSetDisabledState); 4582 dir.control = newCtrl; 4583 } 4584 } 4585 }); 4586 this.form._updateTreeValidity({ 4587 emitEvent: false 4588 }); 4589 } 4590 _setUpFormContainer(dir) { 4591 const ctrl = this.form.get(dir.path); 4592 setUpFormContainer(ctrl, dir); 4593 ctrl.updateValueAndValidity({ 4594 emitEvent: false 4595 }); 4596 } 4597 _cleanUpFormContainer(dir) { 4598 if (this.form) { 4599 const ctrl = this.form.get(dir.path); 4600 if (ctrl) { 4601 const isControlUpdated = cleanUpFormContainer(ctrl, dir); 4602 if (isControlUpdated) { 4603 ctrl.updateValueAndValidity({ 4604 emitEvent: false 4605 }); 4606 } 4607 } 4608 } 4609 } 4610 _updateRegistrations() { 4611 this.form._registerOnCollectionChange(this._onCollectionChange); 4612 if (this._oldForm) { 4613 this._oldForm._registerOnCollectionChange(() => { 4614 }); 4615 } 4616 } 4617 _updateValidators() { 4618 setUpValidators(this.form, this); 4619 if (this._oldForm) { 4620 cleanUpValidators(this._oldForm, this); 4621 } 4622 } 4623 static \u0275fac = function FormGroupDirective_Factory(__ngFactoryType__) { 4624 return new (__ngFactoryType__ || _FormGroupDirective)(\u0275\u0275directiveInject(NG_VALIDATORS, 10), \u0275\u0275directiveInject(NG_ASYNC_VALIDATORS, 10), \u0275\u0275directiveInject(CALL_SET_DISABLED_STATE, 8)); 4625 }; 4626 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 4627 type: _FormGroupDirective, 4628 selectors: [["", "formGroup", ""]], 4629 hostBindings: function FormGroupDirective_HostBindings(rf, ctx) { 4630 if (rf & 1) { 4631 \u0275\u0275listener("submit", function FormGroupDirective_submit_HostBindingHandler($event) { 4632 return ctx.onSubmit($event); 4633 })("reset", function FormGroupDirective_reset_HostBindingHandler() { 4634 return ctx.onReset(); 4635 }); 4636 } 4637 }, 4638 inputs: { 4639 form: [0, "formGroup", "form"] 4640 }, 4641 outputs: { 4642 ngSubmit: "ngSubmit" 4643 }, 4644 exportAs: ["ngForm"], 4645 standalone: false, 4646 features: [\u0275\u0275ProvidersFeature([formDirectiveProvider]), \u0275\u0275InheritDefinitionFeature, \u0275\u0275NgOnChangesFeature] 4647 }); 4648}; 4649(() => { 4650 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(FormGroupDirective, [{ 4651 type: Directive, 4652 args: [{ 4653 selector: "[formGroup]", 4654 providers: [formDirectiveProvider], 4655 host: { 4656 "(submit)": "onSubmit($event)", 4657 "(reset)": "onReset()" 4658 }, 4659 exportAs: "ngForm", 4660 standalone: false 4661 }] 4662 }], () => [{ 4663 type: void 0, 4664 decorators: [{ 4665 type: Optional 4666 }, { 4667 type: Self 4668 }, { 4669 type: Inject, 4670 args: [NG_VALIDATORS] 4671 }] 4672 }, { 4673 type: void 0, 4674 decorators: [{ 4675 type: Optional 4676 }, { 4677 type: Self 4678 }, { 4679 type: Inject, 4680 args: [NG_ASYNC_VALIDATORS] 4681 }] 4682 }, { 4683 type: void 0, 4684 decorators: [{ 4685 type: Optional 4686 }, { 4687 type: Inject, 4688 args: [CALL_SET_DISABLED_STATE] 4689 }] 4690 }], { 4691 form: [{ 4692 type: Input, 4693 args: ["formGroup"] 4694 }], 4695 ngSubmit: [{ 4696 type: Output 4697 }] 4698 }); 4699})(); 4700var formGroupNameProvider = { 4701 provide: ControlContainer, 4702 useExisting: forwardRef(() => FormGroupName) 4703}; 4704var FormGroupName = class _FormGroupName extends AbstractFormGroupDirective { 4705 /** 4706 * @description 4707 * Tracks the name of the `FormGroup` bound to the directive. The name corresponds 4708 * to a key in the parent `FormGroup` or `FormArray`. 4709 * Accepts a name as a string or a number. 4710 * The name in the form of a string is useful for individual forms, 4711 * while the numerical form allows for form groups to be bound 4712 * to indices when iterating over groups in a `FormArray`. 4713 */ 4714 name = null; 4715 constructor(parent, validators, asyncValidators) { 4716 super(); 4717 this._parent = parent; 4718 this._setValidators(validators); 4719 this._setAsyncValidators(asyncValidators); 4720 } 4721 /** @internal */ 4722 _checkParentType() { 4723 if (hasInvalidParent(this._parent) && (typeof ngDevMode === "undefined" || ngDevMode)) { 4724 throw groupParentException(); 4725 } 4726 } 4727 static \u0275fac = function FormGroupName_Factory(__ngFactoryType__) { 4728 return new (__ngFactoryType__ || _FormGroupName)(\u0275\u0275directiveInject(ControlContainer, 13), \u0275\u0275directiveInject(NG_VALIDATORS, 10), \u0275\u0275directiveInject(NG_ASYNC_VALIDATORS, 10)); 4729 }; 4730 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 4731 type: _FormGroupName, 4732 selectors: [["", "formGroupName", ""]], 4733 inputs: { 4734 name: [0, "formGroupName", "name"] 4735 }, 4736 standalone: false, 4737 features: [\u0275\u0275ProvidersFeature([formGroupNameProvider]), \u0275\u0275InheritDefinitionFeature] 4738 }); 4739}; 4740(() => { 4741 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(FormGroupName, [{ 4742 type: Directive, 4743 args: [{ 4744 selector: "[formGroupName]", 4745 providers: [formGroupNameProvider], 4746 standalone: false 4747 }] 4748 }], () => [{ 4749 type: ControlContainer, 4750 decorators: [{ 4751 type: Optional 4752 }, { 4753 type: Host 4754 }, { 4755 type: SkipSelf 4756 }] 4757 }, { 4758 type: void 0, 4759 decorators: [{ 4760 type: Optional 4761 }, { 4762 type: Self 4763 }, { 4764 type: Inject, 4765 args: [NG_VALIDATORS] 4766 }] 4767 }, { 4768 type: void 0, 4769 decorators: [{ 4770 type: Optional 4771 }, { 4772 type: Self 4773 }, { 4774 type: Inject, 4775 args: [NG_ASYNC_VALIDATORS] 4776 }] 4777 }], { 4778 name: [{ 4779 type: Input, 4780 args: ["formGroupName"] 4781 }] 4782 }); 4783})(); 4784var formArrayNameProvider = { 4785 provide: ControlContainer, 4786 useExisting: forwardRef(() => FormArrayName) 4787}; 4788var FormArrayName = class _FormArrayName extends ControlContainer { 4789 /** @internal */ 4790 _parent; 4791 /** 4792 * @description 4793 * Tracks the name of the `FormArray` bound to the directive. The name corresponds 4794 * to a key in the parent `FormGroup` or `FormArray`. 4795 * Accepts a name as a string or a number. 4796 * The name in the form of a string is useful for individual forms, 4797 * while the numerical form allows for form arrays to be bound 4798 * to indices when iterating over arrays in a `FormArray`. 4799 */ 4800 name = null; 4801 constructor(parent, validators, asyncValidators) { 4802 super(); 4803 this._parent = parent; 4804 this._setValidators(validators); 4805 this._setAsyncValidators(asyncValidators); 4806 } 4807 /** 4808 * A lifecycle method called when the directive's inputs are initialized. For internal use only. 4809 * @throws If the directive does not have a valid parent. 4810 * @docs-private 4811 */ 4812 ngOnInit() { 4813 if (hasInvalidParent(this._parent) && (typeof ngDevMode === "undefined" || ngDevMode)) { 4814 throw arrayParentException(); 4815 } 4816 this.formDirective.addFormArray(this); 4817 } 4818 /** 4819 * A lifecycle method called before the directive's instance is destroyed. For internal use only. 4820 * @docs-private 4821 */ 4822 ngOnDestroy() { 4823 this.formDirective?.removeFormArray(this); 4824 } 4825 /** 4826 * @description 4827 * The `FormArray` bound to this directive. 4828 */ 4829 get control() { 4830 return this.formDirective.getFormArray(this); 4831 } 4832 /** 4833 * @description 4834 * The top-level directive for this group if present, otherwise null. 4835 */ 4836 get formDirective() { 4837 return this._parent ? this._parent.formDirective : null; 4838 } 4839 /** 4840 * @description 4841 * Returns an array that represents the path from the top-level form to this control. 4842 * Each index is the string name of the control on that level. 4843 */ 4844 get path() { 4845 return controlPath(this.name == null ? this.name : this.name.toString(), this._parent); 4846 } 4847 static \u0275fac = function FormArrayName_Factory(__ngFactoryType__) { 4848 return new (__ngFactoryType__ || _FormArrayName)(\u0275\u0275directiveInject(ControlContainer, 13), \u0275\u0275directiveInject(NG_VALIDATORS, 10), \u0275\u0275directiveInject(NG_ASYNC_VALIDATORS, 10)); 4849 }; 4850 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 4851 type: _FormArrayName, 4852 selectors: [["", "formArrayName", ""]], 4853 inputs: { 4854 name: [0, "formArrayName", "name"] 4855 }, 4856 standalone: false, 4857 features: [\u0275\u0275ProvidersFeature([formArrayNameProvider]), \u0275\u0275InheritDefinitionFeature] 4858 }); 4859}; 4860(() => { 4861 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(FormArrayName, [{ 4862 type: Directive, 4863 args: [{ 4864 selector: "[formArrayName]", 4865 providers: [formArrayNameProvider], 4866 standalone: false 4867 }] 4868 }], () => [{ 4869 type: ControlContainer, 4870 decorators: [{ 4871 type: Optional 4872 }, { 4873 type: Host 4874 }, { 4875 type: SkipSelf 4876 }] 4877 }, { 4878 type: void 0, 4879 decorators: [{ 4880 type: Optional 4881 }, { 4882 type: Self 4883 }, { 4884 type: Inject, 4885 args: [NG_VALIDATORS] 4886 }] 4887 }, { 4888 type: void 0, 4889 decorators: [{ 4890 type: Optional 4891 }, { 4892 type: Self 4893 }, { 4894 type: Inject, 4895 args: [NG_ASYNC_VALIDATORS] 4896 }] 4897 }], { 4898 name: [{ 4899 type: Input, 4900 args: ["formArrayName"] 4901 }] 4902 }); 4903})(); 4904function hasInvalidParent(parent) { 4905 return !(parent instanceof FormGroupName) && !(parent instanceof FormGroupDirective) && !(parent instanceof FormArrayName); 4906} 4907var controlNameBinding = { 4908 provide: NgControl, 4909 useExisting: forwardRef(() => FormControlName) 4910}; 4911var FormControlName = class _FormControlName extends NgControl { 4912 _ngModelWarningConfig; 4913 _added = false; 4914 /** 4915 * Internal reference to the view model value. 4916 * @internal 4917 */ 4918 viewModel; 4919 /** 4920 * @description 4921 * Tracks the `FormControl` instance bound to the directive. 4922 */ 4923 control; 4924 /** 4925 * @description 4926 * Tracks the name of the `FormControl` bound to the directive. The name corresponds 4927 * to a key in the parent `FormGroup` or `FormArray`. 4928 * Accepts a name as a string or a number. 4929 * The name in the form of a string is useful for individual forms, 4930 * while the numerical form allows for form controls to be bound 4931 * to indices when iterating over controls in a `FormArray`. 4932 */ 4933 name = null; 4934 /** 4935 * @description 4936 * Triggers a warning in dev mode that this input should not be used with reactive forms. 4937 */ 4938 set isDisabled(isDisabled) { 4939 if (typeof ngDevMode === "undefined" || ngDevMode) { 4940 console.warn(disabledAttrWarning); 4941 } 4942 } 4943 // TODO(kara): remove next 4 properties once deprecation period is over 4944 /** @deprecated as of v6 */ 4945 model; 4946 /** @deprecated as of v6 */ 4947 update = new EventEmitter(); 4948 /** 4949 * @description 4950 * Static property used to track whether any ngModel warnings have been sent across 4951 * all instances of FormControlName. Used to support warning config of "once". 4952 * 4953 * @internal 4954 */ 4955 static _ngModelWarningSentOnce = false; 4956 /** 4957 * @description 4958 * Instance property used to track whether an ngModel warning has been sent out for this 4959 * particular FormControlName instance. Used to support warning config of "always". 4960 * 4961 * @internal 4962 */ 4963 _ngModelWarningSent = false; 4964 constructor(parent, validators, asyncValidators, valueAccessors, _ngModelWarningConfig) { 4965 super(); 4966 this._ngModelWarningConfig = _ngModelWarningConfig; 4967 this._parent = parent; 4968 this._setValidators(validators); 4969 this._setAsyncValidators(asyncValidators); 4970 this.valueAccessor = selectValueAccessor(this, valueAccessors); 4971 } 4972 /** @docs-private */ 4973 ngOnChanges(changes) { 4974 if (!this._added) this._setUpControl(); 4975 if (isPropertyUpdated(changes, this.viewModel)) { 4976 if (typeof ngDevMode === "undefined" || ngDevMode) { 4977 _ngModelWarning("formControlName", _FormControlName, this, this._ngModelWarningConfig); 4978 } 4979 this.viewModel = this.model; 4980 this.formDirective.updateModel(this, this.model); 4981 } 4982 } 4983 /** @docs-private */ 4984 ngOnDestroy() { 4985 if (this.formDirective) { 4986 this.formDirective.removeControl(this); 4987 } 4988 } 4989 /** 4990 * @description 4991 * Sets the new value for the view model and emits an `ngModelChange` event. 4992 * 4993 * @param newValue The new value for the view model. 4994 */ 4995 viewToModelUpdate(newValue) { 4996 this.viewModel = newValue; 4997 this.update.emit(newValue); 4998 } 4999 /** 5000 * @description 5001 * Returns an array that represents the path from the top-level form to this control. 5002 * Each index is the string name of the control on that level. 5003 */ 5004 get path() { 5005 return controlPath(this.name == null ? this.name : this.name.toString(), this._parent); 5006 } 5007 /** 5008 * @description 5009 * The top-level directive for this group if present, otherwise null. 5010 */ 5011 get formDirective() { 5012 return this._parent ? this._parent.formDirective : null; 5013 } 5014 _setUpControl() { 5015 if (typeof ngDevMode === "undefined" || ngDevMode) { 5016 checkParentType(this._parent, this.name); 5017 } 5018 this.control = this.formDirective.addControl(this); 5019 this._added = true; 5020 } 5021 static \u0275fac = function FormControlName_Factory(__ngFactoryType__) { 5022 return new (__ngFactoryType__ || _FormControlName)(\u0275\u0275directiveInject(ControlContainer, 13), \u0275\u0275directiveInject(NG_VALIDATORS, 10), \u0275\u0275directiveInject(NG_ASYNC_VALIDATORS, 10), \u0275\u0275directiveInject(NG_VALUE_ACCESSOR, 10), \u0275\u0275directiveInject(NG_MODEL_WITH_FORM_CONTROL_WARNING, 8)); 5023 }; 5024 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 5025 type: _FormControlName, 5026 selectors: [["", "formControlName", ""]], 5027 inputs: { 5028 name: [0, "formControlName", "name"], 5029 isDisabled: [0, "disabled", "isDisabled"], 5030 model: [0, "ngModel", "model"] 5031 }, 5032 outputs: { 5033 update: "ngModelChange" 5034 }, 5035 standalone: false, 5036 features: [\u0275\u0275ProvidersFeature([controlNameBinding]), \u0275\u0275InheritDefinitionFeature, \u0275\u0275NgOnChangesFeature] 5037 }); 5038}; 5039(() => { 5040 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(FormControlName, [{ 5041 type: Directive, 5042 args: [{ 5043 selector: "[formControlName]", 5044 providers: [controlNameBinding], 5045 standalone: false 5046 }] 5047 }], () => [{ 5048 type: ControlContainer, 5049 decorators: [{ 5050 type: Optional 5051 }, { 5052 type: Host 5053 }, { 5054 type: SkipSelf 5055 }] 5056 }, { 5057 type: void 0, 5058 decorators: [{ 5059 type: Optional 5060 }, { 5061 type: Self 5062 }, { 5063 type: Inject, 5064 args: [NG_VALIDATORS] 5065 }] 5066 }, { 5067 type: void 0, 5068 decorators: [{ 5069 type: Optional 5070 }, { 5071 type: Self 5072 }, { 5073 type: Inject, 5074 args: [NG_ASYNC_VALIDATORS] 5075 }] 5076 }, { 5077 type: void 0, 5078 decorators: [{ 5079 type: Optional 5080 }, { 5081 type: Self 5082 }, { 5083 type: Inject, 5084 args: [NG_VALUE_ACCESSOR] 5085 }] 5086 }, { 5087 type: void 0, 5088 decorators: [{ 5089 type: Optional 5090 }, { 5091 type: Inject, 5092 args: [NG_MODEL_WITH_FORM_CONTROL_WARNING] 5093 }] 5094 }], { 5095 name: [{ 5096 type: Input, 5097 args: ["formControlName"] 5098 }], 5099 isDisabled: [{ 5100 type: Input, 5101 args: ["disabled"] 5102 }], 5103 model: [{ 5104 type: Input, 5105 args: ["ngModel"] 5106 }], 5107 update: [{ 5108 type: Output, 5109 args: ["ngModelChange"] 5110 }] 5111 }); 5112})(); 5113function checkParentType(parent, name) { 5114 if (!(parent instanceof FormGroupName) && parent instanceof AbstractFormGroupDirective) { 5115 throw ngModelGroupException(); 5116 } else if (!(parent instanceof FormGroupName) && !(parent instanceof FormGroupDirective) && !(parent instanceof FormArrayName)) { 5117 throw controlParentException(name); 5118 } 5119} 5120var SELECT_VALUE_ACCESSOR = { 5121 provide: NG_VALUE_ACCESSOR, 5122 useExisting: forwardRef(() => SelectControlValueAccessor), 5123 multi: true 5124}; 5125function _buildValueString$1(id, value) { 5126 if (id == null) return `${value}`; 5127 if (value && typeof value === "object") value = "Object"; 5128 return `${id}: ${value}`.slice(0, 50); 5129} 5130function _extractId$1(valueString) { 5131 return valueString.split(":")[0]; 5132} 5133var SelectControlValueAccessor = class _SelectControlValueAccessor extends BuiltInControlValueAccessor { 5134 /** @docs-private */ 5135 value; 5136 /** @internal */ 5137 _optionMap = /* @__PURE__ */ new Map(); 5138 /** @internal */ 5139 _idCounter = 0; 5140 /** 5141 * @description 5142 * Tracks the option comparison algorithm for tracking identities when 5143 * checking for changes. 5144 */ 5145 set compareWith(fn) { 5146 if (typeof fn !== "function" && (typeof ngDevMode === "undefined" || ngDevMode)) { 5147 throw new RuntimeError(1201, `compareWith must be a function, but received ${JSON.stringify(fn)}`); 5148 } 5149 this._compareWith = fn; 5150 } 5151 _compareWith = Object.is; 5152 /** 5153 * Sets the "value" property on the select element. 5154 * @docs-private 5155 */ 5156 writeValue(value) { 5157 this.value = value; 5158 const id = this._getOptionId(value); 5159 const valueString = _buildValueString$1(id, value); 5160 this.setProperty("value", valueString); 5161 } 5162 /** 5163 * Registers a function called when the control value changes. 5164 * @docs-private 5165 */ 5166 registerOnChange(fn) { 5167 this.onChange = (valueString) => { 5168 this.value = this._getOptionValue(valueString); 5169 fn(this.value); 5170 }; 5171 } 5172 /** @internal */ 5173 _registerOption() { 5174 return (this._idCounter++).toString(); 5175 } 5176 /** @internal */ 5177 _getOptionId(value) { 5178 for (const id of this._optionMap.keys()) { 5179 if (this._compareWith(this._optionMap.get(id), value)) return id; 5180 } 5181 return null; 5182 } 5183 /** @internal */ 5184 _getOptionValue(valueString) { 5185 const id = _extractId$1(valueString); 5186 return this._optionMap.has(id) ? this._optionMap.get(id) : valueString; 5187 } 5188 static \u0275fac = /* @__PURE__ */ (() => { 5189 let \u0275SelectControlValueAccessor_BaseFactory; 5190 return function SelectControlValueAccessor_Factory(__ngFactoryType__) { 5191 return (\u0275SelectControlValueAccessor_BaseFactory || (\u0275SelectControlValueAccessor_BaseFactory = \u0275\u0275getInheritedFactory(_SelectControlValueAccessor)))(__ngFactoryType__ || _SelectControlValueAccessor); 5192 }; 5193 })(); 5194 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 5195 type: _SelectControlValueAccessor, 5196 selectors: [["select", "formControlName", "", 3, "multiple", ""], ["select", "formControl", "", 3, "multiple", ""], ["select", "ngModel", "", 3, "multiple", ""]], 5197 hostBindings: function SelectControlValueAccessor_HostBindings(rf, ctx) { 5198 if (rf & 1) { 5199 \u0275\u0275listener("change", function SelectControlValueAccessor_change_HostBindingHandler($event) { 5200 return ctx.onChange($event.target.value); 5201 })("blur", function SelectControlValueAccessor_blur_HostBindingHandler() { 5202 return ctx.onTouched(); 5203 }); 5204 } 5205 }, 5206 inputs: { 5207 compareWith: "compareWith" 5208 }, 5209 standalone: false, 5210 features: [\u0275\u0275ProvidersFeature([SELECT_VALUE_ACCESSOR]), \u0275\u0275InheritDefinitionFeature] 5211 }); 5212}; 5213(() => { 5214 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(SelectControlValueAccessor, [{ 5215 type: Directive, 5216 args: [{ 5217 selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", 5218 host: { 5219 "(change)": "onChange($event.target.value)", 5220 "(blur)": "onTouched()" 5221 }, 5222 providers: [SELECT_VALUE_ACCESSOR], 5223 standalone: false 5224 }] 5225 }], null, { 5226 compareWith: [{ 5227 type: Input 5228 }] 5229 }); 5230})(); 5231var NgSelectOption = class _NgSelectOption { 5232 _element; 5233 _renderer; 5234 _select; 5235 /** 5236 * @description 5237 * ID of the option element 5238 */ 5239 id; 5240 constructor(_element, _renderer, _select) { 5241 this._element = _element; 5242 this._renderer = _renderer; 5243 this._select = _select; 5244 if (this._select) this.id = this._select._registerOption(); 5245 } 5246 /** 5247 * @description 5248 * Tracks the value bound to the option element. Unlike the value binding, 5249 * ngValue supports binding to objects. 5250 */ 5251 set ngValue(value) { 5252 if (this._select == null) return; 5253 this._select._optionMap.set(this.id, value); 5254 this._setElementValue(_buildValueString$1(this.id, value)); 5255 this._select.writeValue(this._select.value); 5256 } 5257 /** 5258 * @description 5259 * Tracks simple string values bound to the option element. 5260 * For objects, use the `ngValue` input binding. 5261 */ 5262 set value(value) { 5263 this._setElementValue(value); 5264 if (this._select) this._select.writeValue(this._select.value); 5265 } 5266 /** @internal */ 5267 _setElementValue(value) { 5268 this._renderer.setProperty(this._element.nativeElement, "value", value); 5269 } 5270 /** @docs-private */ 5271 ngOnDestroy() { 5272 if (this._select) { 5273 this._select._optionMap.delete(this.id); 5274 this._select.writeValue(this._select.value); 5275 } 5276 } 5277 static \u0275fac = function NgSelectOption_Factory(__ngFactoryType__) { 5278 return new (__ngFactoryType__ || _NgSelectOption)(\u0275\u0275directiveInject(ElementRef), \u0275\u0275directiveInject(Renderer2), \u0275\u0275directiveInject(SelectControlValueAccessor, 9)); 5279 }; 5280 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 5281 type: _NgSelectOption, 5282 selectors: [["option"]], 5283 inputs: { 5284 ngValue: "ngValue", 5285 value: "value" 5286 }, 5287 standalone: false 5288 }); 5289}; 5290(() => { 5291 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(NgSelectOption, [{ 5292 type: Directive, 5293 args: [{ 5294 selector: "option", 5295 standalone: false 5296 }] 5297 }], () => [{ 5298 type: ElementRef 5299 }, { 5300 type: Renderer2 5301 }, { 5302 type: SelectControlValueAccessor, 5303 decorators: [{ 5304 type: Optional 5305 }, { 5306 type: Host 5307 }] 5308 }], { 5309 ngValue: [{ 5310 type: Input, 5311 args: ["ngValue"] 5312 }], 5313 value: [{ 5314 type: Input, 5315 args: ["value"] 5316 }] 5317 }); 5318})(); 5319var SELECT_MULTIPLE_VALUE_ACCESSOR = { 5320 provide: NG_VALUE_ACCESSOR, 5321 useExisting: forwardRef(() => SelectMultipleControlValueAccessor), 5322 multi: true 5323}; 5324function _buildValueString(id, value) { 5325 if (id == null) return `${value}`; 5326 if (typeof value === "string") value = `'${value}'`; 5327 if (value && typeof value === "object") value = "Object"; 5328 return `${id}: ${value}`.slice(0, 50); 5329} 5330function _extractId(valueString) { 5331 return valueString.split(":")[0]; 5332} 5333var SelectMultipleControlValueAccessor = class _SelectMultipleControlValueAccessor extends BuiltInControlValueAccessor { 5334 /** 5335 * The current value. 5336 * @docs-private 5337 */ 5338 value; 5339 /** @internal */ 5340 _optionMap = /* @__PURE__ */ new Map(); 5341 /** @internal */ 5342 _idCounter = 0; 5343 /** 5344 * @description 5345 * Tracks the option comparison algorithm for tracking identities when 5346 * checking for changes. 5347 */ 5348 set compareWith(fn) { 5349 if (typeof fn !== "function" && (typeof ngDevMode === "undefined" || ngDevMode)) { 5350 throw new RuntimeError(1201, `compareWith must be a function, but received ${JSON.stringify(fn)}`); 5351 } 5352 this._compareWith = fn; 5353 } 5354 _compareWith = Object.is; 5355 /** 5356 * Sets the "value" property on one or of more of the select's options. 5357 * @docs-private 5358 */ 5359 writeValue(value) { 5360 this.value = value; 5361 let optionSelectedStateSetter; 5362 if (Array.isArray(value)) { 5363 const ids = value.map((v) => this._getOptionId(v)); 5364 optionSelectedStateSetter = (opt, o) => { 5365 opt._setSelected(ids.indexOf(o.toString()) > -1); 5366 }; 5367 } else { 5368 optionSelectedStateSetter = (opt, o) => { 5369 opt._setSelected(false); 5370 }; 5371 } 5372 this._optionMap.forEach(optionSelectedStateSetter); 5373 } 5374 /** 5375 * Registers a function called when the control value changes 5376 * and writes an array of the selected options. 5377 * @docs-private 5378 */ 5379 registerOnChange(fn) { 5380 this.onChange = (element) => { 5381 const selected = []; 5382 const selectedOptions = element.selectedOptions; 5383 if (selectedOptions !== void 0) { 5384 const options = selectedOptions; 5385 for (let i = 0; i < options.length; i++) { 5386 const opt = options[i]; 5387 const val = this._getOptionValue(opt.value); 5388 selected.push(val); 5389 } 5390 } else { 5391 const options = element.options; 5392 for (let i = 0; i < options.length; i++) { 5393 const opt = options[i]; 5394 if (opt.selected) { 5395 const val = this._getOptionValue(opt.value); 5396 selected.push(val); 5397 } 5398 } 5399 } 5400 this.value = selected; 5401 fn(selected); 5402 }; 5403 } 5404 /** @internal */ 5405 _registerOption(value) { 5406 const id = (this._idCounter++).toString(); 5407 this._optionMap.set(id, value); 5408 return id; 5409 } 5410 /** @internal */ 5411 _getOptionId(value) { 5412 for (const id of this._optionMap.keys()) { 5413 if (this._compareWith(this._optionMap.get(id)._value, value)) return id; 5414 } 5415 return null; 5416 } 5417 /** @internal */ 5418 _getOptionValue(valueString) { 5419 const id = _extractId(valueString); 5420 return this._optionMap.has(id) ? this._optionMap.get(id)._value : valueString; 5421 } 5422 static \u0275fac = /* @__PURE__ */ (() => { 5423 let \u0275SelectMultipleControlValueAccessor_BaseFactory; 5424 return function SelectMultipleControlValueAccessor_Factory(__ngFactoryType__) { 5425 return (\u0275SelectMultipleControlValueAccessor_BaseFactory || (\u0275SelectMultipleControlValueAccessor_BaseFactory = \u0275\u0275getInheritedFactory(_SelectMultipleControlValueAccessor)))(__ngFactoryType__ || _SelectMultipleControlValueAccessor); 5426 }; 5427 })(); 5428 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 5429 type: _SelectMultipleControlValueAccessor, 5430 selectors: [["select", "multiple", "", "formControlName", ""], ["select", "multiple", "", "formControl", ""], ["select", "multiple", "", "ngModel", ""]], 5431 hostBindings: function SelectMultipleControlValueAccessor_HostBindings(rf, ctx) { 5432 if (rf & 1) { 5433 \u0275\u0275listener("change", function SelectMultipleControlValueAccessor_change_HostBindingHandler($event) { 5434 return ctx.onChange($event.target); 5435 })("blur", function SelectMultipleControlValueAccessor_blur_HostBindingHandler() { 5436 return ctx.onTouched(); 5437 }); 5438 } 5439 }, 5440 inputs: { 5441 compareWith: "compareWith" 5442 }, 5443 standalone: false, 5444 features: [\u0275\u0275ProvidersFeature([SELECT_MULTIPLE_VALUE_ACCESSOR]), \u0275\u0275InheritDefinitionFeature] 5445 }); 5446}; 5447(() => { 5448 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(SelectMultipleControlValueAccessor, [{ 5449 type: Directive, 5450 args: [{ 5451 selector: "select[multiple][formControlName],select[multiple][formControl],select[multiple][ngModel]", 5452 host: { 5453 "(change)": "onChange($event.target)", 5454 "(blur)": "onTouched()" 5455 }, 5456 providers: [SELECT_MULTIPLE_VALUE_ACCESSOR], 5457 standalone: false 5458 }] 5459 }], null, { 5460 compareWith: [{ 5461 type: Input 5462 }] 5463 }); 5464})(); 5465var \u0275NgSelectMultipleOption = class _\u0275NgSelectMultipleOption { 5466 _element; 5467 _renderer; 5468 _select; 5469 id; 5470 /** @internal */ 5471 _value; 5472 constructor(_element, _renderer, _select) { 5473 this._element = _element; 5474 this._renderer = _renderer; 5475 this._select = _select; 5476 if (this._select) { 5477 this.id = this._select._registerOption(this); 5478 } 5479 } 5480 /** 5481 * @description 5482 * Tracks the value bound to the option element. Unlike the value binding, 5483 * ngValue supports binding to objects. 5484 */ 5485 set ngValue(value) { 5486 if (this._select == null) return; 5487 this._value = value; 5488 this._setElementValue(_buildValueString(this.id, value)); 5489 this._select.writeValue(this._select.value); 5490 } 5491 /** 5492 * @description 5493 * Tracks simple string values bound to the option element. 5494 * For objects, use the `ngValue` input binding. 5495 */ 5496 set value(value) { 5497 if (this._select) { 5498 this._value = value; 5499 this._setElementValue(_buildValueString(this.id, value)); 5500 this._select.writeValue(this._select.value); 5501 } else { 5502 this._setElementValue(value); 5503 } 5504 } 5505 /** @internal */ 5506 _setElementValue(value) { 5507 this._renderer.setProperty(this._element.nativeElement, "value", value); 5508 } 5509 /** @internal */ 5510 _setSelected(selected) { 5511 this._renderer.setProperty(this._element.nativeElement, "selected", selected); 5512 } 5513 /** @docs-private */ 5514 ngOnDestroy() { 5515 if (this._select) { 5516 this._select._optionMap.delete(this.id); 5517 this._select.writeValue(this._select.value); 5518 } 5519 } 5520 static \u0275fac = function \u0275NgSelectMultipleOption_Factory(__ngFactoryType__) { 5521 return new (__ngFactoryType__ || _\u0275NgSelectMultipleOption)(\u0275\u0275directiveInject(ElementRef), \u0275\u0275directiveInject(Renderer2), \u0275\u0275directiveInject(SelectMultipleControlValueAccessor, 9)); 5522 }; 5523 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 5524 type: _\u0275NgSelectMultipleOption, 5525 selectors: [["option"]], 5526 inputs: { 5527 ngValue: "ngValue", 5528 value: "value" 5529 }, 5530 standalone: false 5531 }); 5532}; 5533(() => { 5534 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(\u0275NgSelectMultipleOption, [{ 5535 type: Directive, 5536 args: [{ 5537 selector: "option", 5538 standalone: false 5539 }] 5540 }], () => [{ 5541 type: ElementRef 5542 }, { 5543 type: Renderer2 5544 }, { 5545 type: SelectMultipleControlValueAccessor, 5546 decorators: [{ 5547 type: Optional 5548 }, { 5549 type: Host 5550 }] 5551 }], { 5552 ngValue: [{ 5553 type: Input, 5554 args: ["ngValue"] 5555 }], 5556 value: [{ 5557 type: Input, 5558 args: ["value"] 5559 }] 5560 }); 5561})(); 5562function toInteger(value) { 5563 return typeof value === "number" ? value : parseInt(value, 10); 5564} 5565function toFloat(value) { 5566 return typeof value === "number" ? value : parseFloat(value); 5567} 5568var AbstractValidatorDirective = class _AbstractValidatorDirective { 5569 _validator = nullValidator; 5570 _onChange; 5571 /** 5572 * A flag that tracks whether this validator is enabled. 5573 * 5574 * Marking it `internal` (vs `protected`), so that this flag can be used in host bindings of 5575 * directive classes that extend this base class. 5576 * @internal 5577 */ 5578 _enabled; 5579 /** @docs-private */ 5580 ngOnChanges(changes) { 5581 if (this.inputName in changes) { 5582 const input = this.normalizeInput(changes[this.inputName].currentValue); 5583 this._enabled = this.enabled(input); 5584 this._validator = this._enabled ? this.createValidator(input) : nullValidator; 5585 if (this._onChange) { 5586 this._onChange(); 5587 } 5588 } 5589 } 5590 /** @docs-private */ 5591 validate(control) { 5592 return this._validator(control); 5593 } 5594 /** @docs-private */ 5595 registerOnValidatorChange(fn) { 5596 this._onChange = fn; 5597 } 5598 /** 5599 * @description 5600 * Determines whether this validator should be active or not based on an input. 5601 * Base class implementation checks whether an input is defined (if the value is different from 5602 * `null` and `undefined`). Validator classes that extend this base class can override this 5603 * function with the logic specific to a particular validator directive. 5604 */ 5605 enabled(input) { 5606 return input != null; 5607 } 5608 static \u0275fac = function AbstractValidatorDirective_Factory(__ngFactoryType__) { 5609 return new (__ngFactoryType__ || _AbstractValidatorDirective)(); 5610 }; 5611 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 5612 type: _AbstractValidatorDirective, 5613 features: [\u0275\u0275NgOnChangesFeature] 5614 }); 5615}; 5616(() => { 5617 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(AbstractValidatorDirective, [{ 5618 type: Directive 5619 }], null, null); 5620})(); 5621var MAX_VALIDATOR = { 5622 provide: NG_VALIDATORS, 5623 useExisting: forwardRef(() => MaxValidator), 5624 multi: true 5625}; 5626var MaxValidator = class _MaxValidator extends AbstractValidatorDirective { 5627 /** 5628 * @description 5629 * Tracks changes to the max bound to this directive. 5630 */ 5631 max; 5632 /** @internal */ 5633 inputName = "max"; 5634 /** @internal */ 5635 normalizeInput = (input) => toFloat(input); 5636 /** @internal */ 5637 createValidator = (max) => maxValidator(max); 5638 static \u0275fac = /* @__PURE__ */ (() => { 5639 let \u0275MaxValidator_BaseFactory; 5640 return function MaxValidator_Factory(__ngFactoryType__) { 5641 return (\u0275MaxValidator_BaseFactory || (\u0275MaxValidator_BaseFactory = \u0275\u0275getInheritedFactory(_MaxValidator)))(__ngFactoryType__ || _MaxValidator); 5642 }; 5643 })(); 5644 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 5645 type: _MaxValidator, 5646 selectors: [["input", "type", "number", "max", "", "formControlName", ""], ["input", "type", "number", "max", "", "formControl", ""], ["input", "type", "number", "max", "", "ngModel", ""]], 5647 hostVars: 1, 5648 hostBindings: function MaxValidator_HostBindings(rf, ctx) { 5649 if (rf & 2) { 5650 \u0275\u0275attribute("max", ctx._enabled ? ctx.max : null); 5651 } 5652 }, 5653 inputs: { 5654 max: "max" 5655 }, 5656 standalone: false, 5657 features: [\u0275\u0275ProvidersFeature([MAX_VALIDATOR]), \u0275\u0275InheritDefinitionFeature] 5658 }); 5659}; 5660(() => { 5661 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(MaxValidator, [{ 5662 type: Directive, 5663 args: [{ 5664 selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]", 5665 providers: [MAX_VALIDATOR], 5666 host: { 5667 "[attr.max]": "_enabled ? max : null" 5668 }, 5669 standalone: false 5670 }] 5671 }], null, { 5672 max: [{ 5673 type: Input 5674 }] 5675 }); 5676})(); 5677var MIN_VALIDATOR = { 5678 provide: NG_VALIDATORS, 5679 useExisting: forwardRef(() => MinValidator), 5680 multi: true 5681}; 5682var MinValidator = class _MinValidator extends AbstractValidatorDirective { 5683 /** 5684 * @description 5685 * Tracks changes to the min bound to this directive. 5686 */ 5687 min; 5688 /** @internal */ 5689 inputName = "min"; 5690 /** @internal */ 5691 normalizeInput = (input) => toFloat(input); 5692 /** @internal */ 5693 createValidator = (min) => minValidator(min); 5694 static \u0275fac = /* @__PURE__ */ (() => { 5695 let \u0275MinValidator_BaseFactory; 5696 return function MinValidator_Factory(__ngFactoryType__) { 5697 return (\u0275MinValidator_BaseFactory || (\u0275MinValidator_BaseFactory = \u0275\u0275getInheritedFactory(_MinValidator)))(__ngFactoryType__ || _MinValidator); 5698 }; 5699 })(); 5700 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 5701 type: _MinValidator, 5702 selectors: [["input", "type", "number", "min", "", "formControlName", ""], ["input", "type", "number", "min", "", "formControl", ""], ["input", "type", "number", "min", "", "ngModel", ""]], 5703 hostVars: 1, 5704 hostBindings: function MinValidator_HostBindings(rf, ctx) { 5705 if (rf & 2) { 5706 \u0275\u0275attribute("min", ctx._enabled ? ctx.min : null); 5707 } 5708 }, 5709 inputs: { 5710 min: "min" 5711 }, 5712 standalone: false, 5713 features: [\u0275\u0275ProvidersFeature([MIN_VALIDATOR]), \u0275\u0275InheritDefinitionFeature] 5714 }); 5715}; 5716(() => { 5717 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(MinValidator, [{ 5718 type: Directive, 5719 args: [{ 5720 selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", 5721 providers: [MIN_VALIDATOR], 5722 host: { 5723 "[attr.min]": "_enabled ? min : null" 5724 }, 5725 standalone: false 5726 }] 5727 }], null, { 5728 min: [{ 5729 type: Input 5730 }] 5731 }); 5732})(); 5733var REQUIRED_VALIDATOR = { 5734 provide: NG_VALIDATORS, 5735 useExisting: forwardRef(() => RequiredValidator), 5736 multi: true 5737}; 5738var CHECKBOX_REQUIRED_VALIDATOR = { 5739 provide: NG_VALIDATORS, 5740 useExisting: forwardRef(() => CheckboxRequiredValidator), 5741 multi: true 5742}; 5743var RequiredValidator = class _RequiredValidator extends AbstractValidatorDirective { 5744 /** 5745 * @description 5746 * Tracks changes to the required attribute bound to this directive. 5747 */ 5748 required; 5749 /** @internal */ 5750 inputName = "required"; 5751 /** @internal */ 5752 normalizeInput = booleanAttribute; 5753 /** @internal */ 5754 createValidator = (input) => requiredValidator; 5755 /** @docs-private */ 5756 enabled(input) { 5757 return input; 5758 } 5759 static \u0275fac = /* @__PURE__ */ (() => { 5760 let \u0275RequiredValidator_BaseFactory; 5761 return function RequiredValidator_Factory(__ngFactoryType__) { 5762 return (\u0275RequiredValidator_BaseFactory || (\u0275RequiredValidator_BaseFactory = \u0275\u0275getInheritedFactory(_RequiredValidator)))(__ngFactoryType__ || _RequiredValidator); 5763 }; 5764 })(); 5765 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 5766 type: _RequiredValidator, 5767 selectors: [["", "required", "", "formControlName", "", 3, "type", "checkbox"], ["", "required", "", "formControl", "", 3, "type", "checkbox"], ["", "required", "", "ngModel", "", 3, "type", "checkbox"]], 5768 hostVars: 1, 5769 hostBindings: function RequiredValidator_HostBindings(rf, ctx) { 5770 if (rf & 2) { 5771 \u0275\u0275attribute("required", ctx._enabled ? "" : null); 5772 } 5773 }, 5774 inputs: { 5775 required: "required" 5776 }, 5777 standalone: false, 5778 features: [\u0275\u0275ProvidersFeature([REQUIRED_VALIDATOR]), \u0275\u0275InheritDefinitionFeature] 5779 }); 5780}; 5781(() => { 5782 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(RequiredValidator, [{ 5783 type: Directive, 5784 args: [{ 5785 selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", 5786 providers: [REQUIRED_VALIDATOR], 5787 host: { 5788 "[attr.required]": '_enabled ? "" : null' 5789 }, 5790 standalone: false 5791 }] 5792 }], null, { 5793 required: [{ 5794 type: Input 5795 }] 5796 }); 5797})(); 5798var CheckboxRequiredValidator = class _CheckboxRequiredValidator extends RequiredValidator { 5799 /** @internal */ 5800 createValidator = (input) => requiredTrueValidator; 5801 static \u0275fac = /* @__PURE__ */ (() => { 5802 let \u0275CheckboxRequiredValidator_BaseFactory; 5803 return function CheckboxRequiredValidator_Factory(__ngFactoryType__) { 5804 return (\u0275CheckboxRequiredValidator_BaseFactory || (\u0275CheckboxRequiredValidator_BaseFactory = \u0275\u0275getInheritedFactory(_CheckboxRequiredValidator)))(__ngFactoryType__ || _CheckboxRequiredValidator); 5805 }; 5806 })(); 5807 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 5808 type: _CheckboxRequiredValidator, 5809 selectors: [["input", "type", "checkbox", "required", "", "formControlName", ""], ["input", "type", "checkbox", "required", "", "formControl", ""], ["input", "type", "checkbox", "required", "", "ngModel", ""]], 5810 hostVars: 1, 5811 hostBindings: function CheckboxRequiredValidator_HostBindings(rf, ctx) { 5812 if (rf & 2) { 5813 \u0275\u0275attribute("required", ctx._enabled ? "" : null); 5814 } 5815 }, 5816 standalone: false, 5817 features: [\u0275\u0275ProvidersFeature([CHECKBOX_REQUIRED_VALIDATOR]), \u0275\u0275InheritDefinitionFeature] 5818 }); 5819}; 5820(() => { 5821 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(CheckboxRequiredValidator, [{ 5822 type: Directive, 5823 args: [{ 5824 selector: "input[type=checkbox][required][formControlName],input[type=checkbox][required][formControl],input[type=checkbox][required][ngModel]", 5825 providers: [CHECKBOX_REQUIRED_VALIDATOR], 5826 host: { 5827 "[attr.required]": '_enabled ? "" : null' 5828 }, 5829 standalone: false 5830 }] 5831 }], null, null); 5832})(); 5833var EMAIL_VALIDATOR = { 5834 provide: NG_VALIDATORS, 5835 useExisting: forwardRef(() => EmailValidator), 5836 multi: true 5837}; 5838var EmailValidator = class _EmailValidator extends AbstractValidatorDirective { 5839 /** 5840 * @description 5841 * Tracks changes to the email attribute bound to this directive. 5842 */ 5843 email; 5844 /** @internal */ 5845 inputName = "email"; 5846 /** @internal */ 5847 normalizeInput = booleanAttribute; 5848 /** @internal */ 5849 createValidator = (input) => emailValidator; 5850 /** @docs-private */ 5851 enabled(input) { 5852 return input; 5853 } 5854 static \u0275fac = /* @__PURE__ */ (() => { 5855 let \u0275EmailValidator_BaseFactory; 5856 return function EmailValidator_Factory(__ngFactoryType__) { 5857 return (\u0275EmailValidator_BaseFactory || (\u0275EmailValidator_BaseFactory = \u0275\u0275getInheritedFactory(_EmailValidator)))(__ngFactoryType__ || _EmailValidator); 5858 }; 5859 })(); 5860 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 5861 type: _EmailValidator, 5862 selectors: [["", "email", "", "formControlName", ""], ["", "email", "", "formControl", ""], ["", "email", "", "ngModel", ""]], 5863 inputs: { 5864 email: "email" 5865 }, 5866 standalone: false, 5867 features: [\u0275\u0275ProvidersFeature([EMAIL_VALIDATOR]), \u0275\u0275InheritDefinitionFeature] 5868 }); 5869}; 5870(() => { 5871 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(EmailValidator, [{ 5872 type: Directive, 5873 args: [{ 5874 selector: "[email][formControlName],[email][formControl],[email][ngModel]", 5875 providers: [EMAIL_VALIDATOR], 5876 standalone: false 5877 }] 5878 }], null, { 5879 email: [{ 5880 type: Input 5881 }] 5882 }); 5883})(); 5884var MIN_LENGTH_VALIDATOR = { 5885 provide: NG_VALIDATORS, 5886 useExisting: forwardRef(() => MinLengthValidator), 5887 multi: true 5888}; 5889var MinLengthValidator = class _MinLengthValidator extends AbstractValidatorDirective { 5890 /** 5891 * @description 5892 * Tracks changes to the minimum length bound to this directive. 5893 */ 5894 minlength; 5895 /** @internal */ 5896 inputName = "minlength"; 5897 /** @internal */ 5898 normalizeInput = (input) => toInteger(input); 5899 /** @internal */ 5900 createValidator = (minlength) => minLengthValidator(minlength); 5901 static \u0275fac = /* @__PURE__ */ (() => { 5902 let \u0275MinLengthValidator_BaseFactory; 5903 return function MinLengthValidator_Factory(__ngFactoryType__) { 5904 return (\u0275MinLengthValidator_BaseFactory || (\u0275MinLengthValidator_BaseFactory = \u0275\u0275getInheritedFactory(_MinLengthValidator)))(__ngFactoryType__ || _MinLengthValidator); 5905 }; 5906 })(); 5907 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 5908 type: _MinLengthValidator, 5909 selectors: [["", "minlength", "", "formControlName", ""], ["", "minlength", "", "formControl", ""], ["", "minlength", "", "ngModel", ""]], 5910 hostVars: 1, 5911 hostBindings: function MinLengthValidator_HostBindings(rf, ctx) { 5912 if (rf & 2) { 5913 \u0275\u0275attribute("minlength", ctx._enabled ? ctx.minlength : null); 5914 } 5915 }, 5916 inputs: { 5917 minlength: "minlength" 5918 }, 5919 standalone: false, 5920 features: [\u0275\u0275ProvidersFeature([MIN_LENGTH_VALIDATOR]), \u0275\u0275InheritDefinitionFeature] 5921 }); 5922}; 5923(() => { 5924 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(MinLengthValidator, [{ 5925 type: Directive, 5926 args: [{ 5927 selector: "[minlength][formControlName],[minlength][formControl],[minlength][ngModel]", 5928 providers: [MIN_LENGTH_VALIDATOR], 5929 host: { 5930 "[attr.minlength]": "_enabled ? minlength : null" 5931 }, 5932 standalone: false 5933 }] 5934 }], null, { 5935 minlength: [{ 5936 type: Input 5937 }] 5938 }); 5939})(); 5940var MAX_LENGTH_VALIDATOR = { 5941 provide: NG_VALIDATORS, 5942 useExisting: forwardRef(() => MaxLengthValidator), 5943 multi: true 5944}; 5945var MaxLengthValidator = class _MaxLengthValidator extends AbstractValidatorDirective { 5946 /** 5947 * @description 5948 * Tracks changes to the maximum length bound to this directive. 5949 */ 5950 maxlength; 5951 /** @internal */ 5952 inputName = "maxlength"; 5953 /** @internal */ 5954 normalizeInput = (input) => toInteger(input); 5955 /** @internal */ 5956 createValidator = (maxlength) => maxLengthValidator(maxlength); 5957 static \u0275fac = /* @__PURE__ */ (() => { 5958 let \u0275MaxLengthValidator_BaseFactory; 5959 return function MaxLengthValidator_Factory(__ngFactoryType__) { 5960 return (\u0275MaxLengthValidator_BaseFactory || (\u0275MaxLengthValidator_BaseFactory = \u0275\u0275getInheritedFactory(_MaxLengthValidator)))(__ngFactoryType__ || _MaxLengthValidator); 5961 }; 5962 })(); 5963 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 5964 type: _MaxLengthValidator, 5965 selectors: [["", "maxlength", "", "formControlName", ""], ["", "maxlength", "", "formControl", ""], ["", "maxlength", "", "ngModel", ""]], 5966 hostVars: 1, 5967 hostBindings: function MaxLengthValidator_HostBindings(rf, ctx) { 5968 if (rf & 2) { 5969 \u0275\u0275attribute("maxlength", ctx._enabled ? ctx.maxlength : null); 5970 } 5971 }, 5972 inputs: { 5973 maxlength: "maxlength" 5974 }, 5975 standalone: false, 5976 features: [\u0275\u0275ProvidersFeature([MAX_LENGTH_VALIDATOR]), \u0275\u0275InheritDefinitionFeature] 5977 }); 5978}; 5979(() => { 5980 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(MaxLengthValidator, [{ 5981 type: Directive, 5982 args: [{ 5983 selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", 5984 providers: [MAX_LENGTH_VALIDATOR], 5985 host: { 5986 "[attr.maxlength]": "_enabled ? maxlength : null" 5987 }, 5988 standalone: false 5989 }] 5990 }], null, { 5991 maxlength: [{ 5992 type: Input 5993 }] 5994 }); 5995})(); 5996var PATTERN_VALIDATOR = { 5997 provide: NG_VALIDATORS, 5998 useExisting: forwardRef(() => PatternValidator), 5999 multi: true 6000}; 6001var PatternValidator = class _PatternValidator extends AbstractValidatorDirective { 6002 /** 6003 * @description 6004 * Tracks changes to the pattern bound to this directive. 6005 */ 6006 pattern; 6007 // This input is always defined, since the name matches selector. 6008 /** @internal */ 6009 inputName = "pattern"; 6010 /** @internal */ 6011 normalizeInput = (input) => input; 6012 /** @internal */ 6013 createValidator = (input) => patternValidator(input); 6014 static \u0275fac = /* @__PURE__ */ (() => { 6015 let \u0275PatternValidator_BaseFactory; 6016 return function PatternValidator_Factory(__ngFactoryType__) { 6017 return (\u0275PatternValidator_BaseFactory || (\u0275PatternValidator_BaseFactory = \u0275\u0275getInheritedFactory(_PatternValidator)))(__ngFactoryType__ || _PatternValidator); 6018 }; 6019 })(); 6020 static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({ 6021 type: _PatternValidator, 6022 selectors: [["", "pattern", "", "formControlName", ""], ["", "pattern", "", "formControl", ""], ["", "pattern", "", "ngModel", ""]], 6023 hostVars: 1, 6024 hostBindings: function PatternValidator_HostBindings(rf, ctx) { 6025 if (rf & 2) { 6026 \u0275\u0275attribute("pattern", ctx._enabled ? ctx.pattern : null); 6027 } 6028 }, 6029 inputs: { 6030 pattern: "pattern" 6031 }, 6032 standalone: false, 6033 features: [\u0275\u0275ProvidersFeature([PATTERN_VALIDATOR]), \u0275\u0275InheritDefinitionFeature] 6034 }); 6035}; 6036(() => { 6037 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(PatternValidator, [{ 6038 type: Directive, 6039 args: [{ 6040 selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", 6041 providers: [PATTERN_VALIDATOR], 6042 host: { 6043 "[attr.pattern]": "_enabled ? pattern : null" 6044 }, 6045 standalone: false 6046 }] 6047 }], null, { 6048 pattern: [{ 6049 type: Input 6050 }] 6051 }); 6052})(); 6053var SHARED_FORM_DIRECTIVES = [\u0275NgNoValidate, NgSelectOption, \u0275NgSelectMultipleOption, DefaultValueAccessor, NumberValueAccessor, RangeValueAccessor, CheckboxControlValueAccessor, SelectControlValueAccessor, SelectMultipleControlValueAccessor, RadioControlValueAccessor, NgControlStatus, NgControlStatusGroup, RequiredValidator, MinLengthValidator, MaxLengthValidator, PatternValidator, CheckboxRequiredValidator, EmailValidator, MinValidator, MaxValidator]; 6054var TEMPLATE_DRIVEN_DIRECTIVES = [NgModel, NgModelGroup, NgForm]; 6055var REACTIVE_DRIVEN_DIRECTIVES = [FormControlDirective, FormGroupDirective, FormControlName, FormGroupName, FormArrayName]; 6056var \u0275InternalFormsSharedModule = class _\u0275InternalFormsSharedModule { 6057 static \u0275fac = function \u0275InternalFormsSharedModule_Factory(__ngFactoryType__) { 6058 return new (__ngFactoryType__ || _\u0275InternalFormsSharedModule)(); 6059 }; 6060 static \u0275mod = /* @__PURE__ */ \u0275\u0275defineNgModule({ 6061 type: _\u0275InternalFormsSharedModule, 6062 declarations: [\u0275NgNoValidate, NgSelectOption, \u0275NgSelectMultipleOption, DefaultValueAccessor, NumberValueAccessor, RangeValueAccessor, CheckboxControlValueAccessor, SelectControlValueAccessor, SelectMultipleControlValueAccessor, RadioControlValueAccessor, NgControlStatus, NgControlStatusGroup, RequiredValidator, MinLengthValidator, MaxLengthValidator, PatternValidator, CheckboxRequiredValidator, EmailValidator, MinValidator, MaxValidator], 6063 exports: [\u0275NgNoValidate, NgSelectOption, \u0275NgSelectMultipleOption, DefaultValueAccessor, NumberValueAccessor, RangeValueAccessor, CheckboxControlValueAccessor, SelectControlValueAccessor, SelectMultipleControlValueAccessor, RadioControlValueAccessor, NgControlStatus, NgControlStatusGroup, RequiredValidator, MinLengthValidator, MaxLengthValidator, PatternValidator, CheckboxRequiredValidator, EmailValidator, MinValidator, MaxValidator]
vendor: 23,360 bytes, lines 6063-6697
6063 6064 }); 6065 static \u0275inj = /* @__PURE__ */ \u0275\u0275defineInjector({}); 6066}; 6067(() => { 6068 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(\u0275InternalFormsSharedModule, [{ 6069 type: NgModule, 6070 args: [{ 6071 declarations: SHARED_FORM_DIRECTIVES, 6072 exports: SHARED_FORM_DIRECTIVES 6073 }] 6074 }], null, null); 6075})(); 6076var FormArray = class extends AbstractControl { 6077 /** 6078 * Creates a new `FormArray` instance. 6079 * 6080 * @param controls An array of child controls. Each child control is given an index 6081 * where it is registered. 6082 * 6083 * @param validatorOrOpts A synchronous validator function, or an array of 6084 * such functions, or an `AbstractControlOptions` object that contains validation functions 6085 * and a validation trigger. 6086 * 6087 * @param asyncValidator A single async validator or array of async validator functions 6088 * 6089 */ 6090 constructor(controls, validatorOrOpts, asyncValidator) { 6091 super(pickValidators(validatorOrOpts), pickAsyncValidators(asyncValidator, validatorOrOpts)); 6092 this.controls = controls; 6093 this._initObservables(); 6094 this._setUpdateStrategy(validatorOrOpts); 6095 this._setUpControls(); 6096 this.updateValueAndValidity({ 6097 onlySelf: true, 6098 // If `asyncValidator` is present, it will trigger control status change from `PENDING` to 6099 // `VALID` or `INVALID`. 6100 // The status should be broadcasted via the `statusChanges` observable, so we set `emitEvent` 6101 // to `true` to allow that during the control creation process. 6102 emitEvent: !!this.asyncValidator 6103 }); 6104 } 6105 controls; 6106 /** 6107 * Get the `AbstractControl` at the given `index` in the array. 6108 * 6109 * @param index Index in the array to retrieve the control. If `index` is negative, it will wrap 6110 * around from the back, and if index is greatly negative (less than `-length`), the result is 6111 * undefined. This behavior is the same as `Array.at(index)`. 6112 */ 6113 at(index) { 6114 return this.controls[this._adjustIndex(index)]; 6115 } 6116 /** 6117 * Insert a new `AbstractControl` at the end of the array. 6118 * 6119 * @param control Form control to be inserted 6120 * @param options Specifies whether this FormArray instance should emit events after a new 6121 * control is added. 6122 * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and 6123 * `valueChanges` observables emit events with the latest status and value when the control is 6124 * inserted. When false, no events are emitted. 6125 */ 6126 push(control, options = {}) { 6127 this.controls.push(control); 6128 this._registerControl(control); 6129 this.updateValueAndValidity({ 6130 emitEvent: options.emitEvent 6131 }); 6132 this._onCollectionChange(); 6133 } 6134 /** 6135 * Insert a new `AbstractControl` at the given `index` in the array. 6136 * 6137 * @param index Index in the array to insert the control. If `index` is negative, wraps around 6138 * from the back. If `index` is greatly negative (less than `-length`), prepends to the array. 6139 * This behavior is the same as `Array.splice(index, 0, control)`. 6140 * @param control Form control to be inserted 6141 * @param options Specifies whether this FormArray instance should emit events after a new 6142 * control is inserted. 6143 * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and 6144 * `valueChanges` observables emit events with the latest status and value when the control is 6145 * inserted. When false, no events are emitted. 6146 */ 6147 insert(index, control, options = {}) { 6148 this.controls.splice(index, 0, control); 6149 this._registerControl(control); 6150 this.updateValueAndValidity({ 6151 emitEvent: options.emitEvent 6152 }); 6153 } 6154 /** 6155 * Remove the control at the given `index` in the array. 6156 * 6157 * @param index Index in the array to remove the control. If `index` is negative, wraps around 6158 * from the back. If `index` is greatly negative (less than `-length`), removes the first 6159 * element. This behavior is the same as `Array.splice(index, 1)`. 6160 * @param options Specifies whether this FormArray instance should emit events after a 6161 * control is removed. 6162 * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and 6163 * `valueChanges` observables emit events with the latest status and value when the control is 6164 * removed. When false, no events are emitted. 6165 */ 6166 removeAt(index, options = {}) { 6167 let adjustedIndex = this._adjustIndex(index); 6168 if (adjustedIndex < 0) adjustedIndex = 0; 6169 if (this.controls[adjustedIndex]) this.controls[adjustedIndex]._registerOnCollectionChange(() => { 6170 }); 6171 this.controls.splice(adjustedIndex, 1); 6172 this.updateValueAndValidity({ 6173 emitEvent: options.emitEvent 6174 }); 6175 } 6176 /** 6177 * Replace an existing control. 6178 * 6179 * @param index Index in the array to replace the control. If `index` is negative, wraps around 6180 * from the back. If `index` is greatly negative (less than `-length`), replaces the first 6181 * element. This behavior is the same as `Array.splice(index, 1, control)`. 6182 * @param control The `AbstractControl` control to replace the existing control 6183 * @param options Specifies whether this FormArray instance should emit events after an 6184 * existing control is replaced with a new one. 6185 * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and 6186 * `valueChanges` observables emit events with the latest status and value when the control is 6187 * replaced with a new one. When false, no events are emitted. 6188 */ 6189 setControl(index, control, options = {}) { 6190 let adjustedIndex = this._adjustIndex(index); 6191 if (adjustedIndex < 0) adjustedIndex = 0; 6192 if (this.controls[adjustedIndex]) this.controls[adjustedIndex]._registerOnCollectionChange(() => { 6193 }); 6194 this.controls.splice(adjustedIndex, 1); 6195 if (control) { 6196 this.controls.splice(adjustedIndex, 0, control); 6197 this._registerControl(control); 6198 } 6199 this.updateValueAndValidity({ 6200 emitEvent: options.emitEvent 6201 }); 6202 this._onCollectionChange(); 6203 } 6204 /** 6205 * Length of the control array. 6206 */ 6207 get length() { 6208 return this.controls.length; 6209 } 6210 /** 6211 * Sets the value of the `FormArray`. It accepts an array that matches 6212 * the structure of the control. 6213 * 6214 * This method performs strict checks, and throws an error if you try 6215 * to set the value of a control that doesn't exist or if you exclude the 6216 * value of a control. 6217 * 6218 * @usageNotes 6219 * ### Set the values for the controls in the form array 6220 * 6221 * ```ts 6222 * const arr = new FormArray([ 6223 * new FormControl(), 6224 * new FormControl() 6225 * ]); 6226 * console.log(arr.value); // [null, null] 6227 * 6228 * arr.setValue(['Nancy', 'Drew']); 6229 * console.log(arr.value); // ['Nancy', 'Drew'] 6230 * ``` 6231 * 6232 * @param value Array of values for the controls 6233 * @param options Configure options that determine how the control propagates changes and 6234 * emits events after the value changes 6235 * 6236 * * `onlySelf`: When true, each change only affects this control, and not its parent. Default 6237 * is false. 6238 * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and 6239 * `valueChanges` 6240 * observables emit events with the latest status and value when the control value is updated. 6241 * When false, no events are emitted. 6242 * The configuration options are passed to the {@link AbstractControl#updateValueAndValidity 6243 * updateValueAndValidity} method. 6244 */ 6245 setValue(value, options = {}) { 6246 assertAllValuesPresent(this, false, value); 6247 value.forEach((newValue, index) => { 6248 assertControlPresent(this, false, index); 6249 this.at(index).setValue(newValue, { 6250 onlySelf: true, 6251 emitEvent: options.emitEvent 6252 }); 6253 }); 6254 this.updateValueAndValidity(options); 6255 } 6256 /** 6257 * Patches the value of the `FormArray`. It accepts an array that matches the 6258 * structure of the control, and does its best to match the values to the correct 6259 * controls in the group. 6260 * 6261 * It accepts both super-sets and sub-sets of the array without throwing an error. 6262 * 6263 * @usageNotes 6264 * ### Patch the values for controls in a form array 6265 * 6266 * ```ts 6267 * const arr = new FormArray([ 6268 * new FormControl(), 6269 * new FormControl() 6270 * ]); 6271 * console.log(arr.value); // [null, null] 6272 * 6273 * arr.patchValue(['Nancy']); 6274 * console.log(arr.value); // ['Nancy', null] 6275 * ``` 6276 * 6277 * @param value Array of latest values for the controls 6278 * @param options Configure options that determine how the control propagates changes and 6279 * emits events after the value changes 6280 * 6281 * * `onlySelf`: When true, each change only affects this control, and not its parent. Default 6282 * is false. 6283 * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and 6284 * `valueChanges` observables emit events with the latest status and value when the control 6285 * value is updated. When false, no events are emitted. The configuration options are passed to 6286 * the {@link AbstractControl#updateValueAndValidity updateValueAndValidity} method. 6287 */ 6288 patchValue(value, options = {}) { 6289 if (value == null) return; 6290 value.forEach((newValue, index) => { 6291 if (this.at(index)) { 6292 this.at(index).patchValue(newValue, { 6293 onlySelf: true, 6294 emitEvent: options.emitEvent 6295 }); 6296 } 6297 }); 6298 this.updateValueAndValidity(options); 6299 } 6300 /** 6301 * Resets the `FormArray` and all descendants are marked `pristine` and `untouched`, and the 6302 * value of all descendants to null or null maps. 6303 * 6304 * You reset to a specific form state by passing in an array of states 6305 * that matches the structure of the control. The state is a standalone value 6306 * or a form state object with both a value and a disabled status. 6307 * 6308 * @usageNotes 6309 * ### Reset the values in a form array 6310 * 6311 * ```ts 6312 * const arr = new FormArray([ 6313 * new FormControl(), 6314 * new FormControl() 6315 * ]); 6316 * arr.reset(['name', 'last name']); 6317 * 6318 * console.log(arr.value); // ['name', 'last name'] 6319 * ``` 6320 * 6321 * ### Reset the values in a form array and the disabled status for the first control 6322 * 6323 * ```ts 6324 * arr.reset([ 6325 * {value: 'name', disabled: true}, 6326 * 'last' 6327 * ]); 6328 * 6329 * console.log(arr.value); // ['last'] 6330 * console.log(arr.at(0).status); // 'DISABLED' 6331 * ``` 6332 * 6333 * @param value Array of values for the controls 6334 * @param options Configure options that determine how the control propagates changes and 6335 * emits events after the value changes 6336 * 6337 * * `onlySelf`: When true, each change only affects this control, and not its parent. Default 6338 * is false. 6339 * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and 6340 * `valueChanges` 6341 * observables emit events with the latest status and value when the control is reset. 6342 * When false, no events are emitted. 6343 * The configuration options are passed to the {@link AbstractControl#updateValueAndValidity 6344 * updateValueAndValidity} method. 6345 */ 6346 reset(value = [], options = {}) { 6347 this._forEachChild((control, index) => { 6348 control.reset(value[index], { 6349 onlySelf: true, 6350 emitEvent: options.emitEvent 6351 }); 6352 }); 6353 this._updatePristine(options, this); 6354 this._updateTouched(options, this); 6355 this.updateValueAndValidity(options); 6356 } 6357 /** 6358 * The aggregate value of the array, including any disabled controls. 6359 * 6360 * Reports all values regardless of disabled status. 6361 */ 6362 getRawValue() { 6363 return this.controls.map((control) => control.getRawValue()); 6364 } 6365 /** 6366 * Remove all controls in the `FormArray`. 6367 * 6368 * @param options Specifies whether this FormArray instance should emit events after all 6369 * controls are removed. 6370 * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and 6371 * `valueChanges` observables emit events with the latest status and value when all controls 6372 * in this FormArray instance are removed. When false, no events are emitted. 6373 * 6374 * @usageNotes 6375 * ### Remove all elements from a FormArray 6376 * 6377 * ```ts 6378 * const arr = new FormArray([ 6379 * new FormControl(), 6380 * new FormControl() 6381 * ]); 6382 * console.log(arr.length); // 2 6383 * 6384 * arr.clear(); 6385 * console.log(arr.length); // 0 6386 * ``` 6387 * 6388 * It's a simpler and more efficient alternative to removing all elements one by one: 6389 * 6390 * ```ts 6391 * const arr = new FormArray([ 6392 * new FormControl(), 6393 * new FormControl() 6394 * ]); 6395 * 6396 * while (arr.length) { 6397 * arr.removeAt(0); 6398 * } 6399 * ``` 6400 */ 6401 clear(options = {}) { 6402 if (this.controls.length < 1) return; 6403 this._forEachChild((control) => control._registerOnCollectionChange(() => { 6404 })); 6405 this.controls.splice(0); 6406 this.updateValueAndValidity({ 6407 emitEvent: options.emitEvent 6408 }); 6409 } 6410 /** 6411 * Adjusts a negative index by summing it with the length of the array. For very negative 6412 * indices, the result may remain negative. 6413 * @internal 6414 */ 6415 _adjustIndex(index) { 6416 return index < 0 ? index + this.length : index; 6417 } 6418 /** @internal */ 6419 _syncPendingControls() { 6420 let subtreeUpdated = this.controls.reduce((updated, child) => { 6421 return child._syncPendingControls() ? true : updated; 6422 }, false); 6423 if (subtreeUpdated) this.updateValueAndValidity({ 6424 onlySelf: true 6425 }); 6426 return subtreeUpdated; 6427 } 6428 /** @internal */ 6429 _forEachChild(cb) { 6430 this.controls.forEach((control, index) => { 6431 cb(control, index); 6432 }); 6433 } 6434 /** @internal */ 6435 _updateValue() { 6436 this.value = this.controls.filter((control) => control.enabled || this.disabled).map((control) => control.value); 6437 } 6438 /** @internal */ 6439 _anyControls(condition) { 6440 return this.controls.some((control) => control.enabled && condition(control)); 6441 } 6442 /** @internal */ 6443 _setUpControls() { 6444 this._forEachChild((control) => this._registerControl(control)); 6445 } 6446 /** @internal */ 6447 _allControlsDisabled() { 6448 for (const control of this.controls) { 6449 if (control.enabled) return false; 6450 } 6451 return this.controls.length > 0 || this.disabled; 6452 } 6453 _registerControl(control) { 6454 control.setParent(this); 6455 control._registerOnCollectionChange(this._onCollectionChange); 6456 } 6457 /** @internal */ 6458 _find(name) { 6459 return this.at(name) ?? null; 6460 } 6461}; 6462function isAbstractControlOptions(options) { 6463 return !!options && (options.asyncValidators !== void 0 || options.validators !== void 0 || options.updateOn !== void 0); 6464} 6465var FormBuilder = class _FormBuilder { 6466 useNonNullable = false; 6467 /** 6468 * @description 6469 * Returns a FormBuilder in which automatically constructed `FormControl` elements 6470 * have `{nonNullable: true}` and are non-nullable. 6471 * 6472 * **Constructing non-nullable controls** 6473 * 6474 * When constructing a control, it will be non-nullable, and will reset to its initial value. 6475 * 6476 * ```ts 6477 * let nnfb = new FormBuilder().nonNullable; 6478 * let name = nnfb.control('Alex'); // FormControl<string> 6479 * name.reset(); 6480 * console.log(name); // 'Alex' 6481 * ``` 6482 * 6483 * **Constructing non-nullable groups or arrays** 6484 * 6485 * When constructing a group or array, all automatically created inner controls will be 6486 * non-nullable, and will reset to their initial values. 6487 * 6488 * ```ts 6489 * let nnfb = new FormBuilder().nonNullable; 6490 * let name = nnfb.group({who: 'Alex'}); // FormGroup<{who: FormControl<string>}> 6491 * name.reset(); 6492 * console.log(name); // {who: 'Alex'} 6493 * ``` 6494 * **Constructing *nullable* fields on groups or arrays** 6495 * 6496 * It is still possible to have a nullable field. In particular, any `FormControl` which is 6497 * *already* constructed will not be altered. For example: 6498 * 6499 * ```ts 6500 * let nnfb = new FormBuilder().nonNullable; 6501 * // FormGroup<{who: FormControl<string|null>}> 6502 * let name = nnfb.group({who: new FormControl('Alex')}); 6503 * name.reset(); console.log(name); // {who: null} 6504 * ``` 6505 * 6506 * Because the inner control is constructed explicitly by the caller, the builder has 6507 * no control over how it is created, and cannot exclude the `null`. 6508 */ 6509 get nonNullable() { 6510 const nnfb = new _FormBuilder(); 6511 nnfb.useNonNullable = true; 6512 return nnfb; 6513 } 6514 group(controls, options = null) { 6515 const reducedControls = this._reduceControls(controls); 6516 let newOptions = {}; 6517 if (isAbstractControlOptions(options)) { 6518 newOptions = options; 6519 } else if (options !== null) { 6520 newOptions.validators = options.validator; 6521 newOptions.asyncValidators = options.asyncValidator; 6522 } 6523 return new FormGroup(reducedControls, newOptions); 6524 } 6525 /** 6526 * @description 6527 * Constructs a new `FormRecord` instance. Accepts a single generic argument, which is an object 6528 * containing all the keys and corresponding inner control types. 6529 * 6530 * @param controls A collection of child controls. The key for each child is the name 6531 * under which it is registered. 6532 * 6533 * @param options Configuration options object for the `FormRecord`. The object should have the 6534 * `AbstractControlOptions` type and might contain the following fields: 6535 * * `validators`: A synchronous validator function, or an array of validator functions. 6536 * * `asyncValidators`: A single async validator or array of async validator functions. 6537 * * `updateOn`: The event upon which the control should be updated (options: 'change' | 'blur' 6538 * | submit'). 6539 */ 6540 record(controls, options = null) { 6541 const reducedControls = this._reduceControls(controls); 6542 return new FormRecord(reducedControls, options); 6543 } 6544 /** 6545 * @description 6546 * Constructs a new `FormControl` with the given state, validators and options. Sets 6547 * `{nonNullable: true}` in the options to get a non-nullable control. Otherwise, the 6548 * control will be nullable. Accepts a single generic argument, which is the type of the 6549 * control's value. 6550 * 6551 * @param formState Initializes the control with an initial state value, or 6552 * with an object that contains both a value and a disabled status. 6553 * 6554 * @param validatorOrOpts A synchronous validator function, or an array of 6555 * such functions, or a `FormControlOptions` object that contains 6556 * validation functions and a validation trigger. 6557 * 6558 * @param asyncValidator A single async validator or array of async validator 6559 * functions. 6560 * 6561 * @usageNotes 6562 * 6563 * ### Initialize a control as disabled 6564 * 6565 * The following example returns a control with an initial value in a disabled state. 6566 * 6567 * {@example forms/ts/formBuilder/form_builder_example.ts region='disabled-control'} 6568 */ 6569 control(formState, validatorOrOpts, asyncValidator) { 6570 let newOptions = {}; 6571 if (!this.useNonNullable) { 6572 return new FormControl(formState, validatorOrOpts, asyncValidator); 6573 } 6574 if (isAbstractControlOptions(validatorOrOpts)) { 6575 newOptions = validatorOrOpts; 6576 } else { 6577 newOptions.validators = validatorOrOpts; 6578 newOptions.asyncValidators = asyncValidator; 6579 } 6580 return new FormControl(formState, __spreadProps(__spreadValues({}, newOptions), { 6581 nonNullable: true 6582 })); 6583 } 6584 /** 6585 * Constructs a new `FormArray` from the given array of configurations, 6586 * validators and options. Accepts a single generic argument, which is the type of each control 6587 * inside the array. 6588 * 6589 * @param controls An array of child controls or control configs. Each child control is given an 6590 * index when it is registered. 6591 * 6592 * @param validatorOrOpts A synchronous validator function, or an array of such functions, or an 6593 * `AbstractControlOptions` object that contains 6594 * validation functions and a validation trigger. 6595 * 6596 * @param asyncValidator A single async validator or array of async validator functions. 6597 */ 6598 array(controls, validatorOrOpts, asyncValidator) { 6599 const createdControls = controls.map((c) => this._createControl(c)); 6600 return new FormArray(createdControls, validatorOrOpts, asyncValidator); 6601 } 6602 /** @internal */ 6603 _reduceControls(controls) { 6604 const createdControls = {}; 6605 Object.keys(controls).forEach((controlName) => { 6606 createdControls[controlName] = this._createControl(controls[controlName]); 6607 }); 6608 return createdControls; 6609 } 6610 /** @internal */ 6611 _createControl(controls) { 6612 if (controls instanceof FormControl) { 6613 return controls; 6614 } else if (controls instanceof AbstractControl) { 6615 return controls; 6616 } else if (Array.isArray(controls)) { 6617 const value = controls[0]; 6618 const validator = controls.length > 1 ? controls[1] : null; 6619 const asyncValidator = controls.length > 2 ? controls[2] : null; 6620 return this.control(value, validator, asyncValidator); 6621 } else { 6622 return this.control(controls); 6623 } 6624 } 6625 static \u0275fac = function FormBuilder_Factory(__ngFactoryType__) { 6626 return new (__ngFactoryType__ || _FormBuilder)(); 6627 }; 6628 static \u0275prov = /* @__PURE__ */ \u0275\u0275defineInjectable({ 6629 token: _FormBuilder, 6630 factory: _FormBuilder.\u0275fac, 6631 providedIn: "root" 6632 }); 6633}; 6634(() => { 6635 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(FormBuilder, [{ 6636 type: Injectable, 6637 args: [{ 6638 providedIn: "root" 6639 }] 6640 }], null, null); 6641})(); 6642var NonNullableFormBuilder = class _NonNullableFormBuilder { 6643 static \u0275fac = function NonNullableFormBuilder_Factory(__ngFactoryType__) { 6644 return new (__ngFactoryType__ || _NonNullableFormBuilder)(); 6645 }; 6646 static \u0275prov = /* @__PURE__ */ \u0275\u0275defineInjectable({ 6647 token: _NonNullableFormBuilder, 6648 factory: () => (() => inject(FormBuilder).nonNullable)(), 6649 providedIn: "root" 6650 }); 6651}; 6652(() => { 6653 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(NonNullableFormBuilder, [{ 6654 type: Injectable, 6655 args: [{ 6656 providedIn: "root", 6657 useFactory: () => inject(FormBuilder).nonNullable 6658 }] 6659 }], null, null); 6660})(); 6661var UntypedFormBuilder = class _UntypedFormBuilder extends FormBuilder { 6662 group(controlsConfig, options = null) { 6663 return super.group(controlsConfig, options); 6664 } 6665 /** 6666 * Like `FormBuilder#control`, except the resulting control is untyped. 6667 */ 6668 control(formState, validatorOrOpts, asyncValidator) { 6669 return super.control(formState, validatorOrOpts, asyncValidator); 6670 } 6671 /** 6672 * Like `FormBuilder#array`, except the resulting array is untyped. 6673 */ 6674 array(controlsConfig, validatorOrOpts, asyncValidator) { 6675 return super.array(controlsConfig, validatorOrOpts, asyncValidator); 6676 } 6677 static \u0275fac = /* @__PURE__ */ (() => { 6678 let \u0275UntypedFormBuilder_BaseFactory; 6679 return function UntypedFormBuilder_Factory(__ngFactoryType__) { 6680 return (\u0275UntypedFormBuilder_BaseFactory || (\u0275UntypedFormBuilder_BaseFactory = \u0275\u0275getInheritedFactory(_UntypedFormBuilder)))(__ngFactoryType__ || _UntypedFormBuilder); 6681 }; 6682 })(); 6683 static \u0275prov = /* @__PURE__ */ \u0275\u0275defineInjectable({ 6684 token: _UntypedFormBuilder, 6685 factory: _UntypedFormBuilder.\u0275fac, 6686 providedIn: "root" 6687 }); 6688}; 6689(() => { 6690 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(UntypedFormBuilder, [{ 6691 type: Injectable, 6692 args: [{ 6693 providedIn: "root" 6694 }] 6695 }], null, null); 6696})(); 6697var VERSION = new Version("19.
66972.18"); 6698var FormsModule = class _FormsModule { 6699 /** 6700 * @description 6701 * Provides options for configuring the forms module. 6702 * 6703 * @param opts An object of configuration options 6704 * * `callSetDisabledState` Configures whether to `always` call `setDisabledState`, which is more 6705 * correct, or to only call it `whenDisabled`, which is the legacy behavior. 6706 */ 6707 static withConfig(opts) { 6708 return { 6709 ngModule: _FormsModule, 6710 providers: [{ 6711 provide: CALL_SET_DISABLED_STATE, 6712 useValue: opts.callSetDisabledState ?? setDisabledStateDefault 6713 }] 6714 }; 6715 } 6716 static \u0275fac = function FormsModule_Factory(__ngFactoryType__) { 6717 return new (__ngFactoryType__ || _FormsModule)(); 6718 }; 6719 static \u0275mod = /* @__PURE__ */ \u0275\u0275defineNgModule({ 6720 type: _FormsModule, 6721 declarations: [NgModel, NgModelGroup, NgForm], 6722 exports: [\u0275InternalFormsSharedModule, NgModel, NgModelGroup, NgForm] 6723 }); 6724 static \u0275inj = /* @__PURE__ */ \u0275\u0275defineInjector({ 6725 imports: [\u0275InternalFormsSharedModule] 6726 }); 6727}; 6728(() => { 6729 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(FormsModule, [{ 6730 type: NgModule, 6731 args: [{ 6732 declarations: TEMPLATE_DRIVEN_DIRECTIVES, 6733 exports: [\u0275InternalFormsSharedModule, TEMPLATE_DRIVEN_DIRECTIVES] 6734 }] 6735 }], null, null); 6736})(); 6737var ReactiveFormsModule = class _ReactiveFormsModule { 6738 /** 6739 * @description
6740 * Provides options for configuring the reactive forms module. 6741 * 6742 * @param opts An object of configuration options 6743 * * `warnOnNgModelWithFormControl` Configures when to emit a warning when an `ngModel` 6744 * binding is used with reactive form directives. 6745 * * `callSetDisabledState` Configures whether to `always` call `setDisabledState`, which is more 6746 * correct, or to only call it `whenDisabled`, which is the legacy behavior. 6747 */ 6748 static withConfig(opts) { 6749 return { 6750 ngModule: _ReactiveFormsModule, 6751 providers: [{ 6752 provide: NG_MODEL_WITH_FORM_CONTROL_WARNING, 6753 useValue: opts.warnOnNgModelWithFormControl ?? "always" 6754 }, { 6755 provide: CALL_SET_DISABLED_STATE, 6756 useValue: opts.callSetDisabledState ?? setDisabledStateDefault 6757 }] 6758 }; 6759 } 6760 static \u0275fac = function ReactiveFormsModule_Factory(__ngFactoryType__) { 6761 return new (__ngFactoryType__ || _ReactiveFormsModule)(); 6762 }; 6763 static \u0275mod = /* @__PURE__ */ \u0275\u0275defineNgModule({ 6764 type: _ReactiveFormsModule,
6765 declarations: [FormControlDirective, FormGroupDirective, FormControlName, FormGroupName, FormArrayName], 6766 exports: [\u0275InternalFormsSharedModule, FormControlDirective, FormGroupDirective, FormControlName, FormGroupName, FormArrayName] 6767 }); 6768 static \u0275inj = /* @__PURE__ */ \u0275\u0275defineInjector({ 6769 imports: [\u0275InternalFormsSharedModule] 6770 }); 6771}; 6772(() => { 6773 (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(ReactiveFormsModule, [{ 6774 type: NgModule, 6775 args: [{ 6776 declarations: [REACTIVE_DRIVEN_DIRECTIVES], 6777 exports: [\u0275InternalFormsSharedModule, REACTIVE_DRIVEN_DIRECTIVES] 6778 }] 6779 }], null, null); 6780})(); 6781 6782export { 6783 NG_VALUE_ACCESSOR, 6784 CheckboxControlValueAccessor, 6785 DefaultValueAccessor, 6786 NG_VALIDATORS, 6787 Validators, 6788 ControlContainer, 6789 NgControl, 6790 NgControlStatus, 6791 NgControlStatusGroup, 6792 NgForm, 6793 NgModel, 6794 ɵNgNoValidate, 6795 NumberValueAccessor, 6796 RadioControlValueAccessor, 6797 FormControlDirective, 6798 FormGroupDirective, 6799 FormControlName, 6800 SelectControlValueAccessor, 6801 NgSelectOption, 6802 ɵNgSelectMultipleOption, 6803 MaxValidator, 6804 MinValidator, 6805 RequiredValidator, 6806 CheckboxRequiredValidator, 6807 MaxLengthValidator, 6808 FormBuilder, 6809 FormsModule, 6810 ReactiveFormsModule 6811}; 6812/*! Bundled license information: 6813 6814@angular/forms/fesm2022/forms.mjs: 6815 (** 6816 * @license Angular v19.2.18 6817 * (c) 2010-2025 Google LLC. https://angular.io/ 6818 * License: MIT 6819 *) 6820*/ 6821//# sourceMappingURL=chunk-4BWSLYHL.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.