@molecule/app-timeline-angular 1.1.0 → 1.1.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 +44 -48
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/timeline.component.d.ts +15 -27
- package/dist/timeline.component.d.ts.map +1 -1
- package/dist/timeline.component.js +47 -50
- package/dist/timeline.component.js.map +1 -1
- package/package.json +5 -5
- package/dist/slot-dom.d.ts +0 -57
- package/dist/slot-dom.d.ts.map +0 -1
- package/dist/slot-dom.js +0 -100
- package/dist/slot-dom.js.map +0 -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-23T14:53:47.073Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-timeline-angular
|
|
@@ -434,13 +434,13 @@ come from `renderDateSeparator`, a template reference whose context carries
|
|
|
434
434
|
the event as `$implicit` / `a0` and its predecessor as `a1`.
|
|
435
435
|
|
|
436
436
|
React's root is the wrapper `<div>` — or, with no events and an empty state,
|
|
437
|
-
that empty state alone (a fragment).
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
437
|
+
that empty state alone (a fragment). Everything the host holds (the empty
|
|
438
|
+
state's capture and the wrapper `<div>`) renders in the host's place and the
|
|
439
|
+
host itself leaves the page, so the fragment root is React's exact DOM. The
|
|
440
|
+
empty state is projected content
|
|
441
441
|
(`[slot=emptyState]`) or a template reference passed as an input, reconciled
|
|
442
|
-
against React's branch by
|
|
443
|
-
|
|
442
|
+
against React's branch by the placement function registered in the
|
|
443
|
+
constructor. Rows are
|
|
444
444
|
tracked by the event's `id` value (`@for (…; track event.id)`), like React's
|
|
445
445
|
per-item keys.
|
|
446
446
|
|
|
@@ -452,16 +452,13 @@ same DOM for the same input.
|
|
|
452
452
|
@Component({
|
|
453
453
|
selector: 'mol-timeline',
|
|
454
454
|
standalone: true,
|
|
455
|
+
hostDirectives: [MolPlacement],
|
|
455
456
|
imports: [NgTemplateOutlet, TimelineEvent],
|
|
456
457
|
inputs: ['events', 'renderDateSeparator', 'emptyState', 'className'],
|
|
457
|
-
host: {
|
|
458
|
-
'data-parity-unwrap': '',
|
|
459
|
-
style: 'display: contents',
|
|
460
|
-
},
|
|
461
458
|
// prettier-ignore
|
|
462
|
-
template: `<span #empty
|
|
459
|
+
template: `<span #empty>@if (emptyText(); as text) {{{ text }}}@if (emptyTemplate(); as empty) {<ng-container [ngTemplateOutlet]="empty"></ng-container>}<ng-content select="[slot=emptyState]"></ng-content></span><div #list [class]="classes()">@for (event of events; track event.id; let i = $index) {<div>@if (separatorTemplate(); as separator) {<ng-container [ngTemplateOutlet]="separator" [ngTemplateOutletContext]="separatorContext(event, i)"></ng-container>}<div mol-timeline-event [event]="event" [isLast]="i === events.length - 1"></div></div>}</div>`,
|
|
463
460
|
})
|
|
464
|
-
export class Timeline
|
|
461
|
+
export class Timeline {
|
|
465
462
|
/** Events in display order. */
|
|
466
463
|
events: TimelineEventData[] = []
|
|
467
464
|
/** Optional renderer for date separators: a template reference with the event in its context. */
|
|
@@ -471,13 +468,19 @@ export class Timeline implements AfterViewInit, AfterViewChecked, DoCheck {
|
|
|
471
468
|
/** Extra classes on the outer wrapper. */
|
|
472
469
|
className?: string
|
|
473
470
|
|
|
474
|
-
/** The projected empty-state capture point (
|
|
471
|
+
/** The projected empty-state capture point (its content renders in its place, and it leaves the page). */
|
|
475
472
|
@ViewChild('empty') private empty?: ElementRef<HTMLElement>
|
|
476
473
|
|
|
477
474
|
/** The wrapper `<div>` (detached when the empty state renders instead). */
|
|
478
475
|
@ViewChild('list') private list?: ElementRef<HTMLElement>
|
|
479
476
|
|
|
480
|
-
private readonly
|
|
477
|
+
private readonly host: ElementRef<HTMLElement> = inject(ElementRef)
|
|
478
|
+
|
|
479
|
+
constructor() {
|
|
480
|
+
// React's root is the wrapper `<div>`, or the empty state alone (a fragment): the
|
|
481
|
+
// host's content renders in the host's place and the host itself leaves the page.
|
|
482
|
+
usePlacement((hasContent) => this.reconcile(hasContent))
|
|
483
|
+
}
|
|
481
484
|
|
|
482
485
|
/**
|
|
483
486
|
* The current class map.
|
|
@@ -535,42 +538,32 @@ export class Timeline implements AfterViewInit, AfterViewChecked, DoCheck {
|
|
|
535
538
|
return { $implicit: event, a0: event, a1: prev, a2: undefined }
|
|
536
539
|
}
|
|
537
540
|
|
|
538
|
-
/**
|
|
539
|
-
* Reconciles the projected empty state and the wrapper against React's
|
|
540
|
-
* branch once the view queries resolve.
|
|
541
|
-
*/
|
|
542
|
-
ngAfterViewInit(): void {
|
|
543
|
-
this.reconcile()
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
/**
|
|
547
|
-
* Re-reconciles on later passes, so a props step that empties or refills the
|
|
548
|
-
* list swaps the branch the way React does.
|
|
549
|
-
*/
|
|
550
|
-
ngDoCheck(): void {
|
|
551
|
-
this.reconcile()
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Re-reconciles after each view update: a node-valued empty state that arrives
|
|
556
|
-
* through an input renders into its outlet only during the update, so the
|
|
557
|
-
* branch decision must be read afterwards.
|
|
558
|
-
*/
|
|
559
|
-
ngAfterViewChecked(): void {
|
|
560
|
-
this.reconcile()
|
|
561
|
-
}
|
|
562
|
-
|
|
563
541
|
/**
|
|
564
542
|
* Applies React's condition: with no events and an empty state, the empty
|
|
565
543
|
* state renders bare and the wrapper disappears; otherwise the wrapper
|
|
566
544
|
* renders and the empty state is dropped.
|
|
545
|
+
*
|
|
546
|
+
* @param hasContent - Reads whether a slot has content.
|
|
567
547
|
*/
|
|
568
|
-
private reconcile(): void {
|
|
548
|
+
private reconcile(hasContent: SlotReader): void {
|
|
549
|
+
const host = this.host.nativeElement
|
|
569
550
|
const empty = this.empty?.nativeElement
|
|
570
551
|
const list = this.list?.nativeElement
|
|
571
|
-
const hasEmpty = (this.events?.length ?? 0) === 0 &&
|
|
572
|
-
|
|
573
|
-
|
|
552
|
+
const hasEmpty = (this.events?.length ?? 0) === 0 && hasContent(empty)
|
|
553
|
+
if (hasEmpty) {
|
|
554
|
+
// The capture's content renders exactly where the capture stood, and the capture
|
|
555
|
+
// itself leaves the page.
|
|
556
|
+
placeContentBefore(empty, empty)
|
|
557
|
+
} else {
|
|
558
|
+
// Back inside the capture, so it leaves the page with it.
|
|
559
|
+
placeContent(empty, null)
|
|
560
|
+
}
|
|
561
|
+
setElementPresent(empty, false)
|
|
562
|
+
setElementPresent(list, !hasEmpty)
|
|
563
|
+
// React's root is the fragment: everything renders in the host's place, and the host
|
|
564
|
+
// itself leaves the page.
|
|
565
|
+
placeContentBefore(host, host)
|
|
566
|
+
setElementPresent(host, false)
|
|
574
567
|
}
|
|
575
568
|
}
|
|
576
569
|
```
|
|
@@ -584,7 +577,7 @@ Peer dependencies:
|
|
|
584
577
|
- `@angular/common` ^22.0.0
|
|
585
578
|
- `@angular/core` ^22.0.0
|
|
586
579
|
- `@angular/platform-browser` ^22.0.0
|
|
587
|
-
- `@molecule/app-angular` ^3.
|
|
580
|
+
- `@molecule/app-angular` ^3.13.0
|
|
588
581
|
- `@molecule/app-ui` ^1.0.1
|
|
589
582
|
- `@molecule/app-ui-angular` ^1.1.0
|
|
590
583
|
|
|
@@ -599,14 +592,17 @@ Peer dependencies:
|
|
|
599
592
|
|
|
600
593
|
This is NOT the Angular binding for `@molecule/app-timeline` (the headless
|
|
601
594
|
provider core wired via `setProvider`) — it is standalone presentational
|
|
602
|
-
markup with no provider. For domain-specific rows see the sibling
|
|
603
|
-
`@molecule/app-
|
|
595
|
+
markup with no provider. For domain-specific rows see the sibling packages
|
|
596
|
+
`@molecule/app-activity-timeline-angular`, `@molecule/app-order-timeline-angular`,
|
|
597
|
+
`@molecule/app-status-timeline-angular`, `@molecule/app-stage-timeline-angular` and
|
|
598
|
+
`@molecule/app-day-timeline-angular`.
|
|
604
599
|
|
|
605
600
|
`TimelineEventData.accent` is currently INERT — no component reads it, so
|
|
606
601
|
setting it changes nothing; color a row by passing a custom `marker` node
|
|
607
602
|
instead. `timestamp` is a display node — format/translate it before
|
|
608
603
|
passing. Node-valued props are `ng-template` references; `Timeline`'s root is
|
|
609
|
-
a fragment in its empty branch, so its
|
|
604
|
+
a fragment in its empty branch, so its content renders in the host's place
|
|
605
|
+
and the host itself leaves the page, and rows
|
|
610
606
|
are tracked by the event's `id`, like React's keys. The prop surface
|
|
611
607
|
(documented on the exported `TimelineProps`, `TimelineEventProps`,
|
|
612
608
|
`TimelineRailProps` and `TimelineDateProps` interfaces):
|
package/dist/index.d.ts
CHANGED
|
@@ -40,14 +40,17 @@
|
|
|
40
40
|
* @remarks
|
|
41
41
|
* This is NOT the Angular binding for `@molecule/app-timeline` (the headless
|
|
42
42
|
* provider core wired via `setProvider`) — it is standalone presentational
|
|
43
|
-
* markup with no provider. For domain-specific rows see the sibling
|
|
44
|
-
* `@molecule/app-
|
|
43
|
+
* markup with no provider. For domain-specific rows see the sibling packages
|
|
44
|
+
* `@molecule/app-activity-timeline-angular`, `@molecule/app-order-timeline-angular`,
|
|
45
|
+
* `@molecule/app-status-timeline-angular`, `@molecule/app-stage-timeline-angular` and
|
|
46
|
+
* `@molecule/app-day-timeline-angular`.
|
|
45
47
|
*
|
|
46
48
|
* `TimelineEventData.accent` is currently INERT — no component reads it, so
|
|
47
49
|
* setting it changes nothing; color a row by passing a custom `marker` node
|
|
48
50
|
* instead. `timestamp` is a display node — format/translate it before
|
|
49
51
|
* passing. Node-valued props are `ng-template` references; `Timeline`'s root is
|
|
50
|
-
* a fragment in its empty branch, so its
|
|
52
|
+
* a fragment in its empty branch, so its content renders in the host's place
|
|
53
|
+
* and the host itself leaves the page, and rows
|
|
51
54
|
* are tracked by the event's `id`, like React's keys. The prop surface
|
|
52
55
|
* (documented on the exported `TimelineProps`, `TimelineEventProps`,
|
|
53
56
|
* `TimelineRailProps` and `TimelineDateProps` interfaces):
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH,cAAc,yBAAyB,CAAA;AACvC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -40,14 +40,17 @@
|
|
|
40
40
|
* @remarks
|
|
41
41
|
* This is NOT the Angular binding for `@molecule/app-timeline` (the headless
|
|
42
42
|
* provider core wired via `setProvider`) — it is standalone presentational
|
|
43
|
-
* markup with no provider. For domain-specific rows see the sibling
|
|
44
|
-
* `@molecule/app-
|
|
43
|
+
* markup with no provider. For domain-specific rows see the sibling packages
|
|
44
|
+
* `@molecule/app-activity-timeline-angular`, `@molecule/app-order-timeline-angular`,
|
|
45
|
+
* `@molecule/app-status-timeline-angular`, `@molecule/app-stage-timeline-angular` and
|
|
46
|
+
* `@molecule/app-day-timeline-angular`.
|
|
45
47
|
*
|
|
46
48
|
* `TimelineEventData.accent` is currently INERT — no component reads it, so
|
|
47
49
|
* setting it changes nothing; color a row by passing a custom `marker` node
|
|
48
50
|
* instead. `timestamp` is a display node — format/translate it before
|
|
49
51
|
* passing. Node-valued props are `ng-template` references; `Timeline`'s root is
|
|
50
|
-
* a fragment in its empty branch, so its
|
|
52
|
+
* a fragment in its empty branch, so its content renders in the host's place
|
|
53
|
+
* and the host itself leaves the page, and rows
|
|
51
54
|
* are tracked by the event's `id`, like React's keys. The prop surface
|
|
52
55
|
* (documented on the exported `TimelineProps`, `TimelineEventProps`,
|
|
53
56
|
* `TimelineRailProps` and `TimelineDateProps` interfaces):
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH,cAAc,yBAAyB,CAAA;AACvC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,YAAY,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TemplateRef } from '@angular/core';
|
|
2
2
|
import type { UIClassMap } from '@molecule/app-ui';
|
|
3
3
|
import type { TimelineEventData } from './types.js';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
|
+
import * as i1 from "@molecule/app-angular";
|
|
5
6
|
/**
|
|
6
7
|
* Timeline component.
|
|
7
8
|
*
|
|
@@ -11,13 +12,13 @@ import * as i0 from "@angular/core";
|
|
|
11
12
|
* the event as `$implicit` / `a0` and its predecessor as `a1`.
|
|
12
13
|
*
|
|
13
14
|
* React's root is the wrapper `<div>` — or, with no events and an empty state,
|
|
14
|
-
* that empty state alone (a fragment).
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* that empty state alone (a fragment). Everything the host holds (the empty
|
|
16
|
+
* state's capture and the wrapper `<div>`) renders in the host's place and the
|
|
17
|
+
* host itself leaves the page, so the fragment root is React's exact DOM. The
|
|
18
|
+
* empty state is projected content
|
|
18
19
|
* (`[slot=emptyState]`) or a template reference passed as an input, reconciled
|
|
19
|
-
* against React's branch by
|
|
20
|
-
*
|
|
20
|
+
* against React's branch by the placement function registered in the
|
|
21
|
+
* constructor. Rows are
|
|
21
22
|
* tracked by the event's `id` value (`@for (…; track event.id)`), like React's
|
|
22
23
|
* per-item keys.
|
|
23
24
|
*
|
|
@@ -25,7 +26,7 @@ import * as i0 from "@angular/core";
|
|
|
25
26
|
* `Timeline`: the same props (React names), the same ClassMap tokens, and the
|
|
26
27
|
* same DOM for the same input.
|
|
27
28
|
*/
|
|
28
|
-
export declare class Timeline
|
|
29
|
+
export declare class Timeline {
|
|
29
30
|
/** Events in display order. */
|
|
30
31
|
events: TimelineEventData[];
|
|
31
32
|
/** Optional renderer for date separators: a template reference with the event in its context. */
|
|
@@ -34,11 +35,12 @@ export declare class Timeline implements AfterViewInit, AfterViewChecked, DoChec
|
|
|
34
35
|
emptyState?: unknown;
|
|
35
36
|
/** Extra classes on the outer wrapper. */
|
|
36
37
|
className?: string;
|
|
37
|
-
/** The projected empty-state capture point (
|
|
38
|
+
/** The projected empty-state capture point (its content renders in its place, and it leaves the page). */
|
|
38
39
|
private empty?;
|
|
39
40
|
/** The wrapper `<div>` (detached when the empty state renders instead). */
|
|
40
41
|
private list?;
|
|
41
|
-
private readonly
|
|
42
|
+
private readonly host;
|
|
43
|
+
constructor();
|
|
42
44
|
/**
|
|
43
45
|
* The current class map.
|
|
44
46
|
* @returns The UIClassMap.
|
|
@@ -73,29 +75,15 @@ export declare class Timeline implements AfterViewInit, AfterViewChecked, DoChec
|
|
|
73
75
|
* @returns The template context.
|
|
74
76
|
*/
|
|
75
77
|
separatorContext(event: TimelineEventData, index: number): Record<string, unknown>;
|
|
76
|
-
/**
|
|
77
|
-
* Reconciles the projected empty state and the wrapper against React's
|
|
78
|
-
* branch once the view queries resolve.
|
|
79
|
-
*/
|
|
80
|
-
ngAfterViewInit(): void;
|
|
81
|
-
/**
|
|
82
|
-
* Re-reconciles on later passes, so a props step that empties or refills the
|
|
83
|
-
* list swaps the branch the way React does.
|
|
84
|
-
*/
|
|
85
|
-
ngDoCheck(): void;
|
|
86
|
-
/**
|
|
87
|
-
* Re-reconciles after each view update: a node-valued empty state that arrives
|
|
88
|
-
* through an input renders into its outlet only during the update, so the
|
|
89
|
-
* branch decision must be read afterwards.
|
|
90
|
-
*/
|
|
91
|
-
ngAfterViewChecked(): void;
|
|
92
78
|
/**
|
|
93
79
|
* Applies React's condition: with no events and an empty state, the empty
|
|
94
80
|
* state renders bare and the wrapper disappears; otherwise the wrapper
|
|
95
81
|
* renders and the empty state is dropped.
|
|
82
|
+
*
|
|
83
|
+
* @param hasContent - Reads whether a slot has content.
|
|
96
84
|
*/
|
|
97
85
|
private reconcile;
|
|
98
86
|
static ɵfac: i0.ɵɵFactoryDeclaration<Timeline, never>;
|
|
99
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<Timeline, "mol-timeline", never, { "events": { "alias": "events"; "required": false; }; "renderDateSeparator": { "alias": "renderDateSeparator"; "required": false; }; "emptyState": { "alias": "emptyState"; "required": false; }; "className": { "alias": "className"; "required": false; }; }, {}, never, ["[slot=emptyState]"], true,
|
|
87
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<Timeline, "mol-timeline", never, { "events": { "alias": "events"; "required": false; }; "renderDateSeparator": { "alias": "renderDateSeparator"; "required": false; }; "emptyState": { "alias": "emptyState"; "required": false; }; "className": { "alias": "className"; "required": false; }; }, {}, never, ["[slot=emptyState]"], true, [{ directive: typeof i1.MolPlacement; inputs: {}; outputs: {}; }]>;
|
|
100
88
|
}
|
|
101
89
|
//# sourceMappingURL=timeline.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline.component.d.ts","sourceRoot":"","sources":["../src/timeline.component.ts"],"names":[],"mappings":"AAOA,OAAO,
|
|
1
|
+
{"version":3,"file":"tim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common';
|
|
7
|
-
import { Component, ElementRef, inject,
|
|
7
|
+
import { Component, ElementRef, inject, TemplateRef, ViewChild } from '@angular/core';
|
|
8
|
+
import { MolPlacement, placeContent, placeContentBefore, setElementPresent, usePlacement, } from '@molecule/app-angular';
|
|
8
9
|
import { getClassMap } from '@molecule/app-ui';
|
|
9
|
-
import { hasNodes, SlotGuard } from './slot-dom.js';
|
|
10
10
|
import { TimelineEvent } from './timeline-event.component.js';
|
|
11
11
|
import * as i0 from "@angular/core";
|
|
12
|
+
import * as i1 from "@molecule/app-angular";
|
|
12
13
|
const _c0 = ["empty"];
|
|
13
14
|
const _c1 = ["list"];
|
|
14
15
|
const _c2 = [[["", "slot", "emptystate"]]];
|
|
@@ -20,12 +21,12 @@ function Timeline_Conditional_2_Template(rf, ctx) { if (rf & 1) {
|
|
|
20
21
|
i0.ɵɵtextInterpolate(ctx);
|
|
21
22
|
} }
|
|
22
23
|
function Timeline_Conditional_3_Template(rf, ctx) { if (rf & 1) {
|
|
23
|
-
i0.ɵɵelementContainer(0,
|
|
24
|
+
i0.ɵɵelementContainer(0, 2);
|
|
24
25
|
} if (rf & 2) {
|
|
25
26
|
i0.ɵɵproperty("ngTemplateOutlet", ctx);
|
|
26
27
|
} }
|
|
27
28
|
function Timeline_For_8_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
28
|
-
i0.ɵɵelementContainer(0,
|
|
29
|
+
i0.ɵɵelementContainer(0, 3);
|
|
29
30
|
} if (rf & 2) {
|
|
30
31
|
const ctx_r0 = i0.ɵɵnextContext();
|
|
31
32
|
const event_r2 = ctx_r0.$implicit;
|
|
@@ -35,8 +36,8 @@ function Timeline_For_8_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
|
35
36
|
} }
|
|
36
37
|
function Timeline_For_8_Template(rf, ctx) { if (rf & 1) {
|
|
37
38
|
i0.ɵɵelementStart(0, "div");
|
|
38
|
-
i0.ɵɵconditionalCreate(1, Timeline_For_8_Conditional_1_Template, 1, 2, "ng-container",
|
|
39
|
-
i0.ɵɵelement(2, "div",
|
|
39
|
+
i0.ɵɵconditionalCreate(1, Timeline_For_8_Conditional_1_Template, 1, 2, "ng-container", 3);
|
|
40
|
+
i0.ɵɵelement(2, "div", 4);
|
|
40
41
|
i0.ɵɵelementEnd();
|
|
41
42
|
} if (rf & 2) {
|
|
42
43
|
let tmp_13_0;
|
|
@@ -57,13 +58,13 @@ function Timeline_For_8_Template(rf, ctx) { if (rf & 1) {
|
|
|
57
58
|
* the event as `$implicit` / `a0` and its predecessor as `a1`.
|
|
58
59
|
*
|
|
59
60
|
* React's root is the wrapper `<div>` — or, with no events and an empty state,
|
|
60
|
-
* that empty state alone (a fragment).
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
61
|
+
* that empty state alone (a fragment). Everything the host holds (the empty
|
|
62
|
+
* state's capture and the wrapper `<div>`) renders in the host's place and the
|
|
63
|
+
* host itself leaves the page, so the fragment root is React's exact DOM. The
|
|
64
|
+
* empty state is projected content
|
|
64
65
|
* (`[slot=emptyState]`) or a template reference passed as an input, reconciled
|
|
65
|
-
* against React's branch by
|
|
66
|
-
*
|
|
66
|
+
* against React's branch by the placement function registered in the
|
|
67
|
+
* constructor. Rows are
|
|
67
68
|
* tracked by the event's `id` value (`@for (…; track event.id)`), like React's
|
|
68
69
|
* per-item keys.
|
|
69
70
|
*
|
|
@@ -80,11 +81,16 @@ export class Timeline {
|
|
|
80
81
|
emptyState;
|
|
81
82
|
/** Extra classes on the outer wrapper. */
|
|
82
83
|
className;
|
|
83
|
-
/** The projected empty-state capture point (
|
|
84
|
+
/** The projected empty-state capture point (its content renders in its place, and it leaves the page). */
|
|
84
85
|
empty;
|
|
85
86
|
/** The wrapper `<div>` (detached when the empty state renders instead). */
|
|
86
87
|
list;
|
|
87
|
-
|
|
88
|
+
host = inject(ElementRef);
|
|
89
|
+
constructor() {
|
|
90
|
+
// React's root is the wrapper `<div>`, or the empty state alone (a fragment): the
|
|
91
|
+
// host's content renders in the host's place and the host itself leaves the page.
|
|
92
|
+
usePlacement((hasContent) => this.reconcile(hasContent));
|
|
93
|
+
}
|
|
88
94
|
/**
|
|
89
95
|
* The current class map.
|
|
90
96
|
* @returns The UIClassMap.
|
|
@@ -138,39 +144,33 @@ export class Timeline {
|
|
|
138
144
|
const prev = index > 0 ? this.events[index - 1] : undefined;
|
|
139
145
|
return { $implicit: event, a0: event, a1: prev, a2: undefined };
|
|
140
146
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Reconciles the projected empty state and the wrapper against React's
|
|
143
|
-
* branch once the view queries resolve.
|
|
144
|
-
*/
|
|
145
|
-
ngAfterViewInit() {
|
|
146
|
-
this.reconcile();
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Re-reconciles on later passes, so a props step that empties or refills the
|
|
150
|
-
* list swaps the branch the way React does.
|
|
151
|
-
*/
|
|
152
|
-
ngDoCheck() {
|
|
153
|
-
this.reconcile();
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Re-reconciles after each view update: a node-valued empty state that arrives
|
|
157
|
-
* through an input renders into its outlet only during the update, so the
|
|
158
|
-
* branch decision must be read afterwards.
|
|
159
|
-
*/
|
|
160
|
-
ngAfterViewChecked() {
|
|
161
|
-
this.reconcile();
|
|
162
|
-
}
|
|
163
147
|
/**
|
|
164
148
|
* Applies React's condition: with no events and an empty state, the empty
|
|
165
149
|
* state renders bare and the wrapper disappears; otherwise the wrapper
|
|
166
150
|
* renders and the empty state is dropped.
|
|
151
|
+
*
|
|
152
|
+
* @param hasContent - Reads whether a slot has content.
|
|
167
153
|
*/
|
|
168
|
-
reconcile() {
|
|
154
|
+
reconcile(hasContent) {
|
|
155
|
+
const host = this.host.nativeElement;
|
|
169
156
|
const empty = this.empty?.nativeElement;
|
|
170
157
|
const list = this.list?.nativeElement;
|
|
171
|
-
const hasEmpty = (this.events?.length ?? 0) === 0 &&
|
|
172
|
-
|
|
173
|
-
|
|
158
|
+
const hasEmpty = (this.events?.length ?? 0) === 0 && hasContent(empty);
|
|
159
|
+
if (hasEmpty) {
|
|
160
|
+
// The capture's content renders exactly where the capture stood, and the capture
|
|
161
|
+
// itself leaves the page.
|
|
162
|
+
placeContentBefore(empty, empty);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
// Back inside the capture, so it leaves the page with it.
|
|
166
|
+
placeContent(empty, null);
|
|
167
|
+
}
|
|
168
|
+
setElementPresent(empty, false);
|
|
169
|
+
setElementPresent(list, !hasEmpty);
|
|
170
|
+
// React's root is the fragment: everything renders in the host's place, and the host
|
|
171
|
+
// itself leaves the page.
|
|
172
|
+
placeContentBefore(host, host);
|
|
173
|
+
setElementPresent(host, false);
|
|
174
174
|
}
|
|
175
175
|
static ɵfac = function Timeline_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Timeline)(); };
|
|
176
176
|
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Timeline, selectors: [["mol-timeline"]], viewQuery: function Timeline_Query(rf, ctx) { if (rf & 1) {
|
|
@@ -179,11 +179,11 @@ export class Timeline {
|
|
|
179
179
|
let _t;
|
|
180
180
|
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.empty = _t.first);
|
|
181
181
|
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.list = _t.first);
|
|
182
|
-
} },
|
|
182
|
+
} }, inputs: { events: "events", renderDateSeparator: "renderDateSeparator", emptyState: "emptyState", className: "className" }, features: [i0.ɵɵHostDirectivesFeature([i1.MolPlacement])], ngContentSelectors: _c3, decls: 9, vars: 4, consts: [["empty", ""], ["list", ""], [3, "ngTemplateOutlet"], [3, "ngTemplateOutlet", "ngTemplateOutletContext"], ["mol-timeline-event", "", 3, "event", "isLast"]], template: function Timeline_Template(rf, ctx) { if (rf & 1) {
|
|
183
183
|
i0.ɵɵprojectionDef(_c2);
|
|
184
|
-
i0.ɵɵelementStart(0, "span",
|
|
184
|
+
i0.ɵɵelementStart(0, "span", null, 0);
|
|
185
185
|
i0.ɵɵconditionalCreate(2, Timeline_Conditional_2_Template, 1, 1);
|
|
186
|
-
i0.ɵɵconditionalCreate(3, Timeline_Conditional_3_Template, 1, 1, "ng-container",
|
|
186
|
+
i0.ɵɵconditionalCreate(3, Timeline_Conditional_3_Template, 1, 1, "ng-container", 2);
|
|
187
187
|
i0.ɵɵprojection(4);
|
|
188
188
|
i0.ɵɵelementEnd();
|
|
189
189
|
i0.ɵɵelementStart(5, "div", null, 1);
|
|
@@ -207,21 +207,18 @@ export class Timeline {
|
|
|
207
207
|
args: [{
|
|
208
208
|
selector: 'mol-timeline',
|
|
209
209
|
standalone: true,
|
|
210
|
+
hostDirectives: [MolPlacement],
|
|
210
211
|
imports: [NgTemplateOutlet, TimelineEvent],
|
|
211
212
|
inputs: ['events', 'renderDateSeparator', 'emptyState', 'className'],
|
|
212
|
-
host: {
|
|
213
|
-
'data-parity-unwrap': '',
|
|
214
|
-
style: 'display: contents',
|
|
215
|
-
},
|
|
216
213
|
// prettier-ignore
|
|
217
|
-
template: `<span #empty
|
|
214
|
+
template: `<span #empty>@if (emptyText(); as text) {{{ text }}}@if (emptyTemplate(); as empty) {<ng-container [ngTemplateOutlet]="empty"></ng-container>}<ng-content select="[slot=emptyState]"></ng-content></span><div #list [class]="classes()">@for (event of events; track event.id; let i = $index) {<div>@if (separatorTemplate(); as separator) {<ng-container [ngTemplateOutlet]="separator" [ngTemplateOutletContext]="separatorContext(event, i)"></ng-container>}<div mol-timeline-event [event]="event" [isLast]="i === events.length - 1"></div></div>}</div>`,
|
|
218
215
|
}]
|
|
219
|
-
}],
|
|
216
|
+
}], () => [], { empty: [{
|
|
220
217
|
type: ViewChild,
|
|
221
218
|
args: ['empty']
|
|
222
219
|
}], list: [{
|
|
223
220
|
type: ViewChild,
|
|
224
221
|
args: ['list']
|
|
225
222
|
}] }); })();
|
|
226
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Timeline, { className: "Timeline", filePath: "timeline.component.ts", lineNumber:
|
|
223
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Timeline, { className: "Timeline", filePath: "timeline.component.ts", lineNumber: 56 }); })();
|
|
227
224
|
//# sourceMappingURL=timeline.component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline.component.js","sourceRoot":"","sources":["../src/timeline.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"timeline.component.js","sourceRoot":"","sources":["../src/timeline.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAErF,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EAEjB,YAAY,GACb,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;;;;;;;;;IAiCP,YAAU;;IAAV,yBAAU;;;IAAkC,2BAAwD;;IAA1C,sCAA0B;;;IAAiN,2BAAmH;;;;;;IAAtE,AAA/B,sCAA8B,6EAAuD;;;IAAjJ,2BAAK;IAAA,yFAAyC;IAAoH,yBAAiF;IAAA,iBAAM;;;;;;IAApP,cAA6J;IAA7J,4EAA6J;IAAwB,cAAe;IAAC,AAAhB,gCAAe,sDAAmC;;AA9BzhB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAUH,MAAM,OAAO,QAAQ;IACnB,+BAA+B;IAC/B,MAAM,GAAwB,EAAE,CAAA;IAChC,iGAAiG;IAC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AA4B;YAAW,mFAAiC;YAAyD,kBAAoD;YAAA,iBAAO;YAAA,oCAA+B;YAAA,8EAAkT;YAAA,iBAAM;;;;YAAnhB,eAAuC;YAAvC,+DAAuC;YAAA,cAA0F;YAA1F,mEAA0F;YAAsE,eAAmB;YAAnB,4BAAmB;YAAC,eAAkT;YAAlT,yBAAkT;4BAH3hB,gBAAgB,EAAE,aAAa;;iFAK9B,QAAQ;cATpB,SAAS;eAAC;gBACT,QAAQ,EAAE,cAAc;gBACxB,UAAU,EAAE,IAAI;gBAChB,cAAc,EAAE,CAAC,YAAY,CAAC;gBAC9B,OAAO,EAAE,CAAC,gBAAgB,EAAE,aAAa,CAAC;gBAC1C,MAAM,EAAE,CAAC,QAAQ,EAAE,qBAAqB,EAAE,YAAY,EAAE,WAAW,CAAC;gBACpE,kBAAkB;gBAClB,QAAQ,EAAE,kiBAAkiB;aAC7iB;;kBAYE,SAAS;mBAAC,OAAO;;kBAGjB,SAAS;mBAAC,MAAM;;kFAdN,QAAQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-timeline-angular",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Angular chronological timeline with event rails and date markers",
|
|
5
5
|
"homepage": "https://www.molecule.dev/packages/app-timeline-angular",
|
|
6
6
|
"type": "module",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@angular/common": "^22.0.0",
|
|
46
46
|
"@angular/core": "^22.0.0",
|
|
47
47
|
"@angular/platform-browser": "^22.0.0",
|
|
48
|
-
"@molecule/app-angular": "^3.
|
|
48
|
+
"@molecule/app-angular": "^3.13.0",
|
|
49
49
|
"@molecule/app-ui": "^1.0.1",
|
|
50
50
|
"@molecule/app-ui-angular": "^1.1.0"
|
|
51
51
|
},
|
|
@@ -55,14 +55,14 @@
|
|
|
55
55
|
"@angular/compiler-cli": "22.2.3",
|
|
56
56
|
"@angular/core": "22.2.3",
|
|
57
57
|
"@angular/platform-browser": "22.2.3",
|
|
58
|
-
"@molecule/app-angular": "3.
|
|
58
|
+
"@molecule/app-angular": "3.13.0",
|
|
59
59
|
"@molecule/app-framework-conformance": "0.0.0",
|
|
60
60
|
"@molecule/app-i18n": "1.2.2",
|
|
61
61
|
"@molecule/app-icons": "1.0.4",
|
|
62
62
|
"@molecule/app-ui": "1.5.0",
|
|
63
|
-
"@molecule/app-ui-angular": "1.
|
|
63
|
+
"@molecule/app-ui-angular": "1.5.1",
|
|
64
64
|
"@types/node": "26.6.5",
|
|
65
|
-
"jsdom": "
|
|
65
|
+
"jsdom": "31.0.1",
|
|
66
66
|
"rxjs": "7.8.2",
|
|
67
67
|
"typescript": "6.0.3",
|
|
68
68
|
"vitest": "4.1.12",
|
package/dist/slot-dom.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DOM helpers for the projected capture points of {@link Timeline}.
|
|
3
|
-
*
|
|
4
|
-
* React renders the empty state bare and drops the wrapper, or renders the
|
|
5
|
-
* wrapper and drops the empty state. Angular projection needs an
|
|
6
|
-
* always-mounted `<ng-content>` capture point, so the wrapper lives in the
|
|
7
|
-
* template unconditionally and these helpers reconcile it against React's DOM:
|
|
8
|
-
* the capture point is marked `data-parity-unwrap` (the snapshot expands it, so
|
|
9
|
-
* it looks like React's bare slot) and is detached together with its contents
|
|
10
|
-
* when React would not render it.
|
|
11
|
-
*
|
|
12
|
-
* @module
|
|
13
|
-
*/
|
|
14
|
-
import type { ElementRef, Renderer2 } from '@angular/core';
|
|
15
|
-
/**
|
|
16
|
-
* Whether an ng-content wrapper captured any element or text node.
|
|
17
|
-
*
|
|
18
|
-
* @param el - The wrapper element.
|
|
19
|
-
* @returns True when at least one projected node exists.
|
|
20
|
-
*/
|
|
21
|
-
export declare const hasNodes: (el: Element | undefined | null) => boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Reconciles one always-mounted wrapper against what React renders.
|
|
24
|
-
*
|
|
25
|
-
* Both operations are idempotent and anchored in the wrapper's current parent
|
|
26
|
-
* (default: the component host), so a wrapper whose contents move with it can
|
|
27
|
-
* be detached and re-attached across prop changes.
|
|
28
|
-
*/
|
|
29
|
-
export declare class SlotGuard {
|
|
30
|
-
private readonly host;
|
|
31
|
-
private readonly renderer;
|
|
32
|
-
private readonly anchors;
|
|
33
|
-
/**
|
|
34
|
-
* Creates the guard.
|
|
35
|
-
*
|
|
36
|
-
* @param host - The component host element (default anchor parent).
|
|
37
|
-
* @param renderer - The DOM renderer.
|
|
38
|
-
*/
|
|
39
|
-
constructor(host: ElementRef<HTMLElement>, renderer: Renderer2);
|
|
40
|
-
/**
|
|
41
|
-
* Attaches or detaches the element (contents move with it).
|
|
42
|
-
*
|
|
43
|
-
* @param el - The wrapper element.
|
|
44
|
-
* @param shouldAttach - Whether it should be in the DOM.
|
|
45
|
-
*/
|
|
46
|
-
toggle(el: Element | undefined | null, shouldAttach: boolean): void;
|
|
47
|
-
/**
|
|
48
|
-
* Returns the wrapper's anchor comment in `parent`, creating (or replacing a
|
|
49
|
-
* stale one) where the wrapper sits.
|
|
50
|
-
*
|
|
51
|
-
* @param parent - The anchor's parent.
|
|
52
|
-
* @param el - The wrapper the anchor stands for.
|
|
53
|
-
* @returns The connected anchor comment.
|
|
54
|
-
*/
|
|
55
|
-
private anchorIn;
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=slot-dom.d.ts.map
|
package/dist/slot-dom.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"slot-dom.d.ts","sourceRoot":"","sources":["../src/slot-dom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,IAAI,OAAO,GAAG,SAAS,GAAG,IAAI,KAAG,OAOzD,CAAA;AAED;;;;;;GAMG;AACH,qBAAa,SAAS;IAUlB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAV3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IAEtD;;;;;OAKG;gBAEgB,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,EAC7B,QAAQ,EAAE,SAAS;IAGtC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,EAAE,YAAY,EAAE,OAAO,GAAG,IAAI;IAoBnE;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ;CASjB"}
|
package/dist/slot-dom.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DOM helpers for the projected capture points of {@link Timeline}.
|
|
3
|
-
*
|
|
4
|
-
* React renders the empty state bare and drops the wrapper, or renders the
|
|
5
|
-
* wrapper and drops the empty state. Angular projection needs an
|
|
6
|
-
* always-mounted `<ng-content>` capture point, so the wrapper lives in the
|
|
7
|
-
* template unconditionally and these helpers reconcile it against React's DOM:
|
|
8
|
-
* the capture point is marked `data-parity-unwrap` (the snapshot expands it, so
|
|
9
|
-
* it looks like React's bare slot) and is detached together with its contents
|
|
10
|
-
* when React would not render it.
|
|
11
|
-
*
|
|
12
|
-
* @module
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* Whether an ng-content wrapper captured any element or text node.
|
|
16
|
-
*
|
|
17
|
-
* @param el - The wrapper element.
|
|
18
|
-
* @returns True when at least one projected node exists.
|
|
19
|
-
*/
|
|
20
|
-
export const hasNodes = (el) => {
|
|
21
|
-
if (!el)
|
|
22
|
-
return false;
|
|
23
|
-
for (const node of Array.from(el.childNodes)) {
|
|
24
|
-
if (node.nodeType === 1)
|
|
25
|
-
return true;
|
|
26
|
-
if (node.nodeType === 3 && (node.textContent ?? '').trim())
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
return false;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Reconciles one always-mounted wrapper against what React renders.
|
|
33
|
-
*
|
|
34
|
-
* Both operations are idempotent and anchored in the wrapper's current parent
|
|
35
|
-
* (default: the component host), so a wrapper whose contents move with it can
|
|
36
|
-
* be detached and re-attached across prop changes.
|
|
37
|
-
*/
|
|
38
|
-
export class SlotGuard {
|
|
39
|
-
host;
|
|
40
|
-
renderer;
|
|
41
|
-
anchors = new Map();
|
|
42
|
-
/**
|
|
43
|
-
* Creates the guard.
|
|
44
|
-
*
|
|
45
|
-
* @param host - The component host element (default anchor parent).
|
|
46
|
-
* @param renderer - The DOM renderer.
|
|
47
|
-
*/
|
|
48
|
-
constructor(host, renderer) {
|
|
49
|
-
this.host = host;
|
|
50
|
-
this.renderer = renderer;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Attaches or detaches the element (contents move with it).
|
|
54
|
-
*
|
|
55
|
-
* @param el - The wrapper element.
|
|
56
|
-
* @param shouldAttach - Whether it should be in the DOM.
|
|
57
|
-
*/
|
|
58
|
-
toggle(el, shouldAttach) {
|
|
59
|
-
if (!el)
|
|
60
|
-
return;
|
|
61
|
-
const parent = el.parentElement ?? this.host.nativeElement;
|
|
62
|
-
if (shouldAttach && !el.isConnected) {
|
|
63
|
-
const anchor = this.anchors.get(el);
|
|
64
|
-
if (anchor?.isConnected) {
|
|
65
|
-
parent.insertBefore(el, anchor);
|
|
66
|
-
this.renderer.removeChild(parent, anchor);
|
|
67
|
-
this.anchors.delete(el);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
parent.appendChild(el);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
else if (!shouldAttach && el.isConnected) {
|
|
74
|
-
// A placeholder comment keeps the re-insertion position stable; the
|
|
75
|
-
// conformance normalizer strips comment nodes, so it never shows.
|
|
76
|
-
this.anchorIn(parent, el);
|
|
77
|
-
this.renderer.removeChild(parent, el);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Returns the wrapper's anchor comment in `parent`, creating (or replacing a
|
|
82
|
-
* stale one) where the wrapper sits.
|
|
83
|
-
*
|
|
84
|
-
* @param parent - The anchor's parent.
|
|
85
|
-
* @param el - The wrapper the anchor stands for.
|
|
86
|
-
* @returns The connected anchor comment.
|
|
87
|
-
*/
|
|
88
|
-
anchorIn(parent, el) {
|
|
89
|
-
const existing = this.anchors.get(el);
|
|
90
|
-
if (existing?.isConnected && existing.parentNode === parent)
|
|
91
|
-
return existing;
|
|
92
|
-
if (existing)
|
|
93
|
-
this.anchors.delete(el);
|
|
94
|
-
const created = this.renderer.createComment('slot');
|
|
95
|
-
parent.insertBefore(created, el.isConnected ? el : null);
|
|
96
|
-
this.anchors.set(el, created);
|
|
97
|
-
return created;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=slot-dom.js.map
|
package/dist/slot-dom.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"slot-dom.js","sourceRoot":"","sources":["../src/slot-dom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EAA8B,EAAW,EAAE;IAClE,IAAI,CAAC,EAAE;QAAE,OAAO,KAAK,CAAA;IACrB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7C,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC;YAAE,OAAO,IAAI,CAAA;QACpC,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;YAAE,OAAO,IAAI,CAAA;IACzE,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED;;;;;;GAM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