@molecule/app-ui-angular 1.0.6 → 1.1.2

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 (312) hide show
  1. package/README.md +11710 -1117
  2. package/dist/components/accordion.component.d.ts +114 -0
  3. package/dist/components/accordion.component.d.ts.map +1 -0
  4. package/dist/components/accordion.component.js +286 -0
  5. package/dist/components/accordion.component.js.map +1 -0
  6. package/dist/components/alert.component.d.ts +81 -37
  7. package/dist/components/alert.component.d.ts.map +1 -1
  8. package/dist/components/alert.component.js +232 -146
  9. package/dist/components/alert.component.js.map +1 -1
  10. package/dist/components/auth-guard.component.d.ts +94 -0
  11. package/dist/components/auth-guard.component.d.ts.map +1 -0
  12. package/dist/components/auth-guard.component.js +212 -0
  13. package/dist/components/auth-guard.component.js.map +1 -0
  14. package/dist/components/avatar.component.d.ts +97 -0
  15. package/dist/components/avatar.component.d.ts.map +1 -0
  16. package/dist/components/avatar.component.js +216 -0
  17. package/dist/components/avatar.component.js.map +1 -0
  18. package/dist/components/badge.component.d.ts +27 -12
  19. package/dist/components/badge.component.d.ts.map +1 -1
  20. package/dist/components/badge.component.js +47 -47
  21. package/dist/components/badge.component.js.map +1 -1
  22. package/dist/components/button.component.d.ts +96 -14
  23. package/dist/components/button.component.d.ts.map +1 -1
  24. package/dist/components/button.component.js +232 -87
  25. package/dist/components/button.component.js.map +1 -1
  26. package/dist/components/card.component.d.ts +135 -0
  27. package/dist/components/card.component.d.ts.map +1 -0
  28. package/dist/components/card.component.js +291 -0
  29. package/dist/components/card.component.js.map +1 -0
  30. package/dist/components/checkbox.component.d.ts +97 -29
  31. package/dist/components/checkbox.component.d.ts.map +1 -1
  32. package/dist/components/checkbox.component.js +222 -117
  33. package/dist/components/checkbox.component.js.map +1 -1
  34. package/dist/components/confirm-button.component.d.ts +130 -0
  35. package/dist/components/confirm-button.component.d.ts.map +1 -0
  36. package/dist/components/confirm-button.component.js +322 -0
  37. package/dist/components/confirm-button.component.js.map +1 -0
  38. package/dist/components/confirm-dialog.component.d.ts +60 -0
  39. package/dist/components/confirm-dialog.component.d.ts.map +1 -0
  40. package/dist/components/confirm-dialog.component.js +152 -0
  41. package/dist/components/confirm-dialog.component.js.map +1 -0
  42. package/dist/components/controlled-checked.directive.d.ts +45 -0
  43. package/dist/components/controlled-checked.directive.d.ts.map +1 -0
  44. package/dist/components/controlled-checked.directive.js +74 -0
  45. package/dist/components/controlled-checked.directive.js.map +1 -0
  46. package/dist/components/dropdown.component.d.ts +313 -0
  47. package/dist/components/dropdown.component.d.ts.map +1 -0
  48. package/dist/components/dropdown.component.js +919 -0
  49. package/dist/components/dropdown.component.js.map +1 -0
  50. package/dist/components/empty-state.component.d.ts +73 -0
  51. package/dist/components/empty-state.component.d.ts.map +1 -0
  52. package/dist/components/empty-state.component.js +180 -0
  53. package/dist/components/empty-state.component.js.map +1 -0
  54. package/dist/components/floating-input.component.d.ts +86 -0
  55. package/dist/components/floating-input.component.d.ts.map +1 -0
  56. package/dist/components/floating-input.component.js +167 -0
  57. package/dist/components/floating-input.component.js.map +1 -0
  58. package/dist/components/form-field.component.d.ts +111 -0
  59. package/dist/components/form-field.component.d.ts.map +1 -0
  60. package/dist/components/form-field.component.js +300 -0
  61. package/dist/components/form-field.component.js.map +1 -0
  62. package/dist/components/form.component.d.ts +77 -0
  63. package/dist/components/form.component.d.ts.map +1 -0
  64. package/dist/components/form.component.js +222 -0
  65. package/dist/components/form.component.js.map +1 -0
  66. package/dist/components/icon.component.d.ts +85 -0
  67. package/dist/components/icon.component.d.ts.map +1 -0
  68. package/dist/components/icon.component.js +187 -0
  69. package/dist/components/icon.component.js.map +1 -0
  70. package/dist/components/index.d.ts +49 -0
  71. package/dist/components/index.d.ts.map +1 -1
  72. package/dist/components/index.js +49 -0
  73. package/dist/components/index.js.map +1 -1
  74. package/dist/components/input.component.d.ts +157 -54
  75. package/dist/components/input.component.d.ts.map +1 -1
  76. package/dist/components/input.component.js +437 -222
  77. package/dist/components/input.component.js.map +1 -1
  78. package/dist/components/label.component.d.ts +29 -0
  79. package/dist/components/label.component.d.ts.map +1 -0
  80. package/dist/components/label.component.js +60 -0
  81. package/dist/components/label.component.js.map +1 -0
  82. package/dist/components/language-picker.component.d.ts +124 -0
  83. package/dist/components/language-picker.component.d.ts.map +1 -0
  84. package/dist/components/language-picker.component.js +305 -0
  85. package/dist/components/language-picker.component.js.map +1 -0
  86. package/dist/components/layout.component.d.ts +167 -0
  87. package/dist/components/layout.component.d.ts.map +1 -0
  88. package/dist/components/layout.component.js +364 -0
  89. package/dist/components/layout.component.js.map +1 -0
  90. package/dist/components/load-error-banner.component.d.ts +103 -0
  91. package/dist/components/load-error-banner.component.d.ts.map +1 -0
  92. package/dist/components/load-error-banner.component.js +263 -0
  93. package/dist/components/load-error-banner.component.js.map +1 -0
  94. package/dist/components/modal.component.d.ts +125 -95
  95. package/dist/components/modal.component.d.ts.map +1 -1
  96. package/dist/components/modal.component.js +458 -271
  97. package/dist/components/modal.component.js.map +1 -1
  98. package/dist/components/molecule/alert.component.d.ts +77 -0
  99. package/dist/components/molecule/alert.component.d.ts.map +1 -0
  100. package/dist/components/molecule/alert.component.js +229 -0
  101. package/dist/components/molecule/alert.component.js.map +1 -0
  102. package/dist/components/molecule/badge.component.d.ts +27 -0
  103. package/dist/components/molecule/badge.component.d.ts.map +1 -0
  104. package/dist/components/molecule/badge.component.js +79 -0
  105. package/dist/components/molecule/badge.component.js.map +1 -0
  106. package/dist/components/molecule/button.component.d.ts +38 -0
  107. package/dist/components/molecule/button.component.d.ts.map +1 -0
  108. package/dist/components/molecule/button.component.js +137 -0
  109. package/dist/components/molecule/button.component.js.map +1 -0
  110. package/dist/components/molecule/checkbox.component.d.ts +53 -0
  111. package/dist/components/molecule/checkbox.component.d.ts.map +1 -0
  112. package/dist/components/molecule/checkbox.component.js +166 -0
  113. package/dist/components/molecule/checkbox.component.js.map +1 -0
  114. package/dist/components/molecule/index.d.ts +18 -0
  115. package/dist/components/molecule/index.d.ts.map +1 -0
  116. package/dist/components/molecule/index.js +18 -0
  117. package/dist/components/molecule/index.js.map +1 -0
  118. package/dist/components/molecule/input.component.d.ts +93 -0
  119. package/dist/components/molecule/input.component.d.ts.map +1 -0
  120. package/dist/components/molecule/input.component.js +314 -0
  121. package/dist/components/molecule/input.component.js.map +1 -0
  122. package/dist/components/molecule/modal.component.d.ts +148 -0
  123. package/dist/components/molecule/modal.component.d.ts.map +1 -0
  124. package/dist/components/molecule/modal.component.js +382 -0
  125. package/dist/components/molecule/modal.component.js.map +1 -0
  126. package/dist/components/molecule/radio-group.component.d.ts +63 -0
  127. package/dist/components/molecule/radio-group.component.d.ts.map +1 -0
  128. package/dist/components/molecule/radio-group.component.js +208 -0
  129. package/dist/components/molecule/radio-group.component.js.map +1 -0
  130. package/dist/components/molecule/select.component.d.ts +72 -0
  131. package/dist/components/molecule/select.component.d.ts.map +1 -0
  132. package/dist/components/molecule/select.component.js +274 -0
  133. package/dist/components/molecule/select.component.js.map +1 -0
  134. package/dist/components/molecule/spinner.component.d.ts +42 -0
  135. package/dist/components/molecule/spinner.component.d.ts.map +1 -0
  136. package/dist/components/molecule/spinner.component.js +122 -0
  137. package/dist/components/molecule/spinner.component.js.map +1 -0
  138. package/dist/components/molecule/switch.component.d.ts +54 -0
  139. package/dist/components/molecule/switch.component.d.ts.map +1 -0
  140. package/dist/components/molecule/switch.component.js +148 -0
  141. package/dist/components/molecule/switch.component.js.map +1 -0
  142. package/dist/components/molecule/toast.component.d.ts +98 -0
  143. package/dist/components/molecule/toast.component.d.ts.map +1 -0
  144. package/dist/components/molecule/toast.component.js +305 -0
  145. package/dist/components/molecule/toast.component.js.map +1 -0
  146. package/dist/components/molecule/tooltip.component.d.ts +77 -0
  147. package/dist/components/molecule/tooltip.component.d.ts.map +1 -0
  148. package/dist/components/molecule/tooltip.component.js +316 -0
  149. package/dist/components/molecule/tooltip.component.js.map +1 -0
  150. package/dist/components/optimistic-toggle-button.component.d.ts +125 -0
  151. package/dist/components/optimistic-toggle-button.component.d.ts.map +1 -0
  152. package/dist/components/optimistic-toggle-button.component.js +296 -0
  153. package/dist/components/optimistic-toggle-button.component.js.map +1 -0
  154. package/dist/components/page-header.component.d.ts +77 -0
  155. package/dist/components/page-header.component.d.ts.map +1 -0
  156. package/dist/components/page-header.component.js +225 -0
  157. package/dist/components/page-header.component.js.map +1 -0
  158. package/dist/components/page-shell.component.d.ts +101 -0
  159. package/dist/components/page-shell.component.d.ts.map +1 -0
  160. package/dist/components/page-shell.component.js +221 -0
  161. package/dist/components/page-shell.component.js.map +1 -0
  162. package/dist/components/pagination.component.d.ts +137 -0
  163. package/dist/components/pagination.component.d.ts.map +1 -0
  164. package/dist/components/pagination.component.js +419 -0
  165. package/dist/components/pagination.component.js.map +1 -0
  166. package/dist/components/panel-close.component.d.ts +43 -0
  167. package/dist/components/panel-close.component.d.ts.map +1 -0
  168. package/dist/components/panel-close.component.js +75 -0
  169. package/dist/components/panel-close.component.js.map +1 -0
  170. package/dist/components/progress.component.d.ts +84 -0
  171. package/dist/components/progress.component.d.ts.map +1 -0
  172. package/dist/components/progress.component.js +219 -0
  173. package/dist/components/progress.component.js.map +1 -0
  174. package/dist/components/prompt-dialog.component.d.ts +121 -0
  175. package/dist/components/prompt-dialog.component.d.ts.map +1 -0
  176. package/dist/components/prompt-dialog.component.js +332 -0
  177. package/dist/components/prompt-dialog.component.js.map +1 -0
  178. package/dist/components/radio-group.component.d.ts +66 -34
  179. package/dist/components/radio-group.component.d.ts.map +1 -1
  180. package/dist/components/radio-group.component.js +157 -134
  181. package/dist/components/radio-group.component.js.map +1 -1
  182. package/dist/components/responsive-app-shell.component.d.ts +408 -0
  183. package/dist/components/responsive-app-shell.component.d.ts.map +1 -0
  184. package/dist/components/responsive-app-shell.component.js +1144 -0
  185. package/dist/components/responsive-app-shell.component.js.map +1 -0
  186. package/dist/components/select.component.d.ts +135 -38
  187. package/dist/components/select.component.d.ts.map +1 -1
  188. package/dist/components/select.component.js +373 -181
  189. package/dist/components/select.component.js.map +1 -1
  190. package/dist/components/separator.component.d.ts +39 -0
  191. package/dist/components/separator.component.d.ts.map +1 -0
  192. package/dist/components/separator.component.js +73 -0
  193. package/dist/components/separator.component.js.map +1 -0
  194. package/dist/components/sidebar-user-card.component.d.ts +106 -0
  195. package/dist/components/sidebar-user-card.component.d.ts.map +1 -0
  196. package/dist/components/sidebar-user-card.component.js +277 -0
  197. package/dist/components/sidebar-user-card.component.js.map +1 -0
  198. package/dist/components/skeleton.component.d.ts +100 -0
  199. package/dist/components/skeleton.component.d.ts.map +1 -0
  200. package/dist/components/skeleton.component.js +214 -0
  201. package/dist/components/skeleton.component.js.map +1 -0
  202. package/dist/components/spinner.component.d.ts +36 -19
  203. package/dist/components/spinner.component.d.ts.map +1 -1
  204. package/dist/components/spinner.component.js +69 -71
  205. package/dist/components/spinner.component.js.map +1 -1
  206. package/dist/components/switch.component.d.ts +72 -29
  207. package/dist/components/switch.component.d.ts.map +1 -1
  208. package/dist/components/switch.component.js +168 -95
  209. package/dist/components/switch.component.js.map +1 -1
  210. package/dist/components/table.component.d.ts +193 -0
  211. package/dist/components/table.component.d.ts.map +1 -0
  212. package/dist/components/table.component.js +550 -0
  213. package/dist/components/table.component.js.map +1 -0
  214. package/dist/components/tabs.component.d.ts +140 -0
  215. package/dist/components/tabs.component.d.ts.map +1 -0
  216. package/dist/components/tabs.component.js +390 -0
  217. package/dist/components/tabs.component.js.map +1 -0
  218. package/dist/components/template-outlet.directive.d.ts +50 -0
  219. package/dist/components/template-outlet.directive.d.ts.map +1 -0
  220. package/dist/components/template-outlet.directive.js +81 -0
  221. package/dist/components/template-outlet.directive.js.map +1 -0
  222. package/dist/components/textarea.component.d.ts +151 -0
  223. package/dist/components/textarea.component.d.ts.map +1 -0
  224. package/dist/components/textarea.component.js +340 -0
  225. package/dist/components/textarea.component.js.map +1 -0
  226. package/dist/components/theme-toggle.component.d.ts +58 -0
  227. package/dist/components/theme-toggle.component.d.ts.map +1 -0
  228. package/dist/components/theme-toggle.component.js +124 -0
  229. package/dist/components/theme-toggle.component.js.map +1 -0
  230. package/dist/components/toast.component.d.ts +237 -49
  231. package/dist/components/toast.component.d.ts.map +1 -1
  232. package/dist/components/toast.component.js +636 -201
  233. package/dist/components/toast.component.js.map +1 -1
  234. package/dist/components/tooltip.component.d.ts +95 -45
  235. package/dist/components/tooltip.component.d.ts.map +1 -1
  236. package/dist/components/tooltip.component.js +372 -221
  237. package/dist/components/tooltip.component.js.map +1 -1
  238. package/dist/components/user-menu-popover.component.d.ts +283 -0
  239. package/dist/components/user-menu-popover.component.d.ts.map +1 -0
  240. package/dist/components/user-menu-popover.component.js +646 -0
  241. package/dist/components/user-menu-popover.component.js.map +1 -0
  242. package/dist/components/user-menu.component.d.ts +95 -0
  243. package/dist/components/user-menu.component.d.ts.map +1 -0
  244. package/dist/components/user-menu.component.js +218 -0
  245. package/dist/components/user-menu.component.js.map +1 -0
  246. package/dist/hooks/index.d.ts +7 -0
  247. package/dist/hooks/index.d.ts.map +1 -0
  248. package/dist/hooks/index.js +7 -0
  249. package/dist/hooks/index.js.map +1 -0
  250. package/dist/hooks/use-is-desktop.d.ts +22 -0
  251. package/dist/hooks/use-is-desktop.d.ts.map +1 -0
  252. package/dist/hooks/use-is-desktop.js +37 -0
  253. package/dist/hooks/use-is-desktop.js.map +1 -0
  254. package/dist/index.d.ts +32 -17
  255. package/dist/index.d.ts.map +1 -1
  256. package/dist/index.js +32 -17
  257. package/dist/index.js.map +1 -1
  258. package/dist/types.d.ts +1 -1
  259. package/dist/types.d.ts.map +1 -1
  260. package/dist/utilities/dom-context.d.ts +42 -0
  261. package/dist/utilities/dom-context.d.ts.map +1 -0
  262. package/dist/utilities/dom-context.js +66 -0
  263. package/dist/utilities/dom-context.js.map +1 -0
  264. package/dist/utilities/focus.d.ts +32 -0
  265. package/dist/utilities/focus.d.ts.map +1 -0
  266. package/dist/utilities/focus.js +47 -0
  267. package/dist/utilities/focus.js.map +1 -0
  268. package/dist/utilities/form-field-context.d.ts +34 -0
  269. package/dist/utilities/form-field-context.d.ts.map +1 -0
  270. package/dist/utilities/form-field-context.js +28 -0
  271. package/dist/utilities/form-field-context.js.map +1 -0
  272. package/dist/utilities/form-submit-error.d.ts +17 -0
  273. package/dist/utilities/form-submit-error.d.ts.map +1 -0
  274. package/dist/utilities/form-submit-error.js +42 -0
  275. package/dist/utilities/form-submit-error.js.map +1 -0
  276. package/dist/utilities/icon-markup.d.ts +17 -0
  277. package/dist/utilities/icon-markup.d.ts.map +1 -0
  278. package/dist/utilities/icon-markup.js +46 -0
  279. package/dist/utilities/icon-markup.js.map +1 -0
  280. package/dist/utilities/ids.d.ts +15 -0
  281. package/dist/utilities/ids.d.ts.map +1 -0
  282. package/dist/utilities/ids.js +19 -0
  283. package/dist/utilities/ids.js.map +1 -0
  284. package/dist/utilities/index.d.ts +11 -0
  285. package/dist/utilities/index.d.ts.map +1 -1
  286. package/dist/utilities/index.js +11 -0
  287. package/dist/utilities/index.js.map +1 -1
  288. package/dist/utilities/initials.d.ts +13 -0
  289. package/dist/utilities/initials.d.ts.map +1 -0
  290. package/dist/utilities/initials.js +23 -0
  291. package/dist/utilities/initials.js.map +1 -0
  292. package/dist/utilities/node-value.d.ts +31 -0
  293. package/dist/utilities/node-value.d.ts.map +1 -0
  294. package/dist/utilities/node-value.js +37 -0
  295. package/dist/utilities/node-value.js.map +1 -0
  296. package/dist/utilities/optimistic-value.d.ts +81 -0
  297. package/dist/utilities/optimistic-value.d.ts.map +1 -0
  298. package/dist/utilities/optimistic-value.js +154 -0
  299. package/dist/utilities/optimistic-value.js.map +1 -0
  300. package/dist/utilities/render-icon.d.ts +77 -7
  301. package/dist/utilities/render-icon.d.ts.map +1 -1
  302. package/dist/utilities/render-icon.js +123 -33
  303. package/dist/utilities/render-icon.js.map +1 -1
  304. package/dist/utilities/rest-attrs.d.ts +21 -0
  305. package/dist/utilities/rest-attrs.d.ts.map +1 -0
  306. package/dist/utilities/rest-attrs.js +37 -0
  307. package/dist/utilities/rest-attrs.js.map +1 -0
  308. package/dist/utilities/style.d.ts +23 -0
  309. package/dist/utilities/style.d.ts.map +1 -0
  310. package/dist/utilities/style.js +86 -0
  311. package/dist/utilities/style.js.map +1 -0
  312. package/package.json +6 -4
