ngwr 13.0.1 → 14.0.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.
Files changed (309) hide show
  1. package/README.md +69 -13
  2. package/aurora/aurora.scss +1 -1
  3. package/aurora/styles/_dark.scss +21 -0
  4. package/aurora/styles/_index.scss +11 -30
  5. package/aurora/styles/_rules.scss +25 -0
  6. package/border-glow/styles/_dark.scss +46 -0
  7. package/border-glow/styles/_index.scss +5 -0
  8. package/border-glow/styles/_rules.scss +0 -31
  9. package/button/styles/_index.scss +16 -0
  10. package/color-picker/styles/_index.scss +43 -5
  11. package/event-calendar/styles/_index.scss +15 -0
  12. package/fesm2022/ngwr-action-sheet.mjs +3 -3
  13. package/fesm2022/ngwr-affix.mjs +3 -3
  14. package/fesm2022/ngwr-alert.mjs +7 -7
  15. package/fesm2022/ngwr-alert.mjs.map +1 -1
  16. package/fesm2022/ngwr-anchor.mjs +3 -3
  17. package/fesm2022/ngwr-aurora.mjs +4 -4
  18. package/fesm2022/ngwr-aurora.mjs.map +1 -1
  19. package/fesm2022/ngwr-avatar.mjs +3 -3
  20. package/fesm2022/ngwr-back-top.mjs +14 -4
  21. package/fesm2022/ngwr-back-top.mjs.map +1 -1
  22. package/fesm2022/ngwr-badge.mjs +6 -6
  23. package/fesm2022/ngwr-bar-chart.mjs +3 -3
  24. package/fesm2022/ngwr-blur-text.mjs +16 -5
  25. package/fesm2022/ngwr-blur-text.mjs.map +1 -1
  26. package/fesm2022/ngwr-border-glow.mjs +4 -4
  27. package/fesm2022/ngwr-border-glow.mjs.map +1 -1
  28. package/fesm2022/ngwr-breadcrumbs.mjs +7 -7
  29. package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
  30. package/fesm2022/ngwr-burger.mjs +3 -3
  31. package/fesm2022/ngwr-button.mjs +88 -10
  32. package/fesm2022/ngwr-button.mjs.map +1 -1
  33. package/fesm2022/ngwr-calendar-heatmap.mjs +3 -3
  34. package/fesm2022/ngwr-calendar-testing.mjs +15 -0
  35. package/fesm2022/ngwr-calendar-testing.mjs.map +1 -1
  36. package/fesm2022/ngwr-calendar.mjs +53 -7
  37. package/fesm2022/ngwr-calendar.mjs.map +1 -1
  38. package/fesm2022/ngwr-card.mjs +9 -9
  39. package/fesm2022/ngwr-carousel.mjs +6 -6
  40. package/fesm2022/ngwr-cascader.mjs +4 -4
  41. package/fesm2022/ngwr-cascader.mjs.map +1 -1
  42. package/fesm2022/ngwr-checkbox.mjs +6 -6
  43. package/fesm2022/ngwr-circular-text.mjs +23 -4
  44. package/fesm2022/ngwr-circular-text.mjs.map +1 -1
  45. package/fesm2022/ngwr-click-spark.mjs +3 -3
  46. package/fesm2022/ngwr-clipboard.mjs +3 -3
  47. package/fesm2022/ngwr-collapse.mjs +9 -9
  48. package/fesm2022/ngwr-collapse.mjs.map +1 -1
  49. package/fesm2022/ngwr-color-picker-testing.mjs +23 -7
  50. package/fesm2022/ngwr-color-picker-testing.mjs.map +1 -1
  51. package/fesm2022/ngwr-color-picker.mjs +93 -14
  52. package/fesm2022/ngwr-color-picker.mjs.map +1 -1
  53. package/fesm2022/ngwr-command-palette.mjs +29 -5
  54. package/fesm2022/ngwr-command-palette.mjs.map +1 -1
  55. package/fesm2022/ngwr-compare.mjs +3 -3
  56. package/fesm2022/ngwr-confetti.mjs +3 -3
  57. package/fesm2022/ngwr-context-menu.mjs +18 -12
  58. package/fesm2022/ngwr-context-menu.mjs.map +1 -1
  59. package/fesm2022/ngwr-cookie.mjs +3 -3
  60. package/fesm2022/ngwr-counter.mjs +6 -6
  61. package/fesm2022/ngwr-date-adapters-fns.mjs +104 -36
  62. package/fesm2022/ngwr-date-adapters-fns.mjs.map +1 -1
  63. package/fesm2022/ngwr-date-adapters-luxon.mjs +3 -3
  64. package/fesm2022/ngwr-date-picker-testing.mjs +10 -2
  65. package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -1
  66. package/fesm2022/ngwr-date-picker.mjs +118 -28
  67. package/fesm2022/ngwr-date-picker.mjs.map +1 -1
  68. package/fesm2022/ngwr-date.mjs +483 -82
  69. package/fesm2022/ngwr-date.mjs.map +1 -1
  70. package/fesm2022/ngwr-decrypt-text.mjs +3 -3
  71. package/fesm2022/ngwr-density.mjs +6 -6
  72. package/fesm2022/ngwr-descriptions.mjs +6 -6
  73. package/fesm2022/ngwr-dialog.mjs +15 -15
  74. package/fesm2022/ngwr-directives.mjs +12 -12
  75. package/fesm2022/ngwr-divider.mjs +3 -3
  76. package/fesm2022/ngwr-donut-chart.mjs +3 -3
  77. package/fesm2022/ngwr-drag-drop.mjs +37 -9
  78. package/fesm2022/ngwr-drag-drop.mjs.map +1 -1
  79. package/fesm2022/ngwr-drawer.mjs +18 -18
  80. package/fesm2022/ngwr-dropdown.mjs +29 -12
  81. package/fesm2022/ngwr-dropdown.mjs.map +1 -1
  82. package/fesm2022/ngwr-empty.mjs +3 -3
  83. package/fesm2022/ngwr-event-calendar-testing.mjs.map +1 -1
  84. package/fesm2022/ngwr-event-calendar.mjs +6 -6
  85. package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
  86. package/fesm2022/ngwr-falling-text.mjs +3 -3
  87. package/fesm2022/ngwr-file-upload.mjs +55 -15
  88. package/fesm2022/ngwr-file-upload.mjs.map +1 -1
  89. package/fesm2022/ngwr-form-testing.mjs +13 -7
  90. package/fesm2022/ngwr-form-testing.mjs.map +1 -1
  91. package/fesm2022/ngwr-form.mjs +44 -25
  92. package/fesm2022/ngwr-form.mjs.map +1 -1
  93. package/fesm2022/ngwr-fuzzy-text.mjs +3 -3
  94. package/fesm2022/ngwr-gauge.mjs +3 -3
  95. package/fesm2022/ngwr-glitch-text.mjs +3 -3
  96. package/fesm2022/ngwr-gradient-text.mjs +3 -3
  97. package/fesm2022/ngwr-hotkey.mjs +6 -6
  98. package/fesm2022/ngwr-i18n-en.mjs +63 -1
  99. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  100. package/fesm2022/ngwr-i18n-ru.mjs +28 -1
  101. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  102. package/fesm2022/ngwr-i18n.mjs +159 -31
  103. package/fesm2022/ngwr-i18n.mjs.map +1 -1
  104. package/fesm2022/ngwr-icon.mjs +6 -6
  105. package/fesm2022/ngwr-image-cropper.mjs +3 -3
  106. package/fesm2022/ngwr-input-number.mjs +5 -5
  107. package/fesm2022/ngwr-input-number.mjs.map +1 -1
  108. package/fesm2022/ngwr-input-otp.mjs +23 -5
  109. package/fesm2022/ngwr-input-otp.mjs.map +1 -1
  110. package/fesm2022/ngwr-input.mjs +37 -26
  111. package/fesm2022/ngwr-input.mjs.map +1 -1
  112. package/fesm2022/ngwr-keyboard.mjs +3 -3
  113. package/fesm2022/ngwr-knob-testing.mjs.map +1 -1
  114. package/fesm2022/ngwr-knob.mjs +22 -4
  115. package/fesm2022/ngwr-knob.mjs.map +1 -1
  116. package/fesm2022/ngwr-layout.mjs +15 -15
  117. package/fesm2022/ngwr-lightbox.mjs +4 -4
  118. package/fesm2022/ngwr-lightbox.mjs.map +1 -1
  119. package/fesm2022/ngwr-line-chart.mjs +3 -3
  120. package/fesm2022/ngwr-list.mjs +7 -7
  121. package/fesm2022/ngwr-list.mjs.map +1 -1
  122. package/fesm2022/ngwr-loading-bar-router.mjs +73 -0
  123. package/fesm2022/ngwr-loading-bar-router.mjs.map +1 -0
  124. package/fesm2022/ngwr-loading-bar.mjs +27 -38
  125. package/fesm2022/ngwr-loading-bar.mjs.map +1 -1
  126. package/fesm2022/ngwr-markdown.mjs +6 -6
  127. package/fesm2022/ngwr-marquee.mjs +3 -3
  128. package/fesm2022/ngwr-media.mjs +3 -3
  129. package/fesm2022/ngwr-mention.mjs +109 -19
  130. package/fesm2022/ngwr-mention.mjs.map +1 -1
  131. package/fesm2022/ngwr-meta.mjs +6 -6
  132. package/fesm2022/ngwr-meter-group.mjs +3 -3
  133. package/fesm2022/ngwr-overlay.mjs +6 -6
  134. package/fesm2022/ngwr-page-header.mjs +3 -3
  135. package/fesm2022/ngwr-pagination-testing.mjs +11 -10
  136. package/fesm2022/ngwr-pagination-testing.mjs.map +1 -1
  137. package/fesm2022/ngwr-pagination.mjs +67 -32
  138. package/fesm2022/ngwr-pagination.mjs.map +1 -1
  139. package/fesm2022/ngwr-pipes.mjs +21 -21
  140. package/fesm2022/ngwr-platform.mjs +9 -9
  141. package/fesm2022/ngwr-popconfirm.mjs +7 -6
  142. package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
  143. package/fesm2022/ngwr-popover.mjs +7 -6
  144. package/fesm2022/ngwr-popover.mjs.map +1 -1
  145. package/fesm2022/ngwr-progress.mjs +3 -3
  146. package/fesm2022/ngwr-pull-to-refresh.mjs +3 -3
  147. package/fesm2022/ngwr-qr.mjs +3 -3
  148. package/fesm2022/ngwr-radio.mjs +6 -6
  149. package/fesm2022/ngwr-rating.mjs +48 -22
  150. package/fesm2022/ngwr-rating.mjs.map +1 -1
  151. package/fesm2022/ngwr-result.mjs +12 -12
  152. package/fesm2022/ngwr-rotating-text.mjs +3 -3
  153. package/fesm2022/ngwr-scroll.mjs +3 -3
  154. package/fesm2022/ngwr-segmented.mjs +12 -8
  155. package/fesm2022/ngwr-segmented.mjs.map +1 -1
  156. package/fesm2022/ngwr-select.mjs +217 -59
  157. package/fesm2022/ngwr-select.mjs.map +1 -1
  158. package/fesm2022/ngwr-shiny-text.mjs +7 -7
  159. package/fesm2022/ngwr-shiny-text.mjs.map +1 -1
  160. package/fesm2022/ngwr-sidebar.mjs +3 -3
  161. package/fesm2022/ngwr-skeleton.mjs +3 -3
  162. package/fesm2022/ngwr-slider.mjs +12 -8
  163. package/fesm2022/ngwr-slider.mjs.map +1 -1
  164. package/fesm2022/ngwr-sparkline.mjs +3 -3
  165. package/fesm2022/ngwr-speed-dial.mjs +3 -3
  166. package/fesm2022/ngwr-spinner.mjs +3 -3
  167. package/fesm2022/ngwr-splash-cursor.mjs +3 -3
  168. package/fesm2022/ngwr-split-text.mjs +3 -3
  169. package/fesm2022/ngwr-splitter-testing.mjs.map +1 -1
  170. package/fesm2022/ngwr-splitter.mjs +3 -3
  171. package/fesm2022/ngwr-spotlight-card.mjs +7 -7
  172. package/fesm2022/ngwr-spotlight-card.mjs.map +1 -1
  173. package/fesm2022/ngwr-squircle.mjs +7 -6
  174. package/fesm2022/ngwr-squircle.mjs.map +1 -1
  175. package/fesm2022/ngwr-star-border.mjs +4 -4
  176. package/fesm2022/ngwr-star-border.mjs.map +1 -1
  177. package/fesm2022/ngwr-statistic.mjs +44 -13
  178. package/fesm2022/ngwr-statistic.mjs.map +1 -1
  179. package/fesm2022/ngwr-stepper.mjs +6 -6
  180. package/fesm2022/ngwr-storage.mjs +11 -3
  181. package/fesm2022/ngwr-storage.mjs.map +1 -1
  182. package/fesm2022/ngwr-switch.mjs +3 -3
  183. package/fesm2022/ngwr-table.mjs +51 -28
  184. package/fesm2022/ngwr-table.mjs.map +1 -1
  185. package/fesm2022/ngwr-tabs-router.mjs +158 -0
  186. package/fesm2022/ngwr-tabs-router.mjs.map +1 -0
  187. package/fesm2022/ngwr-tabs-testing.mjs +13 -11
  188. package/fesm2022/ngwr-tabs-testing.mjs.map +1 -1
  189. package/fesm2022/ngwr-tabs.mjs +104 -16
  190. package/fesm2022/ngwr-tabs.mjs.map +1 -1
  191. package/fesm2022/ngwr-textarea.mjs +46 -6
  192. package/fesm2022/ngwr-textarea.mjs.map +1 -1
  193. package/fesm2022/ngwr-theme.mjs +90 -4
  194. package/fesm2022/ngwr-theme.mjs.map +1 -1
  195. package/fesm2022/ngwr-tilt-card.mjs +7 -7
  196. package/fesm2022/ngwr-tilt-card.mjs.map +1 -1
  197. package/fesm2022/ngwr-timeline.mjs +6 -6
  198. package/fesm2022/ngwr-toast.mjs +116 -11
  199. package/fesm2022/ngwr-toast.mjs.map +1 -1
  200. package/fesm2022/ngwr-toolbar.mjs +3 -3
  201. package/fesm2022/ngwr-tour.mjs +6 -6
  202. package/fesm2022/ngwr-tour.mjs.map +1 -1
  203. package/fesm2022/ngwr-transfer.mjs +4 -4
  204. package/fesm2022/ngwr-transfer.mjs.map +1 -1
  205. package/fesm2022/ngwr-tree.mjs +35 -12
  206. package/fesm2022/ngwr-tree.mjs.map +1 -1
  207. package/fesm2022/ngwr-typewriter.mjs +3 -3
  208. package/fesm2022/ngwr-typography.mjs +3 -3
  209. package/fesm2022/ngwr-utils.mjs +37 -1
  210. package/fesm2022/ngwr-utils.mjs.map +1 -1
  211. package/fesm2022/ngwr-version.mjs +1 -1
  212. package/fesm2022/ngwr-version.mjs.map +1 -1
  213. package/fesm2022/ngwr-virtual-scroll.mjs +3 -3
  214. package/fesm2022/ngwr-waves.mjs +4 -4
  215. package/fesm2022/ngwr-waves.mjs.map +1 -1
  216. package/fesm2022/ngwr-window-testing.mjs +10 -2
  217. package/fesm2022/ngwr-window-testing.mjs.map +1 -1
  218. package/fesm2022/ngwr-window.mjs +15 -15
  219. package/fesm2022/ngwr-window.mjs.map +1 -1
  220. package/i18n/en.json +33 -6
  221. package/i18n/ru.json +33 -6
  222. package/llms-full.txt +29 -20
  223. package/llms.txt +127 -25
  224. package/mcp/catalog.js +3 -3
  225. package/mcp/providers.js +11 -0
  226. package/package.json +9 -1
  227. package/schematics/migrations/v13/index.js +101 -0
  228. package/schematics/migrations/v14/index.js +422 -0
  229. package/schematics/migrations.json +10 -0
  230. package/schematics/page/templates.js +1 -1
  231. package/schematics/use/symbol-map.json +1 -0
  232. package/shiny-text/styles/_dark.scss +20 -0
  233. package/shiny-text/styles/_index.scss +5 -0
  234. package/shiny-text/styles/_rules.scss +0 -4
  235. package/skills/ngwr/SKILL.md +4 -1
  236. package/skills/ngwr/references/catalog.md +2 -0
  237. package/skills/ngwr/references/setup.md +4 -0
  238. package/spotlight-card/styles/_dark.scss +21 -0
  239. package/spotlight-card/styles/_index.scss +5 -0
  240. package/spotlight-card/styles/_rules.scss +0 -6
  241. package/star-border/styles/_dark.scss +21 -0
  242. package/star-border/styles/_index.scss +5 -0
  243. package/star-border/styles/_rules.scss +0 -5
  244. package/stepper/styles/_index.scss +19 -1
  245. package/textarea/styles/_index.scss +14 -6
  246. package/theme/styles/_colors.scss +102 -0
  247. package/theme/styles/_focus.scss +31 -1
  248. package/tilt-card/styles/_dark.scss +21 -0
  249. package/tilt-card/styles/_index.scss +5 -0
  250. package/tilt-card/styles/_rules.scss +0 -5
  251. package/toast/styles/_index.scss +12 -4
  252. package/types/ngwr-alert.d.ts +3 -3
  253. package/types/ngwr-blur-text.d.ts +8 -0
  254. package/types/ngwr-button.d.ts +45 -2
  255. package/types/ngwr-calendar-testing.d.ts +21 -4
  256. package/types/ngwr-calendar.d.ts +37 -0
  257. package/types/ngwr-circular-text.d.ts +9 -0
  258. package/types/ngwr-collapse.d.ts +19 -15
  259. package/types/ngwr-color-picker-testing.d.ts +10 -4
  260. package/types/ngwr-color-picker.d.ts +70 -2
  261. package/types/ngwr-command-palette.d.ts +14 -0
  262. package/types/ngwr-context-menu.d.ts +1 -1
  263. package/types/ngwr-date-adapters-fns.d.ts +71 -29
  264. package/types/ngwr-date-picker-testing.d.ts +206 -185
  265. package/types/ngwr-date-picker.d.ts +7 -0
  266. package/types/ngwr-date.d.ts +143 -13
  267. package/types/ngwr-drag-drop.d.ts +19 -0
  268. package/types/ngwr-dropdown.d.ts +18 -2
  269. package/types/ngwr-event-calendar-testing.d.ts +12 -9
  270. package/types/ngwr-file-upload.d.ts +31 -3
  271. package/types/ngwr-form-testing.d.ts +13 -7
  272. package/types/ngwr-form.d.ts +47 -12
  273. package/types/ngwr-i18n.d.ts +89 -7
  274. package/types/ngwr-input-number.d.ts +1 -1
  275. package/types/ngwr-input-otp.d.ts +3 -0
  276. package/types/ngwr-input.d.ts +13 -5
  277. package/types/ngwr-knob-testing.d.ts +8 -4
  278. package/types/ngwr-knob.d.ts +18 -0
  279. package/types/ngwr-loading-bar-router.d.ts +35 -0
  280. package/types/ngwr-loading-bar.d.ts +19 -9
  281. package/types/ngwr-mention.d.ts +13 -0
  282. package/types/ngwr-pagination-testing.d.ts +11 -10
  283. package/types/ngwr-pagination.d.ts +39 -10
  284. package/types/ngwr-popconfirm.d.ts +1 -1
  285. package/types/ngwr-popover.d.ts +1 -1
  286. package/types/ngwr-rating.d.ts +25 -4
  287. package/types/ngwr-segmented.d.ts +1 -0
  288. package/types/ngwr-select.d.ts +110 -19
  289. package/types/ngwr-slider.d.ts +1 -0
  290. package/types/ngwr-splitter-testing.d.ts +9 -4
  291. package/types/ngwr-squircle.d.ts +1 -1
  292. package/types/ngwr-statistic.d.ts +22 -2
  293. package/types/ngwr-storage.d.ts +39 -1
  294. package/types/ngwr-table.d.ts +24 -5
  295. package/types/ngwr-tabs-router.d.ts +67 -0
  296. package/types/ngwr-tabs-testing.d.ts +12 -10
  297. package/types/ngwr-tabs.d.ts +103 -6
  298. package/types/ngwr-textarea.d.ts +29 -0
  299. package/types/ngwr-theme.d.ts +92 -2
  300. package/types/ngwr-toast.d.ts +53 -0
  301. package/types/ngwr-tree.d.ts +10 -2
  302. package/types/ngwr-utils.d.ts +33 -1
  303. package/types/ngwr-version.d.ts +1 -1
  304. package/types/ngwr-window-testing.d.ts +11 -3
  305. package/types/ngwr-window.d.ts +11 -4
  306. package/waves/styles/_dark.scss +19 -0
  307. package/waves/styles/_index.scss +5 -0
  308. package/waves/styles/_rules.scss +0 -3
  309. package/window/styles/_index.scss +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-file-upload.mjs","sources":["../../../projects/lib/file-upload/file-upload.ts","../../../projects/lib/file-upload/file-upload.html","../../../projects/lib/file-upload/ngwr-file-upload.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, coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n type ElementRef,\n ViewEncapsulation,\n computed,\n effect,\n input,\n model,\n output,\n signal,\n untracked,\n viewChild,\n} from '@angular/core';\nimport type { FormValueControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { useI18nText } from 'ngwr/i18n';\n\nimport type { WrFileUploadRejection, WrFileUploadRejectionReason } from './interfaces';\n\n/** Human-readable byte size (e.g. `1.2 MB`). */\nfunction formatBytes(bytes: number): string {\n if (!Number.isFinite(bytes) || bytes <= 0) return '0 B';\n const units = ['B', 'KB', 'MB', 'GB', 'TB'];\n const i = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1);\n const v = bytes / 1024 ** i;\n return `${v.toFixed(v >= 100 || i === 0 ? 0 : 1)} ${units[i]}`;\n}\n\n/** Does `file` match the `accept` attribute (extensions or MIME globs)? */\nfunction matchesAccept(file: File, accept: string): boolean {\n if (!accept) return true;\n const tokens = accept\n .split(',')\n .map(t => t.trim().toLowerCase())\n .filter(Boolean);\n if (tokens.length === 0) return true;\n const name = file.name.toLowerCase();\n const mime = file.type.toLowerCase();\n return tokens.some(token => {\n if (token.startsWith('.')) return name.endsWith(token);\n if (token.endsWith('/*')) return mime.startsWith(token.slice(0, -1));\n return mime === token;\n });\n}\n\n/**\n * Drag-and-drop file upload zone. Click to browse, drag-and-drop to add,\n * with an optional file list + remove buttons.\n *\n * A signal-forms native control: it implements\n * `FormValueControl<File | readonly File[] | null>`, so `[formField]` binds\n * straight to its `value` model — no `ControlValueAccessor` in between.\n * `[(value)]` works standalone. The value shape follows `multiple`: a single\n * `File` (or `null`), or a `File[]` array.\n *\n * @example\n * ```html\n * <!-- signal forms -->\n * <wr-file-upload [formField]=\"form.files\" [multiple]=\"true\" accept=\"image/*\" />\n *\n * <!-- standalone two-way binding -->\n * <wr-file-upload [(value)]=\"avatar\" accept=\".png,.jpg\" [maxSize]=\"2 * 1024 * 1024\" />\n * ```\n *\n * @see https://ngwr.dev/reference/components/file-upload\n */\n@Component({\n selector: 'wr-file-upload',\n templateUrl: './file-upload.html',\n encapsulation: ViewEncapsulation.None,\n host: { '[class]': 'classes()' },\n imports: [],\n})\nexport class WrFileUpload implements FormValueControl<File | readonly File[] | null> {\n /** Allow multiple files. Single mode replaces on each add. @default false */\n readonly multiple = input(false, { transform: coerceBooleanProperty });\n\n /** `accept` attribute — comma-separated MIME types or extensions. @default '' */\n readonly accept = input<string>('');\n\n /** Max bytes per file. `0` disables the check. @default 0 */\n readonly maxSize = input(0, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 0)) });\n\n /** Max files (multi mode only). `0` disables the check. @default 0 */\n readonly maxFiles = input(0, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 0)) });\n\n /** Render the picked-files list below the zone. @default true */\n readonly showList = input(true, { transform: coerceBooleanProperty });\n\n /**\n * Disable interaction. Bound automatically from the field's disabled state\n * when used with `[formField]`.\n *\n * @default false\n */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Refuse changes to the selection while the zone stays focusable and the files\n * still submit. Bound automatically from the field's readonly state when used\n * with `[formField]`.\n *\n * The zone stops opening the picker, a drop is refused and the per-file remove\n * buttons go inert — but the list stays readable, which is the point. No\n * `aria-readonly`: the zone is a `role=\"button\"`, and ARIA does not define the\n * state for that role, so `aria-disabled` would be the only mirror available\n * and it would say the wrong thing.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /** The surrounding `<wr-form-field>`'s error state. @internal */\n protected readonly fieldAria = useFormFieldAria();\n\n /** Primary call-to-action label. Falls back to `fileUpload.browse`. */\n readonly pickLabel = input<string | null>(null);\n\n /** Secondary instruction below the CTA. Falls back to `fileUpload.dropZone`. */\n readonly dropLabel = input<string | null>(null);\n\n /** Drop-zone host aria-label. Falls back to `fileUpload.dropZoneLabel`. */\n readonly dropZoneLabel = input<string | null>(null);\n\n /** Remove-file button aria-label. Falls back to `fileUpload.removeFile`. */\n readonly removeFileLabel = input<string | null>(null);\n\n protected readonly resolvedPick = useI18nText(this.pickLabel, 'fileUpload.browse', 'Click to browse');\n protected readonly resolvedDrop = useI18nText(this.dropLabel, 'fileUpload.dropZone', 'or drop files here');\n protected readonly resolvedDropZone = useI18nText(\n this.dropZoneLabel,\n 'fileUpload.dropZoneLabel',\n 'File upload drop zone — click or drop files'\n );\n protected readonly resolvedRemove = useI18nText(this.removeFileLabel, 'fileUpload.removeFile', 'Remove file');\n\n /** Optional helper text shown below the labels (e.g. accepted formats). */\n readonly helperText = input<string>('');\n\n /**\n * Selected file(s). Bound by `[formField]`, or two-way via `[(value)]`. Shape\n * follows `multiple`: a single `File` (or `null`), or a `File[]` array.\n */\n readonly value = model<File | readonly File[] | null>(null);\n\n /** Emitted when files are rejected for type / size / count reasons. */\n readonly rejected = output<readonly WrFileUploadRejection[]>();\n\n /** Emitted on commit so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n protected readonly picker = viewChild.required<ElementRef<HTMLInputElement>>('picker');\n\n protected readonly files = signal<readonly File[]>([]);\n protected readonly dragging = signal(false);\n\n protected readonly classes = computed(() => {\n const parts = ['wr-file-upload'];\n if (this.dragging()) parts.push('wr-file-upload--dragging');\n if (this.disabled()) parts.push('wr-file-upload--disabled');\n else if (this.readonly()) parts.push('wr-file-upload--readonly');\n return parts.join(' ');\n });\n\n protected readonly formatBytes = formatBytes;\n\n constructor() {\n // Rebuild the internal file list from an external `value` write (mirrors the\n // old `writeValue`). Skipped when the value is merely the echo of an\n // in-component edit, so re-syncing can never clobber a live selection.\n effect(() => {\n const v = this.value();\n untracked(() => {\n // Coerce null/undefined to `[]` — a classic-forms binding can write\n // null, which the old `writeValue(v: … | null)` accepted too.\n const next: readonly File[] = v === null || v === undefined ? [] : Array.isArray(v) ? v : [v as File];\n const current = this.files();\n if (current.length === next.length && current.every((file, i) => file === next[i])) return;\n this.files.set(next);\n });\n });\n }\n\n // Template handlers\n\n protected openPicker(): void {\n if (this.disabled() || this.readonly()) return;\n this.picker().nativeElement.click();\n }\n\n protected onZoneKey(event: KeyboardEvent): void {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n this.openPicker();\n }\n }\n\n protected onPickerChange(event: Event): void {\n const target = event.target as HTMLInputElement;\n if (target.files) this.acceptFiles(Array.from(target.files));\n // Reset so picking the same file twice re-fires `change`.\n target.value = '';\n }\n\n protected onDragEnter(event: DragEvent): void {\n if (this.disabled() || this.readonly()) return;\n event.preventDefault();\n this.dragging.set(true);\n }\n\n protected onDragOver(event: DragEvent): void {\n if (this.disabled() || this.readonly()) return;\n event.preventDefault();\n if (event.dataTransfer) event.dataTransfer.dropEffect = 'copy';\n }\n\n protected onDragLeave(event: DragEvent): void {\n // Only clear when leaving the zone itself, not internal children.\n if (event.currentTarget === event.target) this.dragging.set(false);\n }\n\n protected onDrop(event: DragEvent): void {\n event.preventDefault();\n this.dragging.set(false);\n if (this.disabled() || this.readonly()) return;\n const dropped = event.dataTransfer?.files ? Array.from(event.dataTransfer.files) : [];\n if (dropped.length > 0) this.acceptFiles(dropped);\n }\n\n protected removeAt(index: number): void {\n if (this.disabled() || this.readonly()) return;\n const next = this.files().filter((_, i) => i !== index);\n this.files.set(next);\n this.emit();\n }\n\n // Internals\n\n private acceptFiles(incoming: readonly File[]): void {\n if (this.disabled() || this.readonly()) return;\n const accept = this.accept();\n const maxSize = this.maxSize();\n const rejections: WrFileUploadRejection[] = [];\n const accepted: File[] = [];\n\n for (const file of incoming) {\n const reason = this.reject(file, accept, maxSize);\n if (reason) rejections.push({ file, reason });\n else accepted.push(file);\n }\n\n let next: File[];\n if (this.multiple()) {\n next = [...this.files(), ...accepted];\n const maxFiles = this.maxFiles();\n if (maxFiles > 0 && next.length > maxFiles) {\n const overflow = next.splice(maxFiles);\n for (const file of overflow) rejections.push({ file, reason: 'count' });\n }\n } else {\n // Single mode — last accepted wins, prior selection cleared.\n next = accepted.length > 0 ? [accepted[accepted.length - 1]] : [...this.files()];\n }\n\n this.files.set(next);\n this.touch.emit();\n this.emit();\n if (rejections.length > 0) this.rejected.emit(rejections);\n }\n\n private reject(file: File, accept: string, maxSize: number): WrFileUploadRejectionReason | null {\n if (accept && !matchesAccept(file, accept)) return 'type';\n if (maxSize > 0 && file.size > maxSize) return 'size';\n return null;\n }\n\n private emit(): void {\n const list = this.files();\n if (this.multiple()) {\n this.value.set(list);\n } else {\n this.value.set(list.length > 0 ? list[0] : null);\n }\n }\n}\n","<div\n class=\"wr-file-upload__zone\"\n role=\"button\"\n tabindex=\"0\"\n [attr.aria-label]=\"resolvedDropZone()\"\n [attr.aria-disabled]=\"disabled() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"openPicker()\"\n (keydown)=\"onZoneKey($event)\"\n (dragenter)=\"onDragEnter($event)\"\n (dragover)=\"onDragOver($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (drop)=\"onDrop($event)\"\n>\n <svg class=\"wr-file-upload__icon\" width=\"32\" height=\"32\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path\n d=\"M12 16V4M12 4l-4 4M12 4l4 4M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n <div class=\"wr-file-upload__hint\">\n <strong>{{ resolvedPick() }}</strong>\n <span>{{ resolvedDrop() }}</span>\n @if (helperText()) {\n <small>{{ helperText() }}</small>\n }\n </div>\n</div>\n\n<!--\n The real <input type=\"file\"> is never operated directly — the zone above is\n the control and forwards clicks here, so the input is visually hidden and kept\n OUTSIDE the zone: inside, it nested one interactive element within another\n (the zone is role=\"button\") and put two tab stops where users see one. It is\n positioned absolutely and clipped, so being a sibling changes nothing visually.\n aria-hidden must be paired with tabindex=\"-1\", or hiding a focusable element is\n itself a violation.\n-->\n<input\n #picker\n class=\"wr-file-upload__picker\"\n type=\"file\"\n aria-hidden=\"true\"\n tabindex=\"-1\"\n [attr.accept]=\"accept() || null\"\n [attr.multiple]=\"multiple() ? '' : null\"\n [disabled]=\"disabled() || readonly()\"\n (change)=\"onPickerChange($event)\"\n/>\n\n@if (showList() && files().length > 0) {\n <ul class=\"wr-file-upload__list\">\n @for (file of files(); track $index) {\n <li class=\"wr-file-upload__item\">\n <span class=\"wr-file-upload__name\" [title]=\"file.name\">{{ file.name }}</span>\n <span class=\"wr-file-upload__size\">{{ formatBytes(file.size) }}</span>\n <button\n type=\"button\"\n class=\"wr-file-upload__remove\"\n [attr.aria-label]=\"resolvedRemove()\"\n [disabled]=\"disabled() || readonly()\"\n (click)=\"removeAt($index)\"\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n <path\n d=\"M2 2 L10 10 M10 2 L2 10\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n />\n </svg>\n </button>\n </li>\n }\n </ul>\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;AAKG;AAuBH;AACA,SAAS,WAAW,CAAC,KAAa,EAAA;IAChC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;AAAE,QAAA,OAAO,KAAK;AACvD,IAAA,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;AAC3C,IAAA,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAClF,IAAA,MAAM,CAAC,GAAG,KAAK,GAAG,IAAI,IAAI,CAAC;IAC3B,OAAO,CAAA,EAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK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../projects/lib/file-upload/file-upload.ts","../../../projects/lib/file-upload/file-upload.html","../../../projects/lib/file-upload/ngwr-file-upload.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, coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n type ElementRef,\n LOCALE_ID,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n model,\n output,\n signal,\n untracked,\n viewChild,\n} from '@angular/core';\nimport type { FormValueControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { readI18nText, useI18nFormatter, useI18nText } from 'ngwr/i18n';\n\nimport type { WrFileUploadRejection, WrFileUploadRejectionReason } from './interfaces';\n\n/** Does `file` match the `accept` attribute (extensions or MIME globs)? */\nfunction matchesAccept(file: File, accept: string): boolean {\n if (!accept) return true;\n const tokens = accept\n .split(',')\n .map(t => t.trim().toLowerCase())\n .filter(Boolean);\n if (tokens.length === 0) return true;\n const name = file.name.toLowerCase();\n const mime = file.type.toLowerCase();\n return tokens.some(token => {\n if (token.startsWith('.')) return name.endsWith(token);\n if (token.endsWith('/*')) return mime.startsWith(token.slice(0, -1));\n return mime === token;\n });\n}\n\n/**\n * Drag-and-drop file upload zone. Click to browse, drag-and-drop to add,\n * with an optional file list + remove buttons.\n *\n * A signal-forms native control: it implements\n * `FormValueControl<File | readonly File[] | null>`, so `[formField]` binds\n * straight to its `value` model — no `ControlValueAccessor` in between.\n * `[(value)]` works standalone. The value shape follows `multiple`: a single\n * `File` (or `null`), or a `File[]` array.\n *\n * @example\n * ```html\n * <!-- signal forms -->\n * <wr-file-upload [formField]=\"form.files\" [multiple]=\"true\" accept=\"image/*\" />\n *\n * <!-- standalone two-way binding -->\n * <wr-file-upload [(value)]=\"avatar\" accept=\".png,.jpg\" [maxSize]=\"2 * 1024 * 1024\" />\n * ```\n *\n * @see https://ngwr.dev/reference/components/file-upload\n */\n@Component({\n selector: 'wr-file-upload',\n templateUrl: './file-upload.html',\n encapsulation: ViewEncapsulation.None,\n host: { '[class]': 'classes()' },\n imports: [],\n})\nexport class WrFileUpload implements FormValueControl<File | readonly File[] | null> {\n /** Allow multiple files. Single mode replaces on each add. @default false */\n readonly multiple = input(false, { transform: coerceBooleanProperty });\n\n /** `accept` attribute — comma-separated MIME types or extensions. @default '' */\n readonly accept = input<string>('');\n\n /** Max bytes per file. `0` disables the check. @default 0 */\n readonly maxSize = input(0, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 0)) });\n\n /** Max files (multi mode only). `0` disables the check. @default 0 */\n readonly maxFiles = input(0, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 0)) });\n\n /** Render the picked-files list below the zone. @default true */\n readonly showList = input(true, { transform: coerceBooleanProperty });\n\n /**\n * Disable interaction. Bound automatically from the field's disabled state\n * when used with `[formField]`.\n *\n * @default false\n */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Refuse changes to the selection while the zone stays focusable and the files\n * still submit. Bound automatically from the field's readonly state when used\n * with `[formField]`.\n *\n * The zone stops opening the picker, a drop is refused and the per-file remove\n * buttons go inert — but the list stays readable, which is the point. No\n * `aria-readonly`: the zone is a `role=\"button\"`, and ARIA does not define the\n * state for that role, so `aria-disabled` would be the only mirror available\n * and it would say the wrong thing.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /** The surrounding `<wr-form-field>`'s error state. @internal */\n protected readonly fieldAria = useFormFieldAria();\n\n /** Primary call-to-action label. Falls back to `fileUpload.browse`. */\n readonly pickLabel = input<string | null>(null);\n\n /** Secondary instruction below the CTA. Falls back to `fileUpload.dropZone`. */\n readonly dropLabel = input<string | null>(null);\n\n /** Drop-zone host aria-label. Falls back to `fileUpload.dropZoneLabel`. */\n readonly dropZoneLabel = input<string | null>(null);\n\n /** Remove-file button aria-label. Falls back to `fileUpload.removeFile`. */\n readonly removeFileLabel = input<string | null>(null);\n\n protected readonly resolvedPick = useI18nText(this.pickLabel, 'fileUpload.browse', 'Click to browse');\n protected readonly resolvedDrop = useI18nText(this.dropLabel, 'fileUpload.dropZone', 'or drop files here');\n protected readonly resolvedDropZone = useI18nText(\n this.dropZoneLabel,\n 'fileUpload.dropZoneLabel',\n 'File upload drop zone — click or drop files'\n );\n protected readonly resolvedRemove = useI18nText(this.removeFileLabel, 'fileUpload.removeFile', 'Remove file');\n\n /** Optional helper text shown below the labels (e.g. accepted formats). */\n readonly helperText = input<string>('');\n\n /**\n * Selected file(s). Bound by `[formField]`, or two-way via `[(value)]`. Shape\n * follows `multiple`: a single `File` (or `null`), or a `File[]` array.\n */\n readonly value = model<File | readonly File[] | null>(null);\n\n /** Emitted when files are rejected for type / size / count reasons. */\n readonly rejected = output<readonly WrFileUploadRejection[]>();\n\n /** Emitted on commit so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n protected readonly picker = viewChild.required<ElementRef<HTMLInputElement>>('picker');\n\n protected readonly files = signal<readonly File[]>([]);\n protected readonly dragging = signal(false);\n\n protected readonly classes = computed(() => {\n const parts = ['wr-file-upload'];\n if (this.dragging()) parts.push('wr-file-upload--dragging');\n if (this.disabled()) parts.push('wr-file-upload--disabled');\n else if (this.readonly()) parts.push('wr-file-upload--readonly');\n return parts.join(' ');\n });\n\n /**\n * Human-readable file size (e.g. `1.2 MB`).\n *\n * Every piece of this used to be English and unreachable: a module-level unit\n * table with no catalog key, and `toFixed()`, which writes an ASCII decimal\n * point whatever `LOCALE_ID` says. A Russian page showed translated drop-zone\n * copy above `3.4 KB`. The number now goes through `Intl.NumberFormat` and the\n * unit through the catalog, joined by a template the catalog also owns — so a\n * locale controls the separator, the digits and whether a space sits before\n * the unit.\n *\n * Not a `computed`: it is called per file, with the file's size as its\n * argument. It still re-runs on a locale switch, because the formatters it\n * calls are signals read during the same change detection that renders the row.\n */\n protected formatBytes(bytes: number): string {\n if (!Number.isFinite(bytes) || bytes <= 0) {\n return this.sizeText({ value: this.number(0, 0), unit: this.unitTexts[0]() });\n }\n const i = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), this.unitTexts.length - 1);\n const v = bytes / 1024 ** i;\n const digits = v >= 100 || i === 0 ? 0 : 1;\n return this.sizeText({ value: this.number(v, digits), unit: this.unitTexts[i]() });\n }\n\n /** `{{value}} {{unit}}` — the join, so a locale owns the space too. */\n private readonly sizeText = useI18nFormatter('fileUpload.size', '{{value}} {{unit}}');\n\n /**\n * One resolved signal per binary unit, indexed by the power of 1024 the\n * arithmetic lands on.\n *\n * Spelled out rather than built from a key list: `i18n.spec.ts` reads every\n * catalog key the library asks for out of the SOURCE, by matching a quoted\n * dotted string inside the call, so a key built by interpolation is invisible\n * to it. That spec fails rather than passing quietly, but either way the key\n * would stop being checked.\n */\n private readonly unitTexts = [\n readI18nText('fileUpload.unitByte', 'B'),\n readI18nText('fileUpload.unitKb', 'KB'),\n readI18nText('fileUpload.unitMb', 'MB'),\n readI18nText('fileUpload.unitGb', 'GB'),\n readI18nText('fileUpload.unitTb', 'TB'),\n ] as const;\n\n private readonly locale = inject(LOCALE_ID);\n\n private number(value: number, digits: number): string {\n return new Intl.NumberFormat(this.locale, {\n minimumFractionDigits: digits,\n maximumFractionDigits: digits,\n }).format(value);\n }\n\n constructor() {\n // Rebuild the internal file list from an external `value` write (mirrors the\n // old `writeValue`). Skipped when the value is merely the echo of an\n // in-component edit, so re-syncing can never clobber a live selection.\n effect(() => {\n const v = this.value();\n untracked(() => {\n // Coerce null/undefined to `[]` — a classic-forms binding can write\n // null, which the old `writeValue(v: … | null)` accepted too.\n const next: readonly File[] = v === null || v === undefined ? [] : Array.isArray(v) ? v : [v as File];\n const current = this.files();\n if (current.length === next.length && current.every((file, i) => file === next[i])) return;\n this.files.set(next);\n });\n });\n }\n\n // Template handlers\n\n protected openPicker(): void {\n if (this.disabled() || this.readonly()) return;\n this.picker().nativeElement.click();\n }\n\n protected onZoneKey(event: KeyboardEvent): void {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n this.openPicker();\n }\n }\n\n protected onPickerChange(event: Event): void {\n const target = event.target as HTMLInputElement;\n if (target.files) this.acceptFiles(Array.from(target.files));\n // Reset so picking the same file twice re-fires `change`.\n target.value = '';\n }\n\n protected onDragEnter(event: DragEvent): void {\n if (this.disabled() || this.readonly()) return;\n event.preventDefault();\n this.dragging.set(true);\n }\n\n protected onDragOver(event: DragEvent): void {\n if (this.disabled() || this.readonly()) return;\n event.preventDefault();\n if (event.dataTransfer) event.dataTransfer.dropEffect = 'copy';\n }\n\n protected onDragLeave(event: DragEvent): void {\n // Only clear when leaving the zone itself, not internal children.\n if (event.currentTarget === event.target) this.dragging.set(false);\n }\n\n protected onDrop(event: DragEvent): void {\n event.preventDefault();\n this.dragging.set(false);\n if (this.disabled() || this.readonly()) return;\n const dropped = event.dataTransfer?.files ? Array.from(event.dataTransfer.files) : [];\n if (dropped.length > 0) this.acceptFiles(dropped);\n }\n\n protected removeAt(index: number): void {\n if (this.disabled() || this.readonly()) return;\n const next = this.files().filter((_, i) => i !== index);\n this.files.set(next);\n this.emit();\n }\n\n // Internals\n\n private acceptFiles(incoming: readonly File[]): void {\n if (this.disabled() || this.readonly()) return;\n const accept = this.accept();\n const maxSize = this.maxSize();\n const rejections: WrFileUploadRejection[] = [];\n const accepted: File[] = [];\n\n for (const file of incoming) {\n const reason = this.reject(file, accept, maxSize);\n if (reason) rejections.push({ file, reason });\n else accepted.push(file);\n }\n\n let next: File[];\n if (this.multiple()) {\n next = [...this.files(), ...accepted];\n const maxFiles = this.maxFiles();\n if (maxFiles > 0 && next.length > maxFiles) {\n const overflow = next.splice(maxFiles);\n for (const file of overflow) rejections.push({ file, reason: 'count' });\n }\n } else {\n // Single mode — last accepted wins, prior selection cleared.\n next = accepted.length > 0 ? [accepted[accepted.length - 1]] : [...this.files()];\n }\n\n this.files.set(next);\n this.touch.emit();\n this.emit();\n if (rejections.length > 0) this.rejected.emit(rejections);\n }\n\n private reject(file: File, accept: string, maxSize: number): WrFileUploadRejectionReason | null {\n if (accept && !matchesAccept(file, accept)) return 'type';\n if (maxSize > 0 && file.size > maxSize) return 'size';\n return null;\n }\n\n private emit(): void {\n const list = this.files();\n if (this.multiple()) {\n this.value.set(list);\n } else {\n this.value.set(list.length > 0 ? list[0] : null);\n }\n }\n}\n","<div\n class=\"wr-file-upload__zone\"\n role=\"button\"\n tabindex=\"0\"\n [attr.aria-label]=\"resolvedDropZone()\"\n [attr.aria-disabled]=\"disabled() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"openPicker()\"\n (keydown)=\"onZoneKey($event)\"\n (dragenter)=\"onDragEnter($event)\"\n (dragover)=\"onDragOver($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (drop)=\"onDrop($event)\"\n>\n <svg class=\"wr-file-upload__icon\" width=\"32\" height=\"32\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path\n d=\"M12 16V4M12 4l-4 4M12 4l4 4M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n <div class=\"wr-file-upload__hint\">\n <strong>{{ resolvedPick() }}</strong>\n <span>{{ resolvedDrop() }}</span>\n @if (helperText()) {\n <small>{{ helperText() }}</small>\n }\n </div>\n</div>\n\n<!--\n The real <input type=\"file\"> is never operated directly — the zone above is\n the control and forwards clicks here, so the input is visually hidden and kept\n OUTSIDE the zone: inside, it nested one interactive element within another\n (the zone is role=\"button\") and put two tab stops where users see one. It is\n positioned absolutely and clipped, so being a sibling changes nothing visually.\n aria-hidden must be paired with tabindex=\"-1\", or hiding a focusable element is\n itself a violation.\n-->\n<input\n #picker\n class=\"wr-file-upload__picker\"\n type=\"file\"\n aria-hidden=\"true\"\n tabindex=\"-1\"\n [attr.accept]=\"accept() || null\"\n [attr.multiple]=\"multiple() ? '' : null\"\n [disabled]=\"disabled() || readonly()\"\n (change)=\"onPickerChange($event)\"\n/>\n\n@if (showList() && files().length > 0) {\n <ul class=\"wr-file-upload__list\">\n @for (file of files(); track $index) {\n <li class=\"wr-file-upload__item\">\n <span class=\"wr-file-upload__name\" [title]=\"file.name\">{{ file.name }}</span>\n <span class=\"wr-file-upload__size\">{{ formatBytes(file.size) }}</span>\n <button\n type=\"button\"\n class=\"wr-file-upload__remove\"\n [attr.aria-label]=\"resolvedRemove()\"\n [disabled]=\"disabled() || readonly()\"\n (click)=\"removeAt($index)\"\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n <path\n d=\"M2 2 L10 10 M10 2 L2 10\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n />\n </svg>\n </button>\n </li>\n }\n </ul>\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;AAKG;AAyBH;AACA,SAAS,aAAa,CAAC,IAAU,EAAE,MAAc,EAAA;AAC/C,IAAA,IAAI,CAAC,MAAM;AAAE,QAAA,OAAO,IAAI;IACxB,MAAM,MAAM,GAAG;SACZ,KAAK,CAAC,GAAG;AACT,SAAA,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE;SAC/B,MAAM,CAAC,OAAO,CAAC;AAClB,IAAA,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;IACpC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;IACpC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;AACpC,IAAA,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,IAAG;AACzB,QAAA,IAAI,KAA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Q,EAAE,EAAE;AACnB,YAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;QACtB;aAAO;YACL,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QAClD;IACF;uGAvQW,YAAY,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAZ,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,YAAY,4+DC3EzB,8xFAkFA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA;;2FDPa,YAAY,EAAA,UAAA,EAAA,CAAA;kBAPxB,SAAS;+BACE,gBAAgB,EAAA,aAAA,EAEX,iBAAiB,CAAC,IAAI,EAAA,IAAA,EAC/B,EAAE,SAAS,EAAE,WAAW,EAAE,EAAA,OAAA,EACvB,EAAE,EAAA,QAAA,EAAA,8xFAAA,EAAA;k+CAgFkE,QAAQ,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AEzJvF;;AAEG;;;;"}
@@ -130,8 +130,9 @@ class WrFormFieldHarness extends ContentContainerComponentHarness {
130
130
  *
131
131
  * `null` does not mean the consumer set no hint: the error block takes the
132
132
  * hint's slot outright, so a field with a visible message has no hint in the DOM
133
- * at all. Note also that the hint carries no id and is NOT referenced by the
134
- * control's `aria-describedby` — see {@link getAnnouncedDescription}.
133
+ * at all — which is also why the hint's id stops being published at the same
134
+ * moment. Whether the CONTROL announces it is a separate question, and one this
135
+ * harness answers through {@link getAnnouncedDescription}.
135
136
  */
136
137
  async getHint() {
137
138
  const hint = await this.locatorForOptional(HINT)();
@@ -251,11 +252,16 @@ class WrFormFieldHarness extends ContentContainerComponentHarness {
251
252
  /**
252
253
  * The ids the projected control names in `aria-describedby`, in order.
253
254
  *
254
- * The field points this at the error block and nothing else — the hint has no
255
- * id — so an empty list while a hint is showing is correct rather than a bug.
256
- * That is not an oversight to fix from a harness either: `[wrInput]` derives
257
- * `aria-invalid` from the same signal, so describing the hint would announce
258
- * every hinted field as invalid.
255
+ * Which id that is depends on the CONTROL, not on the field, and the answer is
256
+ * worth knowing before reading a result. A control that composes the pair with
257
+ * `useFormFieldAria()` names the error block while one is showing and the hint
258
+ * otherwise. A control that reads the field's `describedBy` on its own — the
259
+ * `[wrInput]` directive, `wr-segmented` and `wr-slider` — names the error block
260
+ * and nothing else, so an empty list beside a visible hint is that control's
261
+ * answer rather than a broken field.
262
+ *
263
+ * The two are separate because folding the hint into the one signal announced
264
+ * every hinted field as invalid: those three derive `aria-invalid` from it.
259
265
  */
260
266
  async getDescribedByIds() {
261
267
  const value = await (await this.control()).getAttribute('aria-describedby');
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-form-testing.mjs","sources":["../../../projects/lib/form/testing/wr-form-field-harness.ts","../../../projects/lib/form/testing/wr-form-item-harness.ts","../../../projects/lib/form/testing/ngwr-form-testing.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 {\n ContentContainerComponentHarness,\n type HarnessLoader,\n HarnessPredicate,\n type TestElement,\n} from '@angular/cdk/testing';\n\nimport type { WrFormFieldError, WrFormFieldHarnessFilters } from './interfaces';\n\n/**\n * The messages this field is showing, or the ones it is holding back.\n *\n * Anchored with `:scope >` because the field's own parts are all direct children\n * of its host: a `<wr-form-field>` nested in another one's control slot otherwise\n * has its error block matched by the OUTER field's query too, and the outer\n * answers with a sentence that is not its own.\n */\nconst MESSAGE = ':scope > .wr-form-field__errors > .wr-form-field__error';\nconst VISIBLE = `${MESSAGE}:not(.wr-form-field__error--hidden)`;\nconst SUPPRESSED = `${MESSAGE}.wr-form-field__error--hidden`;\n\n/** The control slot — every native control lookup is scoped through this. */\nconst SLOT = ':scope > .wr-form-field__control';\n\n/** The label and the hint, anchored for the same reason as {@link MESSAGE}. */\nconst LABEL = ':scope > .wr-form-field__label';\nconst HINT = ':scope > .wr-form-field__hint';\n\n/**\n * Test harness for `<wr-form-field>` — the label + control + hint + validation\n * copy block.\n *\n * The field's real job is the COPY CONTRACT, and this harness is built around it.\n * A message reaches the DOM one of two ways, and they are distinguishable there:\n *\n * - a `<wr-form-error key=\"…\">` the consumer wrote, which renders only while that\n * key is failing — the others stay in the DOM carrying\n * `wr-form-field__error--hidden`, which is why {@link getErrors} filters and\n * {@link getSuppressedErrorKeys} exists. A raw `.wr-form-error` query answers\n * with the held-back copy too, and reads green on the wrong sentence.\n * - a message the field RESOLVED for an error no markup claimed:\n * `provideWrFormErrors()`, then the `ngwr/i18n` `validation.*` catalog, then a\n * built-in English sentence. All three render the identical `<div>`, so\n * `source` is `'resolved'` for every one of them — the DOM genuinely cannot say\n * which link answered, and this harness does not pretend otherwise.\n *\n * Nothing renders at all until the projected control is touched or dirty, so a\n * spec has to reach that gate first: {@link blurControl} is the shortest way\n * (blur is what marks a bound control touched), and typing through the control's\n * own harness is the other.\n *\n * The field publishes no `aria-label` anywhere. Its `<label for>` pointing at the\n * projected control IS the naming story, and a control that does not adopt the\n * id leaves the field silently unlabelled — {@link isLabelLinkedToControl} is\n * what catches that. The other half is the reverse wiring: the control reads back\n * `aria-describedby` and `aria-invalid`, which is the only reason a screen reader\n * hears the message ({@link getAnnouncedDescription}).\n *\n * Harnesses loaded through this one resolve INSIDE the control slot, so the\n * control's own harness composes without a selector:\n *\n * @example\n * ```ts\n * const email = await loader.getHarness(WrFormFieldHarness.with({ label: 'Email' }));\n *\n * await (await email.getHarness(WrInputHarness)).setValue('nope');\n * await email.blurControl();\n *\n * expect(await email.getErrorTexts()).toEqual([\"That isn't a valid email.\"]);\n * expect(await email.getAnnouncedDescription()).toBe(\"That isn't a valid email.\");\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrFormFieldHarness extends ContentContainerComponentHarness {\n static hostSelector = 'wr-form-field';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrFormFieldHarnessFilters = {}): HarnessPredicate<WrFormFieldHarness> {\n return new HarnessPredicate(WrFormFieldHarness, options)\n .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label))\n .addOption('hint', options.hint, (harness, hint) => HarnessPredicate.stringMatches(harness.getHint(), hint))\n .addOption('required', options.required, async (harness, required) => (await harness.isRequired()) === required)\n .addOption('invalid', options.invalid, async (harness, invalid) => (await harness.isInvalid()) === invalid)\n .addOption('errorText', options.errorText, async (harness, text) => {\n for (const shown of await harness.getErrorTexts()) {\n if (await HarnessPredicate.stringMatches(shown, text)) return true;\n }\n return false;\n });\n }\n\n /**\n * The label text, or `null` when the field renders no label.\n *\n * The `*` and `(optional)` markers ride INSIDE the `<label>`, so they are\n * excluded here — otherwise this answers `'Email *'` and every equality\n * assertion has to know which marker the field happens to carry.\n *\n * `null` is not \"the consumer forgot\": `label=\"\"` renders no `<label>` element\n * at all, which also means there is nothing naming the control.\n */\n async getLabel(): Promise<string | null> {\n const label = await this.labelElement();\n return label ? label.text({ exclude: '.wr-form-field__required, .wr-form-field__optional' }) : null;\n }\n\n /**\n * Whether the field is marked required.\n *\n * Read from the host's `wr-form-field--required` modifier, not from the `*`:\n * that marker is `aria-hidden=\"true\"` decoration, and it is only rendered when\n * there is a label to hang it on — the modifier is set either way. Note what\n * this does NOT mean: the field forwards nothing to the projected control, so\n * `required` here is the field's own visual state. What announces the constraint\n * is the forms layer — a `required` rule writes the native `required` attribute\n * onto the control — and the two are set independently, so a field can carry the\n * `*` with no validator behind it.\n */\n async isRequired(): Promise<boolean> {\n return (await this.host()).hasClass('wr-form-field--required');\n }\n\n /**\n * Whether the label carries the `(optional)` marker.\n *\n * Read from the marker itself, because — unlike `required` — `optional` sets no\n * host modifier. It is also the marker a screen reader actually reads: this one\n * is not `aria-hidden`. `required` wins when both inputs are set, so a required\n * field is never optional here however it was bound.\n */\n async isOptional(): Promise<boolean> {\n return (await this.locatorForOptional(`${LABEL} .wr-form-field__optional`)()) !== null;\n }\n\n /**\n * The hint text, or `null` when none is showing.\n *\n * `null` does not mean the consumer set no hint: the error block takes the\n * hint's slot outright, so a field with a visible message has no hint in the DOM\n * at all. Note also that the hint carries no id and is NOT referenced by the\n * control's `aria-describedby` — see {@link getAnnouncedDescription}.\n */\n async getHint(): Promise<string | null> {\n const hint = await this.locatorForOptional(HINT)();\n return hint ? hint.text() : null;\n }\n\n /**\n * Whether the field is painting the error state.\n *\n * The host's `wr-form-field--invalid` modifier — what the user sees. The\n * screen-reader half lives on the control as `aria-invalid`, and the two are\n * separate elements rather than two readings of one: {@link isControlInvalid}.\n */\n async isInvalid(): Promise<boolean> {\n return (await this.host()).hasClass('wr-form-field--invalid');\n }\n\n /**\n * Every message the field is SHOWING, in DOM order — the consumer's markup\n * first, then whatever the field resolved for the keys that markup left over.\n *\n * Only THIS field's own error block is read — its direct child, holding its\n * direct children — so a `<wr-form-field>` nested in another one's control slot\n * contributes nothing to the outer field's answer. Without that anchoring the\n * outer field reports the inner one's copy as its own, which is the same class\n * of break as reading a sibling field's messages.\n */\n async getErrors(): Promise<WrFormFieldError[]> {\n const elements = await this.locatorForAll(VISIBLE)();\n\n return Promise.all(\n elements.map(async element => ({\n key: await element.getAttribute('data-key'),\n text: await element.text(),\n // The consumer's copy is its own element; a resolved message is a plain\n // `<div>` the field stamped out. That tag name is the whole of what the\n // DOM knows about provenance.\n source:\n (await element.getProperty<string>('tagName')).toLowerCase() === 'wr-form-error'\n ? ('projected' as const)\n : ('resolved' as const),\n }))\n );\n }\n\n /** The visible messages as text, in DOM order. */\n async getErrorTexts(): Promise<string[]> {\n return (await this.getErrors()).map(error => error.text);\n }\n\n /**\n * The visible message for one validator key.\n *\n * Throws rather than answering `null` when that key has no visible message: the\n * two reasons are worth failing on and the message names both — the key is not\n * in error at all, or its copy resolved to nothing.\n */\n async getErrorText(key: string): Promise<string> {\n const errors = await this.getErrors();\n const match = errors.find(error => error.key === key);\n if (match) return match.text;\n\n const shown = errors.map(error => error.key ?? '(keyless)');\n const detail =\n shown.length > 0\n ? `Showing: ${shown.join(', ')}.`\n : 'The field is showing nothing — it is either valid, or the control is still untouched and pristine.';\n\n throw new Error(\n `WrFormFieldHarness.getErrorText(${JSON.stringify(key)}): no visible message for that key. ${detail}`\n );\n }\n\n /**\n * The keys of the projected messages the field is holding BACK — copy that is in\n * the DOM but hidden because its key is not among the failing ones.\n *\n * This is the gating contract seen from outside, and the reason a spec must not\n * query `.wr-form-error` itself: the suppressed sentences sit right next to the\n * live one.\n */\n async getSuppressedErrorKeys(): Promise<string[]> {\n const hidden = await this.locatorForAll(SUPPRESSED)();\n const keys = await Promise.all(hidden.map(element => element.getAttribute('data-key')));\n return keys.filter((key): key is string => key !== null);\n }\n\n /**\n * Whether the field is announcing an error it has no words for: invalid, with an\n * error block that renders nothing.\n *\n * Worth a named check because it is invisible in review — the field still goes\n * red, and `aria-describedby` still points at the block, so a screen reader is\n * sent to an empty element. It happens when no link in the copy chain answers\n * the key (`[autoErrors]=\"false\"` with no markup, or a key nothing has copy for\n * — Signal Forms reports `minLength`, while the chain only knows Angular's\n * lowercase `minlength`).\n */\n async hasEmptyErrorBlock(): Promise<boolean> {\n if (!(await this.isInvalid())) return false;\n return (await this.getErrors()).every(error => error.text.length === 0);\n }\n\n /** The id the `<label for>` points at, or `null` when there is no label. */\n async getLabelFor(): Promise<string | null> {\n const label = await this.labelElement();\n return label ? label.getAttribute('for') : null;\n }\n\n /** The `id` the projected control actually answers to, or `null` when it has none. */\n async getControlId(): Promise<string | null> {\n return (await this.control()).getAttribute('id');\n }\n\n /**\n * Whether the `<label for>` resolves to an element inside THIS field's control\n * slot — the only thing that makes the field nameable.\n *\n * Scoped to the slot on purpose: ids are document-global, so a check that went\n * through `getElementById` would also pass for a label pointing at a DIFFERENT\n * field's control, and for a control that has been moved out of the field\n * entirely. The failure this catches is quiet — a projected control that does\n * not adopt the field's `controlId` (a bare `<input>` with no `[wrInput]`, say)\n * leaves a `for` naming nothing, the field renders exactly as it always did, and\n * nothing is labelled.\n */\n async isLabelLinkedToControl(): Promise<boolean> {\n const id = await this.getLabelFor();\n if (!id) return false;\n return (await this.locatorForOptional(`${SLOT} [id=\"${id}\"]`)()) !== null;\n }\n\n /**\n * The ids the projected control names in `aria-describedby`, in order.\n *\n * The field points this at the error block and nothing else — the hint has no\n * id — so an empty list while a hint is showing is correct rather than a bug.\n * That is not an oversight to fix from a harness either: `[wrInput]` derives\n * `aria-invalid` from the same signal, so describing the hint would announce\n * every hinted field as invalid.\n */\n async getDescribedByIds(): Promise<string[]> {\n const value = await (await this.control()).getAttribute('aria-describedby');\n return value ? value.split(/\\s+/).filter(Boolean) : [];\n }\n\n /**\n * What a screen reader reads as the control's description: the text of the\n * elements `aria-describedby` names, joined by a space. `null` when the control\n * describes nothing.\n *\n * `''` is a real answer and the interesting one — the reference resolves to an\n * element with no text in it, which is {@link hasEmptyErrorBlock}. Ids naming\n * something outside this field are skipped (a consumer's own description is out\n * of a field harness's reach); an id naming nothing anywhere throws, because a\n * dangling reference is the bug this method exists to surface.\n *\n * Suppressed copy is excluded explicitly rather than left to CSS: a browser drops\n * `display: none` subtrees from the accessibility tree, but a unit test loads no\n * stylesheet at all, so the referenced block's raw `textContent` runs every\n * held-back sentence together with the live one and this would answer with copy\n * nobody can read.\n */\n async getAnnouncedDescription(): Promise<string | null> {\n const ids = await this.getDescribedByIds();\n if (ids.length === 0) return null;\n\n const parts: string[] = [];\n for (const id of ids) {\n const inField = await this.locatorForOptional(`[id=\"${id}\"]`)();\n if (inField) {\n parts.push(await inField.text({ exclude: '.wr-form-field__error--hidden' }));\n continue;\n }\n if ((await this.documentRootLocatorFactory().locatorForOptional(`[id=\"${id}\"]`)()) === null) {\n throw new Error(\n `WrFormFieldHarness.getAnnouncedDescription(): the control's aria-describedby names \"${id}\", which is not ` +\n 'an element anywhere in the document — a screen reader is pointed at nothing.'\n );\n }\n }\n\n return parts.join(' ');\n }\n\n /**\n * Whether the control announces itself invalid.\n *\n * `aria-invalid` on the projected control, which is what assistive technology\n * is told — the field's own red styling is {@link isInvalid}. Both are here\n * because they live on different elements and travel in opposite directions: the\n * field renders the message, the control reads back that there is one. A field\n * that paints red while the control says nothing is a real (and silent) break.\n */\n async isControlInvalid(): Promise<boolean> {\n return (await (await this.control()).getAttribute('aria-invalid')) === 'true';\n }\n\n /** Move focus to the projected control. */\n async focusControl(): Promise<void> {\n return (await this.control()).focus();\n }\n\n /**\n * Blur the projected control, which is usually how a spec gets any message to\n * appear at all: a bound control marks itself touched on blur, and the field\n * renders nothing while the control is untouched AND pristine.\n */\n async blurControl(): Promise<void> {\n return (await this.control()).blur();\n }\n\n /** The rendered `<label>`, or `null` when `label` is empty. */\n private async labelElement(): Promise<TestElement | null> {\n return this.locatorForOptional(LABEL)();\n }\n\n /**\n * The control this field wraps.\n *\n * The element the label points at, when that resolves inside the slot — which\n * covers a control nested inside a component (`<wr-input-number>`'s own\n * `<input>` adopts the field's id, so the label names it, not the component\n * element). Otherwise the first native control in the slot, so a field with no\n * label still answers.\n */\n private async control(): Promise<TestElement> {\n const id = await this.getLabelFor();\n if (id) {\n const labelled = await this.locatorForOptional(`${SLOT} [id=\"${id}\"]`)();\n if (labelled) return labelled;\n }\n\n const native = await this.locatorForOptional(`${SLOT} input, ${SLOT} select, ${SLOT} textarea`)();\n if (native) return native;\n\n throw new Error(\n 'WrFormFieldHarness: this field wraps no control. Nothing in `.wr-form-field__control` answers to the ' +\n \"label's `for`, and there is no <input> / <select> / <textarea> to fall back to.\"\n );\n }\n\n /**\n * The content loader every `HarnessLoader` method on this class runs through,\n * scoped to the control slot.\n *\n * So `field.getHarness(WrInputHarness)` finds the control this field wraps and\n * not a sibling field's — the loader is per-instance by construction, which is\n * what a document-wide query for the same selector would lose.\n */\n protected override async getRootHarnessLoader(): Promise<HarnessLoader> {\n return this.locatorFactory.harnessLoaderFor(SLOT);\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 { ContentContainerComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport type { WrFormItemHarnessFilters } from './interfaces';\n\n/**\n * Test harness for `<wr-form-item>` — the layout-only field row.\n *\n * Deliberately a much smaller surface than {@link WrFormFieldHarness}, because\n * the component is a much smaller thing: it discovers no control, generates no\n * id, wires no `for` and no `aria-describedby`, and reads no validity. It paints\n * the error state it is TOLD to paint, via `[hasError]`, and everything else in\n * it belongs to the consumer — including the `<label>`, which is named here\n * rather than linked (nothing wires it; the consumer's own `for` is the only\n * thing that can).\n *\n * The one behavioural trap it is worth a harness for: a `<wr-form-error>` inside\n * a form-item renders UNCONDITIONALLY. `key` has no effect at all — the gating\n * lives in the surrounding `<wr-form-field>`, and with no field to ask, every\n * message decides it is the one to show. Markup moved from a field into an item\n * therefore starts printing every sentence at once, and {@link getErrorTexts}\n * is what says so.\n *\n * @example\n * ```ts\n * const item = await loader.getHarness(WrFormItemHarness.with({ label: 'Email' }));\n *\n * expect(await item.isInvalid()).toBe(true);\n * expect(await item.getErrorTexts()).toEqual(['Invalid email']);\n * await (await item.getHarness(WrInputHarness)).setValue('ada@example.test');\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrFormItemHarness extends ContentContainerComponentHarness {\n static hostSelector = 'wr-form-item';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrFormItemHarnessFilters = {}): HarnessPredicate<WrFormItemHarness> {\n return new HarnessPredicate(WrFormItemHarness, options)\n .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label))\n .addOption('invalid', options.invalid, async (harness, invalid) => (await harness.isInvalid()) === invalid)\n .addOption('errorText', options.errorText, async (harness, text) => {\n for (const shown of await harness.getErrorTexts()) {\n if (await HarnessPredicate.stringMatches(shown, text)) return true;\n }\n return false;\n });\n }\n\n /**\n * The text of the item's own `<label>` child, or `null` when it has none.\n *\n * Direct child only — that is what the item styles (`> label` is what turns red\n * in the error state), so a label nested deeper is the consumer's own business\n * and answering with it would describe something the item never touches.\n */\n async getLabel(): Promise<string | null> {\n const label = await this.locatorForOptional(':scope > label')();\n return label ? label.text() : null;\n }\n\n /**\n * Whether the item is painting the error state.\n *\n * The `wr-form-item--error` modifier, which is driven entirely by the\n * consumer's `[hasError]` — the item runs no validity check of its own, so this\n * answers what it was told, not what the control thinks.\n */\n async isInvalid(): Promise<boolean> {\n return (await this.host()).hasClass('wr-form-item--error');\n }\n\n /**\n * Every `<wr-form-error>` in the item, as text, in DOM order.\n *\n * All of them: nothing is gated here, `key` or no `key`. Nothing is ever\n * hidden either, so there is no suppressed-message counterpart to this — see\n * the class docs.\n */\n async getErrorTexts(): Promise<string[]> {\n const errors = await this.locatorForAll('wr-form-error')();\n return Promise.all(errors.map(error => error.text()));\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;;;;;AAKG;AAWH;;;;;;;AAOG;AACH,MAAM,OAAO,GAAG,yDAAyD;AACzE,MAAM,OAAO,GAAG,CAAA,EAAG,OAAO,qCAAqC;AAC/D,MAAM,UAAU,GAAG,CAAA,EAAG,OAAO,+BAA+B;AAE5D;AACA,MAAM,IAAI,GAAG,kCAAkC;AAE/C;AACA,MAAM,KAAK,GAAG,gCAAgC;AAC9C,MAAM,IAAI,GAAG,+BAA+B;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CG;AACG,MAAO,kBAAmB,SAAQ,gCAAgC,CAAA;AACtE,IAAA,OAAO,YAAY,GAAG,eAAe;;AAGrC,I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AAK,IAAI,MAAM,OAAO,CAAC,aAAa,EAAE,EAAE;gBACjD,IAAI,MAAM,gBAAgB,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC;AAAE,oBAAA,OAAO,IAAI;YACpE;AACA,YAAA,OAAO,KAAK;AACd,QAAA,CAAC,CAAC;IACN;AAEA;;;;;;AAMG;AACH,IAAA,MAAM,QAAQ,GAAA;QACZ,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,EAAE;AAC/D,QAAA,OAAO,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,GAAG,IAAI;IACpC;AAEA;;;;;;AAMG;AACH,IAAA,MAAM,SAAS,GAAA;AACb,QAAA,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,qBAAqB,CAAC;IAC5D;AAEA;;;;;;AAMG;AACH,IAAA,MAAM,aAAa,GAAA;QACjB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,EAAE;AAC1D,QAAA,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACvD;;;ACzFF;;AAEG;;;;"}
1
+ {"version":3,"file":"ngwr-form-testing.mjs","sources":["../../../projects/lib/form/testing/wr-form-field-harness.ts","../../../projects/lib/form/testing/wr-form-item-harness.ts","../../../projects/lib/form/testing/ngwr-form-testing.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 {\n ContentContainerComponentHarness,\n type HarnessLoader,\n HarnessPredicate,\n type TestElement,\n} from '@angular/cdk/testing';\n\nimport type { WrFormFieldError, WrFormFieldHarnessFilters } from './interfaces';\n\n/**\n * The messages this field is showing, or the ones it is holding back.\n *\n * Anchored with `:scope >` because the field's own parts are all direct children\n * of its host: a `<wr-form-field>` nested in another one's control slot otherwise\n * has its error block matched by the OUTER field's query too, and the outer\n * answers with a sentence that is not its own.\n */\nconst MESSAGE = ':scope > .wr-form-field__errors > .wr-form-field__error';\nconst VISIBLE = `${MESSAGE}:not(.wr-form-field__error--hidden)`;\nconst SUPPRESSED = `${MESSAGE}.wr-form-field__error--hidden`;\n\n/** The control slot — every native control lookup is scoped through this. */\nconst SLOT = ':scope > .wr-form-field__control';\n\n/** The label and the hint, anchored for the same reason as {@link MESSAGE}. */\nconst LABEL = ':scope > .wr-form-field__label';\nconst HINT = ':scope > .wr-form-field__hint';\n\n/**\n * Test harness for `<wr-form-field>` — the label + control + hint + validation\n * copy block.\n *\n * The field's real job is the COPY CONTRACT, and this harness is built around it.\n * A message reaches the DOM one of two ways, and they are distinguishable there:\n *\n * - a `<wr-form-error key=\"…\">` the consumer wrote, which renders only while that\n * key is failing — the others stay in the DOM carrying\n * `wr-form-field__error--hidden`, which is why {@link getErrors} filters and\n * {@link getSuppressedErrorKeys} exists. A raw `.wr-form-error` query answers\n * with the held-back copy too, and reads green on the wrong sentence.\n * - a message the field RESOLVED for an error no markup claimed:\n * `provideWrFormErrors()`, then the `ngwr/i18n` `validation.*` catalog, then a\n * built-in English sentence. All three render the identical `<div>`, so\n * `source` is `'resolved'` for every one of them — the DOM genuinely cannot say\n * which link answered, and this harness does not pretend otherwise.\n *\n * Nothing renders at all until the projected control is touched or dirty, so a\n * spec has to reach that gate first: {@link blurControl} is the shortest way\n * (blur is what marks a bound control touched), and typing through the control's\n * own harness is the other.\n *\n * The field publishes no `aria-label` anywhere. Its `<label for>` pointing at the\n * projected control IS the naming story, and a control that does not adopt the\n * id leaves the field silently unlabelled — {@link isLabelLinkedToControl} is\n * what catches that. The other half is the reverse wiring: the control reads back\n * `aria-describedby` and `aria-invalid`, which is the only reason a screen reader\n * hears the message ({@link getAnnouncedDescription}).\n *\n * Harnesses loaded through this one resolve INSIDE the control slot, so the\n * control's own harness composes without a selector:\n *\n * @example\n * ```ts\n * const email = await loader.getHarness(WrFormFieldHarness.with({ label: 'Email' }));\n *\n * await (await email.getHarness(WrInputHarness)).setValue('nope');\n * await email.blurControl();\n *\n * expect(await email.getErrorTexts()).toEqual([\"That isn't a valid email.\"]);\n * expect(await email.getAnnouncedDescription()).toBe(\"That isn't a valid email.\");\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrFormFieldHarness extends ContentContainerComponentHarness {\n static hostSelector = 'wr-form-field';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrFormFieldHarnessFilters = {}): HarnessPredicate<WrFormFieldHarness> {\n return new HarnessPredicate(WrFormFieldHarness, options)\n .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label))\n .addOption('hint', options.hint, (harness, hint) => HarnessPredicate.stringMatches(harness.getHint(), hint))\n .addOption('required', options.required, async (harness, required) => (await harness.isRequired()) === required)\n .addOption('invalid', options.invalid, async (harness, invalid) => (await harness.isInvalid()) === invalid)\n .addOption('errorText', options.errorText, async (harness, text) => {\n for (const shown of await harness.getErrorTexts()) {\n if (await HarnessPredicate.stringMatches(shown, text)) return true;\n }\n return false;\n });\n }\n\n /**\n * The label text, or `null` when the field renders no label.\n *\n * The `*` and `(optional)` markers ride INSIDE the `<label>`, so they are\n * excluded here — otherwise this answers `'Email *'` and every equality\n * assertion has to know which marker the field happens to carry.\n *\n * `null` is not \"the consumer forgot\": `label=\"\"` renders no `<label>` element\n * at all, which also means there is nothing naming the control.\n */\n async getLabel(): Promise<string | null> {\n const label = await this.labelElement();\n return label ? label.text({ exclude: '.wr-form-field__required, .wr-form-field__optional' }) : null;\n }\n\n /**\n * Whether the field is marked required.\n *\n * Read from the host's `wr-form-field--required` modifier, not from the `*`:\n * that marker is `aria-hidden=\"true\"` decoration, and it is only rendered when\n * there is a label to hang it on — the modifier is set either way. Note what\n * this does NOT mean: the field forwards nothing to the projected control, so\n * `required` here is the field's own visual state. What announces the constraint\n * is the forms layer — a `required` rule writes the native `required` attribute\n * onto the control — and the two are set independently, so a field can carry the\n * `*` with no validator behind it.\n */\n async isRequired(): Promise<boolean> {\n return (await this.host()).hasClass('wr-form-field--required');\n }\n\n /**\n * Whether the label carries the `(optional)` marker.\n *\n * Read from the marker itself, because — unlike `required` — `optional` sets no\n * host modifier. It is also the marker a screen reader actually reads: this one\n * is not `aria-hidden`. `required` wins when both inputs are set, so a required\n * field is never optional here however it was bound.\n */\n async isOptional(): Promise<boolean> {\n return (await this.locatorForOptional(`${LABEL} .wr-form-field__optional`)()) !== null;\n }\n\n /**\n * The hint text, or `null` when none is showing.\n *\n * `null` does not mean the consumer set no hint: the error block takes the\n * hint's slot outright, so a field with a visible message has no hint in the DOM\n * at all — which is also why the hint's id stops being published at the same\n * moment. Whether the CONTROL announces it is a separate question, and one this\n * harness answers through {@link getAnnouncedDescription}.\n */\n async getHint(): Promise<string | null> {\n const hint = await this.locatorForOptional(HINT)();\n return hint ? hint.text() : null;\n }\n\n /**\n * Whether the field is painting the error state.\n *\n * The host's `wr-form-field--invalid` modifier — what the user sees. The\n * screen-reader half lives on the control as `aria-invalid`, and the two are\n * separate elements rather than two readings of one: {@link isControlInvalid}.\n */\n async isInvalid(): Promise<boolean> {\n return (await this.host()).hasClass('wr-form-field--invalid');\n }\n\n /**\n * Every message the field is SHOWING, in DOM order — the consumer's markup\n * first, then whatever the field resolved for the keys that markup left over.\n *\n * Only THIS field's own error block is read — its direct child, holding its\n * direct children — so a `<wr-form-field>` nested in another one's control slot\n * contributes nothing to the outer field's answer. Without that anchoring the\n * outer field reports the inner one's copy as its own, which is the same class\n * of break as reading a sibling field's messages.\n */\n async getErrors(): Promise<WrFormFieldError[]> {\n const elements = await this.locatorForAll(VISIBLE)();\n\n return Promise.all(\n elements.map(async element => ({\n key: await element.getAttribute('data-key'),\n text: await element.text(),\n // The consumer's copy is its own element; a resolved message is a plain\n // `<div>` the field stamped out. That tag name is the whole of what the\n // DOM knows about provenance.\n source:\n (await element.getProperty<string>('tagName')).toLowerCase() === 'wr-form-error'\n ? ('projected' as const)\n : ('resolved' as const),\n }))\n );\n }\n\n /** The visible messages as text, in DOM order. */\n async getErrorTexts(): Promise<string[]> {\n return (await this.getErrors()).map(error => error.text);\n }\n\n /**\n * The visible message for one validator key.\n *\n * Throws rather than answering `null` when that key has no visible message: the\n * two reasons are worth failing on and the message names both — the key is not\n * in error at all, or its copy resolved to nothing.\n */\n async getErrorText(key: string): Promise<string> {\n const errors = await this.getErrors();\n const match = errors.find(error => error.key === key);\n if (match) return match.text;\n\n const shown = errors.map(error => error.key ?? '(keyless)');\n const detail =\n shown.length > 0\n ? `Showing: ${shown.join(', ')}.`\n : 'The field is showing nothing — it is either valid, or the control is still untouched and pristine.';\n\n throw new Error(\n `WrFormFieldHarness.getErrorText(${JSON.stringify(key)}): no visible message for that key. ${detail}`\n );\n }\n\n /**\n * The keys of the projected messages the field is holding BACK — copy that is in\n * the DOM but hidden because its key is not among the failing ones.\n *\n * This is the gating contract seen from outside, and the reason a spec must not\n * query `.wr-form-error` itself: the suppressed sentences sit right next to the\n * live one.\n */\n async getSuppressedErrorKeys(): Promise<string[]> {\n const hidden = await this.locatorForAll(SUPPRESSED)();\n const keys = await Promise.all(hidden.map(element => element.getAttribute('data-key')));\n return keys.filter((key): key is string => key !== null);\n }\n\n /**\n * Whether the field is announcing an error it has no words for: invalid, with an\n * error block that renders nothing.\n *\n * Worth a named check because it is invisible in review — the field still goes\n * red, and `aria-describedby` still points at the block, so a screen reader is\n * sent to an empty element. It happens when no link in the copy chain answers\n * the key (`[autoErrors]=\"false\"` with no markup, or a key nothing has copy for\n * — Signal Forms reports `minLength`, while the chain only knows Angular's\n * lowercase `minlength`).\n */\n async hasEmptyErrorBlock(): Promise<boolean> {\n if (!(await this.isInvalid())) return false;\n return (await this.getErrors()).every(error => error.text.length === 0);\n }\n\n /** The id the `<label for>` points at, or `null` when there is no label. */\n async getLabelFor(): Promise<string | null> {\n const label = await this.labelElement();\n return label ? label.getAttribute('for') : null;\n }\n\n /** The `id` the projected control actually answers to, or `null` when it has none. */\n async getControlId(): Promise<string | null> {\n return (await this.control()).getAttribute('id');\n }\n\n /**\n * Whether the `<label for>` resolves to an element inside THIS field's control\n * slot — the only thing that makes the field nameable.\n *\n * Scoped to the slot on purpose: ids are document-global, so a check that went\n * through `getElementById` would also pass for a label pointing at a DIFFERENT\n * field's control, and for a control that has been moved out of the field\n * entirely. The failure this catches is quiet — a projected control that does\n * not adopt the field's `controlId` (a bare `<input>` with no `[wrInput]`, say)\n * leaves a `for` naming nothing, the field renders exactly as it always did, and\n * nothing is labelled.\n */\n async isLabelLinkedToControl(): Promise<boolean> {\n const id = await this.getLabelFor();\n if (!id) return false;\n return (await this.locatorForOptional(`${SLOT} [id=\"${id}\"]`)()) !== null;\n }\n\n /**\n * The ids the projected control names in `aria-describedby`, in order.\n *\n * Which id that is depends on the CONTROL, not on the field, and the answer is\n * worth knowing before reading a result. A control that composes the pair with\n * `useFormFieldAria()` names the error block while one is showing and the hint\n * otherwise. A control that reads the field's `describedBy` on its own — the\n * `[wrInput]` directive, `wr-segmented` and `wr-slider` — names the error block\n * and nothing else, so an empty list beside a visible hint is that control's\n * answer rather than a broken field.\n *\n * The two are separate because folding the hint into the one signal announced\n * every hinted field as invalid: those three derive `aria-invalid` from it.\n */\n async getDescribedByIds(): Promise<string[]> {\n const value = await (await this.control()).getAttribute('aria-describedby');\n return value ? value.split(/\\s+/).filter(Boolean) : [];\n }\n\n /**\n * What a screen reader reads as the control's description: the text of the\n * elements `aria-describedby` names, joined by a space. `null` when the control\n * describes nothing.\n *\n * `''` is a real answer and the interesting one — the reference resolves to an\n * element with no text in it, which is {@link hasEmptyErrorBlock}. Ids naming\n * something outside this field are skipped (a consumer's own description is out\n * of a field harness's reach); an id naming nothing anywhere throws, because a\n * dangling reference is the bug this method exists to surface.\n *\n * Suppressed copy is excluded explicitly rather than left to CSS: a browser drops\n * `display: none` subtrees from the accessibility tree, but a unit test loads no\n * stylesheet at all, so the referenced block's raw `textContent` runs every\n * held-back sentence together with the live one and this would answer with copy\n * nobody can read.\n */\n async getAnnouncedDescription(): Promise<string | null> {\n const ids = await this.getDescribedByIds();\n if (ids.length === 0) return null;\n\n const parts: string[] = [];\n for (const id of ids) {\n const inField = await this.locatorForOptional(`[id=\"${id}\"]`)();\n if (inField) {\n parts.push(await inField.text({ exclude: '.wr-form-field__error--hidden' }));\n continue;\n }\n if ((await this.documentRootLocatorFactory().locatorForOptional(`[id=\"${id}\"]`)()) === null) {\n throw new Error(\n `WrFormFieldHarness.getAnnouncedDescription(): the control's aria-describedby names \"${id}\", which is not ` +\n 'an element anywhere in the document — a screen reader is pointed at nothing.'\n );\n }\n }\n\n return parts.join(' ');\n }\n\n /**\n * Whether the control announces itself invalid.\n *\n * `aria-invalid` on the projected control, which is what assistive technology\n * is told — the field's own red styling is {@link isInvalid}. Both are here\n * because they live on different elements and travel in opposite directions: the\n * field renders the message, the control reads back that there is one. A field\n * that paints red while the control says nothing is a real (and silent) break.\n */\n async isControlInvalid(): Promise<boolean> {\n return (await (await this.control()).getAttribute('aria-invalid')) === 'true';\n }\n\n /** Move focus to the projected control. */\n async focusControl(): Promise<void> {\n return (await this.control()).focus();\n }\n\n /**\n * Blur the projected control, which is usually how a spec gets any message to\n * appear at all: a bound control marks itself touched on blur, and the field\n * renders nothing while the control is untouched AND pristine.\n */\n async blurControl(): Promise<void> {\n return (await this.control()).blur();\n }\n\n /** The rendered `<label>`, or `null` when `label` is empty. */\n private async labelElement(): Promise<TestElement | null> {\n return this.locatorForOptional(LABEL)();\n }\n\n /**\n * The control this field wraps.\n *\n * The element the label points at, when that resolves inside the slot — which\n * covers a control nested inside a component (`<wr-input-number>`'s own\n * `<input>` adopts the field's id, so the label names it, not the component\n * element). Otherwise the first native control in the slot, so a field with no\n * label still answers.\n */\n private async control(): Promise<TestElement> {\n const id = await this.getLabelFor();\n if (id) {\n const labelled = await this.locatorForOptional(`${SLOT} [id=\"${id}\"]`)();\n if (labelled) return labelled;\n }\n\n const native = await this.locatorForOptional(`${SLOT} input, ${SLOT} select, ${SLOT} textarea`)();\n if (native) return native;\n\n throw new Error(\n 'WrFormFieldHarness: this field wraps no control. Nothing in `.wr-form-field__control` answers to the ' +\n \"label's `for`, and there is no <input> / <select> / <textarea> to fall back to.\"\n );\n }\n\n /**\n * The content loader every `HarnessLoader` method on this class runs through,\n * scoped to the control slot.\n *\n * So `field.getHarness(WrInputHarness)` finds the control this field wraps and\n * not a sibling field's — the loader is per-instance by construction, which is\n * what a document-wide query for the same selector would lose.\n */\n protected override async getRootHarnessLoader(): Promise<HarnessLoader> {\n return this.locatorFactory.harnessLoaderFor(SLOT);\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 { ContentContainerComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport type { WrFormItemHarnessFilters } from './interfaces';\n\n/**\n * Test harness for `<wr-form-item>` — the layout-only field row.\n *\n * Deliberately a much smaller surface than {@link WrFormFieldHarness}, because\n * the component is a much smaller thing: it discovers no control, generates no\n * id, wires no `for` and no `aria-describedby`, and reads no validity. It paints\n * the error state it is TOLD to paint, via `[hasError]`, and everything else in\n * it belongs to the consumer — including the `<label>`, which is named here\n * rather than linked (nothing wires it; the consumer's own `for` is the only\n * thing that can).\n *\n * The one behavioural trap it is worth a harness for: a `<wr-form-error>` inside\n * a form-item renders UNCONDITIONALLY. `key` has no effect at all — the gating\n * lives in the surrounding `<wr-form-field>`, and with no field to ask, every\n * message decides it is the one to show. Markup moved from a field into an item\n * therefore starts printing every sentence at once, and {@link getErrorTexts}\n * is what says so.\n *\n * @example\n * ```ts\n * const item = await loader.getHarness(WrFormItemHarness.with({ label: 'Email' }));\n *\n * expect(await item.isInvalid()).toBe(true);\n * expect(await item.getErrorTexts()).toEqual(['Invalid email']);\n * await (await item.getHarness(WrInputHarness)).setValue('ada@example.test');\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrFormItemHarness extends ContentContainerComponentHarness {\n static hostSelector = 'wr-form-item';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrFormItemHarnessFilters = {}): HarnessPredicate<WrFormItemHarness> {\n return new HarnessPredicate(WrFormItemHarness, options)\n .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label))\n .addOption('invalid', options.invalid, async (harness, invalid) => (await harness.isInvalid()) === invalid)\n .addOption('errorText', options.errorText, async (harness, text) => {\n for (const shown of await harness.getErrorTexts()) {\n if (await HarnessPredicate.stringMatches(shown, text)) return true;\n }\n return false;\n });\n }\n\n /**\n * The text of the item's own `<label>` child, or `null` when it has none.\n *\n * Direct child only — that is what the item styles (`> label` is what turns red\n * in the error state), so a label nested deeper is the consumer's own business\n * and answering with it would describe something the item never touches.\n */\n async getLabel(): Promise<string | null> {\n const label = await this.locatorForOptional(':scope > label')();\n return label ? label.text() : null;\n }\n\n /**\n * Whether the item is painting the error state.\n *\n * The `wr-form-item--error` modifier, which is driven entirely by the\n * consumer's `[hasError]` — the item runs no validity check of its own, so this\n * answers what it was told, not what the control thinks.\n */\n async isInvalid(): Promise<boolean> {\n return (await this.host()).hasClass('wr-form-item--error');\n }\n\n /**\n * Every `<wr-form-error>` in the item, as text, in DOM order.\n *\n * All of them: nothing is gated here, `key` or no `key`. Nothing is ever\n * hidden either, so there is no suppressed-message counterpart to this — see\n * the class docs.\n */\n async getErrorTexts(): Promise<string[]> {\n const errors = await this.locatorForAll('wr-form-error')();\n return Promise.all(errors.map(error => error.text()));\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;;;;;AAKG;AAWH;;;;;;;AAOG;AACH,MAAM,OAAO,GAAG,yDAAyD;AACzE,MAAM,OAAO,GAAG,CAAA,EAAG,O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debugName: "classes" }] : /* istanbul ignore next */ []));
45
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: WrFormItem, deps: [], target: i0.ɵɵFactoryTarget.Component });
46
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.4", type: WrFormItem, isStandalone: true, selector: "wr-form-item", inputs: { hasError: { classPropertyName: "hasError", publicName: "hasError", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "classes()" } }, ngImport: i0, template: '<ng-content />', isInline: true, encapsulation: i0.ViewEncapsulation.None });
45
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: WrFormItem, deps: [], target: i0.ɵɵFactoryTarget.Component });
46
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.5", type: WrFormItem, isStandalone: true, selector: "wr-form-item", inputs: { hasError: { classPropertyName: "hasError", publicName: "hasError", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "classes()" } }, ngImport: i0, template: '<ng-content />', isInline: true, encapsulation: i0.ViewEncapsulation.None });
47
47
  }
48
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: WrFormItem, decorators: [{
48
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: WrFormItem, decorators: [{
49
49
  type: Component,
50
50
  args: [{
51
51
  selector: 'wr-form-item',
@@ -200,10 +200,10 @@ class WrFormError {
200
200
  return this.field.errorKeys().includes(key);
201
201
  }, /* @ts-ignore */
202
202
  ...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
203
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: WrFormError, deps: [], target: i0.ɵɵFactoryTarget.Component });
204
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.4", 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 });
203
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: WrFormError, deps: [], target: i0.ɵɵFactoryTarget.Component });
204
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.5", 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 });
205
205
  }
206
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: WrFormError, decorators: [{
206
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: WrFormError, decorators: [{
207
207
  type: Component,
208
208
  args: [{
209
209
  selector: 'wr-form-error',
@@ -338,6 +338,21 @@ class WrFormField {
338
338
  /** @internal Read by the projected control so a screen reader is pointed at the message. */
339
339
  describedBy = computed(() => (this.hasError() ? `${this.controlId()}-errors` : null), /* @ts-ignore */
340
340
  ...(ngDevMode ? [{ debugName: "describedBy" }] : /* istanbul ignore next */ []));
341
+ /**
342
+ * @internal Read by the projected control so the hint is announced with the field.
343
+ *
344
+ * The hint used to carry no id at all, so the only thing `aria-describedby`
345
+ * could ever name was the error block: the sentence explaining what to type was
346
+ * on screen and reached a screen-reader user through no path whatsoever, and
347
+ * the one gate that could have said so does not exist — axe has no rule that
348
+ * visible help text must be programmatically associated.
349
+ *
350
+ * `null` while an error is showing, because the template swaps the hint out for
351
+ * the message; publishing the id anyway would point every control at an element
352
+ * that had just left the document.
353
+ */
354
+ hintId = computed(() => (!this.hasError() && this.hint() ? `${this.controlId()}-hint` : null), /* @ts-ignore */
355
+ ...(ngDevMode ? [{ debugName: "hintId" }] : /* istanbul ignore next */ []));
341
356
  /**
342
357
  * Render a catalog message for any error the markup does not already answer.
343
358
  *
@@ -392,16 +407,16 @@ class WrFormField {
392
407
  return parts.join(' ');
393
408
  }, /* @ts-ignore */
394
409
  ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
395
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: WrFormField, deps: [], target: i0.ɵɵFactoryTarget.Component });
396
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.4", 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 }, optionalLabel: { classPropertyName: "optionalLabel", publicName: "optionalLabel", 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: [
410
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: WrFormField, deps: [], target: i0.ɵɵFactoryTarget.Component });
411
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", 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 }, optionalLabel: { classPropertyName: "optionalLabel", publicName: "optionalLabel", 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: [
397
412
  {
398
413
  provide: WR_FORM_FIELD,
399
414
  // eslint-disable-next-line @angular-eslint/no-forward-ref
400
415
  useExisting: forwardRef(() => WrFormField),
401
416
  },
402
- ], 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]=\"labelFor()\">\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\">({{ resolvedOptional() }})</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 });
417
+ ], 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]=\"labelFor()\">\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\">({{ resolvedOptional() }})</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\" [attr.id]=\"hintId()\">{{ hint() }}</small>\n}\n", encapsulation: i0.ViewEncapsulation.None });
403
418
  }
404
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: WrFormField, decorators: [{
419
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: WrFormField, decorators: [{
405
420
  type: Component,
406
421
  args: [{ selector: 'wr-form-field', encapsulation: ViewEncapsulation.None, host: { '[class]': 'classes()' }, providers: [
407
422
  {
@@ -409,7 +424,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImpor
409
424
  // eslint-disable-next-line @angular-eslint/no-forward-ref
410
425
  useExisting: forwardRef(() => WrFormField),
411
426
  },
412
- ], template: "@if (label()) {\n <label class=\"wr-form-field__label\" [attr.for]=\"labelFor()\">\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\">({{ resolvedOptional() }})</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" }]
427
+ ], template: "@if (label()) {\n <label class=\"wr-form-field__label\" [attr.for]=\"labelFor()\">\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\">({{ resolvedOptional() }})</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\" [attr.id]=\"hintId()\">{{ hint() }}</small>\n}\n" }]
413
428
  }], 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 }] }], optionalLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionalLabel", 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 }] }] } });
