@molecule/app-ui-angular 1.0.6 → 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 +11740 -1143
  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 +6 -4
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Optimistic-value controller — a faithful local port of
3
+ * `@molecule/app-state`'s `createOptimisticValue`, used by
4
+ * `OptimisticToggleButton` (React reaches it through `useOptimisticValue`).
5
+ * Local so this package adds no `@molecule/app-state` dependency; the two
6
+ * must stay behaviorally identical.
7
+ *
8
+ * @module
9
+ */
10
+ /** What a commit reports back. */
11
+ export type OptimisticCommit<T> = (next: T, previous: T, confirm: (change: (current: T) => T) => void) => Promise<T | void>;
12
+ /** Options for {@link createOptimisticValue}. */
13
+ export interface OptimisticValueOptions<T> {
14
+ /** The loaded server value. */
15
+ value: T;
16
+ /** Saves the desired value; resolve with the confirmed value. */
17
+ commit: OptimisticCommit<T>;
18
+ /** Equality override (defaults to {@link shallowEqual}). */
19
+ equals?: (a: T, b: T) => boolean;
20
+ /** Called with a failed save after rollback. */
21
+ onError?: (error: unknown, value: T) => void;
22
+ }
23
+ /** The externally visible state. */
24
+ export interface OptimisticValueState<T> {
25
+ /** The value to render. */
26
+ value: T;
27
+ /** Whether a save is in flight. */
28
+ pending: boolean;
29
+ /** The newest failure, when the newest save failed. */
30
+ error: unknown;
31
+ }
32
+ /** The controller. */
33
+ export interface OptimisticValue<T> {
34
+ /**
35
+ * Gets the current state.
36
+ * @returns The state snapshot.
37
+ */
38
+ getState(): OptimisticValueState<T>;
39
+ /**
40
+ * Sets the desired value (starts or queues a save).
41
+ * @param next - The desired value.
42
+ */
43
+ set(next: T): void;
44
+ /**
45
+ * Updates the desired value from the current desired one.
46
+ * @param change - Maps current to next.
47
+ */
48
+ update(change: (current: T) => T): void;
49
+ /**
50
+ * Syncs a newer server value.
51
+ * @param value - The confirmed server value.
52
+ */
53
+ sync(value: T): void;
54
+ /**
55
+ * Subscribes to state changes.
56
+ * @param listener - Called on every publish.
57
+ * @returns Unsubscribe.
58
+ */
59
+ subscribe(listener: (state: OptimisticValueState<T>) => void): () => void;
60
+ /**
61
+ * Resolves when the current save settles.
62
+ * @returns The settled state.
63
+ */
64
+ settled(): Promise<OptimisticValueState<T>>;
65
+ }
66
+ /**
67
+ * Shallow equality (React's `@molecule/app-state` semantics).
68
+ *
69
+ * @param a - One value.
70
+ * @param b - The other value.
71
+ * @returns Whether the values are shallowly equal.
72
+ */
73
+ export declare function shallowEqual(a: unknown, b: unknown): boolean;
74
+ /**
75
+ * Creates the optimistic-value controller.
76
+ *
77
+ * @param options - Initial value, commit and callbacks.
78
+ * @returns The controller.
79
+ */
80
+ export declare function createOptimisticValue<T>(options: OptimisticValueOptions<T>): OptimisticValue<T>;
81
+ //# sourceMappingURL=optimistic-value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimistic-value.d.ts","sourceRoot":"","sources":["../../src/utilities/optimistic-value.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,kCAAkC;AAClC,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAChC,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,KACzC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;AAEtB,iDAAiD;AACjD,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,+BAA+B;IAC/B,KAAK,EAAE,CAAC,CAAA;IACR,iEAAiE;IACjE,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAA;IAC3B,4DAA4D;IAC5D,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAA;IAChC,gDAAgD;IAChD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;CAC7C;AAED,oCAAoC;AACpC,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,2BAA2B;IAC3B,KAAK,EAAE,CAAC,CAAA;IACR,mCAAmC;IACnC,OAAO,EAAE,OAAO,CAAA;IAChB,uDAAuD;IACvD,KAAK,EAAE,OAAO,CAAA;CACf;AAED,sBAAsB;AACtB,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC;;;OAGG;IACH,QAAQ,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAA;IACnC;;;OAGG;IACH,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAA;IAClB;;;OAGG;IACH,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAA;IACvC;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAA;IACpB;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;IACzE;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAA;CAC5C;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAW5D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAkH/F"}
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Optimistic-value controller — a faithful local port of
3
+ * `@molecule/app-state`'s `createOptimisticValue`, used by
4
+ * `OptimisticToggleButton` (React reaches it through `useOptimisticValue`).
5
+ * Local so this package adds no `@molecule/app-state` dependency; the two
6
+ * must stay behaviorally identical.
7
+ *
8
+ * @module
9
+ */
10
+ /**
11
+ * Shallow equality (React's `@molecule/app-state` semantics).
12
+ *
13
+ * @param a - One value.
14
+ * @param b - The other value.
15
+ * @returns Whether the values are shallowly equal.
16
+ */
17
+ export function shallowEqual(a, b) {
18
+ if (Object.is(a, b))
19
+ return true;
20
+ if (typeof a !== 'object' || a === null || typeof b !== 'object' || b === null)
21
+ return false;
22
+ const ka = Object.keys(a);
23
+ const kb = Object.keys(b);
24
+ if (ka.length !== kb.length)
25
+ return false;
26
+ for (const key of ka) {
27
+ if (!Object.is(a[key], b[key]))
28
+ return false;
29
+ }
30
+ return true;
31
+ }
32
+ /**
33
+ * Creates the optimistic-value controller.
34
+ *
35
+ * @param options - Initial value, commit and callbacks.
36
+ * @returns The controller.
37
+ */
38
+ export function createOptimisticValue(options) {
39
+ const equals = options.equals ?? shallowEqual;
40
+ const listeners = new Set();
41
+ let waiters = [];
42
+ let confirmed = options.value;
43
+ let desired = options.value;
44
+ let intent = 0;
45
+ let running = false;
46
+ let state = { value: options.value, pending: false, error: null };
47
+ const publish = (next) => {
48
+ if (Object.is(next.value, state.value) &&
49
+ next.pending === state.pending &&
50
+ Object.is(next.error, state.error))
51
+ return;
52
+ state = next;
53
+ for (const listener of [...listeners]) {
54
+ try {
55
+ listener(state);
56
+ }
57
+ catch (error) {
58
+ // This package cannot depend on @molecule/app-logger; the state
59
+ // listener contract still requires the failure to be visible.
60
+ console.error('optimistic value: a state listener threw', { error });
61
+ }
62
+ }
63
+ if (!state.pending) {
64
+ const settledWaiters = waiters;
65
+ waiters = [];
66
+ for (const resolve of settledWaiters)
67
+ resolve(state);
68
+ }
69
+ };
70
+ const run = async () => {
71
+ running = true;
72
+ let failure = null;
73
+ for (;;) {
74
+ const sent = desired;
75
+ const sentIntent = intent;
76
+ publish({ value: sent, pending: true, error: null });
77
+ let acceptingProgress = true;
78
+ let hasProgress = false;
79
+ const confirm = (change) => {
80
+ if (!acceptingProgress)
81
+ return;
82
+ confirmed = change(confirmed);
83
+ hasProgress = true;
84
+ };
85
+ try {
86
+ const result = await options.commit(sent, confirmed, confirm);
87
+ acceptingProgress = false;
88
+ confirmed = result === undefined ? (hasProgress ? confirmed : sent) : result;
89
+ if (sentIntent === intent || equals(desired, confirmed)) {
90
+ desired = confirmed;
91
+ break;
92
+ }
93
+ }
94
+ catch (error) {
95
+ acceptingProgress = false;
96
+ if (sentIntent === intent) {
97
+ desired = confirmed;
98
+ failure = { error };
99
+ break;
100
+ }
101
+ // A newer change replaced this one; only its own outcome is shown.
102
+ if (equals(desired, confirmed)) {
103
+ desired = confirmed;
104
+ break;
105
+ }
106
+ }
107
+ }
108
+ running = false;
109
+ publish({ value: desired, pending: false, error: failure ? failure.error : null });
110
+ if (failure) {
111
+ try {
112
+ options.onError?.(failure.error, confirmed);
113
+ }
114
+ catch (error) {
115
+ console.error('optimistic value: onError threw', { error });
116
+ }
117
+ }
118
+ };
119
+ const set = (next) => {
120
+ intent += 1;
121
+ desired = next;
122
+ if (!running && equals(next, confirmed)) {
123
+ desired = confirmed;
124
+ publish({ value: confirmed, pending: false, error: null });
125
+ return;
126
+ }
127
+ if (running)
128
+ publish({ value: next, pending: true, error: null });
129
+ else
130
+ void run();
131
+ };
132
+ return {
133
+ getState: () => state,
134
+ set,
135
+ update: (change) => set(change(desired)),
136
+ sync(value) {
137
+ confirmed = value;
138
+ if (running)
139
+ return;
140
+ desired = value;
141
+ publish({ value, pending: false, error: state.error });
142
+ },
143
+ subscribe(listener) {
144
+ listeners.add(listener);
145
+ return () => {
146
+ listeners.delete(listener);
147
+ };
148
+ },
149
+ settled: () => state.pending
150
+ ? new Promise((resolve) => waiters.push(resolve))
151
+ : Promise.resolve(state),
152
+ };
153
+ }
154
+ //# sourceMappingURL=optimistic-value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimistic-value.js","sourceRoot":"","sources":["../../src/utilities/optimistic-value.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkEH;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,CAAU,EAAE,CAAU;IACjD,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QAAE,OAAO,IAAI,CAAA;IAChC,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CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC1E,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;KAC7B,CAAA;AACH,CAAC"}
@@ -1,15 +1,85 @@
1
1
  /**
2
- * Icon rendering utility for Angular components.
2
+ * Icon rendering for Angular components — DOM parity with React's
3
+ * `renderIcon` and `Icon`.
3
4
  *
4
5
  * @module
5
6
  */
