@molecule/app-angular 3.10.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 +244 -11
- 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/hooks/use-router.js +1 -1
- package/dist/hooks/use-router.js.map +1 -1
- 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/dist/routed-view-token.js +1 -1
- package/dist/routed-view-token.js.map +1 -1
- package/dist/services/forms.service.d.ts +1 -0
- package/dist/services/forms.service.d.ts.map +1 -1
- package/dist/services/forms.service.js +1 -0
- package/dist/services/forms.service.js.map +1 -1
- package/package.json +5 -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
|
|
@@ -101,7 +101,7 @@ Pass `awaitSession: false` to render before the restore settles.
|
|
|
101
101
|
## Installation
|
|
102
102
|
|
|
103
103
|
```bash
|
|
104
|
-
npm install @molecule/app-angular @angular/core @molecule/app-ai-chat @molecule/app-ai-models @molecule/app-auth @molecule/app-
|
|
104
|
+
npm install @molecule/app-angular @angular/core @molecule/app-ai-chat @molecule/app-ai-models @molecule/app-auth @molecule/app-device @molecule/app-forms @molecule/app-http @molecule/app-i18n @molecule/app-logger @molecule/app-platform @molecule/app-push @molecule/app-routing @molecule/app-state @molecule/app-storage @molecule/app-theme @molecule/app-ui @molecule/app-utilities @molecule/app-version rxjs
|
|
105
105
|
```
|
|
106
106
|
|
|
107
107
|
## API
|
|
@@ -1275,7 +1275,8 @@ interface Router {
|
|
|
1275
1275
|
getHash(): string
|
|
1276
1276
|
|
|
1277
1277
|
/**
|
|
1278
|
-
* Navigates to a path.
|
|
1278
|
+
* Navigates to a path. A path that is only a query or a hash (`'?tab=2'`, `'#top'`) stays on
|
|
1279
|
+
* the current page, as React Router's `navigate` does; a hash alone drops the current query.
|
|
1279
1280
|
*/
|
|
1280
1281
|
navigate(path: string, options?: NavigateOptions): void
|
|
1281
1282
|
|
|
@@ -1342,7 +1343,9 @@ interface Router {
|
|
|
1342
1343
|
/**
|
|
1343
1344
|
* The `href` an anchor to the in-app `path` carries, as the native router's own link
|
|
1344
1345
|
* writes it (its base path prefixed, or `#/…` under a hash history), so a middle-click,
|
|
1345
|
-
* a new tab or a copied link opens the same page a click does.
|
|
1346
|
+
* a new tab or a copied link opens the same page a click does. A `path` that is only a
|
|
1347
|
+
* query or a hash (`'?tab=2'`, `'#top'`) is the current page's, as `navigate` reads it
|
|
1348
|
+
* and as React Router's `<Link>` writes it: `'#top'` on `/docs?x=1` is `/docs#top`.
|
|
1346
1349
|
*
|
|
1347
1350
|
* @param path - Pathname with optional query string and hash, as passed to `navigate`.
|
|
1348
1351
|
* @returns The `href`.
|
|
@@ -1350,7 +1353,15 @@ interface Router {
|
|
|
1350
1353
|
createHref(path: string): string
|
|
1351
1354
|
|
|
1352
1355
|
/**
|
|
1353
|
-
*
|
|
1356
|
+
* Calls `listener` once after each navigation the router commits, however it started (a
|
|
1357
|
+
* link, the back button, `navigate`), with the new location and the navigation action.
|
|
1358
|
+
* A router calls it before the browser paints the new page, so a component that renders
|
|
1359
|
+
* from a listener (the framework bindings' `useLocation` and `useParams` do) shows the new
|
|
1360
|
+
* location in the same paint as the new page. The router conformance cases of
|
|
1361
|
+
* `@molecule/app-framework-conformance/routing` check that at every paint.
|
|
1362
|
+
*
|
|
1363
|
+
* @param listener - Called with the new location and the navigation action.
|
|
1364
|
+
* @returns Stops calling `listener`.
|
|
1354
1365
|
*/
|
|
1355
1366
|
subscribe(listener: RouteChangeListener): () => void
|
|
1356
1367
|
|
|
@@ -3450,6 +3461,108 @@ type MaybeSignal<T> = T | Signal<T>
|
|
|
3450
3461
|
|
|
3451
3462
|
### Classes
|
|
3452
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
|
+
|
|
3453
3566
|
#### `Link`
|
|
3454
3567
|
|
|
3455
3568
|
`<a molLink="/settings">`: sets the anchor's `href` and navigates in-app
|
|
@@ -4837,6 +4950,117 @@ function useChat(options: UseChatOptions | Signal<UseChatOptions>): UseChatResul
|
|
|
4837
4950
|
|
|
4838
4951
|
**Returns:** Each state field as a signal, and the chat controls.
|
|
4839
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
|
+
|
|
4840
5064
|
#### `useExternalStore(read, subscribe)`
|
|
4841
5065
|
|
|
4842
5066
|
Subscribes to an external store and mirrors its value into a signal, with
|
|
@@ -6520,17 +6744,18 @@ Peer dependencies:
|
|
|
6520
6744
|
- `@molecule/app-ai-chat` ^1.8.0
|
|
6521
6745
|
- `@molecule/app-ai-models` ^1.0.1
|
|
6522
6746
|
- `@molecule/app-auth` ^3.0.0
|
|
6523
|
-
- `@molecule/app-code-editor` ^1.0.1
|
|
6747
|
+
- `@molecule/app-code-editor` ^1.0.1 _(optional)_
|
|
6524
6748
|
- `@molecule/app-device` ^1.0.1
|
|
6525
6749
|
- `@molecule/app-forms` ^2.4.0
|
|
6526
6750
|
- `@molecule/app-http` ^1.0.1
|
|
6527
6751
|
- `@molecule/app-i18n` ^1.0.1
|
|
6528
|
-
- `@molecule/app-ide` ^1.0.1
|
|
6529
|
-
- `@molecule/app-live-preview` ^1.0.1
|
|
6752
|
+
- `@molecule/app-ide` ^1.0.1 _(optional)_
|
|
6753
|
+
- `@molecule/app-live-preview` ^1.0.1 _(optional)_
|
|
6530
6754
|
- `@molecule/app-logger` ^1.0.1
|
|
6531
6755
|
- `@molecule/app-platform` ^1.0.1
|
|
6532
6756
|
- `@molecule/app-push` ^1.0.1
|
|
6533
6757
|
- `@molecule/app-routing` ^1.4.0
|
|
6758
|
+
- `@molecule/app-routing-angular-router` >=1.4.0 _(optional)_
|
|
6534
6759
|
- `@molecule/app-state` ^1.2.0
|
|
6535
6760
|
- `@molecule/app-storage` ^1.1.1
|
|
6536
6761
|
- `@molecule/app-theme` ^1.0.1
|
|
@@ -6545,17 +6770,18 @@ Peer dependencies:
|
|
|
6545
6770
|
- `@molecule/app-ai-chat`
|
|
6546
6771
|
- `@molecule/app-ai-models`
|
|
6547
6772
|
- `@molecule/app-auth`
|
|
6548
|
-
- `@molecule/app-code-editor`
|
|
6773
|
+
- `@molecule/app-code-editor` _(optional)_
|
|
6549
6774
|
- `@molecule/app-device`
|
|
6550
6775
|
- `@molecule/app-forms`
|
|
6551
6776
|
- `@molecule/app-http`
|
|
6552
6777
|
- `@molecule/app-i18n`
|
|
6553
|
-
- `@molecule/app-ide`
|
|
6554
|
-
- `@molecule/app-live-preview`
|
|
6778
|
+
- `@molecule/app-ide` _(optional)_
|
|
6779
|
+
- `@molecule/app-live-preview` _(optional)_
|
|
6555
6780
|
- `@molecule/app-logger`
|
|
6556
6781
|
- `@molecule/app-platform`
|
|
6557
6782
|
- `@molecule/app-push`
|
|
6558
6783
|
- `@molecule/app-routing`
|
|
6784
|
+
- `@molecule/app-routing-angular-router` _(optional)_
|
|
6559
6785
|
- `@molecule/app-state`
|
|
6560
6786
|
- `@molecule/app-storage`
|
|
6561
6787
|
- `@molecule/app-theme`
|
|
@@ -6578,6 +6804,13 @@ Peer dependencies:
|
|
|
6578
6804
|
Molecule service whose token was never provided fails at DI time.
|
|
6579
6805
|
Per-concern helpers (`provideAuth`, `provideTheme`, ...) exist for
|
|
6580
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).
|
|
6581
6814
|
- In-app links use the `Link` directive (`<a molLink="/settings">`, `imports: [Link]`): it
|
|
6582
6815
|
navigates through the molecule router with react-router `<Link>`'s click rules. A bare
|
|
6583
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,CAkB1D;AAkBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAc1F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAaxF;AAKD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,EACnC,MAAM,EAAE,IAAI,GAAG,IAAI,EACnB,MAAM,GAAE,IAAI,GAAG,IAAW,GACzB,IAAI,CAoBN;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAgBpE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,OAAO,GAAG,IAAI,CA4B9D;AAED;;;;;;;;;;;GAWG;AACH,qBACa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqC;IAC3D,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,MAAM,CAAmF;IAEjG,qCAAqC;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,SAAS,WAAW,EAAE,CAAC,CAA0B;;IAM3E;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,WAAW,GAAG,IAAI;IAI3D;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAQjC;;;;;OAKG;IACH,aAAa,IAAI,WAAW;IAM5B;;;;OAIG;IACH,OAAO,IAAI,IAAI;yCAtDJ,eAAe;;CAmE3B;AAED;;;;GAIG;AACH,qBACa,gBAAgB;;yCAAhB,gBAAgB;2CAAhB,gBAAgB;CAM5B"}
|