ngwr 10.0.0 → 10.1.0

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.
Files changed (233) hide show
  1. package/README.md +9 -8
  2. package/action-sheet/styles/_index.scss +6 -1
  3. package/badge/styles/_index.scss +1 -1
  4. package/badge/styles/_tag.scss +2 -2
  5. package/border-glow/styles/_index.scss +5 -0
  6. package/button/styles/_index.scss +6 -6
  7. package/calendar/styles/_index.scss +9 -1
  8. package/circular-text/styles/_index.scss +6 -1
  9. package/density/styles/_index.scss +3 -1
  10. package/dialog/styles/_index.scss +1 -2
  11. package/drag-drop/styles/_index.scss +20 -7
  12. package/event-calendar/styles/_index.scss +284 -0
  13. package/falling-text/styles/_index.scss +5 -0
  14. package/fesm2022/ngwr-alert.mjs +8 -3
  15. package/fesm2022/ngwr-alert.mjs.map +1 -1
  16. package/fesm2022/ngwr-back-top.mjs +6 -4
  17. package/fesm2022/ngwr-back-top.mjs.map +1 -1
  18. package/fesm2022/ngwr-border-glow.mjs +12 -9
  19. package/fesm2022/ngwr-border-glow.mjs.map +1 -1
  20. package/fesm2022/ngwr-breadcrumbs.mjs +2 -2
  21. package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
  22. package/fesm2022/ngwr-calendar.mjs +5 -3
  23. package/fesm2022/ngwr-calendar.mjs.map +1 -1
  24. package/fesm2022/ngwr-card.mjs +2 -2
  25. package/fesm2022/ngwr-card.mjs.map +1 -1
  26. package/fesm2022/ngwr-carousel.mjs +17 -4
  27. package/fesm2022/ngwr-carousel.mjs.map +1 -1
  28. package/fesm2022/ngwr-cascader.mjs +31 -4
  29. package/fesm2022/ngwr-cascader.mjs.map +1 -1
  30. package/fesm2022/ngwr-checkbox.mjs +12 -3
  31. package/fesm2022/ngwr-checkbox.mjs.map +1 -1
  32. package/fesm2022/ngwr-circular-text.mjs +2 -2
  33. package/fesm2022/ngwr-circular-text.mjs.map +1 -1
  34. package/fesm2022/ngwr-command-palette.mjs +7 -3
  35. package/fesm2022/ngwr-command-palette.mjs.map +1 -1
  36. package/fesm2022/ngwr-counter.mjs +9 -1
  37. package/fesm2022/ngwr-counter.mjs.map +1 -1
  38. package/fesm2022/ngwr-date-picker.mjs +23 -6
  39. package/fesm2022/ngwr-date-picker.mjs.map +1 -1
  40. package/fesm2022/ngwr-descriptions.mjs +5 -4
  41. package/fesm2022/ngwr-descriptions.mjs.map +1 -1
  42. package/fesm2022/ngwr-drag-drop.mjs +2 -2
  43. package/fesm2022/ngwr-drag-drop.mjs.map +1 -1
  44. package/fesm2022/ngwr-dropdown.mjs +4 -0
  45. package/fesm2022/ngwr-dropdown.mjs.map +1 -1
  46. package/fesm2022/ngwr-event-calendar.mjs +723 -0
  47. package/fesm2022/ngwr-event-calendar.mjs.map +1 -0
  48. package/fesm2022/ngwr-falling-text.mjs +2 -2
  49. package/fesm2022/ngwr-falling-text.mjs.map +1 -1
  50. package/fesm2022/ngwr-file-upload.mjs +2 -2
  51. package/fesm2022/ngwr-file-upload.mjs.map +1 -1
  52. package/fesm2022/ngwr-form.mjs +258 -42
  53. package/fesm2022/ngwr-form.mjs.map +1 -1
  54. package/fesm2022/ngwr-fuzzy-text.mjs +15 -1
  55. package/fesm2022/ngwr-fuzzy-text.mjs.map +1 -1
  56. package/fesm2022/ngwr-gauge.mjs +8 -3
  57. package/fesm2022/ngwr-gauge.mjs.map +1 -1
  58. package/fesm2022/ngwr-glitch-text.mjs +2 -2
  59. package/fesm2022/ngwr-glitch-text.mjs.map +1 -1
  60. package/fesm2022/ngwr-gradient-text.mjs +2 -2
  61. package/fesm2022/ngwr-gradient-text.mjs.map +1 -1
  62. package/fesm2022/ngwr-i18n-en.mjs +73 -5
  63. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  64. package/fesm2022/ngwr-i18n-ru.mjs +73 -5
  65. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  66. package/fesm2022/ngwr-i18n.mjs +20 -2
  67. package/fesm2022/ngwr-i18n.mjs.map +1 -1
  68. package/fesm2022/ngwr-icon.mjs +5 -0
  69. package/fesm2022/ngwr-icon.mjs.map +1 -1
  70. package/fesm2022/ngwr-input-number.mjs +19 -3
  71. package/fesm2022/ngwr-input-number.mjs.map +1 -1
  72. package/fesm2022/ngwr-input.mjs +48 -6
  73. package/fesm2022/ngwr-input.mjs.map +1 -1
  74. package/fesm2022/ngwr-knob.mjs +8 -3
  75. package/fesm2022/ngwr-knob.mjs.map +1 -1
  76. package/fesm2022/ngwr-lightbox.mjs +32 -3
  77. package/fesm2022/ngwr-lightbox.mjs.map +1 -1
  78. package/fesm2022/ngwr-line-chart.mjs +3 -3
  79. package/fesm2022/ngwr-line-chart.mjs.map +1 -1
  80. package/fesm2022/ngwr-list.mjs +2 -2
  81. package/fesm2022/ngwr-list.mjs.map +1 -1
  82. package/fesm2022/ngwr-loading-bar.mjs +2 -2
  83. package/fesm2022/ngwr-loading-bar.mjs.map +1 -1
  84. package/fesm2022/ngwr-marquee.mjs +2 -2
  85. package/fesm2022/ngwr-marquee.mjs.map +1 -1
  86. package/fesm2022/ngwr-media.mjs +3 -0
  87. package/fesm2022/ngwr-media.mjs.map +1 -1
  88. package/fesm2022/ngwr-meter-group.mjs +14 -3
  89. package/fesm2022/ngwr-meter-group.mjs.map +1 -1
  90. package/fesm2022/ngwr-page-header.mjs +2 -2
  91. package/fesm2022/ngwr-page-header.mjs.map +1 -1
  92. package/fesm2022/ngwr-pagination.mjs +1 -1
  93. package/fesm2022/ngwr-pagination.mjs.map +1 -1
  94. package/fesm2022/ngwr-progress.mjs +8 -2
  95. package/fesm2022/ngwr-progress.mjs.map +1 -1
  96. package/fesm2022/ngwr-qr.mjs.map +1 -1
  97. package/fesm2022/ngwr-rating.mjs +6 -4
  98. package/fesm2022/ngwr-rating.mjs.map +1 -1
  99. package/fesm2022/ngwr-result.mjs +19 -12
  100. package/fesm2022/ngwr-result.mjs.map +1 -1
  101. package/fesm2022/ngwr-segmented.mjs +2 -2
  102. package/fesm2022/ngwr-segmented.mjs.map +1 -1
  103. package/fesm2022/ngwr-select.mjs +28 -8
  104. package/fesm2022/ngwr-select.mjs.map +1 -1
  105. package/fesm2022/ngwr-shiny-text.mjs +4 -6
  106. package/fesm2022/ngwr-shiny-text.mjs.map +1 -1
  107. package/fesm2022/ngwr-speed-dial.mjs +11 -3
  108. package/fesm2022/ngwr-speed-dial.mjs.map +1 -1
  109. package/fesm2022/ngwr-spotlight-card.mjs +2 -2
  110. package/fesm2022/ngwr-spotlight-card.mjs.map +1 -1
  111. package/fesm2022/ngwr-squircle.mjs +1 -1
  112. package/fesm2022/ngwr-squircle.mjs.map +1 -1
  113. package/fesm2022/ngwr-star-border.mjs +2 -2
  114. package/fesm2022/ngwr-star-border.mjs.map +1 -1
  115. package/fesm2022/ngwr-switch.mjs +10 -3
  116. package/fesm2022/ngwr-switch.mjs.map +1 -1
  117. package/fesm2022/ngwr-table.mjs +233 -19
  118. package/fesm2022/ngwr-table.mjs.map +1 -1
  119. package/fesm2022/ngwr-tabs.mjs +21 -4
  120. package/fesm2022/ngwr-tabs.mjs.map +1 -1
  121. package/fesm2022/ngwr-textarea.mjs +20 -4
  122. package/fesm2022/ngwr-textarea.mjs.map +1 -1
  123. package/fesm2022/ngwr-tilt-card.mjs +2 -2
  124. package/fesm2022/ngwr-tilt-card.mjs.map +1 -1
  125. package/fesm2022/ngwr-toolbar.mjs +2 -2
  126. package/fesm2022/ngwr-toolbar.mjs.map +1 -1
  127. package/fesm2022/ngwr-tour.mjs +264 -0
  128. package/fesm2022/ngwr-tour.mjs.map +1 -0
  129. package/fesm2022/ngwr-transfer.mjs +184 -0
  130. package/fesm2022/ngwr-transfer.mjs.map +1 -0
  131. package/fesm2022/ngwr-tree.mjs +23 -6
  132. package/fesm2022/ngwr-tree.mjs.map +1 -1
  133. package/fesm2022/ngwr-typewriter.mjs +2 -2
  134. package/fesm2022/ngwr-typewriter.mjs.map +1 -1
  135. package/fesm2022/ngwr-validators.mjs +118 -2
  136. package/fesm2022/ngwr-validators.mjs.map +1 -1
  137. package/fesm2022/ngwr-version.mjs +2 -2
  138. package/fesm2022/ngwr-version.mjs.map +1 -1
  139. package/fesm2022/ngwr-virtual-scroll.mjs +2 -2
  140. package/fesm2022/ngwr-virtual-scroll.mjs.map +1 -1
  141. package/fesm2022/ngwr-waves.mjs +2 -2
  142. package/fesm2022/ngwr-waves.mjs.map +1 -1
  143. package/form/styles/_index.scss +8 -4
  144. package/glitch-text/styles/_index.scss +5 -0
  145. package/gradient-text/styles/_index.scss +5 -0
  146. package/i18n/en.json +74 -6
  147. package/i18n/ru.json +74 -6
  148. package/icon/styles/_index.scss +5 -0
  149. package/keyboard/styles/_index.scss +5 -0
  150. package/llms-full.txt +123 -62
  151. package/llms.txt +29 -8
  152. package/loading-bar/styles/_index.scss +5 -0
  153. package/marquee/styles/_index.scss +7 -2
  154. package/overlay/styles/_index.scss +5 -0
  155. package/package.json +13 -1
  156. package/popover/styles/_index.scss +48 -12
  157. package/pull-to-refresh/styles/_index.scss +5 -0
  158. package/result/styles/_index.scss +3 -3
  159. package/schematics/icon-set/index.js +80 -34
  160. package/schematics/icon-set/schema.json +8 -3
  161. package/schematics/ng-add/index.js +5 -2
  162. package/schematics/page/templates.js +17 -21
  163. package/schematics/provider/index.js +31 -13
  164. package/schematics/provider/schema.json +40 -24
  165. package/schematics/use/index.js +5 -1
  166. package/schematics/use/schema.json +8 -3
  167. package/schematics/use/symbol-map.json +6 -177
  168. package/segmented/styles/_index.scss +1 -1
  169. package/select/styles/_index.scss +7 -3
  170. package/shiny-text/styles/_index.scss +5 -0
  171. package/speed-dial/styles/_index.scss +12 -1
  172. package/spotlight-card/styles/_index.scss +5 -0
  173. package/squircle/styles/_index.scss +5 -0
  174. package/star-border/styles/_index.scss +5 -0
  175. package/statistic/styles/_index.scss +2 -2
  176. package/styles/_animations.scss +6 -0
  177. package/styles.scss +3 -0
  178. package/table/styles/_index.scss +100 -2
  179. package/theme/styles/_colors.scss +43 -1
  180. package/theme/styles/_dark.scss +18 -6
  181. package/theme/styles/_focus.scss +2 -8
  182. package/tilt-card/styles/_index.scss +5 -0
  183. package/toast/styles/_index.scss +6 -3
  184. package/tour/styles/_index.scss +63 -0
  185. package/transfer/styles/_index.scss +105 -0
  186. package/types/ngwr-alert.d.ts +4 -1
  187. package/types/ngwr-avatar.d.ts +1 -1
  188. package/types/ngwr-back-top.d.ts +3 -2
  189. package/types/ngwr-badge.d.ts +1 -1
  190. package/types/ngwr-border-glow.d.ts +0 -1
  191. package/types/ngwr-carousel.d.ts +10 -1
  192. package/types/ngwr-cascader.d.ts +12 -1
  193. package/types/ngwr-checkbox.d.ts +9 -1
  194. package/types/ngwr-command-palette.d.ts +4 -1
  195. package/types/ngwr-date-picker.d.ts +9 -1
  196. package/types/ngwr-density.d.ts +1 -1
  197. package/types/ngwr-divider.d.ts +1 -1
  198. package/types/ngwr-event-calendar.d.ts +358 -0
  199. package/types/ngwr-form.d.ts +177 -20
  200. package/types/ngwr-fuzzy-text.d.ts +8 -0
  201. package/types/ngwr-gauge.d.ts +4 -1
  202. package/types/ngwr-i18n.d.ts +15 -0
  203. package/types/ngwr-input-number.d.ts +8 -1
  204. package/types/ngwr-input.d.ts +50 -20
  205. package/types/ngwr-knob.d.ts +4 -1
  206. package/types/ngwr-lightbox.d.ts +7 -1
  207. package/types/ngwr-line-chart.d.ts +1 -1
  208. package/types/ngwr-media.d.ts +1 -1
  209. package/types/ngwr-meter-group.d.ts +9 -1
  210. package/types/ngwr-page-header.d.ts +2 -2
  211. package/types/ngwr-pagination.d.ts +1 -1
  212. package/types/ngwr-progress.d.ts +4 -1
  213. package/types/ngwr-rating.d.ts +3 -2
  214. package/types/ngwr-result.d.ts +12 -6
  215. package/types/ngwr-segmented.d.ts +6 -0
  216. package/types/ngwr-select.d.ts +13 -7
  217. package/types/ngwr-shiny-text.d.ts +2 -4
  218. package/types/ngwr-speed-dial.d.ts +7 -1
  219. package/types/ngwr-squircle.d.ts +1 -1
  220. package/types/ngwr-switch.d.ts +7 -1
  221. package/types/ngwr-table.d.ts +126 -6
  222. package/types/ngwr-tabs.d.ts +1 -4
  223. package/types/ngwr-textarea.d.ts +8 -1
  224. package/types/ngwr-toolbar.d.ts +2 -2
  225. package/types/ngwr-tour.d.ts +132 -0
  226. package/types/ngwr-transfer.d.ts +118 -0
  227. package/types/ngwr-tree.d.ts +10 -2
  228. package/types/ngwr-validators.d.ts +62 -2
  229. package/types/ngwr-version.d.ts +2 -2
  230. package/typewriter/styles/_index.scss +5 -0
  231. package/typography/styles/_index.scss +3 -3
  232. package/virtual-scroll/styles/_index.scss +6 -1
  233. package/waves/styles/_index.scss +5 -0
