@molecule/app-ui-angular 1.4.2 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +987 -1015
- 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 +143 -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 +38 -21
- package/dist/components/modal.component.d.ts.map +1 -1
- package/dist/components/modal.component.js +55 -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 +46 -41
- package/dist/components/responsive-app-shell.component.d.ts.map +1 -1
- package/dist/components/responsive-app-shell.component.js +138 -147
- 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 -30
- package/dist/components/toast.component.d.ts.map +1 -1
- package/dist/components/toast.component.js +74 -84
- package/dist/components/toast.component.js.map +1 -1
- package/dist/components/tooltip.component.d.ts +27 -11
- package/dist/components/tooltip.component.d.ts.map +1 -1
- package/dist/components/tooltip.component.js +62 -47
- package/dist/components/tooltip.component.js.map +1 -1
- package/dist/components/user-menu-popover.component.d.ts +18 -12
- package/dist/components/user-menu-popover.component.d.ts.map +1 -1
- package/dist/components/user-menu-popover.component.js +52 -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-24T08:12:12.486Z
|
|
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
3187
|
|
|
3176
3188
|
/**
|
|
3177
|
-
*
|
|
3178
|
-
*
|
|
3179
|
-
* tracks
|
|
3180
|
-
* template binding reads them.
|
|
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.
|
|
3181
3192
|
*/
|
|
3182
|
-
|
|
3183
|
-
this.
|
|
3184
|
-
this.router.location()
|
|
3185
|
-
this.reconcile()
|
|
3186
|
-
})
|
|
3187
|
-
|
|
3188
|
-
/**
|
|
3189
|
-
* Detects the `loadingFallback` slot and the children (view queries resolve
|
|
3190
|
-
* only by view init).
|
|
3191
|
-
*/
|
|
3192
|
-
ngAfterViewInit(): void {
|
|
3193
|
-
this.hasFallback = hasNodes(this.fallbackWrap?.nativeElement)
|
|
3194
|
-
this.hasChildren = hasNodes(this.childrenWrap?.nativeElement)
|
|
3195
|
-
this.viewReady = true
|
|
3196
|
-
this.reconcile()
|
|
3193
|
+
constructor() {
|
|
3194
|
+
usePlacement((hasContent) => this.reconcile(hasContent))
|
|
3197
3195
|
}
|
|
3198
3196
|
|
|
3199
3197
|
/**
|
|
3200
3198
|
* Applies React's branch for the current auth status and location, fires
|
|
3201
3199
|
* `onAuthenticated` on its rising edge, and redirects once per entry into
|
|
3202
3200
|
* the redirect state.
|
|
3201
|
+
*
|
|
3202
|
+
* @param hasContent - Reads whether a slot has content.
|
|
3203
3203
|
*/
|
|
3204
|
-
private reconcile(): void {
|
|
3204
|
+
private reconcile(hasContent: SlotReader): void {
|
|
3205
|
+
this.hasFallback = hasContent(this.fallbackWrap?.nativeElement)
|
|
3206
|
+
this.hasChildren = hasContent(this.childrenWrap?.nativeElement)
|
|
3207
|
+
this.viewReady = this.childrenWrap !== undefined
|
|
3205
3208
|
const status = this.auth.status()
|
|
3206
3209
|
const authenticated = this.auth.isAuthenticated()
|
|
3207
3210
|
if (this.onAuthenticated && authenticated && !this.lastAuthenticated) this.onAuthenticated()
|
|
@@ -3229,33 +3232,40 @@ export class AuthGuard implements AfterViewInit {
|
|
|
3229
3232
|
/**
|
|
3230
3233
|
* Shows exactly one branch's content, the way React's early returns do.
|
|
3231
3234
|
*
|
|
3235
|
+
* React's branch elements render in front of the host, which leaves the
|
|
3236
|
+
* page; each capture that holds projected content renders that content in its
|
|
3237
|
+
* own place and leaves the page, so the projected nodes are bare, as React
|
|
3238
|
+
* renders them.
|
|
3239
|
+
*
|
|
3232
3240
|
* @param branch - The branch to render.
|
|
3233
3241
|
*/
|
|
3234
3242
|
private renderBranch(branch: 'loading' | 'redirect' | 'children'): void {
|
|
3235
3243
|
const host = this.host.nativeElement as HTMLElement
|
|
3236
|
-
|
|
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
|
|
|
@@ -4957,11 +4948,13 @@ export class Dropdown implements AfterViewInit, DoCheck, OnDestroy, HasElement<H
|
|
|
4957
4948
|
private readonly cdr = inject(ChangeDetectorRef)
|
|
4958
4949
|
private readonly injector = inject(Injector)
|
|
4959
4950
|
private readonly host: HTMLElement = this.el.nativeElement
|
|
4960
|
-
private triggerEl: HTMLElement | null = null
|
|
4951
|
+
private triggerEl: HTMLElement | SVGElement | null = null
|
|
4961
4952
|
private triggerOwnTestId: string | null = null
|
|
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,16 +7312,23 @@ 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
|
|
|
7322
|
+
Projected content is created with the consumer's view, so a closed modal's body and footer exist
|
|
7323
|
+
while hidden: their components, effects and fetches run. React mounts them only while shown, and
|
|
7324
|
+
again each time they show. Write content with state as `*molLazy` (`MolLazy` from
|
|
7325
|
+
`@molecule/app-angular`): it is created when it shows and destroyed when it hides, as React's is.
|
|
7326
|
+
|
|
7350
7327
|
```typescript
|
|
7351
7328
|
@Component({
|
|
7352
7329
|
selector: 'mol-modal',
|
|
7353
7330
|
standalone: true,
|
|
7331
|
+
hostDirectives: [MolPlacement],
|
|
7354
7332
|
imports: [MolIconSvg],
|
|
7355
7333
|
inputs: [
|
|
7356
7334
|
'open',
|
|
@@ -7371,10 +7349,6 @@ the topmost dialog only, reference-counted body scroll lock).
|
|
|
7371
7349
|
'onDoubleClick',
|
|
7372
7350
|
],
|
|
7373
7351
|
outputs: ['close'],
|
|
7374
|
-
host: {
|
|
7375
|
-
'data-parity-unwrap': '',
|
|
7376
|
-
style: 'display: contents',
|
|
7377
|
-
},
|
|
7378
7352
|
template: `<div #overlay [class]="cm().dialogOverlay" aria-hidden="true"></div>
|
|
7379
7353
|
<div
|
|
7380
7354
|
#wrapper
|
|
@@ -7466,16 +7440,18 @@ export class Modal
|
|
|
7466
7440
|
private readonly inner = signal<HTMLDivElement | null>(null)
|
|
7467
7441
|
readonly element = this.inner.asReadonly()
|
|
7468
7442
|
|
|
7443
|
+
constructor() {
|
|
7444
|
+
usePlacement((hasContent) => this.reconcileFooter(hasContent))
|
|
7445
|
+
}
|
|
7446
|
+
|
|
7469
7447
|
private readonly i18n = useTranslation()
|
|
7470
7448
|
|
|
7471
7449
|
private readonly sync = createScrollLock()
|
|
7472
7450
|
private lastOpen = false
|
|
7473
7451
|
private lastFooter = false
|
|
7474
|
-
private footerParent: HTMLElement | null = null
|
|
7475
7452
|
private previouslyFocused: HTMLElement | null = null
|
|
7476
7453
|
private listeners: (() => void)[] = []
|
|
7477
7454
|
private locked = false
|
|
7478
|
-
private moved = false
|
|
7479
7455
|
private externalMolId: string | undefined
|
|
7480
7456
|
|
|
7481
7457
|
cm(): UIClassMap {
|
|
@@ -7526,7 +7502,6 @@ export class Modal
|
|
|
7526
7502
|
const overlay = this.overlay?.nativeElement
|
|
7527
7503
|
const wrapper = this.wrapper?.nativeElement
|
|
7528
7504
|
const dialog = this.dialog?.nativeElement
|
|
7529
|
-
this.footerParent = this.footerSlot?.nativeElement.parentElement ?? null
|
|
7530
7505
|
if (dialog) {
|
|
7531
7506
|
adoptHostDataMolId(
|
|
7532
7507
|
this.host.nativeElement,
|
|
@@ -7536,10 +7511,7 @@ export class Modal
|
|
|
7536
7511
|
},
|
|
7537
7512
|
() => this.molId(),
|
|
7538
7513
|
)
|
|
7539
|
-
moveRestAttributes(this.host.nativeElement, dialog)
|
|
7540
7514
|
}
|
|
7541
|
-
this.lastFooter = this.hasFooter()
|
|
7542
|
-
this.syncFooter()
|
|
7543
7515
|
const open = !!this.open
|
|
7544
7516
|
if (open) {
|
|
7545
7517
|
this.previouslyFocused = (document.activeElement as HTMLElement | null) ?? null
|
|
@@ -7553,15 +7525,12 @@ export class Modal
|
|
|
7553
7525
|
this.syncScrollLock()
|
|
7554
7526
|
this.lastOpen = open
|
|
7555
7527
|
}
|
|
7556
|
-
|
|
7557
7528
|
ngDoCheck(): void {
|
|
7558
7529
|
const open = !!this.open
|
|
7559
7530
|
if (open !== this.lastOpen) {
|
|
7560
7531
|
this.lastOpen = open
|
|
7561
7532
|
this.transition(open)
|
|
7562
7533
|
}
|
|
7563
|
-
this.lastFooter = this.hasFooter()
|
|
7564
|
-
this.syncFooter()
|
|
7565
7534
|
this.syncScrollLock()
|
|
7566
7535
|
}
|
|
7567
7536
|
|
|
@@ -7574,9 +7543,6 @@ export class Modal
|
|
|
7574
7543
|
},
|
|
7575
7544
|
() => this.molId(),
|
|
7576
7545
|
)
|
|
7577
|
-
reapplyRestAttributes(this.host.nativeElement, this.dialog?.nativeElement, {
|
|
7578
|
-
includeDescribedBy: true,
|
|
7579
|
-
})
|
|
7580
7546
|
}
|
|
7581
7547
|
|
|
7582
7548
|
ngOnDestroy(): void {
|
|
@@ -7594,37 +7560,50 @@ export class Modal
|
|
|
7594
7560
|
this.sync.unlock()
|
|
7595
7561
|
this.locked = false
|
|
7596
7562
|
}
|
|
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
7563
|
}
|
|
7606
7564
|
|
|
7607
|
-
private
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
if (node.nodeType === 3 && (node.textContent ?? '').trim()) return true
|
|
7613
|
-
}
|
|
7614
|
-
return false
|
|
7565
|
+
private reconcileFooter(hasContent: SlotReader): void {
|
|
7566
|
+
this.lastFooter = hasContent(this.footerSlot?.nativeElement)
|
|
7567
|
+
setElementPresent(this.footerSlot?.nativeElement, this.lastFooter)
|
|
7568
|
+
setElementPresent(this.host.nativeElement, false)
|
|
7569
|
+
setHostRoot(this.host.nativeElement, this.dialog?.nativeElement, { except: ['data-mol-id'] })
|
|
7615
7570
|
}
|
|
7616
7571
|
|
|
7617
|
-
private
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7572
|
+
private transition(open: boolean): void {
|
|
7573
|
+
if (open) {
|
|
7574
|
+
this.previouslyFocused = (document.activeElement as HTMLElement | null) ?? null
|
|
7575
|
+
pushModalStack(this.stackId)
|
|
7576
|
+
this.attachPortal()
|
|
7577
|
+
this.focusFirstInDialog()
|
|
7578
|
+
this.addListeners()
|
|
7579
|
+
} else {
|
|
7580
|
+
popModalStack(this.stackId)
|
|
7581
|
+
this.removeListeners()
|
|
7582
|
+
this.detachPortal()
|
|
7583
|
+
const toRestore = this.previouslyFocused
|
|
7584
|
+
if (toRestore)
|
|
7585
|
+
afterNextRender(
|
|
7586
|
+
() => {
|
|
7587
|
+
if (document.contains(toRestore)) toRestore.focus()
|
|
7588
|
+
},
|
|
7589
|
+
{ injector: this.injector },
|
|
7590
|
+
)
|
|
7625
7591
|
}
|
|
7592
|
+
this.syncScrollLock()
|
|
7593
|
+
}
|
|
7594
|
+
|
|
7595
|
+
private focusFirstInDialog(): void {
|
|
7596
|
+
afterNextRender(
|
|
7597
|
+
() => {
|
|
7598
|
+
const dialog = this.dialog?.nativeElement
|
|
7599
|
+
if (!dialog) return
|
|
7600
|
+
const focusables = getFocusableElements(dialog)
|
|
7601
|
+
;(focusables[0] ?? dialog).focus()
|
|
7602
|
+
},
|
|
7603
|
+
{ injector: this.injector },
|
|
7604
|
+
)
|
|
7626
7605
|
}
|
|
7627
|
-
// … truncated —
|
|
7606
|
+
// … 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
7607
|
```
|
|
7629
7608
|
|
|
7630
7609
|
_(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 +7807,20 @@ export class MoleculeBadge {
|
|
|
7828
7807
|
|
|
7829
7808
|
Angular Button UI component with UIClassMap-driven styling.
|
|
7830
7809
|
|
|
7810
|
+
React's root is the native `<button>`, so the button element of the
|
|
7811
|
+
template renders in front of the host (`placeElementBefore`) and the host
|
|
7812
|
+
itself leaves the page: the rendered tree is React's, with no wrapper
|
|
7813
|
+
element around the button.
|
|
7814
|
+
|
|
7831
7815
|
```typescript
|
|
7832
7816
|
@Component({
|
|
7833
7817
|
selector: 'mol-button',
|
|
7834
7818
|
standalone: true,
|
|
7835
7819
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
7836
|
-
|
|
7820
|
+
hostDirectives: [MolPlacement],
|
|
7837
7821
|
template: `
|
|
7838
7822
|
<button
|
|
7823
|
+
#root
|
|
7839
7824
|
[type]="type"
|
|
7840
7825
|
[class]="classes"
|
|
7841
7826
|
[style]="style"
|
|
@@ -7874,6 +7859,21 @@ export class MoleculeButton {
|
|
|
7874
7859
|
|
|
7875
7860
|
@Output() handleClick = new EventEmitter<MouseEvent>()
|
|
7876
7861
|
|
|
7862
|
+
/** The native button React renders as the component's root. */
|
|
7863
|
+
@ViewChild('root') root?: ElementRef<HTMLButtonElement>
|
|
7864
|
+
|
|
7865
|
+
private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
|
|
7866
|
+
|
|
7867
|
+
/** Renders the button in front of the host, which leaves the page. */
|
|
7868
|
+
constructor() {
|
|
7869
|
+
usePlacement(() => {
|
|
7870
|
+
const root = this.root?.nativeElement
|
|
7871
|
+
if (!root) return
|
|
7872
|
+
placeElementBefore(root, this.host.nativeElement)
|
|
7873
|
+
setElementPresent(this.host.nativeElement, false)
|
|
7874
|
+
})
|
|
7875
|
+
}
|
|
7876
|
+
|
|
7877
7877
|
/**
|
|
7878
7878
|
* Retrieves the current UI class map.
|
|
7879
7879
|
* @returns The UIClassMap instance for styling.
|
|
@@ -8908,7 +8908,7 @@ Angular Toast UI component with UIClassMap-driven styling.
|
|
|
8908
8908
|
standalone: true,
|
|
8909
8909
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
8910
8910
|
template: `
|
|
8911
|
-
@if (isVisible) {
|
|
8911
|
+
@if (isVisible()) {
|
|
8912
8912
|
<div
|
|
8913
8913
|
role="alert"
|
|
8914
8914
|
data-state="open"
|
|
@@ -8966,7 +8966,8 @@ export class MoleculeToast implements OnInit, OnDestroy {
|
|
|
8966
8966
|
|
|
8967
8967
|
@Output() dismiss = new EventEmitter<void>()
|
|
8968
8968
|
|
|
8969
|
-
|
|
8969
|
+
/** Whether the toast shows; a signal, so the auto-dismiss timer's change renders (OnPush). */
|
|
8970
|
+
readonly isVisible = signal(true)
|
|
8970
8971
|
private timer?: ReturnType<typeof setTimeout>
|
|
8971
8972
|
|
|
8972
8973
|
/**
|
|
@@ -9071,7 +9072,7 @@ export class MoleculeToast implements OnInit, OnDestroy {
|
|
|
9071
9072
|
ngOnInit(): void {
|
|
9072
9073
|
if (this.duration > 0) {
|
|
9073
9074
|
this.timer = setTimeout(() => {
|
|
9074
|
-
this.isVisible
|
|
9075
|
+
this.isVisible.set(false)
|
|
9075
9076
|
this.dismiss.emit()
|
|
9076
9077
|
}, this.duration)
|
|
9077
9078
|
}
|
|
@@ -9090,7 +9091,7 @@ export class MoleculeToast implements OnInit, OnDestroy {
|
|
|
9090
9091
|
* Handles the dismiss action by hiding the toast.
|
|
9091
9092
|
*/
|
|
9092
9093
|
onDismiss(): void {
|
|
9093
|
-
this.isVisible
|
|
9094
|
+
this.isVisible.set(false)
|
|
9094
9095
|
this.dismiss.emit()
|
|
9095
9096
|
}
|
|
9096
9097
|
}
|
|
@@ -9119,7 +9120,7 @@ a small themed pointer at the resolved `placement` edge.
|
|
|
9119
9120
|
>
|
|
9120
9121
|
<ng-content></ng-content>
|
|
9121
9122
|
</div>
|
|
9122
|
-
@if (isVisible) {
|
|
9123
|
+
@if (isVisible()) {
|
|
9123
9124
|
<!--
|
|
9124
9125
|
Outer positioned wrapper carries the top/left/z-index placement; the
|
|
9125
9126
|
arrow renders as its SIBLING (not nested inside the visible box),
|
|
@@ -9127,7 +9128,7 @@ a small themed pointer at the resolved `placement` edge.
|
|
|
9127
9128
|
past the box's own edge would be clipped invisible if it were a
|
|
9128
9129
|
descendant of that element instead.
|
|
9129
9130
|
-->
|
|
9130
|
-
<div [style]="positionStyle">
|
|
9131
|
+
<div [style]="positionStyle()">
|
|
9131
9132
|
<div
|
|
9132
9133
|
#tooltipEl
|
|
9133
9134
|
role="tooltip"
|
|
@@ -9160,8 +9161,10 @@ export class MoleculeTooltip implements OnDestroy {
|
|
|
9160
9161
|
@ViewChild('trigger') triggerRef?: ElementRef<HTMLDivElement>
|
|
9161
9162
|
@ViewChild('tooltipEl') tooltipRef?: ElementRef<HTMLDivElement>
|
|
9162
9163
|
|
|
9163
|
-
|
|
9164
|
-
|
|
9164
|
+
/** Whether the tooltip shows; a signal, so the delay timer's change renders (OnPush). */
|
|
9165
|
+
readonly isVisible = signal(false)
|
|
9166
|
+
/** The measured placement; a signal, so the animation frame's measurement renders (OnPush). */
|
|
9167
|
+
readonly positionStyle = signal<Record<string, string>>({})
|
|
9165
9168
|
private timeoutId?: ReturnType<typeof setTimeout>
|
|
9166
9169
|
|
|
9167
9170
|
/**
|
|
@@ -9194,11 +9197,12 @@ export class MoleculeTooltip implements OnDestroy {
|
|
|
9194
9197
|
show(): void {
|
|
9195
9198
|
if (this.delay > 0) {
|
|
9196
9199
|
this.timeoutId = setTimeout(() => {
|
|
9197
|
-
this.isVisible
|
|
9198
|
-
|
|
9200
|
+
this.isVisible.set(true)
|
|
9201
|
+
// Measured once the tooltip has rendered.
|
|
9202
|
+
requestAnimationFrame(() => this.updatePosition())
|
|
9199
9203
|
}, this.delay)
|
|
9200
9204
|
} else {
|
|
9201
|
-
this.isVisible
|
|
9205
|
+
this.isVisible.set(true)
|
|
9202
9206
|
requestAnimationFrame(() => this.updatePosition())
|
|
9203
9207
|
}
|
|
9204
9208
|
}
|
|
@@ -9210,7 +9214,7 @@ export class MoleculeTooltip implements OnDestroy {
|
|
|
9210
9214
|
if (this.timeoutId) {
|
|
9211
9215
|
clearTimeout(this.timeoutId)
|
|
9212
9216
|
}
|
|
9213
|
-
this.isVisible
|
|
9217
|
+
this.isVisible.set(false)
|
|
9214
9218
|
}
|
|
9215
9219
|
|
|
9216
9220
|
/**
|
|
@@ -9272,12 +9276,12 @@ export class MoleculeTooltip implements OnDestroy {
|
|
|
9272
9276
|
}
|
|
9273
9277
|
|
|
9274
9278
|
const pos = positions[this.placement]
|
|
9275
|
-
this.positionStyle
|
|
9279
|
+
this.positionStyle.set({
|
|
9276
9280
|
position: 'absolute',
|
|
9277
9281
|
top: `${pos.top}px`,
|
|
9278
9282
|
left: `${pos.left}px`,
|
|
9279
9283
|
zIndex: '9999',
|
|
9280
|
-
}
|
|
9284
|
+
})
|
|
9281
9285
|
}
|
|
9282
9286
|
}
|
|
9283
9287
|
```
|
|
@@ -9296,6 +9300,7 @@ one is shown, moved onto the button with no wrapper, matching React's
|
|
|
9296
9300
|
@Component({
|
|
9297
9301
|
selector: 'button[mol-optimistic-toggle-button]',
|
|
9298
9302
|
standalone: true,
|
|
9303
|
+
hostDirectives: [MolPlacement],
|
|
9299
9304
|
imports: [MolTemplateOutlet],
|
|
9300
9305
|
inputs: [
|
|
9301
9306
|
'value',
|
|
@@ -9317,6 +9322,7 @@ one is shown, moved onto the button with no wrapper, matching React's
|
|
|
9317
9322
|
'dataMolId: data-mol-id',
|
|
9318
9323
|
],
|
|
9319
9324
|
host: {
|
|
9325
|
+
// `value` is the loaded server state, which React keeps off the <button>; Angular would also keep
|
|
9320
9326
|
// a static `value="…"` on the host as the button's form value.
|
|
9321
9327
|
'[attr.value]': 'null',
|
|
9322
9328
|
'[class]': 'classes()',
|
|
@@ -9347,9 +9353,7 @@ one is shown, moved onto the button with no wrapper, matching React's
|
|
|
9347
9353
|
>{{ nodeText(rightIcon) }}</span
|
|
9348
9354
|
>`,
|
|
9349
9355
|
})
|
|
9350
|
-
export class OptimisticToggleButton
|
|
9351
|
-
implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTMLButtonElement>
|
|
9352
|
-
{
|
|
9356
|
+
export class OptimisticToggleButton implements DoCheck, OnDestroy, HasElement<HTMLButtonElement> {
|
|
9353
9357
|
/** The loaded server value. */
|
|
9354
9358
|
value: OptimisticToggleButtonProps['value'] = false
|
|
9355
9359
|
/** Saves the desired boolean and returns the server-confirmed boolean. */
|
|
@@ -9358,6 +9362,7 @@ export class OptimisticToggleButton
|
|
|
9358
9362
|
activeLabel!: OptimisticToggleButtonProps['activeLabel']
|
|
9359
9363
|
/** Label when the displayed value is false (node-valued prop). */
|
|
9360
9364
|
inactiveLabel!: OptimisticToggleButtonProps['inactiveLabel']
|
|
9365
|
+
/** Receives a failed save after the controller has restored the last confirmed value. */
|
|
9361
9366
|
onError?: OptimisticToggleButtonProps['onError']
|
|
9362
9367
|
/** Button variant. */
|
|
9363
9368
|
variant?: OptimisticToggleButtonProps['variant']
|
|
@@ -9379,7 +9384,9 @@ export class OptimisticToggleButton
|
|
|
9379
9384
|
testId?: OptimisticToggleButtonProps['testId']
|
|
9380
9385
|
/** Disables the button (permissions, never a pending save). */
|
|
9381
9386
|
disabled?: OptimisticToggleButtonProps['disabled'] = false
|
|
9387
|
+
/** `data-mol-id` automation id (React's `automationId`; default `optimistic-toggle`). */
|
|
9382
9388
|
automationId?: OptimisticToggleButtonProps['automationId']
|
|
9389
|
+
/** A `data-mol-id` given as a plain rest attribute (React's `rootProps` precedence). */
|
|
9383
9390
|
dataMolId?: string
|
|
9384
9391
|
|
|
9385
9392
|
/** Template helpers (templates see only class members). */
|
|
@@ -9389,6 +9396,7 @@ export class OptimisticToggleButton
|
|
|
9389
9396
|
|
|
9390
9397
|
/** The optimistic controller. */
|
|
9391
9398
|
private readonly controller: OptimisticValue<boolean>
|
|
9399
|
+
/** The controller state (a signal so the zoneless view re-checks on every publish). */
|
|
9392
9400
|
readonly state = signal<OptimisticValueState<boolean>>({
|
|
9393
9401
|
value: false,
|
|
9394
9402
|
pending: false,
|
|
@@ -9407,15 +9415,12 @@ export class OptimisticToggleButton
|
|
|
9407
9415
|
private readonly host: ElementRef<HTMLButtonElement> = inject(ElementRef)
|
|
9408
9416
|
/** The element a caller's ref receives: the host `<button>`. */
|
|
9409
9417
|
readonly element = hostElement(this.host)
|
|
9410
|
-
private readonly renderer = inject(Renderer2)
|
|
9411
|
-
private readonly sync = new SlotWrapper(this.host, this.renderer)
|
|
9412
9418
|
private unsubscribe?: () => void
|
|
9413
9419
|
private lastReceived = false
|
|
9414
9420
|
private hasLeft = false
|
|
9415
9421
|
private hasRight = false
|
|
9416
|
-
|
|
9422
|
+
/** The slot whose content is currently shown on the button. */
|
|
9417
9423
|
private visibleFrom: HTMLSpanElement | null = null
|
|
9418
|
-
private anchor: Comment | null = null
|
|
9419
9424
|
|
|
9420
9425
|
/** Creates the optimistic controller and mirrors its state into the signal. */
|
|
9421
9426
|
constructor() {
|
|
@@ -9426,6 +9431,7 @@ export class OptimisticToggleButton
|
|
|
9426
9431
|
})
|
|
9427
9432
|
this.unsubscribe = this.controller.subscribe((next) => this.state.set({ ...next }))
|
|
9428
9433
|
this.state.set(this.controller.getState())
|
|
9434
|
+
usePlacement((hasContent) => this.reconcile(hasContent))
|
|
9429
9435
|
}
|
|
9430
9436
|
|
|
9431
9437
|
/** The current class map. */
|
|
@@ -9465,13 +9471,14 @@ export class OptimisticToggleButton
|
|
|
9465
9471
|
this.controller.update((current) => !current)
|
|
9466
9472
|
}
|
|
9467
9473
|
|
|
9468
|
-
|
|
9469
|
-
|
|
9470
|
-
this.
|
|
9471
|
-
this.
|
|
9472
|
-
|
|
9473
|
-
|
|
9474
|
-
|
|
9474
|
+
/** Reads slot presence and takes the label capture spans out of the DOM, then shows the visible label. */
|
|
9475
|
+
private reconcile(hasContent: SlotReader): void {
|
|
9476
|
+
this.hasLeft = hasContent(this.leftSlot?.nativeElement)
|
|
9477
|
+
this.hasRight = hasContent(this.rightSlot?.nativeElement)
|
|
9478
|
+
setElementPresent(this.activeSlot?.nativeElement, false)
|
|
9479
|
+
setElementPresent(this.inactiveSlot?.nativeElement, false)
|
|
9480
|
+
setElementPresent(this.leftSlot?.nativeElement, this.hasLeft)
|
|
9481
|
+
setElementPresent(this.rightSlot?.nativeElement, this.hasRight)
|
|
9475
9482
|
this.syncLabels()
|
|
9476
9483
|
}
|
|
9477
9484
|
|
|
@@ -9480,53 +9487,30 @@ export class OptimisticToggleButton
|
|
|
9480
9487
|
this.lastReceived = this.value
|
|
9481
9488
|
this.controller.sync(this.value)
|
|
9482
9489
|
}
|
|
9483
|
-
this.syncLabels()
|
|
9484
9490
|
}
|
|
9485
9491
|
|
|
9486
9492
|
/** Stops mirroring controller state into the signal (unmount). */
|
|
9487
9493
|
ngOnDestroy(): void {
|
|
9488
9494
|
this.unsubscribe?.()
|
|
9489
|
-
this.visibleNodes = []
|
|
9490
|
-
this.visibleFrom = null
|
|
9491
9495
|
}
|
|
9492
9496
|
|
|
9493
9497
|
private syncLabels(): void {
|
|
9494
9498
|
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
|
|
9499
|
+
const shown = state.value
|
|
9500
|
+
? (this.activeSlot?.nativeElement ?? null)
|
|
9501
|
+
: (this.inactiveSlot?.nativeElement ?? null)
|
|
9502
|
+
const hidden = state.value
|
|
9503
|
+
? (this.inactiveSlot?.nativeElement ?? null)
|
|
9504
|
+
: (this.activeSlot?.nativeElement ?? null)
|
|
9505
|
+
if (hidden) placeContent(hidden, null)
|
|
9506
|
+
// The label goes before the right icon's place (its placeholder while the
|
|
9507
|
+
// icon is absent, which placeContent resolves), else at the end.
|
|
9508
|
+
if (shown) placeContent(shown, this.host.nativeElement, this.rightSlot?.nativeElement ?? null)
|
|
9525
9509
|
}
|
|
9526
9510
|
}
|
|
9527
9511
|
```
|
|
9528
9512
|
|
|
9529
|
-
_(Member comments are shortened to their first sentence, and the
|
|
9513
|
+
_(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
9514
|
|
|
9531
9515
|
#### `PageHeader`
|
|
9532
9516
|
|
|
@@ -9542,6 +9526,7 @@ from the DOM — the projected nodes need an always-mounted capture point.
|
|
|
9542
9526
|
@Component({
|
|
9543
9527
|
selector: 'div[mol-page-header]',
|
|
9544
9528
|
standalone: true,
|
|
9529
|
+
hostDirectives: [MolPlacement],
|
|
9545
9530
|
inputs: ['title', 'description', 'breadcrumbs', 'className', 'style', 'testId', 'automationId'],
|
|
9546
9531
|
host: {
|
|
9547
9532
|
// `title` is this component's heading, which React renders as text; Angular would also keep a
|
|
@@ -9578,7 +9563,7 @@ from the DOM — the projected nodes need an always-mounted capture point.
|
|
|
9578
9563
|
</div>
|
|
9579
9564
|
</div>`,
|
|
9580
9565
|
})
|
|
9581
|
-
export class PageHeader implements
|
|
9566
|
+
export class PageHeader implements HasElement<HTMLDivElement> {
|
|
9582
9567
|
/** Page title. */
|
|
9583
9568
|
title = ''
|
|
9584
9569
|
/** Page description. */
|
|
@@ -9604,12 +9589,15 @@ export class PageHeader implements AfterViewInit, DoCheck, HasElement<HTMLDivEle
|
|
|
9604
9589
|
*/
|
|
9605
9590
|
private readonly i18n = useTranslation()
|
|
9606
9591
|
|
|
9607
|
-
private readonly sync = new SlotWrapper(inject(ElementRef), inject(Renderer2))
|
|
9608
9592
|
private readonly host: ElementRef<HTMLDivElement> = inject(ElementRef)
|
|
9609
9593
|
/** The element a caller's ref receives: the host `<div>`. */
|
|
9610
9594
|
readonly element = hostElement(this.host)
|
|
9611
9595
|
private hasActions = false
|
|
9612
|
-
|
|
9596
|
+
|
|
9597
|
+
/** Applies React's `{actions ? <div>…</div> : null}`. */
|
|
9598
|
+
constructor() {
|
|
9599
|
+
usePlacement((hasContent) => this.syncActions(hasContent))
|
|
9600
|
+
}
|
|
9613
9601
|
|
|
9614
9602
|
/**
|
|
9615
9603
|
* The current class map.
|
|
@@ -9643,31 +9631,14 @@ export class PageHeader implements AfterViewInit, DoCheck, HasElement<HTMLDivEle
|
|
|
9643
9631
|
return styleText(this.style)
|
|
9644
9632
|
}
|
|
9645
9633
|
|
|
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
9634
|
/**
|
|
9663
9635
|
* Applies React's `{actions ? <div>…</div> : null}`.
|
|
9636
|
+
*
|
|
9637
|
+
* @param hasContent - Reads whether a slot has content.
|
|
9664
9638
|
*/
|
|
9665
|
-
private syncActions(): void {
|
|
9666
|
-
this.
|
|
9667
|
-
|
|
9668
|
-
this.hasActions,
|
|
9669
|
-
this.actionsParent ?? undefined,
|
|
9670
|
-
)
|
|
9639
|
+
private syncActions(hasContent: SlotReader): void {
|
|
9640
|
+
this.hasActions = hasContent(this.actionsSlot?.nativeElement)
|
|
9641
|
+
setElementPresent(this.actionsSlot?.nativeElement, this.hasActions)
|
|
9671
9642
|
}
|
|
9672
9643
|
}
|
|
9673
9644
|
```
|
|
@@ -9690,6 +9661,7 @@ The sidebar toggle button renders only when the caller passed
|
|
|
9690
9661
|
@Component({
|
|
9691
9662
|
selector: 'div[mol-page-shell]',
|
|
9692
9663
|
standalone: true,
|
|
9664
|
+
hostDirectives: [MolPlacement],
|
|
9693
9665
|
inputs: ['sidebar', 'topbar', 'sidebarCollapsed', 'className', 'style', 'testId', 'automationId'],
|
|
9694
9666
|
outputs: ['sidebarToggle'],
|
|
9695
9667
|
host: {
|
|
@@ -9718,7 +9690,7 @@ The sidebar toggle button renders only when the caller passed
|
|
|
9718
9690
|
<main [class]="cm().pageShellContent"><ng-content></ng-content></main>
|
|
9719
9691
|
</div>`,
|
|
9720
9692
|
})
|
|
9721
|
-
export class PageShell implements
|
|
9693
|
+
export class PageShell implements HasElement<HTMLDivElement> {
|
|
9722
9694
|
/** Sidebar content (node-valued prop). */
|
|
9723
9695
|
sidebar?: unknown
|
|
9724
9696
|
/** Top bar content (node-valued prop). */
|
|
@@ -9749,14 +9721,16 @@ export class PageShell implements AfterViewInit, DoCheck, HasElement<HTMLDivElem
|
|
|
9749
9721
|
*/
|
|
9750
9722
|
private readonly i18n = useTranslation()
|
|
9751
9723
|
|
|
9752
|
-
private readonly sync = new SlotWrapper(inject(ElementRef), inject(Renderer2))
|
|
9753
9724
|
private readonly host: ElementRef<HTMLDivElement> = inject(ElementRef)
|
|
9754
9725
|
/** The element a caller's ref receives: the host `<div>`. */
|
|
9755
9726
|
readonly element = hostElement(this.host)
|
|
9756
9727
|
private hasSidebar = false
|
|
9757
9728
|
private hasTopbar = false
|
|
9758
|
-
|
|
9759
|
-
|
|
9729
|
+
|
|
9730
|
+
/** Applies React's `{sidebar ? … : null}` / `{topbar ? … : null}`. */
|
|
9731
|
+
constructor() {
|
|
9732
|
+
usePlacement((hasContent) => this.syncWrappers(hasContent))
|
|
9733
|
+
}
|
|
9760
9734
|
|
|
9761
9735
|
/**
|
|
9762
9736
|
* The current class map.
|
|
@@ -9812,34 +9786,16 @@ export class PageShell implements AfterViewInit, DoCheck, HasElement<HTMLDivElem
|
|
|
9812
9786
|
return styleText(this.style)
|
|
9813
9787
|
}
|
|
9814
9788
|
|
|
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
9789
|
/**
|
|
9834
9790
|
* Applies React's `{sidebar ? … : null}` / `{topbar ? … : null}`.
|
|
9791
|
+
*
|
|
9792
|
+
* @param hasContent - Reads whether a slot has content.
|
|
9835
9793
|
*/
|
|
9836
|
-
private syncWrappers(): void {
|
|
9837
|
-
this.
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
)
|
|
9842
|
-
this.sync.sync(this.topbarSlot?.nativeElement, this.hasTopbar, this.topbarParent ?? undefined)
|
|
9794
|
+
private syncWrappers(hasContent: SlotReader): void {
|
|
9795
|
+
this.hasSidebar = hasContent(this.sidebarSlot?.nativeElement)
|
|
9796
|
+
this.hasTopbar = hasContent(this.topbarSlot?.nativeElement)
|
|
9797
|
+
setElementPresent(this.sidebarSlot?.nativeElement, this.hasSidebar)
|
|
9798
|
+
setElementPresent(this.topbarSlot?.nativeElement, this.hasTopbar)
|
|
9843
9799
|
}
|
|
9844
9800
|
}
|
|
9845
9801
|
```
|
|
@@ -10159,19 +10115,19 @@ export class Pagination implements HasElement<HTMLElement> {
|
|
|
10159
10115
|
Provides the drawer-close callback to descendants.
|
|
10160
10116
|
|
|
10161
10117
|
Rendered internally by `UserMenu` and `SidebarUserCard` around their panel
|
|
10162
|
-
content; apps do not normally render it directly.
|
|
10163
|
-
|
|
10164
|
-
|
|
10118
|
+
content; apps do not normally render it directly. React's context provider
|
|
10119
|
+
renders its children and no DOM of its own, so the projected children
|
|
10120
|
+
render in front of the host (`placeContentBefore`) and the host itself
|
|
10121
|
+
leaves the page. The context is registered on the parent element — the one
|
|
10122
|
+
whose child list the content now belongs to — so a consumer in the content
|
|
10123
|
+
still resolves it from its DOM ancestors.
|
|
10165
10124
|
|
|
10166
10125
|
```typescript
|
|
10167
10126
|
@Component({
|
|
10168
10127
|
selector: 'mol-panel-close-provider',
|
|
10169
10128
|
standalone: true,
|
|
10129
|
+
hostDirectives: [MolPlacement],
|
|
10170
10130
|
inputs: ['close'],
|
|
10171
|
-
host: {
|
|
10172
|
-
'data-parity-unwrap': '',
|
|
10173
|
-
style: 'display: contents',
|
|
10174
|
-
},
|
|
10175
10131
|
template: `<ng-content></ng-content>`,
|
|
10176
10132
|
})
|
|
10177
10133
|
export class PanelCloseProvider implements OnDestroy {
|
|
@@ -10179,14 +10135,22 @@ export class PanelCloseProvider implements OnDestroy {
|
|
|
10179
10135
|
close?: PanelCloseProviderProps['close']
|
|
10180
10136
|
|
|
10181
10137
|
private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
|
|
10182
|
-
/**
|
|
10138
|
+
/** The value consumers read; its closure keeps the CURRENT `close` prop. */
|
|
10139
|
+
private readonly value = { close: (): void => this.close?.() }
|
|
10140
|
+
|
|
10141
|
+
/** Renders the children in front of the host and registers the context where they render. */
|
|
10183
10142
|
constructor() {
|
|
10184
|
-
|
|
10143
|
+
const host = this.host.nativeElement
|
|
10144
|
+
PanelCloseDomContext.provide(host, this.value)
|
|
10145
|
+
usePlacement(() => {
|
|
10146
|
+
placeContentBefore(host, host)
|
|
10147
|
+
setElementPresent(host, false)
|
|
10148
|
+
})
|
|
10185
10149
|
}
|
|
10186
10150
|
|
|
10187
10151
|
/** Removes the context registration (unmount). */
|
|
10188
10152
|
ngOnDestroy(): void {
|
|
10189
|
-
|
|
10153
|
+
PanelCloseDomContext.remove(this.host.nativeElement)
|
|
10190
10154
|
}
|
|
10191
10155
|
}
|
|
10192
10156
|
```
|
|
@@ -10383,13 +10347,15 @@ PromptDialog component.
|
|
|
10383
10347
|
|
|
10384
10348
|
Composed from `Modal`, `Input` and `Button` exactly as React composes
|
|
10385
10349
|
them. Resolving `onSubmit` closes the dialog and resets it; a rejection
|
|
10386
|
-
keeps it open with the value intact.
|
|
10387
|
-
|
|
10350
|
+
keeps it open with the value intact. React's root is a `Modal`, which
|
|
10351
|
+
renders a portal while open and nothing while closed, so the host element
|
|
10352
|
+
leaves the page and the portal renders in `document.body`.
|
|
10388
10353
|
|
|
10389
10354
|
```typescript
|
|
10390
10355
|
@Component({
|
|
10391
10356
|
selector: 'mol-prompt-dialog',
|
|
10392
10357
|
standalone: true,
|
|
10358
|
+
hostDirectives: [MolPlacement],
|
|
10393
10359
|
imports: [Button, Input, Modal, MolTemplateOutlet],
|
|
10394
10360
|
inputs: [
|
|
10395
10361
|
'open',
|
|
@@ -10406,20 +10372,17 @@ keeps it open with the value intact. The host is unwrapped
|
|
|
10406
10372
|
'cancelMolId',
|
|
10407
10373
|
],
|
|
10408
10374
|
outputs: ['close'],
|
|
10409
|
-
host: {
|
|
10410
|
-
'data-parity-unwrap': '',
|
|
10411
|
-
style: 'display: contents',
|
|
10412
|
-
},
|
|
10413
10375
|
template: `<mol-modal
|
|
10376
|
+
#modal
|
|
10414
10377
|
[open]="open"
|
|
10415
10378
|
(close)="onModalClose()"
|
|
10416
|
-
[attr.aria-labelledby]="
|
|
10417
|
-
[attr.aria-describedby]="
|
|
10379
|
+
[attr.aria-labelledby]="ariaLabelledBy()"
|
|
10380
|
+
[attr.aria-describedby]="rendersNode(description) ? descriptionId : null"
|
|
10418
10381
|
><form (submit)="handleSubmit($event)">
|
|
10419
10382
|
<div [class]="cm().stack(3)">
|
|
10420
10383
|
<h2
|
|
10421
10384
|
#titleSlot
|
|
10422
|
-
[attr.id]="
|
|
10385
|
+
[attr.id]="ariaLabelledBy()"
|
|
10423
10386
|
[class]="cm().cn(cm().textSize('lg'), cm().fontWeight('bold'))"
|
|
10424
10387
|
>
|
|
10425
10388
|
@if (isGiven(title)) {
|
|
@@ -10433,7 +10396,7 @@ keeps it open with the value intact. The host is unwrapped
|
|
|
10433
10396
|
<p [attr.id]="descriptionId" [class]="cm().textSize('sm')">
|
|
10434
10397
|
<ng-container [molTemplateOutlet]="descriptionTemplate"></ng-container>
|
|
10435
10398
|
</p>
|
|
10436
|
-
} @else if (
|
|
10399
|
+
} @else if (rendersNode(description)) {
|
|
10437
10400
|
<p
|
|
10438
10401
|
[attr.id]="descriptionId"
|
|
10439
10402
|
[class]="cm().textSize('sm')"
|
|
@@ -10489,19 +10452,13 @@ export class PromptDialog implements AfterViewInit, AfterViewChecked, DoCheck {
|
|
|
10489
10452
|
open: PromptDialogProps['open'] = false
|
|
10490
10453
|
/** Dialog heading (node-valued prop). */
|
|
10491
10454
|
title?: PromptDialogProps['title']
|
|
10492
|
-
/** Explanatory line under the title (node-valued prop). */
|
|
10493
10455
|
description?: PromptDialogProps['description']
|
|
10494
10456
|
/** Input placeholder. */
|
|
10495
10457
|
placeholder?: PromptDialogProps['placeholder']
|
|
10496
|
-
/** Value the input starts from every time the dialog opens. */
|
|
10497
10458
|
initialValue?: PromptDialogProps['initialValue'] = ''
|
|
10498
|
-
/** Called with the entered value on confirm. */
|
|
10499
10459
|
onSubmit?: PromptDialogProps['onSubmit']
|
|
10500
|
-
/** Confirm-button label (node-valued prop). */
|
|
10501
10460
|
confirmLabel?: PromptDialogProps['confirmLabel']
|
|
10502
|
-
/** Cancel-button label (node-valued prop). */
|
|
10503
10461
|
cancelLabel?: PromptDialogProps['cancelLabel']
|
|
10504
|
-
/** Renders the confirm button in the error color. */
|
|
10505
10462
|
destructive?: PromptDialogProps['destructive'] = false
|
|
10506
10463
|
/** `data-mol-id` for the text input. */
|
|
10507
10464
|
inputMolId?: PromptDialogProps['inputMolId']
|
|
@@ -10510,35 +10467,49 @@ export class PromptDialog implements AfterViewInit, AfterViewChecked, DoCheck {
|
|
|
10510
10467
|
/** `data-mol-id` for the cancel button. */
|
|
10511
10468
|
cancelMolId?: PromptDialogProps['cancelMolId']
|
|
10512
10469
|
|
|
10513
|
-
/** Template helpers (templates see only class members). */
|
|
10514
10470
|
readonly asTemplate = asTemplate
|
|
10515
|
-
/** Renders a plain-string/number node value. */
|
|
10516
10471
|
readonly nodeText = nodeText
|
|
10517
10472
|
/** Whether a node-valued prop was given. */
|
|
10518
10473
|
readonly isGiven = isGiven
|
|
10474
|
+
readonly rendersNode = rendersNode
|
|
10519
10475
|
|
|
10520
10476
|
@Output() readonly close = new EventEmitter<unknown>()
|
|
10521
10477
|
|
|
10522
10478
|
@ViewChild('titleSlot') titleSlot?: ElementRef<HTMLHeadingElement>
|
|
10523
10479
|
@ViewChild(Input) inputComponent?: Input
|
|
10480
|
+
@ViewChild('modal', { read: ElementRef }) modalElement?: ElementRef<HTMLElement>
|
|
10524
10481
|
|
|
10525
10482
|
readonly titleId = nextInstanceId()
|
|
10526
10483
|
|
|
10527
10484
|
readonly descriptionId = nextInstanceId()
|
|
10528
10485
|
|
|
10486
|
+
readonly ariaLabelledBy = signal<string | null>(null)
|
|
10487
|
+
|
|
10529
10488
|
/** The current input value. */
|
|
10530
10489
|
readonly value = signal('')
|
|
10531
10490
|
/** Whether a submit is in flight. */
|
|
10532
10491
|
readonly pending = signal(false)
|
|
10533
10492
|
|
|
10534
|
-
/** Reactive translation, read in the injection context. */
|
|
10535
10493
|
private readonly i18n = useTranslation()
|
|
10536
10494
|
|
|
10495
|
+
private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
|
|
10496
|
+
|
|
10537
10497
|
private lastOpen = false
|
|
10538
10498
|
private lastInitial = ''
|
|
10539
10499
|
private pendingInputFocus = false
|
|
10540
10500
|
private readonly injector = inject(Injector)
|
|
10541
10501
|
|
|
10502
|
+
constructor() {
|
|
10503
|
+
usePlacement((hasContent) => {
|
|
10504
|
+
setElementPresent(this.host.nativeElement, false)
|
|
10505
|
+
setHostRoot(this.host.nativeElement, this.modalElement?.nativeElement)
|
|
10506
|
+
this.ariaLabelledBy.set(
|
|
10507
|
+
rendersNode(this.title) || hasContent(this.titleSlot?.nativeElement) ? this.titleId : null,
|
|
10508
|
+
)
|
|
10509
|
+
this.applyInputLabel(hasContent)
|
|
10510
|
+
})
|
|
10511
|
+
}
|
|
10512
|
+
|
|
10542
10513
|
/** The current class map. */
|
|
10543
10514
|
cm(): UIClassMap {
|
|
10544
10515
|
return getClassMap()
|
|
@@ -10558,24 +10529,27 @@ export class PromptDialog implements AfterViewInit, AfterViewChecked, DoCheck {
|
|
|
10558
10529
|
: this.i18n.t('prompt.confirm', {}, { defaultValue: 'Confirm' })
|
|
10559
10530
|
}
|
|
10560
10531
|
|
|
10561
|
-
inputLabel(): string | null {
|
|
10562
|
-
const
|
|
10563
|
-
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
|
|
10532
|
+
inputLabel(hasContent: SlotReader): string | null {
|
|
10533
|
+
const heading = this.titleSlot?.nativeElement
|
|
10534
|
+
const nodes = isGiven(this.title)
|
|
10535
|
+
? Array.from(heading?.childNodes ?? [])
|
|
10536
|
+
: hasContent.nodes(heading)
|
|
10537
|
+
const hasElement = nodes.some((node) => node.nodeType === Node.ELEMENT_NODE)
|
|
10538
|
+
const text = nodes
|
|
10539
|
+
.filter((node) => node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.TEXT_NODE)
|
|
10540
|
+
.map((node) => node.textContent ?? '')
|
|
10541
|
+
.join('')
|
|
10542
|
+
.trim()
|
|
10543
|
+
if (!hasElement && text) return text
|
|
10568
10544
|
return this.placeholder ?? null
|
|
10569
10545
|
}
|
|
10570
10546
|
|
|
10571
10547
|
ngAfterViewInit(): void {
|
|
10572
|
-
this.applyInputLabel()
|
|
10573
10548
|
this.lastOpen = !!this.open
|
|
10574
10549
|
this.lastInitial = this.initialValue ?? ''
|
|
10575
10550
|
if (this.open) {
|
|
10576
10551
|
this.value.set(this.initialValue ?? '')
|
|
10577
10552
|
this.pending.set(false)
|
|
10578
|
-
// input — after the Modal has focused the dialog's first control.
|
|
10579
10553
|
this.pendingInputFocus = true
|
|
10580
10554
|
}
|
|
10581
10555
|
}
|
|
@@ -10588,7 +10562,6 @@ export class PromptDialog implements AfterViewInit, AfterViewChecked, DoCheck {
|
|
|
10588
10562
|
|
|
10589
10563
|
ngDoCheck(): void {
|
|
10590
10564
|
const open = !!this.open
|
|
10591
|
-
this.applyInputLabel()
|
|
10592
10565
|
if (open !== this.lastOpen || (open && this.initialValue !== this.lastInitial)) {
|
|
10593
10566
|
this.lastOpen = open
|
|
10594
10567
|
this.lastInitial = this.initialValue ?? ''
|
|
@@ -10604,15 +10577,14 @@ export class PromptDialog implements AfterViewInit, AfterViewChecked, DoCheck {
|
|
|
10604
10577
|
this.inputComponent?.inputEl?.nativeElement.focus()
|
|
10605
10578
|
}
|
|
10606
10579
|
|
|
10607
|
-
private applyInputLabel(): void {
|
|
10580
|
+
private applyInputLabel(hasContent: SlotReader): void {
|
|
10608
10581
|
const input = this.inputComponent?.inputEl?.nativeElement
|
|
10609
10582
|
if (!input) return
|
|
10610
|
-
const label = this.inputLabel()
|
|
10583
|
+
const label = this.inputLabel(hasContent)
|
|
10611
10584
|
if (label === null) input.removeAttribute('aria-label')
|
|
10612
10585
|
else input.setAttribute('aria-label', label)
|
|
10613
10586
|
}
|
|
10614
10587
|
|
|
10615
|
-
/** Tracks the typed value (React's controlled `onChange`). */
|
|
10616
10588
|
onInput(event: Event): void {
|
|
10617
10589
|
this.value.set((event.target as HTMLInputElement).value)
|
|
10618
10590
|
}
|
|
@@ -10632,15 +10604,13 @@ export class PromptDialog implements AfterViewInit, AfterViewChecked, DoCheck {
|
|
|
10632
10604
|
this.close.emit()
|
|
10633
10605
|
})
|
|
10634
10606
|
.catch((_error: unknown) => {
|
|
10635
|
-
// Deliberate: a rejection keeps the dialog open and the caller owns
|
|
10636
|
-
// the error, rendering it through `children`.
|
|
10637
10607
|
this.pending.set(false)
|
|
10638
10608
|
})
|
|
10639
10609
|
}
|
|
10640
10610
|
}
|
|
10641
10611
|
```
|
|
10642
10612
|
|
|
10643
|
-
_(Member comments are shortened to their first sentence, and the
|
|
10613
|
+
_(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
10614
|
|
|
10645
10615
|
#### `RadioGroup`
|
|
10646
10616
|
|
|
@@ -10882,7 +10852,7 @@ export class ResponsiveAppShell implements DoCheck, OnDestroy {
|
|
|
10882
10852
|
|
|
10883
10853
|
/** Registers the shell context on the host before any projected child resolves it. */
|
|
10884
10854
|
constructor() {
|
|
10885
|
-
|
|
10855
|
+
ShellDomContext.provide(this.host.nativeElement, new ShellContextValueImpl(this))
|
|
10886
10856
|
}
|
|
10887
10857
|
|
|
10888
10858
|
/**
|
|
@@ -10921,7 +10891,7 @@ export class ResponsiveAppShell implements DoCheck, OnDestroy {
|
|
|
10921
10891
|
|
|
10922
10892
|
/** Removes the context registration (unmount). */
|
|
10923
10893
|
ngOnDestroy(): void {
|
|
10924
|
-
|
|
10894
|
+
ShellDomContext.remove(this.host.nativeElement)
|
|
10925
10895
|
}
|
|
10926
10896
|
}
|
|
10927
10897
|
```
|
|
@@ -10935,6 +10905,7 @@ Drawer is composed), the brand, and trailing actions.
|
|
|
10935
10905
|
@Component({
|
|
10936
10906
|
selector: 'header[mol-responsive-app-shell-topbar]',
|
|
10937
10907
|
standalone: true,
|
|
10908
|
+
hostDirectives: [MolPlacement],
|
|
10938
10909
|
imports: [MolIconSvg, MolTemplateOutlet],
|
|
10939
10910
|
inputs: ['brand', 'actions', 'mobileOnly', 'className', 'dataMolId', 'testId'],
|
|
10940
10911
|
host: {
|
|
@@ -10972,7 +10943,7 @@ Drawer is composed), the brand, and trailing actions.
|
|
|
10972
10943
|
>{{ nodeText(actions) }}
|
|
10973
10944
|
</div>`,
|
|
10974
10945
|
})
|
|
10975
|
-
export class ResponsiveAppShellTopBar implements OnInit
|
|
10946
|
+
export class ResponsiveAppShellTopBar implements OnInit {
|
|
10976
10947
|
/** Brand/title node (React's `brand`), rendered after the menu trigger. */
|
|
10977
10948
|
brand?: ResponsiveAppShellTopBarProps['brand']
|
|
10978
10949
|
/** Trailing actions node (React's `actions`). */
|
|
@@ -11005,32 +10976,38 @@ export class ResponsiveAppShellTopBar implements OnInit, AfterViewInit, DoCheck
|
|
|
11005
10976
|
*/
|
|
11006
10977
|
private readonly i18n = useTranslation()
|
|
11007
10978
|
|
|
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
10979
|
private hasBrand = false
|
|
11013
10980
|
private hasActions = false
|
|
11014
10981
|
|
|
11015
10982
|
/** Prepares the header's mount condition (React's `mobileOnly`). */
|
|
11016
10983
|
constructor() {
|
|
10984
|
+
usePlacement((hasContent) => {
|
|
10985
|
+
// Resolve the shell context while the host is still in the page: a mobileOnly header
|
|
10986
|
+
// leaves it on desktop, and its ancestors are the only way to the shell root.
|
|
10987
|
+
void this.shell()
|
|
10988
|
+
this.syncWrappers(hasContent)
|
|
10989
|
+
})
|
|
11017
10990
|
// Leaves no element in the page while the bar is hidden on desktop (React renders null).
|
|
11018
10991
|
useHostPresence(() => !(this.mobileOnly && this.shell().isDesktop))
|
|
11019
10992
|
}
|
|
11020
10993
|
|
|
11021
10994
|
/**
|
|
11022
10995
|
* The nearest shell context.
|
|
11023
|
-
* @returns The context (
|
|
10996
|
+
* @returns The context (its defaults outside the shell).
|
|
11024
10997
|
*/
|
|
11025
10998
|
shell(): ShellContextValue {
|
|
11026
10999
|
// Cached: a detached (mobileOnly) header loses its DOM ancestors, so the
|
|
11027
11000
|
// lookup must not be repeated after the element leaves the tree.
|
|
11028
|
-
this.
|
|
11029
|
-
return this.context
|
|
11001
|
+
return this.readContext() ?? contextOrDefault(null)
|
|
11030
11002
|
}
|
|
11031
11003
|
|
|
11032
|
-
/**
|
|
11033
|
-
|
|
11004
|
+
/**
|
|
11005
|
+
* Reads the shell context from the host's place in the rendered tree.
|
|
11006
|
+
* @returns The context, or null outside the shell.
|
|
11007
|
+
*/
|
|
11008
|
+
private readContext(): ShellContextValue | null {
|
|
11009
|
+
return ShellDomContext.find(this.host.nativeElement) ?? null
|
|
11010
|
+
}
|
|
11034
11011
|
|
|
11035
11012
|
/**
|
|
11036
11013
|
* The current class map.
|
|
@@ -11102,36 +11079,15 @@ export class ResponsiveAppShellTopBar implements OnInit, AfterViewInit, DoCheck
|
|
|
11102
11079
|
* Refuses to render outside a shell (React's `useShellContext` throws).
|
|
11103
11080
|
*/
|
|
11104
11081
|
ngOnInit(): void {
|
|
11105
|
-
requireShell(this.
|
|
11106
|
-
}
|
|
11107
|
-
|
|
11108
|
-
/** Reads slot presence and applies the conditional brand/actions wrappers. */
|
|
11109
|
-
ngAfterViewInit(): void {
|
|
11110
|
-
this.brandParent = this.brandSlot?.nativeElement.parentElement ?? null
|
|
11111
|
-
this.actionsParent = this.actionsSlot?.nativeElement.parentElement ?? null
|
|
11112
|
-
this.hasBrand = isGiven(this.brand) || hasNodes(this.brandSlot?.nativeElement)
|
|
11113
|
-
this.hasActions = isGiven(this.actions) || hasNodes(this.actionsSlot?.nativeElement)
|
|
11114
|
-
this.syncWrappers()
|
|
11115
|
-
}
|
|
11116
|
-
|
|
11117
|
-
/** Re-reconciles the wrappers. */
|
|
11118
|
-
ngDoCheck(): void {
|
|
11119
|
-
this.hasBrand = isGiven(this.brand) || hasNodes(this.brandSlot?.nativeElement)
|
|
11120
|
-
this.hasActions = isGiven(this.actions) || hasNodes(this.actionsSlot?.nativeElement)
|
|
11121
|
-
this.syncWrappers()
|
|
11082
|
+
requireShell(this.readContext(), 'ResponsiveAppShell.TopBar')
|
|
11122
11083
|
}
|
|
11123
11084
|
|
|
11124
11085
|
/** Applies React's conditional brand/actions wrappers. */
|
|
11125
|
-
private syncWrappers(): void {
|
|
11126
|
-
|
|
11127
|
-
|
|
11128
|
-
|
|
11129
|
-
|
|
11130
|
-
this.sync.sync(
|
|
11131
|
-
this.actionsSlot?.nativeElement,
|
|
11132
|
-
this.hasActions,
|
|
11133
|
-
this.actionsParent ?? undefined,
|
|
11134
|
-
)
|
|
11086
|
+
private syncWrappers(hasContent: SlotReader): void {
|
|
11087
|
+
this.hasBrand = isGiven(this.brand) || hasContent(this.brandSlot?.nativeElement)
|
|
11088
|
+
this.hasActions = isGiven(this.actions) || hasContent(this.actionsSlot?.nativeElement)
|
|
11089
|
+
setElementPresent(this.brandSlot?.nativeElement, this.hasBrand)
|
|
11090
|
+
setElementPresent(this.actionsSlot?.nativeElement, this.hasActions)
|
|
11135
11091
|
}
|
|
11136
11092
|
}
|
|
11137
11093
|
```
|
|
@@ -11145,6 +11101,7 @@ the breakpoint (the Drawer carries the nav there).
|
|
|
11145
11101
|
@Component({
|
|
11146
11102
|
selector: 'aside[mol-responsive-app-shell-sidebar]',
|
|
11147
11103
|
standalone: true,
|
|
11104
|
+
hostDirectives: [MolPlacement],
|
|
11148
11105
|
imports: [MolTemplateOutlet],
|
|
11149
11106
|
inputs: ['navLabel', 'footer', 'className', 'dataMolId', 'testId'],
|
|
11150
11107
|
host: {
|
|
@@ -11171,7 +11128,7 @@ the breakpoint (the Drawer carries the nav there).
|
|
|
11171
11128
|
><ng-container [molTemplateOutlet]="asTemplate(footer)"></ng-container>{{ nodeText(footer) }}
|
|
11172
11129
|
</div>`,
|
|
11173
11130
|
})
|
|
11174
|
-
export class ResponsiveAppShellSidebar implements OnInit
|
|
11131
|
+
export class ResponsiveAppShellSidebar implements OnInit {
|
|
11175
11132
|
/** Accessible name for the `<nav>` landmark. */
|
|
11176
11133
|
navLabel?: ResponsiveAppShellSidebarProps['navLabel']
|
|
11177
11134
|
/** Below-nav content (React's `footer` node value). */
|
|
@@ -11200,29 +11157,36 @@ export class ResponsiveAppShellSidebar implements OnInit, AfterViewInit, DoCheck
|
|
|
11200
11157
|
*/
|
|
11201
11158
|
private readonly i18n = useTranslation()
|
|
11202
11159
|
|
|
11203
|
-
private readonly renderer = inject(Renderer2)
|
|
11204
|
-
private readonly sync = new SlotWrapper(this.host, this.renderer)
|
|
11205
|
-
private footerParent: HTMLElement | null = null
|
|
11206
11160
|
private hasFooter = false
|
|
11207
11161
|
|
|
11208
11162
|
/** Prepares the aside's mount condition (React's breakpoint check). */
|
|
11209
11163
|
constructor() {
|
|
11164
|
+
usePlacement((hasContent) => {
|
|
11165
|
+
// Resolve the shell context while the host is still in the page: below the breakpoint
|
|
11166
|
+
// it leaves the page, and its ancestors are the only way to the shell root.
|
|
11167
|
+
void this.shell()
|
|
11168
|
+
this.syncWrapper(hasContent)
|
|
11169
|
+
})
|
|
11210
11170
|
// Leaves no element in the page below the breakpoint (React renders null).
|
|
11211
11171
|
useHostPresence(() => this.shell().isDesktop)
|
|
11212
11172
|
}
|
|
11213
11173
|
|
|
11214
11174
|
/**
|
|
11215
11175
|
* The nearest shell context.
|
|
11216
|
-
* @returns The context (defaults outside the shell).
|
|
11176
|
+
* @returns The context (its defaults outside the shell).
|
|
11217
11177
|
*/
|
|
11218
11178
|
shell(): ShellContextValue {
|
|
11219
11179
|
// Cached: a detached (mobile) sidebar loses its DOM ancestors.
|
|
11220
|
-
this.
|
|
11221
|
-
return this.context
|
|
11180
|
+
return this.readContext() ?? contextOrDefault(null)
|
|
11222
11181
|
}
|
|
11223
11182
|
|
|
11224
|
-
/**
|
|
11225
|
-
|
|
11183
|
+
/**
|
|
11184
|
+
* Reads the shell context from the host's place in the rendered tree.
|
|
11185
|
+
* @returns The context, or null outside the shell.
|
|
11186
|
+
*/
|
|
11187
|
+
private readContext(): ShellContextValue | null {
|
|
11188
|
+
return ShellDomContext.find(this.host.nativeElement) ?? null
|
|
11189
|
+
}
|
|
11226
11190
|
|
|
11227
11191
|
/**
|
|
11228
11192
|
* The current class map.
|
|
@@ -11271,27 +11235,13 @@ export class ResponsiveAppShellSidebar implements OnInit, AfterViewInit, DoCheck
|
|
|
11271
11235
|
* Refuses to render outside a shell (React's `useShellContext` throws).
|
|
11272
11236
|
*/
|
|
11273
11237
|
ngOnInit(): void {
|
|
11274
|
-
requireShell(this.
|
|
11275
|
-
}
|
|
11276
|
-
|
|
11277
|
-
/** Reads footer presence and applies the conditional footer wrapper. */
|
|
11278
|
-
ngAfterViewInit(): void {
|
|
11279
|
-
this.footerParent = this.footerSlot?.nativeElement.parentElement ?? null
|
|
11280
|
-
this.hasFooter = isGiven(this.footer) || hasNodes(this.footerSlot?.nativeElement)
|
|
11281
|
-
this.syncWrapper()
|
|
11282
|
-
}
|
|
11283
|
-
|
|
11284
|
-
/** Re-reconciles the footer wrapper. */
|
|
11285
|
-
ngDoCheck(): void {
|
|
11286
|
-
this.hasFooter = isGiven(this.footer) || hasNodes(this.footerSlot?.nativeElement)
|
|
11287
|
-
this.syncWrapper()
|
|
11238
|
+
requireShell(this.readContext(), 'ResponsiveAppShell.Sidebar')
|
|
11288
11239
|
}
|
|
11289
11240
|
|
|
11290
11241
|
/** Applies React's conditional footer wrapper. */
|
|
11291
|
-
private syncWrapper(): void {
|
|
11292
|
-
|
|
11293
|
-
|
|
11294
|
-
this.sync.sync(this.footerSlot?.nativeElement, this.hasFooter, this.footerParent ?? undefined)
|
|
11242
|
+
private syncWrapper(hasContent: SlotReader): void {
|
|
11243
|
+
this.hasFooter = isGiven(this.footer) || hasContent(this.footerSlot?.nativeElement)
|
|
11244
|
+
setElementPresent(this.footerSlot?.nativeElement, this.hasFooter)
|
|
11295
11245
|
}
|
|
11296
11246
|
}
|
|
11297
11247
|
```
|
|
@@ -11301,10 +11251,16 @@ export class ResponsiveAppShellSidebar implements OnInit, AfterViewInit, DoCheck
|
|
|
11301
11251
|
The mobile nav drawer (<768px): a left-anchored dialog panel over a
|
|
11302
11252
|
backdrop, portaled into `document.body`.
|
|
11303
11253
|
|
|
11254
|
+
Projected content is created with the consumer's view, so a closed drawer's content exists while
|
|
11255
|
+
hidden: its components, effects and fetches run. React mounts it only while shown, and again each
|
|
11256
|
+
time it shows. Write content with state as `*molLazy` (`MolLazy` from `@molecule/app-angular`):
|
|
11257
|
+
it is created when it shows and destroyed when it hides, as React's is.
|
|
11258
|
+
|
|
11304
11259
|
```typescript
|
|
11305
11260
|
@Component({
|
|
11306
11261
|
selector: 'mol-responsive-app-shell-drawer',
|
|
11307
11262
|
standalone: true,
|
|
11263
|
+
hostDirectives: [MolPlacement],
|
|
11308
11264
|
imports: [MolIconSvg, MolTemplateOutlet],
|
|
11309
11265
|
inputs: [
|
|
11310
11266
|
'header',
|
|
@@ -11316,11 +11272,6 @@ backdrop, portaled into `document.body`.
|
|
|
11316
11272
|
'closeDataMolId',
|
|
11317
11273
|
'testId',
|
|
11318
11274
|
],
|
|
11319
|
-
host: {
|
|
11320
|
-
'data-parity-unwrap': '',
|
|
11321
|
-
style: 'display: contents',
|
|
11322
|
-
'[attr.data-open]': 'shell().drawerOpen ? "true" : null',
|
|
11323
|
-
},
|
|
11324
11275
|
template: `<div #overlay [class]="cm().overlay" aria-hidden="true"></div>
|
|
11325
11276
|
<div
|
|
11326
11277
|
#wrapper
|
|
@@ -11418,27 +11369,30 @@ export class ResponsiveAppShellDrawer implements OnInit, AfterViewInit, DoCheck,
|
|
|
11418
11369
|
|
|
11419
11370
|
private readonly i18n = useTranslation()
|
|
11420
11371
|
|
|
11421
|
-
private readonly renderer = inject(Renderer2)
|
|
11422
11372
|
private readonly injector = inject(Injector)
|
|
11423
11373
|
private readonly environmentInjector = inject(EnvironmentInjector)
|
|
11424
|
-
private readonly sync = new SlotWrapper(this.host, this.renderer)
|
|
11425
11374
|
private readonly scrollLock = createScrollLock()
|
|
11426
11375
|
private hasFooter = false
|
|
11427
|
-
private footerParent: HTMLElement | null = null
|
|
11428
|
-
private headerParent: HTMLElement | null = null
|
|
11429
|
-
private headerRowParent: HTMLElement | null = null
|
|
11430
|
-
private attached = false
|
|
11431
11376
|
private locked = false
|
|
11432
11377
|
private lastOpen = false
|
|
11433
11378
|
private previouslyFocused: HTMLElement | null = null
|
|
11434
11379
|
private listeners: (() => void)[] = []
|
|
11435
11380
|
|
|
11381
|
+
constructor() {
|
|
11382
|
+
usePlacement((hasContent) => {
|
|
11383
|
+
void this.shell()
|
|
11384
|
+
this.syncWrappers(hasContent)
|
|
11385
|
+
this.syncOpen()
|
|
11386
|
+
})
|
|
11387
|
+
}
|
|
11388
|
+
|
|
11436
11389
|
shell(): ShellContextValue {
|
|
11437
|
-
this.
|
|
11438
|
-
return this.context
|
|
11390
|
+
return this.readContext() ?? contextOrDefault(null)
|
|
11439
11391
|
}
|
|
11440
11392
|
|
|
11441
|
-
private
|
|
11393
|
+
private readContext(): ShellContextValue | null {
|
|
11394
|
+
return ShellDomContext.find(this.host.nativeElement) ?? null
|
|
11395
|
+
}
|
|
11442
11396
|
|
|
11443
11397
|
cm(): UIClassMap {
|
|
11444
11398
|
return getClassMap()
|
|
@@ -11496,17 +11450,11 @@ export class ResponsiveAppShellDrawer implements OnInit, AfterViewInit, DoCheck,
|
|
|
11496
11450
|
}
|
|
11497
11451
|
|
|
11498
11452
|
ngOnInit(): void {
|
|
11499
|
-
requireShell(this.
|
|
11453
|
+
requireShell(this.readContext(), 'ResponsiveAppShell.Drawer')
|
|
11500
11454
|
}
|
|
11501
11455
|
|
|
11502
11456
|
ngAfterViewInit(): void {
|
|
11503
11457
|
this.shell().registerDrawer(true)
|
|
11504
|
-
this.headerParent = this.headerSlot?.nativeElement.parentElement ?? null
|
|
11505
|
-
this.headerRowParent = this.headerRow?.nativeElement.parentElement ?? null
|
|
11506
|
-
this.footerParent = this.footerSlot?.nativeElement.parentElement ?? null
|
|
11507
|
-
this.headerPresent.set(isGiven(this.header) || hasNodes(this.headerSlot?.nativeElement))
|
|
11508
|
-
this.hasFooter = isGiven(this.footer) || hasNodes(this.footerSlot?.nativeElement)
|
|
11509
|
-
this.syncWrappers()
|
|
11510
11458
|
const open = this.shell().drawerOpen && !this.shell().isDesktop
|
|
11511
11459
|
this.lastOpen = open
|
|
11512
11460
|
if (open) this.openPanel()
|
|
@@ -11514,9 +11462,6 @@ export class ResponsiveAppShellDrawer implements OnInit, AfterViewInit, DoCheck,
|
|
|
11514
11462
|
}
|
|
11515
11463
|
|
|
11516
11464
|
ngDoCheck(): void {
|
|
11517
|
-
this.headerPresent.set(isGiven(this.header) || hasNodes(this.headerSlot?.nativeElement))
|
|
11518
|
-
this.hasFooter = isGiven(this.footer) || hasNodes(this.footerSlot?.nativeElement)
|
|
11519
|
-
this.syncWrappers()
|
|
11520
11465
|
this.syncOpen()
|
|
11521
11466
|
}
|
|
11522
11467
|
|
|
@@ -11535,16 +11480,44 @@ export class ResponsiveAppShellDrawer implements OnInit, AfterViewInit, DoCheck,
|
|
|
11535
11480
|
this.scrollLock.unlock()
|
|
11536
11481
|
this.locked = false
|
|
11537
11482
|
}
|
|
11538
|
-
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
11542
|
-
|
|
11543
|
-
|
|
11544
|
-
this.
|
|
11483
|
+
}
|
|
11484
|
+
|
|
11485
|
+
private syncWrappers(hasContent: SlotReader): void {
|
|
11486
|
+
this.headerPresent.set(isGiven(this.header) || hasContent(this.headerSlot?.nativeElement))
|
|
11487
|
+
this.hasFooter = isGiven(this.footer) || hasContent(this.footerSlot?.nativeElement)
|
|
11488
|
+
setElementPresent(
|
|
11489
|
+
this.headerRow?.nativeElement,
|
|
11490
|
+
this.headerPresent() || (this.showCloseButton ?? true),
|
|
11491
|
+
)
|
|
11492
|
+
setElementPresent(this.headerSlot?.nativeElement, this.headerPresent())
|
|
11493
|
+
setElementPresent(this.footerSlot?.nativeElement, this.hasFooter)
|
|
11494
|
+
setElementPresent(this.host.nativeElement, false)
|
|
11495
|
+
}
|
|
11496
|
+
|
|
11497
|
+
private syncOpen(): void {
|
|
11498
|
+
const open = this.shell().drawerOpen && !this.shell().isDesktop
|
|
11499
|
+
if (open === this.lastOpen) return
|
|
11500
|
+
this.lastOpen = open
|
|
11501
|
+
if (open) {
|
|
11502
|
+
this.openPanel()
|
|
11503
|
+
} else {
|
|
11504
|
+
this.removeListeners()
|
|
11505
|
+
this.detachPortal()
|
|
11506
|
+
if (this.locked) {
|
|
11507
|
+
this.scrollLock.unlock()
|
|
11508
|
+
this.locked = false
|
|
11509
|
+
}
|
|
11510
|
+
const toRestore = this.previouslyFocused
|
|
11511
|
+
if (toRestore)
|
|
11512
|
+
afterNextRender(
|
|
11513
|
+
() => {
|
|
11514
|
+
if (document.contains(toRestore)) toRestore.focus()
|
|
11515
|
+
},
|
|
11516
|
+
{ injector: this.injector },
|
|
11517
|
+
)
|
|
11545
11518
|
}
|
|
11546
11519
|
}
|
|
11547
|
-
// … truncated —
|
|
11520
|
+
// … truncated — 6 more members: openPanel, attachPortal, detachPortal, addListeners, removeListeners, handleKeyDown; the full declaration is in node_modules/@molecule/app-ui-angular/dist/components/responsive-app-shell.component.d.ts
|
|
11548
11521
|
```
|
|
11549
11522
|
|
|
11550
11523
|
_(Member comments are left out to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/responsive-app-shell.component.d.ts`.)_
|
|
@@ -11980,9 +11953,9 @@ export class Separator implements HasElement<HTMLDivElement> {
|
|
|
11980
11953
|
|
|
11981
11954
|
SidebarUserCard component.
|
|
11982
11955
|
|
|
11983
|
-
React's root is a FRAGMENT (the trigger button plus a drawer), so the
|
|
11984
|
-
|
|
11985
|
-
|
|
11956
|
+
React's root is a FRAGMENT (the trigger button plus a drawer), so the trigger
|
|
11957
|
+
button renders in front of the host (`placeElementBefore`) and the host
|
|
11958
|
+
itself leaves the DOM. Identity comes from `useAuth()` unless the
|
|
11986
11959
|
matching props override it.
|
|
11987
11960
|
|
|
11988
11961
|
```typescript
|
|
@@ -11990,6 +11963,7 @@ matching props override it.
|
|
|
11990
11963
|
selector: 'mol-sidebar-user-card',
|
|
11991
11964
|
standalone: true,
|
|
11992
11965
|
imports: [Modal, PanelCloseProvider],
|
|
11966
|
+
hostDirectives: [MolPlacement],
|
|
11993
11967
|
inputs: [
|
|
11994
11968
|
'name',
|
|
11995
11969
|
'secondaryLine',
|
|
@@ -11999,10 +11973,6 @@ matching props override it.
|
|
|
11999
11973
|
'dataMolId',
|
|
12000
11974
|
'className',
|
|
12001
11975
|
],
|
|
12002
|
-
host: {
|
|
12003
|
-
'data-parity-unwrap': '',
|
|
12004
|
-
style: 'display: contents',
|
|
12005
|
-
},
|
|
12006
11976
|
template: `<button
|
|
12007
11977
|
#trigger
|
|
12008
11978
|
type="button"
|
|
@@ -12033,7 +12003,7 @@ matching props override it.
|
|
|
12033
12003
|
><ng-content></ng-content></mol-panel-close-provider
|
|
12034
12004
|
></mol-modal>`,
|
|
12035
12005
|
})
|
|
12036
|
-
export class SidebarUserCard
|
|
12006
|
+
export class SidebarUserCard {
|
|
12037
12007
|
/** Display name override (falls back to the auth user, then the guest label). */
|
|
12038
12008
|
name?: SidebarUserCardProps['name']
|
|
12039
12009
|
/** Secondary line under the name (falls back to the auth user's email). */
|
|
@@ -12067,8 +12037,15 @@ export class SidebarUserCard implements AfterViewInit, OnDestroy {
|
|
|
12067
12037
|
@ViewChild('trigger') trigger?: ElementRef<HTMLButtonElement>
|
|
12068
12038
|
|
|
12069
12039
|
private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
|
|
12070
|
-
|
|
12071
|
-
|
|
12040
|
+
|
|
12041
|
+
constructor() {
|
|
12042
|
+
usePlacement(() => {
|
|
12043
|
+
const trigger = this.trigger?.nativeElement
|
|
12044
|
+
if (!trigger) return
|
|
12045
|
+
placeElementBefore(trigger, this.host.nativeElement)
|
|
12046
|
+
setElementPresent(this.host.nativeElement, false)
|
|
12047
|
+
})
|
|
12048
|
+
}
|
|
12072
12049
|
private readonly routeEffect = effect(() => {
|
|
12073
12050
|
const location = this.router.location()
|
|
12074
12051
|
void `${location.pathname}${location.search}`
|
|
@@ -12208,26 +12185,6 @@ export class SidebarUserCard implements AfterViewInit, OnDestroy {
|
|
|
12208
12185
|
closePanel = (): void => {
|
|
12209
12186
|
this.isOpen.set(false)
|
|
12210
12187
|
}
|
|
12211
|
-
|
|
12212
|
-
/** Adopts the trigger beside the host and moves rest props onto it. */
|
|
12213
|
-
ngAfterViewInit(): void {
|
|
12214
|
-
const trigger = this.trigger?.nativeElement
|
|
12215
|
-
const host = this.host.nativeElement
|
|
12216
|
-
if (!trigger) return
|
|
12217
|
-
if (host.parentNode) {
|
|
12218
|
-
host.parentNode.insertBefore(trigger, host)
|
|
12219
|
-
this.adopted = true
|
|
12220
|
-
}
|
|
12221
|
-
if (!this.movedRest) {
|
|
12222
|
-
moveRestAttributes(host, trigger)
|
|
12223
|
-
this.movedRest = true
|
|
12224
|
-
}
|
|
12225
|
-
}
|
|
12226
|
-
|
|
12227
|
-
/** Restores the adopted trigger (unmount). */
|
|
12228
|
-
ngOnDestroy(): void {
|
|
12229
|
-
if (this.adopted) this.host.nativeElement.appendChild(this.trigger?.nativeElement as Node)
|
|
12230
|
-
}
|
|
12231
12188
|
}
|
|
12232
12189
|
```
|
|
12233
12190
|
|
|
@@ -12577,16 +12534,17 @@ export class Spinner implements HasElement<HTMLDivElement> {
|
|
|
12577
12534
|
|
|
12578
12535
|
Switch component.
|
|
12579
12536
|
|
|
12580
|
-
React's root is a fragment (hidden native checkbox + label)
|
|
12581
|
-
|
|
12582
|
-
|
|
12583
|
-
|
|
12537
|
+
React's root is a fragment (hidden native checkbox + label): both elements
|
|
12538
|
+
render in front of the host, which leaves the page, so the rendered tree is
|
|
12539
|
+
React's — no wrapper element around the pair. Clicking the visible button
|
|
12540
|
+
clicks the hidden checkbox, whose GENUINE native `change` event is
|
|
12584
12541
|
forwarded as the `change` output.
|
|
12585
12542
|
|
|
12586
12543
|
```typescript
|
|
12587
12544
|
@Component({
|
|
12588
12545
|
selector: 'mol-switch',
|
|
12589
12546
|
standalone: true,
|
|
12547
|
+
hostDirectives: [MolPlacement],
|
|
12590
12548
|
imports: [MolControlledChecked],
|
|
12591
12549
|
inputs: [
|
|
12592
12550
|
'label',
|
|
@@ -12601,10 +12559,6 @@ forwarded as the `change` output.
|
|
|
12601
12559
|
'dataMolId: data-mol-id',
|
|
12602
12560
|
'onClick',
|
|
12603
12561
|
],
|
|
12604
|
-
host: {
|
|
12605
|
-
'data-parity-unwrap': '',
|
|
12606
|
-
style: 'display: contents',
|
|
12607
|
-
},
|
|
12608
12562
|
template: `<input
|
|
12609
12563
|
type="checkbox"
|
|
12610
12564
|
[molChecked]="!!checked"
|
|
@@ -12688,7 +12642,23 @@ export class Switch implements AfterViewChecked, HasElement<HTMLButtonElement> {
|
|
|
12688
12642
|
private hasLabel = false
|
|
12689
12643
|
/** The `data-mol-id` a caller bound on the host (React spreads it onto the trigger). */
|
|
12690
12644
|
private externalMolId: string | undefined
|
|
12691
|
-
|
|
12645
|
+
|
|
12646
|
+
/**
|
|
12647
|
+
* Renders the host's content (the checkbox and the label) in front of the
|
|
12648
|
+
* host, which leaves the page, and applies React's `{!!label && <span>}`
|
|
12649
|
+
* label condition.
|
|
12650
|
+
*/
|
|
12651
|
+
constructor() {
|
|
12652
|
+
usePlacement((hasContent) => {
|
|
12653
|
+
const host = this.host.nativeElement
|
|
12654
|
+
placeContentBefore(host, host)
|
|
12655
|
+
setElementPresent(host, false)
|
|
12656
|
+
// React spreads the rest props on the switch button.
|
|
12657
|
+
setHostRoot(host, this.trigger?.nativeElement, { except: ['data-mol-id'] })
|
|
12658
|
+
this.hasLabel = !!this.label || hasContent(this.labelSlot?.nativeElement)
|
|
12659
|
+
setElementPresent(this.labelSlot?.nativeElement, this.hasLabel)
|
|
12660
|
+
})
|
|
12661
|
+
}
|
|
12692
12662
|
|
|
12693
12663
|
/**
|
|
12694
12664
|
* The current class map.
|
|
@@ -12771,8 +12741,7 @@ export class Switch implements AfterViewChecked, HasElement<HTMLButtonElement> {
|
|
|
12771
12741
|
}
|
|
12772
12742
|
|
|
12773
12743
|
/**
|
|
12774
|
-
* Moves rest attributes onto the button
|
|
12775
|
-
* `{!!label && <span>}` label condition after queries resolve.
|
|
12744
|
+
* Moves rest attributes onto the button after queries resolve.
|
|
12776
12745
|
*/
|
|
12777
12746
|
ngAfterViewChecked(): void {
|
|
12778
12747
|
adoptHostDataMolId(
|
|
@@ -12783,13 +12752,6 @@ export class Switch implements AfterViewChecked, HasElement<HTMLButtonElement> {
|
|
|
12783
12752
|
},
|
|
12784
12753
|
() => this.molId(),
|
|
12785
12754
|
)
|
|
12786
|
-
moveRestAttributes(this.host.nativeElement, this.trigger?.nativeElement)
|
|
12787
|
-
this.hasLabel = !!this.label || hasNodes(this.labelSlot?.nativeElement)
|
|
12788
|
-
this.sync.sync(
|
|
12789
|
-
this.labelSlot?.nativeElement,
|
|
12790
|
-
this.hasLabel,
|
|
12791
|
-
this.labelSlot?.nativeElement.parentElement ?? undefined,
|
|
12792
|
-
)
|
|
12793
12755
|
}
|
|
12794
12756
|
}
|
|
12795
12757
|
```
|
|
@@ -12807,6 +12769,7 @@ or plain functions returning text.
|
|
|
12807
12769
|
@Component({
|
|
12808
12770
|
selector: 'div[mol-table]',
|
|
12809
12771
|
standalone: true,
|
|
12772
|
+
hostDirectives: [MolPlacement],
|
|
12810
12773
|
imports: [MolIconSvg, MolTemplateOutlet, Spinner],
|
|
12811
12774
|
inputs: [
|
|
12812
12775
|
'data',
|
|
@@ -12904,9 +12867,7 @@ or plain functions returning text.
|
|
|
12904
12867
|
</tbody>
|
|
12905
12868
|
</table>`,
|
|
12906
12869
|
})
|
|
12907
|
-
export class Table
|
|
12908
|
-
implements AfterViewInit, AfterViewChecked, DoCheck, HasElement<HTMLTableElement>
|
|
12909
|
-
{
|
|
12870
|
+
export class Table implements AfterViewInit, AfterViewChecked, HasElement<HTMLTableElement> {
|
|
12910
12871
|
data: Record<string, unknown>[] = []
|
|
12911
12872
|
columns: TableColumn<Record<string, unknown>>[] = []
|
|
12912
12873
|
rowKey?: string | ((row: Record<string, unknown>) => string | number)
|
|
@@ -12941,13 +12902,13 @@ export class Table
|
|
|
12941
12902
|
|
|
12942
12903
|
private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
|
|
12943
12904
|
|
|
12905
|
+
constructor() {
|
|
12906
|
+
usePlacement((hasContent) => this.reconcile(hasContent))
|
|
12907
|
+
}
|
|
12908
|
+
|
|
12944
12909
|
private readonly i18n = useTranslation()
|
|
12945
12910
|
|
|
12946
|
-
private readonly renderer = inject(Renderer2)
|
|
12947
|
-
private readonly sync = new SlotWrapper(this.host, this.renderer)
|
|
12948
12911
|
private externalMolId: string | undefined
|
|
12949
|
-
private emptyParent: HTMLElement | null = null
|
|
12950
|
-
private adoptedEmpty: Node[] = []
|
|
12951
12912
|
|
|
12952
12913
|
cm(): UIClassMap {
|
|
12953
12914
|
return getClassMap()
|
|
@@ -13051,7 +13012,14 @@ export class Table
|
|
|
13051
13012
|
const value = row[column.key as string]
|
|
13052
13013
|
return value === undefined || value === null ? '' : String(value)
|
|
13053
13014
|
}
|
|
13054
|
-
|
|
13015
|
+
|
|
13016
|
+
handleSort(column: TableColumn<Record<string, unknown>>): void {
|
|
13017
|
+
if (!column.sortable || !this.onSort) return
|
|
13018
|
+
const key = column.key as string
|
|
13019
|
+
const currentDirection = this.sort?.key === key ? this.sort.direction : undefined
|
|
13020
|
+
this.onSort(key, currentDirection === 'asc' ? 'desc' : 'asc')
|
|
13021
|
+
}
|
|
13022
|
+
// … truncated — 6 more members: handleRowClick, ngAfterViewInit, ngAfterViewChecked, ngDoCheck, reconcile, placeEmptyContent; the full declaration is in node_modules/@molecule/app-ui-angular/dist/components/table.component.d.ts
|
|
13055
13023
|
```
|
|
13056
13024
|
|
|
13057
13025
|
_(Member comments are left out to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/table.component.d.ts`.)_
|
|
@@ -13704,6 +13672,7 @@ with the remaining time; the announced role follows `status`
|
|
|
13704
13672
|
@Component({
|
|
13705
13673
|
selector: 'div[mol-toast]',
|
|
13706
13674
|
standalone: true,
|
|
13675
|
+
hostDirectives: [MolPlacement],
|
|
13707
13676
|
imports: [MolIconSvg, MolTemplateOutlet],
|
|
13708
13677
|
inputs: [
|
|
13709
13678
|
'title',
|
|
@@ -13722,6 +13691,7 @@ with the remaining time; the announced role follows `status`
|
|
|
13722
13691
|
],
|
|
13723
13692
|
outputs: ['dismiss'],
|
|
13724
13693
|
host: {
|
|
13694
|
+
// static `title="…"` on the host, where the browser shows it as a tooltip.
|
|
13725
13695
|
'[attr.title]': 'null',
|
|
13726
13696
|
'[class]': 'classes()',
|
|
13727
13697
|
'[style]': 'hostStyle()',
|
|
@@ -13779,6 +13749,7 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
|
|
|
13779
13749
|
style?: Record<string, unknown>
|
|
13780
13750
|
/** `data-testid`. */
|
|
13781
13751
|
testId?: string
|
|
13752
|
+
/** Accepted for prop parity; positioning is the container's job. */
|
|
13782
13753
|
position?: ToastPosition
|
|
13783
13754
|
/** `data-mol-id` automation id (React's `automationId`). */
|
|
13784
13755
|
automationId?: string
|
|
@@ -13802,20 +13773,16 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
|
|
|
13802
13773
|
/** Reactive translation, read in the injection context. */
|
|
13803
13774
|
private readonly i18n = useTranslation()
|
|
13804
13775
|
|
|
13805
|
-
private readonly renderer = inject(Renderer2)
|
|
13806
13776
|
private readonly host: HTMLElement = this.el.nativeElement
|
|
13807
|
-
private readonly sync = new SlotWrapper(this.el, this.renderer)
|
|
13808
13777
|
private remaining: number
|
|
13809
13778
|
private startedAt: number | null = null
|
|
13810
13779
|
private timer: ReturnType<typeof setTimeout> | undefined
|
|
13811
13780
|
private lastDuration: number
|
|
13812
|
-
private descriptionParent: HTMLElement | null = null
|
|
13813
|
-
private childrenParent: HTMLElement | null = null
|
|
13814
13781
|
private hasChildren = false
|
|
13815
|
-
private adoptedChildren: Node[] = []
|
|
13816
13782
|
|
|
13817
13783
|
/** Prepares the countdown state (the timer starts at view init). */
|
|
13818
13784
|
constructor() {
|
|
13785
|
+
usePlacement((hasContent) => this.reconcile(hasContent))
|
|
13819
13786
|
useHostPresence(() => this.visible())
|
|
13820
13787
|
this.remaining = this.duration
|
|
13821
13788
|
this.lastDuration = this.duration
|
|
@@ -13845,6 +13812,7 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
|
|
|
13845
13812
|
return this.automationId ?? this.dataMolId ?? this.host.getAttribute('data-mol-id') ?? undefined
|
|
13846
13813
|
}
|
|
13847
13814
|
|
|
13815
|
+
/** The announced role: assertive for warnings/errors, polite otherwise. */
|
|
13848
13816
|
role(): 'alert' | 'status' {
|
|
13849
13817
|
return this.variant() === 'warning' || this.variant() === 'error' ? 'alert' : 'status'
|
|
13850
13818
|
}
|
|
@@ -13875,11 +13843,13 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
|
|
|
13875
13843
|
return this.closeLabel ?? this.i18n.t('ui.toast.close', undefined, { defaultValue: 'Close' })
|
|
13876
13844
|
}
|
|
13877
13845
|
|
|
13846
|
+
/** Dismisses the toast and calls the callback (React's `handleDismiss`). */
|
|
13878
13847
|
handleDismiss(): void {
|
|
13879
13848
|
this.visible.set(false)
|
|
13880
13849
|
this.dismiss.emit()
|
|
13881
13850
|
}
|
|
13882
13851
|
|
|
13852
|
+
/** Pauses the countdown, keeping the time left (React's `pauseTimer`). */
|
|
13883
13853
|
pauseTimer(): void {
|
|
13884
13854
|
if (this.startedAt === null) return
|
|
13885
13855
|
const elapsed = Date.now() - this.startedAt
|
|
@@ -13892,28 +13862,22 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
|
|
|
13892
13862
|
}
|
|
13893
13863
|
|
|
13894
13864
|
ngAfterViewInit(): void {
|
|
13895
|
-
this.descriptionParent = this.descriptionSlot?.nativeElement.parentElement ?? null
|
|
13896
|
-
this.childrenParent = this.childrenSlot?.nativeElement.parentElement ?? null
|
|
13897
|
-
this.hasChildren = hasNodes(this.childrenSlot?.nativeElement)
|
|
13898
|
-
this.adoptChildren()
|
|
13899
13865
|
this.restart()
|
|
13900
13866
|
}
|
|
13901
13867
|
|
|
13902
|
-
/** Re-reconciles children visibility on later passes. */
|
|
13903
13868
|
ngDoCheck(): void {
|
|
13904
13869
|
if (this.duration !== this.lastDuration) {
|
|
13905
13870
|
this.lastDuration = this.duration
|
|
13906
13871
|
this.restart()
|
|
13907
13872
|
}
|
|
13908
|
-
this.syncDescription()
|
|
13909
13873
|
}
|
|
13910
13874
|
|
|
13911
13875
|
/** Stops the countdown (React's unmount cleanup). */
|
|
13912
13876
|
ngOnDestroy(): void {
|
|
13913
13877
|
this.clearTimer()
|
|
13914
|
-
this.adoptedChildren = []
|
|
13915
13878
|
}
|
|
13916
13879
|
|
|
13880
|
+
/** React's effect body: reset the remaining time and start counting. */
|
|
13917
13881
|
private restart(): void {
|
|
13918
13882
|
this.remaining = this.duration
|
|
13919
13883
|
this.startTimer(this.duration)
|
|
@@ -13939,50 +13903,51 @@ export class Toast implements AfterViewInit, DoCheck, OnDestroy, HasElement<HTML
|
|
|
13939
13903
|
}, ms)
|
|
13940
13904
|
}
|
|
13941
13905
|
|
|
13906
|
+
private reconcile(hasContent: SlotReader): void {
|
|
13907
|
+
this.hasChildren = hasContent(this.childrenSlot?.nativeElement)
|
|
13908
|
+
this.adoptChildren()
|
|
13909
|
+
}
|
|
13910
|
+
|
|
13942
13911
|
private adoptChildren(): void {
|
|
13943
13912
|
const span = this.childrenSlot?.nativeElement
|
|
13944
13913
|
if (!span) return
|
|
13945
13914
|
const wrapper = this.descriptionSlot?.nativeElement
|
|
13946
13915
|
const descWins = this.descriptionText() !== null || this.descriptionTemplate() !== null
|
|
13947
|
-
|
|
13948
|
-
|
|
13949
|
-
|
|
13950
|
-
}
|
|
13951
|
-
this.sync.sync(span, false, this.childrenParent ?? undefined)
|
|
13916
|
+
setElementPresent(span, false)
|
|
13917
|
+
if (wrapper && !descWins && this.hasChildren) placeContent(span, wrapper)
|
|
13918
|
+
else placeContent(span, null)
|
|
13952
13919
|
this.syncDescription()
|
|
13953
13920
|
}
|
|
13954
13921
|
|
|
13922
|
+
/** Applies React's `{!!(description || children) && <div>…</div>}`. */
|
|
13955
13923
|
private syncDescription(): void {
|
|
13956
13924
|
const wrapper = this.descriptionSlot?.nativeElement
|
|
13957
13925
|
if (!wrapper) return
|
|
13958
13926
|
const hasDescription = this.descriptionText() !== null || this.descriptionTemplate() !== null
|
|
13959
|
-
|
|
13927
|
+
setElementPresent(wrapper, hasDescription || this.hasChildren)
|
|
13960
13928
|
}
|
|
13961
13929
|
}
|
|
13962
13930
|
```
|
|
13963
13931
|
|
|
13964
|
-
_(Member comments are shortened to their first sentence, and the
|
|
13932
|
+
_(Member comments are shortened to their first sentence, and the 13 longest are left out to fit; the full declaration is in `node_modules/@molecule/app-ui-angular/dist/components/toast.component.d.ts`.)_
|
|
13965
13933
|
|
|
13966
13934
|
#### `ToastContainer`
|
|
13967
13935
|
|
|
13968
13936
|
Toast container: positions toasts on screen via a body portal.
|
|
13969
13937
|
|
|
13970
|
-
React's root is a portal
|
|
13971
|
-
|
|
13972
|
-
|
|
13938
|
+
React's root is a portal: the container `<div>` is moved into
|
|
13939
|
+
`document.body` and the host element leaves the page, so nothing is left at
|
|
13940
|
+
the component's place.
|
|
13973
13941
|
|
|
13974
13942
|
```typescript
|
|
13975
13943
|
@Component({
|
|
13976
13944
|
selector: 'mol-toast-container',
|
|
13977
13945
|
standalone: true,
|
|
13946
|
+
hostDirectives: [MolPlacement],
|
|
13978
13947
|
inputs: ['position', 'className'],
|
|
13979
|
-
host: {
|
|
13980
|
-
'data-parity-unwrap': '',
|
|
13981
|
-
style: 'display: contents',
|
|
13982
|
-
},
|
|
13983
13948
|
template: `<div #container [class]="classes()"><ng-content></ng-content></div>`,
|
|
13984
13949
|
})
|
|
13985
|
-
export class ToastContainer implements
|
|
13950
|
+
export class ToastContainer implements HasElement<HTMLDivElement> {
|
|
13986
13951
|
/** The container position (default `bottom-right`). */
|
|
13987
13952
|
position: ToastPosition = 'bottom-right'
|
|
13988
13953
|
/** Extra classes. */
|
|
@@ -14003,6 +13968,15 @@ export class ToastContainer implements AfterViewInit, OnDestroy, HasElement<HTML
|
|
|
14003
13968
|
|
|
14004
13969
|
private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
|
|
14005
13970
|
|
|
13971
|
+
/** Renders the container in `document.body` (React's portal) and takes the host out of the page. */
|
|
13972
|
+
constructor() {
|
|
13973
|
+
usePlacement(() => {
|
|
13974
|
+
if (typeof document !== 'undefined')
|
|
13975
|
+
placeElement(this.container?.nativeElement, document.body)
|
|
13976
|
+
setElementPresent(this.host.nativeElement, false)
|
|
13977
|
+
})
|
|
13978
|
+
}
|
|
13979
|
+
|
|
14006
13980
|
/**
|
|
14007
13981
|
* The current class map.
|
|
14008
13982
|
* @returns The UIClassMap.
|
|
@@ -14018,18 +13992,6 @@ export class ToastContainer implements AfterViewInit, OnDestroy, HasElement<HTML
|
|
|
14018
13992
|
classes(): string {
|
|
14019
13993
|
return this.cm().cn(this.cm().toastContainer({ position: this.position }), this.className)
|
|
14020
13994
|
}
|
|
14021
|
-
|
|
14022
|
-
/** Moves the container to `document.body` (React's portal). */
|
|
14023
|
-
ngAfterViewInit(): void {
|
|
14024
|
-
const el = this.container?.nativeElement
|
|
14025
|
-
if (el && typeof document !== 'undefined') document.body.appendChild(el)
|
|
14026
|
-
}
|
|
14027
|
-
|
|
14028
|
-
/** Moves the container back under the host so Angular can remove it. */
|
|
14029
|
-
ngOnDestroy(): void {
|
|
14030
|
-
const el = this.container?.nativeElement
|
|
14031
|
-
if (el && this.host.nativeElement.parentNode) this.host.nativeElement.appendChild(el)
|
|
14032
|
-
}
|
|
14033
13995
|
}
|
|
14034
13996
|
```
|
|
14035
13997
|
|
|
@@ -14038,20 +14000,21 @@ export class ToastContainer implements AfterViewInit, OnDestroy, HasElement<HTML
|
|
|
14038
14000
|
ToastProvider: manages global toast state and renders children plus a
|
|
14039
14001
|
positioned toast container (React's context provider + portal).
|
|
14040
14002
|
|
|
14041
|
-
The context value is registered on
|
|
14003
|
+
The context value is registered on a DOM element (React context flows
|
|
14042
14004
|
through the rendered tree, which Angular DI cannot reach for projected
|
|
14043
|
-
content); `useToast()` reads it through the DOM ancestors.
|
|
14005
|
+
content); `useToast()` reads it through the DOM ancestors. React's provider
|
|
14006
|
+
renders its children and the container's portal, no element of its own, so
|
|
14007
|
+
the children render in front of the host and the host leaves the page; the
|
|
14008
|
+
context is registered on the parent element, the one whose child list the
|
|
14009
|
+
children now belong to.
|
|
14044
14010
|
|
|
14045
14011
|
```typescript
|
|
14046
14012
|
@Component({
|
|
14047
14013
|
selector: 'mol-toast-provider',
|
|
14048
14014
|
standalone: true,
|
|
14015
|
+
hostDirectives: [MolPlacement],
|
|
14049
14016
|
imports: [Toast],
|
|
14050
14017
|
inputs: ['position'],
|
|
14051
|
-
host: {
|
|
14052
|
-
'data-parity-unwrap': '',
|
|
14053
|
-
style: 'display: contents',
|
|
14054
|
-
},
|
|
14055
14018
|
template: `<span #childrenCapture><ng-content></ng-content></span>
|
|
14056
14019
|
<div #container [class]="containerClasses()">
|
|
14057
14020
|
@for (toast of toasts(); track toast.id) {
|
|
@@ -14073,7 +14036,7 @@ content); `useToast()` reads it through the DOM ancestors.
|
|
|
14073
14036
|
}
|
|
14074
14037
|
</div>`,
|
|
14075
14038
|
})
|
|
14076
|
-
export class ToastProvider implements
|
|
14039
|
+
export class ToastProvider implements OnDestroy {
|
|
14077
14040
|
/** The default position for toasts (default `bottom-right`). */
|
|
14078
14041
|
position: ToastPosition = 'bottom-right'
|
|
14079
14042
|
|
|
@@ -14086,13 +14049,26 @@ export class ToastProvider implements AfterViewInit, OnDestroy {
|
|
|
14086
14049
|
readonly toasts = signal<(ToastProps & { id: string })[]>([])
|
|
14087
14050
|
|
|
14088
14051
|
private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
|
|
14089
|
-
|
|
14090
|
-
private readonly
|
|
14091
|
-
private adopted: Node[] = []
|
|
14052
|
+
/** The value consumers read; its closures keep the live toast state. */
|
|
14053
|
+
private readonly value = new ToastContextImplementation(this)
|
|
14092
14054
|
|
|
14093
|
-
/**
|
|
14055
|
+
/**
|
|
14056
|
+
* Renders the children in front of the host (which leaves the page),
|
|
14057
|
+
* registers the context where they render, and portals the container.
|
|
14058
|
+
*/
|
|
14094
14059
|
constructor() {
|
|
14095
|
-
|
|
14060
|
+
ToastDomContext.provide(this.host.nativeElement, this.value)
|
|
14061
|
+
usePlacement(() => {
|
|
14062
|
+
const capture = this.childrenCapture?.nativeElement
|
|
14063
|
+
const host = this.host.nativeElement
|
|
14064
|
+
if (capture) {
|
|
14065
|
+
placeContentBefore(capture, host)
|
|
14066
|
+
setElementPresent(capture, false)
|
|
14067
|
+
}
|
|
14068
|
+
setElementPresent(host, false)
|
|
14069
|
+
if (typeof document !== 'undefined')
|
|
14070
|
+
placeElement(this.container?.nativeElement, document.body)
|
|
14071
|
+
})
|
|
14096
14072
|
}
|
|
14097
14073
|
|
|
14098
14074
|
/**
|
|
@@ -14131,29 +14107,9 @@ export class ToastProvider implements AfterViewInit, OnDestroy {
|
|
|
14131
14107
|
this.toasts.update((prev) => prev.filter((toast) => toast.id !== id))
|
|
14132
14108
|
}
|
|
14133
14109
|
|
|
14134
|
-
/**
|
|
14135
|
-
* Adopts the children bare into the host and moves the container to
|
|
14136
|
-
* `document.body` (React's portal).
|
|
14137
|
-
*/
|
|
14138
|
-
ngAfterViewInit(): void {
|
|
14139
|
-
const capture = this.childrenCapture?.nativeElement
|
|
14140
|
-
const host = this.host.nativeElement
|
|
14141
|
-
if (capture) {
|
|
14142
|
-
this.adopted = Array.from(capture.childNodes)
|
|
14143
|
-
for (const node of this.adopted) host.appendChild(node)
|
|
14144
|
-
this.sync.sync(capture, false, host)
|
|
14145
|
-
}
|
|
14146
|
-
const container = this.container?.nativeElement
|
|
14147
|
-
if (container && typeof document !== 'undefined') document.body.appendChild(container)
|
|
14148
|
-
}
|
|
14149
|
-
|
|
14150
|
-
/** Removes the context registration and restores the container (unmount). */
|
|
14110
|
+
/** Removes the context registration (unmount). */
|
|
14151
14111
|
ngOnDestroy(): void {
|
|
14152
|
-
|
|
14153
|
-
const container = this.container?.nativeElement
|
|
14154
|
-
if (container && this.host.nativeElement.parentNode)
|
|
14155
|
-
this.host.nativeElement.appendChild(container)
|
|
14156
|
-
this.adopted = []
|
|
14112
|
+
ToastDomContext.remove(this.host.nativeElement)
|
|
14157
14113
|
}
|
|
14158
14114
|
}
|
|
14159
14115
|
```
|
|
@@ -14163,17 +14119,23 @@ export class ToastProvider implements AfterViewInit, OnDestroy {
|
|
|
14163
14119
|
Tooltip component.
|
|
14164
14120
|
|
|
14165
14121
|
React's root is a FRAGMENT (a trigger wrapper `<div>` plus a portal), so
|
|
14166
|
-
the
|
|
14167
|
-
|
|
14168
|
-
|
|
14169
|
-
|
|
14122
|
+
the trigger wrapper renders in front of the host (`placeElementBefore`),
|
|
14123
|
+
the host itself leaves the DOM, and the portal element renders in
|
|
14124
|
+
`document.body` while visible: the rendered tree and focus paths are
|
|
14125
|
+
React's. A single-element trigger receives `aria-describedby` while the
|
|
14170
14126
|
tooltip shows; show/hide are coordinated across instances exactly like
|
|
14171
14127
|
React's module-level `activeTooltips` map.
|
|
14172
14128
|
|
|
14129
|
+
Projected content is created with the consumer's view, so a tooltip's `[slot=content]` exists
|
|
14130
|
+
while hidden: its components, effects and fetches run. React mounts it only while shown, and
|
|
14131
|
+
again each time it shows. Write content with state as `*molLazy` (`MolLazy` from
|
|
14132
|
+
`@molecule/app-angular`): it is created when it shows and destroyed when it hides, as React's is.
|
|
14133
|
+
|
|
14173
14134
|
```typescript
|
|
14174
14135
|
@Component({
|
|
14175
14136
|
selector: 'mol-tooltip',
|
|
14176
14137
|
standalone: true,
|
|
14138
|
+
hostDirectives: [MolPlacement],
|
|
14177
14139
|
inputs: [
|
|
14178
14140
|
'content',
|
|
14179
14141
|
'placement',
|
|
@@ -14188,10 +14150,6 @@ React's module-level `activeTooltips` map.
|
|
|
14188
14150
|
'title',
|
|
14189
14151
|
'onDoubleClick',
|
|
14190
14152
|
],
|
|
14191
|
-
host: {
|
|
14192
|
-
'data-parity-unwrap': '',
|
|
14193
|
-
style: 'display: contents',
|
|
14194
|
-
},
|
|
14195
14153
|
template: `<div
|
|
14196
14154
|
#triggerWrap
|
|
14197
14155
|
[class]="cm().tooltipTrigger"
|
|
@@ -14269,16 +14227,34 @@ export class Tooltip
|
|
|
14269
14227
|
if (event.key === 'Escape') this.hide()
|
|
14270
14228
|
}
|
|
14271
14229
|
private escapeBound = false
|
|
14272
|
-
private attached = false
|
|
14273
14230
|
private lastVisible = false
|
|
14274
14231
|
private lastContentText: string | null = null
|
|
14275
14232
|
private lastPlacement: TooltipPlacement | null = null
|
|
14276
|
-
private associateEl:
|
|
14277
|
-
private hostParent: Node | null = null
|
|
14233
|
+
private associateEl: Element | null = null
|
|
14278
14234
|
private externalMolId: string | undefined
|
|
14279
14235
|
|
|
14280
14236
|
constructor() {
|
|
14281
14237
|
afterEveryRender(() => this.repositionForContentChange())
|
|
14238
|
+
usePlacement((hasContent) => {
|
|
14239
|
+
const wrap = this.triggerWrap?.nativeElement
|
|
14240
|
+
const capture = this.childrenCapture?.nativeElement
|
|
14241
|
+
if (!wrap || !capture) return
|
|
14242
|
+
placeElementBefore(wrap, this.host.nativeElement)
|
|
14243
|
+
setElementPresent(this.host.nativeElement, false)
|
|
14244
|
+
setHostRoot(this.host.nativeElement, this.contentEl?.nativeElement, {
|
|
14245
|
+
except: ['data-mol-id'],
|
|
14246
|
+
})
|
|
14247
|
+
placeContent(capture, wrap)
|
|
14248
|
+
setElementPresent(capture, false)
|
|
14249
|
+
const children = hasContent.nodes(capture)
|
|
14250
|
+
const only = children.length === 1 ? slotElement(children[0]) : null
|
|
14251
|
+
if (only === this.associateEl) return
|
|
14252
|
+
if (this.visible()) {
|
|
14253
|
+
this.associateEl?.removeAttribute('aria-describedby')
|
|
14254
|
+
only?.setAttribute('aria-describedby', this.boxId())
|
|
14255
|
+
}
|
|
14256
|
+
this.associateEl = only
|
|
14257
|
+
})
|
|
14282
14258
|
}
|
|
14283
14259
|
|
|
14284
14260
|
private repositionForContentChange(): void {
|
|
@@ -14366,25 +14342,7 @@ export class Tooltip
|
|
|
14366
14342
|
}
|
|
14367
14343
|
|
|
14368
14344
|
ngAfterViewInit(): void {
|
|
14369
|
-
|
|
14370
|
-
const host = this.host.nativeElement
|
|
14371
|
-
const capture = this.childrenCapture?.nativeElement
|
|
14372
|
-
this.hostParent = host.parentNode
|
|
14373
|
-
if (wrap) {
|
|
14374
|
-
this.hostParent?.insertBefore(wrap, host)
|
|
14375
|
-
}
|
|
14376
|
-
if (capture && wrap) {
|
|
14377
|
-
const children = Array.from(capture.childNodes)
|
|
14378
|
-
for (const node of children) wrap.appendChild(node)
|
|
14379
|
-
const elements = children.filter((node) => node.nodeType === 1)
|
|
14380
|
-
const hasText = children.some(
|
|
14381
|
-
(node) => node.nodeType === 3 && (node.textContent ?? '').trim(),
|
|
14382
|
-
)
|
|
14383
|
-
this.associateEl = elements.length === 1 && !hasText ? (elements[0] as HTMLElement) : null
|
|
14384
|
-
capture.remove()
|
|
14385
|
-
}
|
|
14386
|
-
this.portalWrap?.nativeElement.remove()
|
|
14387
|
-
this.attached = false
|
|
14345
|
+
setElementPresent(this.portalWrap?.nativeElement, false)
|
|
14388
14346
|
this.lastVisible = false
|
|
14389
14347
|
}
|
|
14390
14348
|
|
|
@@ -14422,20 +14380,14 @@ export class Tooltip
|
|
|
14422
14380
|
activeTooltips.delete(document)
|
|
14423
14381
|
}
|
|
14424
14382
|
if (this.escapeBound) document.removeEventListener('keydown', this.escapeListener)
|
|
14425
|
-
const host = this.host.nativeElement
|
|
14426
|
-
const wrap = this.triggerWrap?.nativeElement
|
|
14427
|
-
if (wrap && wrap.parentElement !== host) host.appendChild(wrap)
|
|
14428
|
-
const portal = this.portalWrap?.nativeElement
|
|
14429
|
-
if (portal && portal.parentElement !== host) host.appendChild(portal)
|
|
14430
14383
|
this.associateEl = null
|
|
14431
14384
|
}
|
|
14432
14385
|
|
|
14433
14386
|
private attachPortal(): void {
|
|
14434
14387
|
const portal = this.portalWrap?.nativeElement
|
|
14435
14388
|
if (!portal) return
|
|
14436
|
-
document.body
|
|
14389
|
+
placeElement(portal, document.body)
|
|
14437
14390
|
this.inner.set(this.contentEl?.nativeElement ?? null)
|
|
14438
|
-
this.attached = true
|
|
14439
14391
|
this.updatePosition()
|
|
14440
14392
|
this.associateEl?.setAttribute('aria-describedby', this.boxId())
|
|
14441
14393
|
if (!this.escapeBound) {
|
|
@@ -14506,7 +14458,7 @@ export class UserMenuPopover implements AfterViewInit, DoCheck, OnDestroy {
|
|
|
14506
14458
|
|
|
14507
14459
|
/** Registers the context on the host before any projected child resolves it. */
|
|
14508
14460
|
constructor() {
|
|
14509
|
-
|
|
14461
|
+
PopoverDomContext.provide(this.host.nativeElement, new UserMenuPopoverContextValue(this))
|
|
14510
14462
|
}
|
|
14511
14463
|
|
|
14512
14464
|
/**
|
|
@@ -14564,7 +14516,7 @@ export class UserMenuPopover implements AfterViewInit, DoCheck, OnDestroy {
|
|
|
14564
14516
|
/** Removes listeners and the context registration (unmount). */
|
|
14565
14517
|
ngOnDestroy(): void {
|
|
14566
14518
|
this.removeDocumentListeners()
|
|
14567
|
-
|
|
14519
|
+
PopoverDomContext.remove(this.host.nativeElement)
|
|
14568
14520
|
}
|
|
14569
14521
|
|
|
14570
14522
|
/** Adds the outside-click and Escape dismiss listeners while open. */
|
|
@@ -14662,7 +14614,7 @@ export class UserMenuPopoverTrigger {
|
|
|
14662
14614
|
* @returns The context, or null outside a popover.
|
|
14663
14615
|
*/
|
|
14664
14616
|
context(): UserMenuPopoverContext | null {
|
|
14665
|
-
return
|
|
14617
|
+
return PopoverDomContext.find(this.host.nativeElement) ?? null
|
|
14666
14618
|
}
|
|
14667
14619
|
|
|
14668
14620
|
/**
|
|
@@ -14770,7 +14722,14 @@ export class UserMenuPopoverTrigger {
|
|
|
14770
14722
|
#### `UserMenuPopoverPanel`
|
|
14771
14723
|
|
|
14772
14724
|
The popover panel: an absolutely-positioned card with an identity header
|
|
14773
|
-
and a `<nav>` wrapping the caller's items.
|
|
14725
|
+
and a `<nav>` wrapping the caller's items. The host element is the card
|
|
14726
|
+
(React's one `<div>`), and it is out of the DOM while the popover is closed
|
|
14727
|
+
(React renders `null`).
|
|
14728
|
+
|
|
14729
|
+
Projected content is created with the consumer's view, so a closed popover's items exist while
|
|
14730
|
+
hidden: their components, effects and fetches run. React mounts them only while shown, and again
|
|
14731
|
+
each time they show. Write content with state as `*molLazy` (`MolLazy` from
|
|
14732
|
+
`@molecule/app-angular`): it is created when it shows and destroyed when it hides, as React's is.
|
|
14774
14733
|
|
|
14775
14734
|
```typescript
|
|
14776
14735
|
@Component({
|
|
@@ -14778,12 +14737,11 @@ and a `<nav>` wrapping the caller's items. Renders nothing while closed.
|
|
|
14778
14737
|
standalone: true,
|
|
14779
14738
|
inputs: ['ariaLabelKey', 'ariaLabelDefault', 'dataMolId', 'className'],
|
|
14780
14739
|
host: {
|
|
14781
|
-
'
|
|
14782
|
-
'[attr.data-
|
|
14783
|
-
|
|
14740
|
+
'[attr.id]': 'panelId()',
|
|
14741
|
+
'[attr.data-mol-id]': 'dataMolId',
|
|
14742
|
+
'[class]': 'classes()',
|
|
14784
14743
|
},
|
|
14785
|
-
template: `<
|
|
14786
|
-
<header [class]="cm().cn(cm().sp('pb', 4), cm().userMenuPopoverHeader)">
|
|
14744
|
+
template: `<header [class]="cm().cn(cm().sp('pb', 4), cm().userMenuPopoverHeader)">
|
|
14787
14745
|
<p [class]="cm().cn(cm().textSize('sm'), cm().fontWeight('semibold'))">{{ displayName() }}</p>
|
|
14788
14746
|
@if (email(); as accountEmail) {
|
|
14789
14747
|
<p [class]="cm().cn(cm().textSize('xs'), cm().textMuted)">{{ accountEmail }}</p>
|
|
@@ -14791,10 +14749,9 @@ and a `<nav>` wrapping the caller's items. Renders nothing while closed.
|
|
|
14791
14749
|
</header>
|
|
14792
14750
|
<nav [class]="cm().cn(cm().sp('mt', 4), cm().stack(1))" [attr.aria-label]="navLabel()">
|
|
14793
14751
|
<ng-content></ng-content>
|
|
14794
|
-
</nav
|
|
14795
|
-
</div>`,
|
|
14752
|
+
</nav>`,
|
|
14796
14753
|
})
|
|
14797
|
-
export class UserMenuPopoverPanel
|
|
14754
|
+
export class UserMenuPopoverPanel {
|
|
14798
14755
|
/** i18n key for the panel's aria-label (default `userMenu.panelLabel`). */
|
|
14799
14756
|
ariaLabelKey?: UserMenuPopoverPanelProps['ariaLabelKey']
|
|
14800
14757
|
/** Fallback aria-label (default `Account menu`). */
|
|
@@ -14804,9 +14761,6 @@ export class UserMenuPopoverPanel implements AfterViewInit, DoCheck {
|
|
|
14804
14761
|
/** Extra classes for the panel. */
|
|
14805
14762
|
className?: UserMenuPopoverPanelProps['className']
|
|
14806
14763
|
|
|
14807
|
-
/** The panel element (removed from the DOM while closed). */
|
|
14808
|
-
@ViewChild('panel') panel?: ElementRef<HTMLDivElement>
|
|
14809
|
-
|
|
14810
14764
|
private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
|
|
14811
14765
|
|
|
14812
14766
|
/**
|
|
@@ -14816,9 +14770,9 @@ export class UserMenuPopoverPanel implements AfterViewInit, DoCheck {
|
|
|
14816
14770
|
*/
|
|
14817
14771
|
private readonly i18n = useTranslation()
|
|
14818
14772
|
|
|
14819
|
-
|
|
14820
|
-
|
|
14821
|
-
|
|
14773
|
+
constructor() {
|
|
14774
|
+
useHostPresence(() => this.open())
|
|
14775
|
+
}
|
|
14822
14776
|
|
|
14823
14777
|
/**
|
|
14824
14778
|
* The current class map.
|
|
@@ -14833,7 +14787,7 @@ export class UserMenuPopoverPanel implements AfterViewInit, DoCheck {
|
|
|
14833
14787
|
* @returns The context, or null outside a popover.
|
|
14834
14788
|
*/
|
|
14835
14789
|
context(): UserMenuPopoverContext | null {
|
|
14836
|
-
return
|
|
14790
|
+
return PopoverDomContext.find(this.host.nativeElement) ?? null
|
|
14837
14791
|
}
|
|
14838
14792
|
|
|
14839
14793
|
/**
|
|
@@ -14880,27 +14834,6 @@ export class UserMenuPopoverPanel implements AfterViewInit, DoCheck {
|
|
|
14880
14834
|
classes(): string {
|
|
14881
14835
|
return this.cm().cn(this.cm().userMenuPopoverPanel, this.className)
|
|
14882
14836
|
}
|
|
14883
|
-
|
|
14884
|
-
/** Records where the panel lives and applies the initial open state. */
|
|
14885
|
-
ngAfterViewInit(): void {
|
|
14886
|
-
const panel = this.panel?.nativeElement
|
|
14887
|
-
if (!panel) return
|
|
14888
|
-
this.panelParent = panel.parentNode
|
|
14889
|
-
this.panelAnchor = panel.nextSibling
|
|
14890
|
-
this.lastOpen = this.open()
|
|
14891
|
-
if (!this.lastOpen) panel.remove()
|
|
14892
|
-
}
|
|
14893
|
-
|
|
14894
|
-
/** Attaches or detaches the panel to match the open state (React renders null). */
|
|
14895
|
-
ngDoCheck(): void {
|
|
14896
|
-
const open = this.open()
|
|
14897
|
-
if (open === this.lastOpen) return
|
|
14898
|
-
this.lastOpen = open
|
|
14899
|
-
const panel = this.panel?.nativeElement
|
|
14900
|
-
if (!panel || !this.panelParent) return
|
|
14901
|
-
if (open) this.panelParent.insertBefore(panel, this.panelAnchor)
|
|
14902
|
-
else panel.remove()
|
|
14903
|
-
}
|
|
14904
14837
|
}
|
|
14905
14838
|
```
|
|
14906
14839
|
|
|
@@ -14956,7 +14889,7 @@ export class UserMenuPopoverSignOut {
|
|
|
14956
14889
|
* @returns The context, or null outside a popover.
|
|
14957
14890
|
*/
|
|
14958
14891
|
context(): UserMenuPopoverContext | null {
|
|
14959
|
-
return
|
|
14892
|
+
return PopoverDomContext.find(this.host.nativeElement) ?? null
|
|
14960
14893
|
}
|
|
14961
14894
|
|
|
14962
14895
|
/**
|
|
@@ -15008,9 +14941,9 @@ export class UserMenuPopoverSignOut {
|
|
|
15008
14941
|
|
|
15009
14942
|
UserMenu component.
|
|
15010
14943
|
|
|
15011
|
-
React's root is a FRAGMENT (the trigger button plus a drawer), so the
|
|
15012
|
-
|
|
15013
|
-
|
|
14944
|
+
React's root is a FRAGMENT (the trigger button plus a drawer), so the trigger
|
|
14945
|
+
button renders in front of the host (`placeElementBefore`) and the host
|
|
14946
|
+
itself leaves the DOM — the rendered tree and focus paths match
|
|
15014
14947
|
React's (a route change must restore focus to the trigger). The panel
|
|
15015
14948
|
content is projected inside the drawer through `PanelCloseProvider`.
|
|
15016
14949
|
|
|
@@ -15019,6 +14952,7 @@ content is projected inside the drawer through `PanelCloseProvider`.
|
|
|
15019
14952
|
selector: 'mol-user-menu',
|
|
15020
14953
|
standalone: true,
|
|
15021
14954
|
imports: [Button, Icon, Modal, PanelCloseProvider],
|
|
14955
|
+
hostDirectives: [MolPlacement],
|
|
15022
14956
|
inputs: [
|
|
15023
14957
|
'ariaLabelKey',
|
|
15024
14958
|
'ariaLabelDefault',
|
|
@@ -15030,10 +14964,6 @@ content is projected inside the drawer through `PanelCloseProvider`.
|
|
|
15030
14964
|
'onClick',
|
|
15031
14965
|
'side',
|
|
15032
14966
|
],
|
|
15033
|
-
host: {
|
|
15034
|
-
'data-parity-unwrap': '',
|
|
15035
|
-
style: 'display: contents',
|
|
15036
|
-
},
|
|
15037
14967
|
template: `<button
|
|
15038
14968
|
#trigger
|
|
15039
14969
|
mol-button
|
|
@@ -15059,7 +14989,7 @@ content is projected inside the drawer through `PanelCloseProvider`.
|
|
|
15059
14989
|
><ng-content></ng-content></mol-panel-close-provider
|
|
15060
14990
|
></mol-modal>`,
|
|
15061
14991
|
})
|
|
15062
|
-
export class UserMenu
|
|
14992
|
+
export class UserMenu {
|
|
15063
14993
|
/** i18n key for the trigger's aria-label (default `userMenu.open`). */
|
|
15064
14994
|
ariaLabelKey?: UserMenuProps['ariaLabelKey']
|
|
15065
14995
|
/** Fallback aria-label (default `Open user menu`). */
|
|
@@ -15095,7 +15025,15 @@ export class UserMenu implements AfterViewInit, OnDestroy {
|
|
|
15095
15025
|
@ViewChild('trigger', { read: ElementRef }) trigger?: ElementRef<HTMLButtonElement>
|
|
15096
15026
|
|
|
15097
15027
|
private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
|
|
15098
|
-
|
|
15028
|
+
|
|
15029
|
+
constructor() {
|
|
15030
|
+
usePlacement(() => {
|
|
15031
|
+
const trigger = this.trigger?.nativeElement
|
|
15032
|
+
if (!trigger) return
|
|
15033
|
+
placeElementBefore(trigger, this.host.nativeElement)
|
|
15034
|
+
setElementPresent(this.host.nativeElement, false)
|
|
15035
|
+
})
|
|
15036
|
+
}
|
|
15099
15037
|
private readonly routeEffect = effect(() => {
|
|
15100
15038
|
const location = this.router.location()
|
|
15101
15039
|
void `${location.pathname}${location.search}`
|
|
@@ -15166,21 +15104,6 @@ export class UserMenu implements AfterViewInit, OnDestroy {
|
|
|
15166
15104
|
if (this.onClick) (this.onClick as (e: MouseEvent) => void)(event)
|
|
15167
15105
|
else this.isOpen.set(true)
|
|
15168
15106
|
}
|
|
15169
|
-
|
|
15170
|
-
/** Adopts the trigger beside the host (React's fragment root). */
|
|
15171
|
-
ngAfterViewInit(): void {
|
|
15172
|
-
const trigger = this.trigger?.nativeElement
|
|
15173
|
-
const host = this.host.nativeElement
|
|
15174
|
-
if (trigger && host.parentNode) {
|
|
15175
|
-
host.parentNode.insertBefore(trigger, host)
|
|
15176
|
-
this.adopted = true
|
|
15177
|
-
}
|
|
15178
|
-
}
|
|
15179
|
-
|
|
15180
|
-
/** Restores the adopted trigger (unmount). */
|
|
15181
|
-
ngOnDestroy(): void {
|
|
15182
|
-
if (this.adopted) this.host.nativeElement.appendChild(this.trigger?.nativeElement as Node)
|
|
15183
|
-
}
|
|
15184
15107
|
}
|
|
15185
15108
|
```
|
|
15186
15109
|
|
|
@@ -15418,9 +15341,14 @@ export class MolIconSvg implements OnChanges {
|
|
|
15418
15341
|
|
|
15419
15342
|
### Functions
|
|
15420
15343
|
|
|
15421
|
-
#### `hasNodes(el)`
|
|
15344
|
+
#### `hasNodes(el)` _(deprecated)_
|
|
15422
15345
|
|
|
15423
|
-
|
|
15346
|
+
> **Deprecated:** Read the slot with the reader `usePlacement` from `@molecule/app-angular` passes to the placement function.
|
|
15347
|
+
|
|
15348
|
+
Whether an ng-content wrapper captured any element or text node, read from a
|
|
15349
|
+
lifecycle hook, which can lag the content: a hook runs before the consumer's
|
|
15350
|
+
`@if` adds its node, and no hook runs at all when the content comes through an
|
|
15351
|
+
`OnPush` component in between.
|
|
15424
15352
|
|
|
15425
15353
|
```typescript
|
|
15426
15354
|
function hasNodes(el: Element | undefined | null): boolean
|
|
@@ -15533,9 +15461,25 @@ function useIsDesktop(query?: string): Signal<boolean>
|
|
|
15533
15461
|
|
|
15534
15462
|
**Returns:** A signal of whether the desktop shell should mount.
|
|
15535
15463
|
|
|
15536
|
-
#### `
|
|
15464
|
+
#### `createDomContext(name)`
|
|
15465
|
+
|
|
15466
|
+
Creates a context (React's `createContext`).
|
|
15537
15467
|
|
|
15538
|
-
|
|
15468
|
+
```typescript
|
|
15469
|
+
function createDomContext<T>(name: string): DomContext<T>
|
|
15470
|
+
```
|
|
15471
|
+
|
|
15472
|
+
- `name` — The context's name, for debugging.
|
|
15473
|
+
|
|
15474
|
+
**Returns:** The context.
|
|
15475
|
+
|
|
15476
|
+
#### `provideDomContext(host, value)` _(deprecated)_
|
|
15477
|
+
|
|
15478
|
+
> **Deprecated:** Use a context of your own: {@link createDomContext}.
|
|
15479
|
+
|
|
15480
|
+
Registers a value on a provider's host element, in the one context every
|
|
15481
|
+
caller of these three functions shares: a consumer then finds the nearest
|
|
15482
|
+
registration of ANY of them.
|
|
15539
15483
|
|
|
15540
15484
|
```typescript
|
|
15541
15485
|
function provideDomContext(host: Element, value: unknown): void
|
|
@@ -15544,7 +15488,9 @@ function provideDomContext(host: Element, value: unknown): void
|
|
|
15544
15488
|
- `host` — The provider component's host element.
|
|
15545
15489
|
- `value` — The context value.
|
|
15546
15490
|
|
|
15547
|
-
#### `removeDomContext(host)`
|
|
15491
|
+
#### `removeDomContext(host)` _(deprecated)_
|
|
15492
|
+
|
|
15493
|
+
> **Deprecated:** Use a context of your own: {@link createDomContext}.
|
|
15548
15494
|
|
|
15549
15495
|
Removes a registration (on provider destroy).
|
|
15550
15496
|
|
|
@@ -15554,29 +15500,34 @@ function removeDomContext(host: Element): void
|
|
|
15554
15500
|
|
|
15555
15501
|
- `host` — The provider component's host element.
|
|
15556
15502
|
|
|
15557
|
-
#### `findDomContext(start)`
|
|
15503
|
+
#### `findDomContext(start)` _(deprecated)_
|
|
15558
15504
|
|
|
15559
|
-
|
|
15505
|
+
> **Deprecated:** Use a context of your own: {@link createDomContext}.
|
|
15506
|
+
|
|
15507
|
+
Finds the nearest enclosing value for a consumer's element.
|
|
15560
15508
|
|
|
15561
15509
|
```typescript
|
|
15562
15510
|
function findDomContext<T>(start: Element | null): T | undefined
|
|
15563
15511
|
```
|
|
15564
15512
|
|
|
15565
|
-
- `start` — The consumer's element (its own
|
|
15513
|
+
- `start` — The consumer's element (its own registration is ignored).
|
|
15566
15514
|
|
|
15567
15515
|
**Returns:** The nearest registered value, or `undefined` when there is none.
|
|
15568
15516
|
|
|
15569
|
-
#### `findDomContextIncludingSelf(start)`
|
|
15517
|
+
#### `findDomContextIncludingSelf(start)` _(deprecated)_
|
|
15518
|
+
|
|
15519
|
+
> **Deprecated:** Use a context of your own: {@link createDomContext}. A provider registers on its own host and a consumer looks up from its own host, so no lookup needs to include itself.
|
|
15570
15520
|
|
|
15571
|
-
Finds the
|
|
15521
|
+
Finds the value registered on the element itself, or else the nearest
|
|
15522
|
+
enclosing one.
|
|
15572
15523
|
|
|
15573
15524
|
```typescript
|
|
15574
15525
|
function findDomContextIncludingSelf<T>(start: Element | null): T | undefined
|
|
15575
15526
|
```
|
|
15576
15527
|
|
|
15577
|
-
- `start` — The element
|
|
15528
|
+
- `start` — The consumer's element.
|
|
15578
15529
|
|
|
15579
|
-
**Returns:** The
|
|
15530
|
+
**Returns:** The registered value, or `undefined` when there is none.
|
|
15580
15531
|
|
|
15581
15532
|
#### `hostElement(host)`
|
|
15582
15533
|
|
|
@@ -15734,6 +15685,19 @@ function isGiven(value: unknown): boolean
|
|
|
15734
15685
|
|
|
15735
15686
|
**Returns:** True when given.
|
|
15736
15687
|
|
|
15688
|
+
#### `rendersNode(value)`
|
|
15689
|
+
|
|
15690
|
+
Whether a node-valued prop renders anything: React's `slot(node) !== undefined` for the values
|
|
15691
|
+
an Angular input carries (not `null`, `undefined`, a boolean or `''`; a template counts).
|
|
15692
|
+
|
|
15693
|
+
```typescript
|
|
15694
|
+
function rendersNode(value: unknown): boolean
|
|
15695
|
+
```
|
|
15696
|
+
|
|
15697
|
+
- `value` — The prop value.
|
|
15698
|
+
|
|
15699
|
+
**Returns:** True when it renders something.
|
|
15700
|
+
|
|
15737
15701
|
#### `shallowEqual(a, b)`
|
|
15738
15702
|
|
|
15739
15703
|
Shallow equality (React's `@molecule/app-state` semantics).
|
|
@@ -15803,7 +15767,7 @@ new one. `aria-describedby` is left alone by default: the input family
|
|
|
15803
15767
|
captured the host's value once and merges it with the field context's own
|
|
15804
15768
|
target on its inner binding, so re-moving a re-bound value would erase that
|
|
15805
15769
|
merge. A component that spreads the attribute onto `...rest` with no merge
|
|
15806
|
-
|
|
15770
|
+
passes {@link ReapplyRestAttributesOptions.includeDescribedBy}.
|
|
15807
15771
|
|
|
15808
15772
|
Idempotent: a host with nothing re-bound moves nothing.
|
|
15809
15773
|
|
|
@@ -15911,6 +15875,14 @@ Elements the WAI-ARIA APG dialog pattern treats as tab-stops for the focus trap.
|
|
|
15911
15875
|
const FOCUSABLE_SELECTOR: 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
15912
15876
|
```
|
|
15913
15877
|
|
|
15878
|
+
#### `FormFieldDomContext`
|
|
15879
|
+
|
|
15880
|
+
The context `FormField` registers on its host.
|
|
15881
|
+
|
|
15882
|
+
```typescript
|
|
15883
|
+
const FormFieldDomContext: DomContext<FormFieldContext>
|
|
15884
|
+
```
|
|
15885
|
+
|
|
15914
15886
|
## Injection Notes
|
|
15915
15887
|
|
|
15916
15888
|
### Requirements
|
|
@@ -15920,7 +15892,7 @@ Peer dependencies:
|
|
|
15920
15892
|
- `@angular/common` ^22.0.0
|
|
15921
15893
|
- `@angular/core` ^22.0.0
|
|
15922
15894
|
- `@angular/platform-browser` ^22.0.0
|
|
15923
|
-
- `@molecule/app-angular` ^3.
|
|
15895
|
+
- `@molecule/app-angular` ^3.14.0
|
|
15924
15896
|
- `@molecule/app-i18n` ^1.0.1
|
|
15925
15897
|
- `@molecule/app-icons` ^1.0.1
|
|
15926
15898
|
- `@molecule/app-ui` ^1.5.0
|
|
@@ -15941,9 +15913,9 @@ Peer dependencies:
|
|
|
15941
15913
|
- Components are standalone — add them to the `imports` array of the consuming component or
|
|
15942
15914
|
route; there is no NgModule.
|
|
15943
15915
|
- A component's selector names the native element React renders at its root (an attribute
|
|
15944
|
-
selector such as `button[mol-button]`), so the host IS the root element.
|
|
15945
|
-
React root is a fragment or portal
|
|
15946
|
-
|
|
15916
|
+
selector such as `button[mol-button]`), so the host IS the root element. A component whose
|
|
15917
|
+
React root is a fragment or a portal renders its template in the host's place and leaves the
|
|
15918
|
+
page itself, so no wrapper element stands among React's nodes.
|
|
15947
15919
|
- Hooks (`useToast`, `usePanelClose`, `useIsDesktop`, `useUserMenuPopoverClose`) are called in
|
|
15948
15920
|
an injection context (a component field initializer or constructor).
|
|
15949
15921
|
- Every component whose React export forwards a ref implements `HasElement`: take it with a
|