6
- import { type IconName } from '@molecule/app-icons';
7
+ import { type OnChanges } from '@angular/core';
8
+ import { type IconData, type IconName } from '@molecule/app-icons';
9
+ import * as i0 from "@angular/core";
7
10
  /**
8
- * Generates SVG markup string from an icon name.
11
+ * The icon data plus the resolved class name, precomputed so the template
12
+ * only binds (recomputing `getIcon` per CD pass would be wasteful and can
13
+ * throw mid-template).
14
+ */
15
+ export interface ResolvedIcon {
16
+ /** The bonded icon data. */
17
+ icon: IconData;
18
+ /** Class for the `<svg>` (already joined, possibly empty). */
19
+ className: string;
20
+ /** Whether the icon carries stroke styling. */
21
+ stroked: boolean;
22
+ /** `0 0 20 20` fallback applied when the icon data has no viewBox. */
23
+ viewBox: string;
24
+ }
25
+ /**
26
+ * Resolves an icon from the bonded set, throwing on unknown names exactly
27
+ * like `@molecule/app-icons`'s `getIcon` (an unknown name is a runtime error,
28
+ * not a blank).
29
+ *
30
+ * @param name - The icon name.
31
+ * @param className - The class for the `<svg>` (a `cm.*` token).
32
+ * @returns The resolved icon data.
33
+ */
34
+ export declare function resolveIcon(name: IconName, className?: string): ResolvedIcon;
35
+ /**
36
+ * Internal SVG renderer used by every React-parity component where React
37
+ * renders through `renderIcon` / `Icon`.
9
38
  *
10
- * @param name - Icon name from the icon set
11
- * @param className - CSS class for sizing
12
- * @returns SVG markup string
39
+ * The component's selector is an attribute on the `<svg>` itself
40
+ * (`<svg mol-icon …>`), so the host IS the svg element and no wrapper
41
+ * element exists. Attribute parity with React's `renderIcon`:
42
+ * `xmlns`, `aria-hidden="true"`, `focusable="false"`, `class`, `viewBox`,
43
+ * `fill` (or the stroke group when the icon is stroked) and `<path>` children.
44
+ * `icon.svg`-backed glyphs inject the bond's raw inner markup (the bond is
45
+ * the trust boundary, exactly as React's `dangerouslySetInnerHTML`).
13
46
  */