@@ -1,7 +1,9 @@
1
1
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
2
2
  import * as i0 from '@angular/core';
3
- import { input, computed, ViewEncapsulation, Component, contentChild } from '@angular/core';
3
+ import { input, computed, ViewEncapsulation, Component, InjectionToken, makeEnvironmentProviders, inject, contentChild, signal, effect, DestroyRef, contentChildren, forwardRef } from '@angular/core';
4
4
  import { NgControl } from '@angular/forms';
5
+ import { EMPTY } from 'rxjs';
6
+ import { WrI18n } from 'ngwr/i18n';
5
7
 
6
8
  /**
7
9
  * @license
@@ -19,7 +21,7 @@ import { NgControl } from '@angular/forms';
19
21
  * ```html
20
22
  * <wr-form-item [hasError]="form.controls.email.invalid">
21
23
  * <label>Email</label>
22
- * <wr-input formControlName="email" />
24
+ * <input wrInput formControlName="email" />
23
25
  * <wr-form-error>Invalid email</wr-form-error>
24
26
  * </wr-form-item>
25
27
  * ```
@@ -53,6 +55,94 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
53
55
  }]
54
56
  }], propDecorators: { hasError: [{ type: i0.Input, args: [{ isSignal: true, alias: "hasError", required: false }] }] } });
55
57
 
58
+ /**
59
+ * @license
60
+ *
61
+ * Use of this source code is governed by an MIT-style license that can be
62
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
63
+ */
64
+ /** Pull a number out of a validator payload without trusting its shape. */
65
+ function num(error, field) {
66
+ if (error && typeof error === 'object' && field in error) {
67
+ const value = error[field];
68
+ if (typeof value === 'number' || typeof value === 'string')
69
+ return String(value);
70
+ }
71
+ return '';
72
+ }
73
+ /**
74
+ * App-wide validation copy. Empty by default; `<wr-form-field>` falls through
75
+ * to the `ngwr/i18n` catalog and then to a built-in English sentence, so a
76
+ * form shows a usable message with no configuration at all.
77
+ */
78
+ const WR_FORM_ERRORS = new InjectionToken('WR_FORM_ERRORS', {
79
+ providedIn: 'root',
80
+ factory: () => ({}),
81
+ });
82
+ /**
83
+ * Register validation messages for the whole app.
84
+ *
85
+ * Only the keys you name are overridden — everything else keeps resolving
86
+ * through the i18n catalog, so this composes with `provideWrI18n()` rather than
87
+ * replacing it. A projected `<wr-form-error key="…">` still wins over both:
88
+ * per-field copy beats app-wide copy.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * bootstrapApplication(App, {
93
+ * providers: [
94
+ * provideWrFormErrors({
95
+ * required: 'Please fill this in.',
96
+ * minlength: ({ error }) => `At least ${(error as { requiredLength: number }).requiredLength} characters.`,
97
+ * }),
98
+ * ],
99
+ * });
100
+ * ```
101
+ */
102
+ function provideWrFormErrors(messages = {}) {
103
+ return makeEnvironmentProviders([{ provide: WR_FORM_ERRORS, useValue: messages }]);
104
+ }
105
+ /**
106
+ * Last-resort English, used when no app catalog and no i18n catalog answer.
107
+ *
108
+ * These exist so that a form with zero configuration still says something true
109
+ * rather than rendering an empty error block. Every key here also ships as a
110
+ * `validation.*` entry in `ngwr/i18n/{en,ru}`, which is what a localized app
111
+ * actually reads.
112
+ */
113
+ const WR_FORM_ERROR_FALLBACKS = {
114
+ // Angular built-ins.
115
+ required: 'This field is required.',
116
+ requiredTrue: 'This field must be checked.',
117
+ email: 'Enter a valid email address.',
118
+ minlength: ({ error }) => `Enter at least ${num(error, 'requiredLength')} characters.`,
119
+ maxlength: ({ error }) => `Enter at most ${num(error, 'requiredLength')} characters.`,
120
+ min: ({ error }) => `Enter ${num(error, 'min')} or more.`,
121
+ max: ({ error }) => `Enter ${num(error, 'max')} or less.`,
122
+ pattern: 'This value is not in the expected format.',
123
+ // WrValidators.
124
+ noWhitespace: 'This field cannot be blank.',
125
+ hexColor: 'Enter a hex colour, e.g. #1a2b3c.',
126
+ url: 'Enter a valid URL.',
127
+ cardNumber: 'Enter a valid card number.',
128
+ cvc: ({ error }) => `Enter the ${num(error, 'length')}-digit security code.`,
129
+ iban: 'Enter a valid IBAN.',
130
+ match: 'The two values do not match.',
131
+ matchFields: 'These fields do not match.',
132
+ oneOf: 'Choose one of the allowed values.',
133
+ minDate: 'Choose a later date.',
134
+ maxDate: 'Choose an earlier date.',
135
+ };
136
+
137
+ /**
138
+ * @license
139
+ *
140
+ * Use of this source code is governed by an MIT-style license that can be
141
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
142
+ */
143
+ /** Present only inside a `<wr-form-field>`; inject with `{ optional: true }`. */
144
+ const WR_FORM_FIELD = new InjectionToken('WR_FORM_FIELD');
145
+
56
146
  /**
57
147
  * @license
58
148
  *
@@ -60,6 +150,70 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
60
150
  * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
61
151
  */
