ngx-recipe-forms 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/fesm2022/ngx-recipe-forms.mjs +130 -19
- package/fesm2022/ngx-recipe-forms.mjs.map +1 -1
- package/package.json +1 -1
- package/types/ngx-recipe-forms.d.ts +47 -6
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ To write a recipe, follow [`AGENTS.md`](https://github.com/SrenoG/ngx-recipe-for
|
|
|
9
9
|
|
|
10
10
|
- **Recipe types**: `FormRecipe<TModel>`, nodes `section`, `row`, `sectionGroup`, `field`, `linked`, `array`; controls and rules constrained by the type of the value; typed builder `recipeBuilder<TModel>()`. The nodes of an `array` item are built with `recipeBuilder<ItemModel, RootModel>()`: their rules read the root through `ctx.root(key)`.
|
|
11
11
|
- **Schema**: `RecipeSchema.build(recipe)` turns each rule into a native function (`required`, `pattern`, `min`…, `validate`, `validateTree`, `validateAsync`, `metadata`), and applies `disabled`, `hidden`, `readonly` (per field, per section or for the whole recipe), the rules of `array` items (`applyEach`), the rules of the whole list (`minItems`, `maxItems`, `unique`, `validate`), non-blocking warnings (`warn`), linked controls and `extraRules`. When a server validator fails, the engine sets the "validation unavailable" warning without blocking: the server still decides on save.
|
|
12
|
-
- **Messages**: priority field → recipe → default → raw message; server errors are shown by their `message`, translated by the caller, otherwise by the key `errors.<code>`; a field error set by the host application as `{ kind: 'server', error: { code, constraint?, message } }` is read as is.
|
|
12
|
+
- **Messages**: priority field → recipe → default → raw message; a field's message appears once the user changes its value (`dirty`), leaves it (`touched`) or submits the form, and a field never changed shows nothing before that; after `reset()` and `resetSubmitAttempt()`, messages stay hidden again until the next change, exit or submit; server errors are shown by their `message`, translated by the caller, otherwise by the key `errors.<code>`; a field error set by the host application as `{ kind: 'server', error: { code, constraint?, message } }` is read as is.
|
|
13
13
|
- **Server errors by path**: `RecipeServerPaths` records the position → key mapping of each `array` when the request is sent; `rooms[2].code` is set on the item that was at position 2, the error clears as soon as the value changes, and whatever cannot be placed comes out through `unplacedServerErrors`.
|
|
14
14
|
- **Sections**: `RecipeSections` (field index, error count, first field in error).
|
|
15
15
|
- **Tailwind layout**, **response time measurement** of server validators.
|
|
@@ -95,7 +95,7 @@ provideRecipeForms({
|
|
|
95
95
|
- **Controls**: the engine renders each control (`text`, `number`, `select`, `date`, `dateMultiple`, `checkbox`) with a template from the `RecipeUi` registry. The host passes to `provideRecipeForms({ ui })` a component that declares one `<ng-template appRecipeTextControl let-field let-inputId="inputId" …>` (`appRecipeNumberControl`, `appRecipeSelectControl`, `appRecipeDateControl`, `appRecipeDateMultipleControl`, `appRecipeCheckboxControl`) per control to render with its design system, and binds its wrapper to it with `[formField]="field"`. A control it does not declare keeps the default template. `RecipeDefaultUiComponent` (`ui/recipe-default-ui.ts`) declares the six templates with the wrappers from `ui/` and serves as a model; the context of each template is typed (`RecipeTextControlContext`…). The registry creates these components once, outside the application tree; a template's view is refreshed with the field that inserts it, and updated in place when its context changes (the control keeps its focus). Learning tests: `specs/ui-seam.learning.spec.ts`.
|
|
96
96
|
- **Messages, buttons, panels and tabs**: the engine renders them through `app-recipe-message`, `app-recipe-button`, `app-recipe-panel` and `app-recipe-tabs`, which keep the id targeted by `aria-describedby`, the placement classes and the state (collapsed panel, active tab), and render the registry template inside: `appRecipeMessage` (translated text, `severity`, `inline`), `appRecipeButton` (label, `variant`, `severity`, `click`), `appRecipePanel` (`let-content` to render with `ngTemplateOutlet`, texts, `collapsed` and `toggle`), `appRecipeTabs` (`let-panels`, one `{ value, template }` per section, to render without ever destroying it, `options`, `value`, `select`, `fill`). The tabs template tracks panels by `value`: the list is recreated on each computation of the context.
|
|
97
97
|
- For a single field, a `SLOT` control renders the template provided by the caller. The wrappers in `ui/` remain those of the default templates. Contracts expected from the wrappers:
|
|
98
|
-
- every control: Signal Forms contract (`value` or `checked`, `disabled`, `invalid`, `touched`, `touch` output), `inputId` and `describedBy` inputs (`aria-describedby` set on the element that receives focus), a `focus(options?: FocusOptions)` method that passes `options` to the native focus (focus of the first field in error, called with `preventScroll: true`: the engine then scrolls `app-recipe-field` to the center with `scrollIntoView({ block: 'center' })`);
|
|
98
|
+
- every control: Signal Forms contract (`value` or `checked`, `disabled`, `invalid`, `touched`, `dirty`, `touch` output; `aria-invalid="true"` when invalid and touched or dirty, like the message under the field), `inputId` and `describedBy` inputs (`aria-describedby` set on the element that receives focus), a `focus(options?: FocusOptions)` method that passes `options` to the native focus (focus of the first field in error, called with `preventScroll: true`: the engine then scrolls `app-recipe-field` to the center with `scrollIntoView({ block: 'center' })`);
|
|
99
99
|
- `app-input-text`: `placeholder` (`''` by default), `inputmode` (`'text'` by default), `maxLength` (a `FormValueControl` input, bound by `[formField]` to the `MAX_LENGTH` rule), `icon` (trailing icon, none by default; the engine passes `TextControlDef.icon` as is, an icon name of the host's wrapper, `string` by default and restricted to the host's names if it extends `RecipeIconTypes` (`declare module 'ngx-recipe-forms' { interface RecipeIconTypes { icon: IconEnum } }`); the default wrapper accepts it without drawing it);
|
|
100
100
|
- `app-input-number`: `step`, `minFractionDigits` (decimals always shown), `maxFractionDigits` (decimals allowed when typing, 3 by default);
|
|
101
101
|
- `app-select`: `options: SelectOption<T>[]` (`[]` by default; the field passes a copy, with `label` already translated for a recipe option using `labelKey`), `showClear`, `filter` (search in the list, `false` by default; the engine passes `filter ?? false`; the native `<select>` of the default wrapper ignores it and keeps the browser's first-letter search), `ariaLabelledBy` (id of the label: a design system's dropdown is often not a native field), `placeholder` (text shown when the value is `null`, translation of `SelectControlDef.placeholderKey`, `''` without a key). In `readonly` mode, the list stays focusable (never `disabled` for read-only), does not open, does not change value from the keyboard, has neither chevron nor pointer cursor and carries `aria-readonly="true"`; the `RecipeSelectControlContext` context passes `placeholder` and `readonly` to the template. Contract spec of the default template: `specs/recipe-select-readonly.spec.ts`;
|
|
@@ -106,7 +106,7 @@ provideRecipeForms({
|
|
|
106
106
|
- `app-message`: `severity` (`SeverityEnum`, including the `WARNING` key), `inline`, projected content; `[id]` set on the host element.
|
|
107
107
|
- Translator: `RECIPE_FORM_TRANSLATOR` and `RECIPE_FORM_TRANSLATION_CHANGES` are provided with `useFactory`: the factory can inject the application's i18n service (see "Providers" above). Without a translator, the key is shown as is. The `recipeTranslate` pipe is impure (lazily loaded scopes).
|
|
108
108
|
- `translationChanges`: the `labelKey` options of a `select`, tab titles and count texts are translated by the translator in a `computed`, not by the impure pipe: they are recomputed whenever their data changes and, with `translationChanges`, whenever translations load; without this option, the scope that holds their keys must be loaded before the form renders.
|
|
109
|
-
- Default keys: they are listed by the `RECIPE_FORM_DEFAULT_KEYS` constant (`constants/recipe-form-default-keys.constants.ts`); a host spec checks that its flattened dictionary (`forms.array.add`) contains each of them (model: `projects/playground/src/app/i18n/fr.spec.ts`): `forms.errors.*` (including `minItems`, `maxItems`, `unique`), `forms.warnings.validationUnavailable`, `forms.pending`, `forms.array.*`, `forms.display.errorCountOne` and `forms.display.errorCount` ("{{ count }} error", "{{ count }} errors": the engine uses the first one when `count` is 1 and the second otherwise, since the translator has no plural), `forms.display.collapsePanel` and `forms.display.expandPanel` ("Collapse panel {{ title }}", "Expand panel {{ title }}"), and, outside the constant, `errors.<code>` (or `<scope>.errors.<code>`) for server codes.
|
|
109
|
+
- Default keys: they are listed by the `RECIPE_FORM_DEFAULT_KEYS` constant (`constants/recipe-form-default-keys.constants.ts`); a host spec checks that its flattened dictionary (`forms.array.add`) contains each of them (model: `projects/playground/src/app/i18n/fr.spec.ts`): `forms.errors.*` (including `minItems`, `maxItems`, `unique`, and `invalidDate` for a typed date that does not exist, set by the host date wrapper), `forms.warnings.validationUnavailable`, `forms.pending`, `forms.array.*`, `forms.display.errorCountOne` and `forms.display.errorCount` ("{{ count }} error", "{{ count }} errors": the engine uses the first one when `count` is 1 and the second otherwise, since the translator has no plural), `forms.display.collapsePanel` and `forms.display.expandPanel` ("Collapse panel {{ title }}", "Expand panel {{ title }}"), and, outside the constant, `errors.<code>` (or `<scope>.errors.<code>`) for server codes.
|
|
110
110
|
|
|
111
111
|
## In the host application
|
|
112
112
|
|
|
@@ -120,7 +120,8 @@ const FORM_ERROR_MESSAGES = {
|
|
|
120
120
|
email: "forms.errors.email",
|
|
121
121
|
minItems: "forms.errors.minItems",
|
|
122
122
|
maxItems: "forms.errors.maxItems",
|
|
123
|
-
unique: "forms.errors.unique"
|
|
123
|
+
unique: "forms.errors.unique",
|
|
124
|
+
invalidDate: "forms.errors.invalidDate"
|
|
124
125
|
};
|
|
125
126
|
const FORM_LAYOUT_COLUMNS = {
|
|
126
127
|
[BreakpointEnum.BASE]: {
|
|
@@ -248,6 +249,7 @@ const RECIPE_FORM_DEFAULT_KEYS = [
|
|
|
248
249
|
"forms.errors.minItems",
|
|
249
250
|
"forms.errors.maxItems",
|
|
250
251
|
"forms.errors.unique",
|
|
252
|
+
"forms.errors.invalidDate",
|
|
251
253
|
"forms.errors.unknown",
|
|
252
254
|
"forms.warnings.validationUnavailable",
|
|
253
255
|
"forms.pending",
|
|
@@ -1032,6 +1034,7 @@ var CheckboxComponent = class CheckboxComponent {
|
|
|
1032
1034
|
readonly = input(false, ...ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []);
|
|
1033
1035
|
invalid = input(false, ...ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []);
|
|
1034
1036
|
touched = input(false, ...ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []);
|
|
1037
|
+
dirty = input(false, ...ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []);
|
|
1035
1038
|
describedBy = input(...ngDevMode ? [void 0, { debugName: "describedBy" }] : /* istanbul ignore next */ []);
|
|
1036
1039
|
touch = output();
|
|
1037
1040
|
control = viewChild.required("control", ...ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []);
|
|
@@ -1108,6 +1111,13 @@ var CheckboxComponent = class CheckboxComponent {
|
|
|
1108
1111
|
isRequired: false,
|
|
1109
1112
|
transformFunction: null
|
|
1110
1113
|
},
|
|
1114
|
+
dirty: {
|
|
1115
|
+
classPropertyName: "dirty",
|
|
1116
|
+
publicName: "dirty",
|
|
1117
|
+
isSignal: true,
|
|
1118
|
+
isRequired: false,
|
|
1119
|
+
transformFunction: null
|
|
1120
|
+
},
|
|
1111
1121
|
describedBy: {
|
|
1112
1122
|
classPropertyName: "describedBy",
|
|
1113
1123
|
publicName: "describedBy",
|
|
@@ -1134,7 +1144,7 @@ var CheckboxComponent = class CheckboxComponent {
|
|
|
1134
1144
|
type="checkbox"
|
|
1135
1145
|
[id]="inputId()"
|
|
1136
1146
|
[attr.name]="name()"
|
|
1137
|
-
[attr.aria-invalid]="invalid() && touched() ? 'true' : null"
|
|
1147
|
+
[attr.aria-invalid]="invalid() && (touched() || dirty()) ? 'true' : null"
|
|
1138
1148
|
[attr.aria-describedby]="describedBy() ?? null"
|
|
1139
1149
|
[attr.aria-readonly]="readonly() ? 'true' : null"
|
|
1140
1150
|
[disabled]="disabled()"
|
|
@@ -1166,7 +1176,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1166
1176
|
type="checkbox"
|
|
1167
1177
|
[id]="inputId()"
|
|
1168
1178
|
[attr.name]="name()"
|
|
1169
|
-
[attr.aria-invalid]="invalid() && touched() ? 'true' : null"
|
|
1179
|
+
[attr.aria-invalid]="invalid() && (touched() || dirty()) ? 'true' : null"
|
|
1170
1180
|
[attr.aria-describedby]="describedBy() ?? null"
|
|
1171
1181
|
[attr.aria-readonly]="readonly() ? 'true' : null"
|
|
1172
1182
|
[disabled]="disabled()"
|
|
@@ -1240,6 +1250,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1240
1250
|
required: false
|
|
1241
1251
|
}]
|
|
1242
1252
|
}],
|
|
1253
|
+
dirty: [{
|
|
1254
|
+
type: i0.Input,
|
|
1255
|
+
args: [{
|
|
1256
|
+
isSignal: true,
|
|
1257
|
+
alias: "dirty",
|
|
1258
|
+
required: false
|
|
1259
|
+
}]
|
|
1260
|
+
}],
|
|
1243
1261
|
describedBy: [{
|
|
1244
1262
|
type: i0.Input,
|
|
1245
1263
|
args: [{
|
|
@@ -1323,6 +1341,7 @@ var DatePickerMultipleComponent = class DatePickerMultipleComponent {
|
|
|
1323
1341
|
readonly = input(false, ...ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []);
|
|
1324
1342
|
invalid = input(false, ...ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []);
|
|
1325
1343
|
touched = input(false, ...ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []);
|
|
1344
|
+
dirty = input(false, ...ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []);
|
|
1326
1345
|
required = input(false, ...ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []);
|
|
1327
1346
|
ariaLabel = input(...ngDevMode ? [void 0, { debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
|
|
1328
1347
|
describedBy = input(...ngDevMode ? [void 0, { debugName: "describedBy" }] : /* istanbul ignore next */ []);
|
|
@@ -1427,6 +1446,13 @@ var DatePickerMultipleComponent = class DatePickerMultipleComponent {
|
|
|
1427
1446
|
isRequired: false,
|
|
1428
1447
|
transformFunction: null
|
|
1429
1448
|
},
|
|
1449
|
+
dirty: {
|
|
1450
|
+
classPropertyName: "dirty",
|
|
1451
|
+
publicName: "dirty",
|
|
1452
|
+
isSignal: true,
|
|
1453
|
+
isRequired: false,
|
|
1454
|
+
transformFunction: null
|
|
1455
|
+
},
|
|
1430
1456
|
required: {
|
|
1431
1457
|
classPropertyName: "required",
|
|
1432
1458
|
publicName: "required",
|
|
@@ -1490,7 +1516,7 @@ var DatePickerMultipleComponent = class DatePickerMultipleComponent {
|
|
|
1490
1516
|
[id]="inputId()"
|
|
1491
1517
|
[attr.name]="name()"
|
|
1492
1518
|
[attr.max]="maxInputValue()"
|
|
1493
|
-
[attr.aria-invalid]="invalid() && touched() ? 'true' : null"
|
|
1519
|
+
[attr.aria-invalid]="invalid() && (touched() || dirty()) ? 'true' : null"
|
|
1494
1520
|
[attr.aria-describedby]="describedBy() ?? null"
|
|
1495
1521
|
[attr.aria-required]="required() ? 'true' : null"
|
|
1496
1522
|
[disabled]="disabled()"
|
|
@@ -1577,7 +1603,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1577
1603
|
[id]="inputId()"
|
|
1578
1604
|
[attr.name]="name()"
|
|
1579
1605
|
[attr.max]="maxInputValue()"
|
|
1580
|
-
[attr.aria-invalid]="invalid() && touched() ? 'true' : null"
|
|
1606
|
+
[attr.aria-invalid]="invalid() && (touched() || dirty()) ? 'true' : null"
|
|
1581
1607
|
[attr.aria-describedby]="describedBy() ?? null"
|
|
1582
1608
|
[attr.aria-required]="required() ? 'true' : null"
|
|
1583
1609
|
[disabled]="disabled()"
|
|
@@ -1680,6 +1706,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1680
1706
|
required: false
|
|
1681
1707
|
}]
|
|
1682
1708
|
}],
|
|
1709
|
+
dirty: [{
|
|
1710
|
+
type: i0.Input,
|
|
1711
|
+
args: [{
|
|
1712
|
+
isSignal: true,
|
|
1713
|
+
alias: "dirty",
|
|
1714
|
+
required: false
|
|
1715
|
+
}]
|
|
1716
|
+
}],
|
|
1683
1717
|
required: [{
|
|
1684
1718
|
type: i0.Input,
|
|
1685
1719
|
args: [{
|
|
@@ -1746,6 +1780,7 @@ var DatePickerComponent = class DatePickerComponent {
|
|
|
1746
1780
|
readonly = input(false, ...ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []);
|
|
1747
1781
|
invalid = input(false, ...ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []);
|
|
1748
1782
|
touched = input(false, ...ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []);
|
|
1783
|
+
dirty = input(false, ...ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []);
|
|
1749
1784
|
required = input(false, ...ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []);
|
|
1750
1785
|
describedBy = input(...ngDevMode ? [void 0, { debugName: "describedBy" }] : /* istanbul ignore next */ []);
|
|
1751
1786
|
touch = output();
|
|
@@ -1822,6 +1857,13 @@ var DatePickerComponent = class DatePickerComponent {
|
|
|
1822
1857
|
isRequired: false,
|
|
1823
1858
|
transformFunction: null
|
|
1824
1859
|
},
|
|
1860
|
+
dirty: {
|
|
1861
|
+
classPropertyName: "dirty",
|
|
1862
|
+
publicName: "dirty",
|
|
1863
|
+
isSignal: true,
|
|
1864
|
+
isRequired: false,
|
|
1865
|
+
transformFunction: null
|
|
1866
|
+
},
|
|
1825
1867
|
required: {
|
|
1826
1868
|
classPropertyName: "required",
|
|
1827
1869
|
publicName: "required",
|
|
@@ -1855,7 +1897,7 @@ var DatePickerComponent = class DatePickerComponent {
|
|
|
1855
1897
|
type="date"
|
|
1856
1898
|
[id]="inputId()"
|
|
1857
1899
|
[attr.name]="name()"
|
|
1858
|
-
[attr.aria-invalid]="invalid() && touched() ? 'true' : null"
|
|
1900
|
+
[attr.aria-invalid]="invalid() && (touched() || dirty()) ? 'true' : null"
|
|
1859
1901
|
[attr.aria-describedby]="describedBy() ?? null"
|
|
1860
1902
|
[attr.aria-required]="required() ? 'true' : null"
|
|
1861
1903
|
[disabled]="disabled()"
|
|
@@ -1886,7 +1928,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1886
1928
|
type="date"
|
|
1887
1929
|
[id]="inputId()"
|
|
1888
1930
|
[attr.name]="name()"
|
|
1889
|
-
[attr.aria-invalid]="invalid() && touched() ? 'true' : null"
|
|
1931
|
+
[attr.aria-invalid]="invalid() && (touched() || dirty()) ? 'true' : null"
|
|
1890
1932
|
[attr.aria-describedby]="describedBy() ?? null"
|
|
1891
1933
|
[attr.aria-required]="required() ? 'true' : null"
|
|
1892
1934
|
[disabled]="disabled()"
|
|
@@ -1959,6 +2001,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1959
2001
|
required: false
|
|
1960
2002
|
}]
|
|
1961
2003
|
}],
|
|
2004
|
+
dirty: [{
|
|
2005
|
+
type: i0.Input,
|
|
2006
|
+
args: [{
|
|
2007
|
+
isSignal: true,
|
|
2008
|
+
alias: "dirty",
|
|
2009
|
+
required: false
|
|
2010
|
+
}]
|
|
2011
|
+
}],
|
|
1962
2012
|
required: [{
|
|
1963
2013
|
type: i0.Input,
|
|
1964
2014
|
args: [{
|
|
@@ -1994,6 +2044,7 @@ var InputNumberComponent = class InputNumberComponent {
|
|
|
1994
2044
|
readonly = input(false, ...ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []);
|
|
1995
2045
|
invalid = input(false, ...ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []);
|
|
1996
2046
|
touched = input(false, ...ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []);
|
|
2047
|
+
dirty = input(false, ...ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []);
|
|
1997
2048
|
required = input(false, ...ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []);
|
|
1998
2049
|
step = input(...ngDevMode ? [void 0, { debugName: "step" }] : /* istanbul ignore next */ []);
|
|
1999
2050
|
minFractionDigits = input(...ngDevMode ? [void 0, { debugName: "minFractionDigits" }] : /* istanbul ignore next */ []);
|
|
@@ -2100,6 +2151,13 @@ var InputNumberComponent = class InputNumberComponent {
|
|
|
2100
2151
|
isRequired: false,
|
|
2101
2152
|
transformFunction: null
|
|
2102
2153
|
},
|
|
2154
|
+
dirty: {
|
|
2155
|
+
classPropertyName: "dirty",
|
|
2156
|
+
publicName: "dirty",
|
|
2157
|
+
isSignal: true,
|
|
2158
|
+
isRequired: false,
|
|
2159
|
+
transformFunction: null
|
|
2160
|
+
},
|
|
2103
2161
|
required: {
|
|
2104
2162
|
classPropertyName: "required",
|
|
2105
2163
|
publicName: "required",
|
|
@@ -2155,7 +2213,7 @@ var InputNumberComponent = class InputNumberComponent {
|
|
|
2155
2213
|
[id]="inputId()"
|
|
2156
2214
|
[attr.name]="name()"
|
|
2157
2215
|
[attr.step]="step() ?? null"
|
|
2158
|
-
[attr.aria-invalid]="invalid() && touched() ? 'true' : null"
|
|
2216
|
+
[attr.aria-invalid]="invalid() && (touched() || dirty()) ? 'true' : null"
|
|
2159
2217
|
[attr.aria-describedby]="describedBy() ?? null"
|
|
2160
2218
|
[attr.aria-required]="required() ? 'true' : null"
|
|
2161
2219
|
[disabled]="disabled()"
|
|
@@ -2187,7 +2245,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2187
2245
|
[id]="inputId()"
|
|
2188
2246
|
[attr.name]="name()"
|
|
2189
2247
|
[attr.step]="step() ?? null"
|
|
2190
|
-
[attr.aria-invalid]="invalid() && touched() ? 'true' : null"
|
|
2248
|
+
[attr.aria-invalid]="invalid() && (touched() || dirty()) ? 'true' : null"
|
|
2191
2249
|
[attr.aria-describedby]="describedBy() ?? null"
|
|
2192
2250
|
[attr.aria-required]="required() ? 'true' : null"
|
|
2193
2251
|
[disabled]="disabled()"
|
|
@@ -2260,6 +2318,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2260
2318
|
required: false
|
|
2261
2319
|
}]
|
|
2262
2320
|
}],
|
|
2321
|
+
dirty: [{
|
|
2322
|
+
type: i0.Input,
|
|
2323
|
+
args: [{
|
|
2324
|
+
isSignal: true,
|
|
2325
|
+
alias: "dirty",
|
|
2326
|
+
required: false
|
|
2327
|
+
}]
|
|
2328
|
+
}],
|
|
2263
2329
|
required: [{
|
|
2264
2330
|
type: i0.Input,
|
|
2265
2331
|
args: [{
|
|
@@ -2318,6 +2384,7 @@ var InputTextComponent = class InputTextComponent {
|
|
|
2318
2384
|
readonly = input(false, ...ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []);
|
|
2319
2385
|
invalid = input(false, ...ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []);
|
|
2320
2386
|
touched = input(false, ...ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []);
|
|
2387
|
+
dirty = input(false, ...ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []);
|
|
2321
2388
|
required = input(false, ...ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []);
|
|
2322
2389
|
placeholder = input("", ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
|
|
2323
2390
|
inputmode = input("text", ...ngDevMode ? [{ debugName: "inputmode" }] : /* istanbul ignore next */ []);
|
|
@@ -2397,6 +2464,13 @@ var InputTextComponent = class InputTextComponent {
|
|
|
2397
2464
|
isRequired: false,
|
|
2398
2465
|
transformFunction: null
|
|
2399
2466
|
},
|
|
2467
|
+
dirty: {
|
|
2468
|
+
classPropertyName: "dirty",
|
|
2469
|
+
publicName: "dirty",
|
|
2470
|
+
isSignal: true,
|
|
2471
|
+
isRequired: false,
|
|
2472
|
+
transformFunction: null
|
|
2473
|
+
},
|
|
2400
2474
|
required: {
|
|
2401
2475
|
classPropertyName: "required",
|
|
2402
2476
|
publicName: "required",
|
|
@@ -2460,7 +2534,7 @@ var InputTextComponent = class InputTextComponent {
|
|
|
2460
2534
|
[attr.name]="name()"
|
|
2461
2535
|
[attr.inputmode]="inputmode()"
|
|
2462
2536
|
[attr.maxlength]="maxLength() ?? null"
|
|
2463
|
-
[attr.aria-invalid]="invalid() && touched() ? 'true' : null"
|
|
2537
|
+
[attr.aria-invalid]="invalid() && (touched() || dirty()) ? 'true' : null"
|
|
2464
2538
|
[attr.aria-describedby]="describedBy() ?? null"
|
|
2465
2539
|
[attr.aria-required]="required() ? 'true' : null"
|
|
2466
2540
|
[placeholder]="placeholder()"
|
|
@@ -2494,7 +2568,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2494
2568
|
[attr.name]="name()"
|
|
2495
2569
|
[attr.inputmode]="inputmode()"
|
|
2496
2570
|
[attr.maxlength]="maxLength() ?? null"
|
|
2497
|
-
[attr.aria-invalid]="invalid() && touched() ? 'true' : null"
|
|
2571
|
+
[attr.aria-invalid]="invalid() && (touched() || dirty()) ? 'true' : null"
|
|
2498
2572
|
[attr.aria-describedby]="describedBy() ?? null"
|
|
2499
2573
|
[attr.aria-required]="required() ? 'true' : null"
|
|
2500
2574
|
[placeholder]="placeholder()"
|
|
@@ -2568,6 +2642,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2568
2642
|
required: false
|
|
2569
2643
|
}]
|
|
2570
2644
|
}],
|
|
2645
|
+
dirty: [{
|
|
2646
|
+
type: i0.Input,
|
|
2647
|
+
args: [{
|
|
2648
|
+
isSignal: true,
|
|
2649
|
+
alias: "dirty",
|
|
2650
|
+
required: false
|
|
2651
|
+
}]
|
|
2652
|
+
}],
|
|
2571
2653
|
required: [{
|
|
2572
2654
|
type: i0.Input,
|
|
2573
2655
|
args: [{
|
|
@@ -2972,6 +3054,7 @@ var SelectComponent = class SelectComponent {
|
|
|
2972
3054
|
readonly = input(false, ...ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []);
|
|
2973
3055
|
invalid = input(false, ...ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []);
|
|
2974
3056
|
touched = input(false, ...ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []);
|
|
3057
|
+
dirty = input(false, ...ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []);
|
|
2975
3058
|
required = input(false, ...ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []);
|
|
2976
3059
|
showClear = input(false, ...ngDevMode ? [{ debugName: "showClear" }] : /* istanbul ignore next */ []);
|
|
2977
3060
|
filter = input(false, ...ngDevMode ? [{ debugName: "filter" }] : /* istanbul ignore next */ []);
|
|
@@ -3083,6 +3166,13 @@ var SelectComponent = class SelectComponent {
|
|
|
3083
3166
|
isRequired: false,
|
|
3084
3167
|
transformFunction: null
|
|
3085
3168
|
},
|
|
3169
|
+
dirty: {
|
|
3170
|
+
classPropertyName: "dirty",
|
|
3171
|
+
publicName: "dirty",
|
|
3172
|
+
isSignal: true,
|
|
3173
|
+
isRequired: false,
|
|
3174
|
+
transformFunction: null
|
|
3175
|
+
},
|
|
3086
3176
|
required: {
|
|
3087
3177
|
classPropertyName: "required",
|
|
3088
3178
|
publicName: "required",
|
|
@@ -3151,7 +3241,7 @@ var SelectComponent = class SelectComponent {
|
|
|
3151
3241
|
[id]="inputId()"
|
|
3152
3242
|
[attr.name]="name()"
|
|
3153
3243
|
[attr.aria-labelledby]="ariaLabelledBy() ?? null"
|
|
3154
|
-
[attr.aria-invalid]="invalid() && touched() ? 'true' : null"
|
|
3244
|
+
[attr.aria-invalid]="invalid() && (touched() || dirty()) ? 'true' : null"
|
|
3155
3245
|
[attr.aria-describedby]="describedBy() ?? null"
|
|
3156
3246
|
[attr.aria-required]="required() ? 'true' : null"
|
|
3157
3247
|
[attr.aria-readonly]="readonly() ? 'true' : null"
|
|
@@ -3197,7 +3287,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3197
3287
|
[id]="inputId()"
|
|
3198
3288
|
[attr.name]="name()"
|
|
3199
3289
|
[attr.aria-labelledby]="ariaLabelledBy() ?? null"
|
|
3200
|
-
[attr.aria-invalid]="invalid() && touched() ? 'true' : null"
|
|
3290
|
+
[attr.aria-invalid]="invalid() && (touched() || dirty()) ? 'true' : null"
|
|
3201
3291
|
[attr.aria-describedby]="describedBy() ?? null"
|
|
3202
3292
|
[attr.aria-required]="required() ? 'true' : null"
|
|
3203
3293
|
[attr.aria-readonly]="readonly() ? 'true' : null"
|
|
@@ -3293,6 +3383,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3293
3383
|
required: false
|
|
3294
3384
|
}]
|
|
3295
3385
|
}],
|
|
3386
|
+
dirty: [{
|
|
3387
|
+
type: i0.Input,
|
|
3388
|
+
args: [{
|
|
3389
|
+
isSignal: true,
|
|
3390
|
+
alias: "dirty",
|
|
3391
|
+
required: false
|
|
3392
|
+
}]
|
|
3393
|
+
}],
|
|
3296
3394
|
required: [{
|
|
3297
3395
|
type: i0.Input,
|
|
3298
3396
|
args: [{
|
|
@@ -3918,6 +4016,7 @@ var RecipeDefaultUiComponent = class RecipeDefaultUiComponent {
|
|
|
3918
4016
|
"readonly",
|
|
3919
4017
|
"invalid",
|
|
3920
4018
|
"touched",
|
|
4019
|
+
"dirty",
|
|
3921
4020
|
"describedBy"
|
|
3922
4021
|
],
|
|
3923
4022
|
outputs: ["checkedChange", "touch"]
|
|
@@ -3934,6 +4033,7 @@ var RecipeDefaultUiComponent = class RecipeDefaultUiComponent {
|
|
|
3934
4033
|
"readonly",
|
|
3935
4034
|
"invalid",
|
|
3936
4035
|
"touched",
|
|
4036
|
+
"dirty",
|
|
3937
4037
|
"required",
|
|
3938
4038
|
"describedBy"
|
|
3939
4039
|
],
|
|
@@ -3951,6 +4051,7 @@ var RecipeDefaultUiComponent = class RecipeDefaultUiComponent {
|
|
|
3951
4051
|
"readonly",
|
|
3952
4052
|
"invalid",
|
|
3953
4053
|
"touched",
|
|
4054
|
+
"dirty",
|
|
3954
4055
|
"required",
|
|
3955
4056
|
"ariaLabel",
|
|
3956
4057
|
"describedBy",
|
|
@@ -3976,6 +4077,7 @@ var RecipeDefaultUiComponent = class RecipeDefaultUiComponent {
|
|
|
3976
4077
|
"readonly",
|
|
3977
4078
|
"invalid",
|
|
3978
4079
|
"touched",
|
|
4080
|
+
"dirty",
|
|
3979
4081
|
"required",
|
|
3980
4082
|
"step",
|
|
3981
4083
|
"minFractionDigits",
|
|
@@ -3996,6 +4098,7 @@ var RecipeDefaultUiComponent = class RecipeDefaultUiComponent {
|
|
|
3996
4098
|
"readonly",
|
|
3997
4099
|
"invalid",
|
|
3998
4100
|
"touched",
|
|
4101
|
+
"dirty",
|
|
3999
4102
|
"required",
|
|
4000
4103
|
"placeholder",
|
|
4001
4104
|
"inputmode",
|
|
@@ -4039,6 +4142,7 @@ var RecipeDefaultUiComponent = class RecipeDefaultUiComponent {
|
|
|
4039
4142
|
"readonly",
|
|
4040
4143
|
"invalid",
|
|
4041
4144
|
"touched",
|
|
4145
|
+
"dirty",
|
|
4042
4146
|
"required",
|
|
4043
4147
|
"showClear",
|
|
4044
4148
|
"filter",
|
|
@@ -4580,7 +4684,7 @@ const RESERVED_KEYS = /* @__PURE__ */ new Set([
|
|
|
4580
4684
|
]);
|
|
4581
4685
|
var RecipeMessages = class RecipeMessages {
|
|
4582
4686
|
static resolve(input) {
|
|
4583
|
-
if (!input.touched && !input.submitted) return;
|
|
4687
|
+
if (!input.touched && !input.dirty && !input.submitted) return;
|
|
4584
4688
|
const [first] = input.errors;
|
|
4585
4689
|
return first === void 0 ? void 0 : RecipeMessages.forError(first, input.fieldMessages, input.recipeMessages);
|
|
4586
4690
|
}
|
|
@@ -5016,12 +5120,16 @@ var RecipeSections = class RecipeSections {
|
|
|
5016
5120
|
if (state.hidden()) continue;
|
|
5017
5121
|
for (const error of state.errorSummary()) {
|
|
5018
5122
|
const errorState = error.fieldTree();
|
|
5019
|
-
|
|
5123
|
+
const shown = errorState.touched() || errorState.dirty() || input.submitted;
|
|
5124
|
+
if (!errorState.hidden() && shown) found.add(error.fieldTree);
|
|
5020
5125
|
}
|
|
5021
5126
|
}
|
|
5022
5127
|
for (const error of input.tree().errors()) if ("linkedId" in error && typeof error.linkedId === "string") {
|
|
5023
5128
|
const linkedKeys = error.linkedId.split("+");
|
|
5024
|
-
if ((input.submitted || linkedKeys.every((key) =>
|
|
5129
|
+
if ((input.submitted || linkedKeys.every((key) => {
|
|
5130
|
+
const state = input.tree[key]?.();
|
|
5131
|
+
return state !== void 0 && (state.touched() || state.dirty());
|
|
5132
|
+
})) && linkedKeys.every((key) => keys.has(key))) found.add(error.linkedId);
|
|
5025
5133
|
}
|
|
5026
5134
|
for (const [path, key] of input.serverErrorKeys ?? []) if (keys.has(key)) found.add(`server:${path}`);
|
|
5027
5135
|
return found.size;
|
|
@@ -5365,6 +5473,7 @@ var RecipeFieldComponent = class RecipeFieldComponent {
|
|
|
5365
5473
|
return RecipeMessages.resolve({
|
|
5366
5474
|
errors: [...this.ownErrors(), ...server],
|
|
5367
5475
|
touched: this.state().touched() || server.length > 0,
|
|
5476
|
+
dirty: this.state().dirty(),
|
|
5368
5477
|
submitted: this.context.submitted(),
|
|
5369
5478
|
fieldMessages: this.node().messages,
|
|
5370
5479
|
recipeMessages: this.context.recipeMessages()
|
|
@@ -5372,7 +5481,7 @@ var RecipeFieldComponent = class RecipeFieldComponent {
|
|
|
5372
5481
|
}, ...ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []);
|
|
5373
5482
|
warnings = computed(() => {
|
|
5374
5483
|
const state = this.state();
|
|
5375
|
-
const ruleWarnings = state.touched() || this.context.submitted() ? state.metadata(FORM_WARNINGS)?.() ?? [] : [];
|
|
5484
|
+
const ruleWarnings = state.touched() || state.dirty() || this.context.submitted() ? state.metadata(FORM_WARNINGS)?.() ?? [] : [];
|
|
5376
5485
|
const messages = RecipeMessages.forAll([...ruleWarnings, ...this.serverWarnings()], this.node().messages, this.context.recipeMessages());
|
|
5377
5486
|
return state.metadata(FORM_VALIDATION_UNAVAILABLE)?.() === true ? [...messages, { key: FORM_VALIDATION_UNAVAILABLE_MESSAGE }] : messages;
|
|
5378
5487
|
}, ...ngDevMode ? [{ debugName: "warnings" }] : /* istanbul ignore next */ []);
|
|
@@ -6454,10 +6563,11 @@ var RecipeNodeComponent = class RecipeNodeComponent {
|
|
|
6454
6563
|
const target = this.linkedTarget();
|
|
6455
6564
|
const source = target === void 0 ? this.tree()() : this.fieldTreeOf(target)();
|
|
6456
6565
|
const errors = source.errors().filter((error) => "linkedId" in error && error.linkedId === linkedId);
|
|
6457
|
-
const
|
|
6566
|
+
const states = target === void 0 ? linked.keys.map((key) => this.fieldTreeOf(key)()) : [source];
|
|
6458
6567
|
return RecipeMessages.resolve({
|
|
6459
6568
|
errors,
|
|
6460
|
-
touched,
|
|
6569
|
+
touched: states.every((state) => state.touched() || state.dirty()),
|
|
6570
|
+
dirty: states.every((state) => state.dirty()),
|
|
6461
6571
|
submitted: this.context.submitted(),
|
|
6462
6572
|
fieldMessages: linked.messages,
|
|
6463
6573
|
recipeMessages: this.context.recipeMessages()
|
|
@@ -6501,6 +6611,7 @@ var RecipeNodeComponent = class RecipeNodeComponent {
|
|
|
6501
6611
|
return RecipeMessages.resolve({
|
|
6502
6612
|
errors: [...own, ...server],
|
|
6503
6613
|
touched: state.touched() || server.length > 0,
|
|
6614
|
+
dirty: state.dirty(),
|
|
6504
6615
|
submitted: this.context.submitted(),
|
|
6505
6616
|
fieldMessages: array.messages,
|
|
6506
6617
|
recipeMessages: this.context.recipeMessages()
|