14
- export declare function getIconSvg(name: IconName, className: string): string;
47
+ export declare class MolIconSvg implements OnChanges {
48
+ /** The resolved icon data (plain field input, JIT-visible). */
49
+ data?: ResolvedIcon;
50
+ /**
51
+ * The fill attribute value: `none` for stroked icons, the icon fill or
52
+ * `currentColor` otherwise.
53
+ * @returns The fill value.
54
+ */
55
+ get fill(): string;
56
+ /**
57
+ * Stroke attribute values (null when the icon is not stroked).
58
+ * @returns The stroke attribute bag.
59
+ */
60
+ get strokeAttrs(): {
61
+ stroke: string | null;
62
+ strokeWidth: number | null;
63
+ strokeLinecap: string | null;
64
+ strokeLinejoin: string | null;
65
+ };
66
+ /**
67
+ * The paths to render (empty for `icon.svg`-backed glyphs).
68
+ * @returns The path list.
69
+ */
70
+ get paths(): IconData['paths'];
71
+ /**
72
+ * Injects raw `icon.svg` markup into the svg host when the icon carries it.
73
+ *
74
+ * @param changes - The changed inputs.
75
+ */
76
+ ngOnChanges(changes: {
77
+ data?: {
78
+ currentValue: ResolvedIcon;
79
+ };
80
+ }): void;
81
+ private readonly host;
82
+ static ɵfac: i0.ɵɵFactoryDeclaration<MolIconSvg, never>;
83
+ static ɵcmp: i0.ɵɵComponentDeclaration<MolIconSvg, "svg[mol-icon]", never, { "data": { "alias": "data"; "required": false; }; }, {}, never, never, true, never>;
84
+ }
15
85
  //# sourceMappingURL=render-icon.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-icon.d.ts","sourceRoot":"","sources":["../../src/utilities/render-icon.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE5D;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE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CAAC,IAAI,CAAgD;yCAtD1D,UAAU;2CAAV,UAAU;CAuDtB"}