62
152
  let uid = 0;
153
+ /** A message is either literal text or a function over the validator's payload. */
154
+ function render(message, key, error, label) {
155
+ return typeof message === 'function' ? message({ key, error, label }) : message;
156
+ }
157
+ /** Validator payloads are plain objects; anything else interpolates nothing. */
158
+ function toParams(error) {
159
+ return error && typeof error === 'object' ? error : undefined;
160
+ }
161
+ /**
162
+ * One error message tied to a validator key. Renders only when the parent
163
+ * form-field has a matching error in `control.errors`, and only once the
164
+ * control is touched or dirty.
165
+ *
166
+ * @example
167
+ * ```html
168
+ * <wr-form-error key="required">This field is required.</wr-form-error>
169
+ * <wr-form-error key="email">That doesn't look right.</wr-form-error>
170
+ * ```
171
+ */
172
+ class WrFormError {
173
+ /**
174
+ * Validator key this message corresponds to (e.g. `'required'`).
175
+ * Optional — without a key the message always renders, which is the
176
+ * plain inline-error usage inside `<wr-form-item>`.
177
+ */
178
+ key = input(/* @ts-ignore */
179
+ ...(ngDevMode ? [undefined, { debugName: "key" }] : /* istanbul ignore next */ []));
180
+ field = inject(WR_FORM_FIELD, { optional: true });
181
+ /**
182
+ * Whether this message is the one the current error calls for.
183
+ *
184
+ * The parent projects every `<wr-form-error>` through a single
185
+ * `<ng-content select>`, which cannot filter — so each message decides for
186
+ * itself. Without this, one invalid control rendered "Email is required."
187
+ * and "That isn't a valid email." side by side, which is what the docs have
188
+ * always described as gated behaviour.
189
+ *
190
+ * A keyless message always shows: that is the plain inline-error usage inside
191
+ * `<wr-form-item>`, which has no error discovery at all.
192
+ */
193
+ visible = computed(() => {
194
+ const key = this.key();
195
+ if (!key || !this.field)
196
+ return true;
197
+ return this.field.errorKeys().includes(key);
198
+ }, /* @ts-ignore */
199
+ ...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
200
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrFormError, deps: [], target: i0.ɵɵFactoryTarget.Component });
201
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.0", type: WrFormError, isStandalone: true, selector: "wr-form-error", inputs: { key: { classPropertyName: "key", publicName: "key", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "alert" }, properties: { "attr.data-key": "key() ?? null", "class.wr-form-field__error--hidden": "!visible()" }, classAttribute: "wr-form-error wr-form-field__error" }, ngImport: i0, template: `<ng-content />`, isInline: true, encapsulation: i0.ViewEncapsulation.None });
202
+ }
203
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrFormError, decorators: [{
204
+ type: Component,
205
+ args: [{
206
+ selector: 'wr-form-error',
207
+ template: `<ng-content />`,
208
+ encapsulation: ViewEncapsulation.None,
209
+ host: {
210
+ class: 'wr-form-error wr-form-field__error',
211
+ role: 'alert',
212
+ '[attr.data-key]': 'key() ?? null',
213
+ '[class.wr-form-field__error--hidden]': '!visible()',
214
+ },
215
+ }]
216
+ }], propDecorators: { key: [{ type: i0.Input, args: [{ isSignal: true, alias: "key", required: false }] }] } });
63
217
  /**
64
218
  * Wraps a label + control + hint + error messages into a single block —
65
219
  * the layout primitive every form ends up reinventing.
@@ -92,13 +246,46 @@ class WrFormField {
92
246
  required = input(false, { ...(ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {}), transform: coerceBooleanProperty });
93
247
  /** Show `(optional)` next to the label. Mutually exclusive with `required`. @default false */
