@molecule/app-ui-angular 1.0.5 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/README.md +11742 -1145
  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 +102 -29
  31. package/dist/components/checkbox.component.d.ts.map +1 -1
  32. package/dist/components/checkbox.component.js +222 -113
  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/dropdown.component.d.ts +313 -0
  43. package/dist/components/dropdown.component.d.ts.map +1 -0
  44. package/dist/components/dropdown.component.js +919 -0
  45. package/dist/components/dropdown.component.js.map +1 -0
  46. package/dist/components/empty-state.component.d.ts +73 -0
  47. package/dist/components/empty-state.component.d.ts.map +1 -0
  48. package/dist/components/empty-state.component.js +180 -0
  49. package/dist/components/empty-state.component.js.map +1 -0
  50. package/dist/components/floating-input.component.d.ts +86 -0
  51. package/dist/components/floating-input.component.d.ts.map +1 -0
  52. package/dist/components/floating-input.component.js +167 -0
  53. package/dist/components/floating-input.component.js.map +1 -0
  54. package/dist/components/form-field.component.d.ts +111 -0
  55. package/dist/components/form-field.component.d.ts.map +1 -0
  56. package/dist/components/form-field.component.js +300 -0
  57. package/dist/components/form-field.component.js.map +1 -0
  58. package/dist/components/form.component.d.ts +77 -0
  59. package/dist/components/form.component.d.ts.map +1 -0
  60. package/dist/components/form.component.js +222 -0
  61. package/dist/components/form.component.js.map +1 -0
  62. package/dist/components/icon.component.d.ts +85 -0
  63. package/dist/components/icon.component.d.ts.map +1 -0
  64. package/dist/components/icon.component.js +187 -0
  65. package/dist/components/icon.component.js.map +1 -0
  66. package/dist/components/index.d.ts +49 -0
  67. package/dist/components/index.d.ts.map +1 -1
  68. package/dist/components/index.js +49 -0
  69. package/dist/components/index.js.map +1 -1
  70. package/dist/components/input.component.d.ts +157 -54
  71. package/dist/components/input.component.d.ts.map +1 -1
  72. package/dist/components/input.component.js +437 -222
  73. package/dist/components/input.component.js.map +1 -1
  74. package/dist/components/label.component.d.ts +29 -0
  75. package/dist/components/label.component.d.ts.map +1 -0
  76. package/dist/components/label.component.js +60 -0
  77. package/dist/components/label.component.js.map +1 -0
  78. package/dist/components/language-picker.component.d.ts +124 -0
  79. package/dist/components/language-picker.component.d.ts.map +1 -0
  80. package/dist/components/language-picker.component.js +305 -0
  81. package/dist/components/language-picker.component.js.map +1 -0
  82. package/dist/components/layout.component.d.ts +167 -0
  83. package/dist/components/layout.component.d.ts.map +1 -0
  84. package/dist/components/layout.component.js +364 -0
  85. package/dist/components/layout.component.js.map +1 -0
  86. package/dist/components/load-error-banner.component.d.ts +103 -0
  87. package/dist/components/load-error-banner.component.d.ts.map +1 -0
  88. package/dist/components/load-error-banner.component.js +263 -0
  89. package/dist/components/load-error-banner.component.js.map +1 -0
  90. package/dist/components/modal.component.d.ts +125 -95
  91. package/dist/components/modal.component.d.ts.map +1 -1
  92. package/dist/components/modal.component.js +458 -271
  93. package/dist/components/modal.component.js.map +1 -1
  94. package/dist/components/molecule/alert.component.d.ts +77 -0
  95. package/dist/components/molecule/alert.component.d.ts.map +1 -0
  96. package/dist/components/molecule/alert.component.js +229 -0
  97. package/dist/components/molecule/alert.component.js.map +1 -0
  98. package/dist/components/molecule/badge.component.d.ts +27 -0
  99. package/dist/components/molecule/badge.component.d.ts.map +1 -0
  100. package/dist/components/molecule/badge.component.js +79 -0
  101. package/dist/components/molecule/badge.component.js.map +1 -0
  102. package/dist/components/molecule/button.component.d.ts +38 -0
  103. package/dist/components/molecule/button.component.d.ts.map +1 -0
  104. package/dist/components/molecule/button.component.js +137 -0
  105. package/dist/components/molecule/button.component.js.map +1 -0
  106. package/dist/components/molecule/checkbox.component.d.ts +53 -0
  107. package/dist/components/molecule/checkbox.component.d.ts.map +1 -0
  108. package/dist/components/molecule/checkbox.component.js +166 -0
  109. package/dist/components/molecule/checkbox.component.js.map +1 -0
  110. package/dist/components/molecule/index.d.ts +18 -0
  111. package/dist/components/molecule/index.d.ts.map +1 -0
  112. package/dist/components/molecule/index.js +18 -0
  113. package/dist/components/molecule/index.js.map +1 -0
  114. package/dist/components/molecule/input.component.d.ts +93 -0
  115. package/dist/components/molecule/input.component.d.ts.map +1 -0
  116. package/dist/components/molecule/input.component.js +314 -0
  117. package/dist/components/molecule/input.component.js.map +1 -0
  118. package/dist/components/molecule/modal.component.d.ts +148 -0
  119. package/dist/components/molecule/modal.component.d.ts.map +1 -0
  120. package/dist/components/molecule/modal.component.js +382 -0
  121. package/dist/components/molecule/modal.component.js.map +1 -0
  122. package/dist/components/molecule/radio-group.component.d.ts +63 -0
  123. package/dist/components/molecule/radio-group.component.d.ts.map +1 -0
  124. package/dist/components/molecule/radio-group.component.js +208 -0
  125. package/dist/components/molecule/radio-group.component.js.map +1 -0
  126. package/dist/components/molecule/select.component.d.ts +72 -0
  127. package/dist/components/molecule/select.component.d.ts.map +1 -0
  128. package/dist/components/molecule/select.component.js +274 -0
  129. package/dist/components/molecule/select.component.js.map +1 -0
  130. package/dist/components/molecule/spinner.component.d.ts +42 -0
  131. package/dist/components/molecule/spinner.component.d.ts.map +1 -0
  132. package/dist/components/molecule/spinner.component.js +122 -0
  133. package/dist/components/molecule/spinner.component.js.map +1 -0
  134. package/dist/components/molecule/switch.component.d.ts +54 -0
  135. package/dist/components/molecule/switch.component.d.ts.map +1 -0
  136. package/dist/components/molecule/switch.component.js +148 -0
  137. package/dist/components/molecule/switch.component.js.map +1 -0
  138. package/dist/components/molecule/toast.component.d.ts +98 -0
  139. package/dist/components/molecule/toast.component.d.ts.map +1 -0
  140. package/dist/components/molecule/toast.component.js +305 -0
  141. package/dist/components/molecule/toast.component.js.map +1 -0
  142. package/dist/components/molecule/tooltip.component.d.ts +77 -0
  143. package/dist/components/molecule/tooltip.component.d.ts.map +1 -0
  144. package/dist/components/molecule/tooltip.component.js +316 -0
  145. package/dist/components/molecule/tooltip.component.js.map +1 -0
  146. package/dist/components/optimistic-toggle-button.component.d.ts +125 -0
  147. package/dist/components/optimistic-toggle-button.component.d.ts.map +1 -0
  148. package/dist/components/optimistic-toggle-button.component.js +296 -0
  149. package/dist/components/optimistic-toggle-button.component.js.map +1 -0
  150. package/dist/components/page-header.component.d.ts +77 -0
  151. package/dist/components/page-header.component.d.ts.map +1 -0
  152. package/dist/components/page-header.component.js +225 -0
  153. package/dist/components/page-header.component.js.map +1 -0
  154. package/dist/components/page-shell.component.d.ts +101 -0
  155. package/dist/components/page-shell.component.d.ts.map +1 -0
  156. package/dist/components/page-shell.component.js +221 -0
  157. package/dist/components/page-shell.component.js.map +1 -0
  158. package/dist/components/pagination.component.d.ts +137 -0
  159. package/dist/components/pagination.component.d.ts.map +1 -0
  160. package/dist/components/pagination.component.js +419 -0
  161. package/dist/components/pagination.component.js.map +1 -0
  162. package/dist/components/panel-close.component.d.ts +43 -0
  163. package/dist/components/panel-close.component.d.ts.map +1 -0
  164. package/dist/components/panel-close.component.js +75 -0
  165. package/dist/components/panel-close.component.js.map +1 -0
  166. package/dist/components/progress.component.d.ts +84 -0
  167. package/dist/components/progress.component.d.ts.map +1 -0
  168. package/dist/components/progress.component.js +219 -0
  169. package/dist/components/progress.component.js.map +1 -0
  170. package/dist/components/prompt-dialog.component.d.ts +121 -0
  171. package/dist/components/prompt-dialog.component.d.ts.map +1 -0
  172. package/dist/components/prompt-dialog.component.js +332 -0
  173. package/dist/components/prompt-dialog.component.js.map +1 -0
  174. package/dist/components/radio-group.component.d.ts +66 -34
  175. package/dist/components/radio-group.component.d.ts.map +1 -1
  176. package/dist/components/radio-group.component.js +146 -125
  177. package/dist/components/radio-group.component.js.map +1 -1
  178. package/dist/components/responsive-app-shell.component.d.ts +408 -0
  179. package/dist/components/responsive-app-shell.component.d.ts.map +1 -0
  180. package/dist/components/responsive-app-shell.component.js +1144 -0
  181. package/dist/components/responsive-app-shell.component.js.map +1 -0
  182. package/dist/components/select.component.d.ts +135 -38
  183. package/dist/components/select.component.d.ts.map +1 -1
  184. package/dist/components/select.component.js +373 -181
  185. package/dist/components/select.component.js.map +1 -1
  186. package/dist/components/separator.component.d.ts +39 -0
  187. package/dist/components/separator.component.d.ts.map +1 -0
  188. package/dist/components/separator.component.js +73 -0
  189. package/dist/components/separator.component.js.map +1 -0
  190. package/dist/components/sidebar-user-card.component.d.ts +106 -0
  191. package/dist/components/sidebar-user-card.component.d.ts.map +1 -0
  192. package/dist/components/sidebar-user-card.component.js +277 -0
  193. package/dist/components/sidebar-user-card.component.js.map +1 -0
  194. package/dist/components/skeleton.component.d.ts +100 -0
  195. package/dist/components/skeleton.component.d.ts.map +1 -0
  196. package/dist/components/skeleton.component.js +214 -0
  197. package/dist/components/skeleton.component.js.map +1 -0
  198. package/dist/components/spinner.component.d.ts +36 -19
  199. package/dist/components/spinner.component.d.ts.map +1 -1
  200. package/dist/components/spinner.component.js +69 -71
  201. package/dist/components/spinner.component.js.map +1 -1
  202. package/dist/components/switch.component.d.ts +72 -29
  203. package/dist/components/switch.component.d.ts.map +1 -1
  204. package/dist/components/switch.component.js +163 -91
  205. package/dist/components/switch.component.js.map +1 -1
  206. package/dist/components/table.component.d.ts +193 -0
  207. package/dist/components/table.component.d.ts.map +1 -0
  208. package/dist/components/table.component.js +550 -0
  209. package/dist/components/table.component.js.map +1 -0
  210. package/dist/components/tabs.component.d.ts +140 -0
  211. package/dist/components/tabs.component.d.ts.map +1 -0
  212. package/dist/components/tabs.component.js +390 -0
  213. package/dist/components/tabs.component.js.map +1 -0
  214. package/dist/components/template-outlet.directive.d.ts +50 -0
  215. package/dist/components/template-outlet.directive.d.ts.map +1 -0
  216. package/dist/components/template-outlet.directive.js +81 -0
  217. package/dist/components/template-outlet.directive.js.map +1 -0
  218. package/dist/components/textarea.component.d.ts +151 -0
  219. package/dist/components/textarea.component.d.ts.map +1 -0
  220. package/dist/components/textarea.component.js +340 -0
  221. package/dist/components/textarea.component.js.map +1 -0
  222. package/dist/components/theme-toggle.component.d.ts +58 -0
  223. package/dist/components/theme-toggle.component.d.ts.map +1 -0
  224. package/dist/components/theme-toggle.component.js +124 -0
  225. package/dist/components/theme-toggle.component.js.map +1 -0
  226. package/dist/components/toast.component.d.ts +237 -49
  227. package/dist/components/toast.component.d.ts.map +1 -1
  228. package/dist/components/toast.component.js +636 -201
  229. package/dist/components/toast.component.js.map +1 -1
  230. package/dist/components/tooltip.component.d.ts +95 -45
  231. package/dist/components/tooltip.component.d.ts.map +1 -1
  232. package/dist/components/tooltip.component.js +372 -221
  233. package/dist/components/tooltip.component.js.map +1 -1
  234. package/dist/components/user-menu-popover.component.d.ts +283 -0
  235. package/dist/components/user-menu-popover.component.d.ts.map +1 -0
  236. package/dist/components/user-menu-popover.component.js +646 -0
  237. package/dist/components/user-menu-popover.component.js.map +1 -0
  238. package/dist/components/user-menu.component.d.ts +95 -0
  239. package/dist/components/user-menu.component.d.ts.map +1 -0
  240. package/dist/components/user-menu.component.js +218 -0
  241. package/dist/components/user-menu.component.js.map +1 -0
  242. package/dist/hooks/index.d.ts +7 -0
  243. package/dist/hooks/index.d.ts.map +1 -0
  244. package/dist/hooks/index.js +7 -0
  245. package/dist/hooks/index.js.map +1 -0
  246. package/dist/hooks/use-is-desktop.d.ts +22 -0
  247. package/dist/hooks/use-is-desktop.d.ts.map +1 -0
  248. package/dist/hooks/use-is-desktop.js +37 -0
  249. package/dist/hooks/use-is-desktop.js.map +1 -0
  250. package/dist/index.d.ts +32 -17
  251. package/dist/index.d.ts.map +1 -1
  252. package/dist/index.js +32 -17
  253. package/dist/index.js.map +1 -1
  254. package/dist/types.d.ts +1 -1
  255. package/dist/types.d.ts.map +1 -1
  256. package/dist/utilities/dom-context.d.ts +42 -0
  257. package/dist/utilities/dom-context.d.ts.map +1 -0
  258. package/dist/utilities/dom-context.js +66 -0
  259. package/dist/utilities/dom-context.js.map +1 -0
  260. package/dist/utilities/focus.d.ts +32 -0
  261. package/dist/utilities/focus.d.ts.map +1 -0
  262. package/dist/utilities/focus.js +47 -0
  263. package/dist/utilities/focus.js.map +1 -0
  264. package/dist/utilities/form-field-context.d.ts +34 -0
  265. package/dist/utilities/form-field-context.d.ts.map +1 -0
  266. package/dist/utilities/form-field-context.js +28 -0
  267. package/dist/utilities/form-field-context.js.map +1 -0
  268. package/dist/utilities/form-submit-error.d.ts +17 -0
  269. package/dist/utilities/form-submit-error.d.ts.map +1 -0
  270. package/dist/utilities/form-submit-error.js +42 -0
  271. package/dist/utilities/form-submit-error.js.map +1 -0
  272. package/dist/utilities/icon-markup.d.ts +17 -0
  273. package/dist/utilities/icon-markup.d.ts.map +1 -0
  274. package/dist/utilities/icon-markup.js +46 -0
  275. package/dist/utilities/icon-markup.js.map +1 -0
  276. package/dist/utilities/ids.d.ts +15 -0
  277. package/dist/utilities/ids.d.ts.map +1 -0
  278. package/dist/utilities/ids.js +19 -0
  279. package/dist/utilities/ids.js.map +1 -0
  280. package/dist/utilities/index.d.ts +11 -0
  281. package/dist/utilities/index.d.ts.map +1 -1
  282. package/dist/utilities/index.js +11 -0
  283. package/dist/utilities/index.js.map +1 -1
  284. package/dist/utilities/initials.d.ts +13 -0
  285. package/dist/utilities/initials.d.ts.map +1 -0
  286. package/dist/utilities/initials.js +23 -0
  287. package/dist/utilities/initials.js.map +1 -0
  288. package/dist/utilities/node-value.d.ts +31 -0
  289. package/dist/utilities/node-value.d.ts.map +1 -0
  290. package/dist/utilities/node-value.js +37 -0
  291. package/dist/utilities/node-value.js.map +1 -0
  292. package/dist/utilities/optimistic-value.d.ts +81 -0
  293. package/dist/utilities/optimistic-value.d.ts.map +1 -0
  294. package/dist/utilities/optimistic-value.js +154 -0
  295. package/dist/utilities/optimistic-value.js.map +1 -0
  296. package/dist/utilities/render-icon.d.ts +77 -7
  297. package/dist/utilities/render-icon.d.ts.map +1 -1
  298. package/dist/utilities/render-icon.js +123 -33
  299. package/dist/utilities/render-icon.js.map +1 -1
  300. package/dist/utilities/rest-attrs.d.ts +21 -0
  301. package/dist/utilities/rest-attrs.d.ts.map +1 -0
  302. package/dist/utilities/rest-attrs.js +37 -0
  303. package/dist/utilities/rest-attrs.js.map +1 -0
  304. package/dist/utilities/style.d.ts +23 -0
  305. package/dist/utilities/style.d.ts.map +1 -0
  306. package/dist/utilities/style.js +86 -0
  307. package/dist/utilities/style.js.map +1 -0
  308. package/package.json +10 -5
