@molecule/app-ui-angular 1.4.2 → 1.5.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 (138) hide show
  1. package/README.md +966 -1013
  2. package/dist/components/alert.component.d.ts +11 -16
  3. package/dist/components/alert.component.d.ts.map +1 -1
  4. package/dist/components/alert.component.js +22 -51
  5. package/dist/components/alert.component.js.map +1 -1
  6. package/dist/components/auth-guard.component.d.ts +36 -28
  7. package/dist/components/auth-guard.component.d.ts.map +1 -1
  8. package/dist/components/auth-guard.component.js +59 -67
  9. package/dist/components/auth-guard.component.js.map +1 -1
  10. package/dist/components/avatar.component.d.ts +13 -10
  11. package/dist/components/avatar.component.d.ts.map +1 -1
  12. package/dist/components/avatar.component.js +27 -25
  13. package/dist/components/avatar.component.js.map +1 -1
  14. package/dist/components/button.component.d.ts +26 -30
  15. package/dist/components/button.component.d.ts.map +1 -1
  16. package/dist/components/button.component.js +41 -75
  17. package/dist/components/button.component.js.map +1 -1
  18. package/dist/components/checkbox.component.d.ts +5 -4
  19. package/dist/components/checkbox.component.d.ts.map +1 -1
  20. package/dist/components/checkbox.component.js +14 -9
  21. package/dist/components/checkbox.component.js.map +1 -1
  22. package/dist/components/confirm-button.component.d.ts +11 -28
  23. package/dist/components/confirm-button.component.d.ts.map +1 -1
  24. package/dist/components/confirm-button.component.js +31 -63
  25. package/dist/components/confirm-button.component.js.map +1 -1
  26. package/dist/components/confirm-dialog.component.d.ts +28 -17
  27. package/dist/components/confirm-dialog.component.d.ts.map +1 -1
  28. package/dist/components/confirm-dialog.component.js +98 -69
  29. package/dist/components/confirm-dialog.component.js.map +1 -1
  30. package/dist/components/dropdown.component.d.ts +29 -16
  31. package/dist/components/dropdown.component.d.ts.map +1 -1
  32. package/dist/components/dropdown.component.js +134 -105
  33. package/dist/components/dropdown.component.js.map +1 -1
  34. package/dist/components/empty-state.component.d.ts +10 -15
  35. package/dist/components/empty-state.component.d.ts.map +1 -1
  36. package/dist/components/empty-state.component.js +23 -27
  37. package/dist/components/empty-state.component.js.map +1 -1
  38. package/dist/components/form-field.component.d.ts +26 -11
  39. package/dist/components/form-field.component.d.ts.map +1 -1
  40. package/dist/components/form-field.component.js +86 -25
  41. package/dist/components/form-field.component.js.map +1 -1
  42. package/dist/components/input.component.d.ts +20 -23
  43. package/dist/components/input.component.d.ts.map +1 -1
  44. package/dist/components/input.component.js +45 -54
  45. package/dist/components/input.component.js.map +1 -1
  46. package/dist/components/language-picker.component.d.ts +15 -18
  47. package/dist/components/language-picker.component.d.ts.map +1 -1
  48. package/dist/components/language-picker.component.js +25 -35
  49. package/dist/components/language-picker.component.js.map +1 -1
  50. package/dist/components/load-error-banner.component.d.ts +14 -26
  51. package/dist/components/load-error-banner.component.d.ts.map +1 -1
  52. package/dist/components/load-error-banner.component.js +28 -62
  53. package/dist/components/load-error-banner.component.js.map +1 -1
  54. package/dist/components/modal.component.d.ts +25 -21
  55. package/dist/components/modal.component.d.ts.map +1 -1
  56. package/dist/components/modal.component.js +42 -78
  57. package/dist/components/modal.component.js.map +1 -1
  58. package/dist/components/molecule/button.component.d.ts +13 -2
  59. package/dist/components/molecule/button.component.d.ts.map +1 -1
  60. package/dist/components/molecule/button.component.js +45 -15
  61. package/dist/components/molecule/button.component.js.map +1 -1
  62. package/dist/components/molecule/toast.component.d.ts +2 -1
  63. package/dist/components/molecule/toast.component.d.ts.map +1 -1
  64. package/dist/components/molecule/toast.component.js +9 -7
  65. package/dist/components/molecule/toast.component.js.map +1 -1
  66. package/dist/components/molecule/tooltip.component.d.ts +4 -2
  67. package/dist/components/molecule/tooltip.component.d.ts.map +1 -1
  68. package/dist/components/molecule/tooltip.component.js +19 -14
  69. package/dist/components/molecule/tooltip.component.js.map +1 -1
  70. package/dist/components/optimistic-toggle-button.component.d.ts +13 -25
  71. package/dist/components/optimistic-toggle-button.component.d.ts.map +1 -1
  72. package/dist/components/optimistic-toggle-button.component.js +33 -63
  73. package/dist/components/optimistic-toggle-button.component.js.map +1 -1
  74. package/dist/components/page-header.component.d.ts +8 -13
  75. package/dist/components/page-header.component.d.ts.map +1 -1
  76. package/dist/components/page-header.component.js +16 -24
  77. package/dist/components/page-header.component.js.map +1 -1
  78. package/dist/components/page-shell.component.d.ts +8 -14
  79. package/dist/components/page-shell.component.d.ts.map +1 -1
  80. package/dist/components/page-shell.component.js +18 -28
  81. package/dist/components/page-shell.component.js.map +1 -1
  82. package/dist/components/panel-close.component.d.ts +14 -8
  83. package/dist/components/panel-close.component.d.ts.map +1 -1
  84. package/dist/components/panel-close.component.js +28 -17
  85. package/dist/components/panel-close.component.js.map +1 -1
  86. package/dist/components/prompt-dialog.component.d.ts +32 -10
  87. package/dist/components/prompt-dialog.component.d.ts.map +1 -1
  88. package/dist/components/prompt-dialog.component.js +110 -73
  89. package/dist/components/prompt-dialog.component.js.map +1 -1
  90. package/dist/components/responsive-app-shell.component.d.ts +34 -41
  91. package/dist/components/responsive-app-shell.component.d.ts.map +1 -1
  92. package/dist/components/responsive-app-shell.component.js +126 -147
  93. package/dist/components/responsive-app-shell.component.js.map +1 -1
  94. package/dist/components/sidebar-user-card.component.d.ts +8 -12
  95. package/dist/components/sidebar-user-card.component.d.ts.map +1 -1
  96. package/dist/components/sidebar-user-card.component.js +19 -35
  97. package/dist/components/sidebar-user-card.component.js.map +1 -1
  98. package/dist/components/switch.component.d.ts +13 -8
  99. package/dist/components/switch.component.d.ts.map +1 -1
  100. package/dist/components/switch.component.js +29 -20
  101. package/dist/components/switch.component.js.map +1 -1
  102. package/dist/components/table.component.d.ts +22 -14
  103. package/dist/components/table.component.d.ts.map +1 -1
  104. package/dist/components/table.component.js +34 -32
  105. package/dist/components/table.component.js.map +1 -1
  106. package/dist/components/toast.component.d.ts +34 -30
  107. package/dist/components/toast.component.d.ts.map +1 -1
  108. package/dist/components/toast.component.js +74 -84
  109. package/dist/components/toast.component.js.map +1 -1
  110. package/dist/components/tooltip.component.d.ts +14 -11
  111. package/dist/components/tooltip.component.d.ts.map +1 -1
  112. package/dist/components/tooltip.component.js +47 -47
  113. package/dist/components/tooltip.component.js.map +1 -1
  114. package/dist/components/user-menu-popover.component.d.ts +6 -12
  115. package/dist/components/user-menu-popover.component.d.ts.map +1 -1
  116. package/dist/components/user-menu-popover.component.js +40 -77
  117. package/dist/components/user-menu-popover.component.js.map +1 -1
  118. package/dist/components/user-menu.component.d.ts +8 -11
  119. package/dist/components/user-menu.component.d.ts.map +1 -1
  120. package/dist/components/user-menu.component.js +19 -27
  121. package/dist/components/user-menu.component.js.map +1 -1
  122. package/dist/index.d.ts +5 -5
  123. package/dist/index.js +5 -5
  124. package/dist/utilities/dom-context.d.ts +62 -15
  125. package/dist/utilities/dom-context.d.ts.map +1 -1
  126. package/dist/utilities/dom-context.js +79 -34
  127. package/dist/utilities/dom-context.js.map +1 -1
  128. package/dist/utilities/form-field-context.d.ts +2 -0
  129. package/dist/utilities/form-field-context.d.ts.map +1 -1
  130. package/dist/utilities/form-field-context.js +4 -2
  131. package/dist/utilities/form-field-context.js.map +1 -1
  132. package/dist/utilities/node-value.d.ts +8 -0
  133. package/dist/utilities/node-value.d.ts.map +1 -1
  134. package/dist/utilities/node-value.js +10 -0
  135. package/dist/utilities/node-value.js.map +1 -1
  136. package/dist/utilities/rest-attrs.d.ts +2 -2
  137. package/dist/utilities/rest-attrs.js +1 -1
  138. package/package.json +3 -3
package/README.md CHANGED
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-11-23T06:34:59.571Z
6
+ Generated: 2026-11-23T17:50:05.108Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-ui-angular
@@ -13,8 +13,8 @@ Angular UI components for molecule.dev.
13
13
  Provides standalone Angular components at parity with `@molecule/app-ui-react`:
14
14
  every React export exists here under the same name, with the same props, the
15
15
  same rendered DOM (ClassMap classes, attributes, inline styles, text) and the
16
- same behaviour. The shared conformance kit
17
- (`@molecule/app-framework-conformance`) proves the parity.
16
+ same behaviour. Molecule's conformance tests render each component in React and
17
+ Angular and compare the two.
18
18
 
19
19
  React-named exports include `Button`, `Card` (+ `CardHeader`, `CardTitle`,
20
20
  `CardDescription`, `CardContent`, `CardFooter`), `Input`, `Select`,
@@ -2314,6 +2314,37 @@ interface UserMenuProps {
2314
2314
  }
2315
2315
  ```
2316
2316
 
2317
+ #### `DomContext`
2318
+
2319
+ One context: what React's `createContext` returns, in Angular's form.
2320
+
2321
+ ```typescript
2322
+ interface DomContext<T> {
2323
+ /**
2324
+ * Registers the value on a provider's host element.
2325
+ *
2326
+ * @param host - The provider component's host element.
2327
+ * @param value - The context value.
2328
+ */
2329
+ provide(host: Element, value: T): void
2330
+ /**
2331
+ * Removes the registration (on provider destroy).
2332
+ *
2333
+ * @param host - The provider component's host element.
2334
+ */
2335
+ remove(host: Element): void
2336
+ /**
2337
+ * Finds the nearest enclosing value for a consumer's element. The element's
2338
+ * own registration is ignored: a provider's children see the provider, the
2339
+ * provider does not see itself.
2340
+ *
2341
+ * @param start - The consumer's host element.
2342
+ * @returns The nearest registered value, or `undefined` when there is none.
2343
+ */
2344
+ find(start: Element | null): T | undefined
2345
+ }
2346
+ ```
2347
+
2317
2348
  #### `HasElement`
2318
2349
 
2319
2350
  A component that gives callers its ref element.
@@ -2446,7 +2477,7 @@ interface ReapplyRestAttributesOptions {
2446
2477
  * (the input/select/textarea family, see below) has already applied it on
2447
2478
  * an inner binding, and re-moving the re-bound value would erase that
2448
2479
  * merge. A component that spreads `aria-describedby` straight onto its
2449
- * `...rest` target (Modal) has no merge to protect, so it opts in.
2480
+ * `...rest` target has no merge to protect, so it opts in.
2450
2481
  */
2451
2482
  includeDescribedBy?: boolean
2452
2483
  }
@@ -2841,14 +2872,15 @@ React renders `{(icon || defaultIcon) && <span className={alertIconWrapper}>…}
2841
2872
  the icon wrapper span exists only when a custom icon is given or the status
2842
2873
  has a default glyph, and its content is the custom icon XOR the default
2843
2874
  glyph. Here the span and the default glyph both always exist in the
2844
- template (projection capture points) and are detached from the DOM when
2845
- React would not render them ({@link SlotWrapper}); the decision is made at
2846
- view init, when view queries resolve.
2875
+ template (projection capture points) and are taken out of the DOM when
2876
+ React would not render them (`setElementPresent`); the decision is made in
2877
+ the placement function, where projected content is current.
2847
2878
 
2848
2879
  ```typescript
2849
2880
  @Component({
2850
2881
  selector: 'div[mol-alert]',
2851
2882
  standalone: true,
2883
+ hostDirectives: [MolPlacement],
2852
2884
  imports: [MolIconSvg],
2853
2885
  inputs: [
2854
2886
  'title',
@@ -2895,7 +2927,7 @@ view init, when view queries resolve.
2895
2927
  </button>
2896
2928
  }`,
2897
2929
  })
2898
- export class Alert implements AfterViewInit, DoCheck, HasElement<HTMLDivElement> {
2930
+ export class Alert implements HasElement<HTMLDivElement> {
2899
2931
  /** Alert title. */
2900
2932
  title?: string
2901
2933
  /** Status color. */
@@ -2929,6 +2961,11 @@ export class Alert implements AfterViewInit, DoCheck, HasElement<HTMLDivElement>
2929
2961
 
2930
2962
  private hasCustomIcon = false
2931
2963
 
2964
+ /** Places the icon wrapper and the default glyph as React renders them. */
2965
+ constructor() {
2966
+ usePlacement((hasContent) => this.syncIcon(hasContent))
2967
+ }
2968
+
2932
2969
  /**
2933
2970
  * Reactive translation, read in the injection context. Its `t` reads the
2934
2971
  * locale, so the view re-renders the text on a locale switch (the static `t`
@@ -2936,7 +2973,6 @@ export class Alert implements AfterViewInit, DoCheck, HasElement<HTMLDivElement>
2936
2973
  */
2937
2974
  private readonly i18n = useTranslation()
2938
2975
 
2939
- private readonly sync = new SlotWrapper(inject(ElementRef), inject(Renderer2))
2940
2976
  private readonly host: ElementRef<HTMLDivElement> = inject(ElementRef)
2941
2977
  /** The element a caller's ref receives: the host `<div>`. */
2942
2978
  readonly element = hostElement(this.host)
@@ -3034,36 +3070,18 @@ export class Alert implements AfterViewInit, DoCheck, HasElement<HTMLDivElement>
3034
3070
  )
3035
3071
  }
3036
3072
 
3037
- /**
3038
- * Decides icon presence at view init (view queries resolve only then) and
3039
- * applies React's conditions.
3040
- */
3041
- ngAfterViewInit(): void {
3042
- const span = this.iconSlot?.nativeElement
3043
- const glyph = this.defaultGlyph?.nativeElement
3044
- // Projected nodes are the span's children other than the default glyph.
3045
- this.hasCustomIcon = !!span && hasNodesExcept(span, glyph)
3046
- this.syncIcon()
3047
- }
3048
-
3049
- /**
3050
- * Re-reconciles on later passes.
3051
- */
3052
- ngDoCheck(): void {
3053
- this.syncIcon()
3054
- }
3055
-
3056
3073
  /**
3057
3074
  * Applies React's `{(icon || defaultIcon) && <span>{icon || defaultIcon}</span>}`.
3075
+ *
3076
+ * @param hasContent - Reads whether a slot has content.
3058
3077
  */
3059
- private syncIcon(): void {
3078
+ private syncIcon(hasContent: SlotReader): void {
3060
3079
  const span = this.iconSlot?.nativeElement
3061
- this.sync.sync(
3062
- this.defaultGlyph?.nativeElement,
3063
- !this.hasCustomIcon && this.defaultIcon() !== null,
3064
- span,
3065
- )
3066
- this.sync.sync(span, this.hasCustomIcon || this.defaultIcon() !== null)
3080
+ const glyph = this.defaultGlyph?.nativeElement
3081
+ // The capture holds the always-mounted default glyph first, then the slot.
3082
+ this.hasCustomIcon = hasContent(span, 1)
3083
+ setElementPresent(glyph, !this.hasCustomIcon && this.defaultIcon() !== null)
3084
+ setElementPresent(span, this.hasCustomIcon || this.defaultIcon() !== null)
3067
3085
  }
3068
3086
  }
3069
3087
  ```
@@ -3079,27 +3097,24 @@ While the auth status is `'loading'` it renders the `loadingFallback` input
3079
3097
  `loginPath` (state `from` carries the attempted location); otherwise it
3080
3098
  renders the projected children, or `<mol-routed-view />` without them (the
3081
3099
  matched child route, through whichever routing bond the app wired; it throws
3082
- when the bond has none: project the page then). The host is unwrapped by the DOM normalizer
3083
- (`data-parity-unwrap`) and `display: contents` keeps it fragment-like —
3084
- React's root is a fragment. On the login path itself the guard renders its
3085
- children, so a guard wrapping the whole route tree does not redirect in a
3086
- loop.
3100
+ when the bond has none: project the page then). React's root is a fragment
3101
+ (or nothing at all while redirecting), so everything the host holds renders
3102
+ in front of the host and the host itself leaves the page. On the login path
3103
+ itself the guard renders its children, so a guard wrapping the whole route
3104
+ tree does not redirect in a loop.
3087
3105
 
3088
- The projected children need one stable capture point, so they live in an
3089
- always-mounted wrapper the guard moves into (or out of) the host itself:
3090
- React renders them bare, never inside a wrapper element, and renders
3091
- nothing at all while redirecting.
3106
+ The projected children (and the loading fallback's content) need one stable
3107
+ capture point, so each lives in an always-mounted wrapper whose content is
3108
+ rendered in its own place and whose element leaves the page: React renders
3109
+ them bare, never inside a wrapper element.
3092
3110
 
3093
3111
  ```typescript
3094
3112
  @Component({
3095
3113
  selector: 'mol-auth-guard',
3096
3114
  standalone: true,
3115
+ hostDirectives: [MolPlacement],
3097
3116
  imports: [MolTemplateOutlet, RoutedView],
3098
3117
  inputs: ['loadingFallback', 'loadingKey', 'loadingDefault', 'loginPath', 'onAuthenticated'],
3099
- host: {
3100
- 'data-parity-unwrap': '',
3101
- style: 'display: contents',
3102
- },
3103
3118
  template: `<div data-mol-id="auth-guard-loading" #defaultLoading>{{ loadingText() }}</div>
3104
3119
  <span #dataFallback
3105
3120
  ><ng-container [molTemplateOutlet]="asTemplate(loadingFallback)"></ng-container
@@ -3111,7 +3126,7 @@ nothing at all while redirecting.
3111
3126
  <mol-routed-view />
3112
3127
  }`,
3113
3128
  })
