Commit graph

370 commits

Author SHA1 Message Date
Andrew Kushnir
1f4533807e Revert "fix(forms): fix FormRecord type inference (#50750)" (#58315)
This reverts commit 18b6f3339f.

PR Close #58315
2024-10-22 14:04:45 -07:00
Andrew Kushnir
79d9be3e63 Revert "feat(forms): add ability to clear a FormRecord (#50750)" (#58315)
This reverts commit 3e7d724037.

PR Close #58315
2024-10-22 14:04:45 -07:00
Emmanuel Roux
3e7d724037 feat(forms): add ability to clear a FormRecord (#50750)
Add new `clear()` method to `FormRecord`

PR Close #50750
2024-10-22 07:36:22 -07:00
emmanuelroux
18b6f3339f fix(forms): fix FormRecord type inference (#50750)
Updates type inference in `ɵElement` to make `FormRecord` take precedence over `FormGroup`

PR Close #50750
2024-10-22 07:36:22 -07:00
Matthieu Riegler
09df589e31 refactor(core): Migrate all packages with the explicit-standalone-flag schematic. (#58160)
All components, directives and pipes will now use standalone as default.
Non-standalone decorators have now `standalone: false`.

PR Close #58160
2024-10-14 14:58:57 +00:00
Matthieu Riegler
186b52449a docs: add info on AbstractControl.source type. (#58094)
The source can be of any type and can't be inferred from `T`

fixes #58076

PR Close #58094
2024-10-07 08:21:55 -07:00
Joey Perrott
9dbe6fc18b refactor: update license text to point to angular.dev (#57901)
Update license text to point to angular.dev instead of angular.io

PR Close #57901
2024-09-24 15:33:00 +02:00
Matthieu Riegler
6c9abd38fb refactor(forms): lift circular deps (#55881)
`import type` to the rescue.

PR Close #55881
2024-09-23 16:24:05 +02:00
Matthieu Riegler
ea1447532a docs: remove @searchKeywords (#57560)
This tag is not supported.

fixes #57540

PR Close #57560
2024-08-28 08:49:05 -07:00
Andrew Scott
2431f206d7 refactor(forms): Update status, touched, and pristine to use private setter (#56573)
This refactor updates the touched, status, and pristine properties to
have a private setter.

PR Close #56573
2024-06-26 08:47:39 -07:00
Andrew Scott
00bde8b1c2 fix(forms): Make NgControlStatus host bindings OnPush compatible (#55720)
This commit makes the host bindings of `NgControlStatus[Group]`
compatible with `OnPush` components. Note that this intentionally _does not_
expose any new APIs in the forms module. The goal is only to remove
unpreventable `ExpressionChangedAfterItHasBeenCheckedError` in the forms
code that developers do not have control over.

PR Close #55720
2024-06-18 11:35:34 -07:00
Matthieu Riegler
eddb4051b8 refactor(forms): remove deprecated symbols (#55723)
Follow-up of #55698 to help remove the symbols from G3.

PR Close #55723
2024-05-17 10:12:01 -07:00
Matthieu Riegler
53b0d6adb8 fix(forms): Allow canceled async validators to emit. (#55134)
With this change, If an async validator that should have emitted was cancelled by a non-emitting validator, the status change will be reported on the `AbstractControl.events` observable.

This issue can happen when a `FormControl` is added to a `FormGroup` and a FormGroupDirective/FormControlDirective trigger a non-emitting validation (which cancels the initial validator execution).

Note: The behavior remains the same of the existing `statusChanges` observable as the change was too breaking to land in G3.

fixes: angular#41519

PR Close #55134
2024-05-15 08:56:25 -07:00
Matthieu Riegler
c8472e5e9e refactor(forms): deprecate unwanted control events aliases (#55698)
This commit deprecates the aliases for the control events to ease the changes in G3
A follow-up commit will remove those deprecated entries.

PR Close #55698
2024-05-13 11:16:15 -07:00
Kristiyan Kostadinov
aa8df1d029 refactor(core): clean up clang comments and workarounds (#55750)
Since we aren't using clang anymore, we can remove the comments and the workarounds that were in place to prevent it from doing the wrong thing.

PR Close #55750
2024-05-13 11:10:36 -07:00
Matthieu Riegler
fedeaac8ba fix(forms): Add event for forms submitted & reset (#55667)
This commit adds 2 new events to the unified control event observable.

PR Close #55667
2024-05-09 09:21:14 -07:00
fdonzello
c001b05c77 refactor(forms): added control name in console errors (#55397)
When a formControlName is used without a parent formGroup, an error is
logged in the console. Before this commit, there was no information
about which control had the issue. Now, it's reported and the
troubleshoot is much faster.

PR Close #55397
2024-04-23 15:16:57 -07:00
Joey Perrott
a2aca69bd3 refactor: migrate forms to prettier formatting (#55423)
Migrate formatting to prettier for forms from clang-format

PR Close #55423
2024-04-19 13:49:24 -07:00
Matthieu Riegler
3547e1e769 refactor(forms): emit status/value event in a consistant order (#55198)
We emit `ValueChangeEvent` first and then `StatusChangeEvent`

PR Close #55198
2024-04-09 15:21:39 -07:00
Matthieu Riegler
f45fbb0f43 docs: remove deprecation details link (#55043)
PR Close #55043
2024-04-09 12:23:09 -07:00
Matthieu Riegler
457d02cca3 docs: Use new Urls to drop the docs url mapper (#55043)
PR Close #55043
2024-04-09 12:23:09 -07:00
cexbrayat
9c776d6802 docs(forms): add docs for emitEvent flag (#55249)
PR Close #55249
2024-04-09 10:31:10 -07:00
Matthieu Riegler
1c736dc3b2 feat(forms): Unified Control State Change Events (#54579)
This commit introduces a new method to subscribe to on every `AbstractControl` subclass.
It allows to track value, pristine, touched and status changes on a given control.

Fixes #10887

PR Close #54579
2024-04-03 17:12:04 +00:00
Kisters-BS
20c47398b6 docs: fix typo (#54427)
PR Close #54427
2024-02-14 15:29:21 -08:00
Matthieu Riegler
e67b9a46f6 refactor(forms): Provide RadioControlRegistry in root. (#54130)
The `RadioControlRegistry` was only provided in a module, providedIn: 'root' fixes that issue.

Fixes #54117

Co-authored-by: sr5434 <118690585+sr5434@users.noreply.github.com>

PR Close #54130
2024-01-31 14:55:56 +00:00
Matthieu Riegler
7800a3c9f5 refactor(core): remove InjectionToken descriptions in optimized builds. (#53747)
We started guarding the `InjectionToken` descriptions with `ngDevMode`. Let's generalize that accross the FW.

PR Close #53747
2024-01-26 19:12:41 +00:00
Chellappan
989394db90 refactor(forms): Specify Provider type for DEFAULT_VALUE_ACCESSOR (#54029)
Change from `any` to `Provider` type for enhanced type safety and clarity

PR Close #54029
2024-01-26 15:46:31 +00:00
Matthieu Riegler
43115da986 refactor(forms): Log a warning when FormGroup keys include a dot. (#50642)
Due to the dotted synthax to resolve controls, keys in FormGroups cannot include dots.

fixes #50608

PR Close #50642
2023-10-18 12:11:25 -07:00
Matthieu Riegler
ddd7212ee2 fix(forms): reset() call with null values on nested group (#48830)
Non typed forms allow to pass null to nested groups when calling `formGroup.reset()`, this commit prevent an undefined access.

fixes #20509

PR Close #48830
2023-10-10 15:34:31 -07:00
Matthieu Riegler
e9b9fd4579 refactor(forms): Use the Writable type when overwriting readonly properties. (#49754)
The `Writable` type is usefull when we want overwrite readonly properties and we still want to maintain code navigation/reference. It should be use instead of `any` type assertions for example.

PR Close #49754
2023-09-22 10:02:13 -07:00
Matthieu Riegler
e6503930f1 docs: fix see also links. (#51379)
These were all the @see with no links.

PR Close #51379
2023-08-17 10:18:33 -07:00
Jeremy Mowery
be3edad60e refactor: add readonly to public InjectionToken types (#51125)
We enabled a lint rule internally to require that multi-provided
`InjectionToken`s have a `readonly` array type, the tokens in this
PR do not follow this rule and are causing lint violations.

Fixes #51124

PR Close #51125
2023-08-14 17:17:35 -07:00
Matthieu Riegler
a871e23857 docs: remove duplicate words. (#51215)
Using the `\b(\w+)\s+\1\b` we can find duplicate word. Let's remove them.

PR Close #51215
2023-08-01 12:08:33 -07:00
aanchal
a24830777f docs: fix typos (#51201)
PR Close #51201
2023-08-01 12:04:31 -07:00
Terry
e77cb75c54 docs(forms): FormBuilder is not associated with ReactiveFormsModule (#50941)
PR Close #50941
2023-07-05 13:53:10 +02:00
Matthieu Riegler
7eb5286d04 docs(forms): Make links out of @see tags (#50110)
This commit is part of the work for #50097 to improve the linking on the online documentation.

PR Close #50110
2023-06-14 10:54:38 +02:00
Kristiyan Kostadinov
68017d4e75 feat(core): add ability to transform input values (#50420)
According to the HTML specification most attributes are defined as strings, however some can be interpreted as different types like booleans or numbers. [In the HTML standard](https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes), boolean attributes are considered `true` if they are present on a DOM node and `false` if they are omitted. Common examples of boolean attributes are `disabled` on interactive elements like `<button>` or `checked` on `<input type="checkbox">`. Another example of an attribute that is defined as a string, but interpreted as a different type is the `value` attribute of `<input type="number">` which logs a warning and ignores the value if it can't be parsed as a number.

Historically, authoring Angular inputs that match the native behavior in a type-safe way has been difficult for developers, because Angular interprets all static attributes as strings. While some recent TypeScript versions made this easier by allowing setters and getters to have different types, supporting this pattern still requires a lot of boilerplate and additional properties to be declared. For example, currently developers have to write something like this to have a `disabled` input that behaves like the native one:

```typescript
import {Directive, Input} from '@angular/core';

@Directive({selector: 'mat-checkbox'})
export class MatCheckbox {
  @Input()
  get disabled() {
    return this._disabled;
  }
  set disabled(value: any) {
    this._disabled = typeof value === 'boolean' ? value : (value != null && value !== 'false');
  }
  private _disabled = false;
}
```

This feature aims to address the issue by introducing a `transform` property on inputs. If an input has a `transform` function, any values set through the template will be passed through the function before being assigned to the directive instance. The example from above can be rewritten to the following:

```typescript
import {Directive, Input, booleanAttribute} from '@angular/core';

@Directive({selector: 'mat-checkbox'})
export class MatCheckbox {
  @Input({transform: booleanAttribute}) disabled: boolean = false;
}
```

These changes also add the `booleanAttribute` and `numberAttribute` utilities to `@angular/core` since they're common enough to be useful for most projects.

Fixes #8968.
Fixes #14761.

PR Close #50420
2023-05-30 13:01:13 -07:00
Sumit Parakh
1598fbc24a docs: added wiki link for domain model (#50180)
Closes #49570

PR Close #50180
2023-05-17 08:12:21 -07:00
gdarnell
efa92ab6ca refactor(forms): remove unnecessary Array.from (#50314)
The Array.from isn't necessary since we're just iterating over the map keys.

PR Close #50314
2023-05-16 09:25:26 -07:00
Samir
7baaed262d docs(forms): warn the user about getting old values and show how to avoid (#50123)
PR Close #50123
2023-05-08 14:34:54 -07:00
Samir
4b355cca67 docs(forms): warn the user about getting old values and show how to avoid (#50123)
Co-authored-by: Andrew Kushnir <43554145+AndrewKushnir@users.noreply.github.com>
PR Close #50123
2023-05-08 14:34:54 -07:00
Samir
4b41257f1c docs(forms): warn the user about getting old values and show how to avoid (#50123)
PR Close #50123
2023-05-08 14:34:54 -07:00
Dylan Hunn
edc3bb180f Revert "feat(forms): Improve typings form (async)Validators" (#49706)
This reverts commit da189dec8f.

PR Close #49706
2023-04-04 11:26:04 -07:00
Matthieu Riegler
07a1aa3004 feat(forms): Improve typings form (async)Validators (#48679)
With this commit, AsyncValidatorFn cannot be passed as ValidatorFn  anymore in FormControl.

fixes: #48676

PR Close #48679
2023-03-30 11:47:29 -07:00
Alan Agius
0f2937ef83 refactor: update code to be ES2022 compliant (#49559)
This commit updates parts of the FW to be ES2022 complaint.

These changes are needed to fix the following problems problems with using properties before they are initialized.

Example
```ts
class Foo {
   bar = this.buz;
   constructor(private buz: unknown){}
}
```

PR Close #49559
2023-03-23 08:18:45 -07:00
Andrew Scott
8d91d74d46 refactor(core): Remove NG_DEV_MODE const (#49530)
From Joost: The locally defined NG_DEV_MODE does not work with ESBuild, as it doesn’t fold recursively

PR Close #49530
2023-03-22 15:31:48 -07:00
Andrew Scott
4d455e06c7 Revert "refactor: update code to be ES2022 compliant (#49332)" (#49554)
This reverts commit 349ff01c4b.

PR Close #49554
2023-03-22 14:34:25 -07:00
Alan Agius
349ff01c4b refactor: update code to be ES2022 compliant (#49332)
This commit updates parts of the FW to be ES2022 complaint.

These changes are needed to fix the following problems problems with using properties before they are initialized.

Example
```ts
class Foo {
   bar = this.buz;
   constructor(private buz: unknown){}
}
```

PR Close #49332
2023-03-22 14:00:19 -07:00
Matthieu Riegler
daaf0fd2f6 refactor(core): Remove isObservable() in favor isSubscribable(). (#49295)
The private util `isObservable` was actually just testing the same thing as`isSubscribable()`. As the implementation is closer to the function's name, let's only keep ``isSubscribable`.

PR Close #49295
2023-03-08 17:58:19 +00:00
Matthieu Riegler
9737df37a9 docs: fix links on untyped forms (#49306)
PR Close #49306
2023-03-03 19:40:00 +00:00