@4sh/ui-kit 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/README.fr.md +10 -10
  2. package/README.md +10 -10
  3. package/fesm2022/4sh-ui-kit-actions-ui-button-split.mjs +542 -150
  4. package/fesm2022/4sh-ui-kit-actions-ui-button-split.mjs.map +1 -1
  5. package/fesm2022/4sh-ui-kit-actions-ui-button.mjs +622 -248
  6. package/fesm2022/4sh-ui-kit-actions-ui-button.mjs.map +1 -1
  7. package/fesm2022/4sh-ui-kit-actions-ui-link.mjs +385 -152
  8. package/fesm2022/4sh-ui-kit-actions-ui-link.mjs.map +1 -1
  9. package/fesm2022/4sh-ui-kit-actions-ui-speed-dial.mjs +748 -433
  10. package/fesm2022/4sh-ui-kit-actions-ui-speed-dial.mjs.map +1 -1
  11. package/fesm2022/4sh-ui-kit-base-ui-icon.mjs +227 -135
  12. package/fesm2022/4sh-ui-kit-base-ui-icon.mjs.map +1 -1
  13. package/fesm2022/4sh-ui-kit-base-ui-image.mjs +1200 -633
  14. package/fesm2022/4sh-ui-kit-base-ui-image.mjs.map +1 -1
  15. package/fesm2022/4sh-ui-kit-forms-ui-autocomplete.mjs +1675 -1000
  16. package/fesm2022/4sh-ui-kit-forms-ui-autocomplete.mjs.map +1 -1
  17. package/fesm2022/4sh-ui-kit-forms-ui-checkbox.mjs +243 -117
  18. package/fesm2022/4sh-ui-kit-forms-ui-checkbox.mjs.map +1 -1
  19. package/fesm2022/4sh-ui-kit-forms-ui-datepicker.mjs +2294 -2048
  20. package/fesm2022/4sh-ui-kit-forms-ui-datepicker.mjs.map +1 -1
  21. package/fesm2022/4sh-ui-kit-forms-ui-editor.mjs +1058 -1113
  22. package/fesm2022/4sh-ui-kit-forms-ui-editor.mjs.map +1 -1
  23. package/fesm2022/4sh-ui-kit-forms-ui-field-sign.mjs +1108 -0
  24. package/fesm2022/4sh-ui-kit-forms-ui-field-sign.mjs.map +1 -0
  25. package/fesm2022/4sh-ui-kit-forms-ui-field.mjs +397 -141
  26. package/fesm2022/4sh-ui-kit-forms-ui-field.mjs.map +1 -1
  27. package/fesm2022/4sh-ui-kit-forms-ui-file-upload.mjs +1529 -583
  28. package/fesm2022/4sh-ui-kit-forms-ui-file-upload.mjs.map +1 -1
  29. package/fesm2022/4sh-ui-kit-forms-ui-input-date.mjs +383 -224
  30. package/fesm2022/4sh-ui-kit-forms-ui-input-date.mjs.map +1 -1
  31. package/fesm2022/4sh-ui-kit-forms-ui-input-group.mjs +345 -177
  32. package/fesm2022/4sh-ui-kit-forms-ui-input-group.mjs.map +1 -1
  33. package/fesm2022/4sh-ui-kit-forms-ui-input-mask.mjs +280 -138
  34. package/fesm2022/4sh-ui-kit-forms-ui-input-mask.mjs.map +1 -1
  35. package/fesm2022/4sh-ui-kit-forms-ui-input-number.mjs +507 -257
  36. package/fesm2022/4sh-ui-kit-forms-ui-input-number.mjs.map +1 -1
  37. package/fesm2022/4sh-ui-kit-forms-ui-input-otp.mjs +401 -312
  38. package/fesm2022/4sh-ui-kit-forms-ui-input-otp.mjs.map +1 -1
  39. package/fesm2022/4sh-ui-kit-forms-ui-input-tags.mjs +1277 -697
  40. package/fesm2022/4sh-ui-kit-forms-ui-input-tags.mjs.map +1 -1
  41. package/fesm2022/4sh-ui-kit-forms-ui-input.mjs +467 -199
  42. package/fesm2022/4sh-ui-kit-forms-ui-input.mjs.map +1 -1
  43. package/fesm2022/4sh-ui-kit-forms-ui-knob.mjs +394 -270
  44. package/fesm2022/4sh-ui-kit-forms-ui-knob.mjs.map +1 -1
  45. package/fesm2022/4sh-ui-kit-forms-ui-label.mjs +140 -60
  46. package/fesm2022/4sh-ui-kit-forms-ui-label.mjs.map +1 -1
  47. package/fesm2022/4sh-ui-kit-forms-ui-nudger.mjs +386 -167
  48. package/fesm2022/4sh-ui-kit-forms-ui-nudger.mjs.map +1 -1
  49. package/fesm2022/4sh-ui-kit-forms-ui-radio.mjs +150 -87
  50. package/fesm2022/4sh-ui-kit-forms-ui-radio.mjs.map +1 -1
  51. package/fesm2022/4sh-ui-kit-forms-ui-rating.mjs +345 -180
  52. package/fesm2022/4sh-ui-kit-forms-ui-rating.mjs.map +1 -1
  53. package/fesm2022/4sh-ui-kit-forms-ui-segment-control.mjs +582 -392
  54. package/fesm2022/4sh-ui-kit-forms-ui-segment-control.mjs.map +1 -1
  55. package/fesm2022/4sh-ui-kit-forms-ui-select.mjs +1552 -888
  56. package/fesm2022/4sh-ui-kit-forms-ui-select.mjs.map +1 -1
  57. package/fesm2022/4sh-ui-kit-forms-ui-slider.mjs +485 -338
  58. package/fesm2022/4sh-ui-kit-forms-ui-slider.mjs.map +1 -1
  59. package/fesm2022/4sh-ui-kit-forms-ui-swatch-picker.mjs +503 -311
  60. package/fesm2022/4sh-ui-kit-forms-ui-swatch-picker.mjs.map +1 -1
  61. package/fesm2022/4sh-ui-kit-forms-ui-textarea.mjs +271 -137
  62. package/fesm2022/4sh-ui-kit-forms-ui-textarea.mjs.map +1 -1
  63. package/fesm2022/4sh-ui-kit-forms-ui-toggle-block.mjs +457 -214
  64. package/fesm2022/4sh-ui-kit-forms-ui-toggle-block.mjs.map +1 -1
  65. package/fesm2022/4sh-ui-kit-forms-ui-toggle-button.mjs +711 -371
  66. package/fesm2022/4sh-ui-kit-forms-ui-toggle-button.mjs.map +1 -1
  67. package/fesm2022/4sh-ui-kit-forms-ui-toggle.mjs +235 -121
  68. package/fesm2022/4sh-ui-kit-forms-ui-toggle.mjs.map +1 -1
  69. package/fesm2022/4sh-ui-kit-forms.mjs +721 -638
  70. package/fesm2022/4sh-ui-kit-forms.mjs.map +1 -1
  71. package/fesm2022/4sh-ui-kit-informative-ui-accordion.mjs +546 -242
  72. package/fesm2022/4sh-ui-kit-informative-ui-accordion.mjs.map +1 -1
  73. package/fesm2022/4sh-ui-kit-informative-ui-alert.mjs +335 -157
  74. package/fesm2022/4sh-ui-kit-informative-ui-alert.mjs.map +1 -1
  75. package/fesm2022/4sh-ui-kit-informative-ui-avatar-group.mjs +53 -33
  76. package/fesm2022/4sh-ui-kit-informative-ui-avatar-group.mjs.map +1 -1
  77. package/fesm2022/4sh-ui-kit-informative-ui-avatar.mjs +218 -121
  78. package/fesm2022/4sh-ui-kit-informative-ui-avatar.mjs.map +1 -1
  79. package/fesm2022/4sh-ui-kit-informative-ui-badge.mjs +192 -100
  80. package/fesm2022/4sh-ui-kit-informative-ui-badge.mjs.map +1 -1
  81. package/fesm2022/4sh-ui-kit-informative-ui-chip.mjs +456 -204
  82. package/fesm2022/4sh-ui-kit-informative-ui-chip.mjs.map +1 -1
  83. package/fesm2022/4sh-ui-kit-informative-ui-empty-state.mjs +314 -147
  84. package/fesm2022/4sh-ui-kit-informative-ui-empty-state.mjs.map +1 -1
  85. package/fesm2022/4sh-ui-kit-informative-ui-helper.mjs +179 -82
  86. package/fesm2022/4sh-ui-kit-informative-ui-helper.mjs.map +1 -1
  87. package/fesm2022/4sh-ui-kit-informative-ui-progress-bar.mjs +268 -123
  88. package/fesm2022/4sh-ui-kit-informative-ui-progress-bar.mjs.map +1 -1
  89. package/fesm2022/4sh-ui-kit-informative-ui-read-only.mjs +391 -146
  90. package/fesm2022/4sh-ui-kit-informative-ui-read-only.mjs.map +1 -1
  91. package/fesm2022/4sh-ui-kit-informative-ui-separator.mjs +158 -76
  92. package/fesm2022/4sh-ui-kit-informative-ui-separator.mjs.map +1 -1
  93. package/fesm2022/4sh-ui-kit-informative-ui-skeleton.mjs +159 -80
  94. package/fesm2022/4sh-ui-kit-informative-ui-skeleton.mjs.map +1 -1
  95. package/fesm2022/4sh-ui-kit-informative-ui-spinner.mjs +295 -131
  96. package/fesm2022/4sh-ui-kit-informative-ui-spinner.mjs.map +1 -1
  97. package/fesm2022/4sh-ui-kit-informative-ui-tag.mjs +211 -83
  98. package/fesm2022/4sh-ui-kit-informative-ui-tag.mjs.map +1 -1
  99. package/fesm2022/4sh-ui-kit-informative-ui-toast.mjs +784 -414
  100. package/fesm2022/4sh-ui-kit-informative-ui-toast.mjs.map +1 -1
  101. package/fesm2022/4sh-ui-kit-informative-ui-tooltip.mjs +822 -476
  102. package/fesm2022/4sh-ui-kit-informative-ui-tooltip.mjs.map +1 -1
  103. package/fesm2022/4sh-ui-kit-layout-ui-bottom-sheet.mjs +1014 -599
  104. package/fesm2022/4sh-ui-kit-layout-ui-bottom-sheet.mjs.map +1 -1
  105. package/fesm2022/4sh-ui-kit-layout-ui-card.mjs +403 -189
  106. package/fesm2022/4sh-ui-kit-layout-ui-card.mjs.map +1 -1
  107. package/fesm2022/4sh-ui-kit-layout-ui-drawer.mjs +707 -272
  108. package/fesm2022/4sh-ui-kit-layout-ui-drawer.mjs.map +1 -1
  109. package/fesm2022/4sh-ui-kit-layout-ui-modal.mjs +1146 -568
  110. package/fesm2022/4sh-ui-kit-layout-ui-modal.mjs.map +1 -1
  111. package/fesm2022/4sh-ui-kit-layout-ui-popover.mjs +519 -308
  112. package/fesm2022/4sh-ui-kit-layout-ui-popover.mjs.map +1 -1
  113. package/fesm2022/4sh-ui-kit-motion.mjs +252 -150
  114. package/fesm2022/4sh-ui-kit-motion.mjs.map +1 -1
  115. package/fesm2022/4sh-ui-kit-navigation-ui-bottom-tab-bar.mjs +793 -341
  116. package/fesm2022/4sh-ui-kit-navigation-ui-bottom-tab-bar.mjs.map +1 -1
  117. package/fesm2022/4sh-ui-kit-navigation-ui-breadcrumb.mjs +351 -194
  118. package/fesm2022/4sh-ui-kit-navigation-ui-breadcrumb.mjs.map +1 -1
  119. package/fesm2022/4sh-ui-kit-navigation-ui-context-menu.mjs +511 -220
  120. package/fesm2022/4sh-ui-kit-navigation-ui-context-menu.mjs.map +1 -1
  121. package/fesm2022/4sh-ui-kit-navigation-ui-menu.mjs +910 -548
  122. package/fesm2022/4sh-ui-kit-navigation-ui-menu.mjs.map +1 -1
  123. package/fesm2022/4sh-ui-kit-navigation-ui-sidebar.mjs +1128 -555
  124. package/fesm2022/4sh-ui-kit-navigation-ui-sidebar.mjs.map +1 -1
  125. package/fesm2022/4sh-ui-kit-navigation-ui-stepper.mjs +915 -470
  126. package/fesm2022/4sh-ui-kit-navigation-ui-stepper.mjs.map +1 -1
  127. package/fesm2022/4sh-ui-kit-navigation-ui-tabs.mjs +931 -474
  128. package/fesm2022/4sh-ui-kit-navigation-ui-tabs.mjs.map +1 -1
  129. package/fesm2022/4sh-ui-kit-overlay.mjs +26 -109
  130. package/fesm2022/4sh-ui-kit-overlay.mjs.map +1 -1
  131. package/fesm2022/4sh-ui-kit-ripple.mjs +329 -290
  132. package/fesm2022/4sh-ui-kit-ripple.mjs.map +1 -1
  133. package/fesm2022/4sh-ui-kit-table-ui-paginator.mjs +709 -248
  134. package/fesm2022/4sh-ui-kit-table-ui-paginator.mjs.map +1 -1
  135. package/fesm2022/4sh-ui-kit-table-ui-table.mjs +2633 -1370
  136. package/fesm2022/4sh-ui-kit-table-ui-table.mjs.map +1 -1
  137. package/fesm2022/4sh-ui-kit-theming.mjs +112 -113
  138. package/fesm2022/4sh-ui-kit-theming.mjs.map +1 -1
  139. package/fesm2022/4sh-ui-kit-types.mjs +0 -12
  140. package/fesm2022/4sh-ui-kit.mjs +3 -15
  141. package/fesm2022/4sh-ui-kit.mjs.map +1 -1
  142. package/mcp/data/component-api.json +299 -2
  143. package/mcp/data/text-search-docs.json +149 -9
  144. package/mcp/data/ui-config.json +378 -1
  145. package/mcp/index.js +8190 -2876
  146. package/mcp/package.json +1 -1
  147. package/package.json +5 -1
  148. package/styles/component-vars.scss +22 -1
  149. package/types/4sh-ui-kit-actions-ui-button-split.d.ts +198 -87
  150. package/types/4sh-ui-kit-actions-ui-button.d.ts +240 -116
  151. package/types/4sh-ui-kit-actions-ui-link.d.ts +136 -67
  152. package/types/4sh-ui-kit-actions-ui-speed-dial.d.ts +287 -180
  153. package/types/4sh-ui-kit-base-ui-icon.d.ts +92 -58
  154. package/types/4sh-ui-kit-base-ui-image.d.ts +406 -205
  155. package/types/4sh-ui-kit-forms-ui-autocomplete.d.ts +573 -376
  156. package/types/4sh-ui-kit-forms-ui-checkbox.d.ts +77 -42
  157. package/types/4sh-ui-kit-forms-ui-datepicker.d.ts +953 -700
  158. package/types/4sh-ui-kit-forms-ui-editor.d.ts +374 -340
  159. package/types/4sh-ui-kit-forms-ui-field-sign.d.ts +325 -0
  160. package/types/4sh-ui-kit-forms-ui-field.d.ts +150 -64
  161. package/types/4sh-ui-kit-forms-ui-file-upload.d.ts +583 -241
  162. package/types/4sh-ui-kit-forms-ui-input-date.d.ts +152 -103
  163. package/types/4sh-ui-kit-forms-ui-input-group.d.ts +109 -63
  164. package/types/4sh-ui-kit-forms-ui-input-mask.d.ts +93 -59
  165. package/types/4sh-ui-kit-forms-ui-input-number.d.ts +171 -96
  166. package/types/4sh-ui-kit-forms-ui-input-otp.d.ts +137 -104
  167. package/types/4sh-ui-kit-forms-ui-input-tags.d.ts +469 -309
  168. package/types/4sh-ui-kit-forms-ui-input.d.ts +198 -118
  169. package/types/4sh-ui-kit-forms-ui-knob.d.ts +132 -80
  170. package/types/4sh-ui-kit-forms-ui-label.d.ts +47 -22
  171. package/types/4sh-ui-kit-forms-ui-nudger.d.ts +134 -67
  172. package/types/4sh-ui-kit-forms-ui-radio.d.ts +48 -33
  173. package/types/4sh-ui-kit-forms-ui-rating.d.ts +120 -86
  174. package/types/4sh-ui-kit-forms-ui-segment-control.d.ts +221 -147
  175. package/types/4sh-ui-kit-forms-ui-select.d.ts +561 -357
  176. package/types/4sh-ui-kit-forms-ui-slider.d.ts +156 -105
  177. package/types/4sh-ui-kit-forms-ui-swatch-picker.d.ts +133 -97
  178. package/types/4sh-ui-kit-forms-ui-textarea.d.ts +90 -56
  179. package/types/4sh-ui-kit-forms-ui-toggle-block.d.ts +158 -94
  180. package/types/4sh-ui-kit-forms-ui-toggle-button.d.ts +314 -178
  181. package/types/4sh-ui-kit-forms-ui-toggle.d.ts +88 -54
  182. package/types/4sh-ui-kit-forms.d.ts +275 -194
  183. package/types/4sh-ui-kit-informative-ui-accordion.d.ts +162 -92
  184. package/types/4sh-ui-kit-informative-ui-alert.d.ts +128 -62
  185. package/types/4sh-ui-kit-informative-ui-avatar-group.d.ts +8 -8
  186. package/types/4sh-ui-kit-informative-ui-avatar.d.ts +81 -44
  187. package/types/4sh-ui-kit-informative-ui-badge.d.ts +71 -41
  188. package/types/4sh-ui-kit-informative-ui-chip.d.ts +194 -99
  189. package/types/4sh-ui-kit-informative-ui-empty-state.d.ts +105 -65
  190. package/types/4sh-ui-kit-informative-ui-helper.d.ts +64 -34
  191. package/types/4sh-ui-kit-informative-ui-progress-bar.d.ts +120 -65
  192. package/types/4sh-ui-kit-informative-ui-read-only.d.ts +147 -67
  193. package/types/4sh-ui-kit-informative-ui-separator.d.ts +65 -35
  194. package/types/4sh-ui-kit-informative-ui-skeleton.d.ts +62 -32
  195. package/types/4sh-ui-kit-informative-ui-spinner.d.ts +111 -50
  196. package/types/4sh-ui-kit-informative-ui-tag.d.ts +77 -37
  197. package/types/4sh-ui-kit-informative-ui-toast.d.ts +300 -180
  198. package/types/4sh-ui-kit-informative-ui-tooltip.d.ts +269 -141
  199. package/types/4sh-ui-kit-layout-ui-bottom-sheet.d.ts +360 -221
  200. package/types/4sh-ui-kit-layout-ui-card.d.ts +119 -79
  201. package/types/4sh-ui-kit-layout-ui-drawer.d.ts +244 -120
  202. package/types/4sh-ui-kit-layout-ui-modal.d.ts +409 -222
  203. package/types/4sh-ui-kit-layout-ui-popover.d.ts +149 -91
  204. package/types/4sh-ui-kit-motion.d.ts +117 -67
  205. package/types/4sh-ui-kit-navigation-ui-bottom-tab-bar.d.ts +279 -145
  206. package/types/4sh-ui-kit-navigation-ui-breadcrumb.d.ts +134 -96
  207. package/types/4sh-ui-kit-navigation-ui-context-menu.d.ts +148 -89
  208. package/types/4sh-ui-kit-navigation-ui-menu.d.ts +282 -201
  209. package/types/4sh-ui-kit-navigation-ui-sidebar.d.ts +425 -261
  210. package/types/4sh-ui-kit-navigation-ui-stepper.d.ts +279 -183
  211. package/types/4sh-ui-kit-navigation-ui-tabs.d.ts +275 -173
  212. package/types/4sh-ui-kit-overlay.d.ts +6 -6
  213. package/types/4sh-ui-kit-ripple.d.ts +99 -74
  214. package/types/4sh-ui-kit-table-ui-paginator.d.ts +237 -133
  215. package/types/4sh-ui-kit-table-ui-table.d.ts +769 -470
  216. package/types/4sh-ui-kit-theming.d.ts +27 -29
  217. package/types/4sh-ui-kit-types.d.ts +6 -5
  218. package/types/4sh-ui-kit.d.ts +4 -3
  219. package/fesm2022/4sh-ui-kit-types.mjs.map +0 -1