3114
- export class AuthGuard implements AfterViewInit {
3129
+ export class AuthGuard {
3115
3130
  /**
3116
3131
  * Element rendered while the auth status is `loading` (a node value, or the
3117
3132
  * projected `[slot=loadingFallback]`). Overrides the default loading tag.
@@ -3138,9 +3153,9 @@ export class AuthGuard implements AfterViewInit {
3138
3153
  @ViewChild('defaultLoading') defaultLoading?: ElementRef<HTMLDivElement>
3139
3154
  /** The node-valued fallback (shown when the input is given). */
3140
3155
  @ViewChild('dataFallback') dataFallback?: ElementRef<HTMLSpanElement>
3141
- /** The `loadingFallback` slot capture (always mounted). */
3156
+ /** The `loadingFallback` slot capture (its content renders in its own place). */
3142
3157
  @ViewChild('fallbackWrap') fallbackWrap?: ElementRef<HTMLSpanElement>
3143
- /** The children capture; its nodes are moved bare into the host to render. */
3158
+ /** The children capture (their content renders in its own place). */
3144
3159
  @ViewChild('childrenWrap') childrenWrap?: ElementRef<HTMLSpanElement>
3145
3160
 
3146
3161
  /** Auth state, read in the component's injection context. */
@@ -3155,10 +3170,9 @@ export class AuthGuard implements AfterViewInit {
3155
3170
  */
3156
3171
  private readonly i18n = useTranslation()
3157
3172
 
3158
- private readonly sync = new SlotWrapper(inject(ElementRef), inject(Renderer2))
3159
3173
  private readonly host = inject(ElementRef)
3160
3174
  private hasFallback = false
3161
- /** Whether the guard was given children to project (known by view init). */
3175
+ /** Whether the guard was given children to project (read in the placement function). */
3162
3176
  private hasChildren = false
3163
3177
  /** Whether the view queries have resolved, so the children capture can be read. */
3164
3178
  private viewReady = false
@@ -3170,38 +3184,27 @@ export class AuthGuard implements AfterViewInit {
3170
3184
  private lastAuthenticated = false
3171
3185
  /** The login path the guard navigated to for the current redirect state. */
3172
3186
  private redirectedTo: string | null = null
3173
- /** The children nodes currently adopted into the host. */
3174
- private adopted: Node[] = []
3175
-
3176
- /**
3177
- * Runs the first reconciliation after the view init (slot detection) and
3178
- * again whenever the auth status or the location changes — the effect
3179
- * tracks both signals directly, so the guard re-evaluates even though no
3180
- * template binding reads them.
3181
- */
3182
- private readonly guardEffect = effect(() => {
3183
- this.auth.status()
3184
- this.router.location()
3185
- this.reconcile()
3186
- })
3187
3187
 
3188
3188
  /**
3189
- * Detects the `loadingFallback` slot and the children (view queries resolve
3190
- * only by view init).
3189
+ * Re-evaluates the guard whenever the auth status, the location or the
3190
+ * projected slots change. The placement function reads both signals, so its
3191
+ * effect tracks them even though no template binding does.
3191
3192
  */
3192
- ngAfterViewInit(): void {
3193
- this.hasFallback = hasNodes(this.fallbackWrap?.nativeElement)
3194
- this.hasChildren = hasNodes(this.childrenWrap?.nativeElement)
3195
- this.viewReady = true
3196
- this.reconcile()
3193
+ constructor() {
3194
+ usePlacement((hasContent) => this.reconcile(hasContent))
3197
3195
  }
3198
3196
 
3199
3197
  /**
3200
3198
  * Applies React's branch for the current auth status and location, fires
3201
3199
  * `onAuthenticated` on its rising edge, and redirects once per entry into
3202
3200
  * the redirect state.
3201
+ *
3202
+ * @param hasContent - Reads whether a slot has content.
3203
3203
  */
3204
- private reconcile(): void {
3204
+ private reconcile(hasContent: SlotReader): void {
3205
+ this.hasFallback = hasContent(this.fallbackWrap?.nativeElement)
3206
+ this.hasChildren = hasContent(this.childrenWrap?.nativeElement)
3207
+ this.viewReady = this.childrenWrap !== undefined
3205
3208
  const status = this.auth.status()
3206
3209
  const authenticated = this.auth.isAuthenticated()
3207
3210
  if (this.onAuthenticated && authenticated && !this.lastAuthenticated) this.onAuthenticated()
@@ -3229,33 +3232,40 @@ export class AuthGuard implements AfterViewInit {
3229
3232
  /**
3230
3233
  * Shows exactly one branch's content, the way React's early returns do.
3231
3234
  *
3235
+ * React's branch elements render in front of the host, which leaves the
3236
+ * page; each capture that holds projected content renders that content in its
3237
+ * own place and leaves the page, so the projected nodes are bare, as React
3238
+ * renders them.
3239
+ *
3232
3240
  * @param branch - The branch to render.
3233
3241
  */
3234
3242
  private renderBranch(branch: 'loading' | 'redirect' | 'children'): void {
3235
3243
  const host = this.host.nativeElement as HTMLElement
3236
- const wrap = this.childrenWrap?.nativeElement
3237
- if (wrap) {
3238
- if (branch === 'children') {
3239
- while (wrap.firstChild) {
3240
- const node = wrap.firstChild
3241
- host.appendChild(node)
3242
- this.adopted.push(node)
3243
- }
3244
- } else {
3245
- for (const node of this.adopted) {
3246
- if (node.parentElement === host) wrap.appendChild(node)
3247
- }
3248
- this.adopted = []
3249
- }
3250
- // The capture span itself never renders (React's children are bare).
3251
- this.sync.sync(this.childrenWrap?.nativeElement, false)
3252
- }
3244
+ // React's root is a fragment (or nothing): everything the host holds renders in front of it.
3245
+ placeContentBefore(host, host)
3246
+ setElementPresent(host, false)
3253
3247
  this.routed.set(this.viewReady && branch === 'children' && !this.hasChildren)
3254
3248
  const loading = branch === 'loading'
3255
3249
  const hasNode = isGiven(this.loadingFallback)
3256
- this.sync.sync(this.defaultLoading?.nativeElement, loading && !hasNode && !this.hasFallback)
3257
- this.sync.sync(this.fallbackWrap?.nativeElement, loading && !hasNode && this.hasFallback)
3258
- this.sync.sync(this.dataFallback?.nativeElement, loading && hasNode)
3250
+ this.placeSlot(this.childrenWrap?.nativeElement, branch === 'children')
3251
+ this.placeSlot(this.fallbackWrap?.nativeElement, loading && !hasNode && this.hasFallback)
3252
+ this.placeSlot(this.dataFallback?.nativeElement, loading && hasNode)
3253
+ setElementPresent(this.defaultLoading?.nativeElement, loading && !hasNode && !this.hasFallback)
3254
+ }
3255
+
3256
+ /**
3257
+ * Renders a capture's content in the capture's own place while `shown`, and
3258
+ * leaves the capture element itself out of the page either way: React
3259
+ * renders the content bare, never inside the capture's span.
3260
+ *
3261
+ * @param capture - The capture element (its own template content, projected or not).
3262
+ * @param shown - Whether React would render that content now.
3263
+ */
3264
+ private placeSlot(capture: HTMLElement | undefined, shown: boolean): void {
3265
+ if (!capture) return
3266
+ if (shown) placeContentBefore(capture, capture)
3267
+ else placeContent(capture, null)
3268
+ setElementPresent(capture, false)
3259
3269
  }
3260
3270
 
3261
3271
  /**
@@ -3282,13 +3292,14 @@ Renders the image while it loads; an image error (or no `src`) swaps to the
3282
3292
  fallback: projected `[slot=fallback]` content, the name's initials, or a
3283
3293
  user glyph. The image/fallback swap is a signal-driven `@if` (an error
3284
3294
  re-renders); the three fallback variants are always-mounted capture points
3285
- detached from the DOM per React's ternary, since projected-content presence
3286
- is only knowable at view init ({@link SlotWrapper}).
3295
+ taken out of the DOM per React's ternary, since projected-content presence
3296
+ is read in the placement function (`setElementPresent`).
3287
3297
 
3288
3298
  ```typescript
3289
3299
  @Component({
3290
3300
  selector: 'div[mol-avatar]',
3291
3301
  standalone: true,
3302
+ hostDirectives: [MolPlacement],
3292
3303
  imports: [MolIconSvg],
3293
3304
  inputs: [
3294
3305
  'src',
@@ -3317,13 +3328,13 @@ is only knowable at view init ({@link SlotWrapper}).
3317
3328
  />
3318
3329
  } @else {
3319
3330
  <div [class]="cm().avatarFallback" #fallbackEl>
3320
- <ng-content select="[slot=fallback]"></ng-content>
3321
3331
  <span [class]="cm().avatarInitials" #initialsEl>{{ initials() }}</span>
3322
3332
  <svg mol-icon [data]="userIcon()" #userGlyph />
3333
+ <ng-content select="[slot=fallback]"></ng-content>
3323
3334
  </div>
3324
3335
  }`,
3325
3336
  })
3326
- export class Avatar implements AfterViewChecked, HasElement<HTMLDivElement> {
3337
+ export class Avatar implements HasElement<HTMLDivElement> {
3327
3338
  /** Image source. */
3328
3339
  src?: string
3329
3340
  /** Image alt text. */
@@ -3362,11 +3373,15 @@ export class Avatar implements AfterViewChecked, HasElement<HTMLDivElement> {
3362
3373
  */
3363
3374
  private readonly i18n = useTranslation()
3364
3375
 
3365
- private readonly sync = new SlotWrapper(inject(ElementRef), inject(Renderer2))
3366
3376
  private readonly host: ElementRef<HTMLDivElement> = inject(ElementRef)
3367
3377
  /** The element a caller's ref receives: the host `<div>`. */
3368
3378
  readonly element = hostElement(this.host)
3369
3379
 
3380
+ /** Applies the fallback ternary; projected content wins over initials and glyph. */
3381
+ constructor() {
3382
+ usePlacement((hasContent) => this.reconcile(hasContent))
3383
+ }
3384
+
3370
3385
  /**
3371
3386
  * The current class map.
3372
3387
  * @returns The UIClassMap.
@@ -3447,21 +3462,17 @@ export class Avatar implements AfterViewChecked, HasElement<HTMLDivElement> {
3447
3462
 
3448
3463
  /**
3449
3464
  * Applies React's fallback ternary (`fallback ? fallback : name ? initials
3450
- * : glyph`) after view queries have resolved for this pass. Projected
3451
- * fallback nodes are exactly the container's children that are not the two
3452
- * always-mounted template children.
3465
+ * : glyph`). The capture holds the initials span and the user glyph first,
3466
+ * then the projected fallback.
3467
+ *
3468
+ * @param hasContent - Reads whether a slot has content.
3453
3469
  */
3454
- ngAfterViewChecked(): void {
3470
+ private reconcile(hasContent: SlotReader): void {
3455
3471
  const fallbackHost = this.fallbackEl?.nativeElement
3456
3472
  if (!fallbackHost) return
3457
- const projected = Array.from(fallbackHost.childNodes).some(
3458
- (node) =>
3459
- node !== this.initialsEl?.nativeElement &&
3460
- node !== this.userGlyph?.nativeElement &&
3461
- (node.nodeType === 1 || (node.nodeType === 3 && (node.textContent ?? '').trim())),
3462
- )
3463
- this.sync.sync(this.initialsEl?.nativeElement, !projected && !!this.name, fallbackHost)
3464
- this.sync.sync(this.userGlyph?.nativeElement, !projected && !this.name, fallbackHost)
3473
+ const projected = hasContent(fallbackHost, 2)
3474
+ setElementPresent(this.initialsEl?.nativeElement, !projected && !!this.name)
3475
+ setElementPresent(this.userGlyph?.nativeElement, !projected && !this.name)
3465
3476
  }
3466
3477
  }
3467
3478
  ```
@@ -3563,59 +3574,37 @@ export class Badge implements HasElement<HTMLSpanElement> {
3563
3574
  }
3564
3575
  ```
3565
3576
 
3566
- #### `SlotWrapper`
3577
+ #### `SlotWrapper` _(deprecated)_
3578
+
3579
+ > **Deprecated:** Use setElementPresent from `@molecule/app-angular`.
3567
3580
 
3568
3581
  Attaches or detaches an always-mounted projection wrapper element from its
3569
- parent, remembering the re-insertion position with a comment anchor the DOM
3570
- normalizer strips.
3582
+ parent. React renders `{cond && <span>{slot}</span>}` — nothing when the
3583
+ condition is false. Angular needs the `<ng-content>` capture point to stay
3584
+ mounted, so the wrapper span always exists in the template and this helper
3585
+ removes it from the DOM whenever React would not render it.
3571
3586
 
3572
- React renders `{cond && <span>{slot}</span>}` — nothing when the condition
3573
- is false. Angular needs the `<ng-content>` capture point to stay mounted,
3574
- so the wrapper span always exists in the template and this helper removes
3575
- it from the DOM whenever React would not render it.
3587
+ It is a thin delegate to `setElementPresent`, kept for callers' signatures.
3576
3588
 
3577
3589
  ```typescript
3578
3590
  class SlotWrapper {
3579
- private readonly anchors = new Map<Node, Comment>()
3580
-
3581
3591
  /**
3582
3592
  * Creates the wrapper helper.
3583
3593
  *
3584
- * @param host - The component host element (default detach parent).
3585
- * @param renderer - The DOM renderer.
3594
+ * @param _host - Kept for callers' constructor signature.
3595
+ * @param _renderer - Kept for callers' constructor signature.
3586
3596
  */
3587
- constructor(
3588
- private readonly host: ElementRef<HTMLElement>,
3589
- private readonly renderer: Renderer2,
3590
- ) {}
3597
+ constructor(_host: ElementRef<HTMLElement>, _renderer: Renderer2) {}
3591
3598
 
3592
3599
  /**
3593
- * Attaches or detaches the element (default parent: the component host).
3600
+ * Attaches or detaches the element.
3594
3601
  *
3595
3602
  * @param el - The wrapper element.
3596
3603
  * @param shouldAttach - Whether it should be in the DOM.
3597
- * @param parent - Where the element lives when attached (default: host).
3598
- */
3599
- sync(el: Element | undefined | null, shouldAttach: boolean, parent?: Node): void {
3600
- if (!el) return
3601
- const host: Node = parent ?? this.host.nativeElement
3602
- if (shouldAttach && !el.isConnected) {
3603
- const anchor = this.anchors.get(el)
3604
- if (anchor?.isConnected) {
3605
- host.insertBefore(el, anchor)
3606
- this.renderer.removeChild(host, anchor)
3607
- this.anchors.delete(el)
3608
- } else {
3609
- host.appendChild(el)
3610
- }
3611
- } else if (!shouldAttach && el.isConnected) {
3612
- // Placeholder comment keeps the re-insertion position stable; the
3613
- // normalizer strips comment nodes, so it never shows in snapshots.
3614
- const placeholder = this.renderer.createComment('slot')
3615
- host.insertBefore(placeholder, el)
3616
- this.anchors.set(el, placeholder)
3617
- this.renderer.removeChild(host, el)
3618
- }
3604
+ * @param _parent - Ignored; the element's own place holds it.
3605
+ */
3606
+ sync(el: Element | undefined | null, shouldAttach: boolean, _parent?: Node): void {
3607
+ setElementPresent(el, shouldAttach)
3619
3608
  }
3620
3609
  }
3621
3610
  ```
@@ -3637,6 +3626,7 @@ capture point, so the wrapper lives in the template unconditionally).
3637
3626
  @Component({
3638
3627
  selector: 'button[mol-button]',
3639
3628
  standalone: true,
3629
+ hostDirectives: [MolPlacement],
3640
3630
  imports: [Spinner],
3641
3631
  inputs: [
3642
3632
  'variant',
@@ -3677,7 +3667,7 @@ capture point, so the wrapper lives in the template unconditionally).
3677
3667
  ><ng-content select="[slot=rightIcon]"></ng-content
3678
3668
  ></span>`,
3679
3669
  })
3680
- export class Button implements AfterViewInit, DoCheck, HasElement<HTMLButtonElement> {
3670
+ export class Button implements HasElement<HTMLButtonElement> {
3681
3671
  /** Button variant. */
3682
3672
  variant: ButtonVariant = 'solid'
3683
3673
  /** Button color. */
@@ -3713,7 +3703,6 @@ export class Button implements AfterViewInit, DoCheck, HasElement<HTMLButtonElem
3713
3703
  /** The right icon wrapper. */
3714
3704
  @ViewChild('rightSlot') rightSlot?: ElementRef<HTMLSpanElement>
3715
3705
 
3716
- private readonly sync = new SlotWrapper(inject(ElementRef), inject(Renderer2))
3717
3706
  private readonly host: ElementRef<HTMLButtonElement> = inject(ElementRef)
3718
3707
  /** The element a caller's ref receives: the host `<button>`. */
3719
3708
  readonly element = hostElement(this.host)
@@ -3768,32 +3757,23 @@ export class Button implements AfterViewInit, DoCheck, HasElement<HTMLButtonElem
3768
3757
  private hasLeft = false
3769
3758
  private hasRight = false
3770
3759
 
3771
- /**
3772
- * Detects slot content and detaches the wrappers React would not render.
3773
- * View queries resolve only by view init (the first pass), so presence is
3774
- * read here rather than at content init.
3775
- */
3776
- ngAfterViewInit(): void {
3777
- const left = this.leftSlot?.nativeElement
3778
- const right = this.rightSlot?.nativeElement
3779
- this.hasLeft = left ? hasNodes(left) : false
3780
- this.hasRight = right ? hasNodes(right) : false
3781
- this.syncWrappers()
3782
- }
3783
-
3784
- /**
3785
- * Re-reconciles the wrappers when `loading` changes.
3786
- */
3787
- ngDoCheck(): void {
3788
- this.syncWrappers()
3760
+ /** Detaches the icon wrappers React would not render. */
3761
+ constructor() {
3762
+ usePlacement((hasContent) => this.syncWrappers(hasContent))
3789
3763
  }
3790
3764
 
3791
3765
  /**
3792
3766
  * Applies React's `{!loading && !!icon}` wrapper conditions.
3767
+ *
3768
+ * @param hasContent - Reads whether a slot has content.
3793
3769
  */
3794
- private syncWrappers(): void {
3795
- this.sync.sync(this.leftSlot?.nativeElement, this.hasLeft && !this.loading)
3796
- this.sync.sync(this.rightSlot?.nativeElement, this.hasRight && !this.loading)
3770
+ private syncWrappers(hasContent: SlotReader): void {
3771
+ const left = this.leftSlot?.nativeElement
3772
+ const right = this.rightSlot?.nativeElement
3773
+ this.hasLeft = left ? hasContent(left) : false
3774
+ this.hasRight = right ? hasContent(right) : false
3775
+ setElementPresent(left, this.hasLeft && !this.loading)
3776
+ setElementPresent(right, this.hasRight && !this.loading)
3797
3777
  }
3798
3778
  }
3799
3779
  ```
@@ -4170,6 +4150,7 @@ there at view init.
4170
4150
  @Component({
4171
4151
  selector: 'div[mol-checkbox]',
4172
4152
  standalone: true,
4153
+ hostDirectives: [MolPlacement],
4173
4154
  imports: [MolControlledChecked],
4174
4155
  inputs: [
4175
4156
  'label',
@@ -4292,10 +4273,17 @@ export class Checkbox implements AfterViewChecked, HasElement<HTMLInputElement>
4292
4273
  private restDescribedByCaptured = false
4293
4274
  /** The `data-mol-id` a caller bound on the host (React spreads it onto the input). */
4294
4275
  private externalMolId: string | undefined
4295
- private readonly sync = new SlotWrapper(inject(ElementRef), inject(Renderer2))
4296
4276
  private hasLabel = false
4297
4277
  private syncIndeterminate = false
4298
4278
 
4279
+ /** Applies React's `{!!label && <span>}` label condition. */
4280
+ constructor() {
4281
+ usePlacement((hasContent) => {
4282
+ this.hasLabel = !!this.label || hasContent(this.labelSlot?.nativeElement)
4283
+ setElementPresent(this.labelSlot?.nativeElement, this.hasLabel)
4284
+ })
4285
+ }
4286
+
4299
4287
  /**
4300
4288
  * The current class map.
4301
4289
  * @returns The UIClassMap.
@@ -4328,7 +4316,10 @@ export class Checkbox implements AfterViewChecked, HasElement<HTMLInputElement>
4328
4316
  )
4329
4317
  }
4330
4318
 
4331
- /** Computes the checkbox class list. */
4319
+ /**
4320
+ * Computes the checkbox class list.
4321
+ * @returns The class string.
4322
+ */
4332
4323
  classes(): string {
4333
4324
  return this.cm().cn(this.cm().checkbox({ error: !!this.error }), this.className)
4334
4325
  }
@@ -4361,8 +4352,7 @@ export class Checkbox implements AfterViewChecked, HasElement<HTMLInputElement>
4361
4352
  private justClicked = false
4362
4353
 
4363
4354
  /**
4364
- * Applies the indeterminate DOM flag (a property, not an attribute) and
4365
- * React's `{!!label && <span>}` label condition.
4355
+ * Applies the indeterminate DOM flag (a property, not an attribute).
4366
4356
  */
4367
4357
  ngAfterViewChecked(): void {
4368
4358
  const input = this.input?.nativeElement
@@ -4385,17 +4375,11 @@ export class Checkbox implements AfterViewChecked, HasElement<HTMLInputElement>
4385
4375
  this.syncIndeterminate = !!this.indeterminate
4386
4376
  }
4387
4377
  }
4388
- this.hasLabel = !!this.label || hasNodes(this.labelSlot?.nativeElement)
4389
- this.sync.sync(
4390
- this.labelSlot?.nativeElement,
4391
- this.hasLabel,
4392
- this.labelSlot?.nativeElement.parentElement ?? undefined,
4393
- )
4394
4378
  }
4395
4379
  }
4396
4380
  ```
4397
4381
 
4398
- _(The 10 longest member comments are shortened to their first sentence to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/checkbox.component.d.ts`.)_
4382
+ _(The 9 longest member comments are shortened to their first sentence to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/checkbox.component.d.ts`.)_
4399
4383
 
4400
4384
  #### `ConfirmButton`
4401
4385
 
@@ -4414,6 +4398,7 @@ renders instead (React's `confirmLabel ?? t(…)`).
4414
4398
  @Component({
4415
4399
  selector: 'button[mol-confirm-button]',
4416
4400
  standalone: true,
4401
+ hostDirectives: [MolPlacement],
4417
4402
  imports: [MolTemplateOutlet],
4418
4403
  inputs: [
4419
4404
  'variant',
@@ -4443,10 +4428,10 @@ renders instead (React's `confirmLabel ?? t(…)`).
4443
4428
  '[class]': 'classes()',
4444
4429
  '[style]': 'hostStyle()',
4445
4430
  },
4446
- template: `@if (phase() === 'armed' && !hasConfirmLabel && !isGiven(confirmLabel)) {
4431
+ template: `@if (phase() === 'armed' && !hasConfirmLabel() && !isGiven(confirmLabel)) {
4447
4432
  Confirm?
4448
4433
  }
4449
- @if (phase() === 'pending' && !hasPendingLabel && !isGiven(pendingLabel)) {
4434
+ @if (phase() === 'pending' && !hasPendingLabel() && !isGiven(pendingLabel)) {
4450
4435
  Working…
4451
4436
  }
4452
4437
  @if (phase() === 'idle' && isGiven(label)) {
@@ -4464,9 +4449,7 @@ renders instead (React's `confirmLabel ?? t(…)`).
4464
4449
  ><span #confirmSlot><ng-content select="[slot=confirmLabel]"></ng-content></span
4465
4450
  ><span #pendingSlot><ng-content select="[slot=pendingLabel]"></ng-content></span>`,
4466
4451
  })
4467
- export class ConfirmButton
4468
- implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTMLButtonElement>
4469
- {
4452
+ export class ConfirmButton implements OnDestroy, HasElement<HTMLButtonElement> {
4470
4453
  /** Button variant (passed through to the button classes). */
4471
4454
  variant?: ConfirmButtonProps['variant']
4472
4455
  /** Button color; the armed state always shows the error color. */
@@ -4477,9 +4460,11 @@ export class ConfirmButton
4477
4460
  onConfirm?: ConfirmButtonProps['onConfirm']
4478
4461
  /** Visible label in the idle state (React's `label` node value). */
4479
4462
  label?: ConfirmButtonProps['label']
4463
+ /** Visible label in the armed state (React's `confirmLabel` node value). */
4480
4464
  confirmLabel?: ConfirmButtonProps['confirmLabel']
4481
4465
  /** Visible label while the confirm callback is pending. */
4482
4466
  pendingLabel?: ConfirmButtonProps['pendingLabel']
4467
+ /** Seconds before the armed state auto-disarms (`0` disables auto-disarm). */
4483
4468
  disarmSeconds?: ConfirmButtonProps['disarmSeconds'] = 4
4484
4469
  /** Disables the control entirely (idle and confirming states). */
4485
4470
  disabled?: ConfirmButtonProps['disabled'] = false
@@ -4507,8 +4492,10 @@ export class ConfirmButton
4507
4492
  /** The pending-state label capture span. */
4508
4493
  @ViewChild('pendingSlot') pendingSlot?: ElementRef<HTMLSpanElement>
4509
4494
 
4510
- hasConfirmLabel = false
4511
- hasPendingLabel = false
4495
+ /** Whether the armed label slot carries content (a signal the template reads). */
4496
+ readonly hasConfirmLabel = signal(false)
4497
+ /** Whether the pending label slot carries content (a signal the template reads). */
4498
+ readonly hasPendingLabel = signal(false)
4512
4499
 
4513
4500
  /** The current phase: idle → armed → pending → idle. */
4514
4501
  readonly phase = signal<'idle' | 'armed' | 'pending'>('idle')
@@ -4516,12 +4503,10 @@ export class ConfirmButton
4516
4503
  private readonly el: ElementRef<HTMLButtonElement> = inject(ElementRef)
4517
4504
  /** The element a caller's ref receives: the host `<button>`. */
4518
4505
  readonly element = hostElement(this.el)
4519
- private readonly renderer = inject(Renderer2)
4520
- private readonly sync = new SlotWrapper(this.el, this.renderer)
4521
4506
  private disarmTimer: ReturnType<typeof setTimeout> | null = null
4522
- private anchor: Comment | null = null
4523
4507
 
4524
4508
  constructor() {
4509
+ usePlacement((hasContent) => this.syncLabels(hasContent))
4525
4510
  effect(() => {
4526
4511
  if (this.disarmTimer) {
4527
4512
  clearTimeout(this.disarmTimer)
@@ -4542,6 +4527,7 @@ export class ConfirmButton
4542
4527
  return getClassMap()
4543
4528
  }
4544
4529
 
4530
+ /** Computes the button class list (the armed state shows the error color). */
4545
4531
  classes(): string {
4546
4532
  return this.cm().cn(
4547
4533
  this.cm().button({
@@ -4558,6 +4544,7 @@ export class ConfirmButton
4558
4544
  return styleText(this.style)
4559
4545
  }
4560
4546
 
4547
+ /** The `data-mol-id` value (`automationId` wins over a rest `data-mol-id`). */
4561
4548
  molId(): string | undefined {
4562
4549
  return (
4563
4550
  this.automationId ??
@@ -4579,6 +4566,7 @@ export class ConfirmButton
4579
4566
  await this.onConfirm?.()
4580
4567
  } catch (_error) {
4581
4568
  // A rejected confirm means the action failed: the caller owns that
4569
+ // error and shows its own message, and the button returns to idle so
4582
4570
  // the user can retry. Ignoring it here only stops it becoming an
4583
4571
  // unhandled rejection.
4584
4572
  } finally {
@@ -4599,29 +4587,21 @@ export class ConfirmButton
4599
4587
  this.phase.set('idle')
4600
4588
  }
4601
4589
 
4602
- ngAfterViewInit(): void {
4603
- this.hasConfirmLabel = hasNodes(this.confirmSlot?.nativeElement)
4604
- this.hasPendingLabel = hasNodes(this.pendingSlot?.nativeElement)
4605
- for (const span of [this.labelSlot, this.confirmSlot, this.pendingSlot])
4606
- this.sync.sync(span?.nativeElement, false)
4607
- this.syncLabels()
4608
- }
4609
-
4610
- ngDoCheck(): void {
4611
- this.syncLabels()
4612
- }
4613
-
4614
- private visibleNodes: Node[] = []
4590
+ /** The slot whose content is currently shown on the button. */
4615
4591
  private visibleFrom: HTMLSpanElement | null = null
4616
4592
 
4617
- private syncLabels(): void {
4593
+ private syncLabels(hasContent: SlotReader): void {
4594
+ this.hasConfirmLabel.set(hasContent(this.confirmSlot?.nativeElement))
4595
+ this.hasPendingLabel.set(hasContent(this.pendingSlot?.nativeElement))
4596
+ for (const span of [this.labelSlot, this.confirmSlot, this.pendingSlot])
4597
+ setElementPresent(span?.nativeElement, false)
4618
4598
  const phase = this.phase()
4619
4599
  const target =
4620
4600
  phase === 'idle'
4621
4601
  ? (this.labelSlot?.nativeElement ?? null)
4622
- : phase === 'armed' && this.hasConfirmLabel
4602
+ : phase === 'armed' && this.hasConfirmLabel()
4623
4603
  ? (this.confirmSlot?.nativeElement ?? null)
4624
- : phase === 'pending' && this.hasPendingLabel
4604
+ : phase === 'pending' && this.hasPendingLabel()
4625
4605
  ? (this.pendingSlot?.nativeElement ?? null)
4626
4606
  : null
4627
4607
  this.showSlot(target)
@@ -4630,25 +4610,10 @@ export class ConfirmButton
4630
4610
  private showSlot(span: HTMLSpanElement | null): void {
4631
4611
  const host = this.el.nativeElement
4632
4612
  if (span === this.visibleFrom) return
4633
- for (const node of this.visibleNodes) {
4634
- if (node.parentElement === host) this.visibleFrom?.appendChild(node)
4635
- }
4636
- this.visibleNodes = []
4637
- this.visibleFrom = null
4638
- if (!span) return
4639
- const nodes = Array.from(span.childNodes)
4640
- for (const node of nodes) host.insertBefore(node, this.labelAnchor())
4641
- this.visibleNodes = nodes
4613
+ if (this.visibleFrom) placeContent(this.visibleFrom, null)
4642
4614
  this.visibleFrom = span
4643
- }
4644
-
4645
- private labelAnchor(): Comment {
4646
- if (this.anchor) return this.anchor
4647
- const anchor = this.renderer.createComment('label') as Comment
4648
- const host = this.el.nativeElement
4649
- host.insertBefore(anchor, host.firstChild)
4650
- this.anchor = anchor
4651
- return anchor
4615
+ if (!span) return
4616
+ placeContent(span, host)
4652
4617
  }
4653
4618
 
4654
4619
  /** Clears the auto-disarm timer (React's unmount cleanup). */
@@ -4658,7 +4623,7 @@ export class ConfirmButton
4658
4623
  }
4659
4624
  ```
4660
4625
 
4661
- _(Member comments are shortened to their first sentence, and the 17 longest are left out to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/confirm-button.component.d.ts`.)_
4626
+ _(Member comments are shortened to their first sentence, and the 6 longest are left out to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/confirm-button.component.d.ts`.)_
4662
4627
 
4663
4628
  #### `ConfirmDialog`
4664
4629
 
@@ -4666,27 +4631,30 @@ ConfirmDialog component.
4666
4631
 
4667
4632
  Composed from `Modal` and `Button` exactly as React composes them; the
4668
4633
  dialog's own title/description/children are projected content (`[slot=title]`,
4669
- `[slot=description]`, default) or node-valued inputs. The host is unwrapped
4670
- (`data-parity-unwrap`, React's `Modal` root is a fragment/portal).
4634
+ `[slot=description]`, default) or node-valued inputs. React's root is a
4635
+ `Modal`, which renders a portal while open and nothing while closed, so the
4636
+ host element leaves the page and the portal renders in `document.body`.
4671
4637
 
4672
4638
  ```typescript
4673
4639
  @Component({
4674
4640
  selector: 'mol-confirm-dialog',
4675
4641
  standalone: true,
4642
+ hostDirectives: [MolPlacement],
4676
4643
  imports: [Button, Modal, MolTemplateOutlet],
4677
4644
  inputs: ['open', 'title', 'description', 'confirmLabel', 'cancelLabel', 'destructive', 'loading'],
4678
4645
  outputs: ['close', 'confirm'],
4679
- host: {
4680
- 'data-parity-unwrap': '',
4681
- style: 'display: contents',
4682
- },
4683
4646
  template: `<mol-modal
4647
+ #modal
4684
4648
  [open]="open"
4685
4649
  (close)="close.emit($event)"
4686
- [attr.aria-labelledby]="titleId"
4687
- [attr.aria-describedby]="ariaDescribedBy"
4650
+ [attr.aria-labelledby]="ariaLabelledBy()"
4651
+ [attr.aria-describedby]="ariaDescribedBy()"
4688
4652
  ><div [class]="cm().stack(3)">
4689
- <h2 [attr.id]="titleId" [class]="cm().cn(cm().textSize('lg'), cm().fontWeight('bold'))">
4653
+ <h2
4654
+ #titleSlot
4655
+ [attr.id]="ariaLabelledBy()"
4656
+ [class]="cm().cn(cm().textSize('lg'), cm().fontWeight('bold'))"
4657
+ >
4690
4658
  @if (isGiven(title)) {
4691
4659
  <ng-container [molTemplateOutlet]="asTemplate(title)"></ng-container>{{ nodeText(title) }}
4692
4660
  }
@@ -4726,11 +4694,11 @@ dialog's own title/description/children are projected content (`[slot=title]`,
4726
4694
  </div></mol-modal
4727
4695
  >`,
4728
4696
  })
4729
- export class ConfirmDialog implements DoCheck {
4697
+ export class ConfirmDialog {
4730
4698
  /**
4731
4699
  * Per-instance id of the rendered title heading, wired as the dialog's
4732
- * accessible name: the binding on `<mol-modal>` lands on its host element,
4733
- * which Modal's rest-attribute move copies onto the dialog `<div>` —
4700
+ * accessible name: the binding on `<mol-modal>` reaches the dialog `<div>`,
4701
+ * React's `{...rest}` target (Modal names it with `setHostRoot`) —
4734
4702
  * `aria-labelledby` pointing at the visible `<h2>` (WAI-ARIA dialog
4735
4703
  * pattern; axe `aria-dialog-name`).
4736
4704
  */
@@ -4738,8 +4706,7 @@ export class ConfirmDialog implements DoCheck {
4738
4706
 
4739
4707
  /**
4740
4708
  * Per-instance id of the rendered description paragraph, wired as the
4741
- * dialog's accessible description through the same rest-attribute move as
4742
- * the title (only bound when projected description content renders — a
4709
+ * dialog's accessible description the same way as the title (only bound when projected description content renders — a
4743
4710
  * reference to an empty paragraph describes nothing, axe
4744
4711
  * `aria-dialog-name`/`aria-valid-attr-value`).
4745
4712
  */
@@ -4752,6 +4719,9 @@ export class ConfirmDialog implements DoCheck {
4752
4719
  @ViewChild('descriptionSlot', { static: true })
4753
4720
  descriptionSlot?: ElementRef<HTMLParagraphElement>
4754
4721
 
4722
+ /** The title heading (its projected nodes decide whether the dialog points at it). */
4723
+ @ViewChild('titleSlot', { static: true }) titleSlot?: ElementRef<HTMLHeadingElement>
4724
+
4755
4725
  /** Whether the dialog is open. */
4756
4726
  open: ConfirmDialogProps['open'] = false
4757
4727
  /** Title (node-valued prop). */
@@ -4796,22 +4766,41 @@ export class ConfirmDialog implements DoCheck {
4796
4766
 
4797
4767
  /**
4798
4768
  * The dialog's accessible description id, or null when no description
4799
- * content renders. A FIELD, not a template method call: Angular memoizes a
4800
- * no-argument method binding, so it would keep the first (pre-view-init)
4801
- * value forever. Re-read each pass from the projected description nodes.
4769
+ * content renders. A signal the template reads, so the association follows
4770
+ * the projected description in the pass where it changes.
4802
4771
  */
4803
- ariaDescribedBy: string | null = null
4772
+ readonly ariaDescribedBy = signal<string | null>(null)
4804
4773
 
4805
4774
  /**
4806
- * Recomputes {@link ariaDescribedBy} before each view check. The query is
4807
- * static, so the projected nodes are readable on the first pass already; a
4808
- * later change to what renders is picked up on the next pass.
4775
+ * The title heading's id, which the dialog's `aria-labelledby` points at, or null while the title
4776
+ * renders nothing (React's `slot(title)`): a heading with no text names nothing.
4809
4777
  */
4810
- ngDoCheck(): void {
4811
- this.ariaDescribedBy =
4812
- isGiven(this.description) || hasNodes(this.descriptionSlot?.nativeElement)
4813
- ? this.descriptionId
4814
- : null
4778
+ readonly ariaLabelledBy = signal<string | null>(null)
4779
+
4780
+ /** The composed Modal's element: what the caller binds on this tag lands there, and Modal passes it to its dialog. */
4781
+ @ViewChild('modal', { read: ElementRef }) modalElement?: ElementRef<HTMLElement>
4782
+
4783
+ private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
4784
+
4785
+ /**
4786
+ * Recomputes {@link ariaLabelledBy} and {@link ariaDescribedBy} from the
4787
+ * title and description inputs and their projected nodes in
4788
+ * the placement function, and takes the host out of the page (React renders
4789
+ * the composed `Modal`'s portal in `document.body`, nothing here).
4790
+ */
4791
+ constructor() {
4792
+ usePlacement((hasContent) => {
4793
+ this.ariaLabelledBy.set(
4794
+ rendersNode(this.title) || hasContent(this.titleSlot?.nativeElement) ? this.titleId : null,
4795
+ )
4796
+ this.ariaDescribedBy.set(
4797
+ rendersNode(this.description) || hasContent(this.descriptionSlot?.nativeElement)
4798
+ ? this.descriptionId
4799
+ : null,
4800
+ )
4801
+ setElementPresent(this.host.nativeElement, false)
4802
+ setHostRoot(this.host.nativeElement, this.modalElement?.nativeElement)
4803
+ })
4815
4804
  }
4816
4805
 
4817
4806
  /**
@@ -4850,15 +4839,18 @@ wrapped in a `role="button"` fallback container. The menu is rendered into
4850
4839
  `document.body` (React's portal) and carries the position, width and
4851
4840
  roving-tabindex behavior.
4852
4841
 
4853
- The React root is a FRAGMENT (trigger + portal), so the host element is
4854
- unwrapped (`data-parity-unwrap`) and `display: contents` keeps it
4855
- fragment-like.
4842
+ The React root is a FRAGMENT (trigger + portal), so the trigger renders in
4843
+ front of the host (`placeContentBefore` / `placeElementBefore`) and the
4844
+ host itself leaves the DOM. The trigger follows the projected content: an
4845
+ element that replaces it becomes the new trigger, text next to it switches
4846
+ to the fallback wrapper.
4856
4847
 
4857
4848
  ```typescript
4858
4849
  @Component({
4859
4850
  selector: 'mol-dropdown',
4860
4851
  standalone: true,
4861
4852
  imports: [MolTemplateOutlet],
4853
+ hostDirectives: [MolPlacement],
4862
4854
  inputs: [
4863
4855
  'trigger',
4864
4856
  'items',
@@ -4873,12 +4865,10 @@ fragment-like.
4873
4865
  'disabled',
4874
4866
  ],
4875
4867
  outputs: ['select', 'openChange'],
4876
- host: {
4877
- 'data-parity-unwrap': '',
4878
- style: 'display: contents',
4879
- },
4880
- template: `<span #triggerCapture><ng-content select="[slot=trigger]"></ng-content></span
4881
- ><ng-container #menuAnchor></ng-container
4868
+ template: `<div #fallback role="button" aria-haspopup="menu" [class]="cm().dropdownTrigger">
4869
+ <span #triggerCapture><ng-content select="[slot=trigger]"></ng-content></span>
4870
+ </div>
4871
+ <ng-container #menuAnchor></ng-container
4882
4872
  ><ng-template #menuTpl
4883
4873
  ><div
4884
4874
  [attr.id]="menuId"
@@ -4940,6 +4930,7 @@ export class Dropdown implements AfterViewInit, DoCheck, OnDestroy, HasElement<H
4940
4930
  @Output() readonly openChange = new EventEmitter<boolean>()
4941
4931
 
4942
4932
  @ViewChild('triggerCapture') triggerCapture?: ElementRef<HTMLSpanElement>
4933
+ @ViewChild('fallback') fallback?: ElementRef<HTMLDivElement>
4943
4934
  @ViewChild('menuAnchor', { read: ViewContainerRef }) menuAnchor?: ViewContainerRef
4944
4935
  @ViewChild('menuTpl') menuTpl?: TemplateRef<unknown>
4945
4936
 
@@ -4962,6 +4953,8 @@ export class Dropdown implements AfterViewInit, DoCheck, OnDestroy, HasElement<H
4962
4953
  private triggerOwnMolId: string | null = null
4963
4954
  private triggerOwnDisabled = false
4964
4955
  private triggerIsFallback = false
4956
+ private triggerOwnTabindex: string | null = null
4957
+ private triggerListeners: (() => void)[] = []
4965
4958
  private menuView?: EmbeddedViewRef<unknown>
4966
4959
  private menuEl: HTMLDivElement | null = null
4967
4960
  private lastOpen = false
@@ -5093,7 +5086,7 @@ export class Dropdown implements AfterViewInit, DoCheck, OnDestroy, HasElement<H
5093
5086
  if (!this.isOpen()) this.pendingOpenFocus = 'first'
5094
5087
  this.setOpen(!this.isOpen())
5095
5088
  }
5096
- // … truncated — 23 more members: handleTriggerKeyDown, handleClose, closeAndRefocusTrigger, ngAfterViewInit, ngDoCheck, ngOnDestroy, adoptTrigger, listen, focusableIndexes, itemElements, elementForIndex, focusActive, constructor, restoreItemFocus, syncMenu, openMenu, destroyMenu, updateMenuWidth, schedulePosition, updatePosition, addListeners, removeListeners, syncTrigger; the full declaration is in node_modules/@molecule/app-ui-angular/dist/components/dropdown.component.d.ts
5089
+ // … truncated — 24 more members: handleTriggerKeyDown, handleClose, closeAndRefocusTrigger, ngAfterViewInit, ngDoCheck, ngOnDestroy, placeTrigger, adopt, release, focusableIndexes, itemElements, elementForIndex, focusActive, constructor, restoreItemFocus, syncMenu, openMenu, destroyMenu, updateMenuWidth, schedulePosition, updatePosition, addListeners, removeListeners, syncTrigger; the full declaration is in node_modules/@molecule/app-ui-angular/dist/components/dropdown.component.d.ts
5097
5090
  ```
5098
5091
 
5099
5092
  _(Member comments are left out to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/dropdown.component.d.ts`.)_
@@ -5186,13 +5179,14 @@ EmptyState component.
5186
5179
  Shown when a list or section has no data: an optional icon badge, a title,
5187
5180
  a description, and an optional action slot. React renders the icon/action
5188
5181
  wrapper divs only when those node props exist; here the wrappers always
5189
- exist as projection capture points and are detached when empty
5190
- ({@link SlotWrapper}).
5182
+ exist as projection capture points and are taken out of the DOM when empty
5183
+ (`setElementPresent`).
5191
5184
 
5192
5185
  ```typescript
5193
5186
  @Component({
5194
5187
  selector: 'div[mol-empty-state]',
5195
5188
  standalone: true,
5189
+ hostDirectives: [MolPlacement],
5196
5190
  inputs: [
5197
5191
  'icon',
5198
5192
  'title',
@@ -5223,7 +5217,7 @@ exist as projection capture points and are detached when empty
5223
5217
  <ng-content select="[slot=action]"></ng-content>
5224
5218
  </div>`,
5225
5219
  })
5226
- export class EmptyState implements AfterViewInit, DoCheck, HasElement<HTMLDivElement> {
5220
+ export class EmptyState implements HasElement<HTMLDivElement> {
5227
5221
  /** An `icon` node prop (TemplateRef), when passed as a prop instead of a slot. */
5228
5222
  icon?: unknown
5229
5223
  /** Heading text. */
@@ -5249,11 +5243,15 @@ export class EmptyState implements AfterViewInit, DoCheck, HasElement<HTMLDivEle
5249
5243
  private hasIcon = false
5250
5244
  private hasAction = false
5251
5245
 
5252
- private readonly sync = new SlotWrapper(inject(ElementRef), inject(Renderer2))
5253
5246
  private readonly host: ElementRef<HTMLDivElement> = inject(ElementRef)
5254
5247
  /** The element a caller's ref receives: the host `<div>`. */
5255
5248
  readonly element = hostElement(this.host)
5256
5249
 
5250
+ /** Detaches the icon and action wrappers React would not render. */
5251
+ constructor() {
5252
+ usePlacement((hasContent) => this.syncWrappers(hasContent))
5253
+ }
5254
+
5257
5255
  /**
5258
5256
  * The current class map.
5259
5257
  * @returns The UIClassMap.
@@ -5279,32 +5277,21 @@ export class EmptyState implements AfterViewInit, DoCheck, HasElement<HTMLDivEle
5279
5277
  }
5280
5278
 
5281
5279
  /**
5282
- * Detects slot content and detaches the wrappers React would not render.
5283
- * View queries resolve only by view init, so presence is read here.
5280
+ * Applies React's `{icon && <div>…}` / `{action && <div>…}` conditions.
5281
+ *
5282
+ * @param hasContent - Reads whether a slot has content.
5284
5283
  */
5285
- ngAfterViewInit(): void {
5284
+ private syncWrappers(hasContent: SlotReader): void {
5286
5285
  this.hasIcon =
5287
- this.icon !== undefined && this.icon !== null ? true : hasNodes(this.iconSlot?.nativeElement)
5286
+ this.icon !== undefined && this.icon !== null
5287
+ ? true
5288
+ : hasContent(this.iconSlot?.nativeElement)
5288
5289
  this.hasAction =
5289
5290
  this.action !== undefined && this.action !== null
5290
5291
  ? true
5291
- : hasNodes(this.actionSlot?.nativeElement)
5292
- this.syncWrappers()
5293
- }
5294
-
5295
- /**
5296
- * Re-reconciles wrappers on later passes.
5297
- */
5298
- ngDoCheck(): void {
5299
- this.syncWrappers()
5300
- }
5301
-
5302
- /**
5303
- * Applies React's `{icon && <div>…}` / `{action && <div>…}` conditions.
5304
- */
5305
- private syncWrappers(): void {
5306
- this.sync.sync(this.iconSlot?.nativeElement, this.hasIcon)
5307
- this.sync.sync(this.actionSlot?.nativeElement, this.hasAction)
5292
+ : hasContent(this.actionSlot?.nativeElement)
5293
+ setElementPresent(this.iconSlot?.nativeElement, this.hasIcon)
5294
+ setElementPresent(this.actionSlot?.nativeElement, this.hasAction)
5308
5295
  }
5309
5296
  }
5310
5297
  ```
@@ -5485,6 +5472,7 @@ components (`Input`, `Select`, `Textarea`, `Checkbox`) read.
5485
5472
  @Component({
5486
5473
  selector: 'div[mol-form-field]',
5487
5474
  standalone: true,
5475
+ hostDirectives: [MolPlacement],
5488
5476
  inputs: [
5489
5477
  'label',
5490
5478
  'name',
@@ -5518,7 +5506,7 @@ components (`Input`, `Select`, `Textarea`, `Checkbox`) read.
5518
5506
  <p [attr.id]="hintId" [class]="cm().formHint">{{ hint }}</p>
5519
5507
  }`,
5520
5508
  })
5521
- export class FormField implements AfterViewInit, OnDestroy, HasElement<HTMLDivElement> {
5509
+ export class FormField implements OnDestroy, HasElement<HTMLDivElement> {
5522
5510
  /** Field label. */
5523
5511
  label?: string
5524
5512
  /** Field name (drives the ids). */
@@ -5551,78 +5539,61 @@ export class FormField implements AfterViewInit, OnDestroy, HasElement<HTMLDivEl
5551
5539
  private readonly host: ElementRef<HTMLDivElement> = inject(ElementRef)
5552
5540
  /** The element a caller's ref receives: the host `<div>`. */
5553
5541
  readonly element = hostElement(this.host)
5554
- private readonly renderer = inject(Renderer2)
5555
- private readonly sync = new SlotWrapper(this.host, this.renderer)
5556
- /** Cached single-child determination (the capture empties at view init). */
5557
- private singleCache: boolean | null = null
5542
+ private readonly singleState = signal<boolean | null>(null)
5543
+ /** The native control this field patched, with the attributes it had before. */
5544
+ private patched: {
5545
+ control: HTMLElement
5546
+ attributes: Record<(typeof PATCHED_ATTRIBUTES)[number], string | null>
5547
+ } | null = null
5548
+ /** The first projected node the last adoption saw: a different one is adopted again. */
5549
+ private adopted: Node | null = null
5550
+ /** Whether the adopted content was a single element child. */
5551
+ private single = false
5558
5552
 
5559
5553
  /** Registers the field context before any projected child resolves it. */
5560
5554
  constructor() {
5561
- provideDomContext(this.host.nativeElement, new FormFieldContextValue(this))
5555
+ FormFieldDomContext.provide(this.host.nativeElement, new FormFieldContextValue(this))
5556
+ usePlacement((hasContent) => this.reconcile(hasContent))
5562
5557
  }
5563
5558
 
5564
- /**
5565
- * The current class map.
5566
- * @returns The UIClassMap.
5567
- */
5559
+ /** The current class map. */
5568
5560
  cm(): UIClassMap {
5569
5561
  return getClassMap()
5570
5562
  }
5571
5563
 
5572
- /**
5573
- * The field id (`name`, or a generated id).
5574
- * @returns The id.
5575
- */
5564
+ /** The field id (`name`, or a generated id). */
5576
5565
  fieldId(): string {
5577
5566
  return this.name || this.generatedId
5578
5567
  }
5579
5568
 
5580
- /**
5581
- * The error paragraph's id.
5582
- * @returns The id.
5583
- */
5569
+ /** The error paragraph's id. */
5584
5570
  get errorId(): string {
5585
5571
  return `${this.fieldId()}-error`
5586
5572
  }
5587
5573
 
5588
- /**
5589
- * The hint paragraph's id.
5590
- * @returns The id.
5591
- */
5574
+ /** The hint paragraph's id. */
5592
5575
  get hintId(): string {
5593
5576
  return `${this.fieldId()}-hint`
5594
5577
  }
5595
5578
 
5596
- /**
5597
- * The id the field should describe itself with (error wins over hint).
5598
- * @returns The id, or undefined.
5599
- */
5579
+ /** The id the field should describe itself with (error wins over hint). */
5600
5580
  describedByTarget(): string | undefined {
5601
5581
  if (this.error) return this.errorId
5602
5582
  if (this.hint) return this.hintId
5603
5583
  return undefined
5604
5584
  }
5605
5585
 
5606
- /**
5607
- * The wrapper class list.
5608
- * @returns The class string.
5609
- */
5586
+ /** The wrapper class list. */
5610
5587
  classes(): string {
5611
5588
  return this.cm().cn(this.cm().inputWrapper, this.cm().sp('mb', 4), this.className)
5612
5589
  }
5613
5590
 
5614
- /**
5615
- * Serializes the wrapper's inline style.
5616
- * @returns The style attribute text.
5617
- */
5591
+ /** Serializes the wrapper's inline style. */
5618
5592
  hostStyle(): string | null {
5619
5593
  return styleText(this.style)
5620
5594
  }
5621
5595
 
5622
- /**
5623
- * The `data-mol-id` value (`automationId` wins over a rest `data-mol-id`).
5624
- * @returns The attribute value.
5625
- */
5596
+ /** The `data-mol-id` value (`automationId` wins over a rest `data-mol-id`). */
5626
5597
  molId(): string | undefined {
5627
5598
  return (
5628
5599
  this.automationId ??
@@ -5632,11 +5603,6 @@ export class FormField implements AfterViewInit, OnDestroy, HasElement<HTMLDivEl
5632
5603
  )
5633
5604
  }
5634
5605
 
5635
- /**
5636
- * The capture span (a view query before view init, a DOM lookup after —
5637
- * the span lives directly under the host and is removed at view init).
5638
- * @returns The capture element, or null.
5639
- */
5640
5606
  private captureEl(): HTMLElement | null {
5641
5607
  return (
5642
5608
  this.capture?.nativeElement ??
@@ -5644,37 +5610,53 @@ export class FormField implements AfterViewInit, OnDestroy, HasElement<HTMLDivEl
5644
5610
  )
5645
5611
  }
5646
5612
 
5647
- /**
5648
- * Whether the projected content is exactly one element (React clones only a
5649
- * single child). Cached: the children leave the capture span at view init.
5650
- * @returns True for a single element child.
5651
- */
5613
+ /** Whether the projected content is exactly one element (React clones only a single child). */
5652
5614
  singleChild(): boolean {
5653
- if (this.singleCache !== null) return this.singleCache
5615
+ const single = this.singleState()
5616
+ if (single !== null) return single
5654
5617
  const capture = this.captureEl()
5655
5618
  if (!capture) return false
5656
5619
  const children = Array.from(capture.childNodes)
5657
5620
  const elements = children.filter((node) => node.nodeType === 1)
5658
5621
  const hasText = children.some((node) => node.nodeType === 3 && (node.textContent ?? '').trim())
5659
- this.singleCache = elements.length === 1 && !hasText
5660
- return this.singleCache
5622
+ return elements.length === 1 && !hasText
5661
5623
  }
5662
5624
 
5663
- /**
5664
- * Adopts the projected children bare into the host (React renders them
5665
- * directly), resolves the label target from the single child's control and
5666
- * patches a plain native control child (React's cloneElement props).
5667
- */
5668
- ngAfterViewInit(): void {
5625
+ private reconcile(hasContent: SlotReader): void {
5669
5626
  const capture = this.captureEl()
5670
5627
  if (!capture) return
5628
+ const children = hasContent.nodes(capture)
5629
+ if (children.length === 0) {
5630
+ this.adopted = null
5631
+ this.single = false
5632
+ this.singleState.set(null)
5633
+ this.unpatchNativeControl()
5634
+ this.labelFor.set(this.fieldId())
5635
+ setElementPresent(capture, false)
5636
+ return
5637
+ }
5638
+ const first = children[0]!
5639
+ // Angular inserts a list's nodes one at a time, and this runs after each:
5640
+ // a second child arriving after the first makes the field "not single" again.
5641
+ const single = children.length === 1 && first.nodeType === 1
5642
+ if (this.adopted === first && this.single === single) {
5643
+ // The adopted control's own id may bind after the first run; keep the
5644
+ // label pointed at it as it settles (React adopts the child's id).
5645
+ const control = this.single
5646
+ ? this.host.nativeElement.querySelector<HTMLElement>(FIELD_SELECTOR)
5647
+ : null
5648
+ this.labelFor.set(control?.id || this.fieldId())
5649
+ setElementPresent(capture, false)
5650
+ return
5651
+ }
5671
5652
  const host = this.host.nativeElement
5672
- const children = Array.from(capture.childNodes)
5673
- const elements = children.filter((node) => node.nodeType === 1)
5674
- const single = this.singleChild()
5675
- for (const node of children) host.insertBefore(node, capture)
5653
+ this.singleState.set(single)
5654
+ this.single = single
5655
+ placeContent(capture, host, capture)
5656
+ // React renders a child it no longer clones with its own props.
5657
+ this.unpatchNativeControl()
5676
5658
  if (single) {
5677
- const child = elements[0] as HTMLElement
5659
+ const child = first as HTMLElement
5678
5660
  const control = child.matches(FIELD_SELECTOR)
5679
5661
  ? child
5680
5662
  : child.querySelector<HTMLElement>(FIELD_SELECTOR)
@@ -5683,14 +5665,18 @@ export class FormField implements AfterViewInit, OnDestroy, HasElement<HTMLDivEl
5683
5665
  } else {
5684
5666
  this.labelFor.set(this.fieldId())
5685
5667
  }
5686
- this.sync.sync(capture, false, host)
5668
+ setElementPresent(capture, false)
5669
+ this.adopted = first
5687
5670
  }
5688
5671
 
5689
- /**
5690
- * Applies React's cloned props to a plain native form control child.
5691
- * @param control - The native control element.
5692
- */
5672
+ /** Applies React's cloned props to a plain native form control child. */
5693
5673
  private patchNativeControl(control: HTMLElement): void {
5674
+ this.patched = {
5675
+ control,
5676
+ attributes: Object.fromEntries(
5677
+ PATCHED_ATTRIBUTES.map((name) => [name, control.getAttribute(name)]),
5678
+ ) as Record<(typeof PATCHED_ATTRIBUTES)[number], string | null>,
5679
+ }
5694
5680
  control.setAttribute('id', this.fieldId())
5695
5681
  const describedBy = this.describedByTarget()
5696
5682
  if (describedBy) {
@@ -5700,13 +5686,27 @@ export class FormField implements AfterViewInit, OnDestroy, HasElement<HTMLDivEl
5700
5686
  if (this.error) control.setAttribute('aria-invalid', 'true')
5701
5687
  }
5702
5688
 
5689
+ /** Puts back the attributes a patched control had before this field cloned it. */
5690
+ private unpatchNativeControl(): void {
5691
+ if (this.patched === null) return
5692
+ const { control, attributes } = this.patched
5693
+ this.patched = null
5694
+ for (const name of PATCHED_ATTRIBUTES) {
5695
+ const value = attributes[name]
5696
+ if (value === null) control.removeAttribute(name)
5697
+ else control.setAttribute(name, value)
5698
+ }
5699
+ }
5700
+
5703
5701
  /** Removes the context registration (unmount). */
5704
5702
  ngOnDestroy(): void {
5705
- removeDomContext(this.host.nativeElement)
5703
+ FormFieldDomContext.remove(this.host.nativeElement)
5706
5704
  }
5707
5705
  }
5708
5706
  ```
5709
5707
 
5708
+ _(Member comments are shortened to their first sentence, and the 3 longest are left out to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/form-field.component.d.ts`.)_
5709
+
5710
5710
  #### `Form`
5711
5711
 
5712
5712
  Form component.
@@ -6114,13 +6114,14 @@ user input exactly like React's controlled-input state restore.
6114
6114
 
6115
6115
  The adornment wrappers React renders conditionally
6116
6116
  (`{!!leftElement && <div …>}` / `{(rightElement || (clearable && value)) && …}`)
6117
- are always-mounted `<ng-content>` capture points that are detached from the
6118
- DOM whenever React would render nothing (see {@link SlotWrapper}).
6117
+ are always-mounted `<ng-content>` capture points that are taken out of the
6118
+ DOM whenever React would render nothing (`setElementPresent`).
6119
6119
 
6120
6120
  ```typescript
6121
6121
  @Component({
6122
6122
  selector: 'div[mol-input]',
6123
6123
  standalone: true,
6124
+ hostDirectives: [MolPlacement],
6124
6125
  imports: [MolIconSvg, NgTemplateOutlet],
6125
6126
  inputs: [
6126
6127
  'type',
@@ -6217,7 +6218,7 @@ DOM whenever React would render nothing (see {@link SlotWrapper}).
6217
6218
  <p [attr.id]="inputId() + '-hint'" [class]="cm().formHint">{{ hint }}</p>
6218
6219
  }`,
6219
6220
  })
6220
- export class Input implements AfterViewChecked, DoCheck, HasElement<HTMLInputElement> {
6221
+ export class Input implements AfterViewChecked, HasElement<HTMLInputElement> {
6221
6222
  type?: string
6222
6223
  size?: Size
6223
6224
  align?: 'left' | 'center' | 'right'
@@ -6263,15 +6264,17 @@ export class Input implements AfterViewChecked, DoCheck, HasElement<HTMLInputEle
6263
6264
 
6264
6265
  private readonly host = inject(ElementRef)
6265
6266
 
6267
+ private readonly hasLeft = signal(false)
6268
+ private readonly hasRight = signal(false)
6269
+
6270
+ constructor() {
6271
+ usePlacement((hasContent) => this.syncAdornments(hasContent))
6272
+ }
6273
+
6266
6274
  private readonly generatedId = nextInstanceId()
6267
6275
 
6268
6276
  private readonly i18n = useTranslation()
6269
6277
 
6270
- private readonly sync = new SlotWrapper(inject(ElementRef), inject(Renderer2))
6271
- private readonly parents = new Map<Node, HTMLElement>()
6272
-
6273
- private hasLeft = false
6274
- private hasRight = false
6275
6278
  private movedRest = false
6276
6279
  private restDescribedBy: string | null = null
6277
6280
  private externalMolId: string | undefined
@@ -6307,8 +6310,8 @@ export class Input implements AfterViewChecked, DoCheck, HasElement<HTMLInputEle
6307
6310
  size: this.size ?? 'md',
6308
6311
  align: this.align === 'right' ? undefined : this.align,
6309
6312
  }),
6310
- this.hasLeft && this.cm().inputPadLeft,
6311
- (this.hasRight || this.clearable) && this.cm().inputPadRight,
6313
+ this.hasLeft() && this.cm().inputPadLeft,
6314
+ (this.hasRight() || this.clearable) && this.cm().inputPadRight,
6312
6315
  this.className,
6313
6316
  )
6314
6317
  }
@@ -6351,7 +6354,24 @@ export class Input implements AfterViewChecked, DoCheck, HasElement<HTMLInputEle
6351
6354
  () => this.molId(),
6352
6355
  )
6353
6356
  }
6354
- // … truncated — 5 more members: ngDoCheck, parentOf, asTemplate, asText, isGiven; the full declaration is in node_modules/@molecule/app-ui-angular/dist/components/input.component.d.ts
6357
+
6358
+ private syncAdornments(hasContent: SlotReader): void {
6359
+ const left = this.leftSlot?.nativeElement
6360
+ const right = this.rightSlot?.nativeElement
6361
+ const inner =
6362
+ this.rightInner?.nativeElement ??
6363
+ (right ? (right.querySelector('span') as HTMLElement | null) : null) ??
6364
+ undefined
6365
+ const hasLeft = this.isGiven(this.leftElement) || hasContent(left)
6366
+ const hasRight = this.isGiven(this.rightElement) || hasContent(inner)
6367
+ this.hasLeft.set(hasLeft)
6368
+ this.hasRight.set(hasRight)
6369
+ const clear = !!(this.clearable && this.value)
6370
+ setElementPresent(left, hasLeft)
6371
+ setElementPresent(inner, hasRight && !clear)
6372
+ setElementPresent(right, hasRight || clear)
6373
+ }
6374
+ // … truncated — 4 more members: ngDoCheck, asTemplate, asText, isGiven; the full declaration is in node_modules/@molecule/app-ui-angular/dist/components/input.component.d.ts
6355
6375
  ```
6356
6376
 
6357
6377
  _(Member comments are left out to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/input.component.d.ts`.)_
@@ -6408,8 +6428,10 @@ export class Label implements HasElement<HTMLLabelElement> {
6408
6428
 
6409
6429
  LanguagePicker component.
6410
6430
 
6411
- React's root is a FRAGMENT (trigger button + locale modal), so the host is
6412
- unwrapped (`data-parity-unwrap`, `display: contents`). Rest props (`title`,
6431
+ React's root is a FRAGMENT (trigger button + locale modal), so everything
6432
+ the host holds renders in front of the host (`placeContentBefore`) and the
6433
+ host itself leaves the page: the rendered tree is React's, with no wrapper
6434
+ element around the trigger. Rest props (`title`,
6413
6435
  `data-*`, `aria-*`, native event handlers) are spread onto the trigger
6414
6436
  button in React; here they land on the host and are moved onto it.
6415
6437
 
@@ -6417,6 +6439,7 @@ button in React; here they land on the host and are moved onto it.
6417
6439
  @Component({
6418
6440
  selector: 'mol-language-picker',
6419
6441
  standalone: true,
6442
+ hostDirectives: [MolPlacement],
6420
6443
  imports: [Icon, Modal, MolTemplateOutlet],
6421
6444
  inputs: [
6422
6445
  'labelKey',
@@ -6430,10 +6453,6 @@ button in React; here they land on the host and are moved onto it.
6430
6453
  'style',
6431
6454
  'renderTrigger',
6432
6455
  ],
6433
- host: {
6434
- 'data-parity-unwrap': '',
6435
- style: 'display: contents',
6436
- },
6437
6456
  template: `@if (asTemplate(renderTrigger); as customTrigger) {
6438
6457
  <ng-container
6439
6458
  [molTemplateOutlet]="customTrigger"
@@ -6477,7 +6496,7 @@ button in React; here they land on the host and are moved onto it.
6477
6496
  </div></mol-modal
6478
6497
  >`,
6479
6498
  })
6480
- export class LanguagePicker implements AfterViewInit, DoCheck {
6499
+ export class LanguagePicker {
6481
6500
  /** i18n key for the trigger label / aria-label (default `footer.language`). */
6482
6501
  labelKey?: LanguagePickerProps['labelKey']
6483
6502
  /** Fallback label if the i18n key is missing (default `Language`). */
@@ -6522,8 +6541,20 @@ export class LanguagePicker implements AfterViewInit, DoCheck {
6522
6541
  readonly i18n = useTranslation()
6523
6542
 
6524
6543
  private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
6525
- private readonly renderer = inject(Renderer2)
6526
- private movedRest = false
6544
+ /**
6545
+ * Renders everything the host holds (the trigger, or the caller's
6546
+ * `renderTrigger` output, and the locale modal) in front of the host, which
6547
+ * leaves the page: React's root is a fragment. What the caller binds on the
6548
+ * tag lands on the trigger button, React's `{...rest}` target.
6549
+ */
6550
+ constructor() {
6551
+ usePlacement(() => {
6552
+ const host = this.host.nativeElement
6553
+ placeContentBefore(host, host)
6554
+ setElementPresent(host, false)
6555
+ setHostRoot(host, this.trigger?.nativeElement)
6556
+ })
6557
+ }
6527
6558
 
6528
6559
  /**
6529
6560
  * The current class map.
@@ -6627,29 +6658,6 @@ export class LanguagePicker implements AfterViewInit, DoCheck {
6627
6658
  await this.i18n.setLocale(code)
6628
6659
  this.isOpen.set(false)
6629
6660
  }
6630
-
6631
- /**
6632
- * Moves React's rest props (title, data-*, aria-*, native handlers) from
6633
- * the host onto the trigger button, and drops the capture wrapper.
6634
- */
6635
- ngAfterViewInit(): void {
6636
- this.syncRest()
6637
- }
6638
-
6639
- /**
6640
- * Re-applies rest attributes on later passes (a props step may add them).
6641
- */
6642
- ngDoCheck(): void {
6643
- this.syncRest()
6644
- }
6645
-
6646
- /** Moves any host rest attributes onto the trigger button. */
6647
- private syncRest(): void {
6648
- const trigger = this.trigger?.nativeElement
6649
- if (!trigger || this.movedRest) return
6650
- moveRestAttributes(this.host.nativeElement, trigger)
6651
- this.movedRest = true
6652
- }
6653
6661
  }
6654
6662
  ```
6655
6663
 
@@ -7127,6 +7135,7 @@ paragraph and the retry row render only when React would render them.
7127
7135
  @Component({
7128
7136
  selector: 'div[mol-load-error-banner]',
7129
7137
  standalone: true,
7138
+ hostDirectives: [MolPlacement],
7130
7139
  imports: [Alert, MolTemplateOutlet],
7131
7140
  inputs: ['message', 'detail', 'retryLabel', 'retryMolId', 'onRetry'],
7132
7141
  host: {
@@ -7164,7 +7173,7 @@ paragraph and the retry row render only when React would render them.
7164
7173
  </div>
7165
7174
  </div>`,
7166
7175
  })
7167
- export class LoadErrorBanner implements AfterViewInit, DoCheck, OnDestroy {
7176
+ export class LoadErrorBanner {
7168
7177
  /** The primary error line (node-valued prop). */
7169
7178
  message?: LoadErrorBannerProps['message']
7170
7179
  /** Secondary line under the message (node-valued prop). */
@@ -7202,12 +7211,13 @@ export class LoadErrorBanner implements AfterViewInit, DoCheck, OnDestroy {
7202
7211
  */
7203
7212
  private readonly i18n = useTranslation()
7204
7213
 
7205
- private readonly sync = new SlotWrapper(inject(ElementRef), inject(Renderer2))
7206
- private hasDetail = false
7207
- /** Whether the projected retry label exists (a signal: it is read after view init). */
7214
+ /** Whether the projected retry label exists (a signal the placement function sets). */
7208
7215
  private readonly hasRetryLabel = signal(false)
7209
- private detailParent: HTMLElement | null = null
7210
- private retryParent: HTMLElement | null = null
7216
+
7217
+ /** Reconciles the detail/retry wrappers and the projected retry label. */
7218
+ constructor() {
7219
+ usePlacement((hasContent) => this.reconcile(hasContent))
7220
+ }
7211
7221
 
7212
7222
  /**
7213
7223
  * The current class map.
@@ -7257,45 +7267,30 @@ export class LoadErrorBanner implements AfterViewInit, DoCheck, OnDestroy {
7257
7267
  }
7258
7268
 
7259
7269
  /**
7260
- * Reads detail/label presence at view init (view queries resolve only then).
7261
- */
7262
- ngAfterViewInit(): void {
7263
- this.detailParent = this.detailSlot?.nativeElement.parentElement ?? null
7264
- this.retryParent = this.retrySlot?.nativeElement.parentElement ?? null
7265
- this.hasDetail = this.detailPresent()
7266
- this.hasRetryLabel.set(hasNodes(this.retryLabelSlot?.nativeElement))
7267
- this.sync.sync(
7268
- this.retryLabelSlot?.nativeElement,
7269
- false,
7270
- this.retryLabelSlot?.nativeElement.parentElement ?? undefined,
7271
- )
7272
- this.ngDoCheck()
7273
- }
7274
-
7275
- /**
7276
- * Re-reconciles the conditional wrappers on later passes.
7270
+ * Applies React's detail/retry conditions and moves the projected retry
7271
+ * label onto the retry button.
7272
+ *
7273
+ * @param hasContent - Reads whether a slot has content.
7277
7274
  */
7278
- ngDoCheck(): void {
7279
- this.hasDetail = this.detailPresent()
7280
- this.sync.sync(this.detailSlot?.nativeElement, this.hasDetail, this.detailParent ?? undefined)
7275
+ private reconcile(hasContent: SlotReader): void {
7276
+ const retryLabelSlot = this.retryLabelSlot?.nativeElement
7277
+ this.hasRetryLabel.set(hasContent(retryLabelSlot))
7278
+ setElementPresent(retryLabelSlot, false)
7279
+ setElementPresent(this.detailSlot?.nativeElement, this.detailPresent(hasContent))
7281
7280
  // React renders the retry row exactly when `onRetry` is given.
7282
- this.sync.sync(this.retrySlot?.nativeElement, !!this.onRetry, this.retryParent ?? undefined)
7281
+ setElementPresent(this.retrySlot?.nativeElement, !!this.onRetry)
7283
7282
  this.showRetryLabel()
7284
7283
  }
7285
7284
 
7286
7285
  /**
7287
7286
  * Whether React would render the detail paragraph (a given node value or
7288
7287
  * projected slot content).
7288
+ *
7289
+ * @param hasContent - Reads whether a slot has content.
7289
7290
  * @returns True when the detail renders.
7290
7291
  */
7291
- private detailPresent(): boolean {
7292
- return isGiven(this.detail) || hasNodes(this.detailSlot?.nativeElement)
7293
- }
7294
-
7295
- /** Restores the retry-label capture span on unmount. */
7296
- ngOnDestroy(): void {
7297
- this.visibleNodes = []
7298
- this.visibleFrom = null
7292
+ private detailPresent(hasContent: SlotReader): boolean {
7293
+ return isGiven(this.detail) || hasContent(this.detailSlot?.nativeElement)
7299
7294
  }
7300
7295
 
7301
7296
  /** Moves the projected retry label onto the retry button (React: no wrapper). */
@@ -7304,34 +7299,10 @@ export class LoadErrorBanner implements AfterViewInit, DoCheck, OnDestroy {
7304
7299
  const span = this.retryLabelSlot?.nativeElement
7305
7300
  if (!host || !span) return
7306
7301
  if (!this.hasRetryLabel()) {
7307
- this.showNodes(host, null)
7302
+ placeContent(span, null)
7308
7303
  return
7309
7304
  }
7310
- this.showNodes(host, span)
7311
- }
7312
-
7313
- private visibleNodes: Node[] = []
7314
- private visibleFrom: HTMLSpanElement | null = null
7315
-
7316
- /**
7317
- * Shows one capture span's children inside a target element, parking any
7318
- * previously shown nodes back in their span.
7319
- *
7320
- * @param target - The element to show the nodes in.
7321
- * @param span - The capture span (null parks everything).
7322
- */
7323
- private showNodes(target: HTMLElement, span: HTMLSpanElement | null): void {
7324
- if (span === this.visibleFrom) return
7325
- for (const node of this.visibleNodes) {
7326
- if (node.parentNode === target) this.visibleFrom?.appendChild(node)
7327
- }
7328
- this.visibleNodes = []
7329
- this.visibleFrom = null
7330
- if (!span) return
7331
- const nodes = Array.from(span.childNodes)
7332
- for (const node of nodes) target.appendChild(node)
7333
- this.visibleNodes = nodes
7334
- this.visibleFrom = span
7305
+ placeContent(span, host)
7335
7306
  }
7336
7307
  }
7337
7308
  ```
@@ -7341,9 +7312,10 @@ export class LoadErrorBanner implements AfterViewInit, DoCheck, OnDestroy {
7341
7312
  Modal component.
7342
7313
 
7343
7314
  React's root is a FRAGMENT portaled into `document.body` (an overlay
7344
- `<div>` and a centering wrapper `<div>`), so the host is unwrapped
7345
- (`data-parity-unwrap`, `display: contents`) and both elements are moved
7346
- into the body. Implements the WAI-ARIA APG modal dialog pattern (focus
7315
+ `<div>` and a centering wrapper `<div>`), so the host element leaves the
7316
+ page and both elements are moved into the body while open: the rendered
7317
+ tree is React's, with no wrapper at the component's place. Implements the
7318
+ WAI-ARIA APG modal dialog pattern (focus
7347
7319
  into the dialog on open, trapped Tab, focus restored on close, Escape for
7348
7320
  the topmost dialog only, reference-counted body scroll lock).
7349
7321
 
@@ -7351,6 +7323,7 @@ the topmost dialog only, reference-counted body scroll lock).
7351
7323
  @Component({
7352
7324
  selector: 'mol-modal',
7353
7325
  standalone: true,
7326
+ hostDirectives: [MolPlacement],
7354
7327
  imports: [MolIconSvg],
7355
7328
  inputs: [
7356
7329
  'open',
@@ -7371,10 +7344,6 @@ the topmost dialog only, reference-counted body scroll lock).
7371
7344
  'onDoubleClick',
7372
7345
  ],
7373
7346
  outputs: ['close'],
7374
- host: {
7375
- 'data-parity-unwrap': '',
7376
- style: 'display: contents',
7377
- },
7378
7347
  template: `<div #overlay [class]="cm().dialogOverlay" aria-hidden="true"></div>
7379
7348
  <div
7380
7349
  #wrapper
@@ -7466,16 +7435,18 @@ export class Modal
7466
7435
  private readonly inner = signal<HTMLDivElement | null>(null)
7467
7436
  readonly element = this.inner.asReadonly()
7468
7437
 
7438
+ constructor() {
7439
+ usePlacement((hasContent) => this.reconcileFooter(hasContent))
7440
+ }
7441
+
7469
7442
  private readonly i18n = useTranslation()
7470
7443
 
7471
7444
  private readonly sync = createScrollLock()
7472
7445
  private lastOpen = false
7473
7446
  private lastFooter = false
7474
- private footerParent: HTMLElement | null = null
7475
7447
  private previouslyFocused: HTMLElement | null = null
7476
7448
  private listeners: (() => void)[] = []
7477
7449
  private locked = false
7478
- private moved = false
7479
7450
  private externalMolId: string | undefined
7480
7451
 
7481
7452
  cm(): UIClassMap {
@@ -7526,7 +7497,6 @@ export class Modal
7526
7497
  const overlay = this.overlay?.nativeElement
7527
7498
  const wrapper = this.wrapper?.nativeElement
7528
7499
  const dialog = this.dialog?.nativeElement
7529
- this.footerParent = this.footerSlot?.nativeElement.parentElement ?? null
7530
7500
  if (dialog) {
7531
7501
  adoptHostDataMolId(
7532
7502
  this.host.nativeElement,
@@ -7536,10 +7506,7 @@ export class Modal
7536
7506
  },
7537
7507
  () => this.molId(),
7538
7508
  )
7539
- moveRestAttributes(this.host.nativeElement, dialog)
7540
7509
  }
7541
- this.lastFooter = this.hasFooter()
7542
- this.syncFooter()
7543
7510
  const open = !!this.open
7544
7511
  if (open) {
7545
7512
  this.previouslyFocused = (document.activeElement as HTMLElement | null) ?? null
@@ -7553,15 +7520,12 @@ export class Modal
7553
7520
  this.syncScrollLock()
7554
7521
  this.lastOpen = open
7555
7522
  }
7556
-
7557
7523
  ngDoCheck(): void {
7558
7524
  const open = !!this.open
7559
7525
  if (open !== this.lastOpen) {
7560
7526
  this.lastOpen = open
7561
7527
  this.transition(open)
7562
7528
  }
7563
- this.lastFooter = this.hasFooter()
7564
- this.syncFooter()
7565
7529
  this.syncScrollLock()
7566
7530
  }
7567
7531
 
@@ -7574,9 +7538,6 @@ export class Modal
7574
7538
  },
7575
7539
  () => this.molId(),
7576
7540
  )
7577
- reapplyRestAttributes(this.host.nativeElement, this.dialog?.nativeElement, {
7578
- includeDescribedBy: true,
7579
- })
7580
7541
  }
7581
7542
 
7582
7543
  ngOnDestroy(): void {
@@ -7594,37 +7555,50 @@ export class Modal
7594
7555
  this.sync.unlock()
7595
7556
  this.locked = false
7596
7557
  }
7597
- const host = this.host.nativeElement
7598
- if (this.moved) {
7599
- const overlay = this.overlay?.nativeElement
7600
- const wrapper = this.wrapper?.nativeElement
7601
- if (overlay?.parentNode === document.body) host.appendChild(overlay)
7602
- if (wrapper?.parentNode === document.body) host.appendChild(wrapper)
7603
- this.moved = false
7604
- }
7605
7558
  }
7606
7559
 
7607
- private hasFooter(): boolean {
7608
- const slot = this.footerSlot?.nativeElement
7609
- if (!slot) return false
7610
- for (const node of Array.from(slot.childNodes)) {
7611
- if (node.nodeType === 1) return true
7612
- if (node.nodeType === 3 && (node.textContent ?? '').trim()) return true
7613
- }
7614
- return false
7560
+ private reconcileFooter(hasContent: SlotReader): void {
7561
+ this.lastFooter = hasContent(this.footerSlot?.nativeElement)
7562
+ setElementPresent(this.footerSlot?.nativeElement, this.lastFooter)
7563
+ setElementPresent(this.host.nativeElement, false)
7564
+ setHostRoot(this.host.nativeElement, this.dialog?.nativeElement, { except: ['data-mol-id'] })
7615
7565
  }
7616
7566
 
7617
- private syncFooter(): void {
7618
- const slot = this.footerSlot?.nativeElement
7619
- if (!slot) return
7620
- const shouldRender = this.lastFooter
7621
- if (shouldRender && !slot.isConnected) {
7622
- ;(this.footerParent ?? this.dialog?.nativeElement ?? null)?.appendChild(slot)
7623
- } else if (!shouldRender && slot.isConnected) {
7624
- slot.remove()
7567
+ private transition(open: boolean): void {
7568
+ if (open) {
7569
+ this.previouslyFocused = (document.activeElement as HTMLElement | null) ?? null
7570
+ pushModalStack(this.stackId)
7571
+ this.attachPortal()
7572
+ this.focusFirstInDialog()
7573
+ this.addListeners()
7574
+ } else {
7575
+ popModalStack(this.stackId)
7576
+ this.removeListeners()
7577
+ this.detachPortal()
7578
+ const toRestore = this.previouslyFocused
7579
+ if (toRestore)
7580
+ afterNextRender(
7581
+ () => {
7582
+ if (document.contains(toRestore)) toRestore.focus()
7583
+ },
7584
+ { injector: this.injector },
7585
+ )
7625
7586
  }
7587
+ this.syncScrollLock()
7626
7588
  }
7627
- // … truncated — 8 more members: transition, focusFirstInDialog, attachPortal, detachPortal, syncScrollLock, addListeners, removeListeners, handleKeyDown; the full declaration is in node_modules/@molecule/app-ui-angular/dist/components/modal.component.d.ts
7589
+
7590
+ private focusFirstInDialog(): void {
7591
+ afterNextRender(
7592
+ () => {
7593
+ const dialog = this.dialog?.nativeElement
7594
+ if (!dialog) return
7595
+ const focusables = getFocusableElements(dialog)
7596
+ ;(focusables[0] ?? dialog).focus()
7597
+ },
7598
+ { injector: this.injector },
7599
+ )
7600
+ }
7601
+ // … truncated — 6 more members: attachPortal, detachPortal, syncScrollLock, addListeners, removeListeners, handleKeyDown; the full declaration is in node_modules/@molecule/app-ui-angular/dist/components/modal.component.d.ts
7628
7602
  ```
7629
7603
 
7630
7604
  _(Member comments are left out to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/modal.component.d.ts`.)_
@@ -7828,14 +7802,20 @@ export class MoleculeBadge {
7828
7802
 
7829
7803
  Angular Button UI component with UIClassMap-driven styling.
7830
7804
 
7805
+ React's root is the native `<button>`, so the button element of the
7806
+ template renders in front of the host (`placeElementBefore`) and the host
7807
+ itself leaves the page: the rendered tree is React's, with no wrapper
7808
+ element around the button.
7809
+
7831
7810
  ```typescript
7832
7811
  @Component({
7833
7812
  selector: 'mol-button',
7834
7813
  standalone: true,
7835
7814
  changeDetection: ChangeDetectionStrategy.OnPush,
7836
- host: { style: 'display: contents' },
7815
+ hostDirectives: [MolPlacement],
7837
7816
  template: `
7838
7817
  <button
7818
+ #root
7839
7819
  [type]="type"
7840
7820
  [class]="classes"
7841
7821
  [style]="style"
@@ -7874,6 +7854,21 @@ export class MoleculeButton {
7874
7854
 
7875
7855
  @Output() handleClick = new EventEmitter<MouseEvent>()
7876
7856
 
7857
+ /** The native button React renders as the component's root. */
7858
+ @ViewChild('root') root?: ElementRef<HTMLButtonElement>
7859
+
7860
+ private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
7861
+
7862
+ /** Renders the button in front of the host, which leaves the page. */
7863
+ constructor() {
7864
+ usePlacement(() => {
7865
+ const root = this.root?.nativeElement
7866
+ if (!root) return
7867
+ placeElementBefore(root, this.host.nativeElement)
7868
+ setElementPresent(this.host.nativeElement, false)
7869
+ })
7870
+ }
7871
+
7877
7872
  /**
7878
7873
  * Retrieves the current UI class map.
7879
7874
  * @returns The UIClassMap instance for styling.
@@ -8908,7 +8903,7 @@ Angular Toast UI component with UIClassMap-driven styling.
8908
8903
  standalone: true,
8909
8904
  changeDetection: ChangeDetectionStrategy.OnPush,
8910
8905
  template: `
8911
- @if (isVisible) {
8906
+ @if (isVisible()) {
8912
8907
  <div
8913
8908
  role="alert"
8914
8909
  data-state="open"
@@ -8966,7 +8961,8 @@ export class MoleculeToast implements OnInit, OnDestroy {
8966
8961
 
8967
8962
  @Output() dismiss = new EventEmitter<void>()
8968
8963
 
8969
- isVisible = true
8964
+ /** Whether the toast shows; a signal, so the auto-dismiss timer's change renders (OnPush). */
8965
+ readonly isVisible = signal(true)
8970
8966
  private timer?: ReturnType<typeof setTimeout>
8971
8967
 
8972
8968
  /**
@@ -9071,7 +9067,7 @@ export class MoleculeToast implements OnInit, OnDestroy {
9071
9067
  ngOnInit(): void {
9072
9068
  if (this.duration > 0) {
9073
9069
  this.timer = setTimeout(() => {
9074
- this.isVisible = false
9070
+ this.isVisible.set(false)
9075
9071
  this.dismiss.emit()
9076
9072
  }, this.duration)
9077
9073
  }
@@ -9090,7 +9086,7 @@ export class MoleculeToast implements OnInit, OnDestroy {
9090
9086
  * Handles the dismiss action by hiding the toast.
9091
9087
  */
9092
9088
  onDismiss(): void {
9093
- this.isVisible = false
9089
+ this.isVisible.set(false)
9094
9090
  this.dismiss.emit()
9095
9091
  }
9096
9092
  }
@@ -9119,7 +9115,7 @@ a small themed pointer at the resolved `placement` edge.
9119
9115
  >
9120
9116
  <ng-content></ng-content>
9121
9117
  </div>
9122
- @if (isVisible) {
9118
+ @if (isVisible()) {
9123
9119
  <!--
9124
9120
  Outer positioned wrapper carries the top/left/z-index placement; the
9125
9121
  arrow renders as its SIBLING (not nested inside the visible box),
@@ -9127,7 +9123,7 @@ a small themed pointer at the resolved `placement` edge.
9127
9123
  past the box's own edge would be clipped invisible if it were a
9128
9124
  descendant of that element instead.
9129
9125
  -->
9130
- <div [style]="positionStyle">
9126
+ <div [style]="positionStyle()">
9131
9127
  <div
9132
9128
  #tooltipEl
9133
9129
  role="tooltip"
@@ -9160,8 +9156,10 @@ export class MoleculeTooltip implements OnDestroy {
9160
9156
  @ViewChild('trigger') triggerRef?: ElementRef<HTMLDivElement>
9161
9157
  @ViewChild('tooltipEl') tooltipRef?: ElementRef<HTMLDivElement>
9162
9158
 
9163
- isVisible = false
9164
- positionStyle: Record<string, string> = {}
9159
+ /** Whether the tooltip shows; a signal, so the delay timer's change renders (OnPush). */
9160
+ readonly isVisible = signal(false)
9161
+ /** The measured placement; a signal, so the animation frame's measurement renders (OnPush). */
9162
+ readonly positionStyle = signal<Record<string, string>>({})
9165
9163
  private timeoutId?: ReturnType<typeof setTimeout>
9166
9164
 
9167
9165
  /**
@@ -9194,11 +9192,12 @@ export class MoleculeTooltip implements OnDestroy {
9194
9192
  show(): void {
9195
9193
  if (this.delay > 0) {
9196
9194
  this.timeoutId = setTimeout(() => {
9197
- this.isVisible = true
9198
- this.updatePosition()
9195
+ this.isVisible.set(true)
9196
+ // Measured once the tooltip has rendered.
9197
+ requestAnimationFrame(() => this.updatePosition())
9199
9198
  }, this.delay)
9200
9199
  } else {
9201
- this.isVisible = true
9200
+ this.isVisible.set(true)
9202
9201
  requestAnimationFrame(() => this.updatePosition())
9203
9202
  }
9204
9203
  }
@@ -9210,7 +9209,7 @@ export class MoleculeTooltip implements OnDestroy {
9210
9209
  if (this.timeoutId) {
9211
9210
  clearTimeout(this.timeoutId)
9212
9211
  }
9213
- this.isVisible = false
9212
+ this.isVisible.set(false)
9214
9213
  }
9215
9214
 
9216
9215
  /**
@@ -9272,12 +9271,12 @@ export class MoleculeTooltip implements OnDestroy {
9272
9271
  }
9273
9272
 
9274
9273
  const pos = positions[this.placement]
9275
- this.positionStyle = {
9274
+ this.positionStyle.set({
9276
9275
  position: 'absolute',
9277
9276
  top: `${pos.top}px`,
9278
9277
  left: `${pos.left}px`,
9279
9278
  zIndex: '9999',
9280
- }
9279
+ })
9281
9280
  }
9282
9281
  }
9283
9282
  ```
@@ -9296,6 +9295,7 @@ one is shown, moved onto the button with no wrapper, matching React's
9296
9295
  @Component({
9297
9296
  selector: 'button[mol-optimistic-toggle-button]',
9298
9297
  standalone: true,
9298
+ hostDirectives: [MolPlacement],
9299
9299
  imports: [MolTemplateOutlet],
9300
9300
  inputs: [
9301
9301
  'value',
@@ -9317,6 +9317,7 @@ one is shown, moved onto the button with no wrapper, matching React's
9317
9317
  'dataMolId: data-mol-id',
9318
9318
  ],
9319
9319
  host: {
9320
+ // `value` is the loaded server state, which React keeps off the <button>; Angular would also keep
9320
9321
  // a static `value="…"` on the host as the button's form value.
9321
9322
  '[attr.value]': 'null',
9322
9323
  '[class]': 'classes()',
@@ -9347,9 +9348,7 @@ one is shown, moved onto the button with no wrapper, matching React's
9347
9348
  >{{ nodeText(rightIcon) }}</span
9348
9349
  >`,
9349
9350
  })
9350
- export class OptimisticToggleButton
9351
- implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTMLButtonElement>
9352
- {
9351
+ export class OptimisticToggleButton implements DoCheck, OnDestroy, HasElement<HTMLButtonElement> {
9353
9352
  /** The loaded server value. */
9354
9353
  value: OptimisticToggleButtonProps['value'] = false
9355
9354
  /** Saves the desired boolean and returns the server-confirmed boolean. */
@@ -9358,6 +9357,7 @@ export class OptimisticToggleButton
9358
9357
  activeLabel!: OptimisticToggleButtonProps['activeLabel']
9359
9358
  /** Label when the displayed value is false (node-valued prop). */
9360
9359
  inactiveLabel!: OptimisticToggleButtonProps['inactiveLabel']
9360
+ /** Receives a failed save after the controller has restored the last confirmed value. */
9361
9361
  onError?: OptimisticToggleButtonProps['onError']
9362
9362
  /** Button variant. */
9363
9363
  variant?: OptimisticToggleButtonProps['variant']
@@ -9379,7 +9379,9 @@ export class OptimisticToggleButton
9379
9379
  testId?: OptimisticToggleButtonProps['testId']
9380
9380
  /** Disables the button (permissions, never a pending save). */
9381
9381
  disabled?: OptimisticToggleButtonProps['disabled'] = false
9382
+ /** `data-mol-id` automation id (React's `automationId`; default `optimistic-toggle`). */
9382
9383
  automationId?: OptimisticToggleButtonProps['automationId']
9384
+ /** A `data-mol-id` given as a plain rest attribute (React's `rootProps` precedence). */
9383
9385
  dataMolId?: string
9384
9386
 
9385
9387
  /** Template helpers (templates see only class members). */
@@ -9389,6 +9391,7 @@ export class OptimisticToggleButton
9389
9391
 
9390
9392
  /** The optimistic controller. */
9391
9393
  private readonly controller: OptimisticValue<boolean>
9394
+ /** The controller state (a signal so the zoneless view re-checks on every publish). */
9392
9395
  readonly state = signal<OptimisticValueState<boolean>>({
9393
9396
  value: false,
9394
9397
  pending: false,
@@ -9407,15 +9410,12 @@ export class OptimisticToggleButton
9407
9410
  private readonly host: ElementRef<HTMLButtonElement> = inject(ElementRef)
9408
9411
  /** The element a caller's ref receives: the host `<button>`. */
9409
9412
  readonly element = hostElement(this.host)
9410
- private readonly renderer = inject(Renderer2)
9411
- private readonly sync = new SlotWrapper(this.host, this.renderer)
9412
9413
  private unsubscribe?: () => void
9413
9414
  private lastReceived = false
9414
9415
  private hasLeft = false
9415
9416
  private hasRight = false
9416
- private visibleNodes: Node[] = []
9417
+ /** The slot whose content is currently shown on the button. */
9417
9418
  private visibleFrom: HTMLSpanElement | null = null
9418
- private anchor: Comment | null = null
9419
9419
 
9420
9420
  /** Creates the optimistic controller and mirrors its state into the signal. */
9421
9421
  constructor() {
@@ -9426,6 +9426,7 @@ export class OptimisticToggleButton
9426
9426
  })
9427
9427
  this.unsubscribe = this.controller.subscribe((next) => this.state.set({ ...next }))
9428
9428
  this.state.set(this.controller.getState())
9429
+ usePlacement((hasContent) => this.reconcile(hasContent))
9429
9430
  }
9430
9431
 
9431
9432
  /** The current class map. */
@@ -9465,13 +9466,14 @@ export class OptimisticToggleButton
9465
9466
  this.controller.update((current) => !current)
9466
9467
  }
9467
9468
 
9468
- ngAfterViewInit(): void {
9469
- this.hasLeft = hasNodes(this.leftSlot?.nativeElement)
9470
- this.hasRight = hasNodes(this.rightSlot?.nativeElement)
9471
- this.sync.sync(this.activeSlot?.nativeElement, false)
9472
- this.sync.sync(this.inactiveSlot?.nativeElement, false)
9473
- this.sync.sync(this.leftSlot?.nativeElement, this.hasLeft)
9474
- this.sync.sync(this.rightSlot?.nativeElement, this.hasRight)
9469
+ /** Reads slot presence and takes the label capture spans out of the DOM, then shows the visible label. */
9470
+ private reconcile(hasContent: SlotReader): void {
9471
+ this.hasLeft = hasContent(this.leftSlot?.nativeElement)
9472
+ this.hasRight = hasContent(this.rightSlot?.nativeElement)
9473
+ setElementPresent(this.activeSlot?.nativeElement, false)
9474
+ setElementPresent(this.inactiveSlot?.nativeElement, false)
9475
+ setElementPresent(this.leftSlot?.nativeElement, this.hasLeft)
9476
+ setElementPresent(this.rightSlot?.nativeElement, this.hasRight)
9475
9477
  this.syncLabels()
9476
9478
  }
9477
9479
 
@@ -9480,53 +9482,30 @@ export class OptimisticToggleButton
9480
9482
  this.lastReceived = this.value
9481
9483
  this.controller.sync(this.value)
9482
9484
  }
9483
- this.syncLabels()
9484
9485
  }
9485
9486
 
9486
9487
  /** Stops mirroring controller state into the signal (unmount). */
9487
9488
  ngOnDestroy(): void {
9488
9489
  this.unsubscribe?.()
9489
- this.visibleNodes = []
9490
- this.visibleFrom = null
9491
9490
  }
9492
9491
 
9493
9492
  private syncLabels(): void {
9494
9493
  const state = this.controller.getState()
9495
- this.showSlot(
9496
- state.value
9497
- ? (this.activeSlot?.nativeElement ?? null)
9498
- : (this.inactiveSlot?.nativeElement ?? null),
9499
- )
9500
- }
9501
-
9502
- private showSlot(span: HTMLSpanElement | null): void {
9503
- const host = this.host.nativeElement
9504
- if (span === this.visibleFrom) return
9505
- for (const node of this.visibleNodes) {
9506
- if (node.parentNode === host) this.visibleFrom?.appendChild(node)
9507
- }
9508
- this.visibleNodes = []
9509
- this.visibleFrom = null
9510
- if (!span) return
9511
- const nodes = Array.from(span.childNodes)
9512
- for (const node of nodes) host.insertBefore(node, this.labelAnchor())
9513
- this.visibleNodes = nodes
9514
- this.visibleFrom = span
9515
- }
9516
-
9517
- private labelAnchor(): Comment {
9518
- if (this.anchor?.isConnected) return this.anchor
9519
- const anchor = this.renderer.createComment('label') as Comment
9520
- const host = this.host.nativeElement
9521
- const left = this.leftSlot?.nativeElement
9522
- host.insertBefore(anchor, left ? left.nextSibling : host.firstChild)
9523
- this.anchor = anchor
9524
- return anchor
9494
+ const shown = state.value
9495
+ ? (this.activeSlot?.nativeElement ?? null)
9496
+ : (this.inactiveSlot?.nativeElement ?? null)
9497
+ const hidden = state.value
9498
+ ? (this.inactiveSlot?.nativeElement ?? null)
9499
+ : (this.activeSlot?.nativeElement ?? null)
9500
+ if (hidden) placeContent(hidden, null)
9501
+ // The label goes before the right icon's place (its placeholder while the
9502
+ // icon is absent, which placeContent resolves), else at the end.
9503
+ if (shown) placeContent(shown, this.host.nativeElement, this.rightSlot?.nativeElement ?? null)
9525
9504
  }
9526
9505
  }
9527
9506
  ```
9528
9507
 
9529
- _(Member comments are shortened to their first sentence, and the 11 longest are left out to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/optimistic-toggle-button.component.d.ts`.)_
9508
+ _(Member comments are shortened to their first sentence, and the 3 longest are left out to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/optimistic-toggle-button.component.d.ts`.)_
9530
9509
 
9531
9510
  #### `PageHeader`
9532
9511
 
@@ -9542,6 +9521,7 @@ from the DOM — the projected nodes need an always-mounted capture point.
9542
9521
  @Component({
9543
9522
  selector: 'div[mol-page-header]',
9544
9523
  standalone: true,
9524
+ hostDirectives: [MolPlacement],
9545
9525
  inputs: ['title', 'description', 'breadcrumbs', 'className', 'style', 'testId', 'automationId'],
9546
9526
  host: {
9547
9527
  // `title` is this component's heading, which React renders as text; Angular would also keep a
@@ -9578,7 +9558,7 @@ from the DOM — the projected nodes need an always-mounted capture point.
9578
9558
  </div>
9579
9559
  </div>`,
9580
9560
  })
9581
- export class PageHeader implements AfterViewInit, DoCheck, HasElement<HTMLDivElement> {
9561
+ export class PageHeader implements HasElement<HTMLDivElement> {
9582
9562
  /** Page title. */
9583
9563
  title = ''
9584
9564
  /** Page description. */
@@ -9604,12 +9584,15 @@ export class PageHeader implements AfterViewInit, DoCheck, HasElement<HTMLDivEle
9604
9584
  */
9605
9585
  private readonly i18n = useTranslation()
9606
9586
 
9607
- private readonly sync = new SlotWrapper(inject(ElementRef), inject(Renderer2))
9608
9587
  private readonly host: ElementRef<HTMLDivElement> = inject(ElementRef)
9609
9588
  /** The element a caller's ref receives: the host `<div>`. */
9610
9589
  readonly element = hostElement(this.host)
9611
9590
  private hasActions = false
9612
- private actionsParent: HTMLElement | null = null
9591
+
9592
+ /** Applies React's `{actions ? <div>…</div> : null}`. */
9593
+ constructor() {
9594
+ usePlacement((hasContent) => this.syncActions(hasContent))
9595
+ }
9613
9596
 
9614
9597
  /**
9615
9598
  * The current class map.
@@ -9643,31 +9626,14 @@ export class PageHeader implements AfterViewInit, DoCheck, HasElement<HTMLDivEle
9643
9626
  return styleText(this.style)
9644
9627
  }
9645
9628
 
9646
- /**
9647
- * Reads actions presence at view init (view queries resolve only then).
9648
- */
9649
- ngAfterViewInit(): void {
9650
- this.actionsParent = this.actionsSlot?.nativeElement.parentElement ?? null
9651
- this.hasActions = hasNodes(this.actionsSlot?.nativeElement)
9652
- this.syncActions()
9653
- }
9654
-
9655
- /**
9656
- * Re-reconciles the actions wrapper on later passes.
9657
- */
9658
- ngDoCheck(): void {
9659
- this.syncActions()
9660
- }
9661
-
9662
9629
  /**
9663
9630
  * Applies React's `{actions ? <div>…</div> : null}`.
9631
+ *
9632
+ * @param hasContent - Reads whether a slot has content.
9664
9633
  */
9665
- private syncActions(): void {
9666
- this.sync.sync(
9667
- this.actionsSlot?.nativeElement,
9668
- this.hasActions,
9669
- this.actionsParent ?? undefined,
9670
- )
9634
+ private syncActions(hasContent: SlotReader): void {
9635
+ this.hasActions = hasContent(this.actionsSlot?.nativeElement)
9636
+ setElementPresent(this.actionsSlot?.nativeElement, this.hasActions)
9671
9637
  }
9672
9638
  }
9673
9639
  ```
@@ -9690,6 +9656,7 @@ The sidebar toggle button renders only when the caller passed
9690
9656
  @Component({
9691
9657
  selector: 'div[mol-page-shell]',
9692
9658
  standalone: true,
9659
+ hostDirectives: [MolPlacement],
9693
9660
  inputs: ['sidebar', 'topbar', 'sidebarCollapsed', 'className', 'style', 'testId', 'automationId'],
9694
9661
  outputs: ['sidebarToggle'],
9695
9662
  host: {
@@ -9718,7 +9685,7 @@ The sidebar toggle button renders only when the caller passed
9718
9685
  <main [class]="cm().pageShellContent"><ng-content></ng-content></main>
9719
9686
  </div>`,
9720
9687
  })
9721
- export class PageShell implements AfterViewInit, DoCheck, HasElement<HTMLDivElement> {
9688
+ export class PageShell implements HasElement<HTMLDivElement> {
9722
9689
  /** Sidebar content (node-valued prop). */
9723
9690
  sidebar?: unknown
9724
9691
  /** Top bar content (node-valued prop). */
@@ -9749,14 +9716,16 @@ export class PageShell implements AfterViewInit, DoCheck, HasElement<HTMLDivElem
9749
9716
  */
9750
9717
  private readonly i18n = useTranslation()
9751
9718
 
9752
- private readonly sync = new SlotWrapper(inject(ElementRef), inject(Renderer2))
9753
9719
  private readonly host: ElementRef<HTMLDivElement> = inject(ElementRef)
9754
9720
  /** The element a caller's ref receives: the host `<div>`. */
9755
9721
  readonly element = hostElement(this.host)
9756
9722
  private hasSidebar = false
9757
9723
  private hasTopbar = false
9758
- private sidebarParent: HTMLElement | null = null
9759
- private topbarParent: HTMLElement | null = null
9724
+
9725
+ /** Applies React's `{sidebar ? … : null}` / `{topbar ? … : null}`. */
9726
+ constructor() {
9727
+ usePlacement((hasContent) => this.syncWrappers(hasContent))
9728
+ }
9760
9729
 
9761
9730
  /**
9762
9731
  * The current class map.
@@ -9812,34 +9781,16 @@ export class PageShell implements AfterViewInit, DoCheck, HasElement<HTMLDivElem
9812
9781
  return styleText(this.style)
9813
9782
  }
9814
9783
 
9815
- /**
9816
- * Reads slot presence at view init (view queries resolve only then).
9817
- */
9818
- ngAfterViewInit(): void {
9819
- this.sidebarParent = this.sidebarSlot?.nativeElement.parentElement ?? null
9820
- this.topbarParent = this.topbarSlot?.nativeElement.parentElement ?? null
9821
- this.hasSidebar = hasNodes(this.sidebarSlot?.nativeElement)
9822
- this.hasTopbar = hasNodes(this.topbarSlot?.nativeElement)
9823
- this.syncWrappers()
9824
- }
9825
-
9826
- /**
9827
- * Re-reconciles the wrappers on later passes.
9828
- */
9829
- ngDoCheck(): void {
9830
- this.syncWrappers()
9831
- }
9832
-
9833
9784
  /**
9834
9785
  * Applies React's `{sidebar ? … : null}` / `{topbar ? … : null}`.
9786
+ *
9787
+ * @param hasContent - Reads whether a slot has content.
9835
9788
  */
9836
- private syncWrappers(): void {
9837
- this.sync.sync(
9838
- this.sidebarSlot?.nativeElement,
9839
- this.hasSidebar,
9840
- this.sidebarParent ?? undefined,
9841
- )
9842
- this.sync.sync(this.topbarSlot?.nativeElement, this.hasTopbar, this.topbarParent ?? undefined)
9789
+ private syncWrappers(hasContent: SlotReader): void {
9790
+ this.hasSidebar = hasContent(this.sidebarSlot?.nativeElement)
9791
+ this.hasTopbar = hasContent(this.topbarSlot?.nativeElement)
9792
+ setElementPresent(this.sidebarSlot?.nativeElement, this.hasSidebar)
9793
+ setElementPresent(this.topbarSlot?.nativeElement, this.hasTopbar)
9843
9794
  }
9844
9795
  }
9845
9796
  ```
@@ -10159,19 +10110,19 @@ export class Pagination implements HasElement<HTMLElement> {
10159
10110
  Provides the drawer-close callback to descendants.
10160
10111
 
10161
10112
  Rendered internally by `UserMenu` and `SidebarUserCard` around their panel
10162
- content; apps do not normally render it directly. The host is unwrapped
10163
- (`data-parity-unwrap`, React's context provider renders no DOM) and the
10164
- projected children render directly inside it.
10113
+ content; apps do not normally render it directly. React's context provider
10114
+ renders its children and no DOM of its own, so the projected children
10115
+ render in front of the host (`placeContentBefore`) and the host itself
10116
+ leaves the page. The context is registered on the parent element — the one
10117
+ whose child list the content now belongs to — so a consumer in the content
10118
+ still resolves it from its DOM ancestors.
10165
10119
 
10166
10120
  ```typescript
10167
10121
  @Component({
10168
10122
  selector: 'mol-panel-close-provider',
10169
10123
  standalone: true,
10124
+ hostDirectives: [MolPlacement],
10170
10125
  inputs: ['close'],
10171
- host: {
10172
- 'data-parity-unwrap': '',
10173
- style: 'display: contents',
10174
- },
10175
10126
  template: `<ng-content></ng-content>`,
10176
10127
  })
10177
10128
  export class PanelCloseProvider implements OnDestroy {
@@ -10179,14 +10130,22 @@ export class PanelCloseProvider implements OnDestroy {
10179
10130
  close?: PanelCloseProviderProps['close']
10180
10131
 
10181
10132
  private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
10182
- /** Registers the context value on the host (before any projected child resolves it). */
10133
+ /** The value consumers read; its closure keeps the CURRENT `close` prop. */
10134
+ private readonly value = { close: (): void => this.close?.() }
10135
+
10136
+ /** Renders the children in front of the host and registers the context where they render. */
10183
10137
  constructor() {
10184
- provideDomContext(this.host.nativeElement, { close: () => this.close?.() })
10138
+ const host = this.host.nativeElement
10139
+ PanelCloseDomContext.provide(host, this.value)
10140
+ usePlacement(() => {
10141
+ placeContentBefore(host, host)
10142
+ setElementPresent(host, false)
10143
+ })
10185
10144
  }
10186
10145
 
10187
10146
  /** Removes the context registration (unmount). */
10188
10147
  ngOnDestroy(): void {
10189
- removeDomContext(this.host.nativeElement)
10148
+ PanelCloseDomContext.remove(this.host.nativeElement)
10190
10149
  }
10191
10150
  }
10192
10151
  ```
@@ -10383,13 +10342,15 @@ PromptDialog component.
10383
10342
 
10384
10343
  Composed from `Modal`, `Input` and `Button` exactly as React composes
10385
10344
  them. Resolving `onSubmit` closes the dialog and resets it; a rejection
10386
- keeps it open with the value intact. The host is unwrapped
10387
- (`data-parity-unwrap`, React's `Modal` root is a fragment/portal).
10345
+ keeps it open with the value intact. React's root is a `Modal`, which
10346
+ renders a portal while open and nothing while closed, so the host element
10347
+ leaves the page and the portal renders in `document.body`.
10388
10348
 
10389
10349
  ```typescript
10390
10350
  @Component({
10391
10351
  selector: 'mol-prompt-dialog',
10392
10352
  standalone: true,
10353
+ hostDirectives: [MolPlacement],
10393
10354
  imports: [Button, Input, Modal, MolTemplateOutlet],
10394
10355
  inputs: [
10395
10356
  'open',
@@ -10406,20 +10367,17 @@ keeps it open with the value intact. The host is unwrapped
10406
10367
  'cancelMolId',
10407
10368
  ],
10408
10369
  outputs: ['close'],
10409
- host: {
10410
- 'data-parity-unwrap': '',
10411
- style: 'display: contents',
10412
- },
10413
10370
  template: `<mol-modal
10371
+ #modal
10414
10372
  [open]="open"
10415
10373
  (close)="onModalClose()"
10416
- [attr.aria-labelledby]="titleId"
10417
- [attr.aria-describedby]="isGiven(description) ? descriptionId : null"
10374
+ [attr.aria-labelledby]="ariaLabelledBy()"
10375
+ [attr.aria-describedby]="rendersNode(description) ? descriptionId : null"
10418
10376
  ><form (submit)="handleSubmit($event)">
10419
10377
  <div [class]="cm().stack(3)">
10420
10378
  <h2
10421
10379
  #titleSlot
10422
- [attr.id]="titleId"
10380
+ [attr.id]="ariaLabelledBy()"
10423
10381
  [class]="cm().cn(cm().textSize('lg'), cm().fontWeight('bold'))"
10424
10382
  >
10425
10383
  @if (isGiven(title)) {
@@ -10433,7 +10391,7 @@ keeps it open with the value intact. The host is unwrapped
10433
10391
  <p [attr.id]="descriptionId" [class]="cm().textSize('sm')">
10434
10392
  <ng-container [molTemplateOutlet]="descriptionTemplate"></ng-container>
10435
10393
  </p>
10436
- } @else if (isGiven(description)) {
10394
+ } @else if (rendersNode(description)) {
10437
10395
  <p
10438
10396
  [attr.id]="descriptionId"
10439
10397
  [class]="cm().textSize('sm')"
@@ -10489,19 +10447,13 @@ export class PromptDialog implements AfterViewInit, AfterViewChecked, DoCheck {
10489
10447
  open: PromptDialogProps['open'] = false
10490
10448
  /** Dialog heading (node-valued prop). */
10491
10449
  title?: PromptDialogProps['title']
10492
- /** Explanatory line under the title (node-valued prop). */
10493
10450
  description?: PromptDialogProps['description']
10494
10451
  /** Input placeholder. */
10495
10452
  placeholder?: PromptDialogProps['placeholder']
10496
- /** Value the input starts from every time the dialog opens. */
10497
10453
  initialValue?: PromptDialogProps['initialValue'] = ''
10498
- /** Called with the entered value on confirm. */
10499
10454
  onSubmit?: PromptDialogProps['onSubmit']
10500
- /** Confirm-button label (node-valued prop). */
10501
10455
  confirmLabel?: PromptDialogProps['confirmLabel']
10502
- /** Cancel-button label (node-valued prop). */
10503
10456
  cancelLabel?: PromptDialogProps['cancelLabel']
10504
- /** Renders the confirm button in the error color. */
10505
10457
  destructive?: PromptDialogProps['destructive'] = false
10506
10458
  /** `data-mol-id` for the text input. */
10507
10459
  inputMolId?: PromptDialogProps['inputMolId']
@@ -10510,35 +10462,49 @@ export class PromptDialog implements AfterViewInit, AfterViewChecked, DoCheck {
10510
10462
  /** `data-mol-id` for the cancel button. */
10511
10463
  cancelMolId?: PromptDialogProps['cancelMolId']
10512
10464
 
10513
- /** Template helpers (templates see only class members). */
10514
10465
  readonly asTemplate = asTemplate
10515
- /** Renders a plain-string/number node value. */
10516
10466
  readonly nodeText = nodeText
10517
10467
  /** Whether a node-valued prop was given. */
10518
10468
  readonly isGiven = isGiven
10469
+ readonly rendersNode = rendersNode
10519
10470
 
10520
10471
  @Output() readonly close = new EventEmitter<unknown>()
10521
10472
 
10522
10473
  @ViewChild('titleSlot') titleSlot?: ElementRef<HTMLHeadingElement>
10523
10474
  @ViewChild(Input) inputComponent?: Input
10475
+ @ViewChild('modal', { read: ElementRef }) modalElement?: ElementRef<HTMLElement>
10524
10476
 
10525
10477
  readonly titleId = nextInstanceId()
10526
10478
 
10527
10479
  readonly descriptionId = nextInstanceId()
10528
10480
 
10481
+ readonly ariaLabelledBy = signal<string | null>(null)
10482
+
10529
10483
  /** The current input value. */
10530
10484
  readonly value = signal('')
10531
10485
  /** Whether a submit is in flight. */
10532
10486
  readonly pending = signal(false)
10533
10487
 
10534
- /** Reactive translation, read in the injection context. */
10535
10488
  private readonly i18n = useTranslation()
10536
10489
 
10490
+ private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
10491
+
10537
10492
  private lastOpen = false
10538
10493
  private lastInitial = ''
10539
10494
  private pendingInputFocus = false
10540
10495
  private readonly injector = inject(Injector)
10541
10496
 
10497
+ constructor() {
10498
+ usePlacement((hasContent) => {
10499
+ setElementPresent(this.host.nativeElement, false)
10500
+ setHostRoot(this.host.nativeElement, this.modalElement?.nativeElement)
10501
+ this.ariaLabelledBy.set(
10502
+ rendersNode(this.title) || hasContent(this.titleSlot?.nativeElement) ? this.titleId : null,
10503
+ )
10504
+ this.applyInputLabel(hasContent)
10505
+ })
10506
+ }
10507
+
10542
10508
  /** The current class map. */
10543
10509
  cm(): UIClassMap {
10544
10510
  return getClassMap()
@@ -10558,24 +10524,27 @@ export class PromptDialog implements AfterViewInit, AfterViewChecked, DoCheck {
10558
10524
  : this.i18n.t('prompt.confirm', {}, { defaultValue: 'Confirm' })
10559
10525
  }
10560
10526
 
10561
- inputLabel(): string | null {
10562
- const title = this.titleSlot?.nativeElement
10563
- if (title) {
10564
- const hasElement = Array.from(title.childNodes).some((node) => node.nodeType === 1)
10565
- const text = (title.textContent ?? '').trim()
10566
- if (!hasElement && text) return text
10567
- }
10527
+ inputLabel(hasContent: SlotReader): string | null {
10528
+ const heading = this.titleSlot?.nativeElement
10529
+ const nodes = isGiven(this.title)
10530
+ ? Array.from(heading?.childNodes ?? [])
10531
+ : hasContent.nodes(heading)
10532
+ const hasElement = nodes.some((node) => node.nodeType === Node.ELEMENT_NODE)
10533
+ const text = nodes
10534
+ .filter((node) => node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.TEXT_NODE)
10535
+ .map((node) => node.textContent ?? '')
10536
+ .join('')
10537
+ .trim()
10538
+ if (!hasElement && text) return text
10568
10539
  return this.placeholder ?? null
10569
10540
  }
10570
10541
 
10571
10542
  ngAfterViewInit(): void {
10572
- this.applyInputLabel()
10573
10543
  this.lastOpen = !!this.open
10574
10544
  this.lastInitial = this.initialValue ?? ''
10575
10545
  if (this.open) {
10576
10546
  this.value.set(this.initialValue ?? '')
10577
10547
  this.pending.set(false)
10578
- // input — after the Modal has focused the dialog's first control.
10579
10548
  this.pendingInputFocus = true
10580
10549
  }
10581
10550
  }
@@ -10588,7 +10557,6 @@ export class PromptDialog implements AfterViewInit, AfterViewChecked, DoCheck {
10588
10557
 
10589
10558
  ngDoCheck(): void {
10590
10559
  const open = !!this.open
10591
- this.applyInputLabel()
10592
10560
  if (open !== this.lastOpen || (open && this.initialValue !== this.lastInitial)) {
10593
10561
  this.lastOpen = open
10594
10562
  this.lastInitial = this.initialValue ?? ''
@@ -10604,15 +10572,14 @@ export class PromptDialog implements AfterViewInit, AfterViewChecked, DoCheck {
10604
10572
  this.inputComponent?.inputEl?.nativeElement.focus()
10605
10573
  }
10606
10574
 
10607
- private applyInputLabel(): void {
10575
+ private applyInputLabel(hasContent: SlotReader): void {
10608
10576
  const input = this.inputComponent?.inputEl?.nativeElement
10609
10577
  if (!input) return
10610
- const label = this.inputLabel()
10578
+ const label = this.inputLabel(hasContent)
10611
10579
  if (label === null) input.removeAttribute('aria-label')
10612
10580
  else input.setAttribute('aria-label', label)
10613
10581
  }
10614
10582
 
10615
- /** Tracks the typed value (React's controlled `onChange`). */
10616
10583
  onInput(event: Event): void {
10617
10584
  this.value.set((event.target as HTMLInputElement).value)
10618
10585
  }
@@ -10632,15 +10599,13 @@ export class PromptDialog implements AfterViewInit, AfterViewChecked, DoCheck {
10632
10599
  this.close.emit()
10633
10600
  })
10634
10601
  .catch((_error: unknown) => {
10635
- // Deliberate: a rejection keeps the dialog open and the caller owns
10636
- // the error, rendering it through `children`.
10637
10602
  this.pending.set(false)
10638
10603
  })
10639
10604
  }
10640
10605
  }
10641
10606
  ```
10642
10607
 
10643
- _(Member comments are shortened to their first sentence, and the 16 longest are left out to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/prompt-dialog.component.d.ts`.)_
10608
+ _(Member comments are shortened to their first sentence, and the 35 longest are left out to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/prompt-dialog.component.d.ts`.)_
10644
10609
 
10645
10610
  #### `RadioGroup`
10646
10611
 
@@ -10882,7 +10847,7 @@ export class ResponsiveAppShell implements DoCheck, OnDestroy {
10882
10847
 
10883
10848
  /** Registers the shell context on the host before any projected child resolves it. */
10884
10849
  constructor() {
10885
- provideDomContext(this.host.nativeElement, new ShellContextValueImpl(this))
10850
+ ShellDomContext.provide(this.host.nativeElement, new ShellContextValueImpl(this))
10886
10851
  }
10887
10852
 
10888
10853
  /**
@@ -10921,7 +10886,7 @@ export class ResponsiveAppShell implements DoCheck, OnDestroy {
10921
10886
 
10922
10887
  /** Removes the context registration (unmount). */
10923
10888
  ngOnDestroy(): void {
10924
- removeDomContext(this.host.nativeElement)
10889
+ ShellDomContext.remove(this.host.nativeElement)
10925
10890
  }
10926
10891
  }
10927
10892
  ```
@@ -10935,6 +10900,7 @@ Drawer is composed), the brand, and trailing actions.
10935
10900
  @Component({
10936
10901
  selector: 'header[mol-responsive-app-shell-topbar]',
10937
10902
  standalone: true,
10903
+ hostDirectives: [MolPlacement],
10938
10904
  imports: [MolIconSvg, MolTemplateOutlet],
10939
10905
  inputs: ['brand', 'actions', 'mobileOnly', 'className', 'dataMolId', 'testId'],
10940
10906
  host: {
@@ -10972,7 +10938,7 @@ Drawer is composed), the brand, and trailing actions.
10972
10938
  >{{ nodeText(actions) }}
10973
10939
  </div>`,
10974
10940
  })
10975
- export class ResponsiveAppShellTopBar implements OnInit, AfterViewInit, DoCheck {
10941
+ export class ResponsiveAppShellTopBar implements OnInit {
10976
10942
  /** Brand/title node (React's `brand`), rendered after the menu trigger. */
10977
10943
  brand?: ResponsiveAppShellTopBarProps['brand']
10978
10944
  /** Trailing actions node (React's `actions`). */
@@ -11005,32 +10971,38 @@ export class ResponsiveAppShellTopBar implements OnInit, AfterViewInit, DoCheck
11005
10971
  */
11006
10972
  private readonly i18n = useTranslation()
11007
10973
 
11008
- private readonly renderer = inject(Renderer2)
11009
- private readonly sync = new SlotWrapper(this.host, this.renderer)
11010
- private brandParent: HTMLElement | null = null
11011
- private actionsParent: HTMLElement | null = null
11012
10974
  private hasBrand = false
11013
10975
  private hasActions = false
11014
10976
 
11015
10977
  /** Prepares the header's mount condition (React's `mobileOnly`). */
11016
10978
  constructor() {
10979
+ usePlacement((hasContent) => {
10980
+ // Resolve the shell context while the host is still in the page: a mobileOnly header
10981
+ // leaves it on desktop, and its ancestors are the only way to the shell root.
10982
+ void this.shell()
10983
+ this.syncWrappers(hasContent)
10984
+ })
11017
10985
  // Leaves no element in the page while the bar is hidden on desktop (React renders null).
11018
10986
  useHostPresence(() => !(this.mobileOnly && this.shell().isDesktop))
11019
10987
  }
11020
10988
 
11021
10989
  /**
11022
10990
  * The nearest shell context.
11023
- * @returns The context (null outside the shell).
10991
+ * @returns The context (its defaults outside the shell).
11024
10992
  */
11025
10993
  shell(): ShellContextValue {
11026
10994
  // Cached: a detached (mobileOnly) header loses its DOM ancestors, so the
11027
10995
  // lookup must not be repeated after the element leaves the tree.
11028
- this.context ??= contextOrDefault(this.host.nativeElement)
11029
- return this.context
10996
+ return this.readContext() ?? contextOrDefault(null)
11030
10997
  }
11031
10998
 
11032
- /** The resolved shell context. */
11033
- private context: ShellContextValue | null = null
10999
+ /**
11000
+ * Reads the shell context from the host's place in the rendered tree.
11001
+ * @returns The context, or null outside the shell.
11002
+ */
11003
+ private readContext(): ShellContextValue | null {
11004
+ return ShellDomContext.find(this.host.nativeElement) ?? null
11005
+ }
11034
11006
 
11035
11007
  /**
11036
11008
  * The current class map.
@@ -11102,36 +11074,15 @@ export class ResponsiveAppShellTopBar implements OnInit, AfterViewInit, DoCheck
11102
11074
  * Refuses to render outside a shell (React's `useShellContext` throws).
11103
11075
  */
11104
11076
  ngOnInit(): void {
11105
- requireShell(this.host.nativeElement, 'ResponsiveAppShell.TopBar')
11106
- }
11107
-
11108
- /** Reads slot presence and applies the conditional brand/actions wrappers. */
11109
- ngAfterViewInit(): void {
11110
- this.brandParent = this.brandSlot?.nativeElement.parentElement ?? null
11111
- this.actionsParent = this.actionsSlot?.nativeElement.parentElement ?? null
11112
- this.hasBrand = isGiven(this.brand) || hasNodes(this.brandSlot?.nativeElement)
11113
- this.hasActions = isGiven(this.actions) || hasNodes(this.actionsSlot?.nativeElement)
11114
- this.syncWrappers()
11115
- }
11116
-
11117
- /** Re-reconciles the wrappers. */
11118
- ngDoCheck(): void {
11119
- this.hasBrand = isGiven(this.brand) || hasNodes(this.brandSlot?.nativeElement)
11120
- this.hasActions = isGiven(this.actions) || hasNodes(this.actionsSlot?.nativeElement)
11121
- this.syncWrappers()
11077
+ requireShell(this.readContext(), 'ResponsiveAppShell.TopBar')
11122
11078
  }
11123
11079
 
11124
11080
  /** Applies React's conditional brand/actions wrappers. */
11125
- private syncWrappers(): void {
11126
- // While the header is detached (mobileOnly on desktop) every node reads as
11127
- // disconnected; attempting a re-attach would append it in the wrong place.
11128
- if (!this.host.nativeElement.isConnected) return
11129
- this.sync.sync(this.brandSlot?.nativeElement, this.hasBrand, this.brandParent ?? undefined)
11130
- this.sync.sync(
11131
- this.actionsSlot?.nativeElement,
11132
- this.hasActions,
11133
- this.actionsParent ?? undefined,
11134
- )
11081
+ private syncWrappers(hasContent: SlotReader): void {
11082
+ this.hasBrand = isGiven(this.brand) || hasContent(this.brandSlot?.nativeElement)
11083
+ this.hasActions = isGiven(this.actions) || hasContent(this.actionsSlot?.nativeElement)
11084
+ setElementPresent(this.brandSlot?.nativeElement, this.hasBrand)
11085
+ setElementPresent(this.actionsSlot?.nativeElement, this.hasActions)
11135
11086
  }
11136
11087
  }
11137
11088
  ```
@@ -11145,6 +11096,7 @@ the breakpoint (the Drawer carries the nav there).
11145
11096
  @Component({
11146
11097
  selector: 'aside[mol-responsive-app-shell-sidebar]',
11147
11098
  standalone: true,
11099
+ hostDirectives: [MolPlacement],
11148
11100
  imports: [MolTemplateOutlet],
11149
11101
  inputs: ['navLabel', 'footer', 'className', 'dataMolId', 'testId'],
11150
11102
  host: {
@@ -11171,7 +11123,7 @@ the breakpoint (the Drawer carries the nav there).
11171
11123
  ><ng-container [molTemplateOutlet]="asTemplate(footer)"></ng-container>{{ nodeText(footer) }}
11172
11124
  </div>`,
11173
11125
  })
11174
- export class ResponsiveAppShellSidebar implements OnInit, AfterViewInit, DoCheck {
11126
+ export class ResponsiveAppShellSidebar implements OnInit {
11175
11127
  /** Accessible name for the `<nav>` landmark. */
11176
11128
  navLabel?: ResponsiveAppShellSidebarProps['navLabel']
11177
11129
  /** Below-nav content (React's `footer` node value). */
@@ -11200,29 +11152,36 @@ export class ResponsiveAppShellSidebar implements OnInit, AfterViewInit, DoCheck
11200
11152
  */
11201
11153
  private readonly i18n = useTranslation()
11202
11154
 
11203
- private readonly renderer = inject(Renderer2)
11204
- private readonly sync = new SlotWrapper(this.host, this.renderer)
11205
- private footerParent: HTMLElement | null = null
11206
11155
  private hasFooter = false
11207
11156
 
11208
11157
  /** Prepares the aside's mount condition (React's breakpoint check). */
11209
11158
  constructor() {
11159
+ usePlacement((hasContent) => {
11160
+ // Resolve the shell context while the host is still in the page: below the breakpoint
11161
+ // it leaves the page, and its ancestors are the only way to the shell root.
11162
+ void this.shell()
11163
+ this.syncWrapper(hasContent)
11164
+ })
11210
11165
  // Leaves no element in the page below the breakpoint (React renders null).
11211
11166
  useHostPresence(() => this.shell().isDesktop)
11212
11167
  }
11213
11168
 
11214
11169
  /**
11215
11170
  * The nearest shell context.
11216
- * @returns The context (defaults outside the shell).
11171
+ * @returns The context (its defaults outside the shell).
11217
11172
  */
11218
11173
  shell(): ShellContextValue {
11219
11174
  // Cached: a detached (mobile) sidebar loses its DOM ancestors.
11220
- this.context ??= contextOrDefault(this.host.nativeElement)
11221
- return this.context
11175
+ return this.readContext() ?? contextOrDefault(null)
11222
11176
  }
11223
11177
 
11224
- /** The resolved shell context. */
11225
- private context: ShellContextValue | null = null
11178
+ /**
11179
+ * Reads the shell context from the host's place in the rendered tree.
11180
+ * @returns The context, or null outside the shell.
11181
+ */
11182
+ private readContext(): ShellContextValue | null {
11183
+ return ShellDomContext.find(this.host.nativeElement) ?? null
11184
+ }
11226
11185
 
11227
11186
  /**
11228
11187
  * The current class map.
@@ -11271,27 +11230,13 @@ export class ResponsiveAppShellSidebar implements OnInit, AfterViewInit, DoCheck
11271
11230
  * Refuses to render outside a shell (React's `useShellContext` throws).
11272
11231
  */
11273
11232
  ngOnInit(): void {
11274
- requireShell(this.host.nativeElement, 'ResponsiveAppShell.Sidebar')
11275
- }
11276
-
11277
- /** Reads footer presence and applies the conditional footer wrapper. */
11278
- ngAfterViewInit(): void {
11279
- this.footerParent = this.footerSlot?.nativeElement.parentElement ?? null
11280
- this.hasFooter = isGiven(this.footer) || hasNodes(this.footerSlot?.nativeElement)
11281
- this.syncWrapper()
11282
- }
11283
-
11284
- /** Re-reconciles the footer wrapper. */
11285
- ngDoCheck(): void {
11286
- this.hasFooter = isGiven(this.footer) || hasNodes(this.footerSlot?.nativeElement)
11287
- this.syncWrapper()
11233
+ requireShell(this.readContext(), 'ResponsiveAppShell.Sidebar')
11288
11234
  }
11289
11235
 
11290
11236
  /** Applies React's conditional footer wrapper. */
11291
- private syncWrapper(): void {
11292
- // While the aside is detached (mobile) every node reads as disconnected.
11293
- if (!this.host.nativeElement.isConnected) return
11294
- this.sync.sync(this.footerSlot?.nativeElement, this.hasFooter, this.footerParent ?? undefined)
11237
+ private syncWrapper(hasContent: SlotReader): void {
11238
+ this.hasFooter = isGiven(this.footer) || hasContent(this.footerSlot?.nativeElement)
11239
+ setElementPresent(this.footerSlot?.nativeElement, this.hasFooter)
11295
11240
  }
11296
11241
  }
11297
11242
  ```
@@ -11305,6 +11250,7 @@ backdrop, portaled into `document.body`.
11305
11250
  @Component({
11306
11251
  selector: 'mol-responsive-app-shell-drawer',
11307
11252
  standalone: true,
11253
+ hostDirectives: [MolPlacement],
11308
11254
  imports: [MolIconSvg, MolTemplateOutlet],
11309
11255
  inputs: [
11310
11256
  'header',
@@ -11316,11 +11262,6 @@ backdrop, portaled into `document.body`.
11316
11262
  'closeDataMolId',
11317
11263
  'testId',
11318
11264
  ],
11319
- host: {
11320
- 'data-parity-unwrap': '',
11321
- style: 'display: contents',
11322
- '[attr.data-open]': 'shell().drawerOpen ? "true" : null',
11323
- },
11324
11265
  template: `<div #overlay [class]="cm().overlay" aria-hidden="true"></div>
11325
11266
  <div
11326
11267
  #wrapper
@@ -11418,27 +11359,30 @@ export class ResponsiveAppShellDrawer implements OnInit, AfterViewInit, DoCheck,
11418
11359
 
11419
11360
  private readonly i18n = useTranslation()
11420
11361
 
11421
- private readonly renderer = inject(Renderer2)
11422
11362
  private readonly injector = inject(Injector)
11423
11363
  private readonly environmentInjector = inject(EnvironmentInjector)
11424
- private readonly sync = new SlotWrapper(this.host, this.renderer)
11425
11364
  private readonly scrollLock = createScrollLock()
11426
11365
  private hasFooter = false
11427
- private footerParent: HTMLElement | null = null
11428
- private headerParent: HTMLElement | null = null
11429
- private headerRowParent: HTMLElement | null = null
11430
- private attached = false
11431
11366
  private locked = false
11432
11367
  private lastOpen = false
11433
11368
  private previouslyFocused: HTMLElement | null = null
11434
11369
  private listeners: (() => void)[] = []
11435
11370
 
11371
+ constructor() {
11372
+ usePlacement((hasContent) => {
11373
+ void this.shell()
11374
+ this.syncWrappers(hasContent)
11375
+ this.syncOpen()
11376
+ })
11377
+ }
11378
+
11436
11379
  shell(): ShellContextValue {
11437
- this.context ??= contextOrDefault(this.host.nativeElement)
11438
- return this.context
11380
+ return this.readContext() ?? contextOrDefault(null)
11439
11381
  }
11440
11382
 
11441
- private context: ShellContextValue | null = null
11383
+ private readContext(): ShellContextValue | null {
11384
+ return ShellDomContext.find(this.host.nativeElement) ?? null
11385
+ }
11442
11386
 
11443
11387
  cm(): UIClassMap {
11444
11388
  return getClassMap()
@@ -11496,17 +11440,11 @@ export class ResponsiveAppShellDrawer implements OnInit, AfterViewInit, DoCheck,
11496
11440
  }
11497
11441
 
11498
11442
  ngOnInit(): void {
11499
- requireShell(this.host.nativeElement, 'ResponsiveAppShell.Drawer')
11443
+ requireShell(this.readContext(), 'ResponsiveAppShell.Drawer')
11500
11444
  }
11501
11445
 
11502
11446
  ngAfterViewInit(): void {
11503
11447
  this.shell().registerDrawer(true)
11504
- this.headerParent = this.headerSlot?.nativeElement.parentElement ?? null
11505
- this.headerRowParent = this.headerRow?.nativeElement.parentElement ?? null
11506
- this.footerParent = this.footerSlot?.nativeElement.parentElement ?? null
11507
- this.headerPresent.set(isGiven(this.header) || hasNodes(this.headerSlot?.nativeElement))
11508
- this.hasFooter = isGiven(this.footer) || hasNodes(this.footerSlot?.nativeElement)
11509
- this.syncWrappers()
11510
11448
  const open = this.shell().drawerOpen && !this.shell().isDesktop
11511
11449
  this.lastOpen = open
11512
11450
  if (open) this.openPanel()
@@ -11514,9 +11452,6 @@ export class ResponsiveAppShellDrawer implements OnInit, AfterViewInit, DoCheck,
11514
11452
  }
11515
11453
 
11516
11454
  ngDoCheck(): void {
11517
- this.headerPresent.set(isGiven(this.header) || hasNodes(this.headerSlot?.nativeElement))
11518
- this.hasFooter = isGiven(this.footer) || hasNodes(this.footerSlot?.nativeElement)
11519
- this.syncWrappers()
11520
11455
  this.syncOpen()
11521
11456
  }
11522
11457
 
@@ -11535,16 +11470,44 @@ export class ResponsiveAppShellDrawer implements OnInit, AfterViewInit, DoCheck,
11535
11470
  this.scrollLock.unlock()
11536
11471
  this.locked = false
11537
11472
  }
11538
- const host = this.host.nativeElement
11539
- if (this.attached) {
11540
- const overlay = this.overlay?.nativeElement
11541
- const wrapper = this.wrapper?.nativeElement
11542
- if (overlay?.parentNode === document.body) host.appendChild(overlay)
11543
- if (wrapper?.parentNode === document.body) host.appendChild(wrapper)
11544
- this.attached = false
11473
+ }
11474
+
11475
+ private syncWrappers(hasContent: SlotReader): void {
11476
+ this.headerPresent.set(isGiven(this.header) || hasContent(this.headerSlot?.nativeElement))
11477
+ this.hasFooter = isGiven(this.footer) || hasContent(this.footerSlot?.nativeElement)
11478
+ setElementPresent(
11479
+ this.headerRow?.nativeElement,
11480
+ this.headerPresent() || (this.showCloseButton ?? true),
11481
+ )
11482
+ setElementPresent(this.headerSlot?.nativeElement, this.headerPresent())
11483
+ setElementPresent(this.footerSlot?.nativeElement, this.hasFooter)
11484
+ setElementPresent(this.host.nativeElement, false)
11485
+ }
11486
+
11487
+ private syncOpen(): void {
11488
+ const open = this.shell().drawerOpen && !this.shell().isDesktop
11489
+ if (open === this.lastOpen) return
11490
+ this.lastOpen = open
11491
+ if (open) {
11492
+ this.openPanel()
11493
+ } else {
11494
+ this.removeListeners()
11495
+ this.detachPortal()
11496
+ if (this.locked) {
11497
+ this.scrollLock.unlock()
11498
+ this.locked = false
11499
+ }
11500
+ const toRestore = this.previouslyFocused
11501
+ if (toRestore)
11502
+ afterNextRender(
11503
+ () => {
11504
+ if (document.contains(toRestore)) toRestore.focus()
11505
+ },
11506
+ { injector: this.injector },
11507
+ )
11545
11508
  }
11546
11509
  }
11547
- // … truncated — 8 more members: syncWrappers, syncOpen, openPanel, attachPortal, detachPortal, addListeners, removeListeners, handleKeyDown; the full declaration is in node_modules/@molecule/app-ui-angular/dist/components/responsive-app-shell.component.d.ts
11510
+ // … truncated — 6 more members: openPanel, attachPortal, detachPortal, addListeners, removeListeners, handleKeyDown; the full declaration is in node_modules/@molecule/app-ui-angular/dist/components/responsive-app-shell.component.d.ts
11548
11511
  ```
11549
11512
 
11550
11513
  _(Member comments are left out to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/responsive-app-shell.component.d.ts`.)_
@@ -11980,9 +11943,9 @@ export class Separator implements HasElement<HTMLDivElement> {
11980
11943
 
11981
11944
  SidebarUserCard component.
11982
11945
 
11983
- React's root is a FRAGMENT (the trigger button plus a drawer), so the host
11984
- is unwrapped (`data-parity-unwrap`, `display: contents`) and the trigger
11985
- button is adopted beside it. Identity comes from `useAuth()` unless the
11946
+ React's root is a FRAGMENT (the trigger button plus a drawer), so the trigger
11947
+ button renders in front of the host (`placeElementBefore`) and the host
11948
+ itself leaves the DOM. Identity comes from `useAuth()` unless the
11986
11949
  matching props override it.
11987
11950
 
11988
11951
  ```typescript
@@ -11990,6 +11953,7 @@ matching props override it.
11990
11953
  selector: 'mol-sidebar-user-card',
11991
11954
  standalone: true,
11992
11955
  imports: [Modal, PanelCloseProvider],
11956
+ hostDirectives: [MolPlacement],
11993
11957
  inputs: [
11994
11958
  'name',
11995
11959
  'secondaryLine',
@@ -11999,10 +11963,6 @@ matching props override it.
11999
11963
  'dataMolId',
12000
11964
  'className',
12001
11965
  ],
12002
- host: {
12003
- 'data-parity-unwrap': '',
12004
- style: 'display: contents',
12005
- },
12006
11966
  template: `<button
12007
11967
  #trigger
12008
11968
  type="button"
@@ -12033,7 +11993,7 @@ matching props override it.
12033
11993
  ><ng-content></ng-content></mol-panel-close-provider
12034
11994
  ></mol-modal>`,
12035
11995
  })
12036
- export class SidebarUserCard implements AfterViewInit, OnDestroy {
11996
+ export class SidebarUserCard {
12037
11997
  /** Display name override (falls back to the auth user, then the guest label). */
12038
11998
  name?: SidebarUserCardProps['name']
12039
11999
  /** Secondary line under the name (falls back to the auth user's email). */
@@ -12067,8 +12027,15 @@ export class SidebarUserCard implements AfterViewInit, OnDestroy {
12067
12027
  @ViewChild('trigger') trigger?: ElementRef<HTMLButtonElement>
12068
12028
 
12069
12029
  private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
12070
- private adopted = false
12071
- private movedRest = false
12030
+
12031
+ constructor() {
12032
+ usePlacement(() => {
12033
+ const trigger = this.trigger?.nativeElement
12034
+ if (!trigger) return
12035
+ placeElementBefore(trigger, this.host.nativeElement)
12036
+ setElementPresent(this.host.nativeElement, false)
12037
+ })
12038
+ }
12072
12039
  private readonly routeEffect = effect(() => {
12073
12040
  const location = this.router.location()
12074
12041
  void `${location.pathname}${location.search}`
@@ -12208,26 +12175,6 @@ export class SidebarUserCard implements AfterViewInit, OnDestroy {
12208
12175
  closePanel = (): void => {
12209
12176
  this.isOpen.set(false)
12210
12177
  }
12211
-
12212
- /** Adopts the trigger beside the host and moves rest props onto it. */
12213
- ngAfterViewInit(): void {
12214
- const trigger = this.trigger?.nativeElement
12215
- const host = this.host.nativeElement
12216
- if (!trigger) return
12217
- if (host.parentNode) {
12218
- host.parentNode.insertBefore(trigger, host)
12219
- this.adopted = true
12220
- }
12221
- if (!this.movedRest) {
12222
- moveRestAttributes(host, trigger)
12223
- this.movedRest = true
12224
- }
12225
- }
12226
-
12227
- /** Restores the adopted trigger (unmount). */
12228
- ngOnDestroy(): void {
12229
- if (this.adopted) this.host.nativeElement.appendChild(this.trigger?.nativeElement as Node)
12230
- }
12231
12178
  }
12232
12179
  ```
12233
12180
 
@@ -12577,16 +12524,17 @@ export class Spinner implements HasElement<HTMLDivElement> {
12577
12524
 
12578
12525
  Switch component.
12579
12526
 
12580
- React's root is a fragment (hidden native checkbox + label); the host
12581
- element is unwrapped by the DOM normalizer (`data-parity-unwrap`) and
12582
- `display: contents` keeps real layout fragment-like. Clicking the visible
12583
- button clicks the hidden checkbox, whose GENUINE native `change` event is
12527
+ React's root is a fragment (hidden native checkbox + label): both elements
12528
+ render in front of the host, which leaves the page, so the rendered tree is
12529
+ React's — no wrapper element around the pair. Clicking the visible button
12530
+ clicks the hidden checkbox, whose GENUINE native `change` event is
12584
12531
  forwarded as the `change` output.
12585
12532
 
12586
12533
  ```typescript
12587
12534
  @Component({
12588
12535
  selector: 'mol-switch',
12589
12536
  standalone: true,
12537
+ hostDirectives: [MolPlacement],
12590
12538
  imports: [MolControlledChecked],
12591
12539
  inputs: [
12592
12540
  'label',
@@ -12601,10 +12549,6 @@ forwarded as the `change` output.
12601
12549
  'dataMolId: data-mol-id',
12602
12550
  'onClick',
12603
12551
  ],
12604
- host: {
12605
- 'data-parity-unwrap': '',
12606
- style: 'display: contents',
12607
- },
12608
12552
  template: `<input
12609
12553
  type="checkbox"
12610
12554
  [molChecked]="!!checked"
@@ -12688,7 +12632,23 @@ export class Switch implements AfterViewChecked, HasElement<HTMLButtonElement> {
12688
12632
  private hasLabel = false
12689
12633
  /** The `data-mol-id` a caller bound on the host (React spreads it onto the trigger). */
12690
12634
  private externalMolId: string | undefined
12691
- private readonly sync = new SlotWrapper(inject(ElementRef), inject(Renderer2))
12635
+
12636
+ /**
12637
+ * Renders the host's content (the checkbox and the label) in front of the
12638
+ * host, which leaves the page, and applies React's `{!!label && <span>}`
12639
+ * label condition.
12640
+ */
12641
+ constructor() {
12642
+ usePlacement((hasContent) => {
12643
+ const host = this.host.nativeElement
12644
+ placeContentBefore(host, host)
12645
+ setElementPresent(host, false)
12646
+ // React spreads the rest props on the switch button.
12647
+ setHostRoot(host, this.trigger?.nativeElement, { except: ['data-mol-id'] })
12648
+ this.hasLabel = !!this.label || hasContent(this.labelSlot?.nativeElement)
12649
+ setElementPresent(this.labelSlot?.nativeElement, this.hasLabel)
12650
+ })
12651
+ }
12692
12652
 
12693
12653
  /**
12694
12654
  * The current class map.
@@ -12771,8 +12731,7 @@ export class Switch implements AfterViewChecked, HasElement<HTMLButtonElement> {
12771
12731
  }
12772
12732
 
12773
12733
  /**
12774
- * Moves rest attributes onto the button and applies React's
12775
- * `{!!label && <span>}` label condition after queries resolve.
12734
+ * Moves rest attributes onto the button after queries resolve.
12776
12735
  */
12777
12736
  ngAfterViewChecked(): void {
12778
12737
  adoptHostDataMolId(
@@ -12783,13 +12742,6 @@ export class Switch implements AfterViewChecked, HasElement<HTMLButtonElement> {
12783
12742
  },
12784
12743
  () => this.molId(),
12785
12744
  )
12786
- moveRestAttributes(this.host.nativeElement, this.trigger?.nativeElement)
12787
- this.hasLabel = !!this.label || hasNodes(this.labelSlot?.nativeElement)
12788
- this.sync.sync(
12789
- this.labelSlot?.nativeElement,
12790
- this.hasLabel,
12791
- this.labelSlot?.nativeElement.parentElement ?? undefined,
12792
- )
12793
12745
  }
12794
12746
  }
12795
12747
  ```
@@ -12807,6 +12759,7 @@ or plain functions returning text.
12807
12759
  @Component({
12808
12760
  selector: 'div[mol-table]',
12809
12761
  standalone: true,
12762
+ hostDirectives: [MolPlacement],
12810
12763
  imports: [MolIconSvg, MolTemplateOutlet, Spinner],
12811
12764
  inputs: [
12812
12765
  'data',
@@ -12904,9 +12857,7 @@ or plain functions returning text.
12904
12857
  </tbody>
12905
12858
  </table>`,
12906
12859
  })
12907
- export class Table
12908
- implements AfterViewInit, AfterViewChecked, DoCheck, HasElement<HTMLTableElement>
12909
- {
12860
+ export class Table implements AfterViewInit, AfterViewChecked, HasElement<HTMLTableElement> {
12910
12861
  data: Record<string, unknown>[] = []
12911
12862
  columns: TableColumn<Record<string, unknown>>[] = []
12912
12863
  rowKey?: string | ((row: Record<string, unknown>) => string | number)
@@ -12941,13 +12892,13 @@ export class Table
12941
12892
 
12942
12893
  private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
12943
12894
 
12895
+ constructor() {
12896
+ usePlacement((hasContent) => this.reconcile(hasContent))
12897
+ }
12898
+
12944
12899
  private readonly i18n = useTranslation()
12945
12900
 
12946
- private readonly renderer = inject(Renderer2)
12947
- private readonly sync = new SlotWrapper(this.host, this.renderer)
12948
12901
  private externalMolId: string | undefined
12949
- private emptyParent: HTMLElement | null = null
12950
- private adoptedEmpty: Node[] = []
12951
12902
 
12952
12903
  cm(): UIClassMap {
12953
12904
  return getClassMap()
@@ -13051,7 +13002,14 @@ export class Table
13051
13002
  const value = row[column.key as string]
13052
13003
  return value === undefined || value === null ? '' : String(value)
13053
13004
  }
13054
- // … truncated — 5 more members: handleSort, handleRowClick, ngAfterViewInit, ngAfterViewChecked, ngDoCheck; the full declaration is in node_modules/@molecule/app-ui-angular/dist/components/table.component.d.ts
13005
+
13006
+ handleSort(column: TableColumn<Record<string, unknown>>): void {
13007
+ if (!column.sortable || !this.onSort) return
13008
+ const key = column.key as string
13009
+ const currentDirection = this.sort?.key === key ? this.sort.direction : undefined
13010
+ this.onSort(key, currentDirection === 'asc' ? 'desc' : 'asc')
13011
+ }
13012
+ // … truncated — 6 more members: handleRowClick, ngAfterViewInit, ngAfterViewChecked, ngDoCheck, reconcile, placeEmptyContent; the full declaration is in node_modules/@molecule/app-ui-angular/dist/components/table.component.d.ts
13055
13013
  ```
13056
13014
 
13057
13015
  _(Member comments are left out to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/table.component.d.ts`.)_
@@ -13704,6 +13662,7 @@ with the remaining time; the announced role follows `status`
13704
13662
  @Component({
13705
13663
  selector: 'div[mol-toast]',
13706
13664
  standalone: true,
13665
+ hostDirectives: [MolPlacement],
13707
13666
  imports: [MolIconSvg, MolTemplateOutlet],
13708
13667
  inputs: [
13709
13668
  'title',
@@ -13722,6 +13681,7 @@ with the remaining time; the announced role follows `status`
13722
13681
  ],
13723
13682
  outputs: ['dismiss'],
13724
13683
  host: {
13684
+ // static `title="…"` on the host, where the browser shows it as a tooltip.
13725
13685
  '[attr.title]': 'null',
13726
13686
  '[class]': 'classes()',
13727
13687
  '[style]': 'hostStyle()',
@@ -13779,6 +13739,7 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
13779
13739
  style?: Record<string, unknown>
13780
13740
  /** `data-testid`. */
13781
13741
  testId?: string
13742
+ /** Accepted for prop parity; positioning is the container's job. */
13782
13743
  position?: ToastPosition
13783
13744
  /** `data-mol-id` automation id (React's `automationId`). */
13784
13745
  automationId?: string
@@ -13802,20 +13763,16 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
13802
13763
  /** Reactive translation, read in the injection context. */
13803
13764
  private readonly i18n = useTranslation()
13804
13765
 
13805
- private readonly renderer = inject(Renderer2)
13806
13766
  private readonly host: HTMLElement = this.el.nativeElement
13807
- private readonly sync = new SlotWrapper(this.el, this.renderer)
13808
13767
  private remaining: number
13809
13768
  private startedAt: number | null = null
13810
13769
  private timer: ReturnType<typeof setTimeout> | undefined
13811
13770
  private lastDuration: number
13812
- private descriptionParent: HTMLElement | null = null
13813
- private childrenParent: HTMLElement | null = null
13814
13771
  private hasChildren = false
13815
- private adoptedChildren: Node[] = []
13816
13772
 
13817
13773
  /** Prepares the countdown state (the timer starts at view init). */
13818
13774
  constructor() {
13775
+ usePlacement((hasContent) => this.reconcile(hasContent))
13819
13776
  useHostPresence(() => this.visible())
13820
13777
  this.remaining = this.duration
13821
13778
  this.lastDuration = this.duration
@@ -13845,6 +13802,7 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
13845
13802
  return this.automationId ?? this.dataMolId ?? this.host.getAttribute('data-mol-id') ?? undefined
13846
13803
  }
13847
13804
 
13805
+ /** The announced role: assertive for warnings/errors, polite otherwise. */
13848
13806
  role(): 'alert' | 'status' {
13849
13807
  return this.variant() === 'warning' || this.variant() === 'error' ? 'alert' : 'status'
13850
13808
  }
@@ -13875,11 +13833,13 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
13875
13833
  return this.closeLabel ?? this.i18n.t('ui.toast.close', undefined, { defaultValue: 'Close' })
13876
13834
  }
13877
13835
 
13836
+ /** Dismisses the toast and calls the callback (React's `handleDismiss`). */
13878
13837
  handleDismiss(): void {
13879
13838
  this.visible.set(false)
13880
13839
  this.dismiss.emit()
13881
13840
  }
13882
13841
 
13842
+ /** Pauses the countdown, keeping the time left (React's `pauseTimer`). */
13883
13843
  pauseTimer(): void {
13884
13844
  if (this.startedAt === null) return
13885
13845
  const elapsed = Date.now() - this.startedAt
@@ -13892,28 +13852,22 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
13892
13852
  }
13893
13853
 
13894
13854
  ngAfterViewInit(): void {
13895
- this.descriptionParent = this.descriptionSlot?.nativeElement.parentElement ?? null
13896
- this.childrenParent = this.childrenSlot?.nativeElement.parentElement ?? null
13897
- this.hasChildren = hasNodes(this.childrenSlot?.nativeElement)
13898
- this.adoptChildren()
13899
13855
  this.restart()
13900
13856
  }
13901
13857
 
13902
- /** Re-reconciles children visibility on later passes. */
13903
13858
  ngDoCheck(): void {
13904
13859
  if (this.duration !== this.lastDuration) {
13905
13860
  this.lastDuration = this.duration
13906
13861
  this.restart()
13907
13862
  }
13908
- this.syncDescription()
13909
13863
  }
13910
13864
 
13911
13865
  /** Stops the countdown (React's unmount cleanup). */
13912
13866
  ngOnDestroy(): void {
13913
13867
  this.clearTimer()
13914
- this.adoptedChildren = []
13915
13868
  }
13916
13869
 
13870
+ /** React's effect body: reset the remaining time and start counting. */
13917
13871
  private restart(): void {
13918
13872
  this.remaining = this.duration
13919
13873
  this.startTimer(this.duration)
@@ -13939,50 +13893,51 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
13939
13893
  }, ms)
13940
13894
  }
13941
13895
 
13896
+ private reconcile(hasContent: SlotReader): void {
13897
+ this.hasChildren = hasContent(this.childrenSlot?.nativeElement)
13898
+ this.adoptChildren()
13899
+ }
13900
+
13942
13901
  private adoptChildren(): void {
13943
13902
  const span = this.childrenSlot?.nativeElement
13944
13903
  if (!span) return
13945
13904
  const wrapper = this.descriptionSlot?.nativeElement
13946
13905
  const descWins = this.descriptionText() !== null || this.descriptionTemplate() !== null
13947
- if (wrapper && !descWins && this.hasChildren) {
13948
- this.adoptedChildren = Array.from(span.childNodes)
13949
- for (const node of this.adoptedChildren) wrapper.appendChild(node)
13950
- }
13951
- this.sync.sync(span, false, this.childrenParent ?? undefined)
13906
+ setElementPresent(span, false)
13907
+ if (wrapper && !descWins && this.hasChildren) placeContent(span, wrapper)
13908
+ else placeContent(span, null)
13952
13909
  this.syncDescription()
13953
13910
  }
13954
13911
 
13912
+ /** Applies React's `{!!(description || children) && <div>…</div>}`. */
13955
13913
  private syncDescription(): void {
13956
13914
  const wrapper = this.descriptionSlot?.nativeElement
13957
13915
  if (!wrapper) return
13958
13916
  const hasDescription = this.descriptionText() !== null || this.descriptionTemplate() !== null
13959
- this.sync.sync(wrapper, hasDescription || this.hasChildren, this.descriptionParent ?? undefined)
13917
+ setElementPresent(wrapper, hasDescription || this.hasChildren)
13960
13918
  }
13961
13919
  }
13962
13920
  ```
13963
13921
 
13964
- _(Member comments are shortened to their first sentence, and the 18 longest are left out to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/toast.component.d.ts`.)_
13922
+ _(Member comments are shortened to their first sentence, and the 13 longest are left out to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/toast.component.d.ts`.)_
13965
13923
 
13966
13924
  #### `ToastContainer`
13967
13925
 
13968
13926
  Toast container: positions toasts on screen via a body portal.
13969
13927
 
13970
- React's root is a portal, so the host is unwrapped
13971
- (`data-parity-unwrap`, `display: contents`) and the container `<div>` is
13972
- moved into `document.body`.
13928
+ React's root is a portal: the container `<div>` is moved into
13929
+ `document.body` and the host element leaves the page, so nothing is left at
13930
+ the component's place.
13973
13931
 
13974
13932
  ```typescript
13975
13933
  @Component({
13976
13934
  selector: 'mol-toast-container',
13977
13935
  standalone: true,
13936
+ hostDirectives: [MolPlacement],
13978
13937
  inputs: ['position', 'className'],
13979
- host: {
13980
- 'data-parity-unwrap': '',
13981
- style: 'display: contents',
13982
- },
13983
13938
  template: `<div #container [class]="classes()"><ng-content></ng-content></div>`,
13984
13939
  })
13985
- export class ToastContainer implements AfterViewInit, OnDestroy, HasElement<HTMLDivElement> {
13940
+ export class ToastContainer implements HasElement<HTMLDivElement> {
13986
13941
  /** The container position (default `bottom-right`). */
13987
13942
  position: ToastPosition = 'bottom-right'
13988
13943
  /** Extra classes. */
@@ -14003,6 +13958,15 @@ export class ToastContainer implements AfterViewInit, OnDestroy, HasElement<HTML
14003
13958
 
14004
13959
  private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
14005
13960
 
13961
+ /** Renders the container in `document.body` (React's portal) and takes the host out of the page. */
13962
+ constructor() {
13963
+ usePlacement(() => {
13964
+ if (typeof document !== 'undefined')
13965
+ placeElement(this.container?.nativeElement, document.body)
13966
+ setElementPresent(this.host.nativeElement, false)
13967
+ })
13968
+ }
13969
+
14006
13970
  /**
14007
13971
  * The current class map.
14008
13972
  * @returns The UIClassMap.
@@ -14018,18 +13982,6 @@ export class ToastContainer implements AfterViewInit, OnDestroy, HasElement<HTML
14018
13982
  classes(): string {
14019
13983
  return this.cm().cn(this.cm().toastContainer({ position: this.position }), this.className)
14020
13984
  }
14021
-
14022
- /** Moves the container to `document.body` (React's portal). */
14023
- ngAfterViewInit(): void {
14024
- const el = this.container?.nativeElement
14025
- if (el && typeof document !== 'undefined') document.body.appendChild(el)
14026
- }
14027
-
14028
- /** Moves the container back under the host so Angular can remove it. */
14029
- ngOnDestroy(): void {
14030
- const el = this.container?.nativeElement
14031
- if (el && this.host.nativeElement.parentNode) this.host.nativeElement.appendChild(el)
14032
- }
14033
13985
  }
14034
13986
  ```
14035
13987
 
@@ -14038,20 +13990,21 @@ export class ToastContainer implements AfterViewInit, OnDestroy, HasElement<HTML
14038
13990
  ToastProvider: manages global toast state and renders children plus a
14039
13991
  positioned toast container (React's context provider + portal).
14040
13992
 
14041
- The context value is registered on the host element (React context flows
13993
+ The context value is registered on a DOM element (React context flows
14042
13994
  through the rendered tree, which Angular DI cannot reach for projected
14043
- content); `useToast()` reads it through the DOM ancestors.
13995
+ content); `useToast()` reads it through the DOM ancestors. React's provider
13996
+ renders its children and the container's portal, no element of its own, so
13997
+ the children render in front of the host and the host leaves the page; the
13998
+ context is registered on the parent element, the one whose child list the
13999
+ children now belong to.
14044
14000
 
14045
14001
  ```typescript
14046
14002
  @Component({
14047
14003
  selector: 'mol-toast-provider',
14048
14004
  standalone: true,
14005
+ hostDirectives: [MolPlacement],
14049
14006
  imports: [Toast],
14050
14007
  inputs: ['position'],
14051
- host: {
14052
- 'data-parity-unwrap': '',
14053
- style: 'display: contents',
14054
- },
14055
14008
  template: `<span #childrenCapture><ng-content></ng-content></span>
14056
14009
  <div #container [class]="containerClasses()">
14057
14010
  @for (toast of toasts(); track toast.id) {
@@ -14073,7 +14026,7 @@ content); `useToast()` reads it through the DOM ancestors.
14073
14026
  }
14074
14027
  </div>`,
14075
14028
  })
14076
- export class ToastProvider implements AfterViewInit, OnDestroy {
14029
+ export class ToastProvider implements OnDestroy {
14077
14030
  /** The default position for toasts (default `bottom-right`). */
14078
14031
  position: ToastPosition = 'bottom-right'
14079
14032
 
@@ -14086,13 +14039,26 @@ export class ToastProvider implements AfterViewInit, OnDestroy {
14086
14039
  readonly toasts = signal<(ToastProps & { id: string })[]>([])
14087
14040
 
14088
14041
  private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
14089
- private readonly renderer = inject(Renderer2)
14090
- private readonly sync = new SlotWrapper(this.host, this.renderer)
14091
- private adopted: Node[] = []
14042
+ /** The value consumers read; its closures keep the live toast state. */
14043
+ private readonly value = new ToastContextImplementation(this)
14092
14044
 
14093
- /** Registers the toast context on the host (before any projected child resolves it). */
14045
+ /**
14046
+ * Renders the children in front of the host (which leaves the page),
14047
+ * registers the context where they render, and portals the container.
14048
+ */
14094
14049
  constructor() {
14095
- provideDomContext(this.host.nativeElement, new ToastContextImplementation(this))
14050
+ ToastDomContext.provide(this.host.nativeElement, this.value)
14051
+ usePlacement(() => {
14052
+ const capture = this.childrenCapture?.nativeElement
14053
+ const host = this.host.nativeElement
14054
+ if (capture) {
14055
+ placeContentBefore(capture, host)
14056
+ setElementPresent(capture, false)
14057
+ }
14058
+ setElementPresent(host, false)
14059
+ if (typeof document !== 'undefined')
14060
+ placeElement(this.container?.nativeElement, document.body)
14061
+ })
14096
14062
  }
14097
14063
 
14098
14064
  /**
@@ -14131,29 +14097,9 @@ export class ToastProvider implements AfterViewInit, OnDestroy {
14131
14097
  this.toasts.update((prev) => prev.filter((toast) => toast.id !== id))
14132
14098
  }
14133
14099
 
14134
- /**
14135
- * Adopts the children bare into the host and moves the container to
14136
- * `document.body` (React's portal).
14137
- */
14138
- ngAfterViewInit(): void {
14139
- const capture = this.childrenCapture?.nativeElement
14140
- const host = this.host.nativeElement
14141
- if (capture) {
14142
- this.adopted = Array.from(capture.childNodes)
14143
- for (const node of this.adopted) host.appendChild(node)
14144
- this.sync.sync(capture, false, host)
14145
- }
14146
- const container = this.container?.nativeElement
14147
- if (container && typeof document !== 'undefined') document.body.appendChild(container)
14148
- }
14149
-
14150
- /** Removes the context registration and restores the container (unmount). */
14100
+ /** Removes the context registration (unmount). */
14151
14101
  ngOnDestroy(): void {
14152
- removeDomContext(this.host.nativeElement)
14153
- const container = this.container?.nativeElement
14154
- if (container && this.host.nativeElement.parentNode)
14155
- this.host.nativeElement.appendChild(container)
14156
- this.adopted = []
14102
+ ToastDomContext.remove(this.host.nativeElement)
14157
14103
  }
14158
14104
  }
14159
14105
  ```
@@ -14163,10 +14109,10 @@ export class ToastProvider implements AfterViewInit, OnDestroy {
14163
14109
  Tooltip component.
14164
14110
 
14165
14111
  React's root is a FRAGMENT (a trigger wrapper `<div>` plus a portal), so
14166
- the host is unwrapped (`data-parity-unwrap`, `display: contents`); the
14167
- wrapper is adopted beside the host (so the rendered tree and focus paths
14168
- match React's) and the portal element is moved into `document.body` while
14169
- visible. A single-element trigger receives `aria-describedby` while the
14112
+ the trigger wrapper renders in front of the host (`placeElementBefore`),
14113
+ the host itself leaves the DOM, and the portal element renders in
14114
+ `document.body` while visible: the rendered tree and focus paths are
14115
+ React's. A single-element trigger receives `aria-describedby` while the
14170
14116
  tooltip shows; show/hide are coordinated across instances exactly like
14171
14117
  React's module-level `activeTooltips` map.
14172
14118
 
@@ -14174,6 +14120,7 @@ React's module-level `activeTooltips` map.
14174
14120
  @Component({
14175
14121
  selector: 'mol-tooltip',
14176
14122
  standalone: true,
14123
+ hostDirectives: [MolPlacement],
14177
14124
  inputs: [
14178
14125
  'content',
14179
14126
  'placement',
@@ -14188,10 +14135,6 @@ React's module-level `activeTooltips` map.
14188
14135
  'title',
14189
14136
  'onDoubleClick',
14190
14137
  ],
14191
- host: {
14192
- 'data-parity-unwrap': '',
14193
- style: 'display: contents',
14194
- },
14195
14138
  template: `<div
14196
14139
  #triggerWrap
14197
14140
  [class]="cm().tooltipTrigger"
@@ -14269,16 +14212,35 @@ export class Tooltip
14269
14212
  if (event.key === 'Escape') this.hide()
14270
14213
  }
14271
14214
  private escapeBound = false
14272
- private attached = false
14273
14215
  private lastVisible = false
14274
14216
  private lastContentText: string | null = null
14275
14217
  private lastPlacement: TooltipPlacement | null = null
14276
14218
  private associateEl: HTMLElement | null = null
14277
- private hostParent: Node | null = null
14278
14219
  private externalMolId: string | undefined
14279
14220
 
14280
14221
  constructor() {
14281
14222
  afterEveryRender(() => this.repositionForContentChange())
14223
+ usePlacement((hasContent) => {
14224
+ const wrap = this.triggerWrap?.nativeElement
14225
+ const capture = this.childrenCapture?.nativeElement
14226
+ if (!wrap || !capture) return
14227
+ placeElementBefore(wrap, this.host.nativeElement)
14228
+ setElementPresent(this.host.nativeElement, false)
14229
+ setHostRoot(this.host.nativeElement, this.contentEl?.nativeElement, {
14230
+ except: ['data-mol-id'],
14231
+ })
14232
+ placeContent(capture, wrap)
14233
+ setElementPresent(capture, false)
14234
+ const children = hasContent.nodes(capture)
14235
+ const only =
14236
+ children.length === 1 && children[0].nodeType === 1 ? (children[0] as HTMLElement) : null
14237
+ if (only === this.associateEl) return
14238
+ if (this.visible()) {
14239
+ this.associateEl?.removeAttribute('aria-describedby')
14240
+ only?.setAttribute('aria-describedby', this.boxId())
14241
+ }
14242
+ this.associateEl = only
14243
+ })
14282
14244
  }
14283
14245
 
14284
14246
  private repositionForContentChange(): void {
@@ -14366,25 +14328,7 @@ export class Tooltip
14366
14328
  }
14367
14329
 
14368
14330
  ngAfterViewInit(): void {
14369
- const wrap = this.triggerWrap?.nativeElement
14370
- const host = this.host.nativeElement
14371
- const capture = this.childrenCapture?.nativeElement
14372
- this.hostParent = host.parentNode
14373
- if (wrap) {
14374
- this.hostParent?.insertBefore(wrap, host)
14375
- }
14376
- if (capture && wrap) {
14377
- const children = Array.from(capture.childNodes)
14378
- for (const node of children) wrap.appendChild(node)
14379
- const elements = children.filter((node) => node.nodeType === 1)
14380
- const hasText = children.some(
14381
- (node) => node.nodeType === 3 && (node.textContent ?? '').trim(),
14382
- )
14383
- this.associateEl = elements.length === 1 && !hasText ? (elements[0] as HTMLElement) : null
14384
- capture.remove()
14385
- }
14386
- this.portalWrap?.nativeElement.remove()
14387
- this.attached = false
14331
+ setElementPresent(this.portalWrap?.nativeElement, false)
14388
14332
  this.lastVisible = false
14389
14333
  }
14390
14334
 
@@ -14422,20 +14366,14 @@ export class Tooltip
14422
14366
  activeTooltips.delete(document)
14423
14367
  }
14424
14368
  if (this.escapeBound) document.removeEventListener('keydown', this.escapeListener)
14425
- const host = this.host.nativeElement
14426
- const wrap = this.triggerWrap?.nativeElement
14427
- if (wrap && wrap.parentElement !== host) host.appendChild(wrap)
14428
- const portal = this.portalWrap?.nativeElement
14429
- if (portal && portal.parentElement !== host) host.appendChild(portal)
14430
14369
  this.associateEl = null
14431
14370
  }
14432
14371
 
14433
14372
  private attachPortal(): void {
14434
14373
  const portal = this.portalWrap?.nativeElement
14435
14374
  if (!portal) return
14436
- document.body.appendChild(portal)
14375
+ placeElement(portal, document.body)
14437
14376
  this.inner.set(this.contentEl?.nativeElement ?? null)
14438
- this.attached = true
14439
14377
  this.updatePosition()
14440
14378
  this.associateEl?.setAttribute('aria-describedby', this.boxId())
14441
14379
  if (!this.escapeBound) {
@@ -14506,7 +14444,7 @@ export class UserMenuPopover implements AfterViewInit, DoCheck, OnDestroy {
14506
14444
 
14507
14445
  /** Registers the context on the host before any projected child resolves it. */
14508
14446
  constructor() {
14509
- provideDomContext(this.host.nativeElement, new UserMenuPopoverContextValue(this))
14447
+ PopoverDomContext.provide(this.host.nativeElement, new UserMenuPopoverContextValue(this))
14510
14448
  }
14511
14449
 
14512
14450
  /**
@@ -14564,7 +14502,7 @@ export class UserMenuPopover implements AfterViewInit, DoCheck, OnDestroy {
14564
14502
  /** Removes listeners and the context registration (unmount). */
14565
14503
  ngOnDestroy(): void {
14566
14504
  this.removeDocumentListeners()
14567
- removeDomContext(this.host.nativeElement)
14505
+ PopoverDomContext.remove(this.host.nativeElement)
14568
14506
  }
14569
14507
 
14570
14508
  /** Adds the outside-click and Escape dismiss listeners while open. */
@@ -14662,7 +14600,7 @@ export class UserMenuPopoverTrigger {
14662
14600
  * @returns The context, or null outside a popover.
14663
14601
  */
14664
14602
  context(): UserMenuPopoverContext | null {
14665
- return findDomContext<UserMenuPopoverContext>(this.host.nativeElement) ?? null
14603
+ return PopoverDomContext.find(this.host.nativeElement) ?? null
14666
14604
  }
14667
14605
 
14668
14606
  /**
@@ -14770,7 +14708,9 @@ export class UserMenuPopoverTrigger {
14770
14708
  #### `UserMenuPopoverPanel`
14771
14709
 
14772
14710
  The popover panel: an absolutely-positioned card with an identity header
14773
- and a `<nav>` wrapping the caller's items. Renders nothing while closed.
14711
+ and a `<nav>` wrapping the caller's items. The host element is the card
14712
+ (React's one `<div>`), and it is out of the DOM while the popover is closed
14713
+ (React renders `null`).
14774
14714
 
14775
14715
  ```typescript
14776
14716
  @Component({
@@ -14778,12 +14718,11 @@ and a `<nav>` wrapping the caller's items. Renders nothing while closed.
14778
14718
  standalone: true,
14779
14719
  inputs: ['ariaLabelKey', 'ariaLabelDefault', 'dataMolId', 'className'],
14780
14720
  host: {
14781
- 'data-parity-unwrap': '',
14782
- '[attr.data-open]': 'open() ? "true" : null',
14783
- style: 'display: contents',
14721
+ '[attr.id]': 'panelId()',
14722
+ '[attr.data-mol-id]': 'dataMolId',
14723
+ '[class]': 'classes()',
14784
14724
  },
14785
- template: `<div #panel [id]="panelId()" [attr.data-mol-id]="dataMolId" [class]="classes()">
14786
- <header [class]="cm().cn(cm().sp('pb', 4), cm().userMenuPopoverHeader)">
14725
+ template: `<header [class]="cm().cn(cm().sp('pb', 4), cm().userMenuPopoverHeader)">
14787
14726
  <p [class]="cm().cn(cm().textSize('sm'), cm().fontWeight('semibold'))">{{ displayName() }}</p>
14788
14727
  @if (email(); as accountEmail) {
14789
14728
  <p [class]="cm().cn(cm().textSize('xs'), cm().textMuted)">{{ accountEmail }}</p>
@@ -14791,10 +14730,9 @@ and a `<nav>` wrapping the caller's items. Renders nothing while closed.
14791
14730
  </header>
14792
14731
  <nav [class]="cm().cn(cm().sp('mt', 4), cm().stack(1))" [attr.aria-label]="navLabel()">
14793
14732
  <ng-content></ng-content>
14794
- </nav>
14795
- </div>`,
14733
+ </nav>`,
14796
14734
  })
14797
- export class UserMenuPopoverPanel implements AfterViewInit, DoCheck {
14735
+ export class UserMenuPopoverPanel {
14798
14736
  /** i18n key for the panel's aria-label (default `userMenu.panelLabel`). */
14799
14737
  ariaLabelKey?: UserMenuPopoverPanelProps['ariaLabelKey']
14800
14738
  /** Fallback aria-label (default `Account menu`). */
@@ -14804,9 +14742,6 @@ export class UserMenuPopoverPanel implements AfterViewInit, DoCheck {
14804
14742
  /** Extra classes for the panel. */
14805
14743
  className?: UserMenuPopoverPanelProps['className']
14806
14744
 
14807
- /** The panel element (removed from the DOM while closed). */
14808
- @ViewChild('panel') panel?: ElementRef<HTMLDivElement>
14809
-
14810
14745
  private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
14811
14746
 
14812
14747
  /**
@@ -14816,9 +14751,9 @@ export class UserMenuPopoverPanel implements AfterViewInit, DoCheck {
14816
14751
  */
14817
14752
  private readonly i18n = useTranslation()
14818
14753
 
14819
- private panelParent: Node | null = null
14820
- private panelAnchor: Node | null = null
14821
- private lastOpen = false
14754
+ constructor() {
14755
+ useHostPresence(() => this.open())
14756
+ }
14822
14757
 
14823
14758
  /**
14824
14759
  * The current class map.
@@ -14833,7 +14768,7 @@ export class UserMenuPopoverPanel implements AfterViewInit, DoCheck {
14833
14768
  * @returns The context, or null outside a popover.
14834
14769
  */
14835
14770
  context(): UserMenuPopoverContext | null {
14836
- return findDomContext<UserMenuPopoverContext>(this.host.nativeElement) ?? null
14771
+ return PopoverDomContext.find(this.host.nativeElement) ?? null
14837
14772
  }
14838
14773
 
14839
14774
  /**
@@ -14880,27 +14815,6 @@ export class UserMenuPopoverPanel implements AfterViewInit, DoCheck {
14880
14815
  classes(): string {
14881
14816
  return this.cm().cn(this.cm().userMenuPopoverPanel, this.className)
14882
14817
  }
14883
-
14884
- /** Records where the panel lives and applies the initial open state. */
14885
- ngAfterViewInit(): void {
14886
- const panel = this.panel?.nativeElement
14887
- if (!panel) return
14888
- this.panelParent = panel.parentNode
14889
- this.panelAnchor = panel.nextSibling
14890
- this.lastOpen = this.open()
14891
- if (!this.lastOpen) panel.remove()
14892
- }
14893
-
14894
- /** Attaches or detaches the panel to match the open state (React renders null). */
14895
- ngDoCheck(): void {
14896
- const open = this.open()
14897
- if (open === this.lastOpen) return
14898
- this.lastOpen = open
14899
- const panel = this.panel?.nativeElement
14900
- if (!panel || !this.panelParent) return
14901
- if (open) this.panelParent.insertBefore(panel, this.panelAnchor)
14902
- else panel.remove()
14903
- }
14904
14818
  }
14905
14819
  ```
14906
14820
 
@@ -14956,7 +14870,7 @@ export class UserMenuPopoverSignOut {
14956
14870
  * @returns The context, or null outside a popover.
14957
14871
  */
14958
14872
  context(): UserMenuPopoverContext | null {
14959
- return findDomContext<UserMenuPopoverContext>(this.host.nativeElement) ?? null
14873
+ return PopoverDomContext.find(this.host.nativeElement) ?? null
14960
14874
  }
14961
14875
 
14962
14876
  /**
@@ -15008,9 +14922,9 @@ export class UserMenuPopoverSignOut {
15008
14922
 
15009
14923
  UserMenu component.
15010
14924
 
15011
- React's root is a FRAGMENT (the trigger button plus a drawer), so the host
15012
- is unwrapped (`data-parity-unwrap`, `display: contents`) and the trigger
15013
- button is adopted beside it — the rendered tree and focus paths match
14925
+ React's root is a FRAGMENT (the trigger button plus a drawer), so the trigger
14926
+ button renders in front of the host (`placeElementBefore`) and the host
14927
+ itself leaves the DOM — the rendered tree and focus paths match
15014
14928
  React's (a route change must restore focus to the trigger). The panel
15015
14929
  content is projected inside the drawer through `PanelCloseProvider`.
15016
14930
 
@@ -15019,6 +14933,7 @@ content is projected inside the drawer through `PanelCloseProvider`.
15019
14933
  selector: 'mol-user-menu',
15020
14934
  standalone: true,
15021
14935
  imports: [Button, Icon, Modal, PanelCloseProvider],
14936
+ hostDirectives: [MolPlacement],
15022
14937
  inputs: [
15023
14938
  'ariaLabelKey',
15024
14939
  'ariaLabelDefault',
@@ -15030,10 +14945,6 @@ content is projected inside the drawer through `PanelCloseProvider`.
15030
14945
  'onClick',
15031
14946
  'side',
15032
14947
  ],
15033
- host: {
15034
- 'data-parity-unwrap': '',
15035
- style: 'display: contents',
15036
- },
15037
14948
  template: `<button
15038
14949
  #trigger
15039
14950
  mol-button
@@ -15059,7 +14970,7 @@ content is projected inside the drawer through `PanelCloseProvider`.
15059
14970
  ><ng-content></ng-content></mol-panel-close-provider
15060
14971
  ></mol-modal>`,
15061
14972
  })
15062
- export class UserMenu implements AfterViewInit, OnDestroy {
14973
+ export class UserMenu {
15063
14974
  /** i18n key for the trigger's aria-label (default `userMenu.open`). */
15064
14975
  ariaLabelKey?: UserMenuProps['ariaLabelKey']
15065
14976
  /** Fallback aria-label (default `Open user menu`). */
@@ -15095,7 +15006,15 @@ export class UserMenu implements AfterViewInit, OnDestroy {
15095
15006
  @ViewChild('trigger', { read: ElementRef }) trigger?: ElementRef<HTMLButtonElement>
15096
15007
 
15097
15008
  private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
15098
- private adopted = false
15009
+
15010
+ constructor() {
15011
+ usePlacement(() => {
15012
+ const trigger = this.trigger?.nativeElement
15013
+ if (!trigger) return
15014
+ placeElementBefore(trigger, this.host.nativeElement)
15015
+ setElementPresent(this.host.nativeElement, false)
15016
+ })
15017
+ }
15099
15018
  private readonly routeEffect = effect(() => {
15100
15019
  const location = this.router.location()
15101
15020
  void `${location.pathname}${location.search}`
@@ -15166,21 +15085,6 @@ export class UserMenu implements AfterViewInit, OnDestroy {
15166
15085
  if (this.onClick) (this.onClick as (e: MouseEvent) => void)(event)
15167
15086
  else this.isOpen.set(true)
15168
15087
  }
15169
-
15170
- /** Adopts the trigger beside the host (React's fragment root). */
15171
- ngAfterViewInit(): void {
15172
- const trigger = this.trigger?.nativeElement
15173
- const host = this.host.nativeElement
15174
- if (trigger && host.parentNode) {
15175
- host.parentNode.insertBefore(trigger, host)
15176
- this.adopted = true
15177
- }
15178
- }
15179
-
15180
- /** Restores the adopted trigger (unmount). */
15181
- ngOnDestroy(): void {
15182
- if (this.adopted) this.host.nativeElement.appendChild(this.trigger?.nativeElement as Node)
15183
- }
15184
15088
  }
15185
15089
  ```
15186
15090
 
@@ -15418,9 +15322,14 @@ export class MolIconSvg implements OnChanges {
15418
15322
 
15419
15323
  ### Functions
15420
15324
 
15421
- #### `hasNodes(el)`
15325
+ #### `hasNodes(el)` _(deprecated)_
15422
15326
 
15423
- Whether an ng-content wrapper captured any element or text node.
15327
+ > **Deprecated:** Read the slot with the reader `usePlacement` from `@molecule/app-angular` passes to the placement function.
15328
+
15329
+ Whether an ng-content wrapper captured any element or text node, read from a
15330
+ lifecycle hook, which can lag the content: a hook runs before the consumer's
15331
+ `@if` adds its node, and no hook runs at all when the content comes through an
15332
+ `OnPush` component in between.
15424
15333
 
15425
15334
  ```typescript
15426
15335
  function hasNodes(el: Element | undefined | null): boolean
@@ -15533,9 +15442,25 @@ function useIsDesktop(query?: string): Signal<boolean>
15533
15442
 
15534
15443
  **Returns:** A signal of whether the desktop shell should mount.
15535
15444
 
15536
- #### `provideDomContext(host, value)`
15445
+ #### `createDomContext(name)`
15446
+
15447
+ Creates a context (React's `createContext`).
15537
15448
 
15538
- Registers a context value on a provider's host element.
15449
+ ```typescript
15450
+ function createDomContext<T>(name: string): DomContext<T>
15451
+ ```
15452
+
15453
+ - `name` — The context's name, for debugging.
15454
+
15455
+ **Returns:** The context.
15456
+
15457
+ #### `provideDomContext(host, value)` _(deprecated)_
15458
+
15459
+ > **Deprecated:** Use a context of your own: {@link createDomContext}.
15460
+
15461
+ Registers a value on a provider's host element, in the one context every
15462
+ caller of these three functions shares: a consumer then finds the nearest
15463
+ registration of ANY of them.
15539
15464
 
15540
15465
  ```typescript
15541
15466
  function provideDomContext(host: Element, value: unknown): void
@@ -15544,7 +15469,9 @@ function provideDomContext(host: Element, value: unknown): void
15544
15469
  - `host` — The provider component's host element.
15545
15470
  - `value` — The context value.
15546
15471
 
15547
- #### `removeDomContext(host)`
15472
+ #### `removeDomContext(host)` _(deprecated)_
15473
+
15474
+ > **Deprecated:** Use a context of your own: {@link createDomContext}.
15548
15475
 
15549
15476
  Removes a registration (on provider destroy).
15550
15477
 
@@ -15554,29 +15481,34 @@ function removeDomContext(host: Element): void
15554
15481
 
15555
15482
  - `host` — The provider component's host element.
15556
15483
 
15557
- #### `findDomContext(start)`
15484
+ #### `findDomContext(start)` _(deprecated)_
15558
15485
 
15559
- Finds the nearest enclosing context value for a consumer's element.
15486
+ > **Deprecated:** Use a context of your own: {@link createDomContext}.
15487
+
15488
+ Finds the nearest enclosing value for a consumer's element.
15560
15489
 
15561
15490
  ```typescript
15562
15491
  function findDomContext<T>(start: Element | null): T | undefined
15563
15492
  ```
15564
15493
 
15565
- - `start` — The consumer's element (its own registrations are ignored — a provider's children see the provider, the provider does not see itself).
15494
+ - `start` — The consumer's element (its own registration is ignored).
15566
15495
 
15567
15496
  **Returns:** The nearest registered value, or `undefined` when there is none.
15568
15497
 
15569
- #### `findDomContextIncludingSelf(start)`
15498
+ #### `findDomContextIncludingSelf(start)` _(deprecated)_
15499
+
15500
+ > **Deprecated:** Use a context of your own: {@link createDomContext}. A provider registers on its own host and a consumer looks up from its own host, so no lookup needs to include itself.
15570
15501
 
15571
- Finds the nearest enclosing context INCLUDING the element itself.
15502
+ Finds the value registered on the element itself, or else the nearest
15503
+ enclosing one.
15572
15504
 
15573
15505
  ```typescript
15574
15506
  function findDomContextIncludingSelf<T>(start: Element | null): T | undefined
15575
15507
  ```
15576
15508
 
15577
- - `start` — The element to start from.
15509
+ - `start` — The consumer's element.
15578
15510
 
15579
- **Returns:** The nearest registered value, or `undefined` when there is none.
15511
+ **Returns:** The registered value, or `undefined` when there is none.
15580
15512
 
15581
15513
  #### `hostElement(host)`
15582
15514
 
@@ -15734,6 +15666,19 @@ function isGiven(value: unknown): boolean
15734
15666
 
15735
15667
  **Returns:** True when given.
15736
15668
 
15669
+ #### `rendersNode(value)`
15670
+
15671
+ Whether a node-valued prop renders anything: React's `slot(node) !== undefined` for the values
15672
+ an Angular input carries (not `null`, `undefined`, a boolean or `''`; a template counts).
15673
+
15674
+ ```typescript
15675
+ function rendersNode(value: unknown): boolean
15676
+ ```
15677
+
15678
+ - `value` — The prop value.
15679
+
15680
+ **Returns:** True when it renders something.
15681
+
15737
15682
  #### `shallowEqual(a, b)`
15738
15683
 
15739
15684
  Shallow equality (React's `@molecule/app-state` semantics).
@@ -15803,7 +15748,7 @@ new one. `aria-describedby` is left alone by default: the input family
15803
15748
  captured the host's value once and merges it with the field context's own
15804
15749
  target on its inner binding, so re-moving a re-bound value would erase that
15805
15750
  merge. A component that spreads the attribute onto `...rest` with no merge
15806
- (Modal) passes {@link ReapplyRestAttributesOptions.includeDescribedBy}.
15751
+ passes {@link ReapplyRestAttributesOptions.includeDescribedBy}.
15807
15752
 
15808
15753
  Idempotent: a host with nothing re-bound moves nothing.
15809
15754
 
@@ -15911,6 +15856,14 @@ Elements the WAI-ARIA APG dialog pattern treats as tab-stops for the focus trap.
15911
15856
  const FOCUSABLE_SELECTOR: 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])'
15912
15857
  ```
15913
15858
 
15859
+ #### `FormFieldDomContext`
15860
+
15861
+ The context `FormField` registers on its host.
15862
+
15863
+ ```typescript
15864
+ const FormFieldDomContext: DomContext<FormFieldContext>
15865
+ ```
15866
+
15914
15867
  ## Injection Notes
15915
15868
 
15916
15869
  ### Requirements
@@ -15920,7 +15873,7 @@ Peer dependencies:
15920
15873
  - `@angular/common` ^22.0.0
15921
15874
  - `@angular/core` ^22.0.0
15922
15875
  - `@angular/platform-browser` ^22.0.0
15923
- - `@molecule/app-angular` ^3.12.0
15876
+ - `@molecule/app-angular` ^3.13.0
15924
15877
  - `@molecule/app-i18n` ^1.0.1
15925
15878
  - `@molecule/app-icons` ^1.0.1
15926
15879
  - `@molecule/app-ui` ^1.5.0
@@ -15941,9 +15894,9 @@ Peer dependencies:
15941
15894
  - Components are standalone — add them to the `imports` array of the consuming component or
15942
15895
  route; there is no NgModule.
15943
15896
  - A component's selector names the native element React renders at its root (an attribute
15944
- selector such as `button[mol-button]`), so the host IS the root element. Components whose
15945
- React root is a fragment or portal use an element selector whose host is
15946
- `display: contents`.
15897
+ selector such as `button[mol-button]`), so the host IS the root element. A component whose
15898
+ React root is a fragment or a portal renders its template in the host's place and leaves the
15899
+ page itself, so no wrapper element stands among React's nodes.
15947
15900
  - Hooks (`useToast`, `usePanelClose`, `useIsDesktop`, `useUserMenuPopoverClose`) are called in
15948
15901
  an injection context (a component field initializer or constructor).
15949
15902
  - Every component whose React export forwards a ref implements `HasElement`: take it with a