@molecule/app-ui-angular 1.4.1 → 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.
- package/README.md +989 -1103
- package/dist/components/alert.component.d.ts +11 -16
- package/dist/components/alert.component.d.ts.map +1 -1
- package/dist/components/alert.component.js +22 -51
- package/dist/components/alert.component.js.map +1 -1
- package/dist/components/auth-guard.component.d.ts +36 -28
- package/dist/components/auth-guard.component.d.ts.map +1 -1
- package/dist/components/auth-guard.component.js +59 -67
- package/dist/components/auth-guard.component.js.map +1 -1
- package/dist/components/avatar.component.d.ts +13 -10
- package/dist/components/avatar.component.d.ts.map +1 -1
- package/dist/components/avatar.component.js +27 -25
- package/dist/components/avatar.component.js.map +1 -1
- package/dist/components/button.component.d.ts +26 -30
- package/dist/components/button.component.d.ts.map +1 -1
- package/dist/components/button.component.js +41 -75
- package/dist/components/button.component.js.map +1 -1
- package/dist/components/checkbox.component.d.ts +5 -4
- package/dist/components/checkbox.component.d.ts.map +1 -1
- package/dist/components/checkbox.component.js +14 -9
- package/dist/components/checkbox.component.js.map +1 -1
- package/dist/components/confirm-button.component.d.ts +11 -28
- package/dist/components/confirm-button.component.d.ts.map +1 -1
- package/dist/components/confirm-button.component.js +31 -63
- package/dist/components/confirm-button.component.js.map +1 -1
- package/dist/components/confirm-dialog.component.d.ts +28 -17
- package/dist/components/confirm-dialog.component.d.ts.map +1 -1
- package/dist/components/confirm-dialog.component.js +98 -69
- package/dist/components/confirm-dialog.component.js.map +1 -1
- package/dist/components/dropdown.component.d.ts +29 -16
- package/dist/components/dropdown.component.d.ts.map +1 -1
- package/dist/components/dropdown.component.js +134 -105
- package/dist/components/dropdown.component.js.map +1 -1
- package/dist/components/empty-state.component.d.ts +10 -15
- package/dist/components/empty-state.component.d.ts.map +1 -1
- package/dist/components/empty-state.component.js +23 -27
- package/dist/components/empty-state.component.js.map +1 -1
- package/dist/components/form-field.component.d.ts +26 -11
- package/dist/components/form-field.component.d.ts.map +1 -1
- package/dist/components/form-field.component.js +86 -25
- package/dist/components/form-field.component.js.map +1 -1
- package/dist/components/input.component.d.ts +20 -23
- package/dist/components/input.component.d.ts.map +1 -1
- package/dist/components/input.component.js +45 -54
- package/dist/components/input.component.js.map +1 -1
- package/dist/components/language-picker.component.d.ts +15 -18
- package/dist/components/language-picker.component.d.ts.map +1 -1
- package/dist/components/language-picker.component.js +25 -35
- package/dist/components/language-picker.component.js.map +1 -1
- package/dist/components/load-error-banner.component.d.ts +14 -26
- package/dist/components/load-error-banner.component.d.ts.map +1 -1
- package/dist/components/load-error-banner.component.js +28 -62
- package/dist/components/load-error-banner.component.js.map +1 -1
- package/dist/components/modal.component.d.ts +25 -21
- package/dist/components/modal.component.d.ts.map +1 -1
- package/dist/components/modal.component.js +42 -78
- package/dist/components/modal.component.js.map +1 -1
- package/dist/components/molecule/button.component.d.ts +13 -2
- package/dist/components/molecule/button.component.d.ts.map +1 -1
- package/dist/components/molecule/button.component.js +45 -15
- package/dist/components/molecule/button.component.js.map +1 -1
- package/dist/components/molecule/toast.component.d.ts +2 -1
- package/dist/components/molecule/toast.component.d.ts.map +1 -1
- package/dist/components/molecule/toast.component.js +9 -7
- package/dist/components/molecule/toast.component.js.map +1 -1
- package/dist/components/molecule/tooltip.component.d.ts +4 -2
- package/dist/components/molecule/tooltip.component.d.ts.map +1 -1
- package/dist/components/molecule/tooltip.component.js +19 -14
- package/dist/components/molecule/tooltip.component.js.map +1 -1
- package/dist/components/optimistic-toggle-button.component.d.ts +13 -25
- package/dist/components/optimistic-toggle-button.component.d.ts.map +1 -1
- package/dist/components/optimistic-toggle-button.component.js +33 -63
- package/dist/components/optimistic-toggle-button.component.js.map +1 -1
- package/dist/components/page-header.component.d.ts +8 -13
- package/dist/components/page-header.component.d.ts.map +1 -1
- package/dist/components/page-header.component.js +16 -24
- package/dist/components/page-header.component.js.map +1 -1
- package/dist/components/page-shell.component.d.ts +8 -14
- package/dist/components/page-shell.component.d.ts.map +1 -1
- package/dist/components/page-shell.component.js +18 -28
- package/dist/components/page-shell.component.js.map +1 -1
- package/dist/components/panel-close.component.d.ts +14 -8
- package/dist/components/panel-close.component.d.ts.map +1 -1
- package/dist/components/panel-close.component.js +28 -17
- package/dist/components/panel-close.component.js.map +1 -1
- package/dist/components/prompt-dialog.component.d.ts +32 -10
- package/dist/components/prompt-dialog.component.d.ts.map +1 -1
- package/dist/components/prompt-dialog.component.js +110 -73
- package/dist/components/prompt-dialog.component.js.map +1 -1
- package/dist/components/responsive-app-shell.component.d.ts +38 -57
- package/dist/components/responsive-app-shell.component.d.ts.map +1 -1
- package/dist/components/responsive-app-shell.component.js +138 -213
- package/dist/components/responsive-app-shell.component.js.map +1 -1
- package/dist/components/sidebar-user-card.component.d.ts +8 -12
- package/dist/components/sidebar-user-card.component.d.ts.map +1 -1
- package/dist/components/sidebar-user-card.component.js +19 -35
- package/dist/components/sidebar-user-card.component.js.map +1 -1
- package/dist/components/switch.component.d.ts +13 -8
- package/dist/components/switch.component.d.ts.map +1 -1
- package/dist/components/switch.component.js +29 -20
- package/dist/components/switch.component.js.map +1 -1
- package/dist/components/table.component.d.ts +22 -14
- package/dist/components/table.component.d.ts.map +1 -1
- package/dist/components/table.component.js +34 -32
- package/dist/components/table.component.js.map +1 -1
- package/dist/components/toast.component.d.ts +34 -37
- package/dist/components/toast.component.d.ts.map +1 -1
- package/dist/components/toast.component.js +76 -112
- package/dist/components/toast.component.js.map +1 -1
- package/dist/components/tooltip.component.d.ts +14 -11
- package/dist/components/tooltip.component.d.ts.map +1 -1
- package/dist/components/tooltip.component.js +47 -47
- package/dist/components/tooltip.component.js.map +1 -1
- package/dist/components/user-menu-popover.component.d.ts +6 -12
- package/dist/components/user-menu-popover.component.d.ts.map +1 -1
- package/dist/components/user-menu-popover.component.js +40 -77
- package/dist/components/user-menu-popover.component.js.map +1 -1
- package/dist/components/user-menu.component.d.ts +8 -11
- package/dist/components/user-menu.component.d.ts.map +1 -1
- package/dist/components/user-menu.component.js +19 -27
- package/dist/components/user-menu.component.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/utilities/dom-context.d.ts +62 -15
- package/dist/utilities/dom-context.d.ts.map +1 -1
- package/dist/utilities/dom-context.js +79 -34
- package/dist/utilities/dom-context.js.map +1 -1
- package/dist/utilities/form-field-context.d.ts +2 -0
- package/dist/utilities/form-field-context.d.ts.map +1 -1
- package/dist/utilities/form-field-context.js +4 -2
- package/dist/utilities/form-field-context.js.map +1 -1
- package/dist/utilities/node-value.d.ts +8 -0
- package/dist/utilities/node-value.d.ts.map +1 -1
- package/dist/utilities/node-value.js +10 -0
- package/dist/utilities/node-value.js.map +1 -1
- package/dist/utilities/rest-attrs.d.ts +2 -2
- package/dist/utilities/rest-attrs.js +1 -1
- 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-
|
|
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.
|
|
17
|
-
|
|
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
|
|
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
|
|
2845
|
-
React would not render them (
|
|
2846
|
-
|
|
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
|
|
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.
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
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).
|
|
3083
|
-
(
|
|
3084
|
-
|
|
3085
|
-
children, so a guard wrapping the whole route
|
|
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
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
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
|
|
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 (
|
|
3156
|
+
/** The `loadingFallback` slot capture (its content renders in its own place). */
|
|
3142
3157
|
@ViewChild('fallbackWrap') fallbackWrap?: ElementRef<HTMLSpanElement>
|
|
3143
|
-
/** The children capture
|
|
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 (
|
|
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
|
-
*
|
|
3190
|
-
*
|
|
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
|
-
|
|
3193
|
-
|
|
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
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
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.
|
|
3257
|
-
this.
|
|
3258
|
-
this.
|
|
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
|
-
|
|
3286
|
-
is
|
|
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
|
|
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`)
|
|
3451
|
-
*
|
|
3452
|
-
*
|
|
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
|
-
|
|
3470
|
+
private reconcile(hasContent: SlotReader): void {
|
|
3455
3471
|
const fallbackHost = this.fallbackEl?.nativeElement
|
|
3456
3472
|
if (!fallbackHost) return
|
|
3457
|
-
const projected =
|
|
3458
|
-
|
|
3459
|
-
|
|
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
|
|
3570
|
-
|
|
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
|
-
|
|
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
|
|
3585
|
-
* @param
|
|
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
|
|
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
|
|
3598
|
-
*/
|
|
3599
|
-
sync(el: Element | undefined | null, shouldAttach: boolean,
|
|
3600
|
-
|
|
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
|
|
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
|
-
|
|
3773
|
-
|
|
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.
|
|
3796
|
-
this.
|
|
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
|
-
/**
|
|
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)
|
|
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
|
|
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
|
-
|
|
4511
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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.
|
|
4670
|
-
|
|
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]="
|
|
4687
|
-
[attr.aria-describedby]="ariaDescribedBy"
|
|
4650
|
+
[attr.aria-labelledby]="ariaLabelledBy()"
|
|
4651
|
+
[attr.aria-describedby]="ariaDescribedBy()"
|
|
4688
4652
|
><div [class]="cm().stack(3)">
|
|
4689
|
-
<h2
|
|
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
|
|
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>`
|
|
4733
|
-
*
|
|
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
|
|
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
|
|
4800
|
-
*
|
|
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
|
|
4772
|
+
readonly ariaDescribedBy = signal<string | null>(null)
|
|
4804
4773
|
|
|
4805
4774
|
/**
|
|
4806
|
-
*
|
|
4807
|
-
*
|
|
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
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
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
|
|
4854
|
-
|
|
4855
|
-
|
|
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
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
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 —
|
|
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
|
|
5190
|
-
(
|
|
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
|
|
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
|
-
*
|
|
5283
|
-
*
|
|
5280
|
+
* Applies React's `{icon && <div>…}` / `{action && <div>…}` conditions.
|
|
5281
|
+
*
|
|
5282
|
+
* @param hasContent - Reads whether a slot has content.
|
|
5284
5283
|
*/
|
|
5285
|
-
|
|
5284
|
+
private syncWrappers(hasContent: SlotReader): void {
|
|
5286
5285
|
this.hasIcon =
|
|
5287
|
-
this.icon !== undefined && this.icon !== null
|
|
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
|
-
:
|
|
5292
|
-
this.
|
|
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
|
|
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
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
6118
|
-
DOM whenever React would render nothing (
|
|
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,
|
|
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
|
-
|
|
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
|
|
6412
|
-
|
|
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
|
|
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
|
-
|
|
6526
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
7210
|
-
|
|
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
|
-
*
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
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
|
-
|
|
7279
|
-
|
|
7280
|
-
this.
|
|
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
|
-
|
|
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) ||
|
|
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
|
-
|
|
7302
|
+
placeContent(span, null)
|
|
7308
7303
|
return
|
|
7309
7304
|
}
|
|
7310
|
-
|
|
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
|
|
7345
|
-
|
|
7346
|
-
|
|
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
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
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
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
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()
|
|
7588
|
+
}
|
|
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
|
+
)
|
|
7626
7600
|
}
|
|
7627
|
-
// … truncated —
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
9164
|
-
|
|
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
|
|
9198
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
9469
|
-
|
|
9470
|
-
this.
|
|
9471
|
-
this.
|
|
9472
|
-
|
|
9473
|
-
|
|
9474
|
-
|
|
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
|
-
|
|
9496
|
-
|
|
9497
|
-
|
|
9498
|
-
|
|
9499
|
-
|
|
9500
|
-
|
|
9501
|
-
|
|
9502
|
-
|
|
9503
|
-
|
|
9504
|
-
if (
|
|
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
|
|
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
|
|
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
|
-
|
|
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.
|
|
9667
|
-
|
|
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
|
|
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
|
-
|
|
9759
|
-
|
|
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.
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
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.
|
|
10163
|
-
|
|
10164
|
-
|
|
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
|
-
/**
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
10387
|
-
|
|
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]="
|
|
10417
|
-
[attr.aria-describedby]="
|
|
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]="
|
|
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 (
|
|
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
|
|
10563
|
-
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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,28 +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
|
-
|
|
11015
|
-
|
|
10976
|
+
|
|
10977
|
+
/** Prepares the header's mount condition (React's `mobileOnly`). */
|
|
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
|
+
})
|
|
10985
|
+
// Leaves no element in the page while the bar is hidden on desktop (React renders null).
|
|
10986
|
+
useHostPresence(() => !(this.mobileOnly && this.shell().isDesktop))
|
|
10987
|
+
}
|
|
11016
10988
|
|
|
11017
10989
|
/**
|
|
11018
10990
|
* The nearest shell context.
|
|
11019
|
-
* @returns The context (
|
|
10991
|
+
* @returns The context (its defaults outside the shell).
|
|
11020
10992
|
*/
|
|
11021
10993
|
shell(): ShellContextValue {
|
|
11022
10994
|
// Cached: a detached (mobileOnly) header loses its DOM ancestors, so the
|
|
11023
10995
|
// lookup must not be repeated after the element leaves the tree.
|
|
11024
|
-
this.
|
|
11025
|
-
return this.context
|
|
10996
|
+
return this.readContext() ?? contextOrDefault(null)
|
|
11026
10997
|
}
|
|
11027
10998
|
|
|
11028
|
-
/**
|
|
11029
|
-
|
|
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
|
+
}
|
|
11030
11006
|
|
|
11031
11007
|
/**
|
|
11032
11008
|
* The current class map.
|
|
@@ -11098,68 +11074,15 @@ export class ResponsiveAppShellTopBar implements OnInit, AfterViewInit, DoCheck,
|
|
|
11098
11074
|
* Refuses to render outside a shell (React's `useShellContext` throws).
|
|
11099
11075
|
*/
|
|
11100
11076
|
ngOnInit(): void {
|
|
11101
|
-
requireShell(this.
|
|
11102
|
-
}
|
|
11103
|
-
|
|
11104
|
-
/** Reads slot presence and applies the `mobileOnly` mount condition. */
|
|
11105
|
-
ngAfterViewInit(): void {
|
|
11106
|
-
this.brandParent = this.brandSlot?.nativeElement.parentElement ?? null
|
|
11107
|
-
this.actionsParent = this.actionsSlot?.nativeElement.parentElement ?? null
|
|
11108
|
-
this.hasBrand = isGiven(this.brand) || hasNodes(this.brandSlot?.nativeElement)
|
|
11109
|
-
this.hasActions = isGiven(this.actions) || hasNodes(this.actionsSlot?.nativeElement)
|
|
11110
|
-
this.syncWrappers()
|
|
11111
|
-
this.syncVisibility()
|
|
11112
|
-
}
|
|
11113
|
-
|
|
11114
|
-
/** Re-reconciles the wrappers and the mount condition. */
|
|
11115
|
-
ngDoCheck(): void {
|
|
11116
|
-
this.hasBrand = isGiven(this.brand) || hasNodes(this.brandSlot?.nativeElement)
|
|
11117
|
-
this.hasActions = isGiven(this.actions) || hasNodes(this.actionsSlot?.nativeElement)
|
|
11118
|
-
this.syncWrappers()
|
|
11119
|
-
this.syncVisibility()
|
|
11120
|
-
}
|
|
11121
|
-
|
|
11122
|
-
/** Restores a detached header (unmount). */
|
|
11123
|
-
ngOnDestroy(): void {
|
|
11124
|
-
this.reattach()
|
|
11125
|
-
}
|
|
11126
|
-
|
|
11127
|
-
/** Applies React's `{mobileOnly && isDesktop ? null : <header>}`. */
|
|
11128
|
-
private syncVisibility(): void {
|
|
11129
|
-
const hidden = this.mobileOnly && this.shell().isDesktop
|
|
11130
|
-
const host = this.host.nativeElement
|
|
11131
|
-
if (hidden && host.isConnected) {
|
|
11132
|
-
this.detachedParent = host.parentNode
|
|
11133
|
-
this.detachedAnchor = host.nextSibling
|
|
11134
|
-
host.parentNode?.removeChild(host)
|
|
11135
|
-
} else if (!hidden && !host.isConnected && this.detachedParent) {
|
|
11136
|
-
this.detachedParent.insertBefore(host, this.detachedAnchor)
|
|
11137
|
-
this.detachedParent = null
|
|
11138
|
-
this.detachedAnchor = null
|
|
11139
|
-
}
|
|
11140
|
-
}
|
|
11141
|
-
|
|
11142
|
-
/** Restores the header into its parent (Angular's removal needs it there). */
|
|
11143
|
-
private reattach(): void {
|
|
11144
|
-
const host = this.host.nativeElement
|
|
11145
|
-
if (!host.isConnected && this.detachedParent) {
|
|
11146
|
-
this.detachedParent.insertBefore(host, this.detachedAnchor)
|
|
11147
|
-
this.detachedParent = null
|
|
11148
|
-
this.detachedAnchor = null
|
|
11149
|
-
}
|
|
11077
|
+
requireShell(this.readContext(), 'ResponsiveAppShell.TopBar')
|
|
11150
11078
|
}
|
|
11151
11079
|
|
|
11152
11080
|
/** Applies React's conditional brand/actions wrappers. */
|
|
11153
|
-
private syncWrappers(): void {
|
|
11154
|
-
|
|
11155
|
-
|
|
11156
|
-
|
|
11157
|
-
|
|
11158
|
-
this.sync.sync(
|
|
11159
|
-
this.actionsSlot?.nativeElement,
|
|
11160
|
-
this.hasActions,
|
|
11161
|
-
this.actionsParent ?? undefined,
|
|
11162
|
-
)
|
|
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)
|
|
11163
11086
|
}
|
|
11164
11087
|
}
|
|
11165
11088
|
```
|
|
@@ -11173,6 +11096,7 @@ the breakpoint (the Drawer carries the nav there).
|
|
|
11173
11096
|
@Component({
|
|
11174
11097
|
selector: 'aside[mol-responsive-app-shell-sidebar]',
|
|
11175
11098
|
standalone: true,
|
|
11099
|
+
hostDirectives: [MolPlacement],
|
|
11176
11100
|
imports: [MolTemplateOutlet],
|
|
11177
11101
|
inputs: ['navLabel', 'footer', 'className', 'dataMolId', 'testId'],
|
|
11178
11102
|
host: {
|
|
@@ -11199,7 +11123,7 @@ the breakpoint (the Drawer carries the nav there).
|
|
|
11199
11123
|
><ng-container [molTemplateOutlet]="asTemplate(footer)"></ng-container>{{ nodeText(footer) }}
|
|
11200
11124
|
</div>`,
|
|
11201
11125
|
})
|
|
11202
|
-
export class ResponsiveAppShellSidebar implements OnInit
|
|
11126
|
+
export class ResponsiveAppShellSidebar implements OnInit {
|
|
11203
11127
|
/** Accessible name for the `<nav>` landmark. */
|
|
11204
11128
|
navLabel?: ResponsiveAppShellSidebarProps['navLabel']
|
|
11205
11129
|
/** Below-nav content (React's `footer` node value). */
|
|
@@ -11228,25 +11152,36 @@ export class ResponsiveAppShellSidebar implements OnInit, AfterViewInit, DoCheck
|
|
|
11228
11152
|
*/
|
|
11229
11153
|
private readonly i18n = useTranslation()
|
|
11230
11154
|
|
|
11231
|
-
private readonly renderer = inject(Renderer2)
|
|
11232
|
-
private readonly sync = new SlotWrapper(this.host, this.renderer)
|
|
11233
|
-
private footerParent: HTMLElement | null = null
|
|
11234
11155
|
private hasFooter = false
|
|
11235
|
-
|
|
11236
|
-
|
|
11156
|
+
|
|
11157
|
+
/** Prepares the aside's mount condition (React's breakpoint check). */
|
|
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
|
+
})
|
|
11165
|
+
// Leaves no element in the page below the breakpoint (React renders null).
|
|
11166
|
+
useHostPresence(() => this.shell().isDesktop)
|
|
11167
|
+
}
|
|
11237
11168
|
|
|
11238
11169
|
/**
|
|
11239
11170
|
* The nearest shell context.
|
|
11240
|
-
* @returns The context (defaults outside the shell).
|
|
11171
|
+
* @returns The context (its defaults outside the shell).
|
|
11241
11172
|
*/
|
|
11242
11173
|
shell(): ShellContextValue {
|
|
11243
11174
|
// Cached: a detached (mobile) sidebar loses its DOM ancestors.
|
|
11244
|
-
this.
|
|
11245
|
-
return this.context
|
|
11175
|
+
return this.readContext() ?? contextOrDefault(null)
|
|
11246
11176
|
}
|
|
11247
11177
|
|
|
11248
|
-
/**
|
|
11249
|
-
|
|
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
|
+
}
|
|
11250
11185
|
|
|
11251
11186
|
/**
|
|
11252
11187
|
* The current class map.
|
|
@@ -11295,59 +11230,13 @@ export class ResponsiveAppShellSidebar implements OnInit, AfterViewInit, DoCheck
|
|
|
11295
11230
|
* Refuses to render outside a shell (React's `useShellContext` throws).
|
|
11296
11231
|
*/
|
|
11297
11232
|
ngOnInit(): void {
|
|
11298
|
-
requireShell(this.
|
|
11299
|
-
}
|
|
11300
|
-
|
|
11301
|
-
/** Applies the initial mount condition and footer presence. */
|
|
11302
|
-
ngAfterViewInit(): void {
|
|
11303
|
-
this.footerParent = this.footerSlot?.nativeElement.parentElement ?? null
|
|
11304
|
-
this.hasFooter = isGiven(this.footer) || hasNodes(this.footerSlot?.nativeElement)
|
|
11305
|
-
this.syncWrapper()
|
|
11306
|
-
this.syncVisibility()
|
|
11307
|
-
}
|
|
11308
|
-
|
|
11309
|
-
/** Re-reconciles the mount condition and the footer wrapper. */
|
|
11310
|
-
ngDoCheck(): void {
|
|
11311
|
-
this.hasFooter = isGiven(this.footer) || hasNodes(this.footerSlot?.nativeElement)
|
|
11312
|
-
this.syncWrapper()
|
|
11313
|
-
this.syncVisibility()
|
|
11314
|
-
}
|
|
11315
|
-
|
|
11316
|
-
/** Restores a detached aside (unmount). */
|
|
11317
|
-
ngOnDestroy(): void {
|
|
11318
|
-
this.reattach()
|
|
11319
|
-
}
|
|
11320
|
-
|
|
11321
|
-
/** Applies React's `{!isDesktop ? null : <aside>}`. */
|
|
11322
|
-
private syncVisibility(): void {
|
|
11323
|
-
const hidden = !this.shell().isDesktop
|
|
11324
|
-
const host = this.host.nativeElement
|
|
11325
|
-
if (hidden && host.isConnected) {
|
|
11326
|
-
this.detachedParent = host.parentNode
|
|
11327
|
-
this.detachedAnchor = host.nextSibling
|
|
11328
|
-
host.parentNode?.removeChild(host)
|
|
11329
|
-
} else if (!hidden && !host.isConnected && this.detachedParent) {
|
|
11330
|
-
this.detachedParent.insertBefore(host, this.detachedAnchor)
|
|
11331
|
-
this.detachedParent = null
|
|
11332
|
-
this.detachedAnchor = null
|
|
11333
|
-
}
|
|
11334
|
-
}
|
|
11335
|
-
|
|
11336
|
-
/** Restores the aside into its parent. */
|
|
11337
|
-
private reattach(): void {
|
|
11338
|
-
const host = this.host.nativeElement
|
|
11339
|
-
if (!host.isConnected && this.detachedParent) {
|
|
11340
|
-
this.detachedParent.insertBefore(host, this.detachedAnchor)
|
|
11341
|
-
this.detachedParent = null
|
|
11342
|
-
this.detachedAnchor = null
|
|
11343
|
-
}
|
|
11233
|
+
requireShell(this.readContext(), 'ResponsiveAppShell.Sidebar')
|
|
11344
11234
|
}
|
|
11345
11235
|
|
|
11346
11236
|
/** Applies React's conditional footer wrapper. */
|
|
11347
|
-
private syncWrapper(): void {
|
|
11348
|
-
|
|
11349
|
-
|
|
11350
|
-
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)
|
|
11351
11240
|
}
|
|
11352
11241
|
}
|
|
11353
11242
|
```
|
|
@@ -11361,6 +11250,7 @@ backdrop, portaled into `document.body`.
|
|
|
11361
11250
|
@Component({
|
|
11362
11251
|
selector: 'mol-responsive-app-shell-drawer',
|
|
11363
11252
|
standalone: true,
|
|
11253
|
+
hostDirectives: [MolPlacement],
|
|
11364
11254
|
imports: [MolIconSvg, MolTemplateOutlet],
|
|
11365
11255
|
inputs: [
|
|
11366
11256
|
'header',
|
|
@@ -11372,11 +11262,6 @@ backdrop, portaled into `document.body`.
|
|
|
11372
11262
|
'closeDataMolId',
|
|
11373
11263
|
'testId',
|
|
11374
11264
|
],
|
|
11375
|
-
host: {
|
|
11376
|
-
'data-parity-unwrap': '',
|
|
11377
|
-
style: 'display: contents',
|
|
11378
|
-
'[attr.data-open]': 'shell().drawerOpen ? "true" : null',
|
|
11379
|
-
},
|
|
11380
11265
|
template: `<div #overlay [class]="cm().overlay" aria-hidden="true"></div>
|
|
11381
11266
|
<div
|
|
11382
11267
|
#wrapper
|
|
@@ -11474,27 +11359,30 @@ export class ResponsiveAppShellDrawer implements OnInit, AfterViewInit, DoCheck,
|
|
|
11474
11359
|
|
|
11475
11360
|
private readonly i18n = useTranslation()
|
|
11476
11361
|
|
|
11477
|
-
private readonly renderer = inject(Renderer2)
|
|
11478
11362
|
private readonly injector = inject(Injector)
|
|
11479
11363
|
private readonly environmentInjector = inject(EnvironmentInjector)
|
|
11480
|
-
private readonly sync = new SlotWrapper(this.host, this.renderer)
|
|
11481
11364
|
private readonly scrollLock = createScrollLock()
|
|
11482
11365
|
private hasFooter = false
|
|
11483
|
-
private footerParent: HTMLElement | null = null
|
|
11484
|
-
private headerParent: HTMLElement | null = null
|
|
11485
|
-
private headerRowParent: HTMLElement | null = null
|
|
11486
|
-
private attached = false
|
|
11487
11366
|
private locked = false
|
|
11488
11367
|
private lastOpen = false
|
|
11489
11368
|
private previouslyFocused: HTMLElement | null = null
|
|
11490
11369
|
private listeners: (() => void)[] = []
|
|
11491
11370
|
|
|
11371
|
+
constructor() {
|
|
11372
|
+
usePlacement((hasContent) => {
|
|
11373
|
+
void this.shell()
|
|
11374
|
+
this.syncWrappers(hasContent)
|
|
11375
|
+
this.syncOpen()
|
|
11376
|
+
})
|
|
11377
|
+
}
|
|
11378
|
+
|
|
11492
11379
|
shell(): ShellContextValue {
|
|
11493
|
-
this.
|
|
11494
|
-
return this.context
|
|
11380
|
+
return this.readContext() ?? contextOrDefault(null)
|
|
11495
11381
|
}
|
|
11496
11382
|
|
|
11497
|
-
private
|
|
11383
|
+
private readContext(): ShellContextValue | null {
|
|
11384
|
+
return ShellDomContext.find(this.host.nativeElement) ?? null
|
|
11385
|
+
}
|
|
11498
11386
|
|
|
11499
11387
|
cm(): UIClassMap {
|
|
11500
11388
|
return getClassMap()
|
|
@@ -11552,17 +11440,11 @@ export class ResponsiveAppShellDrawer implements OnInit, AfterViewInit, DoCheck,
|
|
|
11552
11440
|
}
|
|
11553
11441
|
|
|
11554
11442
|
ngOnInit(): void {
|
|
11555
|
-
requireShell(this.
|
|
11443
|
+
requireShell(this.readContext(), 'ResponsiveAppShell.Drawer')
|
|
11556
11444
|
}
|
|
11557
11445
|
|
|
11558
11446
|
ngAfterViewInit(): void {
|
|
11559
11447
|
this.shell().registerDrawer(true)
|
|
11560
|
-
this.headerParent = this.headerSlot?.nativeElement.parentElement ?? null
|
|
11561
|
-
this.headerRowParent = this.headerRow?.nativeElement.parentElement ?? null
|
|
11562
|
-
this.footerParent = this.footerSlot?.nativeElement.parentElement ?? null
|
|
11563
|
-
this.headerPresent.set(isGiven(this.header) || hasNodes(this.headerSlot?.nativeElement))
|
|
11564
|
-
this.hasFooter = isGiven(this.footer) || hasNodes(this.footerSlot?.nativeElement)
|
|
11565
|
-
this.syncWrappers()
|
|
11566
11448
|
const open = this.shell().drawerOpen && !this.shell().isDesktop
|
|
11567
11449
|
this.lastOpen = open
|
|
11568
11450
|
if (open) this.openPanel()
|
|
@@ -11570,9 +11452,6 @@ export class ResponsiveAppShellDrawer implements OnInit, AfterViewInit, DoCheck,
|
|
|
11570
11452
|
}
|
|
11571
11453
|
|
|
11572
11454
|
ngDoCheck(): void {
|
|
11573
|
-
this.headerPresent.set(isGiven(this.header) || hasNodes(this.headerSlot?.nativeElement))
|
|
11574
|
-
this.hasFooter = isGiven(this.footer) || hasNodes(this.footerSlot?.nativeElement)
|
|
11575
|
-
this.syncWrappers()
|
|
11576
11455
|
this.syncOpen()
|
|
11577
11456
|
}
|
|
11578
11457
|
|
|
@@ -11591,16 +11470,44 @@ export class ResponsiveAppShellDrawer implements OnInit, AfterViewInit, DoCheck,
|
|
|
11591
11470
|
this.scrollLock.unlock()
|
|
11592
11471
|
this.locked = false
|
|
11593
11472
|
}
|
|
11594
|
-
|
|
11595
|
-
|
|
11596
|
-
|
|
11597
|
-
|
|
11598
|
-
|
|
11599
|
-
|
|
11600
|
-
this.
|
|
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
|
+
)
|
|
11601
11508
|
}
|
|
11602
11509
|
}
|
|
11603
|
-
// … truncated —
|
|
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
|
|
11604
11511
|
```
|
|
11605
11512
|
|
|
11606
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`.)_
|
|
@@ -12036,9 +11943,9 @@ export class Separator implements HasElement<HTMLDivElement> {
|
|
|
12036
11943
|
|
|
12037
11944
|
SidebarUserCard component.
|
|
12038
11945
|
|
|
12039
|
-
React's root is a FRAGMENT (the trigger button plus a drawer), so the
|
|
12040
|
-
|
|
12041
|
-
|
|
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
|
|
12042
11949
|
matching props override it.
|
|
12043
11950
|
|
|
12044
11951
|
```typescript
|
|
@@ -12046,6 +11953,7 @@ matching props override it.
|
|
|
12046
11953
|
selector: 'mol-sidebar-user-card',
|
|
12047
11954
|
standalone: true,
|
|
12048
11955
|
imports: [Modal, PanelCloseProvider],
|
|
11956
|
+
hostDirectives: [MolPlacement],
|
|
12049
11957
|
inputs: [
|
|
12050
11958
|
'name',
|
|
12051
11959
|
'secondaryLine',
|
|
@@ -12055,10 +11963,6 @@ matching props override it.
|
|
|
12055
11963
|
'dataMolId',
|
|
12056
11964
|
'className',
|
|
12057
11965
|
],
|
|
12058
|
-
host: {
|
|
12059
|
-
'data-parity-unwrap': '',
|
|
12060
|
-
style: 'display: contents',
|
|
12061
|
-
},
|
|
12062
11966
|
template: `<button
|
|
12063
11967
|
#trigger
|
|
12064
11968
|
type="button"
|
|
@@ -12089,7 +11993,7 @@ matching props override it.
|
|
|
12089
11993
|
><ng-content></ng-content></mol-panel-close-provider
|
|
12090
11994
|
></mol-modal>`,
|
|
12091
11995
|
})
|
|
12092
|
-
export class SidebarUserCard
|
|
11996
|
+
export class SidebarUserCard {
|
|
12093
11997
|
/** Display name override (falls back to the auth user, then the guest label). */
|
|
12094
11998
|
name?: SidebarUserCardProps['name']
|
|
12095
11999
|
/** Secondary line under the name (falls back to the auth user's email). */
|
|
@@ -12123,8 +12027,15 @@ export class SidebarUserCard implements AfterViewInit, OnDestroy {
|
|
|
12123
12027
|
@ViewChild('trigger') trigger?: ElementRef<HTMLButtonElement>
|
|
12124
12028
|
|
|
12125
12029
|
private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
|
|
12126
|
-
|
|
12127
|
-
|
|
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
|
+
}
|
|
12128
12039
|
private readonly routeEffect = effect(() => {
|
|
12129
12040
|
const location = this.router.location()
|
|
12130
12041
|
void `${location.pathname}${location.search}`
|
|
@@ -12264,26 +12175,6 @@ export class SidebarUserCard implements AfterViewInit, OnDestroy {
|
|
|
12264
12175
|
closePanel = (): void => {
|
|
12265
12176
|
this.isOpen.set(false)
|
|
12266
12177
|
}
|
|
12267
|
-
|
|
12268
|
-
/** Adopts the trigger beside the host and moves rest props onto it. */
|
|
12269
|
-
ngAfterViewInit(): void {
|
|
12270
|
-
const trigger = this.trigger?.nativeElement
|
|
12271
|
-
const host = this.host.nativeElement
|
|
12272
|
-
if (!trigger) return
|
|
12273
|
-
if (host.parentNode) {
|
|
12274
|
-
host.parentNode.insertBefore(trigger, host)
|
|
12275
|
-
this.adopted = true
|
|
12276
|
-
}
|
|
12277
|
-
if (!this.movedRest) {
|
|
12278
|
-
moveRestAttributes(host, trigger)
|
|
12279
|
-
this.movedRest = true
|
|
12280
|
-
}
|
|
12281
|
-
}
|
|
12282
|
-
|
|
12283
|
-
/** Restores the adopted trigger (unmount). */
|
|
12284
|
-
ngOnDestroy(): void {
|
|
12285
|
-
if (this.adopted) this.host.nativeElement.appendChild(this.trigger?.nativeElement as Node)
|
|
12286
|
-
}
|
|
12287
12178
|
}
|
|
12288
12179
|
```
|
|
12289
12180
|
|
|
@@ -12633,16 +12524,17 @@ export class Spinner implements HasElement<HTMLDivElement> {
|
|
|
12633
12524
|
|
|
12634
12525
|
Switch component.
|
|
12635
12526
|
|
|
12636
|
-
React's root is a fragment (hidden native checkbox + label)
|
|
12637
|
-
|
|
12638
|
-
|
|
12639
|
-
|
|
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
|
|
12640
12531
|
forwarded as the `change` output.
|
|
12641
12532
|
|
|
12642
12533
|
```typescript
|
|
12643
12534
|
@Component({
|
|
12644
12535
|
selector: 'mol-switch',
|
|
12645
12536
|
standalone: true,
|
|
12537
|
+
hostDirectives: [MolPlacement],
|
|
12646
12538
|
imports: [MolControlledChecked],
|
|
12647
12539
|
inputs: [
|
|
12648
12540
|
'label',
|
|
@@ -12657,10 +12549,6 @@ forwarded as the `change` output.
|
|
|
12657
12549
|
'dataMolId: data-mol-id',
|
|
12658
12550
|
'onClick',
|
|
12659
12551
|
],
|
|
12660
|
-
host: {
|
|
12661
|
-
'data-parity-unwrap': '',
|
|
12662
|
-
style: 'display: contents',
|
|
12663
|
-
},
|
|
12664
12552
|
template: `<input
|
|
12665
12553
|
type="checkbox"
|
|
12666
12554
|
[molChecked]="!!checked"
|
|
@@ -12744,7 +12632,23 @@ export class Switch implements AfterViewChecked, HasElement<HTMLButtonElement> {
|
|
|
12744
12632
|
private hasLabel = false
|
|
12745
12633
|
/** The `data-mol-id` a caller bound on the host (React spreads it onto the trigger). */
|
|
12746
12634
|
private externalMolId: string | undefined
|
|
12747
|
-
|
|
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
|
+
}
|
|
12748
12652
|
|
|
12749
12653
|
/**
|
|
12750
12654
|
* The current class map.
|
|
@@ -12827,8 +12731,7 @@ export class Switch implements AfterViewChecked, HasElement<HTMLButtonElement> {
|
|
|
12827
12731
|
}
|
|
12828
12732
|
|
|
12829
12733
|
/**
|
|
12830
|
-
* Moves rest attributes onto the button
|
|
12831
|
-
* `{!!label && <span>}` label condition after queries resolve.
|
|
12734
|
+
* Moves rest attributes onto the button after queries resolve.
|
|
12832
12735
|
*/
|
|
12833
12736
|
ngAfterViewChecked(): void {
|
|
12834
12737
|
adoptHostDataMolId(
|
|
@@ -12839,13 +12742,6 @@ export class Switch implements AfterViewChecked, HasElement<HTMLButtonElement> {
|
|
|
12839
12742
|
},
|
|
12840
12743
|
() => this.molId(),
|
|
12841
12744
|
)
|
|
12842
|
-
moveRestAttributes(this.host.nativeElement, this.trigger?.nativeElement)
|
|
12843
|
-
this.hasLabel = !!this.label || hasNodes(this.labelSlot?.nativeElement)
|
|
12844
|
-
this.sync.sync(
|
|
12845
|
-
this.labelSlot?.nativeElement,
|
|
12846
|
-
this.hasLabel,
|
|
12847
|
-
this.labelSlot?.nativeElement.parentElement ?? undefined,
|
|
12848
|
-
)
|
|
12849
12745
|
}
|
|
12850
12746
|
}
|
|
12851
12747
|
```
|
|
@@ -12863,6 +12759,7 @@ or plain functions returning text.
|
|
|
12863
12759
|
@Component({
|
|
12864
12760
|
selector: 'div[mol-table]',
|
|
12865
12761
|
standalone: true,
|
|
12762
|
+
hostDirectives: [MolPlacement],
|
|
12866
12763
|
imports: [MolIconSvg, MolTemplateOutlet, Spinner],
|
|
12867
12764
|
inputs: [
|
|
12868
12765
|
'data',
|
|
@@ -12960,9 +12857,7 @@ or plain functions returning text.
|
|
|
12960
12857
|
</tbody>
|
|
12961
12858
|
</table>`,
|
|
12962
12859
|
})
|
|
12963
|
-
export class Table
|
|
12964
|
-
implements AfterViewInit, AfterViewChecked, DoCheck, HasElement<HTMLTableElement>
|
|
12965
|
-
{
|
|
12860
|
+
export class Table implements AfterViewInit, AfterViewChecked, HasElement<HTMLTableElement> {
|
|
12966
12861
|
data: Record<string, unknown>[] = []
|
|
12967
12862
|
columns: TableColumn<Record<string, unknown>>[] = []
|
|
12968
12863
|
rowKey?: string | ((row: Record<string, unknown>) => string | number)
|
|
@@ -12997,13 +12892,13 @@ export class Table
|
|
|
12997
12892
|
|
|
12998
12893
|
private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
|
|
12999
12894
|
|
|
12895
|
+
constructor() {
|
|
12896
|
+
usePlacement((hasContent) => this.reconcile(hasContent))
|
|
12897
|
+
}
|
|
12898
|
+
|
|
13000
12899
|
private readonly i18n = useTranslation()
|
|
13001
12900
|
|
|
13002
|
-
private readonly renderer = inject(Renderer2)
|
|
13003
|
-
private readonly sync = new SlotWrapper(this.host, this.renderer)
|
|
13004
12901
|
private externalMolId: string | undefined
|
|
13005
|
-
private emptyParent: HTMLElement | null = null
|
|
13006
|
-
private adoptedEmpty: Node[] = []
|
|
13007
12902
|
|
|
13008
12903
|
cm(): UIClassMap {
|
|
13009
12904
|
return getClassMap()
|
|
@@ -13107,7 +13002,14 @@ export class Table
|
|
|
13107
13002
|
const value = row[column.key as string]
|
|
13108
13003
|
return value === undefined || value === null ? '' : String(value)
|
|
13109
13004
|
}
|
|
13110
|
-
|
|
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
|
|
13111
13013
|
```
|
|
13112
13014
|
|
|
13113
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`.)_
|
|
@@ -13760,6 +13662,7 @@ with the remaining time; the announced role follows `status`
|
|
|
13760
13662
|
@Component({
|
|
13761
13663
|
selector: 'div[mol-toast]',
|
|
13762
13664
|
standalone: true,
|
|
13665
|
+
hostDirectives: [MolPlacement],
|
|
13763
13666
|
imports: [MolIconSvg, MolTemplateOutlet],
|
|
13764
13667
|
inputs: [
|
|
13765
13668
|
'title',
|
|
@@ -13778,6 +13681,7 @@ with the remaining time; the announced role follows `status`
|
|
|
13778
13681
|
],
|
|
13779
13682
|
outputs: ['dismiss'],
|
|
13780
13683
|
host: {
|
|
13684
|
+
// static `title="…"` on the host, where the browser shows it as a tooltip.
|
|
13781
13685
|
'[attr.title]': 'null',
|
|
13782
13686
|
'[class]': 'classes()',
|
|
13783
13687
|
'[style]': 'hostStyle()',
|
|
@@ -13823,6 +13727,7 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
|
|
|
13823
13727
|
description?: unknown
|
|
13824
13728
|
/** The toast status. */
|
|
13825
13729
|
status: ColorVariant = 'info'
|
|
13730
|
+
/** Auto-dismiss delay in ms (`0` keeps it until dismissed). */
|
|
13826
13731
|
duration = 5000
|
|
13827
13732
|
/** Whether the close button renders. */
|
|
13828
13733
|
dismissible = true
|
|
@@ -13834,7 +13739,9 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
|
|
|
13834
13739
|
style?: Record<string, unknown>
|
|
13835
13740
|
/** `data-testid`. */
|
|
13836
13741
|
testId?: string
|
|
13742
|
+
/** Accepted for prop parity; positioning is the container's job. */
|
|
13837
13743
|
position?: ToastPosition
|
|
13744
|
+
/** `data-mol-id` automation id (React's `automationId`). */
|
|
13838
13745
|
automationId?: string
|
|
13839
13746
|
dataMolId?: string
|
|
13840
13747
|
id?: string
|
|
@@ -13845,29 +13752,28 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
|
|
|
13845
13752
|
/** The children capture point. */
|
|
13846
13753
|
@ViewChild('childrenSlot') childrenSlot?: ElementRef<HTMLSpanElement>
|
|
13847
13754
|
|
|
13755
|
+
/** Whether the toast is still rendered (React's `isVisible`). */
|
|
13848
13756
|
readonly visible = signal(true)
|
|
13849
13757
|
|
|
13850
13758
|
private readonly el = inject(ElementRef)
|
|
13851
13759
|
private readonly hostRef: ElementRef<HTMLDivElement> = inject(ElementRef)
|
|
13760
|
+
/** The element a caller's ref receives: the host `<div>`. */
|
|
13852
13761
|
readonly element = hostElement(this.hostRef)
|
|
13853
13762
|
|
|
13763
|
+
/** Reactive translation, read in the injection context. */
|
|
13854
13764
|
private readonly i18n = useTranslation()
|
|
13855
13765
|
|
|
13856
|
-
private readonly renderer = inject(Renderer2)
|
|
13857
13766
|
private readonly host: HTMLElement = this.el.nativeElement
|
|
13858
|
-
private readonly sync = new SlotWrapper(this.el, this.renderer)
|
|
13859
13767
|
private remaining: number
|
|
13860
13768
|
private startedAt: number | null = null
|
|
13861
13769
|
private timer: ReturnType<typeof setTimeout> | undefined
|
|
13862
13770
|
private lastDuration: number
|
|
13863
|
-
private descriptionParent: HTMLElement | null = null
|
|
13864
|
-
private childrenParent: HTMLElement | null = null
|
|
13865
13771
|
private hasChildren = false
|
|
13866
|
-
private adoptedChildren: Node[] = []
|
|
13867
|
-
private detachedParent: Node | null = null
|
|
13868
|
-
private detachedAnchor: Node | null = null
|
|
13869
13772
|
|
|
13773
|
+
/** Prepares the countdown state (the timer starts at view init). */
|
|
13870
13774
|
constructor() {
|
|
13775
|
+
usePlacement((hasContent) => this.reconcile(hasContent))
|
|
13776
|
+
useHostPresence(() => this.visible())
|
|
13871
13777
|
this.remaining = this.duration
|
|
13872
13778
|
this.lastDuration = this.duration
|
|
13873
13779
|
}
|
|
@@ -13896,6 +13802,7 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
|
|
|
13896
13802
|
return this.automationId ?? this.dataMolId ?? this.host.getAttribute('data-mol-id') ?? undefined
|
|
13897
13803
|
}
|
|
13898
13804
|
|
|
13805
|
+
/** The announced role: assertive for warnings/errors, polite otherwise. */
|
|
13899
13806
|
role(): 'alert' | 'status' {
|
|
13900
13807
|
return this.variant() === 'warning' || this.variant() === 'error' ? 'alert' : 'status'
|
|
13901
13808
|
}
|
|
@@ -13911,10 +13818,12 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
|
|
|
13911
13818
|
return resolveIcon('x-mark', this.cm().iconSm)
|
|
13912
13819
|
}
|
|
13913
13820
|
|
|
13821
|
+
/** The string description, when the description is a string. */
|
|
13914
13822
|
descriptionText(): string | null {
|
|
13915
13823
|
return typeof this.description === 'string' ? this.description : null
|
|
13916
13824
|
}
|
|
13917
13825
|
|
|
13826
|
+
/** The description as a template, when it is a node value. */
|
|
13918
13827
|
descriptionTemplate(): TemplateRef<unknown> | null {
|
|
13919
13828
|
return this.description instanceof TemplateRef ? this.description : null
|
|
13920
13829
|
}
|
|
@@ -13924,11 +13833,13 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
|
|
|
13924
13833
|
return this.closeLabel ?? this.i18n.t('ui.toast.close', undefined, { defaultValue: 'Close' })
|
|
13925
13834
|
}
|
|
13926
13835
|
|
|
13836
|
+
/** Dismisses the toast and calls the callback (React's `handleDismiss`). */
|
|
13927
13837
|
handleDismiss(): void {
|
|
13928
13838
|
this.visible.set(false)
|
|
13929
13839
|
this.dismiss.emit()
|
|
13930
13840
|
}
|
|
13931
13841
|
|
|
13842
|
+
/** Pauses the countdown, keeping the time left (React's `pauseTimer`). */
|
|
13932
13843
|
pauseTimer(): void {
|
|
13933
13844
|
if (this.startedAt === null) return
|
|
13934
13845
|
const elapsed = Date.now() - this.startedAt
|
|
@@ -13941,10 +13852,6 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
|
|
|
13941
13852
|
}
|
|
13942
13853
|
|
|
13943
13854
|
ngAfterViewInit(): void {
|
|
13944
|
-
this.descriptionParent = this.descriptionSlot?.nativeElement.parentElement ?? null
|
|
13945
|
-
this.childrenParent = this.childrenSlot?.nativeElement.parentElement ?? null
|
|
13946
|
-
this.hasChildren = hasNodes(this.childrenSlot?.nativeElement)
|
|
13947
|
-
this.adoptChildren()
|
|
13948
13855
|
this.restart()
|
|
13949
13856
|
}
|
|
13950
13857
|
|
|
@@ -13953,25 +13860,20 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
|
|
|
13953
13860
|
this.lastDuration = this.duration
|
|
13954
13861
|
this.restart()
|
|
13955
13862
|
}
|
|
13956
|
-
this.syncDescription()
|
|
13957
|
-
this.syncHostVisibility()
|
|
13958
13863
|
}
|
|
13959
13864
|
|
|
13865
|
+
/** Stops the countdown (React's unmount cleanup). */
|
|
13960
13866
|
ngOnDestroy(): void {
|
|
13961
13867
|
this.clearTimer()
|
|
13962
|
-
this.adoptedChildren = []
|
|
13963
|
-
if (!this.host.isConnected && this.detachedParent) {
|
|
13964
|
-
this.detachedParent.insertBefore(this.host, this.detachedAnchor)
|
|
13965
|
-
this.detachedParent = null
|
|
13966
|
-
this.detachedAnchor = null
|
|
13967
|
-
}
|
|
13968
13868
|
}
|
|
13969
13869
|
|
|
13870
|
+
/** React's effect body: reset the remaining time and start counting. */
|
|
13970
13871
|
private restart(): void {
|
|
13971
13872
|
this.remaining = this.duration
|
|
13972
13873
|
this.startTimer(this.duration)
|
|
13973
13874
|
}
|
|
13974
13875
|
|
|
13876
|
+
/** Clears the running timer (React's `clearTimer`). */
|
|
13975
13877
|
private clearTimer(): void {
|
|
13976
13878
|
if (this.timer) {
|
|
13977
13879
|
clearTimeout(this.timer)
|
|
@@ -13991,65 +13893,51 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
|
|
|
13991
13893
|
}, ms)
|
|
13992
13894
|
}
|
|
13993
13895
|
|
|
13896
|
+
private reconcile(hasContent: SlotReader): void {
|
|
13897
|
+
this.hasChildren = hasContent(this.childrenSlot?.nativeElement)
|
|
13898
|
+
this.adoptChildren()
|
|
13899
|
+
}
|
|
13900
|
+
|
|
13994
13901
|
private adoptChildren(): void {
|
|
13995
13902
|
const span = this.childrenSlot?.nativeElement
|
|
13996
13903
|
if (!span) return
|
|
13997
13904
|
const wrapper = this.descriptionSlot?.nativeElement
|
|
13998
13905
|
const descWins = this.descriptionText() !== null || this.descriptionTemplate() !== null
|
|
13999
|
-
|
|
14000
|
-
|
|
14001
|
-
|
|
14002
|
-
}
|
|
14003
|
-
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)
|
|
14004
13909
|
this.syncDescription()
|
|
14005
13910
|
}
|
|
14006
13911
|
|
|
14007
|
-
|
|
14008
|
-
const host = this.host
|
|
14009
|
-
if (!this.visible()) {
|
|
14010
|
-
if (host.isConnected) {
|
|
14011
|
-
this.detachedParent = host.parentNode
|
|
14012
|
-
this.detachedAnchor = host.nextSibling
|
|
14013
|
-
host.parentNode?.removeChild(host)
|
|
14014
|
-
}
|
|
14015
|
-
} else if (this.detachedParent && !host.isConnected) {
|
|
14016
|
-
this.detachedParent.insertBefore(host, this.detachedAnchor)
|
|
14017
|
-
this.detachedParent = null
|
|
14018
|
-
this.detachedAnchor = null
|
|
14019
|
-
}
|
|
14020
|
-
}
|
|
14021
|
-
|
|
13912
|
+
/** Applies React's `{!!(description || children) && <div>…</div>}`. */
|
|
14022
13913
|
private syncDescription(): void {
|
|
14023
13914
|
const wrapper = this.descriptionSlot?.nativeElement
|
|
14024
13915
|
if (!wrapper) return
|
|
14025
13916
|
const hasDescription = this.descriptionText() !== null || this.descriptionTemplate() !== null
|
|
14026
|
-
|
|
13917
|
+
setElementPresent(wrapper, hasDescription || this.hasChildren)
|
|
14027
13918
|
}
|
|
14028
13919
|
}
|
|
14029
13920
|
```
|
|
14030
13921
|
|
|
14031
|
-
_(Member comments are shortened to their first sentence, and the
|
|
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`.)_
|
|
14032
13923
|
|
|
14033
13924
|
#### `ToastContainer`
|
|
14034
13925
|
|
|
14035
13926
|
Toast container: positions toasts on screen via a body portal.
|
|
14036
13927
|
|
|
14037
|
-
React's root is a portal
|
|
14038
|
-
|
|
14039
|
-
|
|
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.
|
|
14040
13931
|
|
|
14041
13932
|
```typescript
|
|
14042
13933
|
@Component({
|
|
14043
13934
|
selector: 'mol-toast-container',
|
|
14044
13935
|
standalone: true,
|
|
13936
|
+
hostDirectives: [MolPlacement],
|
|
14045
13937
|
inputs: ['position', 'className'],
|
|
14046
|
-
host: {
|
|
14047
|
-
'data-parity-unwrap': '',
|
|
14048
|
-
style: 'display: contents',
|
|
14049
|
-
},
|
|
14050
13938
|
template: `<div #container [class]="classes()"><ng-content></ng-content></div>`,
|
|
14051
13939
|
})
|
|
14052
|
-
export class ToastContainer implements
|
|
13940
|
+
export class ToastContainer implements HasElement<HTMLDivElement> {
|
|
14053
13941
|
/** The container position (default `bottom-right`). */
|
|
14054
13942
|
position: ToastPosition = 'bottom-right'
|
|
14055
13943
|
/** Extra classes. */
|
|
@@ -14070,6 +13958,15 @@ export class ToastContainer implements AfterViewInit, OnDestroy, HasElement<HTML
|
|
|
14070
13958
|
|
|
14071
13959
|
private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
|
|
14072
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
|
+
|
|
14073
13970
|
/**
|
|
14074
13971
|
* The current class map.
|
|
14075
13972
|
* @returns The UIClassMap.
|
|
@@ -14085,18 +13982,6 @@ export class ToastContainer implements AfterViewInit, OnDestroy, HasElement<HTML
|
|
|
14085
13982
|
classes(): string {
|
|
14086
13983
|
return this.cm().cn(this.cm().toastContainer({ position: this.position }), this.className)
|
|
14087
13984
|
}
|
|
14088
|
-
|
|
14089
|
-
/** Moves the container to `document.body` (React's portal). */
|
|
14090
|
-
ngAfterViewInit(): void {
|
|
14091
|
-
const el = this.container?.nativeElement
|
|
14092
|
-
if (el && typeof document !== 'undefined') document.body.appendChild(el)
|
|
14093
|
-
}
|
|
14094
|
-
|
|
14095
|
-
/** Moves the container back under the host so Angular can remove it. */
|
|
14096
|
-
ngOnDestroy(): void {
|
|
14097
|
-
const el = this.container?.nativeElement
|
|
14098
|
-
if (el && this.host.nativeElement.parentNode) this.host.nativeElement.appendChild(el)
|
|
14099
|
-
}
|
|
14100
13985
|
}
|
|
14101
13986
|
```
|
|
14102
13987
|
|
|
@@ -14105,20 +13990,21 @@ export class ToastContainer implements AfterViewInit, OnDestroy, HasElement<HTML
|
|
|
14105
13990
|
ToastProvider: manages global toast state and renders children plus a
|
|
14106
13991
|
positioned toast container (React's context provider + portal).
|
|
14107
13992
|
|
|
14108
|
-
The context value is registered on
|
|
13993
|
+
The context value is registered on a DOM element (React context flows
|
|
14109
13994
|
through the rendered tree, which Angular DI cannot reach for projected
|
|
14110
|
-
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.
|
|
14111
14000
|
|
|
14112
14001
|
```typescript
|
|
14113
14002
|
@Component({
|
|
14114
14003
|
selector: 'mol-toast-provider',
|
|
14115
14004
|
standalone: true,
|
|
14005
|
+
hostDirectives: [MolPlacement],
|
|
14116
14006
|
imports: [Toast],
|
|
14117
14007
|
inputs: ['position'],
|
|
14118
|
-
host: {
|
|
14119
|
-
'data-parity-unwrap': '',
|
|
14120
|
-
style: 'display: contents',
|
|
14121
|
-
},
|
|
14122
14008
|
template: `<span #childrenCapture><ng-content></ng-content></span>
|
|
14123
14009
|
<div #container [class]="containerClasses()">
|
|
14124
14010
|
@for (toast of toasts(); track toast.id) {
|
|
@@ -14140,7 +14026,7 @@ content); `useToast()` reads it through the DOM ancestors.
|
|
|
14140
14026
|
}
|
|
14141
14027
|
</div>`,
|
|
14142
14028
|
})
|
|
14143
|
-
export class ToastProvider implements
|
|
14029
|
+
export class ToastProvider implements OnDestroy {
|
|
14144
14030
|
/** The default position for toasts (default `bottom-right`). */
|
|
14145
14031
|
position: ToastPosition = 'bottom-right'
|
|
14146
14032
|
|
|
@@ -14153,13 +14039,26 @@ export class ToastProvider implements AfterViewInit, OnDestroy {
|
|
|
14153
14039
|
readonly toasts = signal<(ToastProps & { id: string })[]>([])
|
|
14154
14040
|
|
|
14155
14041
|
private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
|
|
14156
|
-
|
|
14157
|
-
private readonly
|
|
14158
|
-
private adopted: Node[] = []
|
|
14042
|
+
/** The value consumers read; its closures keep the live toast state. */
|
|
14043
|
+
private readonly value = new ToastContextImplementation(this)
|
|
14159
14044
|
|
|
14160
|
-
/**
|
|
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
|
+
*/
|
|
14161
14049
|
constructor() {
|
|
14162
|
-
|
|
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
|
+
})
|
|
14163
14062
|
}
|
|
14164
14063
|
|
|
14165
14064
|
/**
|
|
@@ -14198,29 +14097,9 @@ export class ToastProvider implements AfterViewInit, OnDestroy {
|
|
|
14198
14097
|
this.toasts.update((prev) => prev.filter((toast) => toast.id !== id))
|
|
14199
14098
|
}
|
|
14200
14099
|
|
|
14201
|
-
/**
|
|
14202
|
-
* Adopts the children bare into the host and moves the container to
|
|
14203
|
-
* `document.body` (React's portal).
|
|
14204
|
-
*/
|
|
14205
|
-
ngAfterViewInit(): void {
|
|
14206
|
-
const capture = this.childrenCapture?.nativeElement
|
|
14207
|
-
const host = this.host.nativeElement
|
|
14208
|
-
if (capture) {
|
|
14209
|
-
this.adopted = Array.from(capture.childNodes)
|
|
14210
|
-
for (const node of this.adopted) host.appendChild(node)
|
|
14211
|
-
this.sync.sync(capture, false, host)
|
|
14212
|
-
}
|
|
14213
|
-
const container = this.container?.nativeElement
|
|
14214
|
-
if (container && typeof document !== 'undefined') document.body.appendChild(container)
|
|
14215
|
-
}
|
|
14216
|
-
|
|
14217
|
-
/** Removes the context registration and restores the container (unmount). */
|
|
14100
|
+
/** Removes the context registration (unmount). */
|
|
14218
14101
|
ngOnDestroy(): void {
|
|
14219
|
-
|
|
14220
|
-
const container = this.container?.nativeElement
|
|
14221
|
-
if (container && this.host.nativeElement.parentNode)
|
|
14222
|
-
this.host.nativeElement.appendChild(container)
|
|
14223
|
-
this.adopted = []
|
|
14102
|
+
ToastDomContext.remove(this.host.nativeElement)
|
|
14224
14103
|
}
|
|
14225
14104
|
}
|
|
14226
14105
|
```
|
|
@@ -14230,10 +14109,10 @@ export class ToastProvider implements AfterViewInit, OnDestroy {
|
|
|
14230
14109
|
Tooltip component.
|
|
14231
14110
|
|
|
14232
14111
|
React's root is a FRAGMENT (a trigger wrapper `<div>` plus a portal), so
|
|
14233
|
-
the
|
|
14234
|
-
|
|
14235
|
-
|
|
14236
|
-
|
|
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
|
|
14237
14116
|
tooltip shows; show/hide are coordinated across instances exactly like
|
|
14238
14117
|
React's module-level `activeTooltips` map.
|
|
14239
14118
|
|
|
@@ -14241,6 +14120,7 @@ React's module-level `activeTooltips` map.
|
|
|
14241
14120
|
@Component({
|
|
14242
14121
|
selector: 'mol-tooltip',
|
|
14243
14122
|
standalone: true,
|
|
14123
|
+
hostDirectives: [MolPlacement],
|
|
14244
14124
|
inputs: [
|
|
14245
14125
|
'content',
|
|
14246
14126
|
'placement',
|
|
@@ -14255,10 +14135,6 @@ React's module-level `activeTooltips` map.
|
|
|
14255
14135
|
'title',
|
|
14256
14136
|
'onDoubleClick',
|
|
14257
14137
|
],
|
|
14258
|
-
host: {
|
|
14259
|
-
'data-parity-unwrap': '',
|
|
14260
|
-
style: 'display: contents',
|
|
14261
|
-
},
|
|
14262
14138
|
template: `<div
|
|
14263
14139
|
#triggerWrap
|
|
14264
14140
|
[class]="cm().tooltipTrigger"
|
|
@@ -14336,16 +14212,35 @@ export class Tooltip
|
|
|
14336
14212
|
if (event.key === 'Escape') this.hide()
|
|
14337
14213
|
}
|
|
14338
14214
|
private escapeBound = false
|
|
14339
|
-
private attached = false
|
|
14340
14215
|
private lastVisible = false
|
|
14341
14216
|
private lastContentText: string | null = null
|
|
14342
14217
|
private lastPlacement: TooltipPlacement | null = null
|
|
14343
14218
|
private associateEl: HTMLElement | null = null
|
|
14344
|
-
private hostParent: Node | null = null
|
|
14345
14219
|
private externalMolId: string | undefined
|
|
14346
14220
|
|
|
14347
14221
|
constructor() {
|
|
14348
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
|
+
})
|
|
14349
14244
|
}
|
|
14350
14245
|
|
|
14351
14246
|
private repositionForContentChange(): void {
|
|
@@ -14433,25 +14328,7 @@ export class Tooltip
|
|
|
14433
14328
|
}
|
|
14434
14329
|
|
|
14435
14330
|
ngAfterViewInit(): void {
|
|
14436
|
-
|
|
14437
|
-
const host = this.host.nativeElement
|
|
14438
|
-
const capture = this.childrenCapture?.nativeElement
|
|
14439
|
-
this.hostParent = host.parentNode
|
|
14440
|
-
if (wrap) {
|
|
14441
|
-
this.hostParent?.insertBefore(wrap, host)
|
|
14442
|
-
}
|
|
14443
|
-
if (capture && wrap) {
|
|
14444
|
-
const children = Array.from(capture.childNodes)
|
|
14445
|
-
for (const node of children) wrap.appendChild(node)
|
|
14446
|
-
const elements = children.filter((node) => node.nodeType === 1)
|
|
14447
|
-
const hasText = children.some(
|
|
14448
|
-
(node) => node.nodeType === 3 && (node.textContent ?? '').trim(),
|
|
14449
|
-
)
|
|
14450
|
-
this.associateEl = elements.length === 1 && !hasText ? (elements[0] as HTMLElement) : null
|
|
14451
|
-
capture.remove()
|
|
14452
|
-
}
|
|
14453
|
-
this.portalWrap?.nativeElement.remove()
|
|
14454
|
-
this.attached = false
|
|
14331
|
+
setElementPresent(this.portalWrap?.nativeElement, false)
|
|
14455
14332
|
this.lastVisible = false
|
|
14456
14333
|
}
|
|
14457
14334
|
|
|
@@ -14489,20 +14366,14 @@ export class Tooltip
|
|
|
14489
14366
|
activeTooltips.delete(document)
|
|
14490
14367
|
}
|
|
14491
14368
|
if (this.escapeBound) document.removeEventListener('keydown', this.escapeListener)
|
|
14492
|
-
const host = this.host.nativeElement
|
|
14493
|
-
const wrap = this.triggerWrap?.nativeElement
|
|
14494
|
-
if (wrap && wrap.parentElement !== host) host.appendChild(wrap)
|
|
14495
|
-
const portal = this.portalWrap?.nativeElement
|
|
14496
|
-
if (portal && portal.parentElement !== host) host.appendChild(portal)
|
|
14497
14369
|
this.associateEl = null
|
|
14498
14370
|
}
|
|
14499
14371
|
|
|
14500
14372
|
private attachPortal(): void {
|
|
14501
14373
|
const portal = this.portalWrap?.nativeElement
|
|
14502
14374
|
if (!portal) return
|
|
14503
|
-
document.body
|
|
14375
|
+
placeElement(portal, document.body)
|
|
14504
14376
|
this.inner.set(this.contentEl?.nativeElement ?? null)
|
|
14505
|
-
this.attached = true
|
|
14506
14377
|
this.updatePosition()
|
|
14507
14378
|
this.associateEl?.setAttribute('aria-describedby', this.boxId())
|
|
14508
14379
|
if (!this.escapeBound) {
|
|
@@ -14573,7 +14444,7 @@ export class UserMenuPopover implements AfterViewInit, DoCheck, OnDestroy {
|
|
|
14573
14444
|
|
|
14574
14445
|
/** Registers the context on the host before any projected child resolves it. */
|
|
14575
14446
|
constructor() {
|
|
14576
|
-
|
|
14447
|
+
PopoverDomContext.provide(this.host.nativeElement, new UserMenuPopoverContextValue(this))
|
|
14577
14448
|
}
|
|
14578
14449
|
|
|
14579
14450
|
/**
|
|
@@ -14631,7 +14502,7 @@ export class UserMenuPopover implements AfterViewInit, DoCheck, OnDestroy {
|
|
|
14631
14502
|
/** Removes listeners and the context registration (unmount). */
|
|
14632
14503
|
ngOnDestroy(): void {
|
|
14633
14504
|
this.removeDocumentListeners()
|
|
14634
|
-
|
|
14505
|
+
PopoverDomContext.remove(this.host.nativeElement)
|
|
14635
14506
|
}
|
|
14636
14507
|
|
|
14637
14508
|
/** Adds the outside-click and Escape dismiss listeners while open. */
|
|
@@ -14729,7 +14600,7 @@ export class UserMenuPopoverTrigger {
|
|
|
14729
14600
|
* @returns The context, or null outside a popover.
|
|
14730
14601
|
*/
|
|
14731
14602
|
context(): UserMenuPopoverContext | null {
|
|
14732
|
-
return
|
|
14603
|
+
return PopoverDomContext.find(this.host.nativeElement) ?? null
|
|
14733
14604
|
}
|
|
14734
14605
|
|
|
14735
14606
|
/**
|
|
@@ -14837,7 +14708,9 @@ export class UserMenuPopoverTrigger {
|
|
|
14837
14708
|
#### `UserMenuPopoverPanel`
|
|
14838
14709
|
|
|
14839
14710
|
The popover panel: an absolutely-positioned card with an identity header
|
|
14840
|
-
and a `<nav>` wrapping the caller's items.
|
|
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`).
|
|
14841
14714
|
|
|
14842
14715
|
```typescript
|
|
14843
14716
|
@Component({
|
|
@@ -14845,12 +14718,11 @@ and a `<nav>` wrapping the caller's items. Renders nothing while closed.
|
|
|
14845
14718
|
standalone: true,
|
|
14846
14719
|
inputs: ['ariaLabelKey', 'ariaLabelDefault', 'dataMolId', 'className'],
|
|
14847
14720
|
host: {
|
|
14848
|
-
'
|
|
14849
|
-
'[attr.data-
|
|
14850
|
-
|
|
14721
|
+
'[attr.id]': 'panelId()',
|
|
14722
|
+
'[attr.data-mol-id]': 'dataMolId',
|
|
14723
|
+
'[class]': 'classes()',
|
|
14851
14724
|
},
|
|
14852
|
-
template: `<
|
|
14853
|
-
<header [class]="cm().cn(cm().sp('pb', 4), cm().userMenuPopoverHeader)">
|
|
14725
|
+
template: `<header [class]="cm().cn(cm().sp('pb', 4), cm().userMenuPopoverHeader)">
|
|
14854
14726
|
<p [class]="cm().cn(cm().textSize('sm'), cm().fontWeight('semibold'))">{{ displayName() }}</p>
|
|
14855
14727
|
@if (email(); as accountEmail) {
|
|
14856
14728
|
<p [class]="cm().cn(cm().textSize('xs'), cm().textMuted)">{{ accountEmail }}</p>
|
|
@@ -14858,10 +14730,9 @@ and a `<nav>` wrapping the caller's items. Renders nothing while closed.
|
|
|
14858
14730
|
</header>
|
|
14859
14731
|
<nav [class]="cm().cn(cm().sp('mt', 4), cm().stack(1))" [attr.aria-label]="navLabel()">
|
|
14860
14732
|
<ng-content></ng-content>
|
|
14861
|
-
</nav
|
|
14862
|
-
</div>`,
|
|
14733
|
+
</nav>`,
|
|
14863
14734
|
})
|
|
14864
|
-
export class UserMenuPopoverPanel
|
|
14735
|
+
export class UserMenuPopoverPanel {
|
|
14865
14736
|
/** i18n key for the panel's aria-label (default `userMenu.panelLabel`). */
|
|
14866
14737
|
ariaLabelKey?: UserMenuPopoverPanelProps['ariaLabelKey']
|
|
14867
14738
|
/** Fallback aria-label (default `Account menu`). */
|
|
@@ -14871,9 +14742,6 @@ export class UserMenuPopoverPanel implements AfterViewInit, DoCheck {
|
|
|
14871
14742
|
/** Extra classes for the panel. */
|
|
14872
14743
|
className?: UserMenuPopoverPanelProps['className']
|
|
14873
14744
|
|
|
14874
|
-
/** The panel element (removed from the DOM while closed). */
|
|
14875
|
-
@ViewChild('panel') panel?: ElementRef<HTMLDivElement>
|
|
14876
|
-
|
|
14877
14745
|
private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
|
|
14878
14746
|
|
|
14879
14747
|
/**
|
|
@@ -14883,9 +14751,9 @@ export class UserMenuPopoverPanel implements AfterViewInit, DoCheck {
|
|
|
14883
14751
|
*/
|
|
14884
14752
|
private readonly i18n = useTranslation()
|
|
14885
14753
|
|
|
14886
|
-
|
|
14887
|
-
|
|
14888
|
-
|
|
14754
|
+
constructor() {
|
|
14755
|
+
useHostPresence(() => this.open())
|
|
14756
|
+
}
|
|
14889
14757
|
|
|
14890
14758
|
/**
|
|
14891
14759
|
* The current class map.
|
|
@@ -14900,7 +14768,7 @@ export class UserMenuPopoverPanel implements AfterViewInit, DoCheck {
|
|
|
14900
14768
|
* @returns The context, or null outside a popover.
|
|
14901
14769
|
*/
|
|
14902
14770
|
context(): UserMenuPopoverContext | null {
|
|
14903
|
-
return
|
|
14771
|
+
return PopoverDomContext.find(this.host.nativeElement) ?? null
|
|
14904
14772
|
}
|
|
14905
14773
|
|
|
14906
14774
|
/**
|
|
@@ -14947,27 +14815,6 @@ export class UserMenuPopoverPanel implements AfterViewInit, DoCheck {
|
|
|
14947
14815
|
classes(): string {
|
|
14948
14816
|
return this.cm().cn(this.cm().userMenuPopoverPanel, this.className)
|
|
14949
14817
|
}
|
|
14950
|
-
|
|
14951
|
-
/** Records where the panel lives and applies the initial open state. */
|
|
14952
|
-
ngAfterViewInit(): void {
|
|
14953
|
-
const panel = this.panel?.nativeElement
|
|
14954
|
-
if (!panel) return
|
|
14955
|
-
this.panelParent = panel.parentNode
|
|
14956
|
-
this.panelAnchor = panel.nextSibling
|
|
14957
|
-
this.lastOpen = this.open()
|
|
14958
|
-
if (!this.lastOpen) panel.remove()
|
|
14959
|
-
}
|
|
14960
|
-
|
|
14961
|
-
/** Attaches or detaches the panel to match the open state (React renders null). */
|
|
14962
|
-
ngDoCheck(): void {
|
|
14963
|
-
const open = this.open()
|
|
14964
|
-
if (open === this.lastOpen) return
|
|
14965
|
-
this.lastOpen = open
|
|
14966
|
-
const panel = this.panel?.nativeElement
|
|
14967
|
-
if (!panel || !this.panelParent) return
|
|
14968
|
-
if (open) this.panelParent.insertBefore(panel, this.panelAnchor)
|
|
14969
|
-
else panel.remove()
|
|
14970
|
-
}
|
|
14971
14818
|
}
|
|
14972
14819
|
```
|
|
14973
14820
|
|
|
@@ -15023,7 +14870,7 @@ export class UserMenuPopoverSignOut {
|
|
|
15023
14870
|
* @returns The context, or null outside a popover.
|
|
15024
14871
|
*/
|
|
15025
14872
|
context(): UserMenuPopoverContext | null {
|
|
15026
|
-
return
|
|
14873
|
+
return PopoverDomContext.find(this.host.nativeElement) ?? null
|
|
15027
14874
|
}
|
|
15028
14875
|
|
|
15029
14876
|
/**
|
|
@@ -15075,9 +14922,9 @@ export class UserMenuPopoverSignOut {
|
|
|
15075
14922
|
|
|
15076
14923
|
UserMenu component.
|
|
15077
14924
|
|
|
15078
|
-
React's root is a FRAGMENT (the trigger button plus a drawer), so the
|
|
15079
|
-
|
|
15080
|
-
|
|
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
|
|
15081
14928
|
React's (a route change must restore focus to the trigger). The panel
|
|
15082
14929
|
content is projected inside the drawer through `PanelCloseProvider`.
|
|
15083
14930
|
|
|
@@ -15086,6 +14933,7 @@ content is projected inside the drawer through `PanelCloseProvider`.
|
|
|
15086
14933
|
selector: 'mol-user-menu',
|
|
15087
14934
|
standalone: true,
|
|
15088
14935
|
imports: [Button, Icon, Modal, PanelCloseProvider],
|
|
14936
|
+
hostDirectives: [MolPlacement],
|
|
15089
14937
|
inputs: [
|
|
15090
14938
|
'ariaLabelKey',
|
|
15091
14939
|
'ariaLabelDefault',
|
|
@@ -15097,10 +14945,6 @@ content is projected inside the drawer through `PanelCloseProvider`.
|
|
|
15097
14945
|
'onClick',
|
|
15098
14946
|
'side',
|
|
15099
14947
|
],
|
|
15100
|
-
host: {
|
|
15101
|
-
'data-parity-unwrap': '',
|
|
15102
|
-
style: 'display: contents',
|
|
15103
|
-
},
|
|
15104
14948
|
template: `<button
|
|
15105
14949
|
#trigger
|
|
15106
14950
|
mol-button
|
|
@@ -15126,7 +14970,7 @@ content is projected inside the drawer through `PanelCloseProvider`.
|
|
|
15126
14970
|
><ng-content></ng-content></mol-panel-close-provider
|
|
15127
14971
|
></mol-modal>`,
|
|
15128
14972
|
})
|
|
15129
|
-
export class UserMenu
|
|
14973
|
+
export class UserMenu {
|
|
15130
14974
|
/** i18n key for the trigger's aria-label (default `userMenu.open`). */
|
|
15131
14975
|
ariaLabelKey?: UserMenuProps['ariaLabelKey']
|
|
15132
14976
|
/** Fallback aria-label (default `Open user menu`). */
|
|
@@ -15162,7 +15006,15 @@ export class UserMenu implements AfterViewInit, OnDestroy {
|
|
|
15162
15006
|
@ViewChild('trigger', { read: ElementRef }) trigger?: ElementRef<HTMLButtonElement>
|
|
15163
15007
|
|
|
15164
15008
|
private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
|
|
15165
|
-
|
|
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
|
+
}
|
|
15166
15018
|
private readonly routeEffect = effect(() => {
|
|
15167
15019
|
const location = this.router.location()
|
|
15168
15020
|
void `${location.pathname}${location.search}`
|
|
@@ -15233,21 +15085,6 @@ export class UserMenu implements AfterViewInit, OnDestroy {
|
|
|
15233
15085
|
if (this.onClick) (this.onClick as (e: MouseEvent) => void)(event)
|
|
15234
15086
|
else this.isOpen.set(true)
|
|
15235
15087
|
}
|
|
15236
|
-
|
|
15237
|
-
/** Adopts the trigger beside the host (React's fragment root). */
|
|
15238
|
-
ngAfterViewInit(): void {
|
|
15239
|
-
const trigger = this.trigger?.nativeElement
|
|
15240
|
-
const host = this.host.nativeElement
|
|
15241
|
-
if (trigger && host.parentNode) {
|
|
15242
|
-
host.parentNode.insertBefore(trigger, host)
|
|
15243
|
-
this.adopted = true
|
|
15244
|
-
}
|
|
15245
|
-
}
|
|
15246
|
-
|
|
15247
|
-
/** Restores the adopted trigger (unmount). */
|
|
15248
|
-
ngOnDestroy(): void {
|
|
15249
|
-
if (this.adopted) this.host.nativeElement.appendChild(this.trigger?.nativeElement as Node)
|
|
15250
|
-
}
|
|
15251
15088
|
}
|
|
15252
15089
|
```
|
|
15253
15090
|
|
|
@@ -15485,9 +15322,14 @@ export class MolIconSvg implements OnChanges {
|
|
|
15485
15322
|
|
|
15486
15323
|
### Functions
|
|
15487
15324
|
|
|
15488
|
-
#### `hasNodes(el)`
|
|
15325
|
+
#### `hasNodes(el)` _(deprecated)_
|
|
15489
15326
|
|
|
15490
|
-
|
|
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.
|
|
15491
15333
|
|
|
15492
15334
|
```typescript
|
|
15493
15335
|
function hasNodes(el: Element | undefined | null): boolean
|
|
@@ -15600,9 +15442,25 @@ function useIsDesktop(query?: string): Signal<boolean>
|
|
|
15600
15442
|
|
|
15601
15443
|
**Returns:** A signal of whether the desktop shell should mount.
|
|
15602
15444
|
|
|
15603
|
-
#### `
|
|
15445
|
+
#### `createDomContext(name)`
|
|
15446
|
+
|
|
15447
|
+
Creates a context (React's `createContext`).
|
|
15604
15448
|
|
|
15605
|
-
|
|
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.
|
|
15606
15464
|
|
|
15607
15465
|
```typescript
|
|
15608
15466
|
function provideDomContext(host: Element, value: unknown): void
|
|
@@ -15611,7 +15469,9 @@ function provideDomContext(host: Element, value: unknown): void
|
|
|
15611
15469
|
- `host` — The provider component's host element.
|
|
15612
15470
|
- `value` — The context value.
|
|
15613
15471
|
|
|
15614
|
-
#### `removeDomContext(host)`
|
|
15472
|
+
#### `removeDomContext(host)` _(deprecated)_
|
|
15473
|
+
|
|
15474
|
+
> **Deprecated:** Use a context of your own: {@link createDomContext}.
|
|
15615
15475
|
|
|
15616
15476
|
Removes a registration (on provider destroy).
|
|
15617
15477
|
|
|
@@ -15621,29 +15481,34 @@ function removeDomContext(host: Element): void
|
|
|
15621
15481
|
|
|
15622
15482
|
- `host` — The provider component's host element.
|
|
15623
15483
|
|
|
15624
|
-
#### `findDomContext(start)`
|
|
15484
|
+
#### `findDomContext(start)` _(deprecated)_
|
|
15625
15485
|
|
|
15626
|
-
|
|
15486
|
+
> **Deprecated:** Use a context of your own: {@link createDomContext}.
|
|
15487
|
+
|
|
15488
|
+
Finds the nearest enclosing value for a consumer's element.
|
|
15627
15489
|
|
|
15628
15490
|
```typescript
|
|
15629
15491
|
function findDomContext<T>(start: Element | null): T | undefined
|
|
15630
15492
|
```
|
|
15631
15493
|
|
|
15632
|
-
- `start` — The consumer's element (its own
|
|
15494
|
+
- `start` — The consumer's element (its own registration is ignored).
|
|
15633
15495
|
|
|
15634
15496
|
**Returns:** The nearest registered value, or `undefined` when there is none.
|
|
15635
15497
|
|
|
15636
|
-
#### `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.
|
|
15637
15501
|
|
|
15638
|
-
Finds the
|
|
15502
|
+
Finds the value registered on the element itself, or else the nearest
|
|
15503
|
+
enclosing one.
|
|
15639
15504
|
|
|
15640
15505
|
```typescript
|
|
15641
15506
|
function findDomContextIncludingSelf<T>(start: Element | null): T | undefined
|
|
15642
15507
|
```
|
|
15643
15508
|
|
|
15644
|
-
- `start` — The element
|
|
15509
|
+
- `start` — The consumer's element.
|
|
15645
15510
|
|
|
15646
|
-
**Returns:** The
|
|
15511
|
+
**Returns:** The registered value, or `undefined` when there is none.
|
|
15647
15512
|
|
|
15648
15513
|
#### `hostElement(host)`
|
|
15649
15514
|
|
|
@@ -15801,6 +15666,19 @@ function isGiven(value: unknown): boolean
|
|
|
15801
15666
|
|
|
15802
15667
|
**Returns:** True when given.
|
|
15803
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
|
+
|
|
15804
15682
|
#### `shallowEqual(a, b)`
|
|
15805
15683
|
|
|
15806
15684
|
Shallow equality (React's `@molecule/app-state` semantics).
|
|
@@ -15870,7 +15748,7 @@ new one. `aria-describedby` is left alone by default: the input family
|
|
|
15870
15748
|
captured the host's value once and merges it with the field context's own
|
|
15871
15749
|
target on its inner binding, so re-moving a re-bound value would erase that
|
|
15872
15750
|
merge. A component that spreads the attribute onto `...rest` with no merge
|
|
15873
|
-
|
|
15751
|
+
passes {@link ReapplyRestAttributesOptions.includeDescribedBy}.
|
|
15874
15752
|
|
|
15875
15753
|
Idempotent: a host with nothing re-bound moves nothing.
|
|
15876
15754
|
|
|
@@ -15978,6 +15856,14 @@ Elements the WAI-ARIA APG dialog pattern treats as tab-stops for the focus trap.
|
|
|
15978
15856
|
const FOCUSABLE_SELECTOR: 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
15979
15857
|
```
|
|
15980
15858
|
|
|
15859
|
+
#### `FormFieldDomContext`
|
|
15860
|
+
|
|
15861
|
+
The context `FormField` registers on its host.
|
|
15862
|
+
|
|
15863
|
+
```typescript
|
|
15864
|
+
const FormFieldDomContext: DomContext<FormFieldContext>
|
|
15865
|
+
```
|
|
15866
|
+
|
|
15981
15867
|
## Injection Notes
|
|
15982
15868
|
|
|
15983
15869
|
### Requirements
|
|
@@ -15987,7 +15873,7 @@ Peer dependencies:
|
|
|
15987
15873
|
- `@angular/common` ^22.0.0
|
|
15988
15874
|
- `@angular/core` ^22.0.0
|
|
15989
15875
|
- `@angular/platform-browser` ^22.0.0
|
|
15990
|
-
- `@molecule/app-angular` ^3.
|
|
15876
|
+
- `@molecule/app-angular` ^3.13.0
|
|
15991
15877
|
- `@molecule/app-i18n` ^1.0.1
|
|
15992
15878
|
- `@molecule/app-icons` ^1.0.1
|
|
15993
15879
|
- `@molecule/app-ui` ^1.5.0
|
|
@@ -16008,9 +15894,9 @@ Peer dependencies:
|
|
|
16008
15894
|
- Components are standalone — add them to the `imports` array of the consuming component or
|
|
16009
15895
|
route; there is no NgModule.
|
|
16010
15896
|
- A component's selector names the native element React renders at its root (an attribute
|
|
16011
|
-
selector such as `button[mol-button]`), so the host IS the root element.
|
|
16012
|
-
React root is a fragment or portal
|
|
16013
|
-
|
|
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.
|
|
16014
15900
|
- Hooks (`useToast`, `usePanelClose`, `useIsDesktop`, `useUserMenuPopoverClose`) are called in
|
|
16015
15901
|
an injection context (a component field initializer or constructor).
|
|
16016
15902
|
- Every component whose React export forwards a ref implements `HasElement`: take it with a
|