/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/forms/signals/src/field/submit.ts
40 строк
1 KB
Miles Malerba
feat(forms): introduce parse errors in signal forms
23 янв 2026, 01:19
23 янв 2026, 01:19
ebae211
Код
Авторство
О чём код?
/** * @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 {computed, linkedSignal, Signal, signal, WritableSignal} from '@angular/core'; import {ValidationError} from '../api/rules/validation/validation_errors'; import type {FieldNode} from './node'; /** * State of a `FieldNode` that's associated with form submission. */ export class FieldSubmitState { /** * Whether this field was directly submitted (as opposed to indirectly by a parent field being submitted) * and is still in the process of submitting. */ readonly selfSubmitting = signal<boolean>(false); /** Submission errors that are associated with this field. */ readonly submissionErrors: WritableSignal<readonly ValidationError.WithFieldTree[]>; constructor(private readonly node: FieldNode) { this.submissionErrors = linkedSignal({ source: this.node.structure.value, computation: () => [] as readonly ValidationError.WithFieldTree[], }); } /** * Whether this form is currently in the process of being submitted. * Either because the field was submitted directly, or because a parent field was submitted. */ readonly submitting: Signal<boolean> = computed(() => { return this.selfSubmitting() || (this.node.structure.parent?.submitting() ?? false); }); }