@@ -1,78 +1,78 @@
1
1
  /**
2
- * Angular Badge UI component with UIClassMap-driven styling.
2
+ * Badge component (React parity).
3
3
  *
4
4
  * @module
5
5
  */
6
- import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
6
+ import { Component } from '@angular/core';
7
7
  import { getClassMap } from '@molecule/app-ui';
8
+ import { styleText } from '../utilities/style.js';
8
9
  import * as i0 from "@angular/core";
9
10
  const _c0 = ["*"];
10
11
  /**
11
- * Angular Badge UI component with UIClassMap-driven styling.
12
- */
13
- /**
14
- * Molecule Badge class.
12
+ * Badge component.
13
+ *
14
+ * The host element is the `<span>` React renders (`span[mol-badge]`); the
15
+ * color variant maps to `badge({ variant })` exactly as React's `Badge`.
15
16
  */
16
- export class MoleculeBadge {
17
+ export class Badge {
18
+ /** Named color variant (`primary`, `success`, …). */
17
19
  color = 'primary';
20
+ /** Visual style (kept for React prop parity; the class map keys off `color`). */
18
21
  variant = 'solid';
22
+ /** Badge size. */
19
23
  size;
24
+ /** Whether the badge is fully rounded (default) or square. */
20
25
  rounded = true;
26
+ /** Extra classes joined onto the badge classes. */
21
27
  className;
28
+ /** Inline style object (React camelCase). */
22
29
  style;
30
+ /** `data-testid` for the badge. */
23
31
  testId;
24
32
  /**
25
- * Retrieves the current UI class map.
26
- * @returns The UIClassMap instance for styling.
33
+ * The current class map.
34
+ * @returns The UIClassMap.
27
35
  */
28
- get cm() {
36
+ cm() {
29
37
  return getClassMap();
30
38
  }
31
39
  /**
32
- * Computes the combined CSS classes for the badge element.
33
- * @returns The badge class name string.
40
+ * Computes the badge class list.
41
+ * @returns The class string.
34
42
  */
35
- get badgeClasses() {
36
- return this.cm.cn(this.cm.badge({ variant: this.color, size: this.size }), !this.rounded && this.cm.badgeSquare, this.className);
43
+ classes() {
44
+ return this.cm().cn(this.cm().badge({ variant: this.color, size: this.size }), !this.rounded && this.cm().badgeSquare, this.className);
37
45
  }
38
- static ɵfac = function MoleculeBadge_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MoleculeBadge)(); };
39
- static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MoleculeBadge, selectors: [["mol-badge"]], inputs: { color: "color", variant: "variant", size: "size", rounded: "rounded", className: "className", style: "style", testId: "testId" }, ngContentSelectors: _c0, decls: 2, vars: 5, template: function MoleculeBadge_Template(rf, ctx) { if (rf & 1) {
40
- i0.ɵɵprojectionDef();
41
- i0.ɵɵdomElementStart(0, "span");
42
- i0.ɵɵprojection(1);
43
- i0.ɵɵdomElementEnd();
44
- } if (rf & 2) {
45
- i0.ɵɵstyleMap(ctx.style);
46
- i0.ɵɵclassMap(ctx.badgeClasses);
46
+ /**
47
+ * Serializes the inline style.
48
+ * @returns The style attribute text.
49
+ */
50
+ hostStyle() {
51
+ return styleText(this.style);
52
+ }
53
+ static ɵfac = function Badge_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Badge)(); };
54
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Badge, selectors: [["span", "mol-badge", ""]], hostVars: 5, hostBindings: function Badge_HostBindings(rf, ctx) { if (rf & 2) {
47
55
  i0.ɵɵattribute("data-testid", ctx.testId);
56
+ i0.ɵɵstyleMap(ctx.hostStyle());
57
+ i0.ɵɵclassMap(ctx.classes());
58
+ } }, inputs: { color: "color", variant: "variant", size: "size", rounded: "rounded", className: "className", style: "style", testId: "testId" }, ngContentSelectors: _c0, decls: 1, vars: 0, template: function Badge_Template(rf, ctx) { if (rf & 1) {
59
+ i0.ɵɵprojectionDef();
60
+ i0.ɵɵprojection(0);
48
61
  } }, encapsulation: 2 });