94
248
  optional = input(false, { ...(ngDevMode ? { debugName: "optional" } : /* istanbul ignore next */ {}), transform: coerceBooleanProperty });
95
- /** Force a specific id on the label's `for` attribute. Auto-generated otherwise. */
249
+ /**
250
+ * Force a specific id on the label's `for` attribute. Auto-generated
251
+ * otherwise, and adopted by the projected `wrInput` unless that element
252
+ * already carries an `id` of its own.
253
+ */
96
254
  controlId = input(`wr-form-field-${++uid}`, /* @ts-ignore */
97
255
  ...(ngDevMode ? [{ debugName: "controlId" }] : /* istanbul ignore next */ []));
98
- /** Projected `NgControl` — used to read touched / dirty / errors. */
256
+ /**
257
+ * Projected `NgControl` — used to read touched / dirty / errors.
258
+ *
259
+ * This catches `[formField]` too: Angular's Signal Forms directive provides
260
+ * `NgControl` via its interop shim, so both forms flavours land here.
261
+ */
99
262
  ngControl = contentChild(NgControl, /* @ts-ignore */
100
263
  ...(ngDevMode ? [{ debugName: "ngControl" }] : /* istanbul ignore next */ []));
264
+ /**
265
+ * Bumped on every event the projected control emits.
266
+ *
267
+ * `AbstractControl`'s `touched` / `dirty` / `errors` accessors are NOT
268
+ * reactive under classic forms — Angular reads them inside `untracked()`, and
269
+ * `errors` is a plain assigned field. A `computed` over them therefore caches
270
+ * its first value and never recomputes, which in a zoneless app means the
271
+ * error block never appears at all. `control.events` is the reactive source
272
+ * Angular does expose, so the computed depends on this counter instead.
273
+ * Signal Forms needs none of this — its interop getters read live signals —
274
+ * and harmlessly contributes no events.
275
+ */
276
+ revision = signal(0, /* @ts-ignore */
277
+ ...(ngDevMode ? [{ debugName: "revision" }] : /* istanbul ignore next */ []));
278
+ constructor() {
279
+ let sub = null;
280
+ effect(() => {
281
+ const control = this.ngControl()?.control;
282
+ sub?.unsubscribe();
283
+ sub = (control?.events ?? EMPTY).subscribe(() => this.revision.update(n => n + 1));
284
+ });
285
+ inject(DestroyRef).onDestroy(() => sub?.unsubscribe());
286
+ }
101
287
  errors = computed(() => {
288
+ this.revision();
102
289
  const c = this.ngControl();
103
290
  if (!c)
104
291
  return null;
@@ -112,6 +299,57 @@ class WrFormField {
112
299
  return !!errs && Object.keys(errs).length > 0;
113
300
  }, /* @ts-ignore */
114
301
  ...(ngDevMode ? [{ debugName: "hasError" }] : /* istanbul ignore next */ []));
302
+ /** @internal Read by the projected `<wr-form-error>` children to decide which of them renders. */
303
+ errorKeys = computed(() => Object.keys(this.errors() ?? {}), /* @ts-ignore */
304
+ ...(ngDevMode ? [{ debugName: "errorKeys" }] : /* istanbul ignore next */ []));
305
+ /** @internal Read by the projected control so a screen reader is pointed at the message. */
306
+ describedBy = computed(() => (this.hasError() ? `${this.controlId()}-errors` : null), /* @ts-ignore */
307
+ ...(ngDevMode ? [{ debugName: "describedBy" }] : /* istanbul ignore next */ []));
308
+ /**
309
+ * Render a catalog message for any error the markup does not already answer.
310
+ *
311
+ * On by default: a field with no `<wr-form-error>` at all is the common case,
312
+ * and an empty error block helps nobody. Turn it off for a field whose copy is
313
+ * entirely hand-written. @default true
314
+ */
315
+ autoErrors = input(true, { ...(ngDevMode ? { debugName: "autoErrors" } : /* istanbul ignore next */ {}), transform: coerceBooleanProperty });
316
+ projectedErrors = contentChildren(WrFormError, /* @ts-ignore */
317
+ ...(ngDevMode ? [{ debugName: "projectedErrors" }] : /* istanbul ignore next */ []));
318
+ appMessages = inject(WR_FORM_ERRORS);
319
+ i18n = inject(WrI18n, { optional: true });
320
+ /**
321
+ * Errors with no projected `<wr-form-error key>` to answer them, resolved to
322
+ * text: the app catalog first, then the `validation.*` i18n keys, then a
323
+ * built-in English sentence. Per-field markup always wins — it is the most
324
+ * specific thing the author wrote.
325
+ */
326
+ autoMessages = computed(() => {
327
+ if (!this.autoErrors())
328
+ return [];
329
+ const errors = this.errors();
330
+ if (!errors)
331
+ return [];
332
+ const claimed = new Set(this.projectedErrors()
333
+ .map(e => e.key())
334
+ .filter(Boolean));
335
+ return Object.entries(errors)
336
+ .filter(([key]) => !claimed.has(key))
337
+ .map(([key, error]) => ({ key, text: this.resolve(key, error) }))
338
+ .filter(m => m.text.length > 0);
339
+ }, /* @ts-ignore */
340
+ ...(ngDevMode ? [{ debugName: "autoMessages" }] : /* istanbul ignore next */ []));
341
+ resolve(key, error) {
342
+ const app = this.appMessages[key];
343
+ if (app !== undefined)
344
+ return render(app, key, error, this.label());
345
+ // `t()` reads the service's revision signal, so this recomputes on a locale
346
+ // switch; a miss returns the key itself, which is the documented signal.
347
+ const translated = this.i18n?.t(`validation.${key}`, toParams(error));
348
+ if (translated && translated !== `validation.${key}`)
349
+ return translated;
350
+ const fallback = WR_FORM_ERROR_FALLBACKS[key];
351
+ return fallback === undefined ? '' : render(fallback, key, error, this.label());
352
+ }
115
353
  classes = computed(() => {
116
354
  const parts = ['wr-form-field'];
117
355
  if (this.hasError())
@@ -122,50 +360,28 @@ class WrFormField {
122
360
  }, /* @ts-ignore */
123
361
  ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
124
362
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrFormField, deps: [], target: i0.ɵɵFactoryTarget.Component });
125
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.0", type: WrFormField, isStandalone: true, selector: "wr-form-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, optional: { classPropertyName: "optional", publicName: "optional", isSignal: true, isRequired: false, transformFunction: null }, controlId: { classPropertyName: "controlId", publicName: "controlId", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "classes()" } }, queries: [{ propertyName: "ngControl", first: true, predicate: NgControl, descendants: true, isSignal: true }], ngImport: i0, template: "@if (label()) {\n <label class=\"wr-form-field__label\" [attr.for]=\"controlId()\">\n {{ label() }}\n @if (required()) {\n <span class=\"wr-form-field__required\" aria-hidden=\"true\">*</span>\n } @else if (optional()) {\n <span class=\"wr-form-field__optional\">(optional)</span>\n }\n </label>\n}\n\n<div class=\"wr-form-field__control\"><ng-content /></div>\n\n@if (hasError()) {\n <div class=\"wr-form-field__errors\">\n <ng-content select=\"wr-form-error\" />\n </div>\n} @else if (hint()) {\n <small class=\"wr-form-field__hint\">{{ hint() }}</small>\n}\n", encapsulation: i0.ViewEncapsulation.None });
363
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.0", type: WrFormField, isStandalone: true, selector: "wr-form-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, optional: { classPropertyName: "optional", publicName: "optional", isSignal: true, isRequired: false, transformFunction: null }, controlId: { classPropertyName: "controlId", publicName: "controlId", isSignal: true, isRequired: false, transformFunction: null }, autoErrors: { classPropertyName: "autoErrors", publicName: "autoErrors", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "classes()" } }, providers: [
364
+ {
365
+ provide: WR_FORM_FIELD,
366
+ // eslint-disable-next-line @angular-eslint/no-forward-ref
367
+ useExisting: forwardRef(() => WrFormField),
368
+ },
369
+ ], queries: [{ propertyName: "ngControl", first: true, predicate: NgControl, descendants: true, isSignal: true }, { propertyName: "projectedErrors", predicate: WrFormError, isSignal: true }], ngImport: i0, template: "@if (label()) {\n <label class=\"wr-form-field__label\" [attr.for]=\"controlId()\">\n {{ label() }}\n @if (required()) {\n <span class=\"wr-form-field__required\" aria-hidden=\"true\">*</span>\n } @else if (optional()) {\n <span class=\"wr-form-field__optional\">(optional)</span>\n }\n </label>\n}\n\n<div class=\"wr-form-field__control\"><ng-content /></div>\n\n@if (hasError()) {\n <div class=\"wr-form-field__errors\" [attr.id]=\"describedBy()\">\n <ng-content select=\"wr-form-error\" />\n @for (message of autoMessages(); track message.key) {\n <div class=\"wr-form-error wr-form-field__error\" role=\"alert\" [attr.data-key]=\"message.key\">\n {{ message.text }}\n </div>\n }\n </div>\n} @else if (hint()) {\n <small class=\"wr-form-field__hint\">{{ hint() }}</small>\n}\n", encapsulation: i0.ViewEncapsulation.None });
126
370
  }