@@ -0,0 +1,296 @@
1
+ /**
2
+ * OptimisticToggleButton component (React parity): a server-backed boolean
3
+ * button that changes its label immediately and saves in order.
4
+ *
5
+ * @module
6
+ */
7
+ import { Component, ElementRef, inject, Renderer2, signal, ViewChild, } from '@angular/core';
8
+ import { getClassMap } from '@molecule/app-ui';
9
+ import { createOptimisticValue } from '../utilities/optimistic-value.js';
10
+ import { styleText } from '../utilities/style.js';
11
+ import { hasNodes, SlotWrapper } from './button.component.js';
12
+ import * as i0 from "@angular/core";
13
+ const _c0 = ["leftSlot"];
14
+ const _c1 = ["activeSlot"];
15
+ const _c2 = ["inactiveSlot"];
16
+ const _c3 = ["rightSlot"];
17
+ const _c4 = [[["", "slot", "lefticon"]], [["", "slot", "activelabel"]], [["", "slot", "inactivelabel"]], [["", "slot", "righticon"]]];
18
+ const _c5 = ["[slot=leftIcon]", "[slot=activeLabel]", "[slot=inactiveLabel]", "[slot=rightIcon]"];
19
+ /**
20
+ * OptimisticToggleButton component.
21
+ *
22
+ * The host is the `<button>` itself (`button[mol-optimistic-toggle-button]`),
23
+ * exactly React's root (it renders `Button`). The two labels are node-valued
24
+ * props, projected as `[slot=activeLabel]` / `[slot=inactiveLabel]`; exactly
25
+ * one is shown, moved onto the button with no wrapper, matching React's
26
+ * `{toggle.value ? activeLabel : inactiveLabel}`.
27
+ */
28
+ export class OptimisticToggleButton {
29
+ /** The loaded server value. */
30
+ value = false;
31
+ /** Saves the desired boolean and returns the server-confirmed boolean. */
32
+ commit;
33
+ /** Label when the displayed value is true (node-valued prop). */
34
+ activeLabel;
35
+ /** Label when the displayed value is false (node-valued prop). */
36
+ inactiveLabel;
37
+ /** Receives a failed save after the controller has restored the last confirmed value. */
38
+ onError;
39
+ /** Button variant. */
40
+ variant;
41
+ /** Button color. */
42
+ color;
43
+ /** Button size. */
44
+ size;
45
+ /** Whether the button stretches to fill its container. */
46
+ fullWidth = false;
47
+ /** Left icon (node-valued prop). */
48
+ leftIcon;
49
+ /** Right icon (node-valued prop). */
50
+ rightIcon;
51
+ /** Extra classes. */
52
+ className;
53
+ /** Inline style object (React camelCase). */
54
+ style;
55
+ /** `data-testid`. */
56
+ testId;
57
+ /** Disables the button (permissions, never a pending save). */
58
+ disabled = false;
59
+ /** The optimistic controller. */
60
+ controller;
61
+ /** The controller state (a signal so the zoneless view re-checks on every publish). */
62
+ state = signal({
63
+ value: false,
64
+ pending: false,
65
+ error: null,
66
+ }, /* @ts-ignore */
67
+ ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
68
+ /** The left icon wrapper. */
69
+ leftSlot;
70
+ /** The active-label capture span. */
71
+ activeSlot;
72
+ /** The inactive-label capture span. */
73
+ inactiveSlot;
74
+ /** The right icon wrapper. */
75
+ rightSlot;
76
+ el = inject(ElementRef);
77
+ renderer = inject(Renderer2);
78
+ sync = new SlotWrapper(this.el, this.renderer);
79
+ unsubscribe;
80
+ lastReceived = false;
81
+ hasLeft = false;
82
+ hasRight = false;
83
+ visibleNodes = [];
84
+ visibleFrom = null;
85
+ anchor = null;
86
+ /** Creates the optimistic controller and mirrors its state into the signal. */
87
+ constructor() {
88
+ this.controller = createOptimisticValue({
89
+ value: this.value,
90
+ commit: (next) => this.commit?.(next) ?? Promise.resolve(next),
91
+ onError: (error) => this.onError?.(error),
92
+ });
93
+ this.unsubscribe = this.controller.subscribe((next) => this.state.set({ ...next }));
94
+ this.state.set(this.controller.getState());
95
+ }
96
+ /**
97
+ * The current class map.
98
+ * @returns The UIClassMap.
99
+ */
100
+ cm() {
101
+ return getClassMap();
102
+ }
103
+ /**
104
+ * Computes the button class list.
105
+ * @returns The class string.
106
+ */
107
+ classes() {
108
+ return this.cm().cn(this.cm().button({
109
+ variant: this.variant ?? 'solid',
110
+ color: this.color ?? 'primary',
111
+ size: this.size ?? 'md',
112
+ fullWidth: this.fullWidth,
113
+ }), this.className);
114
+ }
115
+ /**
116
+ * Serializes the inline style.
117
+ * @returns The style attribute text.
118
+ */
119
+ hostStyle() {
120
+ return styleText(this.style);
121
+ }
122
+ /** Flips the displayed value and saves the newest desired value. */
123
+ handleClick() {
124
+ this.controller.update((current) => !current);
125
+ }
126
+ /**
127
+ * Reads slot presence at view init (view queries resolve only then) and
128
+ * takes the label capture spans out of the DOM.
129
+ */
130
+ ngAfterViewInit() {
131
+ this.hasLeft = hasNodes(this.leftSlot?.nativeElement);
132
+ this.hasRight = hasNodes(this.rightSlot?.nativeElement);
133
+ this.sync.sync(this.activeSlot?.nativeElement, false);
134
+ this.sync.sync(this.inactiveSlot?.nativeElement, false);
135
+ this.sync.sync(this.leftSlot?.nativeElement, this.hasLeft);
136
+ this.sync.sync(this.rightSlot?.nativeElement, this.hasRight);
137
+ this.syncLabels();
138
+ }
139
+ /**
140
+ * Takes a newer server value the way React's effect does (only when it
141
+ * differs from the last one received) and re-reconciles the label.
142
+ */
143
+ ngDoCheck() {
144
+ if (this.value !== this.lastReceived) {
145
+ this.lastReceived = this.value;
146
+ this.controller.sync(this.value);
147
+ }
148
+ this.syncLabels();
149
+ }
150
+ /** Stops mirroring controller state into the signal (unmount). */
151
+ ngOnDestroy() {
152
+ this.unsubscribe?.();
153
+ this.visibleNodes = [];
154
+ this.visibleFrom = null;
155
+ }
156
+ /**
157
+ * Shows exactly the displayed value's projected children on the button —
158
+ * React renders exactly one label and no wrapper element.
159
+ */
160
+ syncLabels() {
161
+ const state = this.controller.getState();
162
+ this.showSlot(state.value
163
+ ? (this.activeSlot?.nativeElement ?? null)
164
+ : (this.inactiveSlot?.nativeElement ?? null));
165
+ }
166
+ /**
167
+ * Shows one slot's projected children on the button, parking whatever
168
+ * another slot was showing back inside its capture span.
169
+ *
170
+ * @param span - The capture span to show (null parks everything).
171
+ */
172
+ showSlot(span) {
173
+ const host = this.el.nativeElement;
174
+ if (span === this.visibleFrom)
175
+ return;
176
+ for (const node of this.visibleNodes) {
177
+ if (node.parentNode === host)
178
+ this.visibleFrom?.appendChild(node);
179
+ }
180
+ this.visibleNodes = [];
181
+ this.visibleFrom = null;
182
+ if (!span)
183
+ return;
184
+ const nodes = Array.from(span.childNodes);
185
+ for (const node of nodes)
186
+ host.insertBefore(node, this.labelAnchor());
187
+ this.visibleNodes = nodes;
188
+ this.visibleFrom = span;
189
+ }
190
+ /**
191
+ * The insertion point for the visible projected label (a comment the DOM
192
+ * normalizer strips), kept after the left icon wrapper.
193
+ * @returns The anchor comment.
194
+ */
195
+ labelAnchor() {
196
+ if (this.anchor?.isConnected)
197
+ return this.anchor;
198
+ const anchor = this.renderer.createComment('label');
199
+ const host = this.el.nativeElement;
200
+ const left = this.leftSlot?.nativeElement;
201
+ host.insertBefore(anchor, left ? left.nextSibling : host.firstChild);
202
+ this.anchor = anchor;
203
+ return anchor;
204
+ }
205
+ static ɵfac = function OptimisticToggleButton_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || OptimisticToggleButton)(); };
206
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: OptimisticToggleButton, selectors: [["button", "mol-optimistic-toggle-button", ""]], viewQuery: function OptimisticToggleButton_Query(rf, ctx) { if (rf & 1) {
207
+ i0.ɵɵviewQuery(_c0, 5)(_c1, 5)(_c2, 5)(_c3, 5);
208
+ } if (rf & 2) {
209
+ let _t;
210
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.leftSlot = _t.first);
211
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.activeSlot = _t.first);
212
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.inactiveSlot = _t.first);
213
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.rightSlot = _t.first);
214
+ } }, hostVars: 10, hostBindings: function OptimisticToggleButton_HostBindings(rf, ctx) { if (rf & 1) {
215
+ i0.ɵɵlistener("click", function OptimisticToggleButton_click_HostBindingHandler() { return ctx.handleClick(); });
216
+ } if (rf & 2) {
217
+ i0.ɵɵdomProperty("disabled", ctx.disabled);
218
+ i0.ɵɵattribute("type", "button")("data-mol-id", "optimistic-toggle")("data-testid", ctx.testId)("aria-pressed", ctx.state().value ? "true" : "false")("aria-busy", ctx.state().pending ? "true" : "false");
219
+ i0.ɵɵstyleMap(ctx.hostStyle());
220
+ i0.ɵɵclassMap(ctx.classes());
221
+ } }, inputs: { value: "value", commit: "commit", activeLabel: "activeLabel", inactiveLabel: "inactiveLabel", onError: "onError", variant: "variant", color: "color", size: "size", fullWidth: "fullWidth", leftIcon: "leftIcon", rightIcon: "rightIcon", className: "className", style: "style", testId: "testId", disabled: "disabled" }, ngContentSelectors: _c5, decls: 12, vars: 4, consts: [["leftSlot", ""], ["activeSlot", ""], ["inactiveSlot", ""], ["rightSlot", ""]], template: function OptimisticToggleButton_Template(rf, ctx) { if (rf & 1) {
222
+ i0.ɵɵprojectionDef(_c4);
223
+ i0.ɵɵdomElementStart(0, "span", null, 0);
224
+ i0.ɵɵprojection(2);
225
+ i0.ɵɵdomElementEnd();
226
+ i0.ɵɵdomElementStart(3, "span", null, 1);
227
+ i0.ɵɵprojection(5, 1);
228
+ i0.ɵɵdomElementEnd();
229
+ i0.ɵɵdomElementStart(6, "span", null, 2);
230
+ i0.ɵɵprojection(8, 2);
231
+ i0.ɵɵdomElementEnd();
232
+ i0.ɵɵdomElementStart(9, "span", null, 3);
233
+ i0.ɵɵprojection(11, 3);
234
+ i0.ɵɵdomElementEnd();
235
+ } if (rf & 2) {
236
+ i0.ɵɵclassMap(ctx.cm().buttonIconLeft);
237
+ i0.ɵɵadvance(9);
238
+ i0.ɵɵclassMap(ctx.cm().buttonIconRight);
239
+ } }, encapsulation: 2 });
240
+ }
241
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(OptimisticToggleButton, [{
242
+ type: Component,
243
+ args: [{
244
+ selector: 'button[mol-optimistic-toggle-button]',
245
+ standalone: true,
246
+ inputs: [
247
+ 'value',
248
+ 'commit',
249
+ 'activeLabel',
250
+ 'inactiveLabel',
251
+ 'onError',
252
+ 'variant',
253
+ 'color',
254
+ 'size',
255
+ 'fullWidth',
256
+ 'leftIcon',
257
+ 'rightIcon',
258
+ 'className',
259
+ 'style',
260
+ 'testId',
261
+ 'disabled',
262
+ ],
263
+ host: {
264
+ '[class]': 'classes()',
265
+ '[style]': 'hostStyle()',
266
+ '[attr.type]': '"button"',
267
+ '[attr.data-mol-id]': '"optimistic-toggle"',
268
+ '[attr.data-testid]': 'testId',
269
+ '[disabled]': 'disabled',
270
+ '[attr.aria-pressed]': 'state().value ? "true" : "false"',
271
+ '[attr.aria-busy]': 'state().pending ? "true" : "false"',
272
+ '(click)': 'handleClick()',
273
+ },
274
+ template: `<span #leftSlot [class]="cm().buttonIconLeft"
275
+ ><ng-content select="[slot=leftIcon]"></ng-content></span
276
+ ><span #activeSlot><ng-content select="[slot=activeLabel]"></ng-content></span
277
+ ><span #inactiveSlot><ng-content select="[slot=inactiveLabel]"></ng-content></span
278
+ ><span #rightSlot [class]="cm().buttonIconRight"
279
+ ><ng-content select="[slot=rightIcon]"></ng-content
280
+ ></span>`,
281
+ }]
282
+ }], () => [], { leftSlot: [{
283
+ type: ViewChild,
284
+ args: ['leftSlot']
285
+ }], activeSlot: [{
286
+ type: ViewChild,
287
+ args: ['activeSlot']
288
+ }], inactiveSlot: [{
289
+ type: ViewChild,
290
+ args: ['inactiveSlot']
291
+ }], rightSlot: [{
292
+ type: ViewChild,
293
+ args: ['rightSlot']
294
+ }] }); })();
295
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(OptimisticToggleButton, { className: "OptimisticToggleButton", filePath: "components/optimistic-toggle-button.component.ts", lineNumber: 76 }); })();
296
+ //# sourceMappingURL=optimistic-toggle-button.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimistic-toggle-button.component.js","sourceRoot":"","sources":["../../src/components/optimistic-toggle-button.component.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,SAAS,EAET,UAAU,EACV,MAAM,EAEN,SAAS,EACT,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAG9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;;;;;;;;AAE7D;;;;;;;;GAQG;AAwCH,MAAM,OAAO,sBAAsB;IACjC,+BAA+B;IAC/B,KAAK,GAAG,KAAK,CAAA;IACb,0EAA0E;IAC1E,MAAM,CAAuD;IAC7D,iEAAiE;IACjE,WAAW,CAAU;IACrB,kEAAkE;IAClE,aAAa,CAAU;IACvB,yFAAyF;IACzF,OAAO,CAA2B;IAClC,sBAAsB;IACtB,OAAO,CAAgB;IACvB,oBAAoB;IACpB,KAAK,CAAe;IACpB,mBAAmB;IACnB,IAAI,CAAO;IACX,0DAA0D;IAC1D,SAAS,GAAG,KAAK,CAAA;IACjB,oCAAoC;IACpC,QAAQ,CAAU;IAClB,qCAAqC;IACrC,SAAS,CAAU;IACnB,qBAAqB;IACrB,SAAS,CAAS;IAClB,6CAA6C;IAC7C,KAAK,CAA0B;IAC/B,qBAAqB;IACrB,MAAM,CAAS;IACf,+DAA+D;IAC/D,QAAQ,GAAG,KAAK,CAAA;IAEhB,iCAAiC;IAChB,UAAU,CAA0B;IACrD,uFAAuF;IAC9E,KAAK,GAAG,MAAM,CAAgC;QACrD,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,IAAI;KACZ;8EAAC,CAAA;IAEF,6BAA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C,SAAS;eAAC;gBACT,QAAQ,EAAE,sCAAsC;gBAChD,UAAU,EAAE,IAAI;gBAChB,MAAM,EAAE;oBACN,OAAO;oBACP,QAAQ;oBACR,aAAa;oBACb,eAAe;oBACf,SAAS;oBACT,SAAS;oBACT,OAAO;oBACP,MAAM;oBACN,WAAW;oBACX,UAAU;oBACV,WAAW;oBACX,WAAW;oBACX,OAAO;oBACP,QAAQ;oBACR,UAAU;iBACX;gBACD,IAAI,EAAE;oBACJ,SAAS,EAAE,WAAW;oBACtB,SAAS,EAAE,aAAa;oBACxB,aAAa,EAAE,UAAU;oBACzB,oBAAoB,EAAE,qBAAqB;oBAC3C,oBAAoB,EAAE,QAAQ;oBAC9B,YAAY,EAAE,UAAU;oBACxB,qBAAqB,EAAE,kCAAkC;oBACzD,kBAAkB,EAAE,oCAAoC;oBACxD,SAAS,EAAE,eAAe;iBAC3B;gBACD,QAAQ,EAAE;;;;;;aAMC;aACZ;;kBA2CE,SAAS;mBAAC,UAAU;;kBAEpB,SAAS;mBAAC,YAAY;;kBAEtB,SAAS;mBAAC,cAAc;;kBAExB,SAAS;mBAAC,WAAW;;kFAhDX,sBAAsB"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * PageHeader component (React parity): page title area with breadcrumbs,
3
+ * description and actions.
4
+ *
5
+ * @module
6
+ */
7
+ import { type AfterViewInit, type DoCheck, ElementRef } from '@angular/core';
8
+ import type { UIClassMap } from '@molecule/app-ui';
9
+ import * as i0 from "@angular/core";
10
+ /** One breadcrumb entry. */
11
+ interface Breadcrumb {
12
+ /** The visible label. */
13
+ label: string;
14
+ /** Link target; without it the crumb renders as a span. */
15
+ href?: string;
16
+ }
17
+ /**
18
+ * PageHeader component.
19
+ *
20
+ * The host is the root `<div>` (`div[mol-page-header]`), exactly React's
21
+ * root. `actions` is a node-valued prop, projected as `[slot=actions]`; its
22
+ * wrapper `<div>` renders only when the slot carries nodes (React's
23
+ * `{actions ? <div>…</div> : null}`), implemented by detaching the wrapper
24
+ * from the DOM — the projected nodes need an always-mounted capture point.
25
+ */
26
+ export declare class PageHeader implements AfterViewInit, DoCheck {
27
+ /** Page title. */
28
+ title: string;
29
+ /** Page description. */
30
+ description?: string;
31
+ /** Breadcrumb trail (empty or absent renders no nav). */
32
+ breadcrumbs?: Breadcrumb[];
33
+ /** Extra classes. */
34
+ className?: string;
35
+ /** Inline style object (React camelCase). */
36
+ style?: Record<string, unknown>;
37
+ /** `data-testid`. */
38
+ testId?: string;
39
+ /** `data-mol-id` automation id. */
40
+ automationId?: string;
41
+ /** The actions wrapper (always in the template; detached when unused). */
42
+ actionsSlot?: ElementRef<HTMLDivElement>;
43
+ private readonly sync;
44
+ private hasActions;
45
+ private actionsParent;
46
+ /**
47
+ * The current class map.
48
+ * @returns The UIClassMap.
49
+ */
50
+ cm(): UIClassMap;
51
+ /**
52
+ * Computes the root class list.
53
+ * @returns The class string.
54
+ */
55
+ classes(): string;
56
+ /**
57
+ * Serializes the inline style.
58
+ * @returns The style attribute text.
59
+ */
60
+ hostStyle(): string | null;
61
+ /**
62
+ * Reads actions presence at view init (view queries resolve only then).
63
+ */
64
+ ngAfterViewInit(): void;
65
+ /**
66
+ * Re-reconciles the actions wrapper on later passes.
67
+ */
68
+ ngDoCheck(): void;
69
+ /**
70
+ * Applies React's `{actions ? <div>…</div> : null}`.
71
+ */
72
+ private syncActions;
73
+ static ɵfac: i0.ɵɵFactoryDeclaration<PageHeader, never>;
74
+ static ɵcmp: i0.ɵɵComponentDeclaration<PageHeader, "div[mol-page-header]", never, { "title": { "alias": "title"; "required": false; }; "description": { "alias": "description"; "required": false; }; "breadcrumbs": { "alias": "breadcrumbs"; "required": false; }; "className": { "alias": "className"; "required": false; }; "style": { "alias": "style"; "required": false; }; "testId": { "alias": "testId"; "required": false; }; "automationId": { "alias": "automationId"; "required": false; }; }, {}, never, ["[slot=actions]"], true, never>;
75
+ }
76
+ export {};
77
+ //# sourceMappingURL=page-header.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-header.component.d.ts","sourceRoot":"","sources":["../../src/components/page-header.component.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,OAAO,EACZ,UAAU,EAIX,MAAM,eAAe,CAAA;AAEtB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;;AAMlD,4BAA4B;AAC5B,UAAU,UAAU;IAClB,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;;GAQG;AACH,qBAoCa,UAAW,YAAW,aAAa,EAAE,OAAO;IACvD,kBAAkB;IAClB,KAAK,SAAK;IACV,wBAAwB;IACxB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,yDAAyD;IACzD,WAAW,CAAC,EAAE,UAAU,EAAE,CAAA;IAC1B,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,qBAAqB;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,mCAAmC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB,0EAA0E;IAChD,WAAW,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,CAAA;IAElE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAyD;IAC9E,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,aAAa,CAA2B;IAEhD;;;OAGG;IACH,EAAE,IAAI,UAAU;IAIhB;;;OAGG;IACH,OAAO,IAAI,MAAM;IAIjB;;;OAGG;IACH,SAAS,IAAI,MAAM,GAAG,IAAI;IAI1B;;OAEG;IACH,eAAe,IAAI,IAAI;IAMvB;;OAEG;IACH,SAAS,IAAI,IAAI;IAIjB;;OAEG;IACH,OAAO,CAAC,WAAW;yCAlER,UAAU;2CAAV,UAAU;CAyEtB"}
@@ -0,0 +1,225 @@
1
+ /**
2
+ * PageHeader component (React parity): page title area with breadcrumbs,
3
+ * description and actions.
4
+ *
5
+ * @module
6
+ */
7
+ import { Component, ElementRef, inject, Renderer2, ViewChild, } from '@angular/core';
8
+ import { getClassMap } from '@molecule/app-ui';
9
+ import { styleText } from '../utilities/style.js';
10
+ import { hasNodes, SlotWrapper } from './button.component.js';
11
+ import * as i0 from "@angular/core";
12
+ const _c0 = ["actionsSlot"];
13
+ const _c1 = [[["", "slot", "actions"]]];
14
+ const _c2 = ["[slot=actions]"];
15
+ const _c3 = () => ({ justify: "between", align: "center" });
16
+ function PageHeader_Conditional_0_For_2_Conditional_0_Template(rf, ctx) { if (rf & 1) {
17
+ i0.ɵɵdomElementStart(0, "span", 6);
18
+ i0.ɵɵtext(1, "/");
19
+ i0.ɵɵdomElementEnd();
20
+ } if (rf & 2) {
21
+ const ctx_r0 = i0.ɵɵnextContext(3);
22
+ i0.ɵɵclassMap(ctx_r0.cm().pageHeaderBreadcrumbSeparator);
23
+ } }
24
+ function PageHeader_Conditional_0_For_2_Conditional_1_Template(rf, ctx) { if (rf & 1) {
25
+ i0.ɵɵdomElementStart(0, "a", 7);
26
+ i0.ɵɵtext(1);
27
+ i0.ɵɵdomElementEnd();
28
+ } if (rf & 2) {
29
+ const crumb_r2 = i0.ɵɵnextContext().$implicit;
30
+ const ctx_r0 = i0.ɵɵnextContext(2);
31
+ i0.ɵɵclassMap(ctx_r0.cm().pageHeaderBreadcrumbItem);
32
+ i0.ɵɵdomProperty("href", crumb_r2.href, i0.ɵɵsanitizeUrl);
33
+ i0.ɵɵadvance();
34
+ i0.ɵɵtextInterpolate(crumb_r2.label);
35
+ } }
36
+ function PageHeader_Conditional_0_For_2_Conditional_2_Template(rf, ctx) { if (rf & 1) {
37
+ i0.ɵɵdomElementStart(0, "span");
38
+ i0.ɵɵtext(1);
39
+ i0.ɵɵdomElementEnd();
40
+ } if (rf & 2) {
41
+ const crumb_r2 = i0.ɵɵnextContext().$implicit;
42
+ const ctx_r0 = i0.ɵɵnextContext(2);
43
+ i0.ɵɵclassMap(ctx_r0.cm().pageHeaderBreadcrumbItem);
44
+ i0.ɵɵadvance();
45
+ i0.ɵɵtextInterpolate(crumb_r2.label);
46
+ } }
47
+ function PageHeader_Conditional_0_For_2_Template(rf, ctx) { if (rf & 1) {
48
+ i0.ɵɵconditionalCreate(0, PageHeader_Conditional_0_For_2_Conditional_0_Template, 2, 2, "span", 4);
49
+ i0.ɵɵconditionalCreate(1, PageHeader_Conditional_0_For_2_Conditional_1_Template, 2, 4, "a", 5)(2, PageHeader_Conditional_0_For_2_Conditional_2_Template, 2, 3, "span", 2);
50
+ } if (rf & 2) {
51
+ const crumb_r2 = ctx.$implicit;
52
+ const $index_r3 = ctx.$index;
53
+ i0.ɵɵconditional($index_r3 > 0 ? 0 : -1);
54
+ i0.ɵɵadvance();
55
+ i0.ɵɵconditional(crumb_r2.href ? 1 : 2);
56
+ } }
57
+ function PageHeader_Conditional_0_Template(rf, ctx) { if (rf & 1) {
58
+ i0.ɵɵdomElementStart(0, "nav", 3);
59
+ i0.ɵɵrepeaterCreate(1, PageHeader_Conditional_0_For_2_Template, 3, 2, null, null, i0.ɵɵrepeaterTrackByIndex);
60
+ i0.ɵɵdomElementEnd();
61
+ } if (rf & 2) {
62
+ const ctx_r0 = i0.ɵɵnextContext();
63
+ i0.ɵɵclassMap(ctx_r0.cm().pageHeaderBreadcrumbs);
64
+ i0.ɵɵadvance();
65
+ i0.ɵɵrepeater(ctx_r0.breadcrumbs);
66
+ } }
67
+ function PageHeader_Conditional_5_Template(rf, ctx) { if (rf & 1) {
68
+ i0.ɵɵdomElementStart(0, "p");
69
+ i0.ɵɵtext(1);
70
+ i0.ɵɵdomElementEnd();
71
+ } if (rf & 2) {
72
+ const ctx_r0 = i0.ɵɵnextContext();
73
+ i0.ɵɵclassMap(ctx_r0.cm().pageHeaderDescription);
74
+ i0.ɵɵadvance();
75
+ i0.ɵɵtextInterpolate(ctx_r0.description);
76
+ } }
77
+ /**
78
+ * PageHeader component.
79
+ *
80
+ * The host is the root `<div>` (`div[mol-page-header]`), exactly React's
81
+ * root. `actions` is a node-valued prop, projected as `[slot=actions]`; its
82
+ * wrapper `<div>` renders only when the slot carries nodes (React's
83
+ * `{actions ? <div>…</div> : null}`), implemented by detaching the wrapper
84
+ * from the DOM — the projected nodes need an always-mounted capture point.
85
+ */
86
+ export class PageHeader {
87
+ /** Page title. */
88
+ title = '';
89
+ /** Page description. */
90
+ description;
91
+ /** Breadcrumb trail (empty or absent renders no nav). */
92
+ breadcrumbs;
93
+ /** Extra classes. */
94
+ className;
95
+ /** Inline style object (React camelCase). */
96
+ style;
97
+ /** `data-testid`. */
98
+ testId;
99
+ /** `data-mol-id` automation id. */
100
+ automationId;
101
+ /** The actions wrapper (always in the template; detached when unused). */
102
+ actionsSlot;
103
+ sync = new SlotWrapper(inject(ElementRef), inject(Renderer2));
104
+ hasActions = false;
105
+ actionsParent = null;
106
+ /**
107
+ * The current class map.
108
+ * @returns The UIClassMap.
109
+ */
110
+ cm() {
111
+ return getClassMap();
112
+ }
113
+ /**
114
+ * Computes the root class list.
115
+ * @returns The class string.
116
+ */
117
+ classes() {
118
+ return this.cm().cn(this.cm().pageHeader, this.className);
119
+ }
120
+ /**
121
+ * Serializes the inline style.
122
+ * @returns The style attribute text.
123
+ */
124
+ hostStyle() {
125
+ return styleText(this.style);
126
+ }
127
+ /**
128
+ * Reads actions presence at view init (view queries resolve only then).
129
+ */
130
+ ngAfterViewInit() {
131
+ this.actionsParent = this.actionsSlot?.nativeElement.parentElement ?? null;
132
+ this.hasActions = hasNodes(this.actionsSlot?.nativeElement);
133
+ this.syncActions();
134
+ }
135
+ /**
136
+ * Re-reconciles the actions wrapper on later passes.
137
+ */
138
+ ngDoCheck() {
139
+ this.syncActions();
140
+ }
141
+ /**
142
+ * Applies React's `{actions ? <div>…</div> : null}`.
143
+ */
144
+ syncActions() {
145
+ this.sync.sync(this.actionsSlot?.nativeElement, this.hasActions, this.actionsParent ?? undefined);
146
+ }
147
+ static ɵfac = function PageHeader_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PageHeader)(); };
148
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PageHeader, selectors: [["div", "mol-page-header", ""]], viewQuery: function PageHeader_Query(rf, ctx) { if (rf & 1) {
149
+ i0.ɵɵviewQuery(_c0, 5);
150
+ } if (rf & 2) {
151
+ let _t;
152
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.actionsSlot = _t.first);
153
+ } }, hostVars: 6, hostBindings: function PageHeader_HostBindings(rf, ctx) { if (rf & 2) {
154
+ i0.ɵɵattribute("data-testid", ctx.testId)("data-mol-id", ctx.automationId);
155
+ i0.ɵɵstyleMap(ctx.hostStyle());
156
+ i0.ɵɵclassMap(ctx.classes());
157
+ } }, inputs: { title: "title", description: "description", breadcrumbs: "breadcrumbs", className: "className", style: "style", testId: "testId", automationId: "automationId" }, ngContentSelectors: _c2, decls: 9, vars: 10, consts: [["actionsSlot", ""], ["aria-label", "Breadcrumb", 3, "class"], [3, "class"], ["aria-label", "Breadcrumb"], ["aria-hidden", "true", 3, "class"], [3, "href", "class"], ["aria-hidden", "true"], [3, "href"]], template: function PageHeader_Template(rf, ctx) { if (rf & 1) {
158
+ i0.ɵɵprojectionDef(_c1);
159
+ i0.ɵɵconditionalCreate(0, PageHeader_Conditional_0_Template, 3, 2, "nav", 1);
160
+ i0.ɵɵdomElementStart(1, "div")(2, "div")(3, "h1");
161
+ i0.ɵɵtext(4);
162
+ i0.ɵɵdomElementEnd();
163
+ i0.ɵɵconditionalCreate(5, PageHeader_Conditional_5_Template, 2, 3, "p", 2);
164
+ i0.ɵɵdomElementEnd();
165
+ i0.ɵɵdomElementStart(6, "div", null, 0);
166
+ i0.ɵɵprojection(8);
167
+ i0.ɵɵdomElementEnd()();
168
+ } if (rf & 2) {
169
+ i0.ɵɵconditional(ctx.breadcrumbs && ctx.breadcrumbs.length > 0 ? 0 : -1);
170
+ i0.ɵɵadvance();
171
+ i0.ɵɵclassMap(ctx.cm().flex(i0.ɵɵpureFunction0(9, _c3)));
172
+ i0.ɵɵadvance(2);
173
+ i0.ɵɵclassMap(ctx.cm().pageHeaderTitle);
174
+ i0.ɵɵadvance();
175
+ i0.ɵɵtextInterpolate(ctx.title);
176
+ i0.ɵɵadvance();
177
+ i0.ɵɵconditional(ctx.description ? 5 : -1);
178
+ i0.ɵɵadvance();
179
+ i0.ɵɵclassMap(ctx.cm().pageHeaderActions);
180
+ } }, encapsulation: 2 });
181
+ }
182
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PageHeader, [{
183
+ type: Component,
184
+ args: [{
185
+ selector: 'div[mol-page-header]',
186
+ standalone: true,
187
+ inputs: ['title', 'description', 'breadcrumbs', 'className', 'style', 'testId', 'automationId'],
188
+ host: {
189
+ '[class]': 'classes()',
190
+ '[style]': 'hostStyle()',
191
+ '[attr.data-testid]': 'testId',
192
+ '[attr.data-mol-id]': 'automationId',
193
+ },
194
+ template: `@if (breadcrumbs && breadcrumbs.length > 0) {
195
+ <nav [class]="cm().pageHeaderBreadcrumbs" aria-label="Breadcrumb">
196
+ @for (crumb of breadcrumbs; track $index) {
197
+ @if ($index > 0) {
198
+ <span [class]="cm().pageHeaderBreadcrumbSeparator" aria-hidden="true">/</span>
199
+ }
200
+ @if (crumb.href) {
201
+ <a [href]="crumb.href" [class]="cm().pageHeaderBreadcrumbItem">{{ crumb.label }}</a>
202
+ } @else {
203
+ <span [class]="cm().pageHeaderBreadcrumbItem">{{ crumb.label }}</span>
204
+ }
205
+ }
206
+ </nav>
207
+ }
208
+ <div [class]="cm().flex({ justify: 'between', align: 'center' })">
209
+ <div>
210
+ <h1 [class]="cm().pageHeaderTitle">{{ title }}</h1>
211
+ @if (description) {
212
+ <p [class]="cm().pageHeaderDescription">{{ description }}</p>
213
+ }
214
+ </div>
215
+ <div #actionsSlot [class]="cm().pageHeaderActions">
216
+ <ng-content select="[slot=actions]"></ng-content>
217
+ </div>
218
+ </div>`,
219
+ }]
220
+ }], null, { actionsSlot: [{
221
+ type: ViewChild,
222
+ args: ['actionsSlot']
223
+ }] }); })();
224
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PageHeader, { className: "PageHeader", filePath: "components/page-header.component.ts", lineNumber: 77 }); })();
225
+ //# sourceMappingURL=page-header.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-header.component.js","sourceRoot":"","sources":["../../src/components/page-header.component.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,SAAS,EAET,UAAU,EACV,MAAM,EACN,SAAS,EACT,SAAS,GACV,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;;;;;;;IAiCjD,kCAAsE;IAAA,iBAAC;IAAA,oBAAO;;;IAAxE,wDAA4C;;;IAGlD,+BAA+D;IAAA,YAAiB;IAAA,oBAAI;;;;IAA7D,mDAAuC;IAA3D,yDAAmB;IAAyC,cAAiB;IAAjB,oCAAiB;;;IAEhF,+BAA8C;IAAA,YAAiB;IAAA,oBAAO;;;;IAAhE,mDAAuC;IAAC,cAAiB;IAAjB,oCAAiB;;;IANjE,iGAAkB;IAKhB,AAFF,8FAAkB,2EAET;;;;IALT,wCAEC;IACD,cAIC;IAJD,uCAIC;;;IATL,iCAAkE;IAChE,4GASC;IACH,oBAAM;;;IAXD,gDAAoC;IACvC,cASC;IATD,iCASC;;;IAOC,4BAAwC;IAAA,YAAiB;IAAA,oBAAI;;;IAA1D,gDAAoC;IAAC,cAAiB;IAAjB,wCAAiB;;AArCnE;;;;;;;;GAQG;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