-
Notifications
You must be signed in to change notification settings - Fork 27.2k
refactor(forms): keep signal forms config tree-shakable #68810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SkyZeroZx
wants to merge
1
commit into
angular:main
Choose a base branch
from
SkyZeroZx:refactor/sf-tree-shake
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| ## API Report File for "@angular/forms_signals_config" | ||
|
|
||
| > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
|
|
||
| ```ts | ||
|
|
||
| import { Injector } from '@angular/core'; | ||
| import { Provider } from '@angular/core'; | ||
| import { Signal } from '@angular/core'; | ||
|
|
||
| // @public | ||
| export function provideSignalFormsConfig(config: SignalFormsConfig): Provider[]; | ||
|
|
||
| // @public | ||
| export interface SignalFormsClassBinding { | ||
| readonly element: HTMLElement; | ||
| focus(options?: FocusOptions): void; | ||
| readonly injector: Injector; | ||
| readonly state: Signal<SignalFormsClassBindingState>; | ||
| } | ||
|
|
||
| // @public | ||
| export interface SignalFormsClassBindingState { | ||
| dirty(): boolean; | ||
| invalid(): boolean; | ||
| pending(): boolean; | ||
| touched(): boolean; | ||
| valid(): boolean; | ||
| } | ||
|
|
||
| // @public | ||
| export interface SignalFormsConfig { | ||
| classes?: { | ||
| [className: string]: (formField: SignalFormsClassBinding) => boolean; | ||
| }; | ||
| } | ||
|
|
||
| // (No @packageDocumentation comment for this package) | ||
|
|
||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| load("//tools:defaults.bzl", "generate_api_docs", "ng_project") | ||
|
|
||
| package(default_visibility = ["//visibility:public"]) | ||
|
|
||
| ng_project( | ||
| name = "config", | ||
| srcs = glob( | ||
| [ | ||
| "*.ts", | ||
| "src/**/*.ts", | ||
| ], | ||
| ), | ||
| deps = [ | ||
| "//packages/core", | ||
| ], | ||
| ) | ||
|
|
||
| filegroup( | ||
| name = "files_for_docgen", | ||
| srcs = glob([ | ||
| "*.ts", | ||
| "src/**/*.ts", | ||
| ]) + ["PACKAGE.md"], | ||
| ) | ||
|
|
||
| generate_api_docs( | ||
| name = "forms_signals_config_docs", | ||
| srcs = [ | ||
| ":files_for_docgen", | ||
| "//packages:common_files_and_deps_for_docs", | ||
| ], | ||
| entry_point = ":index.ts", | ||
| module_name = "@angular/forms/signals/config", | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Configuration APIs for Signal Forms | ||
|
|
||
| This package contains configuration helpers for signal-based forms that can be imported without | ||
| bringing in the rest of the signal forms runtime. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /** | ||
| * @license | ||
| * Copyright Google LLC All Rights Reserved. | ||
| * | ||
| * Use of this source code is governed by an MIT-style license that can be | ||
| * found in the LICENSE file at https://angular.dev/license | ||
| */ | ||
|
|
||
| // This file is not used to build this module. It is only used during editing | ||
| // by the TypeScript language service and during build for verification. `ngc` | ||
| // replaces this file with production index.ts when it rewrites private symbol | ||
| // names. | ||
|
|
||
| export * from './public_api'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /** | ||
| * @license | ||
| * Copyright Google LLC All Rights Reserved. | ||
| * | ||
| * Use of this source code is governed by an MIT-style license that can be | ||
| * found in the LICENSE file at https://angular.dev/license | ||
| */ | ||
|
|
||
| /** | ||
| * @module | ||
| * @description | ||
| * Entry point for Signal Forms configuration APIs. | ||
| */ | ||
| export * from './src/api'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /** | ||
| * @license | ||
| * Copyright Google LLC All Rights Reserved. | ||
| * | ||
| * Use of this source code is governed by an MIT-style license that can be | ||
| * found in the LICENSE file at https://angular.dev/license | ||
| */ | ||
|
|
||
| import {type Injector, type Provider, type Signal} from '@angular/core'; | ||
| import {SIGNAL_FORMS_CONFIG} from './di'; | ||
|
|
||
| /** | ||
| * The subset of field state APIs used by signal forms CSS class configuration. | ||
| * | ||
| * @publicApi 22.0 | ||
| */ | ||
| export interface SignalFormsClassBindingState { | ||
| /** Whether the bound field has been touched. */ | ||
| touched(): boolean; | ||
|
|
||
| /** Whether the bound field is dirty. */ | ||
| dirty(): boolean; | ||
|
|
||
| /** Whether the bound field is valid. */ | ||
| valid(): boolean; | ||
|
|
||
| /** Whether the bound field is invalid. */ | ||
| invalid(): boolean; | ||
|
|
||
| /** Whether the bound field has pending validation. */ | ||
| pending(): boolean; | ||
| } | ||
|
|
||
| /** | ||
| * Represents a binding between a field and a UI control for signal forms configuration. | ||
| * | ||
| * @publicApi 22.0 | ||
| */ | ||
| export interface SignalFormsClassBinding { | ||
| /** The HTML element on which the binding is applied. */ | ||
| readonly element: HTMLElement; | ||
|
|
||
| /** The node injector for the element hosting this field binding. */ | ||
| readonly injector: Injector; | ||
|
|
||
| /** The subset of field state available to configuration callbacks. */ | ||
| readonly state: Signal<SignalFormsClassBindingState>; | ||
|
|
||
| /** Focuses this field binding. */ | ||
| focus(options?: FocusOptions): void; | ||
| } | ||
|
|
||
| /** | ||
| * Configuration options for signal forms. | ||
| * | ||
| * @publicApi 22.0 | ||
| */ | ||
| export interface SignalFormsConfig { | ||
| /** A map of CSS class names to predicate functions that determine when to apply them. */ | ||
| classes?: { | ||
| [className: string]: (formField: SignalFormsClassBinding) => boolean; | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Provides configuration options for signal forms. | ||
| * | ||
| * @publicApi 22.0 | ||
| */ | ||
| export function provideSignalFormsConfig(config: SignalFormsConfig): Provider[] { | ||
| return [{provide: SIGNAL_FORMS_CONFIG, useValue: config}]; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /** | ||
| * @license | ||
| * Copyright Google LLC All Rights Reserved. | ||
| * | ||
| * Use of this source code is governed by an MIT-style license that can be | ||
| * found in the LICENSE file at https://angular.dev/license | ||
| */ | ||
|
|
||
| import {InjectionToken} from '@angular/core'; | ||
| import type {SignalFormsConfig} from './api'; | ||
|
|
||
| /** Injection token for the signal forms configuration. */ | ||
| export const SIGNAL_FORMS_CONFIG = new InjectionToken<SignalFormsConfig>( | ||
| typeof ngDevMode !== 'undefined' && ngDevMode ? 'SIGNAL_FORMS_CONFIG' : '', | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're past 22.0 freeze.
This would be 22.1.