127
371
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrFormField, decorators: [{
128
372
  type: Component,
129
- args: [{ selector: 'wr-form-field', encapsulation: ViewEncapsulation.None, host: { '[class]': 'classes()' }, template: "@if (label()) {\n <label class=\"wr-form-field__label\" [attr.for]=\"controlId()\">\n {{ label() }}\n @if (required()) {\n <span class=\"wr-form-field__required\" aria-hidden=\"true\">*</span>\n } @else if (optional()) {\n <span class=\"wr-form-field__optional\">(optional)</span>\n }\n </label>\n}\n\n<div class=\"wr-form-field__control\"><ng-content /></div>\n\n@if (hasError()) {\n <div class=\"wr-form-field__errors\">\n <ng-content select=\"wr-form-error\" />\n </div>\n} @else if (hint()) {\n <small class=\"wr-form-field__hint\">{{ hint() }}</small>\n}\n" }]
130
- }], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], optional: [{ type: i0.Input, args: [{ isSignal: true, alias: "optional", required: false }] }], controlId: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlId", required: false }] }], ngControl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => NgControl), { isSignal: true }] }] } });
131
- /**
132
- * One error message tied to a validator key. Renders only when the
133
- * parent form-field has a matching error in `control.errors`.
134
- *
135
- * @example
136
- * ```html
137
- * <wr-form-error key="required">This field is required.</wr-form-error>
138
- * <wr-form-error key="email">That doesn't look right.</wr-form-error>
139
- * ```
140
- */
141
- class WrFormError {
142
- /**
143
- * Validator key this message corresponds to (e.g. `'required'`).
144
- * Optional — without a key the message always renders, which is the
145
- * plain inline-error usage inside `<wr-form-item>`.
146
- */
147
- key = input(/* @ts-ignore */
148
- ...(ngDevMode ? [undefined, { debugName: "key" }] : /* istanbul ignore next */ []));
149
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrFormError, deps: [], target: i0.ɵɵFactoryTarget.Component });
150
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.0", type: WrFormError, isStandalone: true, selector: "wr-form-error", inputs: { key: { classPropertyName: "key", publicName: "key", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "alert" }, properties: { "attr.data-key": "key() ?? null" }, classAttribute: "wr-form-error wr-form-field__error" }, ngImport: i0, template: `<ng-content />`, isInline: true, encapsulation: i0.ViewEncapsulation.None });
151
- }
152
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrFormError, decorators: [{
153
- type: Component,
154
- args: [{
155
- selector: 'wr-form-error',
156
- template: `<ng-content />`,
157
- encapsulation: ViewEncapsulation.None,
158
- host: {
159
- class: 'wr-form-error wr-form-field__error',
160
- role: 'alert',
161
- '[attr.data-key]': 'key() ?? null',
162
- },
163
- }]
164
- }], propDecorators: { key: [{ type: i0.Input, args: [{ isSignal: true, alias: "key", required: false }] }] } });
373
+ args: [{ selector: 'wr-form-field', encapsulation: ViewEncapsulation.None, host: { '[class]': 'classes()' }, providers: [
374
+ {
375
+ provide: WR_FORM_FIELD,
376
+ // eslint-disable-next-line @angular-eslint/no-forward-ref
377
+ useExisting: forwardRef(() => WrFormField),
378
+ },
379
+ ], template: "@if (label()) {\n <label class=\"wr-form-field__label\" [attr.for]=\"controlId()\">\n {{ label() }}\n @if (required()) {\n <span class=\"wr-form-field__required\" aria-hidden=\"true\">*</span>\n } @else if (optional()) {\n <span class=\"wr-form-field__optional\">(optional)</span>\n }\n </label>\n}\n\n<div class=\"wr-form-field__control\"><ng-content /></div>\n\n@if (hasError()) {\n <div class=\"wr-form-field__errors\" [attr.id]=\"describedBy()\">\n <ng-content select=\"wr-form-error\" />\n @for (message of autoMessages(); track message.key) {\n <div class=\"wr-form-error wr-form-field__error\" role=\"alert\" [attr.data-key]=\"message.key\">\n {{ message.text }}\n </div>\n }\n </div>\n} @else if (hint()) {\n <small class=\"wr-form-field__hint\">{{ hint() }}</small>\n}\n" }]
380
+ }], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], optional: [{ type: i0.Input, args: [{ isSignal: true, alias: "optional", required: false }] }], controlId: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlId", required: false }] }], ngControl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => NgControl), { isSignal: true }] }], autoErrors: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoErrors", required: false }] }], projectedErrors: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => WrFormError), { isSignal: true }] }] } });
165
381
 
166
382
  /**
167
383
  * Generated bundle index. Do not edit.
168
384
  */
169
385
 