49
62
  }
50
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MoleculeBadge, [{
63
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Badge, [{
51
64
  type: Component,
52
65
  args: [{
53
- selector: 'mol-badge',
66
+ selector: 'span[mol-badge]',
54
67
  standalone: true,
55
- changeDetection: ChangeDetectionStrategy.OnPush,
56
- template: `
57
- <span [class]="badgeClasses" [style]="style" [attr.data-testid]="testId">
58
- <ng-content></ng-content>
59
- </span>
60
- `,
68
+ inputs: ['color', 'variant', 'size', 'rounded', 'className', 'style', 'testId'],
69
+ host: {
70
+ '[class]': 'classes()',
71
+ '[style]': 'hostStyle()',
72
+ '[attr.data-testid]': 'testId',
73
+ },
74
+ template: `<ng-content></ng-content>`,
61
75
  }]
62
- }], null, { color: [{
63
- type: Input
64
- }], variant: [{
65
- type: Input
66
- }], size: [{
67
- type: Input
68
- }], rounded: [{
69
- type: Input
70
- }], className: [{
71
- type: Input
72
- }], style: [{
73
- type: Input
74
- }], testId: [{
75
- type: Input
76
- }] }); })();
77
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MoleculeBadge, { className: "MoleculeBadge", filePath: "components/badge.component.ts", lineNumber: 28 }); })();
76
+ }], null, null); })();
77
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Badge, { className: "Badge", filePath: "components/badge.component.ts", lineNumber: 31 }); })();
78
78
  //# sourceMappingURL=badge.component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"badge.component.js","sourceRoot":"","sources":["../../src/components/badge.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAGzE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;;;AAE9C;;GAEG;AAWH;;GAEG;AACH,MAAM,OAAO,aAAa;IACf,KAAK,GAAiB,SAAS,CAAA;IAC/B,OAAO,GAAmC,OAAO,CAAA;IACjD,IAAI,CAAO;IACX,OAAO,GAAG,IAAI,CAAA;IACd,SAAS,CAAS;IAClB,KAAK,CAAyB;IAC9B,MAAM,CAAS;IAExB;;;OAGG;IACH,IAAY,EAAE;QACZ,OAAO,WAAW,EAAE,CAAA;IACtB,CAAC;IAED;;;OAGG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,EAAE,CAAC,EAAE,CACf,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,EACvD,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,EAAE,CAAC,WAAW,EACpC,IAAI,CAAC,SAAS,CACf,CAAA;IACH,CAAC;uGA3BU,aAAa;6DAAb,aAAa;;YARtB,+BAAyE;YACvE,kBAAyB;YAC3B,oBAAO;;YAFsB,wBAAe;YAAtC,+BAAsB;;;;iFAQnB,aAAa;cAbzB,SAAS;eAAC;gBACT,QAAQ,EAAE,WAAW;gBACrB,UAAU,EAAE,IAAI;gBAChB,eAAe,EAAE,uBAAuB,CAAC,MAAM;gBAC/C,QAAQ,EAAE;;;;GAIT;aACF;;kBAKE,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kFAPK,aAAa"}
