ngx-recipe-forms 0.0.0-stage → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,131 @@
1
- # Temporary Holding Version
1
+ # ngx-recipe-forms
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Generic **recipe-based** form engine, built on Angular Signal Forms (`@angular/forms/signals`, Angular 22.2) and Tailwind 4.
4
+ A recipe is **an object typed by the model**, declared in code; the engine derives the Signal Forms schema, the rendering, the messages and the layout from it.
5
+
6
+ To write a recipe, follow [`AGENTS.md`](https://github.com/SrenoG/ngx-recipe-forms/blob/main/AGENTS.md) (in French: method, catalog, pitfalls, checklist).
7
+
8
+ ## What the library does
9
+
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
+ - **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.
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
+ - **Sections**: `RecipeSections` (field index, error count, first field in error).
15
+ - **Tailwind layout**, **response time measurement** of server validators.
16
+ - **Rendering**: `<app-recipe-form>`, `<app-recipe-node>`, `<app-recipe-section-group>` (`plain`, `panel` and `tabs` formats, error counts per panel or per tab, opening the panel or activating the tab of the first field in error; no format destroys a section), `<app-recipe-field>`, `array` as a list or a table with a slot and an API (`addItem`, `removeItem`, `has`, `items`, declared sort). Default wrappers `app-input-text`, `app-input-number` (decimals bounded by `minFractionDigits` and `maxFractionDigits`), `app-select`, `app-date-picker`, `app-date-picker-multiple`, `app-checkbox`, `app-button`, `app-panel`, `app-tabs` (with `TabPanelDirective`), and `app-message` for field, group and list messages. Under a field: the hint (`hintKey`, conditional through `{ key, when?, showWhenReadonly? }`, hidden in read-only mode like the required asterisk), then the translated reason of an active `disabled` rule (`reasonKey`), in the same style, removed when the field is enabled again. The `labelKey` options of a `select` are translated by the engine before they reach the wrapper. A table `array` scrolls in its own container (`overflow-x-auto`); a cell message wraps instead of widening its column.
17
+
18
+ ## Usage
19
+
20
+ ```ts
21
+ // 1. The form model, in plain values (the conversion to the DTO stays in the mapper).
22
+ interface CourseFormData { deliveryMode: string | null; sessions: readonly CourseSession[]; totalHours: number | null; }
23
+ interface CourseSession extends ArrayItem { date: Date | null; hours: number | null; }
24
+
25
+ // 2. The recipe, built from its context (permission signals, options, validators).
26
+ const b = recipeBuilder<CourseFormData>();
27
+ const item = recipeBuilder<Omit<CourseSession, 'key'>, CourseFormData>();
28
+ export const courseRecipe = (ctx: Ctx) => b.recipe('course', {
29
+ readonly: () => ctx.readOnly(),
30
+ nodes: [
31
+ b.sectionGroup('main', { display: SectionDisplayEnum.PANEL, sections: [
32
+ b.section('sessions', { legendKey: 'course.sections.sessions', nodes: [
33
+ b.array('sessions', {
34
+ display: ArrayDisplayEnum.TABLE,
35
+ emptyItem: (key) => ({ key, date: null, hours: 7 }),
36
+ sort: (a, c) => (a.date?.getTime() ?? 0) - (c.date?.getTime() ?? 0),
37
+ slot: { name: 'calendar', position: 'before' },
38
+ rules: [{ rule: RuleTypeEnum.MIN_ITEMS, value: 1 }, { rule: RuleTypeEnum.UNIQUE, by: (s) => String(s.date) }],
39
+ item: [
40
+ item.field('date', { labelKey: 'course.fields.date', control: { type: ControlTypeEnum.DISPLAY } }),
41
+ item.field('hours', { labelKey: 'course.fields.hours', control: { type: ControlTypeEnum.NUMBER },
42
+ rules: [{ rule: RuleTypeEnum.VALIDATE, fn: (hours, c) => (c.root('deliveryMode') === 'REMOTE' && hours !== null && hours > 4 ? { kind: 'remoteHours' } : undefined) }] }),
43
+ ],
44
+ }),
45
+ b.field('totalHours', { labelKey: 'course.fields.totalHours', control: { type: ControlTypeEnum.DISPLAY, compute: (m) => String(m.sessions.reduce((sum, s) => sum + (s.hours ?? 0), 0)) } }),
46
+ ] }),
47
+ ] }),
48
+ ],
49
+ });
50
+
51
+ // 3. The caller creates the FieldTree and receives the submitted value.
52
+ readonly model = signal<CourseFormData>(initial);
53
+ readonly form = form(this.model, RecipeSchema.build(this.recipe, { timing: inject(FORM_VALIDATION_TIMING) }));
54
+ ```
55
+
56
+ ```html
57
+ <app-recipe-form
58
+ [recipe]="recipe"
59
+ [form]="form"
60
+ [serverErrors]="rejection()"
61
+ (submitted)="save($event)"
62
+ (invalidSubmit)="…"
63
+ (unplacedServerErrors)="generalErrors.set($event)"
64
+ >
65
+ <ng-template appRecipeSlot="calendar" let-list let-api="api">
66
+ <app-date-picker-multiple
67
+ [value]="selectedDates()"
68
+ (dateAdded)="api.addItem({ date: $event })"
69
+ (dateRemoved)="api.removeItem(keyOf($event))"
70
+ />
71
+ </ng-template>
72
+ <button appRecipeActions type="submit">Save</button>
73
+ </app-recipe-form>
74
+ ```
75
+
76
+ Providers: `provideRecipeForms({ production, translator, translationChanges, keyGenerator })`. `translator` and `translationChanges` are factories run in the injection context (`useFactory`). For example with Transloco:
77
+
78
+ ```ts
79
+ provideRecipeForms({
80
+ production,
81
+ translator: () => {
82
+ const transloco = inject(TranslocoService);
83
+ return (key, params) => transloco.translate(key, params);
84
+ },
85
+ // A new object on each event: lazily loaded scope, language change.
86
+ translationChanges: () => toSignal(inject(TranslocoService).events$),
87
+ });
88
+ ```
89
+
90
+ `translationChanges` (token `RECIPE_FORM_TRANSLATION_CHANGES`, a constant signal by default) returns a signal whose value changes each time translations are loaded or changed. The engine reads it before calling the translator for tab titles, error count texts, the `labelKey` options of a `select` and the `recipeTranslate` pipe: a scope loaded after the first render replaces the raw keys on screen. A value equal to the previous one (`Object.is`) triggers nothing: with Transloco, `langChanges$` alone is not enough, since it does not change when a scope loads.
91
+
92
+ ## Plugging in your design system
93
+
94
+ - Selectors are `app-*` and classes end with `Component`.
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
+ - **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
+ - 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' })`);
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
+ - `app-input-number`: `step`, `minFractionDigits` (decimals always shown), `maxFractionDigits` (decimals allowed when typing, 3 by default);
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`;
102
+ - `app-date-picker-multiple`: `FormValueControl<readonly Date[]>`, `maxDate`, `numberOfMonths` (months shown side by side, 3 by default; the engine passes `months ?? 3`; the native field of the default wrapper ignores it), `ariaLabel` (name of the group, the translated label), `dateAdded` and `dateRemoved` outputs for each day checked or unchecked;
103
+ - `app-panel`: `header`, `collapsible`, `collapsed` (model), `badge` (number, absent at zero), `badgeLabel`, `collapseLabel` and `expandLabel` (name of the collapse button, with `aria-expanded`);
104
+ - `app-tabs`: `value` (model, `string`), `options: TabOption[]` (`label`, `value`, `disabled`, `badge` absent at zero, `badgeLabel`; same shape as `SelectOption<string>`), `fill` (`false` by default; when true: below 768 px, the tabs share the full width, `flex-1` on a zero basis, and their title wraps between words only, never inside a word, so no tab is out of view; smaller padding and text (`px-2`, `text-xs`); badge in the top right corner of the tab (`absolute`, tab `relative`), in a top space reserved even without a count (`pt-6`): the title gets the full width and the tab keeps the same height with or without a count; nothing changes above that width; the section group sets it to true); one panel per projected `<ng-template [appTabPanel]="value">` (`TabPanelDirective`, in template order), hidden (`hidden`) when its tab is inactive and never destroyed; the bar alone without a template; ARIA tabs pattern (`aria-controls`, `aria-labelledby`, roving focus, arrows, Home, End); sticky bar at the top of the scrolling container (`sticky z-10`, opaque white background), panels in the same block, at `top: var(--app-sticky-top, 0px)` (class `top-[var(--app-sticky-top,0px)]`): a scrolling container with a top padding sets `--app-sticky-top` to the negative of that padding (`-20px` for 20 px), otherwise content stays visible in the strip above the stuck bar; when the user changes tab (click or keyboard) while the bar is stuck (top of the host above the top of the bar), the host scrolls to the start of the area (`scrollIntoView({ block: 'start' })`, after rendering), nothing without prior scrolling, nothing when `value` is changed by the parent (tab of the first field in error: the field's focus takes over); name of the tab (and of the panel) = title only, `badgeLabel` in a `hidden` element targeted by the tab's `aria-describedby`, badge `aria-hidden`; same tab height with or without a badge (`leading-none` in an `h-5` container, the title's line);
105
+ - `app-checkbox` (and any `appRecipeCheckboxControl` template): `FormCheckboxControl`; in `readonly` mode, the box never changes state, neither on screen nor for assistive technologies (click, click on the label and Space are cancelled, the native box does not get checked), stays focusable (never `disabled` for read-only), carries `aria-readonly="true"` on the focusable element, and keeps the default cursor on the box and its label. The `RecipeCheckboxControlContext` context passes `readonly` to the template. Contract spec of the default template: `specs/recipe-readonly-field.spec.ts`;
106
+ - `app-message`: `severity` (`SeverityEnum`, including the `WARNING` key), `inline`, projected content; `[id]` set on the host element.
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
+ - `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.
110
+
111
+ ## In the host application
112
+
113
+ - Tailwind 4: the library's classes are literal. If the package is consumed from `node_modules`, add `@source "../node_modules/ngx-recipe-forms";` to the host's stylesheet.
114
+ - Server validators (`ServerValidator<T>`) return an `Observable<ServerValidationResult>`; the adapter to the application's HTTP services is written by the caller. A validator that needs other keys of the model (for example the start date and the format of a training course) is declared `ServerValidator<T, RootModel>`, receives `(value, ctx)` and reads through `ctx.root(key)` the keys its rule declares in `dependsOn`. The errors of a write (`RecipeServerError[]`: `fields`, `code`, `message?`) are passed as is to `serverErrors`.
115
+ - `server` rules call their validator through the resource of `RECIPE_FORM_RX_RESOURCE` (`rxResource` by default): an application that enforces its own resource wrapper passes it to `provideRecipeForms({ rxResource })`, with the signature of `rxResource`. The timing collector is a `@Service({ autoProvided: false })`.
116
+ - `npm run check:loose` compiles the library and its specs under less strict options, like an application that sets neither `strict` nor `strictTemplates`: the `@ts-expect-error` of `recipe-types.spec.ts` must hold. The specs use no API specific to Vitest 5. Those that submit an invalid form replace `Element.prototype.scrollIntoView`, which jsdom does not implement, with a `vi.fn` spy for each test; a host spec that submits an invalid recipe form must do the same.
117
+
118
+ ## Commands
119
+
120
+ ```bash
121
+ npm run build:lib # ng build recipe-forms
122
+ npm run pack:lib # builds then packs the package (dist/ngx-recipe-forms-<version>.tgz)
123
+ npm run publish:lib # builds then publishes dist/recipe-forms to npm
124
+ npm run test:lib # ng test recipe-forms --watch=false
125
+ npm run check:loose # tsc with less strict options
126
+ npm start # ng serve playground
127
+ npm run install:host -- <host folder> # installs the built package in a host (file:…tgz)
128
+ npm run export:host -- <folder> # copies the sources into a host, with the hash manifest
129
+ ```
130
+
131
+ Both scripts are described in the [repository README](https://github.com/SrenoG/ngx-recipe-forms#readme) ("Trying it in an application before publication", "Copying it into an application").