170
- export { WrFormError, WrFormField, WrFormItem };
386
+ export { WR_FORM_ERRORS, WR_FORM_ERROR_FALLBACKS, WR_FORM_FIELD, WrFormError, WrFormField, WrFormItem, provideWrFormErrors };
171
387
  //# sourceMappingURL=ngwr-form.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-form.mjs","sources":["../../../projects/lib/form/form-item.ts","../../../projects/lib/form/form-field.ts","../../../projects/lib/form/form-field.html","../../../projects/lib/form/ngwr-form.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, computed, input } from '@angular/core';\n\n/**\n * Wraps a label + control + error message into a single field row.\n *\n * Toggle `hasError` to apply error styling to the projected label and\n * any descendant input / textarea / checkbox.\n *\n * @example\n * ```html\n * <wr-form-item [hasError]=\"form.controls.email.invalid\">\n * <label>Email</label>\n * <wr-input formControlName=\"email\" />\n * <wr-form-error>Invalid email</wr-form-error>\n * </wr-form-item>\n * ```\n *\n * @see https://ngwr.dev/reference/components/form\n */\n@Component({\n selector: 'wr-form-item',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n host: { '[class]': 'classes()' },\n})\nexport class WrFormItem {\n /**\n * When `true`, applies error coloring to the projected label and inputs.\n *\n * @default false\n */\n readonly hasError = input(false, { transform: coerceBooleanProperty });\n\n protected readonly classes = computed(() => {\n const parts = ['wr-form-item'];\n if (this.hasError()) parts.push('wr-form-item--error');\n return parts.join(' ');\n });\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, computed, contentChild, input } from '@angular/core';\nimport { NgControl } from '@angular/forms';\n\nlet uid = 0;\n\n/**\n * Wraps a label + control + hint + error messages into a single block —\n * the layout primitive every form ends up reinventing.\n *\n * - Auto-binds `label[for]` to the projected control via a generated id\n * (or use the form-control's `[id]` if you set one).\n * - Reads the projected control's `NgControl` to surface validation\n * errors only when the control has been touched / submitted.\n * - Optional `[required]` / `[optional]` markers next to the label.\n *\n * @example\n * ```html\n * <wr-form-field label=\"Email\" hint=\"We'll never share it.\">\n * <input wrInput [formControl]=\"email\" type=\"email\" />\n * <wr-form-error key=\"required\">Email is required.</wr-form-error>\n * <wr-form-error key=\"email\">Not a valid email.</wr-form-error>\n * </wr-form-field>\n * ```\n *\n * @see https://ngwr.dev/reference/components/form-field\n */\n@Component({\n selector: 'wr-form-field',\n templateUrl: './form-field.html',\n encapsulation: ViewEncapsulation.None,\n host: { '[class]': 'classes()' },\n})\nexport class WrFormField {\n /** Label text shown above the control. */\n readonly label = input<string>('');\n\n /** Hint text shown below the control. Hidden when an error is visible. */\n readonly hint = input<string>('');\n\n /** Show a `*` next to the label. @default false */\n readonly required = input(false, { transform: coerceBooleanProperty });\n\n /** Show `(optional)` next to the label. Mutually exclusive with `required`. @default false */\n readonly optional = input(false, { transform: coerceBooleanProperty });\n\n /** Force a specific id on the label's `for` attribute. Auto-generated otherwise. */\n readonly controlId = input<string>(`wr-form-field-${++uid}`);\n\n /** Projected `NgControl` — used to read touched / dirty / errors. */\n protected readonly ngControl = contentChild(NgControl);\n\n protected readonly errors = computed(() => {\n const c = this.ngControl();\n if (!c) return null;\n if (!c.touched && !c.dirty) return null;\n return c.errors;\n });\n\n protected readonly hasError = computed(() => {\n const errs = this.errors();\n return !!errs && Object.keys(errs).length > 0;\n });\n\n protected readonly classes = computed(() => {\n const parts = ['wr-form-field'];\n if (this.hasError()) parts.push('wr-form-field--invalid');\n if (this.required()) parts.push('wr-form-field--required');\n return parts.join(' ');\n });\n}\n\n/**\n * One error message tied to a validator key. Renders only when the\n * parent form-field has a matching error in `control.errors`.\n *\n * @example\n * ```html\n * <wr-form-error key=\"required\">This field is required.</wr-form-error>\n * <wr-form-error key=\"email\">That doesn't look right.</wr-form-error>\n * ```\n */\n@Component({\n selector: 'wr-form-error',\n template: `<ng-content />`,\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-form-error wr-form-field__error',\n role: 'alert',\n '[attr.data-key]': 'key() ?? null',\n },\n})\nexport class WrFormError {\n /**\n * Validator key this message corresponds to (e.g. `'required'`).\n * Optional — without a key the message always renders, which is the\n * plain inline-error usage inside `<wr-form-item>`.\n */\n readonly key = input<string>();\n}\n","@if (label()) {\n <label class=\"wr-form-field__label\" [attr.for]=\"controlId()\">\n {{ label() }}\n @if (required()) {\n <span class=\"wr-form-field__required\" aria-hidden=\"true\">*</span>\n } @else if (optional()) {\n <span class=\"wr-form-field__optional\">(optional)</span>\n }\n </label>\n}\n\n<div class=\"wr-form-field__control\"><ng-content /></div>\n\n@if (hasError()) {\n <div class=\"wr-form-field__errors\">\n <ng-content select=\"wr-form-error\" />\n </div>\n} @else if (hint()) {\n <small class=\"wr-form-field__hint\">{{ hint() }}</small>\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAAA;;;;;AAKG;AAKH;;;;;;;;;;;;;;;;AAgBG;MAOU,UAAU,CAAA;AACrB;;;;AAIG;IACM,QAAQ,GAAG,KAAK,CAAC,KAAK,gFAAI,SAAS,EAAE,qBAAqB,EAAA,CAAG;AAEnD,IAAA,OAAO,GAAG,QAAQ,CAAC,MAAK;AACzC,QAAA,MAAM,KAAK,GAAG,CAAC,cAAc,CAAC;QAC9B,IAAI,IAAI,CAAC,QAAQ,EAAE;AAAE,YAAA,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC;AACtD,QAAA,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;IACxB,CAAC;gFAAC;uGAZS,UAAU,EAAA,IAAA,EAAA,EAAA,EAAA,MA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AA,EAAA,QAAA,EAAA,IAAA,EAAA,WAAW,0VARZ,CAAA,cAAA,CAAgB,EAAA,QAAA,EAAA,IAAA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA;;2FAQf,WAAW,EAAA,UAAA,EAAA,CAAA;kBAVvB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,eAAe;AACzB,oBAAA,QAAQ,EAAE,CAAA,cAAA,CAAgB;oBAC1B,aAAa,EAAE,iBAAiB,CAAC,IAAI;AACrC,oBAAA,IAAI,EAAE;AACJ,wBAAA,KAAK,EAAE,oCAAoC;AAC3C,wBAAA,IAAI,EAAE,OAAO;AACb,wBAAA,iBAAiB,EAAE,eAAe;AACnC,qBAAA;AACF,iBAAA;;;AElGD;;AAEG;;;;"}
