@molecule/app-angular 3.11.0 → 3.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +221 -1
- package/dist/dom-placement.d.ts +172 -0
- package/dist/dom-placement.d.ts.map +1 -0
- package/dist/dom-placement.js +518 -0
- package/dist/dom-placement.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +3 -1
- package/dist/providers.js.map +1 -1
- package/package.json +1 -1
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-23T06:34:57.062Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-angular
|
|
@@ -3461,6 +3461,108 @@ type MaybeSignal<T> = T | Signal<T>
|
|
|
3461
3461
|
|
|
3462
3462
|
### Classes
|
|
3463
3463
|
|
|
3464
|
+
#### `WrappedChildren`
|
|
3465
|
+
|
|
3466
|
+
The wrappers around a component's projected children: React's
|
|
3467
|
+
`children.map((child) => <div>{child}</div>)`.
|
|
3468
|
+
|
|
3469
|
+
The component lists it in `providers`, injects it, and puts
|
|
3470
|
+
`molWrapEachChild` on the template element that holds `<ng-content>`.
|
|
3471
|
+
Angular then places every projected child — at creation and whenever the
|
|
3472
|
+
consumer's `@for` or `@if` adds one later, anywhere in the list — inside its
|
|
3473
|
+
own wrapper, and a wrapper goes with its child. No node is moved after
|
|
3474
|
+
Angular placed it. The component styles the wrappers from {@link wrappers}
|
|
3475
|
+
(an effect), and reads React's `children.length` as `wrappers().length`.
|
|
3476
|
+
|
|
3477
|
+
```typescript
|
|
3478
|
+
@Injectable()
|
|
3479
|
+
export class WrappedChildren {
|
|
3480
|
+
private readonly state = signal<readonly HTMLElement[]>([])
|
|
3481
|
+
private parent: HTMLElement | null = null
|
|
3482
|
+
private create: (document: Document) => HTMLElement = (document) => document.createElement('div')
|
|
3483
|
+
|
|
3484
|
+
/** The wrappers, in render order. */
|
|
3485
|
+
readonly wrappers: Signal<readonly HTMLElement[]> = this.state.asReadonly()
|
|
3486
|
+
|
|
3487
|
+
constructor() {
|
|
3488
|
+
assertDomPlacement('WrappedChildren')
|
|
3489
|
+
}
|
|
3490
|
+
|
|
3491
|
+
/**
|
|
3492
|
+
* Sets how a wrapper element is created (default: an empty `<div>`). Call it
|
|
3493
|
+
* in the constructor; attributes that depend on the child's index belong in
|
|
3494
|
+
* an effect over {@link wrappers}.
|
|
3495
|
+
*
|
|
3496
|
+
* @param create - Builds one wrapper element.
|
|
3497
|
+
*/
|
|
3498
|
+
wrapWith(create: (document: Document) => HTMLElement): void {
|
|
3499
|
+
this.create = create
|
|
3500
|
+
}
|
|
3501
|
+
|
|
3502
|
+
/**
|
|
3503
|
+
* Starts wrapping the children Angular places in `parent`.
|
|
3504
|
+
*
|
|
3505
|
+
* @param parent - The element that holds the projected content.
|
|
3506
|
+
* @internal
|
|
3507
|
+
*/
|
|
3508
|
+
attach(parent: HTMLElement): void {
|
|
3509
|
+
if (this.parent !== null) {
|
|
3510
|
+
throw new Error('WrappedChildren: one component wraps the children of one element.')
|
|
3511
|
+
}
|
|
3512
|
+
this.parent = parent
|
|
3513
|
+
wrappingParents.set(parent, this)
|
|
3514
|
+
}
|
|
3515
|
+
|
|
3516
|
+
/**
|
|
3517
|
+
* Creates one wrapper.
|
|
3518
|
+
*
|
|
3519
|
+
* @returns The wrapper element.
|
|
3520
|
+
* @internal
|
|
3521
|
+
*/
|
|
3522
|
+
createWrapper(): HTMLElement {
|
|
3523
|
+
const wrapper = this.create((this.parent as HTMLElement).ownerDocument)
|
|
3524
|
+
wrapperOwners.set(wrapper, this)
|
|
3525
|
+
return wrapper
|
|
3526
|
+
}
|
|
3527
|
+
|
|
3528
|
+
/**
|
|
3529
|
+
* Re-reads the wrappers after Angular added or removed a child.
|
|
3530
|
+
*
|
|
3531
|
+
* @internal
|
|
3532
|
+
*/
|
|
3533
|
+
refresh(): void {
|
|
3534
|
+
if (this.parent === null) return
|
|
3535
|
+
const next: HTMLElement[] = []
|
|
3536
|
+
for (const child of Array.from(this.parent.children)) {
|
|
3537
|
+
if (wrapperOwners.get(child) !== this) continue
|
|
3538
|
+
// Angular's `animate.leave` removes a cancelled leaving element without the renderer.
|
|
3539
|
+
if (child.hasChildNodes()) next.push(child as HTMLElement)
|
|
3540
|
+
else child.remove()
|
|
3541
|
+
}
|
|
3542
|
+
const current = this.state()
|
|
3543
|
+
if (next.length === current.length && next.every((wrapper, i) => wrapper === current[i])) return
|
|
3544
|
+
this.state.set(next)
|
|
3545
|
+
}
|
|
3546
|
+
}
|
|
3547
|
+
```
|
|
3548
|
+
|
|
3549
|
+
#### `MolWrapEachChild`
|
|
3550
|
+
|
|
3551
|
+
Marks the template element whose projected children are each wrapped:
|
|
3552
|
+
`<div molWrapEachChild><ng-content /></div>`. See {@link WrappedChildren}.
|
|
3553
|
+
The marker attribute is taken off the element, so the markup stays React's.
|
|
3554
|
+
|
|
3555
|
+
```typescript
|
|
3556
|
+
@Directive({ selector: '[molWrapEachChild]', standalone: true })
|
|
3557
|
+
export class MolWrapEachChild {
|
|
3558
|
+
constructor() {
|
|
3559
|
+
const parent = inject(ElementRef<HTMLElement>).nativeElement as HTMLElement
|
|
3560
|
+
parent.removeAttribute('molWrapEachChild')
|
|
3561
|
+
inject(WrappedChildren).attach(parent)
|
|
3562
|
+
}
|
|
3563
|
+
}
|
|
3564
|
+
```
|
|
3565
|
+
|
|
3464
3566
|
#### `Link`
|
|
3465
3567
|
|
|
3466
3568
|
`<a molLink="/settings">`: sets the anchor's `href` and navigates in-app
|
|
@@ -4848,6 +4950,117 @@ function useChat(options: UseChatOptions | Signal<UseChatOptions>): UseChatResul
|
|
|
4848
4950
|
|
|
4849
4951
|
**Returns:** Each state field as a signal, and the chat controls.
|
|
4850
4952
|
|
|
4953
|
+
#### `provideDomPlacement()`
|
|
4954
|
+
|
|
4955
|
+
Installs the placement rules in the application's renderer. `provideMolecule`
|
|
4956
|
+
includes it; a test that mounts a port without `provideMolecule` adds it to
|
|
4957
|
+
the application's providers. It wraps whatever renderer factory the
|
|
4958
|
+
application configured, so it also applies under an animation renderer.
|
|
4959
|
+
|
|
4960
|
+
```typescript
|
|
4961
|
+
function provideDomPlacement(): EnvironmentProviders
|
|
4962
|
+
```
|
|
4963
|
+
|
|
4964
|
+
**Returns:** The environment providers.
|
|
4965
|
+
|
|
4966
|
+
#### `setElementPresent(element, present)`
|
|
4967
|
+
|
|
4968
|
+
Takes an element out of its parent while `present` is false and puts it back
|
|
4969
|
+
in the same place once it is true: Angular's equivalent of React's
|
|
4970
|
+
`{cond && <span>…</span>}` for an element the template must keep (one that
|
|
4971
|
+
holds an `<ng-content>`). "Attached" means the element has a parent, not
|
|
4972
|
+
that it is in the document, so it also works inside a host that is itself
|
|
4973
|
+
absent. An element that was never taken out is left where Angular put it.
|
|
4974
|
+
Angular may remove or move the element while it is absent; its placeholder
|
|
4975
|
+
goes then.
|
|
4976
|
+
|
|
4977
|
+
```typescript
|
|
4978
|
+
function setElementPresent(element: Node | null | undefined, present: boolean): void
|
|
4979
|
+
```
|
|
4980
|
+
|
|
4981
|
+
- `element` — The element (nothing happens without one).
|
|
4982
|
+
- `present` — Whether React would render it now.
|
|
4983
|
+
|
|
4984
|
+
#### `placeElement(element, target)`
|
|
4985
|
+
|
|
4986
|
+
Renders an element in another parent while it keeps its place in Angular's
|
|
4987
|
+
view: Angular's equivalent of React's `createPortal(child, document.body)`.
|
|
4988
|
+
An empty comment holds the element's place, so Angular can still insert
|
|
4989
|
+
before it and remove it. `null` puts it back where Angular put it. Calling it
|
|
4990
|
+
again with the same target moves nothing. If Angular moves the element while
|
|
4991
|
+
it is elsewhere, the element follows Angular and the next call moves it
|
|
4992
|
+
again. When Angular removes the view that holds its place, the element is
|
|
4993
|
+
removed from the other parent too, as React unmounts a portal.
|
|
4994
|
+
|
|
4995
|
+
```typescript
|
|
4996
|
+
function placeElement(element: Node | null | undefined, target: Node | null): void
|
|
4997
|
+
```
|
|
4998
|
+
|
|
4999
|
+
- `element` — The element (nothing happens without one).
|
|
5000
|
+
- `target` — The parent to render it in, or `null` for its own place.
|
|
5001
|
+
|
|
5002
|
+
#### `placeContent(capture, target, before)`
|
|
5003
|
+
|
|
5004
|
+
Renders a capture element's content somewhere else: Angular's equivalent of
|
|
5005
|
+
React placing the same `{slot}` in a different parent depending on props
|
|
5006
|
+
(`loading ? <span>{label}</span> : label`). The capture element is the
|
|
5007
|
+
template element that holds the `<ng-content>`.
|
|
5008
|
+
|
|
5009
|
+
The whole content moves as one run, Angular's block anchors included, so the
|
|
5010
|
+
consumer's `@for` and `@if` keep working at the new place: Angular inserts a
|
|
5011
|
+
view under the parent of its anchor, before a node of the same run. Never
|
|
5012
|
+
move a filtered or remembered list of nodes instead; the anchors or the
|
|
5013
|
+
nodes Angular adds later stay behind (NG05106). Calling it again with the
|
|
5014
|
+
same target moves nothing.
|
|
5015
|
+
|
|
5016
|
+
```typescript
|
|
5017
|
+
function placeContent(
|
|
5018
|
+
capture: Element | null | undefined,
|
|
5019
|
+
target: Node | null,
|
|
5020
|
+
before?: Node | null,
|
|
5021
|
+
): void
|
|
5022
|
+
```
|
|
5023
|
+
|
|
5024
|
+
- `capture` — The element Angular projected the content into.
|
|
5025
|
+
- `target` — The parent to render the content in, or `null` to put it back inside `capture`.
|
|
5026
|
+
- `before` — The child of `target` to place the content before (default: at the end).
|
|
5027
|
+
|
|
5028
|
+
#### `hasContent(capture)`
|
|
5029
|
+
|
|
5030
|
+
Whether a slot renders anything, React's `{slot && …}` for projected
|
|
5031
|
+
content: an element, or text that is not template indentation. It reads the
|
|
5032
|
+
content wherever {@link placeContent} rendered it, so a component that moved
|
|
5033
|
+
its slot elsewhere still sees it. Comments (Angular's anchors) are not
|
|
5034
|
+
content.
|
|
5035
|
+
|
|
5036
|
+
```typescript
|
|
5037
|
+
function hasContent(capture: Node | null | undefined): boolean
|
|
5038
|
+
```
|
|
5039
|
+
|
|
5040
|
+
- `capture` — The element Angular projected the content into.
|
|
5041
|
+
|
|
5042
|
+
**Returns:** Whether the slot has content.
|
|
5043
|
+
|
|
5044
|
+
#### `useHostPresence(isPresent)`
|
|
5045
|
+
|
|
5046
|
+
Keeps the calling component's host element out of the DOM while
|
|
5047
|
+
`isPresent()` is false: Angular's equivalent of a React component that
|
|
5048
|
+
returns `null`. Call it in the component's injection context.
|
|
5049
|
+
|
|
5050
|
+
The host is put back before the component's own view refreshes whenever that
|
|
5051
|
+
is knowable: when a signal `isPresent` reads changed (an effect, which
|
|
5052
|
+
Angular runs before the view), and when Angular renders the first node into
|
|
5053
|
+
the absent host (so an `@if` branch that turns on with a plain input is
|
|
5054
|
+
built inside the document). Every render ends with the same check, which
|
|
5055
|
+
covers a predicate that reads what the render produced; a host restored
|
|
5056
|
+
there gets one more check with its content in the page.
|
|
5057
|
+
|
|
5058
|
+
```typescript
|
|
5059
|
+
function useHostPresence(isPresent: () => boolean): void
|
|
5060
|
+
```
|
|
5061
|
+
|
|
5062
|
+
- `isPresent` — Whether the component renders anything now. It may read inputs, plain fields or signals.
|
|
5063
|
+
|
|
4851
5064
|
#### `useExternalStore(read, subscribe)`
|
|
4852
5065
|
|
|
4853
5066
|
Subscribes to an external store and mirrors its value into a signal, with
|
|
@@ -6591,6 +6804,13 @@ Peer dependencies:
|
|
|
6591
6804
|
Molecule service whose token was never provided fails at DI time.
|
|
6592
6805
|
Per-concern helpers (`provideAuth`, `provideTheme`, ...) exist for
|
|
6593
6806
|
piecemeal setup.
|
|
6807
|
+
- The Molecule Angular components render through `provideDomPlacement()`,
|
|
6808
|
+
which `provideMolecule` includes. An app or test that mounts them without
|
|
6809
|
+
`provideMolecule` adds `provideDomPlacement()` to its providers; a component
|
|
6810
|
+
that needs it throws a message naming it. A component never moves a node
|
|
6811
|
+
Angular rendered (`appendChild`, `insertBefore`, `remove`): it uses
|
|
6812
|
+
`useHostPresence`, `setElementPresent`, `placeElement`, `placeContent` or
|
|
6813
|
+
`WrappedChildren`, which keep Angular's own inserts working (NG05106).
|
|
6594
6814
|
- In-app links use the `Link` directive (`<a molLink="/settings">`, `imports: [Link]`): it
|
|
6595
6815
|
navigates through the molecule router with react-router `<Link>`'s click rules. A bare
|
|
6596
6816
|
`<a href>` reloads the page; a hand-written `(click)` handler that calls `navigate()`
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM placement for the Angular ports.
|
|
3
|
+
*
|
|
4
|
+
* One owner for every case where a port's DOM must differ from where Angular
|
|
5
|
+
* put a node:
|
|
6
|
+
*
|
|
7
|
+
* - an element that is absent while React would render nothing
|
|
8
|
+
* ({@link setElementPresent}, {@link useHostPresence});
|
|
9
|
+
* - an element rendered in another parent, React's `createPortal`
|
|
10
|
+
* ({@link placeElement});
|
|
11
|
+
* - a slot's content rendered in another parent ({@link placeContent});
|
|
12
|
+
* - one wrapper element per projected child, React's
|
|
13
|
+
* `children.map((c) => <div>{c}</div>)` ({@link WrappedChildren},
|
|
14
|
+
* {@link MolWrapEachChild}).
|
|
15
|
+
*
|
|
16
|
+
* Angular keeps inserting, moving and removing the nodes it created, and it
|
|
17
|
+
* finds their place through the nodes themselves: it inserts a view before the
|
|
18
|
+
* first node of the next view, under the parent of the container's anchor
|
|
19
|
+
* comment. A node a component moved elsewhere breaks that (NG05106). So the
|
|
20
|
+
* placement rules are applied where Angular places nodes, in its renderer
|
|
21
|
+
* ({@link provideDomPlacement}); components never move a node themselves.
|
|
22
|
+
*
|
|
23
|
+
* @module
|
|
24
|
+
*/
|
|
25
|
+
import { type EnvironmentProviders, type Signal } from '@angular/core';
|
|
26
|
+
import * as i0 from "@angular/core";
|
|
27
|
+
/**
|
|
28
|
+
* Installs the placement rules in the application's renderer. `provideMolecule`
|
|
29
|
+
* includes it; a test that mounts a port without `provideMolecule` adds it to
|
|
30
|
+
* the application's providers. It wraps whatever renderer factory the
|
|
31
|
+
* application configured, so it also applies under an animation renderer.
|
|
32
|
+
*
|
|
33
|
+
* @returns The environment providers.
|
|
34
|
+
*/
|
|
35
|
+
export declare function provideDomPlacement(): EnvironmentProviders;
|
|
36
|
+
/**
|
|
37
|
+
* Takes an element out of its parent while `present` is false and puts it back
|
|
38
|
+
* in the same place once it is true: Angular's equivalent of React's
|
|
39
|
+
* `{cond && <span>…</span>}` for an element the template must keep (one that
|
|
40
|
+
* holds an `<ng-content>`). "Attached" means the element has a parent, not
|
|
41
|
+
* that it is in the document, so it also works inside a host that is itself
|
|
42
|
+
* absent. An element that was never taken out is left where Angular put it.
|
|
43
|
+
* Angular may remove or move the element while it is absent; its placeholder
|
|
44
|
+
* goes then.
|
|
45
|
+
*
|
|
46
|
+
* @param element - The element (nothing happens without one).
|
|
47
|
+
* @param present - Whether React would render it now.
|
|
48
|
+
*/
|
|
49
|
+
export declare function setElementPresent(element: Node | null | undefined, present: boolean): void;
|
|
50
|
+
/**
|
|
51
|
+
* Renders an element in another parent while it keeps its place in Angular's
|
|
52
|
+
* view: Angular's equivalent of React's `createPortal(child, document.body)`.
|
|
53
|
+
* An empty comment holds the element's place, so Angular can still insert
|
|
54
|
+
* before it and remove it. `null` puts it back where Angular put it. Calling it
|
|
55
|
+
* again with the same target moves nothing. If Angular moves the element while
|
|
56
|
+
* it is elsewhere, the element follows Angular and the next call moves it
|
|
57
|
+
* again. When Angular removes the view that holds its place, the element is
|
|
58
|
+
* removed from the other parent too, as React unmounts a portal.
|
|
59
|
+
*
|
|
60
|
+
* @param element - The element (nothing happens without one).
|
|
61
|
+
* @param target - The parent to render it in, or `null` for its own place.
|
|
62
|
+
*/
|
|
63
|
+
export declare function placeElement(element: Node | null | undefined, target: Node | null): void;
|
|
64
|
+
/**
|
|
65
|
+
* Renders a capture element's content somewhere else: Angular's equivalent of
|
|
66
|
+
* React placing the same `{slot}` in a different parent depending on props
|
|
67
|
+
* (`loading ? <span>{label}</span> : label`). The capture element is the
|
|
68
|
+
* template element that holds the `<ng-content>`.
|
|
69
|
+
*
|
|
70
|
+
* The whole content moves as one run, Angular's block anchors included, so the
|
|
71
|
+
* consumer's `@for` and `@if` keep working at the new place: Angular inserts a
|
|
72
|
+
* view under the parent of its anchor, before a node of the same run. Never
|
|
73
|
+
* move a filtered or remembered list of nodes instead; the anchors or the
|
|
74
|
+
* nodes Angular adds later stay behind (NG05106). Calling it again with the
|
|
75
|
+
* same target moves nothing.
|
|
76
|
+
*
|
|
77
|
+
* @param capture - The element Angular projected the content into.
|
|
78
|
+
* @param target - The parent to render the content in, or `null` to put it
|
|
79
|
+
* back inside `capture`.
|
|
80
|
+
* @param before - The child of `target` to place the content before (default:
|
|
81
|
+
* at the end).
|
|
82
|
+
*/
|
|
83
|
+
export declare function placeContent(capture: Element | null | undefined, target: Node | null, before?: Node | null): void;
|
|
84
|
+
/**
|
|
85
|
+
* Whether a slot renders anything, React's `{slot && …}` for projected
|
|
86
|
+
* content: an element, or text that is not template indentation. It reads the
|
|
87
|
+
* content wherever {@link placeContent} rendered it, so a component that moved
|
|
88
|
+
* its slot elsewhere still sees it. Comments (Angular's anchors) are not
|
|
89
|
+
* content.
|
|
90
|
+
*
|
|
91
|
+
* @param capture - The element Angular projected the content into.
|
|
92
|
+
* @returns Whether the slot has content.
|
|
93
|
+
*/
|
|
94
|
+
export declare function hasContent(capture: Node | null | undefined): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Keeps the calling component's host element out of the DOM while
|
|
97
|
+
* `isPresent()` is false: Angular's equivalent of a React component that
|
|
98
|
+
* returns `null`. Call it in the component's injection context.
|
|
99
|
+
*
|
|
100
|
+
* The host is put back before the component's own view refreshes whenever that
|
|
101
|
+
* is knowable: when a signal `isPresent` reads changed (an effect, which
|
|
102
|
+
* Angular runs before the view), and when Angular renders the first node into
|
|
103
|
+
* the absent host (so an `@if` branch that turns on with a plain input is
|
|
104
|
+
* built inside the document). Every render ends with the same check, which
|
|
105
|
+
* covers a predicate that reads what the render produced; a host restored
|
|
106
|
+
* there gets one more check with its content in the page.
|
|
107
|
+
*
|
|
108
|
+
* @param isPresent - Whether the component renders anything now. It may read
|
|
109
|
+
* inputs, plain fields or signals.
|
|
110
|
+
*/
|
|
111
|
+
export declare function useHostPresence(isPresent: () => boolean): void;
|
|
112
|
+
/**
|
|
113
|
+
* The wrappers around a component's projected children: React's
|
|
114
|
+
* `children.map((child) => <div>{child}</div>)`.
|
|
115
|
+
*
|
|
116
|
+
* The component lists it in `providers`, injects it, and puts
|
|
117
|
+
* `molWrapEachChild` on the template element that holds `<ng-content>`.
|
|
118
|
+
* Angular then places every projected child — at creation and whenever the
|
|
119
|
+
* consumer's `@for` or `@if` adds one later, anywhere in the list — inside its
|
|
120
|
+
* own wrapper, and a wrapper goes with its child. No node is moved after
|
|
121
|
+
* Angular placed it. The component styles the wrappers from {@link wrappers}
|
|
122
|
+
* (an effect), and reads React's `children.length` as `wrappers().length`.
|
|
123
|
+
*/
|
|
124
|
+
export declare class WrappedChildren {
|
|
125
|
+
private readonly state;
|
|
126
|
+
private parent;
|
|
127
|
+
private create;
|
|
128
|
+
/** The wrappers, in render order. */
|
|
129
|
+
readonly wrappers: Signal<readonly HTMLElement[]>;
|
|
130
|
+
constructor();
|
|
131
|
+
/**
|
|
132
|
+
* Sets how a wrapper element is created (default: an empty `<div>`). Call it
|
|
133
|
+
* in the constructor; attributes that depend on the child's index belong in
|
|
134
|
+
* an effect over {@link wrappers}.
|
|
135
|
+
*
|
|
136
|
+
* @param create - Builds one wrapper element.
|
|
137
|
+
*/
|
|
138
|
+
wrapWith(create: (document: Document) => HTMLElement): void;
|
|
139
|
+
/**
|
|
140
|
+
* Starts wrapping the children Angular places in `parent`.
|
|
141
|
+
*
|
|
142
|
+
* @param parent - The element that holds the projected content.
|
|
143
|
+
* @internal
|
|
144
|
+
*/
|
|
145
|
+
attach(parent: HTMLElement): void;
|
|
146
|
+
/**
|
|
147
|
+
* Creates one wrapper.
|
|
148
|
+
*
|
|
149
|
+
* @returns The wrapper element.
|
|
150
|
+
* @internal
|
|
151
|
+
*/
|
|
152
|
+
createWrapper(): HTMLElement;
|
|
153
|
+
/**
|
|
154
|
+
* Re-reads the wrappers after Angular added or removed a child.
|
|
155
|
+
*
|
|
156
|
+
* @internal
|
|
157
|
+
*/
|
|
158
|
+
refresh(): void;
|
|
159
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<WrappedChildren, never>;
|
|
160
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Marks the template element whose projected children are each wrapped:
|
|
164
|
+
* `<div molWrapEachChild><ng-content /></div>`. See {@link WrappedChildren}.
|
|
165
|
+
* The marker attribute is taken off the element, so the markup stays React's.
|
|
166
|
+
*/
|
|
167
|
+
export declare class MolWrapEachChild {
|
|
168
|
+
constructor();
|
|
169
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MolWrapEachChild, never>;
|
|
170
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<MolWrapEachChild, "[molWrapEachChild]", never, {}, {}, never, never, true, never>;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=dom-placement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom-placement.d.ts","sourceRoot":"","sources":["../src/dom-placement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAOL,KAAK,oBAAoB,EAQzB,KAAK,MAAM,EAEZ,MAAM,eAAe,CAAA;;AAoKtB;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,IAAI,oBAAoB,CAk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gB;;yCAAhB,gBAAgB;2CAAhB,gBAAgB;CAM5B"}
|
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM placement for the Angular ports.
|
|
3
|
+
*
|
|
4
|
+
* One owner for every case where a port's DOM must differ from where Angular
|
|
5
|
+
* put a node:
|
|
6
|
+
*
|
|
7
|
+
* - an element that is absent while React would render nothing
|
|
8
|
+
* ({@link setElementPresent}, {@link useHostPresence});
|
|
9
|
+
* - an element rendered in another parent, React's `createPortal`
|
|
10
|
+
* ({@link placeElement});
|
|
11
|
+
* - a slot's content rendered in another parent ({@link placeContent});
|
|
12
|
+
* - one wrapper element per projected child, React's
|
|
13
|
+
* `children.map((c) => <div>{c}</div>)` ({@link WrappedChildren},
|
|
14
|
+
* {@link MolWrapEachChild}).
|
|
15
|
+
*
|
|
16
|
+
* Angular keeps inserting, moving and removing the nodes it created, and it
|
|
17
|
+
* finds their place through the nodes themselves: it inserts a view before the
|
|
18
|
+
* first node of the next view, under the parent of the container's anchor
|
|
19
|
+
* comment. A node a component moved elsewhere breaks that (NG05106). So the
|
|
20
|
+
* placement rules are applied where Angular places nodes, in its renderer
|
|
21
|
+
* ({@link provideDomPlacement}); components never move a node themselves.
|
|
22
|
+
*
|
|
23
|
+
* @module
|
|
24
|
+
*/
|
|
25
|
+
import { afterEveryRender, ChangeDetectorRef, DestroyRef, Directive, effect, ElementRef, inject, Injectable, InjectionToken, makeEnvironmentProviders, provideEnvironmentInitializer, RendererFactory2, signal, } from '@angular/core';
|
|
26
|
+
import * as i0 from "@angular/core";
|
|
27
|
+
/** Set once {@link provideDomPlacement} decorated the application's renderer factory. */
|
|
28
|
+
const DOM_PLACEMENT = new InjectionToken('@molecule/app-angular DOM placement');
|
|
29
|
+
/** The renderer factories already decorated (a wrapper of a wrapper would wrap each child twice). */
|
|
30
|
+
const decorated = new WeakSet();
|
|
31
|
+
/** An absent element → the empty comment that holds its place. */
|
|
32
|
+
const placeholders = new WeakMap();
|
|
33
|
+
/** An absent host element → the check that restores it once its component renders again. */
|
|
34
|
+
const absentHosts = new WeakMap();
|
|
35
|
+
/** An element whose children are each wrapped → its wrapper bookkeeping. */
|
|
36
|
+
const wrappingParents = new WeakMap();
|
|
37
|
+
/** A wrapper element → the bookkeeping that created it. */
|
|
38
|
+
const wrapperOwners = new WeakMap();
|
|
39
|
+
/**
|
|
40
|
+
* Elements {@link placeElement} rendered in another parent. Angular removes only
|
|
41
|
+
* a view's root nodes, so an element moved out of a component goes when its
|
|
42
|
+
* placeholder's view goes (React unmounts a portal with its owner).
|
|
43
|
+
*/
|
|
44
|
+
const elsewhere = new Set();
|
|
45
|
+
/**
|
|
46
|
+
* Whether Angular's node is one React child: an element, or a text node that
|
|
47
|
+
* is not template indentation. Angular creates an interpolated text node empty
|
|
48
|
+
* and fills it in the same pass, so an empty text node is a child; comments are
|
|
49
|
+
* Angular's own block anchors.
|
|
50
|
+
*
|
|
51
|
+
* @param node - The node Angular is placing.
|
|
52
|
+
* @returns Whether the node gets its own wrapper.
|
|
53
|
+
*/
|
|
54
|
+
function isChild(node) {
|
|
55
|
+
if (node.nodeType === 1)
|
|
56
|
+
return true;
|
|
57
|
+
if (node.nodeType !== 3)
|
|
58
|
+
return false;
|
|
59
|
+
const text = node.data;
|
|
60
|
+
return text.length === 0 || text.trim() !== '';
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The node that holds `ref`'s place among `parent`'s children: `ref` itself,
|
|
64
|
+
* the placeholder of an absent element, or the wrapper around a wrapped child.
|
|
65
|
+
*
|
|
66
|
+
* @param ref - The node Angular wants to insert before.
|
|
67
|
+
* @param parent - The parent Angular is inserting into.
|
|
68
|
+
* @returns The child of `parent` to insert before.
|
|
69
|
+
*/
|
|
70
|
+
function placeOf(ref, parent) {
|
|
71
|
+
let node = placeholders.get(ref) ?? ref;
|
|
72
|
+
while (node.parentNode !== null && node.parentNode !== parent) {
|
|
73
|
+
if (!wrapperOwners.has(node.parentNode))
|
|
74
|
+
break;
|
|
75
|
+
node = node.parentNode;
|
|
76
|
+
}
|
|
77
|
+
return node;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Forgets an absent element's placeholder: Angular is removing or re-placing
|
|
81
|
+
* the element, so the old place is no longer its place.
|
|
82
|
+
*
|
|
83
|
+
* @param node - The node Angular is removing or inserting.
|
|
84
|
+
*/
|
|
85
|
+
function dropPlaceholder(node) {
|
|
86
|
+
const placeholder = placeholders.get(node);
|
|
87
|
+
if (placeholder === undefined)
|
|
88
|
+
return;
|
|
89
|
+
placeholders.delete(node);
|
|
90
|
+
elsewhere.delete(node);
|
|
91
|
+
const wrapper = placeholder.parentNode;
|
|
92
|
+
placeholder.remove();
|
|
93
|
+
dropEmptyWrapper(wrapper);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Removes a wrapper whose child Angular removed (React renders one wrapper per
|
|
97
|
+
* child).
|
|
98
|
+
*
|
|
99
|
+
* @param node - The removed node's former parent.
|
|
100
|
+
*/
|
|
101
|
+
function dropEmptyWrapper(node) {
|
|
102
|
+
if (node === null || node.hasChildNodes())
|
|
103
|
+
return;
|
|
104
|
+
const owner = wrapperOwners.get(node);
|
|
105
|
+
if (owner === undefined)
|
|
106
|
+
return;
|
|
107
|
+
node.remove();
|
|
108
|
+
owner.refresh();
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Removes every element rendered elsewhere whose place was inside a subtree
|
|
112
|
+
* Angular just removed.
|
|
113
|
+
*
|
|
114
|
+
* @param removed - The node Angular removed.
|
|
115
|
+
*/
|
|
116
|
+
function dropElsewhereInside(removed) {
|
|
117
|
+
for (const element of elsewhere) {
|
|
118
|
+
const placeholder = placeholders.get(element);
|
|
119
|
+
if (placeholder === undefined) {
|
|
120
|
+
elsewhere.delete(element);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (!removed.contains(placeholder))
|
|
124
|
+
continue;
|
|
125
|
+
elsewhere.delete(element);
|
|
126
|
+
placeholders.delete(element);
|
|
127
|
+
element.remove();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Restores an absent host as soon as Angular renders a node into it, so the
|
|
132
|
+
* component's new content is created inside the document (its children's
|
|
133
|
+
* `ngAfterViewInit` can focus and measure, as a React effect can).
|
|
134
|
+
*
|
|
135
|
+
* @param parent - The parent Angular just inserted into.
|
|
136
|
+
*/
|
|
137
|
+
function restoreAbsentHostOf(parent) {
|
|
138
|
+
if (parent.isConnected)
|
|
139
|
+
return;
|
|
140
|
+
absentHosts.get(parent.getRootNode())?.();
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Wraps one of Angular's renderers so the placement rules apply to every node
|
|
144
|
+
* it inserts or removes. Everything else is the wrapped renderer's.
|
|
145
|
+
*
|
|
146
|
+
* @param renderer - The application's renderer.
|
|
147
|
+
* @returns The renderer Angular uses instead.
|
|
148
|
+
*/
|
|
149
|
+
function withPlacement(renderer) {
|
|
150
|
+
const placed = Object.create(renderer);
|
|
151
|
+
const insert = (parent, child, ref, isMove) => {
|
|
152
|
+
// Angular injects a container's anchor through a host that is not in the
|
|
153
|
+
// DOM yet (a component created inside a view before it is inserted), and
|
|
154
|
+
// its own renderer ignores a null parent. Forward that call unchanged:
|
|
155
|
+
// `appendChild` would throw, while `insertBefore` does nothing.
|
|
156
|
+
if (parent === null) {
|
|
157
|
+
;
|
|
158
|
+
renderer.insertBefore(parent, child, ref, isMove);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
dropPlaceholder(child);
|
|
162
|
+
const from = child.parentNode;
|
|
163
|
+
const before = ref === null ? null : placeOf(ref, parent);
|
|
164
|
+
const owner = wrappingParents.get(parent);
|
|
165
|
+
let node = child;
|
|
166
|
+
if (owner !== undefined && isChild(child)) {
|
|
167
|
+
node = owner.createWrapper();
|
|
168
|
+
node.appendChild(child);
|
|
169
|
+
}
|
|
170
|
+
if (before === null)
|
|
171
|
+
renderer.appendChild(parent, node);
|
|
172
|
+
else
|
|
173
|
+
renderer.insertBefore(parent, node, before, isMove);
|
|
174
|
+
if (from !== parent)
|
|
175
|
+
dropEmptyWrapper(from);
|
|
176
|
+
owner?.refresh();
|
|
177
|
+
restoreAbsentHostOf(parent);
|
|
178
|
+
};
|
|
179
|
+
placed.appendChild = (parent, child) => insert(parent, child, null);
|
|
180
|
+
placed.insertBefore = (parent, child, ref, isMove) => insert(parent, child, ref ?? null, isMove);
|
|
181
|
+
placed.removeChild = (parent, child, ...rest) => {
|
|
182
|
+
dropPlaceholder(child);
|
|
183
|
+
const from = child.parentNode;
|
|
184
|
+
renderer.removeChild(parent, child, ...rest);
|
|
185
|
+
dropEmptyWrapper(from);
|
|
186
|
+
if (elsewhere.size > 0)
|
|
187
|
+
dropElsewhereInside(child);
|
|
188
|
+
};
|
|
189
|
+
return placed;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Installs the placement rules in the application's renderer. `provideMolecule`
|
|
193
|
+
* includes it; a test that mounts a port without `provideMolecule` adds it to
|
|
194
|
+
* the application's providers. It wraps whatever renderer factory the
|
|
195
|
+
* application configured, so it also applies under an animation renderer.
|
|
196
|
+
*
|
|
197
|
+
* @returns The environment providers.
|
|
198
|
+
*/
|
|
199
|
+
export function provideDomPlacement() {
|
|
200
|
+
return makeEnvironmentProviders([
|
|
201
|
+
{ provide: DOM_PLACEMENT, useValue: true },
|
|
202
|
+
provideEnvironmentInitializer(() => {
|
|
203
|
+
const factory = inject(RendererFactory2);
|
|
204
|
+
// provideMolecule() and a direct provideDomPlacement() together decorate it once.
|
|
205
|
+
if (decorated.has(factory))
|
|
206
|
+
return;
|
|
207
|
+
decorated.add(factory);
|
|
208
|
+
const create = factory.createRenderer.bind(factory);
|
|
209
|
+
const placed = new WeakMap();
|
|
210
|
+
factory.createRenderer = (element, type) => {
|
|
211
|
+
const renderer = create(element, type);
|
|
212
|
+
let wrapped = placed.get(renderer);
|
|
213
|
+
if (wrapped === undefined)
|
|
214
|
+
placed.set(renderer, (wrapped = withPlacement(renderer)));
|
|
215
|
+
return wrapped;
|
|
216
|
+
};
|
|
217
|
+
}),
|
|
218
|
+
]);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Throws when the application has no {@link provideDomPlacement}: without it
|
|
222
|
+
* Angular throws NG05106 the first time it inserts before a wrapped or absent
|
|
223
|
+
* node, which depends on the data.
|
|
224
|
+
*
|
|
225
|
+
* @param user - The API the caller used, for the message.
|
|
226
|
+
*/
|
|
227
|
+
function assertDomPlacement(user) {
|
|
228
|
+
if (inject(DOM_PLACEMENT, { optional: true }) === null) {
|
|
229
|
+
throw new Error(`${user} needs provideDomPlacement() from @molecule/app-angular in the application's providers ` +
|
|
230
|
+
`(provideMolecule() includes it).`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Takes an element out of its parent while `present` is false and puts it back
|
|
235
|
+
* in the same place once it is true: Angular's equivalent of React's
|
|
236
|
+
* `{cond && <span>…</span>}` for an element the template must keep (one that
|
|
237
|
+
* holds an `<ng-content>`). "Attached" means the element has a parent, not
|
|
238
|
+
* that it is in the document, so it also works inside a host that is itself
|
|
239
|
+
* absent. An element that was never taken out is left where Angular put it.
|
|
240
|
+
* Angular may remove or move the element while it is absent; its placeholder
|
|
241
|
+
* goes then.
|
|
242
|
+
*
|
|
243
|
+
* @param element - The element (nothing happens without one).
|
|
244
|
+
* @param present - Whether React would render it now.
|
|
245
|
+
*/
|
|
246
|
+
export function setElementPresent(element, present) {
|
|
247
|
+
if (!element)
|
|
248
|
+
return;
|
|
249
|
+
const placeholder = placeholders.get(element);
|
|
250
|
+
if (present) {
|
|
251
|
+
if (placeholder === undefined)
|
|
252
|
+
return;
|
|
253
|
+
placeholders.delete(element);
|
|
254
|
+
elsewhere.delete(element);
|
|
255
|
+
// A placeholder whose parent was removed meanwhile has nowhere to restore to.
|
|
256
|
+
if (placeholder.parentNode !== null)
|
|
257
|
+
placeholder.replaceWith(element);
|
|
258
|
+
}
|
|
259
|
+
else if (placeholder === undefined && element.parentNode !== null) {
|
|
260
|
+
const comment = element.ownerDocument.createComment('');
|
|
261
|
+
element.replaceWith(comment);
|
|
262
|
+
placeholders.set(element, comment);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Renders an element in another parent while it keeps its place in Angular's
|
|
267
|
+
* view: Angular's equivalent of React's `createPortal(child, document.body)`.
|
|
268
|
+
* An empty comment holds the element's place, so Angular can still insert
|
|
269
|
+
* before it and remove it. `null` puts it back where Angular put it. Calling it
|
|
270
|
+
* again with the same target moves nothing. If Angular moves the element while
|
|
271
|
+
* it is elsewhere, the element follows Angular and the next call moves it
|
|
272
|
+
* again. When Angular removes the view that holds its place, the element is
|
|
273
|
+
* removed from the other parent too, as React unmounts a portal.
|
|
274
|
+
*
|
|
275
|
+
* @param element - The element (nothing happens without one).
|
|
276
|
+
* @param target - The parent to render it in, or `null` for its own place.
|
|
277
|
+
*/
|
|
278
|
+
export function placeElement(element, target) {
|
|
279
|
+
if (!element)
|
|
280
|
+
return;
|
|
281
|
+
if (target === null) {
|
|
282
|
+
setElementPresent(element, true);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
if (!placeholders.has(element) && element.parentNode !== null) {
|
|
286
|
+
const comment = element.ownerDocument.createComment('');
|
|
287
|
+
element.replaceWith(comment);
|
|
288
|
+
placeholders.set(element, comment);
|
|
289
|
+
}
|
|
290
|
+
elsewhere.add(element);
|
|
291
|
+
if (element.parentNode !== target)
|
|
292
|
+
target.appendChild(element);
|
|
293
|
+
}
|
|
294
|
+
/** A capture element → the comments that bracket its content wherever it is. */
|
|
295
|
+
const contentRanges = new WeakMap();
|
|
296
|
+
/**
|
|
297
|
+
* Renders a capture element's content somewhere else: Angular's equivalent of
|
|
298
|
+
* React placing the same `{slot}` in a different parent depending on props
|
|
299
|
+
* (`loading ? <span>{label}</span> : label`). The capture element is the
|
|
300
|
+
* template element that holds the `<ng-content>`.
|
|
301
|
+
*
|
|
302
|
+
* The whole content moves as one run, Angular's block anchors included, so the
|
|
303
|
+
* consumer's `@for` and `@if` keep working at the new place: Angular inserts a
|
|
304
|
+
* view under the parent of its anchor, before a node of the same run. Never
|
|
305
|
+
* move a filtered or remembered list of nodes instead; the anchors or the
|
|
306
|
+
* nodes Angular adds later stay behind (NG05106). Calling it again with the
|
|
307
|
+
* same target moves nothing.
|
|
308
|
+
*
|
|
309
|
+
* @param capture - The element Angular projected the content into.
|
|
310
|
+
* @param target - The parent to render the content in, or `null` to put it
|
|
311
|
+
* back inside `capture`.
|
|
312
|
+
* @param before - The child of `target` to place the content before (default:
|
|
313
|
+
* at the end).
|
|
314
|
+
*/
|
|
315
|
+
export function placeContent(capture, target, before = null) {
|
|
316
|
+
if (!capture)
|
|
317
|
+
return;
|
|
318
|
+
let range = contentRanges.get(capture);
|
|
319
|
+
if (range === undefined) {
|
|
320
|
+
if (target === null)
|
|
321
|
+
return;
|
|
322
|
+
const document = capture.ownerDocument;
|
|
323
|
+
range = { start: document.createComment(''), end: document.createComment('') };
|
|
324
|
+
capture.prepend(range.start);
|
|
325
|
+
capture.append(range.end);
|
|
326
|
+
contentRanges.set(capture, range);
|
|
327
|
+
}
|
|
328
|
+
const parent = target ?? capture;
|
|
329
|
+
if (range.start.parentNode === parent)
|
|
330
|
+
return;
|
|
331
|
+
const run = [];
|
|
332
|
+
for (let node = range.start; node !== null; node = node.nextSibling) {
|
|
333
|
+
run.push(node);
|
|
334
|
+
if (node === range.end)
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
const ref = target === null ? null : before;
|
|
338
|
+
for (const node of run)
|
|
339
|
+
parent.insertBefore(node, ref);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Whether a slot renders anything, React's `{slot && …}` for projected
|
|
343
|
+
* content: an element, or text that is not template indentation. It reads the
|
|
344
|
+
* content wherever {@link placeContent} rendered it, so a component that moved
|
|
345
|
+
* its slot elsewhere still sees it. Comments (Angular's anchors) are not
|
|
346
|
+
* content.
|
|
347
|
+
*
|
|
348
|
+
* @param capture - The element Angular projected the content into.
|
|
349
|
+
* @returns Whether the slot has content.
|
|
350
|
+
*/
|
|
351
|
+
export function hasContent(capture) {
|
|
352
|
+
if (!capture)
|
|
353
|
+
return false;
|
|
354
|
+
const range = contentRanges.get(capture);
|
|
355
|
+
const nodes = [];
|
|
356
|
+
if (range === undefined || range.start.parentNode === capture) {
|
|
357
|
+
nodes.push(...Array.from(capture.childNodes));
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
for (let node = range.start.nextSibling; node !== null && node !== range.end;) {
|
|
361
|
+
nodes.push(node);
|
|
362
|
+
node = node.nextSibling;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return nodes.some((node) => node.nodeType === 1 || (node.nodeType === 3 && (node.textContent ?? '').trim() !== ''));
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Keeps the calling component's host element out of the DOM while
|
|
369
|
+
* `isPresent()` is false: Angular's equivalent of a React component that
|
|
370
|
+
* returns `null`. Call it in the component's injection context.
|
|
371
|
+
*
|
|
372
|
+
* The host is put back before the component's own view refreshes whenever that
|
|
373
|
+
* is knowable: when a signal `isPresent` reads changed (an effect, which
|
|
374
|
+
* Angular runs before the view), and when Angular renders the first node into
|
|
375
|
+
* the absent host (so an `@if` branch that turns on with a plain input is
|
|
376
|
+
* built inside the document). Every render ends with the same check, which
|
|
377
|
+
* covers a predicate that reads what the render produced; a host restored
|
|
378
|
+
* there gets one more check with its content in the page.
|
|
379
|
+
*
|
|
380
|
+
* @param isPresent - Whether the component renders anything now. It may read
|
|
381
|
+
* inputs, plain fields or signals.
|
|
382
|
+
*/
|
|
383
|
+
export function useHostPresence(isPresent) {
|
|
384
|
+
assertDomPlacement('useHostPresence');
|
|
385
|
+
const host = inject((ElementRef)).nativeElement;
|
|
386
|
+
const sync = () => {
|
|
387
|
+
const present = isPresent();
|
|
388
|
+
if (present) {
|
|
389
|
+
absentHosts.delete(host);
|
|
390
|
+
setElementPresent(host, true);
|
|
391
|
+
}
|
|
392
|
+
else if (host.parentNode !== null) {
|
|
393
|
+
// React removes the subtree and the focus with it.
|
|
394
|
+
const active = host.ownerDocument.activeElement;
|
|
395
|
+
if (active instanceof HTMLElement && host.contains(active))
|
|
396
|
+
active.blur();
|
|
397
|
+
setElementPresent(host, false);
|
|
398
|
+
absentHosts.set(host, sync);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
effect(sync);
|
|
402
|
+
const changeDetector = inject(ChangeDetectorRef);
|
|
403
|
+
afterEveryRender({
|
|
404
|
+
write: () => {
|
|
405
|
+
const wasAbsent = placeholders.has(host);
|
|
406
|
+
sync();
|
|
407
|
+
// Restored only after the render (a plain-input predicate whose change rendered no new
|
|
408
|
+
// node): the content was checked outside the page, so check it once more inside it.
|
|
409
|
+
if (wasAbsent && !placeholders.has(host))
|
|
410
|
+
changeDetector.markForCheck();
|
|
411
|
+
},
|
|
412
|
+
});
|
|
413
|
+
inject(DestroyRef).onDestroy(() => absentHosts.delete(host));
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* The wrappers around a component's projected children: React's
|
|
417
|
+
* `children.map((child) => <div>{child}</div>)`.
|
|
418
|
+
*
|
|
419
|
+
* The component lists it in `providers`, injects it, and puts
|
|
420
|
+
* `molWrapEachChild` on the template element that holds `<ng-content>`.
|
|
421
|
+
* Angular then places every projected child — at creation and whenever the
|
|
422
|
+
* consumer's `@for` or `@if` adds one later, anywhere in the list — inside its
|
|
423
|
+
* own wrapper, and a wrapper goes with its child. No node is moved after
|
|
424
|
+
* Angular placed it. The component styles the wrappers from {@link wrappers}
|
|
425
|
+
* (an effect), and reads React's `children.length` as `wrappers().length`.
|
|
426
|
+
*/
|
|
427
|
+
export class WrappedChildren {
|
|
428
|
+
constructor() {
|
|
429
|
+
this.state = signal([], /* @ts-ignore */
|
|
430
|
+
...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
431
|
+
this.parent = null;
|
|
432
|
+
this.create = (document) => document.createElement('div');
|
|
433
|
+
/** The wrappers, in render order. */
|
|
434
|
+
this.wrappers = this.state.asReadonly();
|
|
435
|
+
assertDomPlacement('WrappedChildren');
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Sets how a wrapper element is created (default: an empty `<div>`). Call it
|
|
439
|
+
* in the constructor; attributes that depend on the child's index belong in
|
|
440
|
+
* an effect over {@link wrappers}.
|
|
441
|
+
*
|
|
442
|
+
* @param create - Builds one wrapper element.
|
|
443
|
+
*/
|
|
444
|
+
wrapWith(create) {
|
|
445
|
+
this.create = create;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Starts wrapping the children Angular places in `parent`.
|
|
449
|
+
*
|
|
450
|
+
* @param parent - The element that holds the projected content.
|
|
451
|
+
* @internal
|
|
452
|
+
*/
|
|
453
|
+
attach(parent) {
|
|
454
|
+
if (this.parent !== null) {
|
|
455
|
+
throw new Error('WrappedChildren: one component wraps the children of one element.');
|
|
456
|
+
}
|
|
457
|
+
this.parent = parent;
|
|
458
|
+
wrappingParents.set(parent, this);
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Creates one wrapper.
|
|
462
|
+
*
|
|
463
|
+
* @returns The wrapper element.
|
|
464
|
+
* @internal
|
|
465
|
+
*/
|
|
466
|
+
createWrapper() {
|
|
467
|
+
const wrapper = this.create(this.parent.ownerDocument);
|
|
468
|
+
wrapperOwners.set(wrapper, this);
|
|
469
|
+
return wrapper;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Re-reads the wrappers after Angular added or removed a child.
|
|
473
|
+
*
|
|
474
|
+
* @internal
|
|
475
|
+
*/
|
|
476
|
+
refresh() {
|
|
477
|
+
if (this.parent === null)
|
|
478
|
+
return;
|
|
479
|
+
const next = [];
|
|
480
|
+
for (const child of Array.from(this.parent.children)) {
|
|
481
|
+
if (wrapperOwners.get(child) !== this)
|
|
482
|
+
continue;
|
|
483
|
+
// Angular's `animate.leave` removes a cancelled leaving element without the renderer.
|
|
484
|
+
if (child.hasChildNodes())
|
|
485
|
+
next.push(child);
|
|
486
|
+
else
|
|
487
|
+
child.remove();
|
|
488
|
+
}
|
|
489
|
+
const current = this.state();
|
|
490
|
+
if (next.length === current.length && next.every((wrapper, i) => wrapper === current[i]))
|
|
491
|
+
return;
|
|
492
|
+
this.state.set(next);
|
|
493
|
+
}
|
|
494
|
+
static { this.ɵfac = function WrappedChildren_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || WrappedChildren)(); }; }
|
|
495
|
+
static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: WrappedChildren, factory: WrappedChildren.ɵfac }); }
|
|
496
|
+
}
|
|
497
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(WrappedChildren, [{
|
|
498
|
+
type: Injectable
|
|
499
|
+
}], () => [], null); })();
|
|
500
|
+
/**
|
|
501
|
+
* Marks the template element whose projected children are each wrapped:
|
|
502
|
+
* `<div molWrapEachChild><ng-content /></div>`. See {@link WrappedChildren}.
|
|
503
|
+
* The marker attribute is taken off the element, so the markup stays React's.
|
|
504
|
+
*/
|
|
505
|
+
export class MolWrapEachChild {
|
|
506
|
+
constructor() {
|
|
507
|
+
const parent = inject((ElementRef)).nativeElement;
|
|
508
|
+
parent.removeAttribute('molWrapEachChild');
|
|
509
|
+
inject(WrappedChildren).attach(parent);
|
|
510
|
+
}
|
|
511
|
+
static { this.ɵfac = function MolWrapEachChild_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MolWrapEachChild)(); }; }
|
|
512
|
+
static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: MolWrapEachChild, selectors: [["", "molWrapEachChild", ""]] }); }
|
|
513
|
+
}
|
|
514
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MolWrapEachChild, [{
|
|
515
|
+
type: Directive,
|
|
516
|
+
args: [{ selector: '[molWrapEachChild]', standalone: true }]
|
|
517
|
+
}], () => [], null); })();
|
|
518
|
+
//# sourceMappingURL=dom-placement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom-placement.js","sourceRoot":"","sources":["../src/dom-placement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,MAAM,EACN,UAAU,EAEV,MAAM,EACN,UAAU,EACV,cAAc,EACd,wBAAwB,EACxB,6BAA6B,EAE7B,gBAAgB,EAEhB,MAAM,GACP,MAAM,eAAe,CAAA;;AAEtB,yFAAyF;AACzF,MAAM,aAAa,GAAG,IAAI,cAAc,CAAO,qCAAqC,CAAC,CAAA;AAErF,qGAAqG;AACrG,MAAM,SAAS,GAAG,IAAI,OAAO,EAAoB,CAAA;AAEjD,kEAAkE;AAClE,MAAM,YAAY,GAAG,IAAI,OAAO,EAAiB,CAAA;AACjD,4FAA4F;AAC5F,MAAM,WAAW,GAAG,IAAI,OAAO,EAAoB,CAAA;AACnD,4EAA4E;AAC5E,MAAM,eAAe,GAAG,IAAI,OAAO,EAAyB,CAAA;AAC5D,2DAA2D;AAC3D,MAAM,aAAa,GAAG,IAAI,OAAO,EAAyB,CAAA;AAC1D;;;;GAIG;AACH,MAAM,SAAS,GAAG,IAAI,GAAG,EAAQ,CAAA;AAEjC;;;;;;;;GAQG;AACH,SAAS,OAAO,CAAC,IAAU;IACzB,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACpC,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IACrC,MAAM,IAAI,GAAI,IAAa,CAAC,IAAI,CAAA;IAChC,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,I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,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrD,IAAI,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI;gBAAE,SAAQ;YAC/C,sFAAsF;YACtF,IAAI,KAAK,CAAC,aAAa,EAAE;gBAAE,IAAI,CAAC,IAAI,CAAC,KAAoB,CAAC,CAAA;;gBACrD,KAAK,CAAC,MAAM,EAAE,CAAA;QACrB,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,EAAE,CAAA;QAC5B,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;YAAE,OAAM;QAChG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACtB,CAAC;gHAlEU,eAAe;uEAAf,eAAe,WAAf,eAAe;;iFAAf,eAAe;cAD3B,UAAU;;AAsEX;;;;GAIG;AAEH,MAAM,OAAO,gBAAgB;IAC3B;QACE,MAAM,MAAM,GAAG,MAAM,CAAC,CAAA,UAAuB,CAAA,CAAC,CAAC,aAA4B,CAAA;QAC3E,MAAM,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAA;QAC1C,MAAM,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACxC,CAAC;iHALU,gBAAgB;oEAAhB,gBAAgB;;iFAAhB,gBAAgB;cAD5B,SAAS;eAAC,EAAE,QAAQ,EAAE,oBAAoB,EAAE,UAAU,EAAE,IAAI,EAAE"}
|
package/dist/index.d.ts
CHANGED
|
@@ -95,6 +95,13 @@
|
|
|
95
95
|
* Molecule service whose token was never provided fails at DI time.
|
|
96
96
|
* Per-concern helpers (`provideAuth`, `provideTheme`, ...) exist for
|
|
97
97
|
* piecemeal setup.
|
|
98
|
+
* - The Molecule Angular components render through `provideDomPlacement()`,
|
|
99
|
+
* which `provideMolecule` includes. An app or test that mounts them without
|
|
100
|
+
* `provideMolecule` adds `provideDomPlacement()` to its providers; a component
|
|
101
|
+
* that needs it throws a message naming it. A component never moves a node
|
|
102
|
+
* Angular rendered (`appendChild`, `insertBefore`, `remove`): it uses
|
|
103
|
+
* `useHostPresence`, `setElementPresent`, `placeElement`, `placeContent` or
|
|
104
|
+
* `WrappedChildren`, which keep Angular's own inserts working (NG05106).
|
|
98
105
|
* - In-app links use the `Link` directive (`<a molLink="/settings">`, `imports: [Link]`): it
|
|
99
106
|
* navigates through the molecule router with react-router `<Link>`'s click rules. A bare
|
|
100
107
|
* `<a href>` reloads the page; a hand-written `(click)` handler that calls `navigate()`
|
|
@@ -104,6 +111,7 @@
|
|
|
104
111
|
*/
|
|
105
112
|
export * from './agent-identity.js';
|
|
106
113
|
export * from './chat.js';
|
|
114
|
+
export * from './dom-placement.js';
|
|
107
115
|
export * from './hooks/index.js';
|
|
108
116
|
export * from './i18n-reactive.js';
|
|
109
117
|
export * from './link.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8GG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -95,6 +95,13 @@
|
|
|
95
95
|
* Molecule service whose token was never provided fails at DI time.
|
|
96
96
|
* Per-concern helpers (`provideAuth`, `provideTheme`, ...) exist for
|
|
97
97
|
* piecemeal setup.
|
|
98
|
+
* - The Molecule Angular components render through `provideDomPlacement()`,
|
|
99
|
+
* which `provideMolecule` includes. An app or test that mounts them without
|
|
100
|
+
* `provideMolecule` adds `provideDomPlacement()` to its providers; a component
|
|
101
|
+
* that needs it throws a message naming it. A component never moves a node
|
|
102
|
+
* Angular rendered (`appendChild`, `insertBefore`, `remove`): it uses
|
|
103
|
+
* `useHostPresence`, `setElementPresent`, `placeElement`, `placeContent` or
|
|
104
|
+
* `WrappedChildren`, which keep Angular's own inserts working (NG05106).
|
|
98
105
|
* - In-app links use the `Link` directive (`<a molLink="/settings">`, `imports: [Link]`): it
|
|
99
106
|
* navigates through the molecule router with react-router `<Link>`'s click rules. A bare
|
|
100
107
|
* `<a href>` reloads the page; a hand-written `(click)` handler that calls `navigate()`
|
|
@@ -104,6 +111,7 @@
|
|
|
104
111
|
*/
|
|
105
112
|
export * from './agent-identity.js';
|
|
106
113
|
export * from './chat.js';
|
|
114
|
+
export * from './dom-placement.js';
|
|
107
115
|
export * from './hooks/index.js';
|
|
108
116
|
export * from './i18n-reactive.js';
|
|
109
117
|
export * from './link.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;GAWG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,EAC/B,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;CAAO,GAC3C,oBAAoB,CAOtB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,YAAY,GAAG,oBAAoB,CAExE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,oBAAoB,CAEpE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,GAAG,oBAAoB,CAE9E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,cAAc,GAAG,oBAAoB,CAE5E;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,YAAY,GAAG,oBAAoB,CAExE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,oBAAoB,CAElF;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,cAAc,GAAG,oBAAoB,CAE5E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,GAAG,oBAAoB,CAE9E;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAgGlF"}
|
package/dist/providers.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { DestroyRef, inject, makeEnvironmentProviders, provideAppInitializer, provideEnvironmentInitializer, } from '@angular/core';
|
|
7
7
|
import { getProvider as getStateProvider, hasProvider as hasStateProvider, } from '@molecule/app-state';
|
|
8
|
+
import { provideDomPlacement } from './dom-placement.js';
|
|
8
9
|
import { bumpLocaleVersion } from './i18n-reactive.js';
|
|
9
10
|
import { ROUTED_VIEW } from './routed-view-token.js';
|
|
10
11
|
import { AUTH_CLIENT, CHAT_PROVIDER, EDITOR_PROVIDER, HTTP_CLIENT, I18N_PROVIDER, LOGGER_PROVIDER, PREVIEW_PROVIDER, ROUTER, STATE_PROVIDER, STORAGE_PROVIDER, THEME_PROVIDER, WORKSPACE_PROVIDER, } from './tokens.js';
|
|
@@ -151,7 +152,8 @@ export function providePreview(provider) {
|
|
|
151
152
|
* ```
|
|
152
153
|
*/
|
|
153
154
|
export function provideMolecule(config) {
|
|
154
|
-
|
|
155
|
+
// The ports' components render through it (host presence, wrapped children, portals).
|
|
156
|
+
const providers = [provideDomPlacement()];
|
|
155
157
|
// Like React's MoleculeProvider: fall back to the provider bonded under
|
|
156
158
|
// `@molecule/app-state` (the singleton every `createStore()` reads), so a
|
|
157
159
|
// scaffolded app needs no `state` option; an explicit `state` wins.
|
package/dist/providers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,UAAU,EACV,MAAM,EACN,wBAAwB,EACxB,qBAAqB,EACrB,6BAA6B,GAC9B,MAAM,eAAe,CAAA;AAYtB,OAAO,EACL,WAAW,IAAI,gBAAgB,EAC/B,WAAW,IAAI,gBAAgB,GAChC,MAAM,qBAAqB,CAAA;AAI5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EACL,WAAW,EACX,aAAa,EACb,eAAe,EACf,WAAW,EACX,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,MAAM,EACN,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,kBAAkB,GACnB,MAAM,aAAa,CAAA;AAGpB;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,QAAuB;IAClD,OAAO,wBAA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