@@ -1,44 +1,134 @@
1
1
  /**
2
- * Icon rendering utility for Angular components.
2
+ * Icon rendering for Angular components — DOM parity with React's
3
+ * `renderIcon` and `Icon`.
3
4
  *
4
5
  * @module
5
6
  */
7
+ import { Component, ElementRef, inject } from '@angular/core';
6
8
  import { getIcon } from '@molecule/app-icons';
9
+ import * as i0 from "@angular/core";
10
+ function MolIconSvg_For_1_Template(rf, ctx) { if (rf & 1) {
11
+ i0.ɵɵnamespaceSVG();
12
+ i0.ɵɵdomElement(0, "path");
13
+ } if (rf & 2) {
14
+ const p_r1 = ctx.$implicit;
15
+ i0.ɵɵattribute("d", p_r1.d)("fill", p_r1.fill)("fill-rule", p_r1.fillRule)("clip-rule", p_r1.clipRule)("opacity", p_r1.opacity);
16
+ } }
7
17
  /**
8
- * Generates SVG markup string from an icon name.
18
+ * Resolves an icon from the bonded set, throwing on unknown names exactly
19
+ * like `@molecule/app-icons`'s `getIcon` (an unknown name is a runtime error,
20
+ * not a blank).
9
21
  *
10
- * @param name - Icon name from the icon set
11
- * @param className - CSS class for sizing
12
- * @returns SVG markup string
22
+ * @param name - The icon name.
23
+ * @param className - The class for the `<svg>` (a `cm.*` token).
24
+ * @returns The resolved icon data.
13
25
  */
