Commit graph

1505 commits

Author SHA1 Message Date
Matthieu Riegler
ffad78360f refactor(core): add dedicated deprecated signatures for providedIn: any / NgModule.
Those were deprecated by #47616 back in v15.

fixes #65923

(cherry picked from commit 8199945637)
2025-12-09 10:38:14 -08:00
Miles Malerba
f254ff4f2e feat(forms): expose element on signal forms Field directive
This allows for easier focusing of the relevant element based on the
`field` property of a `ValidationError`

(cherry picked from commit aff8b248b3)
2025-12-09 09:47:56 -08:00
Miles Malerba
5880fbc73c feat(forms): redo the signal forms metadata API
This PR makes a number of changes to the metadata API to address design
flaws in the previous API. Some of the changes include:

- Replaces the previous `MetadataKey` and `AggregateMetadataKey` with a
  single unified `MetadataKey` that is used for all metadata.
- The new `MetadataKey` is only defined for fields that explicitly set
  it in their schema logic
- All metadata now has reducer / aggregate behavior
- The new `MetadataKey` has an option to create a managed key which
  wraps the result of its computed aggregate into some other structure
  such as a `Resource` or `linkedSignal`
- There are now two APIs to create metadata keys
  - `createMetadataKey` for pure computed metadata
  - `createManagedMetadataKey` for metadata that manages its computation
    internally

(cherry picked from commit ebc5c2b083)
2025-12-09 09:21:45 -08:00
SkyZeroZx
6b4ab876e8 feat(forms): Allows transforms on FormUiControl signals
Extends the `FormUiControl` interface to allow `InputSignalWithTransform` in addition to `InputSignal` for its properties.

Fixes #65756