@@ -1,695 +1,778 @@
1
- import * as i0 from '@angular/core';
2
- import { inject, Injector, DestroyRef, signal, computed, afterNextRender, effect, input, booleanAttribute, Directive, isDevMode, output } from '@angular/core';
3
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
4
- import { NgControl, PristineChangeEvent, TouchedChangeEvent, StatusChangeEvent } from '@angular/forms';
5
-
6
- /**
7
- * Base class for form components (`ui-checkbox`, `ui-radio`, `ui-input`…).
8
- *
9
- * Implements `ControlValueAccessor` and mirrors the attached `NgControl` state
10
- * into signals, so templates/styles can react to it declaratively:
11
- *
12
- * - `touched` / `dirty` / `pristine` / `untouched` — interaction state
13
- * - `controlInvalid` / `controlErrors` — validation state
14
- * - `controlDisabled` — driven by `control.disable()`
15
- * - `showError` — invalid AND (touched or dirty),
16
- * the usual "when to paint red" rule
17
- *
18
- * The subscription is wired automatically after first render and cleaned up on
19
- * destroy. Subclasses only have to:
20
- * 1. implement `writeValue()` (form → view),
21
- * 2. call `emitChange(value)` on user interaction (view → form),
22
- * 3. call `emitTouch()` on blur,
23
- * 4. declare the DI provider:
24
- * `{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => MyComponent), multi: true }`.
25
- *
26
- * Works with reactive forms, template-driven forms, or standalone (no form at
27
- * all — the signals simply keep their defaults).
28
- */
29
- class BaseControlValueAccessor {
30
- constructor() {
31
- this.injector = inject(Injector);
32
- this.destroyRef = inject(DestroyRef);
33
- this.dirty = signal(false, /* @ts-ignore */
34
- ...(ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []));
35
- this.pristine = signal(true, /* @ts-ignore */
36
- ...(ngDevMode ? [{ debugName: "pristine" }] : /* istanbul ignore next */ []));
37
- this.touched = signal(false, /* @ts-ignore */
38
- ...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
39
- this.untouched = signal(true, /* @ts-ignore */
40
- ...(ngDevMode ? [{ debugName: "untouched" }] : /* istanbul ignore next */ []));
41
- /** Validation state of the attached control (false when no control). */
42
- this.controlInvalid = signal(false, /* @ts-ignore */
43
- ...(ngDevMode ? [{ debugName: "controlInvalid" }] : /* istanbul ignore next */ []));
44
- /** Validation errors of the attached control (null when valid / no control). */
45
- this.controlErrors = signal(null, /* @ts-ignore */
46
- ...(ngDevMode ? [{ debugName: "controlErrors" }] : /* istanbul ignore next */ []));
47
- /** Disabled state driven by the forms API (`control.disable()`), not by the `disabled` input. */
48
- this.controlDisabled = signal(false, /* @ts-ignore */
49
- ...(ngDevMode ? [{ debugName: "controlDisabled" }] : /* istanbul ignore next */ []));
50
- /** True when the error state should be surfaced to the user. */
51
- this.showError = computed(() => this.controlInvalid() && (this.touched() || this.dirty()), /* @ts-ignore */
52
- ...(ngDevMode ? [{ debugName: "showError" }] : /* istanbul ignore next */ []));
53
- this.onChange = () => {
54
- /* noop until registered */
55
- };
56
- this.onTouched = () => {
57
- /* noop until registered */
58
- };
59
- // NgControl injects lazily (after the directive tree is built) to avoid
60
- // the classic NgControl ↔ value-accessor circular dependency.
61
- afterNextRender(() => this.watchNgControlEvents());
62
- }
63
- registerOnChange(fn) {
64
- this.onChange = fn;
65
- }
66
- registerOnTouched(fn) {
67
- this.onTouched = fn;
68
- }
69
- setDisabledState(isDisabled) {
70
- this.controlDisabled.set(isDisabled);
71
- }
72
- /** Propagate a user-driven value change to the form (view → form). */
73
- emitChange(value) {
74
- this.onChange(value);
75
- }
76
- /** Mark the control as touched (call on blur). */
77
- emitTouch() {
78
- this.onTouched();
79
- this.touched.set(true);
80
- this.untouched.set(false);
81
- }
82
- /** Mirror the NgControl state into the signals. Wired automatically; safe to call once manually if needed. */
83
- watchNgControlEvents() {
84
- const control = this.injector.get(NgControl, null, { optional: true, self: true })?.control;
85
- if (!control)
86
- return;
87
- const mirror = () => {
88
- this.pristine.set(control.pristine);
89
- this.dirty.set(control.dirty);
90
- this.touched.set(control.touched);
91
- this.untouched.set(control.untouched);
92
- this.controlInvalid.set(control.invalid);
93
- this.controlErrors.set(control.errors);
94
- };
95
- // Signal-forms interop provides a fake NgControl without an `events`
96
- // stream, but its getters read the field's signals: mirroring inside
97
- // an effect tracks them and keeps the state live.
98
- if (!control.events) {
99
- effect(mirror, { injector: this.injector });
100
- return;
101
- }
102
- // Seed with the current state (events only fire on transitions).
103
- mirror();
104
- control.events.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event) => {
105
- if (event instanceof PristineChangeEvent) {
106
- this.pristine.set(event.pristine);
107
- this.dirty.set(!event.pristine);
108
- }
109
- else if (event instanceof TouchedChangeEvent) {
110
- this.touched.set(event.touched);
111
- this.untouched.set(!event.touched);
112
- }
113
- else if (event instanceof StatusChangeEvent) {
114
- this.controlInvalid.set(event.status === 'INVALID');
115
- this.controlErrors.set(control.errors);
116
- }
117
- });
118
- }
119
- }
120
-
1
+ import * as i0 from "@angular/core";
2
+ import { DestroyRef, Directive, Injector, afterNextRender, booleanAttribute, computed, effect, inject, input, isDevMode, output, signal } from "@angular/core";
3
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
4
+ import { NgControl, PristineChangeEvent, StatusChangeEvent, TouchedChangeEvent } from "@angular/forms";
5
+ var BaseControlValueAccessor = class {
6
+ constructor() {
7
+ this.injector = inject(Injector);
8
+ this.destroyRef = inject(DestroyRef);
9
+ this.dirty = signal(false, ...ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []);
10
+ this.pristine = signal(true, ...ngDevMode ? [{ debugName: "pristine" }] : /* istanbul ignore next */ []);
11
+ this.touched = signal(false, ...ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []);
12
+ this.untouched = signal(true, ...ngDevMode ? [{ debugName: "untouched" }] : /* istanbul ignore next */ []);
13
+ this.controlInvalid = signal(false, ...ngDevMode ? [{ debugName: "controlInvalid" }] : /* istanbul ignore next */ []);
14
+ this.controlErrors = signal(null, ...ngDevMode ? [{ debugName: "controlErrors" }] : /* istanbul ignore next */ []);
15
+ this.controlDisabled = signal(false, ...ngDevMode ? [{ debugName: "controlDisabled" }] : /* istanbul ignore next */ []);
16
+ this.showError = computed(() => this.controlInvalid() && (this.touched() || this.dirty()), ...ngDevMode ? [{ debugName: "showError" }] : /* istanbul ignore next */ []);
17
+ this.onChange = () => {};
18
+ this.onTouched = () => {};
19
+ afterNextRender(() => this.watchNgControlEvents());
20
+ }
21
+ registerOnChange(fn) {
22
+ this.onChange = fn;
23
+ }
24
+ registerOnTouched(fn) {
25
+ this.onTouched = fn;
26
+ }
27
+ setDisabledState(isDisabled) {
28
+ this.controlDisabled.set(isDisabled);
29
+ }
30
+ emitChange(value) {
31
+ this.onChange(value);
32
+ }
33
+ emitTouch() {
34
+ this.onTouched();
35
+ this.touched.set(true);
36
+ this.untouched.set(false);
37
+ }
38
+ watchNgControlEvents() {
39
+ const control = this.injector.get(NgControl, null, {
40
+ optional: true,
41
+ self: true
42
+ })?.control;
43
+ if (!control) return;
44
+ const mirror = () => {
45
+ this.pristine.set(control.pristine);
46
+ this.dirty.set(control.dirty);
47
+ this.touched.set(control.touched);
48
+ this.untouched.set(control.untouched);
49
+ this.controlInvalid.set(control.invalid);
50
+ this.controlErrors.set(control.errors);
51
+ };
52
+ if (!control.events) {
53
+ effect(mirror, { injector: this.injector });
54
+ return;
55
+ }
56
+ mirror();
57
+ control.events.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event) => {
58
+ if (event instanceof PristineChangeEvent) {
59
+ this.pristine.set(event.pristine);
60
+ this.dirty.set(!event.pristine);
61
+ } else if (event instanceof TouchedChangeEvent) {
62
+ this.touched.set(event.touched);
63
+ this.untouched.set(!event.touched);
64
+ } else if (event instanceof StatusChangeEvent) {
65
+ this.controlInvalid.set(event.status === "INVALID");
66
+ this.controlErrors.set(control.errors);
67
+ }
68
+ });
69
+ }
70
+ };
121
71
  let nextUid = 0;