14
- export function getIconSvg(name, className) {
26
+ export function resolveIcon(name, className) {
15
27
  const icon = getIcon(name);
16
- const viewBox = icon.viewBox || '0 0 20 20';
17
- const fill = icon.fill || 'currentColor';
18
- const attrs = [
19
- `xmlns="http://www.w3.org/2000/svg"`,
20
- `class="${className}"`,
21
- `viewBox="${viewBox}"`,
22
- `fill="${fill}"`,
23
- ];
24
- if (icon.stroke)
25
- attrs.push(`stroke="${icon.stroke}"`);
26
- if (icon.strokeWidth)
27
- attrs.push(`stroke-width="${icon.strokeWidth}"`);
28
- if (icon.strokeLinecap)
29
- attrs.push(`stroke-linecap="${icon.strokeLinecap}"`);
30
- if (icon.strokeLinejoin)
31
- attrs.push(`stroke-linejoin="${icon.strokeLinejoin}"`);
32
- const paths = icon.paths
33
- .map((p) => {
34
- const pathAttrs = [`d="${p.d}"`];
35
- if (p.fillRule)
36
- pathAttrs.push(`fill-rule="${p.fillRule}"`);
37
- if (p.clipRule)
38
- pathAttrs.push(`clip-rule="${p.clipRule}"`);
39
- return `<path ${pathAttrs.join(' ')} />`;
40
- })
41
- .join('');
42
- return `<svg ${attrs.join(' ')}>${paths}</svg>`;
28
+ return {
29
+ icon,
30
+ className: className ?? '',
31
+ stroked: !!icon.stroke,
32
+ viewBox: icon.viewBox || '0 0 20 20',
33
+ };
43
34
  }
35
+ /**
36
+ * Internal SVG renderer used by every React-parity component where React
37
+ * renders through `renderIcon` / `Icon`.
38
+ *
39
+ * The component's selector is an attribute on the `<svg>` itself
40
+ * (`<svg mol-icon …>`), so the host IS the svg element and no wrapper
41
+ * element exists. Attribute parity with React's `renderIcon`:
42
+ * `xmlns`, `aria-hidden="true"`, `focusable="false"`, `class`, `viewBox`,
43
+ * `fill` (or the stroke group when the icon is stroked) and `<path>` children.
44
+ * `icon.svg`-backed glyphs inject the bond's raw inner markup (the bond is
45
+ * the trust boundary, exactly as React's `dangerouslySetInnerHTML`).
46
+ */
47
+ export class MolIconSvg {
48
+ /** The resolved icon data (plain field input, JIT-visible). */
49
+ data;
50
+ /**
51
+ * The fill attribute value: `none` for stroked icons, the icon fill or
52
+ * `currentColor` otherwise.
53
+ * @returns The fill value.
54
+ */
55
+ get fill() {
56
+ return this.data?.stroked ? 'none' : (this.data?.icon.fill ?? 'currentColor') || 'currentColor';
57
+ }
58
+ /**
59
+ * Stroke attribute values (null when the icon is not stroked).
60
+ * @returns The stroke attribute bag.
61
+ */
62
+ get strokeAttrs() {
63
+ if (!this.data?.stroked) {
64
+ return { stroke: null, strokeWidth: null, strokeLinecap: null, strokeLinejoin: null };
65
+ }
66
+ const icon = this.data.icon;
67
+ return {
68
+ stroke: icon.stroke ?? null,
69
+ strokeWidth: icon.strokeWidth ?? null,
70
+ strokeLinecap: icon.strokeLinecap ?? null,
71
+ strokeLinejoin: icon.strokeLinejoin ?? null,
72
+ };
73
+ }
74
+ /**
75
+ * The paths to render (empty for `icon.svg`-backed glyphs).
76
+ * @returns The path list.
77
+ */
78
+ get paths() {
79
+ return this.data?.icon.svg ? [] : (this.data?.icon.paths ?? []);
80
+ }
81
+ /**
82
+ * Injects raw `icon.svg` markup into the svg host when the icon carries it.
83
+ *
84
+ * @param changes - The changed inputs.
85
+ */
86
+ ngOnChanges(changes) {
87
+ if (!changes.data)
88
+ return;
89
+ const svg = changes.data.currentValue.icon.svg;
90
+ if (svg)
91
+ this.host.nativeElement.innerHTML = svg;
92
+ }
93
+ host = inject(ElementRef);
94
+ static ɵfac = function MolIconSvg_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MolIconSvg)(); };
95
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MolIconSvg, selectors: [["svg", "mol-icon", ""]], hostAttrs: ["xmlns", "http://www.w3.org/2000/svg"], hostVars: 10, hostBindings: function MolIconSvg_HostBindings(rf, ctx) { if (rf & 2) {
96
+ i0.ɵɵattribute("aria-hidden", "true")("focusable", "false")("viewBox", ctx.data?.viewBox)("fill", ctx.fill)("stroke", ctx.strokeAttrs.stroke)("stroke-width", ctx.strokeAttrs.strokeWidth)("stroke-linecap", ctx.strokeAttrs.strokeLinecap)("stroke-linejoin", ctx.strokeAttrs.strokeLinejoin);
97
+ i0.ɵɵclassMap(ctx.data?.className);
98
+ } }, inputs: { data: "data" }, features: [i0.ɵɵNgOnChangesFeature], decls: 2, vars: 0, template: function MolIconSvg_Template(rf, ctx) { if (rf & 1) {
99
+ i0.ɵɵrepeaterCreate(0, MolIconSvg_For_1_Template, 1, 5, "path", null, i0.ɵɵrepeaterTrackByIndex);
100
+ } if (rf & 2) {
101
+ i0.ɵɵrepeater(ctx.paths);
102
+ } }, encapsulation: 2 });
103
+ }
104
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MolIconSvg, [{
105
+ type: Component,
106
+ args: [{
107
+ selector: 'svg[mol-icon]',
108
+ standalone: true,
109
+ inputs: ['data'],
110
+ host: {
111
+ xmlns: 'http://www.w3.org/2000/svg',
112
+ '[attr.aria-hidden]': '"true"',
113
+ '[attr.focusable]': '"false"',
114
+ '[class]': 'data?.className',
115
+ '[attr.viewBox]': 'data?.viewBox',
116
+ '[attr.fill]': 'fill',
117
+ '[attr.stroke]': 'strokeAttrs.stroke',
118
+ '[attr.stroke-width]': 'strokeAttrs.strokeWidth',
119
+ '[attr.stroke-linecap]': 'strokeAttrs.strokeLinecap',
120
+ '[attr.stroke-linejoin]': 'strokeAttrs.strokeLinejoin',
121
+ },
122
+ template: `@for (p of paths; track $index) {
123
+ <svg:path
124
+ [attr.d]="p.d"
125
+ [attr.fill]="p.fill"
126
+ [attr.fill-rule]="p.fillRule"
127
+ [attr.clip-rule]="p.clipRule"
128
+ [attr.opacity]="p.opacity"
129
+ />
130
+ }`,
131
+ }]
132
+ }], null, null); })();
133
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MolIconSvg, { className: "MolIconSvg", filePath: "utilities/render-icon.ts", lineNumber: 85 }); })();
44
134
  //# sourceMappingURL=render-icon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-icon.js","sourceRoot":"","sources":["../../src/utilities/render-icon.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAiB,MAAM,qBAAqB,CAAA;AAE5D;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,IAAc,EAAE,SAAiB;IAC1D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,WAAW,CAAA;IAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,cAAc,CAAA;IAExC,MAAM,KA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;;;OAGG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;IACjE,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,OAAkD;QAC5D,IAAI,CAAC,OAAO,CAAC,IAAI;YAAE,OAAM;QACzB,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAA;QAC9C,IAAI,GAAG;YAAG,IAAI,CAAC,IAAI,CAAC,aAA+B,CAAC,SAAS,GAAG,GAAG,CAAA;IACrE,CAAC;IAEgB,IAAI,GAA8B,MAAM,CAAC,UAAU,CAAC,CAAA;oGAtD1D,UAAU;6DAAV,UAAU;0CAAV,MAAM,eAAN,OAAO;YAAP,kCAAU;;YAVV,gGAQV;;YARU,wBAQV;;;iFAEU,UAAU;cA1BtB,SAAS;eAAC;gBACT,QAAQ,EAAE,eAAe;gBACzB,UAAU,EAAE,IAAI;gBAChB,MAAM,EAAE,CAAC,MAAM,CAAC;gBAChB,IAAI,EAAE;oBACJ,KAAK,EAAE,4BAA4B;oBACnC,oBAAoB,EAAE,QAAQ;oBAC9B,kBAAkB,EAAE,SAAS;oBAC7B,SAAS,EAAE,iBAAiB;oBAC5B,gBAAgB,EAAE,eAAe;oBACjC,aAAa,EAAE,MAAM;oBACrB,eAAe,EAAE,oBAAoB;oBACrC,qBAAqB,EAAE,yBAAyB;oBAChD,uBAAuB,EAAE,2BAA2B;oBACpD,wBAAwB,EAAE,4BAA4B;iBACvD;gBACD,QAAQ,EAAE;;;;;;;;IAQR;aACH;;kFACY,UAAU"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Rest-attribute handling for components whose React root is a fragment or