1
+ {"version":3,"file":"badge.component.js","sourceRoot":"","sources":["../../src/components/badge.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAGzC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;;;AAEjD;;;;;GAKG;AAYH,MAAM,OAAO,KAAK;IAChB,qDAAqD;IACrD,KAAK,GAAiB,SAAS,CAAA;IAC/B,iFAAiF;IACjF,OAAO,GAAmC,OAAO,CAAA;IACjD,kBAAkB;IAClB,IAAI,CAAO;IACX,8DAA8D;IAC9D,OAAO,GAAG,IAAI,CAAA;IACd,mDAAmD;IACnD,SAAS,CAAS;IAClB,6CAA6C;IAC7C,KAAK,CAA0B;IAC/B,mCAAmC;IACnC,MAAM,CAAS;IAEf;;;OAGG;IACH,EAAE;QACA,OAAO,WAAW,EAAE,CAAA;IACtB,CAAC;IAED;;;OAGG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CACjB,IAAI,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,EACzD,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,WAAW,EACtC,IAAI,CAAC,SAAS,CACf,CAAA;IACH,CAAC;IAED;;;OAGG;IACH,SAAS;QACP,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC9B,CAAC;+FA1CU,KAAK;6DAAL,KAAK;;YAAL,cAAA,eACV,CADe;YAAL,cAAA,aACZ,CADiB;;;YAFL,kBAAyB;;;iFAEzB,KAAK;cAXjB,SAAS;eAAC;gBACT,QAAQ,EAAE,iBAAiB;gBAC3B,UAAU,EAAE,IAAI;gBAChB,MAAM,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,CAAC;gBAC/E,IAAI,EAAE;oBACJ,SAAS,EAAE,WAAW;oBACtB,SAAS,EAAE,aAAa;oBACxB,oBAAoB,EAAE,QAAQ;iBAC/B;gBACD,QAAQ,EAAE,2BAA2B;aACtC;;kFACY,KAAK"}
@@ -1,38 +1,120 @@
1
1
  /**
2
- * Angular Button UI component with UIClassMap-driven styling.
2
+ * Button component (React parity).
3
3
  *
4
4
  * @module
5
5
  */
6
- import { EventEmitter } from '@angular/core';
6
+ import { type AfterViewInit, type DoCheck, ElementRef, Renderer2 } from '@angular/core';
7
7
  import type { ButtonVariant, ColorVariant, Size, UIClassMap } from '@molecule/app-ui';
8
8
  import * as i0 from "@angular/core";
9
9
  /**
10
- * Angular Button UI component with UIClassMap-driven styling.
10
+ * Whether an ng-content wrapper captured any element or text node.
11
+ *
12
+ * @param el - The wrapper element.
13
+ * @returns True when at least one projected node exists.
14
+ */
15
+ export declare function hasNodes(el: Element | undefined | null): boolean;
16
+ /**
17
+ * Attaches or detaches an always-mounted projection wrapper element from its
18
+ * parent, remembering the re-insertion position with a comment anchor the DOM
19
+ * normalizer strips.
20
+ *
21
+ * React renders `{cond && <span>{slot}</span>}` — nothing when the condition
22
+ * is false. Angular needs the `<ng-content>` capture point to stay mounted,
23
+ * so the wrapper span always exists in the template and this helper removes
24
+ * it from the DOM whenever React would not render it.
25
+ */
26
+ export declare class SlotWrapper {
27
+ private readonly host;
28
+ private readonly renderer;
29
+ private readonly anchors;
30
+ /**
31
+ * Creates the wrapper helper.
32
+ *
33
+ * @param host - The component host element (default detach parent).
34
+ * @param renderer - The DOM renderer.
35
+ */
36
+ constructor(host: ElementRef<HTMLElement>, renderer: Renderer2);
37
+ /**
38
+ * Attaches or detaches the element (default parent: the component host).
39
+ *
40
+ * @param el - The wrapper element.
41
+ * @param shouldAttach - Whether it should be in the DOM.
42
+ * @param parent - Where the element lives when attached (default: host).
43
+ */
44
+ sync(el: Element | undefined | null, shouldAttach: boolean, parent?: Node): void;
45
+ }
46
+ /**
47
+ * Button component.
48
+ *
49
+ * While `loading` is true, the native button is disabled and marked busy.
50
+ * The host element is the `<button>` itself (`button[mol-button]`), matching
51
+ * React's root exactly. Icon slots are projected as `[slot=leftIcon]` /
52
+ * `[slot=rightIcon]`; each wrapping `<span>` renders only while the slot
53
+ * carries nodes AND the button is not loading — React's
54
+ * `{!loading && !!leftIcon && <span>…}` — implemented by detaching the
55
+ * wrapper from the DOM (the projected nodes must have an always-mounted
56
+ * capture point, so the wrapper lives in the template unconditionally).
11
57
  */
12
- export declare class MoleculeButton {
58
+ export declare class Button implements AfterViewInit, DoCheck {
59
+ /** Button variant. */
13
60
  variant: ButtonVariant;
61
+ /** Button color. */
14
62
  color: ColorVariant;
63
+ /** Button size. */
15
64
  size: Size;
65
+ /** Whether the button is in its loading (busy) state. */
16
66
  loading: boolean;
67
+ /** Text shown instead of children while loading. */
17
68
  loadingText?: string;
69
+ /** Whether the button stretches to fill its container. */
18
70
  fullWidth: boolean;
71
+ /** Extra classes joined onto the button classes. */
19
72
  className?: string;
20
- style?: Record<string, string>;
73
+ /** Inline style object (React camelCase). */
74
+ style?: Record<string, unknown>;
75
+ /** `data-testid` for the button. */
21
76
  testId?: string;
77
+ /** Disables the button. */
22
78
  disabled: boolean;
79
+ /** The button's `type` attribute. */
23
80
  type: 'button' | 'submit' | 'reset';
24
- handleClick: EventEmitter<MouseEvent>;
81
+ /** The left icon wrapper (always in the template; detached when unused). */
82
+ leftSlot?: ElementRef<HTMLSpanElement>;
83
+ /** The right icon wrapper. */
84
+ rightSlot?: ElementRef<HTMLSpanElement>;
85
+ private readonly sync;
86
+ /**
87
+ * The current class map.
88
+ * @returns The UIClassMap.
89
+ */
90
+ cm(): UIClassMap;
91
+ /**
92
+ * Computes the button class list.
93
+ * @returns The class string.
94
+ */
95
+ classes(): string;
96
+ /**
97
+ * Serializes the inline style.
98
+ * @returns The style attribute text.
99
+ */
100
+ hostStyle(): string | null;
101
+ private hasLeft;
102
+ private hasRight;
103
+ /**
104
+ * Detects slot content and detaches the wrappers React would not render.
105
+ * View queries resolve only by view init (the first pass), so presence is
106
+ * read here rather than at content init.
107
+ */
108
+ ngAfterViewInit(): void;
25
109
  /**
26
- * Retrieves the current UI class map.
27
- * @returns The UIClassMap instance for styling.
110
+ * Re-reconciles the wrappers when `loading` changes.
28
111
  */
29
- get cm(): UIClassMap;
112
+ ngDoCheck(): void;
30
113
  /**
31
- * Computes the combined CSS classes for the button element.
32
- * @returns The button class name string.
114
+ * Applies React's `{!loading && !!icon}` wrapper conditions.
33
115
  */
34
- get classes(): string;
35
- static ɵfac: i0.ɵɵFactoryDeclaration<MoleculeButton, never>;
36
- static ɵcmp: i0.ɵɵComponentDeclaration<MoleculeButton, "mol-button", never, { "variant": { "alias": "variant"; "required": false; }; "color": { "alias": "color"; "required": false; }; "size": { "alias": "size"; "required": false; }; "loading": { "alias": "loading"; "required": false; }; "loadingText": { "alias": "loadingText"; "required": false; }; "fullWidth": { "alias": "fullWidth"; "required": false; }; "className": { "alias": "className"; "required": false; }; "style": { "alias": "style"; "required": false; }; "testId": { "alias": "testId"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "type": { "alias": "type"; "required": false; }; }, { "handleClick": "handleClick"; }, never, ["*"], true, never>;
116
+ private syncWrappers;
117
+ static ɵfac: i0.ɵɵFactoryDeclaration<Button, never>;
118
+ static ɵcmp: i0.ɵɵComponentDeclaration<Button, "button[mol-button]", never, { "variant": { "alias": "variant"; "required": false; }; "color": { "alias": "color"; "required": false; }; "size": { "alias": "size"; "required": false; }; "loading": { "alias": "loading"; "required": false; }; "loadingText": { "alias": "loadingText"; "required": false; }; "fullWidth": { "alias": "fullWidth"; "required": false; }; "className": { "alias": "className"; "required": false; }; "style": { "alias": "style"; "required": false; }; "testId": { "alias": "testId"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "type": { "alias": "type"; "required": false; }; }, {}, never, ["[slot=leftIcon]", "*", "[slot=rightIcon]"], true, never>;
37
119
  }
38
120
  //# sourceMappingURL=button.component.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"button.component.d.ts","sourceRoot":"","sources":["../../src/components/button.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAsC,YAAY,EAAiB,MAAM,eAAe,CAAA;AAE/F,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;;AAGrF;;GAEG;AACH,qBA6Ba,cAAc;IAChB,OAAO,EAAE,aAAa,CAAU;IAChC,KAAK,EAAE,YAAY,CAAY;IAC/B,IAAI,EAAE,IAAI,CAAO;IACjB,OAAO,UAAQ;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,UAAQ;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,UAAQ;IAChB,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAW;IAE7C,WAAW,2BAAiC;IAEtD;;;OAGG;IACH,IAAI,EAAE,IAAI,UAAU,CAEnB;IAED;;;OAGG;IACH,IAAI,OAAO,IAAI,MAAM,CAUpB;yCArCU,cAAc;2CAAd,cAAc;CAsC1B"}
1
+ {"version":3,"file":"button.component.d.ts","sourceRoot":"","sources":["../../src/components/button.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,OAAO,EACZ,UAAU,EAEV,SAAS,EAEV,MAAM,eAAe,CAAA;AAEtB,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;;AAMrF;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAOhE;AAED;;;;;;;;;GASG;AACH,qBAAa,WAAW;IAUpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAV3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2B;IAEnD;;;;;OAKG;gBAEgB,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,EAC7B,QAAQ,EAAE,SAAS;IAGtC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI;CAqBjF;AAED;;;;;;;;;;;GAWG;AACH,qBAwCa,MAAO,YAAW,aAAa,EAAE,OAAO;IACnD,sBAAsB;IACtB,OAAO,EAAE,aAAa,CAAU;IAChC,oBAAoB;IACpB,KAAK,EAAE,YAAY,CAAY;IAC/B,mBAAmB;IACnB,IAAI,EAAE,IAAI,CAAO;IACjB,yDAAyD;IACzD,OAAO,UAAQ;IACf,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,0DAA0D;IAC1D,SAAS,UAAQ;IACjB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,2BAA2B;IAC3B,QAAQ,UAAQ;IAChB,qCAAqC;IACrC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAW;IAE9C,4EAA4E;IACrD,QAAQ,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAC7D,8BAA8B;IACN,SAAS,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAE/D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAyD;IAE9E;;;OAGG;IACH,EAAE,IAAI,UAAU;IAIhB;;;OAGG;IACH,OAAO,IAAI,MAAM;IAYjB;;;OAGG;IACH,SAAS,IAAI,MAAM,GAAG,IAAI;IAI1B,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,QAAQ,CAAQ;IAExB;;;;OAIG;IACH,eAAe,IAAI,IAAI;IAQvB;;OAEG;IACH,SAAS,IAAI,IAAI;IAIjB;;OAEG;IACH,OAAO,CAAC,YAAY;yCAzFT,MAAM;2CAAN,MAAM;CA6FlB"}
@@ -1,136 +1,281 @@
1
1
  /**
2
- * Angular Button UI component with UIClassMap-driven styling.
2
+ * Button component (React parity).
3
3
  *
4
4
  * @module
5
5
  */
6
- import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
6
+ import { Component, ElementRef, inject, Renderer2, ViewChild, } from '@angular/core';
7
7
  import { getClassMap } from '@molecule/app-ui';
8
+ import { styleText } from '../utilities/style.js';
9
+ import { Spinner } from './spinner.component.js';
8
10
  import * as i0 from "@angular/core";
9
- const _c0 = ["*"];
10
- function MoleculeButton_Conditional_1_Template(rf, ctx) { if (rf & 1) {
11
- i0.ɵɵdomElement(0, "span");
11
+ const _c0 = ["leftSlot"];
12
+ const _c1 = ["rightSlot"];
13
+ const _c2 = [[["", "slot", "lefticon"]], [["", "slot", "righticon"]], "*"];
14
+ const _c3 = ["[slot=leftIcon]", "[slot=rightIcon]", "*"];
15
+ function Button_Conditional_0_Template(rf, ctx) { if (rf & 1) {
16
+ i0.ɵɵelement(0, "div", 2);
12
17
  } if (rf & 2) {
13
18
  const ctx_r0 = i0.ɵɵnextContext();
14
- i0.ɵɵclassMap(ctx_r0.cm.buttonSpinner);
19
+ i0.ɵɵproperty("size", "sm")("className", ctx_r0.cm().buttonIconLeft);
15
20
  } }
16
- function MoleculeButton_Conditional_2_Template(rf, ctx) { if (rf & 1) {
17
- i0.ɵɵtext(0);
21
+ function Button_Conditional_4_Template(rf, ctx) { if (rf & 1) {
22
+ i0.ɵɵelementContainerStart(0);
23
+ i0.ɵɵtext(1);
24
+ i0.ɵɵelementContainerEnd();
18
25
  } if (rf & 2) {
19
26
  const ctx_r0 = i0.ɵɵnextContext();
20
- i0.ɵɵtextInterpolate1(" ", ctx_r0.loadingText, " ");
27
+ i0.ɵɵadvance();
28
+ i0.ɵɵtextInterpolate(ctx_r0.loadingText);
21
29
  } }
22
- function MoleculeButton_Conditional_3_Template(rf, ctx) { if (rf & 1) {
23
- i0.ɵɵprojection(0);
30
+ function Button_Conditional_5_Template(rf, ctx) { if (rf & 1) {
31
+ i0.ɵɵprojection(0, 2);
24
32
  } }
25
33
  /**
26
- * Angular Button UI component with UIClassMap-driven styling.
34
+ * Whether an ng-content wrapper captured any element or text node.
35
+ *
36
+ * @param el - The wrapper element.
37
+ * @returns True when at least one projected node exists.
27
38
  */
39
+ export function hasNodes(el) {
40
+ if (!el)
41
+ return false;
42
+ for (const node of Array.from(el.childNodes)) {
43
+ if (node.nodeType === 1)
44
+ return true;
45
+ if (node.nodeType === 3 && (node.textContent ?? '').trim())
46
+ return true;
47
+ }
48
+ return false;
49
+ }
28
50
  /**
29
- * Molecule Button class.
51
+ * Attaches or detaches an always-mounted projection wrapper element from its
52
+ * parent, remembering the re-insertion position with a comment anchor the DOM
53
+ * normalizer strips.
54
+ *
55
+ * React renders `{cond && <span>{slot}</span>}` — nothing when the condition
56
+ * is false. Angular needs the `<ng-content>` capture point to stay mounted,
57
+ * so the wrapper span always exists in the template and this helper removes
58
+ * it from the DOM whenever React would not render it.
30
59
  */
31
- export class MoleculeButton {
60
+ export class SlotWrapper {
61
+ host;
62
+ renderer;
63
+ anchors = new Map();
64
+ /**
65
+ * Creates the wrapper helper.
66
+ *
67
+ * @param host - The component host element (default detach parent).
68
+ * @param renderer - The DOM renderer.
69
+ */
70
+ constructor(host, renderer) {
71
+ this.host = host;
72
+ this.renderer = renderer;
73
+ }
74
+ /**
75
+ * Attaches or detaches the element (default parent: the component host).
76
+ *
77
+ * @param el - The wrapper element.
78
+ * @param shouldAttach - Whether it should be in the DOM.
79
+ * @param parent - Where the element lives when attached (default: host).
80
+ */
81
+ sync(el, shouldAttach, parent) {
82
+ if (!el)
83
+ return;
84
+ const host = parent ?? this.host.nativeElement;
85
+ if (shouldAttach && !el.isConnected) {
86
+ const anchor = this.anchors.get(el);
87
+ if (anchor?.isConnected) {
88
+ host.insertBefore(el, anchor);
89
+ this.renderer.removeChild(host, anchor);
90
+ this.anchors.delete(el);
91
+ }
92
+ else {
93
+ host.appendChild(el);
94
+ }
95
+ }
96
+ else if (!shouldAttach && el.isConnected) {
97
+ // Placeholder comment keeps the re-insertion position stable; the
98
+ // normalizer strips comment nodes, so it never shows in snapshots.
99
+ const placeholder = this.renderer.createComment('slot');
100
+ host.insertBefore(placeholder, el);
101
+ this.anchors.set(el, placeholder);
102
+ this.renderer.removeChild(host, el);
103
+ }
104
+ }
105
+ }
106
+ /**
107
+ * Button component.
108
+ *
109
+ * While `loading` is true, the native button is disabled and marked busy.
110
+ * The host element is the `<button>` itself (`button[mol-button]`), matching
111
+ * React's root exactly. Icon slots are projected as `[slot=leftIcon]` /
112
+ * `[slot=rightIcon]`; each wrapping `<span>` renders only while the slot
113
+ * carries nodes AND the button is not loading — React's
114
+ * `{!loading && !!leftIcon && <span>…}` — implemented by detaching the
115
+ * wrapper from the DOM (the projected nodes must have an always-mounted
116
+ * capture point, so the wrapper lives in the template unconditionally).
117
+ */
118
+ export class Button {
119
+ /** Button variant. */
32
120
  variant = 'solid';
121
+ /** Button color. */
33
122
  color = 'primary';
123
+ /** Button size. */
34
124
  size = 'md';
125
+ /** Whether the button is in its loading (busy) state. */
35
126
  loading = false;
127
+ /** Text shown instead of children while loading. */
36
128
  loadingText;
129
+ /** Whether the button stretches to fill its container. */
37
130
  fullWidth = false;
131
+ /** Extra classes joined onto the button classes. */
38
132
  className;
133
+ /** Inline style object (React camelCase). */
39
134
  style;
135
+ /** `data-testid` for the button. */
40
136
  testId;
137
+ /** Disables the button. */
41
138
  disabled = false;
139
+ /** The button's `type` attribute. */
42
140
  type = 'button';
43
- handleClick = new EventEmitter();
141
+ /** The left icon wrapper (always in the template; detached when unused). */
142
+ leftSlot;
143
+ /** The right icon wrapper. */
144
+ rightSlot;
145
+ sync = new SlotWrapper(inject(ElementRef), inject(Renderer2));
44
146
  /**
45
- * Retrieves the current UI class map.
46
- * @returns The UIClassMap instance for styling.
147
+ * The current class map.
148
+ * @returns The UIClassMap.
47
149
  */
48
- get cm() {
150
+ cm() {
49
151
  return getClassMap();
50
152
  }
51
153
  /**
52
- * Computes the combined CSS classes for the button element.
53
- * @returns The button class name string.
154
+ * Computes the button class list.
155
+ * @returns The class string.
54
156
  */
55
- get classes() {
56
- return this.cm.cn(this.cm.button({
157
+ classes() {
158
+ return this.cm().cn(this.cm().button({
57
159
  variant: this.variant,
58
160
  color: this.color,
59
161
  size: this.size,
60
162
  fullWidth: this.fullWidth,
61
163
  }), this.className);
62
164
  }
63
- static ɵfac = function MoleculeButton_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MoleculeButton)(); };
64
- static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MoleculeButton, selectors: [["mol-button"]], hostAttrs: [2, "display", "contents"], inputs: { variant: "variant", color: "color", size: "size", loading: "loading", loadingText: "loadingText", fullWidth: "fullWidth", className: "className", style: "style", testId: "testId", disabled: "disabled", type: "type" }, outputs: { handleClick: "handleClick" }, ngContentSelectors: _c0, decls: 4, vars: 10, consts: [[3, "click", "type", "disabled"], [3, "class"]], template: function MoleculeButton_Template(rf, ctx) { if (rf & 1) {
65
- i0.ɵɵprojectionDef();
66
- i0.ɵɵdomElementStart(0, "button", 0);
67
- i0.ɵɵdomListener("click", function MoleculeButton_Template_button_click_0_listener($event) { return ctx.handleClick.emit($event); });
68
- i0.ɵɵconditionalCreate(1, MoleculeButton_Conditional_1_Template, 1, 2, "span", 1);
69
- i0.ɵɵconditionalCreate(2, MoleculeButton_Conditional_2_Template, 1, 1)(3, MoleculeButton_Conditional_3_Template, 1, 0);
70
- i0.ɵɵdomElementEnd();
165
+ /**
166
+ * Serializes the inline style.
167
+ * @returns The style attribute text.
168
+ */
169
+ hostStyle() {
170
+ return styleText(this.style);
171
+ }
172
+ hasLeft = false;
173
+ hasRight = false;
174
+ /**
175
+ * Detects slot content and detaches the wrappers React would not render.
176
+ * View queries resolve only by view init (the first pass), so presence is
177
+ * read here rather than at content init.
178
+ */
179
+ ngAfterViewInit() {
180
+ const left = this.leftSlot?.nativeElement;
181
+ const right = this.rightSlot?.nativeElement;
182
+ this.hasLeft = left ? hasNodes(left) : false;
183
+ this.hasRight = right ? hasNodes(right) : false;
184
+ this.syncWrappers();
185
+ }
186
+ /**
187
+ * Re-reconciles the wrappers when `loading` changes.
188
+ */
189
+ ngDoCheck() {
190
+ this.syncWrappers();
191
+ }
192
+ /**
193
+ * Applies React's `{!loading && !!icon}` wrapper conditions.
194
+ */
195
+ syncWrappers() {
196
+ this.sync.sync(this.leftSlot?.nativeElement, this.hasLeft && !this.loading);
197
+ this.sync.sync(this.rightSlot?.nativeElement, this.hasRight && !this.loading);
198
+ }
199
+ static ɵfac = function Button_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Button)(); };
200
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Button, selectors: [["button", "mol-button", ""]], viewQuery: function Button_Query(rf, ctx) { if (rf & 1) {
201
+ i0.ɵɵviewQuery(_c0, 5)(_c1, 5);
71
202
  } if (rf & 2) {
72
- i0.ɵɵstyleMap(ctx.style);
73
- i0.ɵɵclassMap(ctx.classes);
74
- i0.ɵɵdomProperty("type", ctx.type)("disabled", ctx.disabled || ctx.loading);
75
- i0.ɵɵattribute("data-testid", ctx.testId)("aria-busy", ctx.loading);
76
- i0.ɵɵadvance();
77
- i0.ɵɵconditional(ctx.loading ? 1 : -1);
203
+ let _t;
204
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.leftSlot = _t.first);
205
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.rightSlot = _t.first);
206
+ } }, hostVars: 8, hostBindings: function Button_HostBindings(rf, ctx) { if (rf & 2) {
207
+ i0.ɵɵdomProperty("disabled", ctx.disabled || ctx.loading);
208
+ i0.ɵɵattribute("data-testid", ctx.testId)("type", ctx.type)("aria-busy", ctx.loading ? "true" : "false");
209
+ i0.ɵɵstyleMap(ctx.hostStyle());
210
+ i0.ɵɵclassMap(ctx.classes());
211
+ } }, inputs: { variant: "variant", color: "color", size: "size", loading: "loading", loadingText: "loadingText", fullWidth: "fullWidth", className: "className", style: "style", testId: "testId", disabled: "disabled", type: "type" }, ngContentSelectors: _c3, decls: 9, vars: 6, consts: [["leftSlot", ""], ["rightSlot", ""], ["mol-spinner", "", 3, "size", "className"]], template: function Button_Template(rf, ctx) { if (rf & 1) {
212
+ i0.ɵɵprojectionDef(_c2);
213
+ i0.ɵɵconditionalCreate(0, Button_Conditional_0_Template, 1, 2, "div", 2);
214
+ i0.ɵɵelementStart(1, "span", null, 0);
215
+ i0.ɵɵprojection(3);
216
+ i0.ɵɵelementEnd();
217
+ i0.ɵɵconditionalCreate(4, Button_Conditional_4_Template, 2, 1, "ng-container")(5, Button_Conditional_5_Template, 1, 0);
218
+ i0.ɵɵelementStart(6, "span", null, 1);
219
+ i0.ɵɵprojection(8, 1);
220
+ i0.ɵɵelementEnd();
221
+ } if (rf & 2) {
222
+ i0.ɵɵconditional(ctx.loading ? 0 : -1);
78
223
  i0.ɵɵadvance();
79
- i0.ɵɵconditional(ctx.loading && ctx.loadingText ? 2 : 3);
80
- } }, encapsulation: 2 });
224
+ i0.ɵɵclassMap(ctx.cm().buttonIconLeft);
225
+ i0.ɵɵadvance(3);
226
+ i0.ɵɵconditional(ctx.loading && ctx.loadingText ? 4 : 5);
227
+ i0.ɵɵadvance(2);
228
+ i0.ɵɵclassMap(ctx.cm().buttonIconRight);
229
+ } }, dependencies: [Spinner], encapsulation: 2 });
81
230
  }
82
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MoleculeButton, [{
231
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Button, [{
83
232
  type: Component,
84
233
  args: [{
85
- selector: 'mol-button',
234
+ selector: 'button[mol-button]',
86
235
  standalone: true,
87
- changeDetection: ChangeDetectionStrategy.OnPush,
88
- host: { style: 'display: contents' },
89
- template: `
90
- <button
91
- [type]="type"
92
- [class]="classes"
93
- [style]="style"
94
- [attr.data-testid]="testId"
95
- [disabled]="disabled || loading"
96
- [attr.aria-busy]="loading"
97
- (click)="handleClick.emit($event)"
98
- >
99
- @if (loading) {
100
- <span [class]="cm.buttonSpinner"></span>
101
- }
102
- @if (loading && loadingText) {
103
- {{ loadingText }}
104
- } @else {
105
- <ng-content></ng-content>
106
- }
107
- </button>
108
- `,
236
+ imports: [Spinner],
237
+ inputs: [
238
+ 'variant',
239
+ 'color',
240
+ 'size',
241
+ 'loading',
242
+ 'loadingText',
243
+ 'fullWidth',
244
+ 'className',
245
+ 'style',
246
+ 'testId',
247
+ 'disabled',
248
+ 'type',
249
+ ],
250
+ host: {
251
+ '[class]': 'classes()',
252
+ '[style]': 'hostStyle()',
253
+ '[attr.data-testid]': 'testId',
254
+ '[attr.type]': 'type',
255
+ '[disabled]': 'disabled || loading',
256
+ '[attr.aria-busy]': 'loading ? "true" : "false"',
257
+ },
258
+ template: `@if (loading) {
259
+ <div mol-spinner [size]="'sm'" [className]="cm().buttonIconLeft"></div>
260
+ }
261
+ <span [class]="cm().buttonIconLeft" #leftSlot
262
+ ><ng-content select="[slot=leftIcon]"></ng-content
263
+ ></span>
264
+ @if (loading && loadingText) {
265
+ <ng-container>{{ loadingText }}</ng-container>
266
+ } @else {
267
+ <ng-content></ng-content>
268
+ }
269
+ <span [class]="cm().buttonIconRight" #rightSlot
270
+ ><ng-content select="[slot=rightIcon]"></ng-content
271
+ ></span>`,
109
272
  }]
110
- }], null, { variant: [{
111
- type: Input
112
- }], color: [{
113
- type: Input
114
- }], size: [{
115
- type: Input
116
- }], loading: [{
117
- type: Input
118
- }], loadingText: [{
119
- type: Input
120
- }], fullWidth: [{
121
- type: Input
122
- }], className: [{
123
- type: Input
124
- }], style: [{
125
- type: Input
126
- }], testId: [{
127
- type: Input
128
- }], disabled: [{
129
- type: Input
130
- }], type: [{
131
- type: Input
132
- }], handleClick: [{
133
- type: Output
273
+ }], null, { leftSlot: [{
274
+ type: ViewChild,
275
+ args: ['leftSlot']
276
+ }], rightSlot: [{
277
+ type: ViewChild,
278
+ args: ['rightSlot']
134
279
  }] }); })();
135
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MoleculeButton, { className: "MoleculeButton", filePath: "components/button.component.ts", lineNumber: 44 }); })();
280
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Button, { className: "Button", filePath: "components/button.component.ts", lineNumber: 144 }); })();
136
281
  //# sourceMappingURL=button.component.js.map