122
- /**
123
- * Base class for every standalone form control (`ui-checkbox`, `ui-toggle`,
124
- * `ui-slider`, `ui-nudger`…): the CVA plumbing shared by all of them, without
125
- * any "box" chrome (no label/helper/error message rendering).
126
- *
127
- * Provides the common inputs (aria*, id/name, required/disabled/readonly/
128
- * invalid, tabindex), the auto-generated id machinery (`resolvedId`,
129
- * `messageId`), the `modelValue` signal with the default `writeValue`, and the
130
- * derived `isDisabled` / `isInvalid` states. Extends `BaseControlValueAccessor`:
131
- * subclasses call `emitChange` / `emitTouch` on user interaction.
132
- *
133
- * Decorated with `@Directive()` (no selector) so the signal inputs are inherited
134
- * correctly by the concrete components.
135
- */
136
- class BaseFieldControl extends BaseControlValueAccessor {
137
- constructor() {
138
- super(...arguments);
139
- /** Accessible name when no visible label is provided. */
140
- this.ariaLabel = input(/* @ts-ignore */
141
- ...(ngDevMode ? [undefined, { debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
142
- /** id of an external element that labels this control. */
143
- this.ariaLabelledBy = input(/* @ts-ignore */
144
- ...(ngDevMode ? [undefined, { debugName: "ariaLabelledBy" }] : /* istanbul ignore next */ []));
145
- /** id forwarded to the native input (auto-generated when omitted). */
146
- this.inputId = input(/* @ts-ignore */
147
- ...(ngDevMode ? [undefined, { debugName: "inputId" }] : /* istanbul ignore next */ []));
148
- /** name forwarded to the native input. */
149
- this.name = input(/* @ts-ignore */
150
- ...(ngDevMode ? [undefined, { debugName: "name" }] : /* istanbul ignore next */ []));
151
- /** Required marker (*) + native required attribute. */
152
- this.required = input(false, { ...(ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
153
- /** Disables the field (native attribute). */
154
- this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
155
- /** Read-only (native attribute). */
156
- this.readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
157
- /** Forces the error styling (automatic when the attached control is invalid and touched/dirty). */
158
- this.invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
159
- /** tabindex forwarded to the native input. */
160
- this.tabindex = input(/* @ts-ignore */
161
- ...(ngDevMode ? [undefined, { debugName: "tabindex" }] : /* istanbul ignore next */ []));
162
- /** @ignore Auto-generated unique id (prefix branded via `uidPrefix`). */
163
- this.uid = `${this.uidPrefix()}-${nextUid++}`;
164
- /** @ignore Current value (written by the form or by user input). */
165
- this.modelValue = signal(undefined, /* @ts-ignore */
166
- ...(ngDevMode ? [{ debugName: "modelValue" }] : /* istanbul ignore next */ []));
167
- /** @ignore */
168
- this.resolvedId = computed(() => this.inputId() ?? this.uid, /* @ts-ignore */
169
- ...(ngDevMode ? [{ debugName: "resolvedId" }] : /* istanbul ignore next */ []));
170
- /** @ignore id of the message (for aria-describedby). */
171
- this.messageId = computed(() => `${this.resolvedId()}-message`, /* @ts-ignore */
172
- ...(ngDevMode ? [{ debugName: "messageId" }] : /* istanbul ignore next */ []));
173
- /** @ignore Input disabled OR control disabled (form API). */
174
- this.isDisabled = computed(() => this.disabled() || this.controlDisabled(), /* @ts-ignore */
175
- ...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
176
- /** @ignore Explicit error OR invalid control worth surfacing. */
177
- this.isInvalid = computed(() => this.invalid() || this.showError(), /* @ts-ignore */
178
- ...(ngDevMode ? [{ debugName: "isInvalid" }] : /* istanbul ignore next */ []));
179
- }
180
- writeValue(value) {
181
- this.modelValue.set(value);
182
- }
183
- /** @ignore Prefix of the auto-generated id — override to brand it per component. */
184
- uidPrefix() {
185
- return 'ui-field';
186
- }
187
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: BaseFieldControl, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
188
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.7", type: BaseFieldControl, isStandalone: true, inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "ariaLabelledBy", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", isSignal: true, isRequired: false, transformFunction: null } }, usesInheritance: true, ngImport: i0 }); }
189
- }
190
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: BaseFieldControl, decorators: [{
191
- type: Directive
192
- }], propDecorators: { ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabelledBy", required: false }] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], tabindex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabindex", required: false }] }] } });
193
- /**
194
- * Base class for "box" form fields (`ui-input`, `ui-input-number`,
195
- * `ui-input-mask`, `ui-textarea`…).
196
- *
197
- * Extends `BaseFieldControl` with the box-specific inputs (label, helper,
198
- * error, size, level) and the derived state (effective level, displayed
199
- * message/value). Subclasses only handle their own `<input>` (specific
200
- * parsing/formatting) and call `emitChange` / `emitTouch`.
201
- */
202
- class BaseFormField extends BaseFieldControl {
203
- constructor() {
204
- super(...arguments);
205
- /** Label (rendered via `ui-label`). */
206
- this.label = input(/* @ts-ignore */
207
- ...(ngDevMode ? [undefined, { debugName: "label" }] : /* istanbul ignore next */ []));
208
- /** Helper text under the field (rendered via `ui-helper`). */
209
- this.helperText = input(/* @ts-ignore */
210
- ...(ngDevMode ? [undefined, { debugName: "helperText" }] : /* istanbul ignore next */ []));
211
- /** Error message shown in place of the helper when the field is in error. */
212
- this.errorText = input(/* @ts-ignore */
213
- ...(ngDevMode ? [undefined, { debugName: "errorText" }] : /* istanbul ignore next */ []));
214
- /** Prefixes the message under the field (helper or error) with a decorative icon. */
215
- this.showMessageIcon = input(false, { ...(ngDevMode ? { debugName: "showMessageIcon" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
216
- /** Overrides the glyph shown by `showMessageIcon`. */
217
- this.messageIcon = input(/* @ts-ignore */
218
- ...(ngDevMode ? [undefined, { debugName: "messageIcon" }] : /* istanbul ignore next */ []));
219
- /** Size. */
220
- this.size = input('default', /* @ts-ignore */
221
- ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
222
- /** Explicit validation status (`error` is forced when the control is invalid + touched). */
223
- this.level = input('default', /* @ts-ignore */
224
- ...(ngDevMode ? [{ debugName: "level" }] : /* istanbul ignore next */ []));
225
- /**
226
- * Floating label placement. Unset = classic label above the box.
227
- *
228
- * The label then plays the placeholder role while at rest, so the native
229
- * `placeholder` is neutralised (see `hasFloatLabel`).
230
- */
231
- this.floatLabel = input(/* @ts-ignore */
232
- ...(ngDevMode ? [undefined, { debugName: "floatLabel" }] : /* istanbul ignore next */ []));
233
- /** @ignore There is a label to float: a `floatLabel` alone has nothing to move. */
234
- this.hasFloatLabel = computed(() => !!this.floatLabel() && !!this.label(), /* @ts-ignore */
235
- ...(ngDevMode ? [{ debugName: "hasFloatLabel" }] : /* istanbul ignore next */ []));
236
- /** @ignore Effective level: error when invalid, otherwise the requested `level`. */
237
- this.effectiveLevel = computed(() => this.isInvalid() ? 'error' : this.level(), /* @ts-ignore */
238
- ...(ngDevMode ? [{ debugName: "effectiveLevel" }] : /* istanbul ignore next */ []));
239
- /** @ignore Displayed message: errorText when in error (if provided), otherwise helperText. */
240
- this.displayMessage = computed(() => this.isInvalid() && this.errorText() ? this.errorText() : this.helperText(), /* @ts-ignore */
241
- ...(ngDevMode ? [{ debugName: "displayMessage" }] : /* istanbul ignore next */ []));
242
- /** @ignore Value shown in the input (string). Override for specific formatting. */
243
- this.displayValue = computed(() => {
244
- const v = this.modelValue();
245
- return v === undefined || v === null ? '' : String(v);
246
- }, /* @ts-ignore */
247
- ...(ngDevMode ? [{ debugName: "displayValue" }] : /* istanbul ignore next */ []));
248
- }
249
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: BaseFormField, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
250
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.7", type: BaseFormField, isStandalone: true, inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, helperText: { classPropertyName: "helperText", publicName: "helperText", isSignal: true, isRequired: false, transformFunction: null }, errorText: { classPropertyName: "errorText", publicName: "errorText", isSignal: true, isRequired: false, transformFunction: null }, showMessageIcon: { classPropertyName: "showMessageIcon", publicName: "showMessageIcon", isSignal: true, isRequired: false, transformFunction: null }, messageIcon: { classPropertyName: "messageIcon", publicName: "messageIcon", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, level: { classPropertyName: "level", publicName: "level", isSignal: true, isRequired: false, transformFunction: null }, floatLabel: { classPropertyName: "floatLabel", publicName: "floatLabel", isSignal: true, isRequired: false, transformFunction: null } }, usesInheritance: true, ngImport: i0 }); }
251
- }
252
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: BaseFormField, decorators: [{
253
- type: Directive
254
- }], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], helperText: [{ type: i0.Input, args: [{ isSignal: true, alias: "helperText", required: false }] }], errorText: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorText", required: false }] }], showMessageIcon: [{ type: i0.Input, args: [{ isSignal: true, alias: "showMessageIcon", required: false }] }], messageIcon: [{ type: i0.Input, args: [{ isSignal: true, alias: "messageIcon", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], level: [{ type: i0.Input, args: [{ isSignal: true, alias: "level", required: false }] }], floatLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "floatLabel", required: false }] }] } });
255
-
256
- /**
257
- * Standard dropdown-panel anchoring shared by the overlay form fields
258
- * (`ui-select`, `ui-autocomplete`, `ui-input-tags`, `ui-datepicker`):
259
- * below the field, flipped above when `autoFlip`, flipped horizontally
260
- * (right-aligned) whenever there isn't enough room on the right.
261
- */
72
+ var BaseFieldControl = class BaseFieldControl extends BaseControlValueAccessor {
73
+ constructor() {
74
+ super(...arguments);
75
+ this.ariaLabel = input(...ngDevMode ? [void 0, { debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
76
+ this.ariaLabelledBy = input(...ngDevMode ? [void 0, { debugName: "ariaLabelledBy" }] : /* istanbul ignore next */ []);
77
+ this.inputId = input(...ngDevMode ? [void 0, { debugName: "inputId" }] : /* istanbul ignore next */ []);
78
+ this.name = input(...ngDevMode ? [void 0, { debugName: "name" }] : /* istanbul ignore next */ []);
79
+ this.required = input(false, {
80
+ ...ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {},
81
+ transform: booleanAttribute
82
+ });
83
+ this.disabled = input(false, {
84
+ ...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
85
+ transform: booleanAttribute
86
+ });
87
+ this.readonly = input(false, {
88
+ ...ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {},
89
+ transform: booleanAttribute
90
+ });
91
+ this.invalid = input(false, {
92
+ ...ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {},
93
+ transform: booleanAttribute
94
+ });
95
+ this.tabindex = input(...ngDevMode ? [void 0, { debugName: "tabindex" }] : /* istanbul ignore next */ []);
96
+ this.uid = `${this.uidPrefix()}-${nextUid++}`;
97
+ this.modelValue = signal(void 0, ...ngDevMode ? [{ debugName: "modelValue" }] : /* istanbul ignore next */ []);
98
+ this.resolvedId = computed(() => this.inputId() ?? this.uid, ...ngDevMode ? [{ debugName: "resolvedId" }] : /* istanbul ignore next */ []);
99
+ this.messageId = computed(() => `${this.resolvedId()}-message`, ...ngDevMode ? [{ debugName: "messageId" }] : /* istanbul ignore next */ []);
100
+ this.isDisabled = computed(() => this.disabled() || this.controlDisabled(), ...ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []);
101
+ this.isInvalid = computed(() => this.invalid() || this.showError(), ...ngDevMode ? [{ debugName: "isInvalid" }] : /* istanbul ignore next */ []);
102
+ }
103
+ writeValue(value) {
104
+ this.modelValue.set(value);
105
+ }
106
+ uidPrefix() {
107
+ return "ui-field";
108
+ }
109
+ static {
110
+ this.ɵfac = i0.ɵɵngDeclareFactory({
111
+ minVersion: "12.0.0",
112
+ version: "22.3.0",
113
+ ngImport: i0,
114
+ type: BaseFieldControl,
115
+ deps: null,
116
+ target: i0.ɵɵFactoryTarget.Directive
117
+ });
118
+ }
119
+ static {
120
+ this.ɵdir = i0.ɵɵngDeclareDirective({
121
+ minVersion: "17.1.0",
122
+ version: "22.3.0",
123
+ type: BaseFieldControl,
124
+ isStandalone: true,
125
+ inputs: {
126
+ ariaLabel: {
127
+ classPropertyName: "ariaLabel",
128
+ publicName: "ariaLabel",
129
+ isSignal: true,
130
+ isRequired: false,
131
+ transformFunction: null
132
+ },
133
+ ariaLabelledBy: {
134
+ classPropertyName: "ariaLabelledBy",
135
+ publicName: "ariaLabelledBy",
136
+ isSignal: true,
137
+ isRequired: false,
138
+ transformFunction: null
139
+ },
140
+ inputId: {
141
+ classPropertyName: "inputId",
142
+ publicName: "inputId",
143
+ isSignal: true,
144
+ isRequired: false,
145
+ transformFunction: null
146
+ },
147
+ name: {
148
+ classPropertyName: "name",
149
+ publicName: "name",
150
+ isSignal: true,
151
+ isRequired: false,
152
+ transformFunction: null
153
+ },
154
+ required: {
155
+ classPropertyName: "required",
156
+ publicName: "required",
157
+ isSignal: true,
158
+ isRequired: false,
159
+ transformFunction: null
160
+ },
161
+ disabled: {
162
+ classPropertyName: "disabled",
163
+ publicName: "disabled",
164
+ isSignal: true,
165
+ isRequired: false,
166
+ transformFunction: null
167
+ },
168
+ readonly: {
169
+ classPropertyName: "readonly",
170
+ publicName: "readonly",
171
+ isSignal: true,
172
+ isRequired: false,
173
+ transformFunction: null
174
+ },
175
+ invalid: {
176
+ classPropertyName: "invalid",
177
+ publicName: "invalid",
178
+ isSignal: true,
179
+ isRequired: false,
180
+ transformFunction: null
181
+ },
182
+ tabindex: {
183
+ classPropertyName: "tabindex",
184
+ publicName: "tabindex",
185
+ isSignal: true,
186
+ isRequired: false,
187
+ transformFunction: null
188
+ }
189
+ },
190
+ usesInheritance: true,
191
+ ngImport: i0
192
+ });
193
+ }
194
+ };
195
+ i0.ɵɵngDeclareClassMetadata({
196
+ minVersion: "12.0.0",
197
+ version: "22.3.0",
198
+ ngImport: i0,
199
+ type: BaseFieldControl,
200
+ decorators: [{ type: Directive }],
201
+ propDecorators: {
202
+ ariaLabel: [{
203
+ type: i0.Input,
204
+ args: [{
205
+ isSignal: true,
206
+ alias: "ariaLabel",
207
+ required: false
208
+ }]
209
+ }],
210
+ ariaLabelledBy: [{
211
+ type: i0.Input,
212
+ args: [{
213
+ isSignal: true,
214
+ alias: "ariaLabelledBy",
215
+ required: false
216
+ }]
217
+ }],
218
+ inputId: [{
219
+ type: i0.Input,
220
+ args: [{
221
+ isSignal: true,
222
+ alias: "inputId",
223
+ required: false
224
+ }]
225
+ }],
226
+ name: [{
227
+ type: i0.Input,
228
+ args: [{
229
+ isSignal: true,
230
+ alias: "name",
231
+ required: false
232
+ }]
233
+ }],
234
+ required: [{
235
+ type: i0.Input,
236
+ args: [{
237
+ isSignal: true,
238
+ alias: "required",
239
+ required: false
240
+ }]
241
+ }],
242
+ disabled: [{
243
+ type: i0.Input,
244
+ args: [{
245
+ isSignal: true,
246
+ alias: "disabled",
247
+ required: false
248
+ }]
249
+ }],
250
+ readonly: [{
251
+ type: i0.Input,
252
+ args: [{
253
+ isSignal: true,
254
+ alias: "readonly",
255
+ required: false
256
+ }]
257
+ }],
258
+ invalid: [{
259
+ type: i0.Input,
260
+ args: [{
261
+ isSignal: true,
262
+ alias: "invalid",
263
+ required: false
264
+ }]
265
+ }],
266
+ tabindex: [{
267
+ type: i0.Input,
268
+ args: [{
269
+ isSignal: true,
270
+ alias: "tabindex",
271
+ required: false
272
+ }]
273
+ }]
274
+ }
275
+ });
276
+ var BaseFormField = class BaseFormField extends BaseFieldControl {
277
+ constructor() {
278
+ super(...arguments);
279
+ this.label = input(...ngDevMode ? [void 0, { debugName: "label" }] : /* istanbul ignore next */ []);
280
+ this.helperText = input(...ngDevMode ? [void 0, { debugName: "helperText" }] : /* istanbul ignore next */ []);
281
+ this.errorText = input(...ngDevMode ? [void 0, { debugName: "errorText" }] : /* istanbul ignore next */ []);
282
+ this.showMessageIcon = input(false, {
283
+ ...ngDevMode ? { debugName: "showMessageIcon" } : /* istanbul ignore next */ {},
284
+ transform: booleanAttribute
285
+ });
286
+ this.messageIcon = input(...ngDevMode ? [void 0, { debugName: "messageIcon" }] : /* istanbul ignore next */ []);
287
+ this.size = input("default", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
288
+ this.level = input("default", ...ngDevMode ? [{ debugName: "level" }] : /* istanbul ignore next */ []);
289
+ this.floatLabel = input(...ngDevMode ? [void 0, { debugName: "floatLabel" }] : /* istanbul ignore next */ []);
290
+ this.hasFloatLabel = computed(() => !!this.floatLabel() && !!this.label(), ...ngDevMode ? [{ debugName: "hasFloatLabel" }] : /* istanbul ignore next */ []);
291
+ this.effectiveLevel = computed(() => this.isInvalid() ? "error" : this.level(), ...ngDevMode ? [{ debugName: "effectiveLevel" }] : /* istanbul ignore next */ []);
292
+ this.displayMessage = computed(() => this.isInvalid() && this.errorText() ? this.errorText() : this.helperText(), ...ngDevMode ? [{ debugName: "displayMessage" }] : /* istanbul ignore next */ []);
293
+ this.displayValue = computed(() => {
294
+ const v = this.modelValue();
295
+ return v === void 0 || v === null ? "" : String(v);
296
+ }, ...ngDevMode ? [{ debugName: "displayValue" }] : /* istanbul ignore next */ []);
297
+ }
298
+ static {
299
+ this.ɵfac = i0.ɵɵngDeclareFactory({
300
+ minVersion: "12.0.0",
301
+ version: "22.3.0",
302
+ ngImport: i0,
303
+ type: BaseFormField,
304
+ deps: null,
305
+ target: i0.ɵɵFactoryTarget.Directive
306
+ });
307
+ }
308
+ static {
309
+ this.ɵdir = i0.ɵɵngDeclareDirective({
310
+ minVersion: "17.1.0",
311
+ version: "22.3.0",
312
+ type: BaseFormField,
313
+ isStandalone: true,
314
+ inputs: {
315
+ label: {
316
+ classPropertyName: "label",
317
+ publicName: "label",
318
+ isSignal: true,
319
+ isRequired: false,
320
+ transformFunction: null
321
+ },
322
+ helperText: {
323
+ classPropertyName: "helperText",
324
+ publicName: "helperText",
325
+ isSignal: true,
326
+ isRequired: false,
327
+ transformFunction: null
328
+ },
329
+ errorText: {
330
+ classPropertyName: "errorText",
331
+ publicName: "errorText",
332
+ isSignal: true,
333
+ isRequired: false,
334
+ transformFunction: null
335
+ },
336
+ showMessageIcon: {
337
+ classPropertyName: "showMessageIcon",
338
+ publicName: "showMessageIcon",
339
+ isSignal: true,
340
+ isRequired: false,
341
+ transformFunction: null
342
+ },
343
+ messageIcon: {
344
+ classPropertyName: "messageIcon",
345
+ publicName: "messageIcon",
346
+ isSignal: true,
347
+ isRequired: false,
348
+ transformFunction: null
349
+ },
350
+ size: {
351
+ classPropertyName: "size",
352
+ publicName: "size",
353
+ isSignal: true,
354
+ isRequired: false,
355
+ transformFunction: null
356
+ },
357
+ level: {
358
+ classPropertyName: "level",
359
+ publicName: "level",
360
+ isSignal: true,
361
+ isRequired: false,
362
+ transformFunction: null
363
+ },
364
+ floatLabel: {
365
+ classPropertyName: "floatLabel",
366
+ publicName: "floatLabel",
367
+ isSignal: true,
368
+ isRequired: false,
369
+ transformFunction: null
370
+ }
371
+ },
372
+ usesInheritance: true,
373
+ ngImport: i0
374
+ });
375
+ }
376
+ };
377
+ i0.ɵɵngDeclareClassMetadata({
378
+ minVersion: "12.0.0",
379
+ version: "22.3.0",
380
+ ngImport: i0,
381
+ type: BaseFormField,
382
+ decorators: [{ type: Directive }],
383
+ propDecorators: {
384
+ label: [{
385
+ type: i0.Input,
386
+ args: [{
387
+ isSignal: true,
388
+ alias: "label",
389
+ required: false
390
+ }]
391
+ }],
392
+ helperText: [{
393
+ type: i0.Input,
394
+ args: [{
395
+ isSignal: true,
396
+ alias: "helperText",
397
+ required: false
398
+ }]
399
+ }],
400
+ errorText: [{
401
+ type: i0.Input,
402
+ args: [{
403
+ isSignal: true,
404
+ alias: "errorText",
405
+ required: false
406
+ }]
407
+ }],
408
+ showMessageIcon: [{
409
+ type: i0.Input,
410
+ args: [{
411
+ isSignal: true,
412
+ alias: "showMessageIcon",
413
+ required: false
414
+ }]
415
+ }],
416
+ messageIcon: [{
417
+ type: i0.Input,
418
+ args: [{
419
+ isSignal: true,
420
+ alias: "messageIcon",
421
+ required: false
422
+ }]
423
+ }],
424
+ size: [{
425
+ type: i0.Input,
426
+ args: [{
427
+ isSignal: true,
428
+ alias: "size",
429
+ required: false
430
+ }]
431
+ }],
432
+ level: [{
433
+ type: i0.Input,
434
+ args: [{
435
+ isSignal: true,
436
+ alias: "level",
437
+ required: false
438
+ }]
439
+ }],
440
+ floatLabel: [{
441
+ type: i0.Input,
442
+ args: [{
443
+ isSignal: true,
444
+ alias: "floatLabel",
445
+ required: false
446
+ }]
447
+ }]
448
+ }
449
+ });
262
450
  function dropdownOverlayPositions(autoFlip) {
263
- const belowStart = {
264
- originX: 'start',
265
- originY: 'bottom',
266
- overlayX: 'start',
267
- overlayY: 'top',
268
- offsetY: 8,
269
- };
270
- const belowEnd = {
271
- originX: 'end',
272
- originY: 'bottom',
273
- overlayX: 'end',
274
- overlayY: 'top',
275
- offsetY: 8,
276
- };
277
- const aboveStart = {
278
- originX: 'start',
279
- originY: 'top',
280
- overlayX: 'start',
281
- overlayY: 'bottom',
282
- offsetY: -8,
283
- };
284
- const aboveEnd = {
285
- originX: 'end',
286
- originY: 'top',
287
- overlayX: 'end',
288
- overlayY: 'bottom',
289
- offsetY: -8,
290
- };
291
- return autoFlip ? [belowStart, belowEnd, aboveStart, aboveEnd] : [belowStart, belowEnd];
451
+ const belowStart = {
452
+ originX: "start",
453
+ originY: "bottom",
454
+ overlayX: "start",
455
+ overlayY: "top",
456
+ offsetY: 8
457
+ };
458
+ const belowEnd = {
459
+ originX: "end",
460
+ originY: "bottom",
461
+ overlayX: "end",
462
+ overlayY: "top",
463
+ offsetY: 8
464
+ };
465
+ return autoFlip ? [
466
+ belowStart,
467
+ belowEnd,
468
+ {
469
+ originX: "start",
470
+ originY: "top",
471
+ overlayX: "start",
472
+ overlayY: "bottom",
473
+ offsetY: -8
474
+ },
475
+ {
476
+ originX: "end",
477
+ originY: "top",
478
+ overlayX: "end",
479
+ overlayY: "bottom",
480
+ offsetY: -8
481
+ }
482
+ ] : [belowStart, belowEnd];
292
483
  }
293
-
294
- /**
295
- * Pure masking engine shared by `ui-input-mask` and `ui-datepicker` (auto-formatting the typed
296
- * date). Same precedent as `overlay-positions.ts` in this folder: framework-free functions, no
297
- * class/Directive/Component, reusable by any form component that needs literal-inserting input
298
- * masking. Extracted from `ui-input-mask.ts` — behavior is a byte-for-byte copy, only `this.mask()`
299
- * /`this.ranges()`/`this.slotChar()` become explicit parameters.
300
- */
301
- /** Mask tokens → accepted character class. */
302
484
  const MASK_TOKENS = {
303
- '9': /[0-9]/, // digit
304
- a: /[a-zA-Z]/, // letter
305
- '*': /[a-zA-Z0-9]/, // alphanumeric
485
+ "9": /[0-9]/,
486
+ a: /[a-zA-Z]/,
487
+ "*": /[a-zA-Z0-9]/
306
488
  };
307
- /** Parse the `ranges` input (`"1-31 1-12 1900-2100"`) into one bound per numeric segment. */
308
489
  function parseMaskRanges(ranges) {
309
- return ranges
310
- .trim()
311
- .split(/\s+/)
312
- .map((part) => {
313
- const m = /^(\d+)-(\d+)$/.exec(part);
314
- return m ? { min: Number(m[1]), max: Number(m[2]) } : null;
315
- });
490
+ return ranges.trim().split(/\s+/).map((part) => {
491
+ const m = /^(\d+)-(\d+)$/.exec(part);
492
+ return m ? {
493
+ min: Number(m[1]),
494
+ max: Number(m[2])
495
+ } : null;
496
+ });
316
497
  }
317
- /**
318
- * Resolve the mask template into slots: literals, input slots, and the `ranges` bounds attached
319
- * to every slot of the numeric segment (consecutive `9` tokens) it belongs to.
320
- */
321
498
  function buildMaskSlots(mask, bounds, tokens = MASK_TOKENS) {
322
- const slots = [];
323
- const segments = [];
324
- let segment = null;
325
- for (const m of mask) {
326
- const rgx = tokens[m];
327
- const slot = rgx ? { char: null, rgx } : { char: m };
328
- slots.push(slot);
329
- if (rgx && m === '9') {
330
- if (!segment)
331
- segments.push((segment = []));
332
- segment.push(slot);
333
- }
334
- else {
335
- segment = null;
336
- }
337
- }
338
- // Every segment gets a `.bound`, even unranged ones (±Infinity = no-op range): `pos`/`len` are
339
- // needed for `atSegmentEnd` regardless, else an unranged segment (e.g. ui-datepicker's year)
340
- // never auto-inserts its own following literal (FSHSP-118).
341
- segments.forEach((seg, i) => {
342
- const range = bounds[i] ?? { min: -Infinity, max: Infinity };
343
- seg.forEach((slot, pos) => (slot.bound = { ...range, pos, len: seg.length }));
344
- });
345
- return slots;
499
+ const slots = [];
500
+ const segments = [];
501
+ let segment = null;
502
+ for (const m of mask) {
503
+ const rgx = tokens[m];
504
+ const slot = rgx ? {
505
+ char: null,
506
+ rgx
507
+ } : { char: m };
508
+ slots.push(slot);
509
+ if (rgx && m === "9") {
510
+ if (!segment) segments.push(segment = []);
511
+ segment.push(slot);
512
+ } else segment = null;
513
+ }
514
+ segments.forEach((seg, i) => {
515
+ const range = bounds[i] ?? {
516
+ min: -Infinity,
517
+ max: Infinity
518
+ };
519
+ seg.forEach((slot, pos) => slot.bound = {
520
+ ...range,
521
+ pos,
522
+ len: seg.length
523
+ });
524
+ });
525
+ return slots;
346
526
  }
347
- /** Keep only the data characters (alphanumeric) of a raw input string. */
348
527
  function extractMaskData(raw) {
349
- return raw.replace(/[^a-zA-Z0-9]/g, '');
528
+ return raw.replace(/[^a-zA-Z0-9]/g, "");
350
529
  }
351
- /**
352
- * Can `ch` fill this slot? It must match the token class and — when the segment is bounded
353
- * AND `enforceBounds` — the digits typed so far plus `ch` must still admit at least one in-range
354
- * completion of the remaining positions (`2` then `4` is refused on `0-23`, `2` then `3` is
355
- * accepted).
356
- *
357
- * `enforceBounds = false` skips that second check (still requires the token class to match):
358
- * meant for re-deriving the mask after characters were REMOVED, not typed. The bounds check
359
- * exists to reject an invalid *new* leading digit while typing forward (e.g. `8` can never start
360
- * a valid `1-31` day, so it's skipped rather than accepted) — applied instead to the digits left
361
- * over after a deletion, that same skip can discard a still-valid residual digit and misalign
362
- * every segment after it. See `autoFormatSegments`.
363
- */
364
530
  function acceptsMaskChar(slot, segment, ch, enforceBounds = true) {
365
- if (!slot.rgx?.test(ch))
366
- return false;
367
- const bound = slot.bound;
368
- if (!enforceBounds || !bound)
369
- return true;
370
- const scale = 10 ** (bound.len - bound.pos - 1);
371
- const low = Number(segment + ch) * scale;
372
- return low <= bound.max && low + scale - 1 >= bound.min;
531
+ if (!slot.rgx?.test(ch)) return false;
532
+ const bound = slot.bound;
533
+ if (!enforceBounds || !bound) return true;
534
+ const scale = 10 ** (bound.len - bound.pos - 1);
535
+ const low = Number(segment + ch) * scale;
536
+ return low <= bound.max && low + scale - 1 >= bound.min;
373
537
  }
374
- /** Apply the mask template to a sequence of data characters (fills empty positions with `slotChar`). */
375
538
  function applyMaskTemplate(slots, data, slotChar) {
376
- let di = 0;
377
- let display = '';
378
- let masked = '';
379
- let lastFilled = 0;
380
- let used = '';
381
- const tokenIndices = [];
382
- // Characters already accepted in the current numeric segment (drives the bounds check).
383
- let segment = '';
384
- for (const slot of slots) {
385
- if (slot.char !== null) {
386
- display += slot.char;
387
- masked += slot.char;
388
- continue;
389
- }
390
- tokenIndices.push(display.length); // index of this token position in `display`
391
- if (!slot.bound || slot.bound.pos === 0)
392
- segment = '';
393
- while (di < data.length && !acceptsMaskChar(slot, segment, data[di]))
394
- di++;
395
- if (di < data.length) {
396
- display += data[di];
397
- masked += data[di];
398
- used += data[di];
399
- if (slot.bound)
400
- segment += data[di];
401
- di++;
402
- lastFilled = masked.length;
403
- }
404
- else {
405
- display += slotChar;
406
- }
407
- }
408
- // Masked value = up to the last typed character (no trailing literals/slots).
409
- return { display, masked: masked.slice(0, lastFilled), data: used, tokenIndices };
539
+ let di = 0;
540
+ let display = "";
541
+ let masked = "";
542
+ let lastFilled = 0;
543
+ let used = "";
544
+ const tokenIndices = [];
545
+ let segment = "";
546
+ for (const slot of slots) {
547
+ if (slot.char !== null) {
548
+ display += slot.char;
549
+ masked += slot.char;
550
+ continue;
551
+ }
552
+ tokenIndices.push(display.length);
553
+ if (!slot.bound || slot.bound.pos === 0) segment = "";
554
+ while (di < data.length && !acceptsMaskChar(slot, segment, data[di])) di++;
555
+ if (di < data.length) {
556
+ display += data[di];
557
+ masked += data[di];
558
+ used += data[di];
559
+ if (slot.bound) segment += data[di];
560
+ di++;
561
+ lastFilled = masked.length;
562
+ } else display += slotChar;
563
+ }
564
+ return {
565
+ display,
566
+ masked: masked.slice(0, lastFilled),
567
+ data: used,
568
+ tokenIndices
569
+ };
410
570
  }
411
- /** Caret position for `n` typed data characters (literals skipped, end-of-text once all filled). */
412
571
  function caretForMask(tokenIndices, n, length) {
413
- if (n <= 0)
414
- return tokenIndices[0] ?? 0;
415
- if (n >= tokenIndices.length)
416
- return length; // all filled → end
417
- return tokenIndices[n]; // next input position (literals skipped)
572
+ if (n <= 0) return tokenIndices[0] ?? 0;
573
+ if (n >= tokenIndices.length) return length;
574
+ return tokenIndices[n];
418
575
  }
419
- /**
420
- * Auto-format-as-you-type variant of {@link applyMaskTemplate}: inserts a literal separator as
421
- * soon as the segment right before it is complete, without ever padding unfilled positions with
422
- * a filler character (unlike `applyMaskTemplate`, meant for a field that displays the full
423
- * template at rest). Used by `ui-datepicker`'s typeable trigger to auto-insert "/" as digits are
424
- * typed, the same way a card-expiry field auto-inserts its "/".
425
- */
426
576
  function autoFormatSegments(slots, data, { enforceBounds = true } = {}) {
427
- let di = 0;
428
- let text = '';
429
- let segment = '';
430
- let atSegmentEnd = false;
431
- const tokenIndices = [];
432
- // Position right after the last DATA character appended — unlike `text.length`, never lands
433
- // after a separator inserted eagerly (see the "auto-insert" doc above) with nothing typed past
434
- // it yet. Landing the caret there instead (see call sites) means a Backspace right after a
435
- // just-completed segment removes that segment's last digit, not the decorative separator —
436
- // which would otherwise be silently re-inserted next render, making Backspace look like it did
437
- // nothing (FSHSP-118).
438
- let dataEnd = 0;
439
- for (const slot of slots) {
440
- if (slot.char !== null) {
441
- // Append EVERY consecutive literal after a completed segment, not just the first — needed
442
- // for a multi-char separator like range's " - " (FSHSP-118). `atSegmentEnd` is left as-is
443
- // here; the next digit slot always resets it before it's read again.
444
- if (atSegmentEnd)
445
- text += slot.char;
446
- continue;
447
- }
448
- tokenIndices.push(text.length);
449
- if (!slot.bound || slot.bound.pos === 0)
450
- segment = '';
451
- while (di < data.length && !acceptsMaskChar(slot, segment, data[di], enforceBounds))
452
- di++;
453
- if (di >= data.length)
454
- break; // no more data: stop, no filler
455
- text += data[di];
456
- dataEnd = text.length;
457
- if (slot.bound)
458
- segment += data[di];
459
- atSegmentEnd = !!slot.bound && slot.bound.pos === slot.bound.len - 1;
460
- di++;
461
- }
462
- return { text, tokenIndices, dataEnd };
577
+ let di = 0;
578
+ let text = "";
579
+ let segment = "";
580
+ let atSegmentEnd = false;
581
+ const tokenIndices = [];
582
+ let dataEnd = 0;
583
+ for (const slot of slots) {
584
+ if (slot.char !== null) {
585
+ if (atSegmentEnd) text += slot.char;
586
+ continue;
587
+ }
588
+ tokenIndices.push(text.length);
589
+ if (!slot.bound || slot.bound.pos === 0) segment = "";
590
+ while (di < data.length && !acceptsMaskChar(slot, segment, data[di], enforceBounds)) di++;
591
+ if (di >= data.length) break;
592
+ text += data[di];
593
+ dataEnd = text.length;
594
+ if (slot.bound) segment += data[di];
595
+ atSegmentEnd = !!slot.bound && slot.bound.pos === slot.bound.len - 1;
596
+ di++;
597
+ }
598
+ return {
599
+ text,
600
+ tokenIndices,
601
+ dataEnd
602
+ };
463
603
  }
464
-
465
- /**
466
- * Pure date helpers (no framework dependency), shared by every field that has to cross
467
- * the `Date` ↔ ISO-string boundary — `ui-datepicker`, which parses what the user types,
468
- * and `ui-input-date`, which reads what the browser's native picker hands back.
469
- *
470
- * They lived inside `ui-datepicker`'s entry point while it was the only caller (FSHSP-209
471
- * moved them here). Two entry points must never import each other, so the second caller
472
- * left one choice: the shared `forms/` entry point, which exists for exactly this — the
473
- * helpers a field is built on. Serializing a `Date` from its LOCAL components rather than
474
- * through `toISOString()` is the subtle part, and it must not be re-derived twice.
475
- */
476
604
  function startOfDay(d) {
477
- const x = new Date(d);
478
- x.setHours(0, 0, 0, 0);
479
- return x;
605
+ const x = new Date(d);
606
+ x.setHours(0, 0, 0, 0);
607
+ return x;
480
608
  }
481
609
  function firstOfMonth(d) {
482
- return new Date(d.getFullYear(), d.getMonth(), 1);
610
+ return new Date(d.getFullYear(), d.getMonth(), 1);
483
611
  }
484
612
  function isSameDay(a, b) {
485
- if (!a || !b)
486
- return false;
487
- return (a.getFullYear() === b.getFullYear() &&
488
- a.getMonth() === b.getMonth() &&
489
- a.getDate() === b.getDate());
613
+ if (!a || !b) return false;
614
+ return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
490
615
  }
491
616
  function addDays(d, n) {
492
- const x = new Date(d);
493
- x.setDate(x.getDate() + n);
494
- return x;
617
+ const x = new Date(d);
618
+ x.setDate(x.getDate() + n);
619
+ return x;
495
620
  }
496
621
  function addMonths(d, n) {
497
- return new Date(d.getFullYear(), d.getMonth() + n, 1);
622
+ return new Date(d.getFullYear(), d.getMonth() + n, 1);
498
623
  }
499
- /** Build a Date and reject overflowed components (e.g. 31 Feb). */
500
624
  function finalizeParsed(year, month, day, h, min) {
501
- if (month < 0 || month > 11 || day < 1 || day > 31 || h > 23 || min > 59)
502
- return null;
503
- const d = new Date(year, month, day, h, min, 0, 0);
504
- if (d.getFullYear() !== year || d.getMonth() !== month || d.getDate() !== day)
505
- return null;
506
- return d;
625
+ if (month < 0 || month > 11 || day < 1 || day > 31 || h > 23 || min > 59) return null;
626
+ const d = new Date(year, month, day, h, min, 0, 0);
627
+ if (d.getFullYear() !== year || d.getMonth() !== month || d.getDate() !== day) return null;
628
+ return d;
507
629
  }
508
630
  const ISO_DATE_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
509
631
  const ISO_DATETIME_RE = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/;
510
632
  const ISO_TIME_RE = /^(\d{2}):(\d{2})$/;
511
633
  function pad2(n) {
512
- return String(n).padStart(2, '0');
634
+ return String(n).padStart(2, "0");
513
635
  }
514
- /** Serialize a `Date` to `"yyyy-MM-dd"` from its LOCAL components — never `toISOString()`
515
- * (which converts to UTC and can shift the day by ±1 depending on the timezone). */
516
636
  function toIsoDate(d) {
517
- return `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;
637
+ return `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;
518
638
  }
519
- /** `"HH:mm"` — the shape a native `<input type="time">` reads and writes. */
520
639
  function toIsoTime(d) {
521
- return `${pad2(d.getHours())}:${pad2(d.getMinutes())}`;
640
+ return `${pad2(d.getHours())}:${pad2(d.getMinutes())}`;
522
641
  }
523
- /** `"yyyy-MM-ddTHH:mm"` — date part built the same local, never-UTC way as {@link toIsoDate}. */
524
642
  function toIsoDateTime(d) {
525
- return `${toIsoDate(d)}T${pad2(d.getHours())}:${pad2(d.getMinutes())}`;
643
+ return `${toIsoDate(d)}T${pad2(d.getHours())}:${pad2(d.getMinutes())}`;
526
644
  }
527
- /** Strict `"yyyy-MM-dd"` parser (rejects anything else, incl. overflowed dates via `finalizeParsed`). */
528
645
  function parseIsoDate(s) {
529
- const m = ISO_DATE_RE.exec(s);
530
- if (!m)
531
- return null;
532
- return finalizeParsed(Number(m[1]), Number(m[2]) - 1, Number(m[3]), 0, 0);
646
+ const m = ISO_DATE_RE.exec(s);
647
+ if (!m) return null;
648
+ return finalizeParsed(Number(m[1]), Number(m[2]) - 1, Number(m[3]), 0, 0);
533
649
  }
534
- /** Strict `"yyyy-MM-ddTHH:mm"` parser (`showTime`/`timeOnly` round-trip). */
535
650
  function parseIsoDateTime(s) {
536
- const m = ISO_DATETIME_RE.exec(s);
537
- if (!m)
538
- return null;
539
- return finalizeParsed(Number(m[1]), Number(m[2]) - 1, Number(m[3]), Number(m[4]), Number(m[5]));
651
+ const m = ISO_DATETIME_RE.exec(s);
652
+ if (!m) return null;
653
+ return finalizeParsed(Number(m[1]), Number(m[2]) - 1, Number(m[3]), Number(m[4]), Number(m[5]));
540
654
  }
541
- /**
542
- * Strict `"HH:mm"` parser, anchored on `reference` (default: today).
543
- *
544
- * A bare time is not a point in time; the caller has to say on which day it lands. Mirrors
545
- * what `ui-datepicker` does in `timeOnly` mode — it too carries a full `Date` — so both
546
- * components hand back the same shape.
547
- */
548
- function parseIsoTime(s, reference = new Date()) {
549
- const m = ISO_TIME_RE.exec(s);
550
- if (!m)
551
- return null;
552
- return finalizeParsed(reference.getFullYear(), reference.getMonth(), reference.getDate(), Number(m[1]), Number(m[2]));
655
+ function parseIsoTime(s, reference = /* @__PURE__ */ new Date()) {
656
+ const m = ISO_TIME_RE.exec(s);
657
+ if (!m) return null;
658
+ return finalizeParsed(reference.getFullYear(), reference.getMonth(), reference.getDate(), Number(m[1]), Number(m[2]));
553
659
  }
554
- /** Accepts a `Date` as-is, or parses a `"yyyy-MM-dd"` string — used to let config inputs
555
- * (`minDate`/`maxDate`/`disabledDates`) take either shape. Invalid strings degrade to `null`
556
- * (no constraint) rather than throwing: a malformed config shouldn't crash the picker. */
557
660
  function normalizeDateInput(v) {
558
- if (!v)
559
- return null;
560
- return v instanceof Date ? v : parseIsoDate(v);
661
+ if (!v) return null;
662
+ return v instanceof Date ? v : parseIsoDate(v);
561
663
  }
562
-
563
- /**
564
- * Shared option-resolution helpers for list-based form fields
565
- * (`ui-select`, `ui-autocomplete`, `ui-input-tags`).
566
- *
567
- * Options can be primitives or objects; `optionValue` / `optionLabel` /
568
- * `optionDisabled` are (dot-path) fields read on object options, and `dataKey`
569
- * drives object equality. The accessors are passed as thunks so the resolver
570
- * stays reactive when bound to signal inputs.
571
- */
572
664
  function createOptionResolver(fields) {
573
- const isObject = (option) => typeof option === 'object' && option !== null;
574
- const getField = (target, path) => {
575
- if (!path || !isObject(target))
576
- return undefined;
577
- return path
578
- .split('.')
579
- .reduce((acc, key) => (isObject(acc) ? acc[key] : undefined), target);
580
- };
581
- const asText = (value) => value === null || value === undefined ? null : String(value);
582
- const resolveValue = (option) => {
583
- const field = fields.optionValue();
584
- if (field && isObject(option))
585
- return getField(option, field);
586
- return option;
587
- };
588
- const resolveLabel = (option) => {
589
- const field = fields.optionLabel();
590
- if (field && isObject(option))
591
- return asText(getField(option, field));
592
- if (isObject(option) && 'label' in option)
593
- return asText(option['label']);
594
- return asText(option);
595
- };
596
- const resolveDisabled = (option) => {
597
- const field = fields.optionDisabled();
598
- if (field && isObject(option))
599
- return !!getField(option, field);
600
- if (isObject(option) && 'disabled' in option)
601
- return !!option['disabled'];
602
- return false;
603
- };
604
- const equals = (a, b) => {
605
- const key = fields.dataKey();
606
- if (key && isObject(a) && isObject(b))
607
- return a[key] === b[key];
608
- return a === b;
609
- };
610
- const toEntry = (option) => ({
611
- value: resolveValue(option),
612
- label: resolveLabel(option) ?? '',
613
- disabled: resolveDisabled(option),
614
- original: option,
615
- });
616
- return { toEntry, getField, resolveValue, resolveLabel, resolveDisabled, asText, equals };
665
+ const isObject = (option) => typeof option === "object" && option !== null;
666
+ const getField = (target, path) => {
667
+ if (!path || !isObject(target)) return void 0;
668
+ return path.split(".").reduce((acc, key) => isObject(acc) ? acc[key] : void 0, target);
669
+ };
670
+ const asText = (value) => value === null || value === void 0 ? null : String(value);
671
+ const resolveValue = (option) => {
672
+ const field = fields.optionValue();
673
+ if (field && isObject(option)) return getField(option, field);
674
+ return option;
675
+ };
676
+ const resolveLabel = (option) => {
677
+ const field = fields.optionLabel();
678
+ if (field && isObject(option)) return asText(getField(option, field));
679
+ if (isObject(option) && "label" in option) return asText(option["label"]);
680
+ return asText(option);
681
+ };
682
+ const resolveDisabled = (option) => {
683
+ const field = fields.optionDisabled();
684
+ if (field && isObject(option)) return !!getField(option, field);
685
+ if (isObject(option) && "disabled" in option) return !!option["disabled"];
686
+ return false;
687
+ };
688
+ const equals = (a, b) => {
689
+ const key = fields.dataKey();
690
+ if (key && isObject(a) && isObject(b)) return a[key] === b[key];
691
+ return a === b;
692
+ };
693
+ const toEntry = (option) => ({
694
+ value: resolveValue(option),
695
+ label: resolveLabel(option) ?? "",
696
+ disabled: resolveDisabled(option),
697
+ original: option
698
+ });
699
+ return {
700
+ toEntry,
701
+ getField,
702
+ resolveValue,
703
+ resolveLabel,
704
+ resolveDisabled,
705
+ asText,
706
+ equals
707
+ };
617
708
  }
618
-
619
- /**
620
- * Substitutes the `{0}` token of a (possibly user-overridden) label with a value.
621
- * Plain split/join — never interprets `$` sequences in `value` (unlike `String.replace`).
622
- */
623
- function formatLabel(template, value) {
624
- return template.split('{0}').join(String(value));
709
+ function formatLabel(template, ...values) {
710
+ return template.replace(/\{(0|[1-9]\d*)\}/g, (token, index) => Number(index) < values.length ? String(values[Number(index)]) : token);
625
711
  }
626
-
627
- // Dev-only a11y guard shared by form controls that require an accessible name
628
- // (`ariaLabel`/`ariaLabelledBy`/`label`). Centralizes the "how to warn" (console + dev-mode
629
- // gating) so each component only supplies its own trigger condition and message text.
630
712
  function warnMissingAccessibleName(componentTag, message) {
631
- if (isDevMode()) {
632
- console.warn(`[${componentTag}] ${message}`);
633
- }
634
- }
635
-
636
- /** Keyframes run by the `browser-fill` SCSS mixin while the browser autofills the field. */
637
- const AUTOFILL_ANIMATION = 'ui-browser-fill';
638
- /**
639
- * Reports the events through which the browser may write a value into a native
640
- * `<input>`/`<textarea>` without an `input` event:
641
- *
642
- * - its autofill: the `:-webkit-autofill` animation declared by the
643
- * `utils.browser-fill` mixin, which the host stylesheet must include;
644
- * - a `change`.
645
- *
646
- * Either may follow an edit the host already handled through `input`: the
647
- * host syncs only when the native value differs from the one it renders, so
648
- * nothing is emitted twice. An `input` sent by the browser to a field without
649
- * focus already reaches the host's own `(input)` handler: `hasFocus()` tells
650
- * it apart from a keystroke.
651
- */
652
- class UiBrowserFill {
653
- constructor() {
654
- /** Emitted with the change/animation event that may reveal a fill. */
655
- this.browserFill = output();
656
- }
657
- onAnimationStart(event) {
658
- if (event.animationName.endsWith(AUTOFILL_ANIMATION))
659
- this.browserFill.emit(event);
660
- }
661
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: UiBrowserFill, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
662
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.1.7", type: UiBrowserFill, isStandalone: true, selector: "[uiBrowserFill]", outputs: { browserFill: "browserFill" }, host: { listeners: { "change": "browserFill.emit($event)", "animationstart": "onAnimationStart($event)" }, classAttribute: "ui-browser-fill" }, ngImport: i0 }); }
713
+ if (isDevMode()) console.warn(`[${componentTag}] ${message}`);
663
714
  }
664
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: UiBrowserFill, decorators: [{
665
- type: Directive,
666
- args: [{
667
- selector: '[uiBrowserFill]',
668
- host: {
669
- class: 'ui-browser-fill',
670
- '(change)': 'browserFill.emit($event)',
671
- '(animationstart)': 'onAnimationStart($event)',
672
- },
673
- }]
674
- }], propDecorators: { browserFill: [{ type: i0.Output, args: ["browserFill"] }] } });
675
- /** Whether `element` holds the focus (works inside a shadow root). */
715
+ const AUTOFILL_ANIMATION = "ui-browser-fill";
716
+ var UiBrowserFill = class UiBrowserFill {
717
+ constructor() {
718
+ this.browserFill = output();
719
+ }
720
+ onAnimationStart(event) {
721
+ if (event.animationName.endsWith(AUTOFILL_ANIMATION)) this.browserFill.emit(event);
722
+ }
723
+ static {
724
+ this.ɵfac = i0.ɵɵngDeclareFactory({
725
+ minVersion: "12.0.0",
726
+ version: "22.3.0",
727
+ ngImport: i0,
728
+ type: UiBrowserFill,
729
+ deps: [],
730
+ target: i0.ɵɵFactoryTarget.Directive
731
+ });
732
+ }
733
+ static {
734
+ this.ɵdir = i0.ɵɵngDeclareDirective({
735
+ minVersion: "14.0.0",
736
+ version: "22.3.0",
737
+ type: UiBrowserFill,
738
+ isStandalone: true,
739
+ selector: "[uiBrowserFill]",
740
+ outputs: { browserFill: "browserFill" },
741
+ host: {
742
+ listeners: {
743
+ "change": "browserFill.emit($event)",
744
+ "animationstart": "onAnimationStart($event)"
745
+ },
746
+ classAttribute: "ui-browser-fill"
747
+ },
748
+ ngImport: i0
749
+ });
750
+ }
751
+ };
752
+ i0.ɵɵngDeclareClassMetadata({
753
+ minVersion: "12.0.0",
754
+ version: "22.3.0",
755
+ ngImport: i0,
756
+ type: UiBrowserFill,
757
+ decorators: [{
758
+ type: Directive,
759
+ args: [{
760
+ selector: "[uiBrowserFill]",
761
+ host: {
762
+ class: "ui-browser-fill",
763
+ "(change)": "browserFill.emit($event)",
764
+ "(animationstart)": "onAnimationStart($event)"
765
+ }
766
+ }]
767
+ }],
768
+ propDecorators: { browserFill: [{
769
+ type: i0.Output,
770
+ args: ["browserFill"]
771
+ }] }
772
+ });
676
773
  function hasFocus(element) {
677
- return element.getRootNode().activeElement === element;
774
+ return element.getRootNode().activeElement === element;
678
775
  }
679
-
680
- /*
681
- * Public API Surface of ui-kit/forms
682
- *
683
- * Shared form infrastructure: the base classes every `ui-*` field inherits
684
- * from, plus the helpers those fields rely on. Importing a field component
685
- * (e.g. `@4sh/ui-kit/forms/ui-input`) pulls this in automatically — you only import
686
- * from here directly when building your OWN field on top of the kit's
687
- * conventions.
688
- */
689
-
690
- /**
691
- * Generated bundle index. Do not edit.
692
- */
693
-
694
776
  export { BaseControlValueAccessor, BaseFieldControl, BaseFormField, MASK_TOKENS, UiBrowserFill, acceptsMaskChar, addDays, addMonths, applyMaskTemplate, autoFormatSegments, buildMaskSlots, caretForMask, createOptionResolver, dropdownOverlayPositions, extractMaskData, finalizeParsed, firstOfMonth, formatLabel, hasFocus, isSameDay, normalizeDateInput, parseIsoDate, parseIsoDateTime, parseIsoTime, parseMaskRanges, startOfDay, toIsoDate, toIsoDateTime, toIsoTime, warnMissingAccessibleName };
695
- //# sourceMappingURL=4sh-ui-kit-forms.mjs.map
777
+
778
+ //# sourceMappingURL=4sh-ui-kit-forms.mjs.map