1
+ {"version":3,"file":"ngwr-form.mjs","sources":["../../../projects/lib/form/form-item.ts","../../../projects/lib/form/form-errors.ts","../../../projects/lib/form/tokens.ts","../../../projects/lib/form/form-field.ts","../../../projects/lib/form/form-field.html","../../../projects/lib/form/ngwr-form.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, computed, input } from '@angular/core';\n\n/**\n * Wraps a label + control + error message into a single field row.\n *\n * Toggle `hasError` to apply error styling to the projected label and\n * any descendant input / textarea / checkbox.\n *\n * @example\n * ```html\n * <wr-form-item [hasError]=\"form.controls.email.invalid\">\n * <label>Email</label>\n * <input wrInput formControlName=\"email\" />\n * <wr-form-error>Invalid email</wr-form-error>\n * </wr-form-item>\n * ```\n *\n * @see https://ngwr.dev/reference/components/form\n */\n@Component({\n selector: 'wr-form-item',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n host: { '[class]': 'classes()' },\n})\nexport class WrFormItem {\n /**\n * When `true`, applies error coloring to the projected label and inputs.\n *\n * @default false\n */\n readonly hasError = input(false, { transform: coerceBooleanProperty });\n\n protected readonly classes = computed(() => {\n const parts = ['wr-form-item'];\n if (this.hasError()) parts.push('wr-form-item--error');\n return parts.join(' ');\n });\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken, type EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\n\n/** Pull a number out of a validator payload without trusting its shape. */\nfunction num(error: unknown, field: string): string {\n if (error && typeof error === 'object' && field in error) {\n const value = (error as Record<string, unknown>)[field];\n if (typeof value === 'number' || typeof value === 'string') return String(value);\n }\n return '';\n}\n\n/** What a message function is handed to build its sentence. */\nexport interface WrFormErrorContext {\n /** Validator key (classic forms) or Signal Forms `kind` that produced the error. */\n readonly key: string;\n /**\n * The validator's own payload — `{ requiredLength, actualLength }` for\n * `minlength`, `{ min }` for `wrMinDate`, and so on. `true` for the\n * flag-shaped validators, which carry nothing.\n */\n readonly error: unknown;\n /** The surrounding field's `label`, so a message can name the field. */\n readonly label: string;\n}\n\n/** A message, or a function that builds one from the validator's payload. */\nexport type WrFormErrorMessage = string | ((ctx: WrFormErrorContext) => string);\n\n/** Validator key → message. Keys are matched exactly against `control.errors`. */\nexport type WrFormErrorMessages = Readonly<Record<string, WrFormErrorMessage>>;\n\n/**\n * App-wide validation copy. Empty by default; `<wr-form-field>` falls through\n * to the `ngwr/i18n` catalog and then to a built-in English sentence, so a\n * form shows a usable message with no configuration at all.\n */\nexport const WR_FORM_ERRORS = new InjectionToken<WrFormErrorMessages>('WR_FORM_ERRORS', {\n providedIn: 'root',\n factory: () => ({}),\n});\n\n/**\n * Register validation messages for the whole app.\n *\n * Only the keys you name are overridden — everything else keeps resolving\n * through the i18n catalog, so this composes with `provideWrI18n()` rather than\n * replacing it. A projected `<wr-form-error key=\"…\">` still wins over both:\n * per-field copy beats app-wide copy.\n *\n * @example\n * ```ts\n * bootstrapApplication(App, {\n * providers: [\n * provideWrFormErrors({\n * required: 'Please fill this in.',\n * minlength: ({ error }) => `At least ${(error as { requiredLength: number }).requiredLength} characters.`,\n * }),\n * ],\n * });\n * ```\n */\nexport function provideWrFormErrors(messages: WrFormErrorMessages = {}): EnvironmentProviders {\n return makeEnvironmentProviders([{ provide: WR_FORM_ERRORS, useValue: messages }]);\n}\n\n/**\n * Last-resort English, used when no app catalog and no i18n catalog answer.\n *\n * These exist so that a form with zero configuration still says something true\n * rather than rendering an empty error block. Every key here also ships as a\n * `validation.*` entry in `ngwr/i18n/{en,ru}`, which is what a localized app\n * actually reads.\n */\nexport const WR_FORM_ERROR_FALLBACKS: WrFormErrorMessages = {\n // Angular built-ins.\n required: 'This field is required.',\n requiredTrue: 'This field must be checked.',\n email: 'Enter a valid email address.',\n minlength: ({ error }) => `Enter at least ${num(error, 'requiredLength')} characters.`,\n maxlength: ({ error }) => `Enter at most ${num(error, 'requiredLength')} characters.`,\n min: ({ error }) => `Enter ${num(error, 'min')} or more.`,\n max: ({ error }) => `Enter ${num(error, 'max')} or less.`,\n pattern: 'This value is not in the expected format.',\n\n // WrValidators.\n noWhitespace: 'This field cannot be blank.',\n hexColor: 'Enter a hex colour, e.g. #1a2b3c.',\n url: 'Enter a valid URL.',\n cardNumber: 'Enter a valid card number.',\n cvc: ({ error }) => `Enter the ${num(error, 'length')}-digit security code.`,\n iban: 'Enter a valid IBAN.',\n match: 'The two values do not match.',\n matchFields: 'These fields do not match.',\n oneOf: 'Choose one of the allowed values.',\n minDate: 'Choose a later date.',\n maxDate: 'Choose an earlier date.',\n};\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken, type Signal } from '@angular/core';\n\n/**\n * What a projected control can read from its surrounding `<wr-form-field>`.\n *\n * The field renders `<label [for]>` before it can see what was projected into\n * it, so the id has to travel the other way: the control adopts the id the\n * label already points at. Doing it through DI keeps it a render-time binding,\n * which is what SSR needs — stamping the id from `afterNextRender` would leave\n * every prerendered page with a label pointing at nothing.\n */\nexport interface WrFormFieldContext {\n /** Id the field's `<label for>` points at. */\n readonly controlId: Signal<string>;\n\n /**\n * Validator keys currently in error, once the control is touched or dirty.\n * Empty when the field is valid or has not been interacted with.\n */\n readonly errorKeys: Signal<readonly string[]>;\n\n /** Id of the element listing the visible messages, or `null` when there are none. */\n readonly describedBy: Signal<string | null>;\n}\n\n/** Present only inside a `<wr-form-field>`; inject with `{ optional: true }`. */\nexport const WR_FORM_FIELD = new InjectionToken<WrFormFieldContext>('WR_FORM_FIELD');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n DestroyRef,\n ViewEncapsulation,\n computed,\n contentChild,\n contentChildren,\n effect,\n forwardRef,\n inject,\n input,\n signal,\n} from '@angular/core';\nimport { NgControl } from '@angular/forms';\n\nimport { EMPTY, type Subscription } from 'rxjs';\n\nimport { WrI18n } from 'ngwr/i18n';\n\nimport { WR_FORM_ERRORS, WR_FORM_ERROR_FALLBACKS, type WrFormErrorMessage } from './form-errors';\nimport { WR_FORM_FIELD, type WrFormFieldContext } from './tokens';\n\nlet uid = 0;\n\n/** A message is either literal text or a function over the validator's payload. */\nfunction render(message: WrFormErrorMessage, key: string, error: unknown, label: string): string {\n return typeof message === 'function' ? message({ key, error, label }) : message;\n}\n\n/** Validator payloads are plain objects; anything else interpolates nothing. */\nfunction toParams(error: unknown): Record<string, unknown> | undefined {\n return error && typeof error === 'object' ? (error as Record<string, unknown>) : undefined;\n}\n\n/**\n * One error message tied to a validator key. Renders only when the parent\n * form-field has a matching error in `control.errors`, and only once the\n * control is touched or dirty.\n *\n * @example\n * ```html\n * <wr-form-error key=\"required\">This field is required.</wr-form-error>\n * <wr-form-error key=\"email\">That doesn't look right.</wr-form-error>\n * ```\n */\n@Component({\n selector: 'wr-form-error',\n template: `<ng-content />`,\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-form-error wr-form-field__error',\n role: 'alert',\n '[attr.data-key]': 'key() ?? null',\n '[class.wr-form-field__error--hidden]': '!visible()',\n },\n})\nexport class WrFormError {\n /**\n * Validator key this message corresponds to (e.g. `'required'`).\n * Optional — without a key the message always renders, which is the\n * plain inline-error usage inside `<wr-form-item>`.\n */\n readonly key = input<string>();\n\n private readonly field = inject(WR_FORM_FIELD, { optional: true });\n\n /**\n * Whether this message is the one the current error calls for.\n *\n * The parent projects every `<wr-form-error>` through a single\n * `<ng-content select>`, which cannot filter — so each message decides for\n * itself. Without this, one invalid control rendered \"Email is required.\"\n * and \"That isn't a valid email.\" side by side, which is what the docs have\n * always described as gated behaviour.\n *\n * A keyless message always shows: that is the plain inline-error usage inside\n * `<wr-form-item>`, which has no error discovery at all.\n */\n protected readonly visible = computed(() => {\n const key = this.key();\n if (!key || !this.field) return true;\n return this.field.errorKeys().includes(key);\n });\n}\n\n/**\n * Wraps a label + control + hint + error messages into a single block —\n * the layout primitive every form ends up reinventing.\n *\n * - Auto-binds `label[for]` to the projected control via a generated id\n * (or use the form-control's `[id]` if you set one).\n * - Reads the projected control's `NgControl` to surface validation\n * errors only when the control has been touched / submitted.\n * - Optional `[required]` / `[optional]` markers next to the label.\n *\n * @example\n * ```html\n * <wr-form-field label=\"Email\" hint=\"We'll never share it.\">\n * <input wrInput [formControl]=\"email\" type=\"email\" />\n * <wr-form-error key=\"required\">Email is required.</wr-form-error>\n * <wr-form-error key=\"email\">Not a valid email.</wr-form-error>\n * </wr-form-field>\n * ```\n *\n * @see https://ngwr.dev/reference/components/form-field\n */\n@Component({\n selector: 'wr-form-field',\n templateUrl: './form-field.html',\n encapsulation: ViewEncapsulation.None,\n host: { '[class]': 'classes()' },\n providers: [\n {\n provide: WR_FORM_FIELD,\n // eslint-disable-next-line @angular-eslint/no-forward-ref\n useExisting: forwardRef(() => WrFormField),\n },\n ],\n})\nexport class WrFormField implements WrFormFieldContext {\n /** Label text shown above the control. */\n readonly label = input<string>('');\n\n /** Hint text shown below the control. Hidden when an error is visible. */\n readonly hint = input<string>('');\n\n /** Show a `*` next to the label. @default false */\n readonly required = input(false, { transform: coerceBooleanProperty });\n\n /** Show `(optional)` next to the label. Mutually exclusive with `required`. @default false */\n readonly optional = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Force a specific id on the label's `for` attribute. Auto-generated\n * otherwise, and adopted by the projected `wrInput` unless that element\n * already carries an `id` of its own.\n */\n readonly controlId = input<string>(`wr-form-field-${++uid}`);\n\n /**\n * Projected `NgControl` — used to read touched / dirty / errors.\n *\n * This catches `[formField]` too: Angular's Signal Forms directive provides\n * `NgControl` via its interop shim, so both forms flavours land here.\n */\n protected readonly ngControl = contentChild(NgControl);\n\n /**\n * Bumped on every event the projected control emits.\n *\n * `AbstractControl`'s `touched` / `dirty` / `errors` accessors are NOT\n * reactive under classic forms — Angular reads them inside `untracked()`, and\n * `errors` is a plain assigned field. A `computed` over them therefore caches\n * its first value and never recomputes, which in a zoneless app means the\n * error block never appears at all. `control.events` is the reactive source\n * Angular does expose, so the computed depends on this counter instead.\n * Signal Forms needs none of this — its interop getters read live signals —\n * and harmlessly contributes no events.\n */\n private readonly revision = signal(0);\n\n constructor() {\n let sub: Subscription | null = null;\n effect(() => {\n const control = this.ngControl()?.control;\n sub?.unsubscribe();\n sub = (control?.events ?? EMPTY).subscribe(() => this.revision.update(n => n + 1));\n });\n inject(DestroyRef).onDestroy(() => sub?.unsubscribe());\n }\n\n protected readonly errors = computed(() => {\n this.revision();\n const c = this.ngControl();\n if (!c) return null;\n if (!c.touched && !c.dirty) return null;\n return c.errors;\n });\n\n protected readonly hasError = computed(() => {\n const errs = this.errors();\n return !!errs && Object.keys(errs).length > 0;\n });\n\n /** @internal Read by the projected `<wr-form-error>` children to decide which of them renders. */\n readonly errorKeys = computed<readonly string[]>(() => Object.keys(this.errors() ?? {}));\n\n /** @internal Read by the projected control so a screen reader is pointed at the message. */\n readonly describedBy = computed(() => (this.hasError() ? `${this.controlId()}-errors` : null));\n\n /**\n * Render a catalog message for any error the markup does not already answer.\n *\n * On by default: a field with no `<wr-form-error>` at all is the common case,\n * and an empty error block helps nobody. Turn it off for a field whose copy is\n * entirely hand-written. @default true\n */\n readonly autoErrors = input(true, { transform: coerceBooleanProperty });\n\n private readonly projectedErrors = contentChildren(WrFormError);\n private readonly appMessages = inject(WR_FORM_ERRORS);\n private readonly i18n = inject(WrI18n, { optional: true });\n\n /**\n * Errors with no projected `<wr-form-error key>` to answer them, resolved to\n * text: the app catalog first, then the `validation.*` i18n keys, then a\n * built-in English sentence. Per-field markup always wins — it is the most\n * specific thing the author wrote.\n */\n protected readonly autoMessages = computed<readonly { key: string; text: string }[]>(() => {\n if (!this.autoErrors()) return [];\n const errors = this.errors();\n if (!errors) return [];\n\n const claimed = new Set(\n this.projectedErrors()\n .map(e => e.key())\n .filter(Boolean)\n );\n\n return Object.entries(errors)\n .filter(([key]) => !claimed.has(key))\n .map(([key, error]) => ({ key, text: this.resolve(key, error) }))\n .filter(m => m.text.length > 0);\n });\n\n private resolve(key: string, error: unknown): string {\n const app = this.appMessages[key];\n if (app !== undefined) return render(app, key, error, this.label());\n\n // `t()` reads the service's revision signal, so this recomputes on a locale\n // switch; a miss returns the key itself, which is the documented signal.\n const translated = this.i18n?.t(`validation.${key}`, toParams(error));\n if (translated && translated !== `validation.${key}`) return translated;\n\n const fallback = WR_FORM_ERROR_FALLBACKS[key];\n return fallback === undefined ? '' : render(fallback, key, error, this.label());\n }\n\n protected readonly classes = computed(() => {\n const parts = ['wr-form-field'];\n if (this.hasError()) parts.push('wr-form-field--invalid');\n if (this.required()) parts.push('wr-form-field--required');\n return parts.join(' ');\n });\n}\n","@if (label()) {\n <label class=\"wr-form-field__label\" [attr.for]=\"controlId()\">\n {{ label() }}\n @if (required()) {\n <span class=\"wr-form-field__required\" aria-hidden=\"true\">*</span>\n } @else if (optional()) {\n <span class=\"wr-form-field__optional\">(optional)</span>\n }\n </label>\n}\n\n<div class=\"wr-form-field__control\"><ng-content /></div>\n\n@if (hasError()) {\n <div class=\"wr-form-field__errors\" [attr.id]=\"describedBy()\">\n <ng-content select=\"wr-form-error\" />\n @for (message of autoMessages(); track message.key) {\n <div class=\"wr-form-error wr-form-field__error\" role=\"alert\" [attr.data-key]=\"message.key\">\n {{ message.text }}\n </div>\n }\n </div>\n} @else if (hint()) {\n <small class=\"wr-form-field__hint\">{{ hint() }}</small>\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;AAKG;AAKH;;;;;;;;;;;;;;;;AAgBG;MAOU,UAAU,CAAA;AACrB;;;;AAIG;IACM,QAAQ,GAAG,KAAK,CAAC,KAAK,gFAAI,SAAS,EAAE,qBAAqB,EAAA,CAAG;AAEnD,IAAA,OAAO,GAAG,QAAQ,CAAC,MAAK;AACzC,QAAA,MAAM,KAAK,GAAG,CAAC,cAAc,CAAC;QAC9B,IAAI,IAAI,CAAC,QAAQ,EAAE;AAAE,YAAA,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC;AACtD,QAAA,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;IACxB,CAAC;gFAAC;uGAZS,UAAU,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAV,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAU,qQAJX,gBAAgB,EAAA,QAAA,EAAA,IAAA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA;;2FAIf,UAAU,EAAA,UAAA,EAAA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A,EAAA,KAAA,EAAA,OAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,IAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,MAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,QAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,UAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,QAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,UAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,SAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,WAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,SAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,YAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,UAAA,CAAA,MAAA,SAAS,wMAsDF,WAAW,CAAA,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AE/MhE;;AAEG;;;;"}
@@ -88,6 +88,14 @@ class WrFuzzyText {
88
88
  isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
89
89
  platform = inject(WrPlatform);
90
90
  teardown;
91
+ /**
92
+ * `init()` suspends on font loading, so the component can be destroyed while
93
+ * it is awaiting. At that moment `teardown` is still undefined, so the
94
+ * destroy hook has nothing to call — and everything the rest of `init()`
95
+ * starts (the rAF loop, the glitch timers, canvas listeners) would run for
96
+ * the life of the page. This flag lets the continuation bail out.
97
+ */
98
+ destroyed = false;
91
99
  constructor() {
92
100
  if (!this.isBrowser)
93
101
  return;
@@ -118,7 +126,10 @@ class WrFuzzyText {
118
126
  void this.init();
119
127
  });
120
128
  });
121
- this.destroyRef.onDestroy(() => this.teardown?.());
129
+ this.destroyRef.onDestroy(() => {
130
+ this.destroyed = true;
131
+ this.teardown?.();
132
+ });
122
133
  }
123
134
  // Init / loop
124
135
  async init() {
@@ -138,6 +149,9 @@ class WrFuzzyText {
138
149
  catch {
139
150
  await document.fonts.ready;
140
151
  }
152
+ // Destroyed while the fonts were loading — nothing below may start.
153
+ if (this.destroyed)
154
+ return;
141
155
  // Numeric font size for buffer maths.
142
156
  let numericFontSize;
143
157
  if (typeof fontSize === 'number') {