3
+ * portal (element-selector host): React spreads `...rest` (`aria-*`,
4
+ * `data-*`, `id`, …) onto a specific inner element, while the conformance
5
+ * adapter binds them onto the Angular host. These helpers move them.
6
+ *
7
+ * @module
8
+ */
9
+ /**
10
+ * Moves every rest attribute (`aria-*`, `data-*`, `id`, …) from the host
11
+ * element onto the element React spreads `{...rest}` onto.
12
+ *
13
+ * Adapter bindings write each attribute once (case props are static), so a
14
+ * move at first view init is stable.
15
+ *
16
+ * @param host - The component host element.
17
+ * @param target - The element React's `...rest` targets.
18
+ * @returns The moved attribute names.
19
+ */
20
+ export declare function moveRestAttributes(host: Element, target: Element | undefined | null): string[];
21
+ //# sourceMappingURL=rest-attrs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest-attrs.d.ts","sourceRoot":"","sources":["../../src/utilities/rest-attrs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,EAAE,CAW9F"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Rest-attribute handling for components whose React root is a fragment or
3
+ * portal (element-selector host): React spreads `...rest` (`aria-*`,
4
+ * `data-*`, `id`, …) onto a specific inner element, while the conformance
5
+ * adapter binds them onto the Angular host. These helpers move them.
6
+ *
7
+ * @module
8
+ */
9
+ /** Host attributes that never move (framework + component host markers). */
10
+ const KEEP = /^(class|style|data-parity-)/;
11
+ const isNgAttr = (name) => name.startsWith('ng-') || name.startsWith('_ng');
12
+ /**
13
+ * Moves every rest attribute (`aria-*`, `data-*`, `id`, …) from the host
14
+ * element onto the element React spreads `{...rest}` onto.
15
+ *
16
+ * Adapter bindings write each attribute once (case props are static), so a
17
+ * move at first view init is stable.
18
+ *
19
+ * @param host - The component host element.
20
+ * @param target - The element React's `...rest` targets.
21
+ * @returns The moved attribute names.
22
+ */
23
+ export function moveRestAttributes(host, target) {
24
+ if (!target)
25
+ return [];
26
+ const moved = [];
27
+ for (const attr of Array.from(host.attributes)) {
28
+ const name = attr.name;
29
+ if (KEEP.test(name) || isNgAttr(name) || name.startsWith('mol-'))
30
+ continue;
31
+ target.setAttribute(name, attr.value);
32
+ host.removeAttribute(name);
33
+ moved.push(name);
34
+ }
35
+ return moved;
36
+ }
37
+ //# sourceMappingURL=rest-attrs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest-attrs.js","sourceRoot":"","sources":["../../src/utilities/rest-attrs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,4EAA4E;AAC5E,MAAM,IAAI,GAAG,6BAA6B,CAAA;AAE1C,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AAE5F;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAa,EAAE,MAAkC;IAClF,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAA;IACtB,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;QACtB,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YAAE,SAAQ;QAC1E,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;QACrC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;QAC1B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAClB,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * React-style inline style serialization for Angular host bindings.
3
+ *
4
+ * @module
5
+ */
6
+ /**
7
+ * Converts a camelCase CSS property name to kebab-case.
8
+ *
9
+ * @param key - The camelCase property name.
10
+ * @returns The kebab-case CSS property name.
11
+ */
12
+ export declare const kebab: (key: string) => string;
13
+ /**
14
+ * Serializes a React-style style object the way React writes it to the DOM:
15
+ * camelCase keys become kebab-case, numbers gain `px` unless the property is
16
+ * unitless, and declaration order follows object key order (the conformance
17
+ * normalizer sorts declarations anyway).
18
+ *
19
+ * @param style - The style object (or undefined).
20
+ * @returns The `style` attribute text, or null when there is nothing to set.
21
+ */
22
+ export declare function styleText(style: Record<string, unknown> | undefined | null): string | null;
23
+ //# sourceMappingURL=style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/utilities/style.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuDH;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAAI,KAAK,MAAM,KAAG,MAC8C,CAAA;AAElF;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAU1F"}