414
429
 
415
430
  /**
@@ -419,18 +434,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImpor
419
434
  * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
420
435
  */
421
436
  /**
422
- * The two attributes that make a `<wr-form-field>`'s visible error reach a
423
- * screen reader — bind both on whichever element carries the control's role.
437
+ * The two attributes that make a `<wr-form-field>`'s visible text — its error
438
+ * message, or its hint — reach a screen reader. Bind both on whichever element
439
+ * carries the control's role.
424
440
  *
425
- * Without them the messages the field renders are visible and nothing else: the
426
- * control announces itself as valid, and the message is associated with nothing.
427
- * No automated gate catches that — axe has no rule that a visible error must be
428
- * programmatically associated with its control — so this helper exists to make
429
- * the wiring one line per control rather than three, and the specs are the gate.
441
+ * Without them the copy the field renders is visible and nothing else: the
442
+ * control announces itself as valid, and the text is associated with nothing.
443
+ * No automated gate catches that — axe has no rule that a visible error or hint
444
+ * must be programmatically associated with its control — so this helper exists
445
+ * to make the wiring one line per control rather than three, and the specs are
446
+ * the gate.
430
447
  *
431
- * `aria-invalid` is keyed on the message EXISTING rather than on `errorKeys()`,
432
- * because the field only publishes an id once it is showing something —
433
- * announcing "invalid" while pointing at nothing is worse than staying quiet.
448
+ * The field renders an error OR a hint, never both, so `describedBy` names
449
+ * whichever is on screen and `aria-invalid` is keyed SEPARATELY, on the field's
450
+ * `errorKeys()`. Deriving it from `describedBy` instead — which is what every
451
+ * control did while a hint had no id to name — makes a field with a plain hint
452
+ * announce its control as invalid the moment the hint becomes describable.
434
453
  *
435
454
  * Must be called from an injection context (a field initialiser or a
436
455
  * constructor). Returns inert signals outside a `<wr-form-field>`.
@@ -451,11 +470,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImpor
451
470
  */
452
471
  function useFormFieldAria(options) {
453
472
  const field = inject(WR_FORM_FIELD, { optional: true, skipSelf: options?.skipSelf ?? false });
454
- const describedBy = computed(() => field?.describedBy() ?? null, /* @ts-ignore */
455
- ...(ngDevMode ? [{ debugName: "describedBy" }] : /* istanbul ignore next */ []));
456
473
  return {
457
- describedBy,
458
- ariaInvalid: computed(() => (describedBy() ? 'true' : null)),
474
+ // `hintId` is optional on the interface so an app-provided field keeps
475
+ // compiling; one without it describes nothing but its errors, as before.
476
+ describedBy: computed(() => field?.describedBy() ?? field?.hintId?.() ?? null),
477
+ ariaInvalid: computed(() => ((field?.errorKeys().length ?? 0) > 0 ? 'true' : null)),
459
478
  };
460
479
  }
461
480