(cherry picked from commit 7d1e502345)
2025-12-03 15:13:06 +01:00
Leon Senft
609699ae17 perf(core): tree shake unused dynamic [field] binding instructions (#65599)
Move the instructions used to dynamically bind a `Field` directive to a
form control onto the `Field` itself. This way the instructions are only
retained if the app uses the `Field` directive.

PR Close #65599
2025-12-03 15:10:50 +01:00
Alan Agius
78fd159b78 fix(compiler): prevent XSS via SVG animation attributeName and MathML/SVG URLs
This commit implements a security fix to prevent XSS vulnerabilities where SVG animation elements (`<animate>`, `<set>`, etc.) could be used to modify the `href` or `xlink:href` attributes of other elements to `javascript:` URLs.

(cherry picked from commit 1c6b0704fb)
2025-12-01 10:27:00 +01:00
kirjs
e3f5f34732 refactor(forms): Make reset take value
Now you can do form.reset({name: 'cat', age: 4});

(cherry picked from commit dec222d4d7)
2025-11-25 10:51:38 -05:00
Miles Malerba
7d5c7cf99a feat(forms): add DI option for classes on Field directive
Adds a DI configuration option for signal forms that allows the
developer to specify CSS classes that should be automatically added
by the `Field` directive based on the field's status.

(cherry picked from commit c70e246c23)
2025-11-25 10:33:41 -05:00
hawkgs
6de8926594 refactor(core): add debug name to resource (#64172)
Decorate `resource` (and `httpResource`) with `debugName`, along with all of its internal signals.

PR Close #64172
2025-11-24 11:30:13 -05:00
David Kingma
630a3b29d8 refactor(core): add debugName option to rxjs-interop toSignal
toSignal predates the debugName option for signals to name the signals in the Angular dev-tools This adds the debugName option to toSignal.

(cherry picked from commit 0812ac3bec)
2025-11-20 10:49:54 -05:00
SkyZeroZx
a7dddcca51 docs: Adds links to relevant guides for APIs in core package
(cherry picked from commit 0432e76171)
2025-11-17 16:47:40 +00:00
Miles Malerba
e1a7c35370 refactor(forms): improve typing on min & max (#65212)
If we're calling `min` on a path that's guaranteed to be `number` we
don't want to make the users validator function handle the `null` or
`string` cases.

This uncovered an issue in the `SchemaTreePath` type which needed to be
fixed by preventing the model type from being distributed over.

PR Close #65212
2025-11-14 21:56:58 +00:00
Miles Malerba
ff4633dab8 refactor(forms): allow passing number|string|null paths to min & max (#65212)
Relaxes the constraints on which paths can be used with the `min` &
`max` validation rules, since people may want to validate a
potentially-null number, or a numeric value represented as a string

PR Close #65212
2025-11-14 21:56:58 +00:00
Miles Malerba
966bfae337 build(forms): expose signal forms compat package
Hooks up @angular/forms/signals/compat to be released and have its docs
published

(cherry picked from commit fc1ef79ad4)
2025-11-14 17:23:39 +00:00
Leon Senft
37463525be refactor(forms): use AbortSignal to cancel debounced updates
Add an `AbortSignal` parameter to `Debouncer`. Implementations may
choose to accept this parameter to be informed when a debounced
operation is aborted. This may be useful for canceling pending timers or
avoiding unnecessary work.

(cherry picked from commit 98ce9a7b17)
2025-11-13 17:59:22 +00:00
Andrew Scott
e5b0a9739c Revert "feat(service-worker): notify clients about version failures (#62718)"
This reverts commit 6d011687ec.

issue #63500 reproduces at head on the main branch in the dev app.
Reverting this change along resolves it.

fixes https://github.com/angular/angular/issues/63500

(cherry picked from commit 4af408afcb)
2025-11-11 12:48:49 -08:00
Leon Senft
a278ee358c feat(forms): add debounce() rule for signal forms
The `debounce()` rule allows developers to control when changes to a
form control are synchronized to the form model.

This feature necessitated some changes to `FieldState`:

  * `controlValue` is a new signal property that represents the current
    value of a form field as it appears in its corresponding control.

  * `value` conceptually remains unchanged; however, its value may lag
    behind that of `controlValue` if a `debounce()` rule is applied.

The `debounce()` rule essentially manages when changes to `controlValue` are
synchronized to `value`. The intent is that an expensive or slow
validation rule can react to the debounced `value`, rather than a more
frequently changing `controlValue`.

Directly updating `value` immediately updates `controlValue`, and cancels any
pending debounced updates.

When multiple `debounce()` rules are applied to the same field, the last
currently active rule is used to debounce an update. These rules are
applied to child fields as well, unless they override them with their
own rule.

(cherry picked from commit d337cfb68f)
2025-11-11 12:00:13 -08:00
Leon Senft
33ed7d116b refactor(forms): do not infer accumulated metadata type from initial value
This removes the need to specify type arguments for
`reducedMetadataKey()` when the value returned from the `getIntial`
callback is a subtype of the accumulated type.

(cherry picked from commit 8866934334)
2025-11-11 12:00:12 -08:00
Matthieu Riegler
6213cbf1a8 refactor(core): rename ExperimentalIsolatedShadowDom to IsolatedShadowDom
This API is still experimental

(cherry picked from commit 21ca49cf62)
2025-11-11 08:46:10 -08:00
arturovt
9db114f4ff refactor(router): replace Optional with inject() flags
Replace `@Optional() link: RouterLink` constructor parameter with
`link = inject(RouterLink, {optional: true})` to enable tree-shaking
of the `Optional` decorator and its factory scaffolding.

Bundle size reduction: `Optional` is a runtime value created by
`makeParamDecorator()`. Even in production builds, ESBuild and other
bundlers must keep their factory code because it is referenced via
`Optional`. With `inject()`, this class is no longer referenced,
allowing it and the `makeParamDecorator` scaffolding to be tree-shaken
when unused elsewhere.

Note: This updates the constructor signature but should not be
considered a breaking change. Angular's official guidance is that
directives, components, and pipes should be instantiated by the
framework, not by user code. Directly calling `new RouterLinkActive(...)`
is an unsupported pattern that goes against Angular's design principles.

(cherry picked from commit 7724a9460d)
2025-11-10 09:48:36 -08:00
Leon Senft
781a3299f9 perf(forms): only update interop controls when bound field changes
https://github.com/angular/angular/pull/64590 implemented change
detection for field bindings, but only for those bound to native or
custom form controls. This change extends that optimization to apply to
field bindings on interoperable controls built using Reactive Forms as well.

(cherry picked from commit 850f0d6b3d)
2025-11-07 11:58:20 -08:00
Alan Agius
1e53f4e957 refactor: exclude tsconfig.json from VSIX package contents (#64991)
The  file is no longer included in the VSCode extension package.
This change updates the golden file and the  file to reflect this exclusion.

PR Close #64991
2025-11-07 11:36:31 -08:00
Alan Agius
8967d9bc40 test: add golden file test for VSCode extension package contents (#64991)
This commit introduces a golden file test to verify the contents of the VSCode extension package.
The test ensures that the list of files included in the extension package remains consistent.

A new Bazel rule  is added to generate the list of files, and  is used to compare it against the golden file. A helper script  is also added to facilitate the generation of the golden file.

PR Close #64991
2025-11-07 11:36:31 -08:00
Miles Malerba
a3cb1dfd1a refactor(forms): nicer type errors
By intersecting with `object` instead of `unknown` in the primitive and
`FormControl` cases, we get TypeScript to show nicer type errors that
mention `FieldTree<...>` insetad of `() => FieldState<...>`

(cherry picked from commit 0efb3f6d1f)
2025-11-07 15:45:08 +00:00
Miles Malerba
6d6fda8610 refactor(forms): allow FieldTree of recursive type
Adjusts our typings to work better with recursive types and avoid
infinite recursion in the type system.

(cherry picked from commit faccf03ee0)
2025-11-06 21:43:46 +00:00
Miles Malerba
9ea1c2216d refactor(forms): expose pathKeys as part of the API
Currently we maintain the pathKeys internally, but do not expose them
through the `FieldContext`, this PR updates the `FieldContext` to expose
this property.

(cherry picked from commit 2fd8dc9195)
2025-11-06 21:43:15 +00:00
Miles Malerba
8b4195fe7e refactor(forms): support dynamic object logic
extends `applyEach` to work on objects as well, conditionally applying
logic to each property of the object.

(cherry picked from commit c9058087ae)
2025-11-06 21:42:51 +00:00
kirjs
3bbcae6ce8 refactor(forms): add compatForm
This allows using reactive form controls in signal forms

(cherry picked from commit 60447945bc)
2025-11-06 18:51:31 +00:00
Alan Agius
3bed9f0f16
build: format md files
This commit configures prettier to format markdown files.
2025-11-06 10:07:13 -08:00
tsc036
b30bcc514d refactor(core): export types from primitives
export Version type and a type for linkedSignal previous value so they can be used for the Wiz implementations

(cherry picked from commit 104f7d57c1)
2025-11-06 16:34:58 +00:00
Miles Malerba
f3e2252f4b refactor(forms): add better support for Object.keys and Symbol.iterator
Improves support for using `Object.keys` (and related methods) and
`Symbol.iterator` to work with a `FieldTree` of unknown shape.

(cherry picked from commit e87f423d90)
2025-11-06 15:51:31 +00:00
Miles Malerba
c3b4bea951 refactor(forms): improve discoverability of ValidationError flavors (#64747)
Improves discoverability by putting the WithField, WithoutField, etc as
subtypes of the main ValidationError type

PR Close #64747
2025-11-05 22:42:59 +00:00
Kristiyan Kostadinov
c371251e4c fix(compiler-cli): report invalid bindings on form controls
Adds validation that users don't bind to unsupported properties on nodes with the `Field` directive.

(cherry picked from commit f20103a1d7)
2025-11-05 09:35:51 -08:00
SkyZeroZx
6de14b14e0 refactor(http): simplifies destruction tracking using destroyed property
Replaces the manual destroyed state with destroyed property

(cherry picked from commit 44435ea97b)
2025-11-05 09:05:34 -08:00
Matthieu Riegler
20b4b2c43c refactor(core): expose isWritableSignal to the publicApi
This is alongside the already exisiting isSignal()

fixes #64763

(cherry picked from commit 76adbbcd0a)
2025-10-29 13:31:53 -07:00
Miles Malerba
981fabc9b6 feat(docs-infra): add support for namespaces
Adds support for generating docs for namespaces (and merged declarations
of namespace + type)

(cherry picked from commit 662f0e5c00)
2025-10-29 13:22:26 -07:00
kirjs
d74fb923cc refactor(forms): Allow returning plain values from validators
This makes the API nicer to use

(cherry picked from commit c57bbaa87d)
2025-10-28 20:50:48 +01:00
kirjs
2c2ea2c0da refactor(forms): Allow returning plain values from validators
This makes the API nicer to use

(cherry picked from commit b5c29d0d0a)
2025-10-28 20:50:48 +01:00
csorrentino
bd780366e8 refactor(forms): add onError callback to validateHttp for HTTP errors
Adds onError callback inside validateHttp validator in signal forms

PR-Close: #63949
(cherry picked from commit a5678f6f2b)
2025-10-27 17:12:28 +01:00
Miles Malerba
02f7263133 refactor(forms): rename files related to metadata (#64603)
Renames some files to reflect the property => metadata name change

PR Close #64603
2025-10-23 18:13:16 +02:00
Jessica Janiuk
e039c6be02 refactor(compiler): Throw an error when old and new animations are used together (#64569)
This adds a new compilation error if someone attempts to put legacy animations and `animate.enter` or `animate.leave` in the same component.

PR Close #64569
2025-10-22 17:14:47 +00:00
Kristiyan Kostadinov
9d48e534e2 Revert "feat(router): allow router outlet to be set on ng-container (#64562)" (#64584)
This reverts commit 2bd764a3c4.

PR Close #64584
2025-10-22 16:35:38 +00:00
Kristiyan Kostadinov
2bd764a3c4 feat(router): allow router outlet to be set on ng-container (#64562)
Updates the selector for `RouterOutlet` to allow for it to be set on an `ng-container`. This allows it to not render the host node which can affect the layout.

Fixes #64553.

PR Close #64562
2025-10-21 16:49:06 +00:00
Kristiyan Kostadinov
196fa500a3 fix(common): properly type ngComponentOutlet (#64561)
Resolves an older TODO about properly typing the `ngComponentOutlet` input.

PR Close #64561
2025-10-21 15:25:13 +00:00
cexbrayat
bc9c814ca7 refactor(forms): remove Mutable from signal forms public API (#64436)
The `Mutable` type is only used internally in the `addDefaultField` function, so it can be avoided to be publicly exposed.

PR Close #64436
2025-10-20 21:20:11 +00:00
hawkgs
daaad1e6b0 refactor(core): narrow down ReactiveNode.kind type (#64127)
Use a string union type instead of a generic string.

PR Close #64127
2025-10-20 20:15:46 +00:00
Andrew Scott
f6a73f1913 fix(router): Respect custom UrlSerializer handling of query parameters (#64449)
Previously, query parameters passed to `router.createUrlTree` were simply converted to strings. This meant that any custom serialization logic in a custom `UrlSerializer` was not applied. This could lead to inconsistencies between navigations triggered from the URL bar (which are parsed by the serializer) and navigations triggered programmatically.

This change ensures that query parameters are normalized using the provided `UrlSerializer`. The values are serialized and then parsed to ensure they are in the same format as if they had come from a URL. This allows custom serializers to handle complex objects in query parameters consistently.

Fixes https://github.com/angular/angular/issues/47307

PR Close #64449
2025-10-20 18:42:56 +00:00
Andrew Scott
7fb7511124 fix(router): Surface parse errors in Router.parseUrl (#64503)
logs error in addition to fallback parse

fixes #54937

PR Close #64503
2025-10-20 17:51:29 +00:00
Kristiyan Kostadinov
c2d376b85a feat(core): make SimpleChanges generic (#64535)
Currently it's easy to make a mistake when accessing properties on `SimpleChanges`, because the keys aren't typed. These changes add an optional generic to the interface so that users can get a compilation error if they make a typo.

A few things to note:
1. The generic argument is optional and we revert to the old behavior if one isn't passed for backwards compatibility.
2. All of the keys are optional, because they aren't guaranteed to be present for any `ngOnChanges` invocation.
3. We unwrap the values of input signals to match the behavior at runtime.

Fixes #17560.

PR Close #64535
2025-10-20 17:49:39 +00:00
Leon Senft
a0f3960270 refactor(forms): prefix framework-private methods on Field with ɵ (#64471)
These methods are only intended to be used internally within framework
instructions. Prefix them with `ɵ` to indicate that they are
framework-private and should not be called from user code.

PR Close #64471
2025-10-20 15:35:42 +00:00