@oslokommune/punkt-elements 19.10.2 → 19.11.0
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/CHANGELOG.md +27 -0
- package/dist/{accordion-BhCmUDoS.js → accordion-CjGAmoQq.js} +1 -1
- package/dist/{accordion-BFKmnCDh.cjs → accordion-lbYihdiw.cjs} +1 -1
- package/dist/{alert-BJPi5ylH.cjs → alert-CuXM6TnC.cjs} +1 -1
- package/dist/{alert-CUH_2zb2.js → alert-Xt26J9yX.js} +2 -2
- package/dist/base-elements/element-with-slot.d.ts +13 -0
- package/dist/{button-CWHqXdSG.cjs → button-BFG-7bDB.cjs} +1 -1
- package/dist/{button-DQ8rH8hx.js → button-DhCqyX4D.js} +1 -1
- package/dist/{card-DfVOJCWA.js → card-DCc3wfUb.js} +2 -2
- package/dist/{card-pJ0CDH2Y.cjs → card-Diivw_vm.cjs} +1 -1
- package/dist/{checkbox-BEBBPgYW.js → checkbox-CCBZc3Ix.js} +1 -1
- package/dist/{checkbox-3z2uH8rd.cjs → checkbox-Dyyrw5TE.cjs} +1 -1
- package/dist/{checkbox-group-DRQmSHyN.cjs → checkbox-group-COWUvl52.cjs} +1 -1
- package/dist/{checkbox-group-BiPX1EhY.js → checkbox-group-CsrEj7oZ.js} +2 -2
- package/dist/{combobox-CdmzQtCh.js → combobox-B0VWv9c_.js} +5 -5
- package/dist/{combobox-C_SMnNsj.cjs → combobox-I8qdg8A4.cjs} +1 -1
- package/dist/{consent-eTXt052m.js → consent-BUS6GEUu.js} +2 -2
- package/dist/{consent-CkK9BZ7t.cjs → consent-DBYZaCTp.cjs} +1 -1
- package/dist/{datepicker-BrQhahYy.cjs → datepicker-0NSvgPXK.cjs} +1 -1
- package/dist/{datepicker-DILpPWCY.js → datepicker-B80E_4Cg.js} +4 -4
- package/dist/directives/slot-content.d.ts +259 -62
- package/dist/docs/components/alert.d.ts +1 -1
- package/dist/docs/components/slot-internals.d.ts +14 -0
- package/dist/docs/components/slots.d.ts +2 -0
- package/dist/element-with-slot-CVmm0_IE.js +703 -0
- package/dist/element-with-slot-CcJPCLgn.cjs +1 -0
- package/dist/{fileupload-BZjZh8Mp.js → fileupload-BmfFC748.js} +3 -3
- package/dist/{fileupload-l1d9UQf9.cjs → fileupload-CyLRyoVU.cjs} +1 -1
- package/dist/{footer-C8Zh-eUU.cjs → footer-C6ajmlq2.cjs} +1 -1
- package/dist/{footer-X5MBVUoo.js → footer-L2vhQTAS.js} +1 -1
- package/dist/{header-DLH6Xx97.js → header-DLKiD7xm.js} +6 -6
- package/dist/{header-EvwDJXP-.cjs → header-IQvyDow3.cjs} +1 -1
- package/dist/{header-menu-0UtMd2_H.js → header-menu-Ch135F5Y.js} +1 -1
- package/dist/{header-menu-BqFpYI-V.cjs → header-menu-DpuxDU9a.cjs} +1 -1
- package/dist/{heading-DMHbL3xs.cjs → heading-BluavR6A.cjs} +1 -1
- package/dist/{heading-tWSLaRPD.js → heading-y72aIgB8.js} +1 -1
- package/dist/{helptext-CGa1p-yd.cjs → helptext-Bdv80rcs.cjs} +1 -1
- package/dist/{helptext-Dy2Ehs9W.js → helptext-Dujce_W9.js} +1 -1
- package/dist/{input-element-kIrd5ABs.cjs → input-element-B9Mhkoog.cjs} +1 -1
- package/dist/{input-element-BGbT4ICl.js → input-element-BdDamXvR.js} +1 -1
- package/dist/{input-wrapper-Uks0spRR.js → input-wrapper-Bb6CZxmg.js} +3 -3
- package/dist/{input-wrapper-EvzyXMw-.cjs → input-wrapper-BwzajfFX.cjs} +1 -1
- package/dist/{link-CLdiz-ly.cjs → link-CRLAhYi0.cjs} +1 -1
- package/dist/{link-C0yBFscy.js → link-sO401Ieh.js} +1 -1
- package/dist/{linkcard-B5-p-YC4.js → linkcard-DdmGxzAP.js} +1 -1
- package/dist/{linkcard-v9UsV9Os.cjs → linkcard-DnZgMzqL.cjs} +1 -1
- package/dist/{loader-DWvjIMsT.js → loader-Di5kHEQ4.js} +1 -1
- package/dist/{loader-C4UfUu2u.cjs → loader-Zo_VSsNw.cjs} +1 -1
- package/dist/{messagebox-clOimkn7.cjs → messagebox-CR59jv8N.cjs} +1 -1
- package/dist/{messagebox-CJTqxfu3.js → messagebox-CzaFlrYz.js} +1 -1
- package/dist/{modal-Bm1daKaW.js → modal-B3CQEBBB.js} +2 -2
- package/dist/{modal-BPweteoS.cjs → modal-BKeSXrzi.cjs} +1 -1
- package/dist/{option-group-element-2A4TBcp-.cjs → option-group-element-CzehfgVZ.cjs} +1 -1
- package/dist/{option-group-element-Ber7NAlg.js → option-group-element-D5PgGNdt.js} +2 -2
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +1 -1
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-checkbox-group.cjs +1 -1
- package/dist/pkt-checkbox-group.js +1 -1
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-footer.cjs +1 -1
- package/dist/pkt-footer.js +1 -1
- package/dist/pkt-header-menu.cjs +1 -1
- package/dist/pkt-header-menu.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-heading.cjs +1 -1
- package/dist/pkt-heading.js +1 -1
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +29 -29
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +1 -1
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/{pkt-options-controller-Ck_549wx.cjs → pkt-options-controller-139UsV4h.cjs} +1 -1
- package/dist/{pkt-options-controller-DTOlYR9b.js → pkt-options-controller-CHosj1Oo.js} +1 -1
- package/dist/pkt-radio-group.cjs +1 -1
- package/dist/pkt-radio-group.js +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +1 -1
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/pkt-timepicker.cjs +1 -1
- package/dist/pkt-timepicker.js +1 -1
- package/dist/{radio-group-CMtx_GRV.js → radio-group-CZGcjEmV.js} +2 -2
- package/dist/{radio-group-9Szx2XyM.cjs → radio-group-DaIRh-fL.cjs} +1 -1
- package/dist/{radiobutton-CYbvJ9y8.js → radiobutton-BJCSVvcQ.js} +1 -1
- package/dist/{radiobutton-Dq2qkfi0.cjs → radiobutton-qTPNeZl5.cjs} +1 -1
- package/dist/{scroll-lock-BN8lOhV5.cjs → scroll-lock-B46ur0FF.cjs} +1 -1
- package/dist/{scroll-lock-DAbNKAUy.js → scroll-lock-BALd8hF9.js} +4 -1
- package/dist/{select-DlgOxHIl.js → select-CIAfUw8F.js} +4 -4
- package/dist/{select-1nm17iN8.cjs → select-CQpwjRPh.cjs} +1 -1
- package/dist/shared-utils/scroll-lock/index.d.ts +3 -1
- package/dist/{tabs-D3pPS9us.js → tabs-DBW3P90Z.js} +2 -1
- package/dist/{tabs-8Y5PlmLl.cjs → tabs-R1Jzzj3-.cjs} +1 -1
- package/dist/{tag-DOUsW7nS.cjs → tag-BMtnaJ1A.cjs} +1 -1
- package/dist/{tag-qHYIycl8.js → tag-uVXp7uP-.js} +1 -1
- package/dist/{textarea-B3qIDyEQ.js → textarea-553WDMEq.js} +3 -3
- package/dist/{textarea-DkeCQKmM.cjs → textarea-DWLVisQX.cjs} +1 -1
- package/dist/{textinput-DibZCHh_.cjs → textinput-C7JFm9jD.cjs} +1 -1
- package/dist/{textinput-CwvVRNsP.js → textinput-wZSCpQgv.js} +3 -3
- package/dist/{timepicker-C_oG9W9Y.js → timepicker-CMe0IbPm.js} +3 -3
- package/dist/{timepicker-CZ_1HVlF.cjs → timepicker-DVyi8teh.cjs} +1 -1
- package/package.json +2 -2
- package/src/components/button/button.test.ts +13 -0
- package/src/components/consent/consent.ts +3 -1
- package/src/components/tabs/tabitem.ts +1 -0
- package/dist/element-with-slot-DOt8HbXA.cjs +0 -1
- package/dist/element-with-slot-U981OZM_.js +0 -353
|
@@ -1,138 +1,330 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
import { AsyncDirective, PartInfo } from 'lit/async-directive.js';
|
|
3
3
|
import { ChildPart, ElementPart } from 'lit/directive.js';
|
|
4
|
-
/**
|
|
5
|
-
* Returns the SlotManager for a host, creating one if it doesn't exist.
|
|
6
|
-
* Call this in connectedCallback() to eagerly collect children before Lit renders.
|
|
7
|
-
*/
|
|
4
|
+
/** Returns the host's SlotManager, and creates it the first time. */
|
|
8
5
|
export declare function getSlotManager(host: LitElement): SlotManager;
|
|
6
|
+
/** The default slot's key. A symbol, so no slot name can be mistaken for it. */
|
|
9
7
|
declare const DEFAULT_SLOT: unique symbol;
|
|
10
8
|
type SlotKey = string | typeof DEFAULT_SLOT;
|
|
9
|
+
/** Which of a source host's slots a forwarding hands to which of the child's slots. */
|
|
11
10
|
type SlotMapping = Array<[from: SlotKey, to: SlotKey]>;
|
|
11
|
+
/** The forwardSlots() argument: slot names kept as they are, or a map from name to name. */
|
|
12
12
|
type ForwardedSlots = Array<string | null> | Record<string, string | null>;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* IMPORTANT: collectNodes() must be called BEFORE Lit's first render
|
|
19
|
-
* (typically in connectedCallback via PktElement.hasSlotContent or getSlotManager).
|
|
20
|
-
* Lit's first render clears host children, so collecting during render is too late.
|
|
14
|
+
* Keeps track of one host's content: which nodes belong to which slot, where each distributed
|
|
15
|
+
* node's placeholder is, and which parts show them. It learns about changes in three ways:
|
|
16
|
+
* through the host's overridden DOM methods (handled at once), through a MutationObserver on
|
|
17
|
+
* the host's subtree, and through text accessors (watchText()).
|
|
21
18
|
*/
|
|
22
19
|
export declare class SlotManager {
|
|
23
20
|
private host;
|
|
24
|
-
|
|
21
|
+
/** The content by slot, in the order of the host's children. Includes mirrors. */
|
|
25
22
|
private nodesBySlot;
|
|
26
|
-
|
|
27
|
-
private observing;
|
|
23
|
+
/** The content nodes this manager owns. Mirrors are not tracked. */
|
|
28
24
|
private trackedNodes;
|
|
29
|
-
|
|
30
|
-
private initialCollectionDone;
|
|
31
|
-
private processingMutations;
|
|
25
|
+
/** Placeholder to distributed node, and whitespace to its mirror. */
|
|
32
26
|
private placeholderToNode;
|
|
27
|
+
/** Distributed node to placeholder, and mirror to its whitespace. */
|
|
33
28
|
private nodeToPlaceholder;
|
|
34
29
|
private static PLACEHOLDER_PREFIX;
|
|
30
|
+
/** Whitespace among the host's children that lies between content, and its mirror. */
|
|
31
|
+
private mirrorOf;
|
|
32
|
+
/** Whether the host has had whitespace text, which syncWhitespace() then has to look at. */
|
|
33
|
+
private hasWhitespace;
|
|
34
|
+
/** Where the first and last default-slot content stood at the last syncWhitespace(). */
|
|
35
|
+
private contentBounds;
|
|
36
|
+
/** Whitespace added or changed since the last syncWhitespace(). */
|
|
37
|
+
private changedWhitespace;
|
|
38
|
+
/** The host's slotContent() parts. */
|
|
39
|
+
private directives;
|
|
40
|
+
/** Hosts whose content this manager includes, by the forwardSlots() directive that set it up. */
|
|
35
41
|
private sources;
|
|
42
|
+
/** Managers that include this host's content. */
|
|
36
43
|
private subscribers;
|
|
37
|
-
|
|
44
|
+
/** Bumped on every change, so that a part can skip placing nodes when nothing changed. */
|
|
45
|
+
generation: number;
|
|
46
|
+
/** Whether collectNodes() has run. */
|
|
47
|
+
private initialCollectionDone;
|
|
48
|
+
/** True during an own change (see asOwnChange()). */
|
|
49
|
+
private inOwnChange;
|
|
50
|
+
/** True while Lit renders the host. Lit's insertions into the host are then left alone. */
|
|
51
|
+
private rendering;
|
|
52
|
+
/** The comment between the content and the template (see insertContentEnd()). */
|
|
53
|
+
private contentEnd;
|
|
54
|
+
/** Lit's marker at the start of the template. The content end goes back in front of it. */
|
|
55
|
+
private rootMarker;
|
|
56
|
+
private observer;
|
|
57
|
+
private observing;
|
|
58
|
+
/** Whether the observer should run whenever the host is connected. */
|
|
38
59
|
private wantsObserver;
|
|
60
|
+
/** Whether the host is a LitElement, whose renders the manager hooks into. */
|
|
61
|
+
private followsHostRenders;
|
|
62
|
+
/**
|
|
63
|
+
* Hooks into the host's lifecycle:
|
|
64
|
+
* - hostConnected: observe again, and catch up on changes made while disconnected
|
|
65
|
+
* - hostUpdate, before Lit renders: handle pending changes by others, and before the first
|
|
66
|
+
* render, register content added since connectedCallback and insert the content end
|
|
67
|
+
* - hostUpdated, after Lit renders: note Lit's root marker, and handle the render's own
|
|
68
|
+
* changes as Lit's, not as content changes
|
|
69
|
+
*/
|
|
39
70
|
constructor(host: LitElement);
|
|
40
71
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* Safe to call multiple times — only the first call scans.
|
|
72
|
+
* Registers the host's children as content. Runs once: in connectedCallback, or earlier when
|
|
73
|
+
* a part or a forwarding needs the content first.
|
|
44
74
|
*/
|
|
45
75
|
collectNodes(): void;
|
|
76
|
+
/** Registers children added between connectedCallback and the first render. */
|
|
46
77
|
private collectLateChildren;
|
|
47
|
-
/**
|
|
48
|
-
* Register a directive instance and start observing for dynamic changes.
|
|
49
|
-
*/
|
|
78
|
+
/** Registers a slotContent() part of the host, and starts observing. */
|
|
50
79
|
addDirective(d: SlotContentDirective): void;
|
|
80
|
+
/** Unregisters a part, when Lit disconnects it. */
|
|
81
|
+
removeDirective(d: SlotContentDirective): void;
|
|
51
82
|
/**
|
|
52
|
-
*
|
|
83
|
+
* Includes another host's slots in this manager's slots, as set up by the forwardSlots()
|
|
84
|
+
* directive `token`. The source keeps observing its own children while anyone subscribes.
|
|
53
85
|
*/
|
|
54
|
-
removeDirective(d: SlotContentDirective): void;
|
|
55
86
|
addSource(token: object, manager: SlotManager, mapping: SlotMapping): void;
|
|
87
|
+
/** Stops including the slots that the forwardSlots() directive `token` handed over. */
|
|
56
88
|
removeSource(token: object): void;
|
|
89
|
+
/** Unsubscribes from a source manager, unless another forwarding still uses it. */
|
|
90
|
+
private detachFrom;
|
|
57
91
|
/**
|
|
58
|
-
*
|
|
92
|
+
* The parts that show this host's content: its own, and those of every manager that includes
|
|
93
|
+
* it, through whole forwarding chains.
|
|
59
94
|
*/
|
|
95
|
+
private reachableParts;
|
|
96
|
+
/** The content of a slot, forwarded content included. Behind hasSlotContent(). */
|
|
60
97
|
getNodes(slotName?: string): Node[];
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
|
|
98
|
+
/** The nodes a part places: the slot's content, and the mirrors between it. */
|
|
99
|
+
placementNodes(slotName?: string): Node[];
|
|
100
|
+
/** Whether a slot has content. */
|
|
64
101
|
hasContent(slotName?: string): boolean;
|
|
102
|
+
/** The host's own nodes for a slot, followed by those forwarded to it. */
|
|
103
|
+
private nodesFor;
|
|
65
104
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* template conditionally removes the content, the MutationObserver can detect
|
|
70
|
-
* the placeholder removal and clean up the real node.
|
|
105
|
+
* Gives a node a placeholder among the host's children before a part moves it away. For
|
|
106
|
+
* forwarded content the source host gets the placeholder. Content found in the template
|
|
107
|
+
* region (inserted there past the overrides) gets its placeholder at the end of the content.
|
|
71
108
|
*/
|
|
72
109
|
ensurePlaceholder(node: Node): void;
|
|
73
|
-
private nodesFor;
|
|
74
|
-
private detachFrom;
|
|
75
|
-
private handleChange;
|
|
76
|
-
private stopObservingIfUnused;
|
|
77
110
|
/**
|
|
78
|
-
*
|
|
111
|
+
* Creates and registers a node's placeholder. A text node's placeholder forwards writes to
|
|
112
|
+
* `data` to the text: a Lit parent updates a text binding by writing to the node after its
|
|
113
|
+
* marker, and once the text is distributed, that node is the placeholder.
|
|
114
|
+
*/
|
|
115
|
+
private createPlaceholder;
|
|
116
|
+
/** Unregisters a node's placeholder and returns it. The placeholder stays in the DOM. */
|
|
117
|
+
private forgetPlaceholder;
|
|
118
|
+
/** The placeholder of a node this manager tracks. Mirrors have none. */
|
|
119
|
+
private placeholderOf;
|
|
120
|
+
/**
|
|
121
|
+
* Runs a change that others make to the host's children, and handles it at once instead of
|
|
122
|
+
* when the observer reports it. While Lit renders the host, the change is Lit's own and runs
|
|
123
|
+
* as it is.
|
|
124
|
+
*/
|
|
125
|
+
handleNow<T>(change: () => T): T;
|
|
126
|
+
/**
|
|
127
|
+
* Translates a reference node given to the host's DOM methods (insertBefore(node, child)) to
|
|
128
|
+
* the host child to insert before:
|
|
129
|
+
* - a distributed node: its placeholder
|
|
130
|
+
* - another node in a part, like Lit's end marker after the last distributed node: next to
|
|
131
|
+
* the nearest distributed node, or the end of the content when the part holds none
|
|
132
|
+
* - `null`, or a node of the template: the end of the content
|
|
133
|
+
* Anything else is returned as it is, and the native method decides.
|
|
134
|
+
*/
|
|
135
|
+
positionInHost(node: Node | null): Node | null;
|
|
136
|
+
/** Whether this manager tracks a node, so the host's removeChild() may remove it from a part. */
|
|
137
|
+
owns(node: Node): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Moves a distributed node to a new position: its placeholder among the host's children
|
|
140
|
+
* (before `before`, or last), and the node itself to the matching place in its part. This is
|
|
141
|
+
* a keyed reorder (Vue v-for, React key), done without placing the whole slot again. Returns
|
|
142
|
+
* false when the move is not that simple, and the caller inserts natively instead.
|
|
143
|
+
*/
|
|
144
|
+
moveDistributed(node: Node, before: Node | null): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Replaces all the host's content with the given nodes and leaves the template alone. Behind
|
|
147
|
+
* the textContent, innerHTML and innerText setters and replaceChildren(). Returns false when
|
|
148
|
+
* the native method should run instead: before the content is collected or the template
|
|
149
|
+
* rendered, and when a node contains the host, which the native method rejects.
|
|
150
|
+
*/
|
|
151
|
+
replaceContent(newNodes: Node[]): boolean;
|
|
152
|
+
/** Makes text among the host's children content, once it has more than whitespace. */
|
|
153
|
+
adoptText(text: Text): void;
|
|
154
|
+
/**
|
|
155
|
+
* Text among the host's children changed without getting real text. Whitespace updates its
|
|
156
|
+
* mirror; otherwise the whitespace between content is worked out again.
|
|
157
|
+
*/
|
|
158
|
+
blankTextChanged(text: Text): void;
|
|
159
|
+
/**
|
|
160
|
+
* Distributed text that became empty or blank is no longer content. It goes back to its
|
|
161
|
+
* placeholder's place among the host's children, where a Lit parent or a framework can give
|
|
162
|
+
* it text again (adoptText()).
|
|
163
|
+
*/
|
|
164
|
+
releaseText(text: Text): void;
|
|
165
|
+
/** Watches text among the host's children, and notes whitespace for syncWhitespace(). */
|
|
166
|
+
private watchHostText;
|
|
167
|
+
/**
|
|
168
|
+
* Gives whitespace among the host's children that lies between the first and the last
|
|
169
|
+
* default-slot content a mirror in the slot, and takes it away from whitespace that no longer
|
|
170
|
+
* does. Whitespace at the start or the end of the content gets none. Runs on every change, so
|
|
171
|
+
* it only looks where something can have changed:
|
|
172
|
+
* - mirrors that are no longer between content sit at the ends of the default slot's list,
|
|
173
|
+
* since the list is in the order of the host's children
|
|
174
|
+
* - whitespace that was added or changed
|
|
175
|
+
* - whitespace where the first or the last content moved outwards, or next to the new first
|
|
176
|
+
* or last content when it moved inwards
|
|
177
|
+
*
|
|
178
|
+
* The whitespace itself is never moved, because a Lit parent may use it as the end of a
|
|
179
|
+
* part (`${a} ${b}`): moving it would make clearing `a` remove `b` as well. It acts as the
|
|
180
|
+
* mirror's placeholder instead, so the mirror moves and goes with it.
|
|
181
|
+
*/
|
|
182
|
+
private syncWhitespace;
|
|
183
|
+
/** Drops the mirrors before the first and after the last content in the default slot. */
|
|
184
|
+
private dropMirrorsOutside;
|
|
185
|
+
/** Whether one child of the host comes before another. */
|
|
186
|
+
private precedes;
|
|
187
|
+
/** Adds the whitespace next to a content's place, up to the nearest other content, to `into`. */
|
|
188
|
+
private collectBlankBeside;
|
|
189
|
+
/** The first and last default-slot content that has a place among the host's children. */
|
|
190
|
+
private findContentBounds;
|
|
191
|
+
/** The host child that holds a content node's place: its placeholder, or the node itself. */
|
|
192
|
+
private placeOf;
|
|
193
|
+
/** Whether a child of the host stands between the first and the last content. */
|
|
194
|
+
private isBetween;
|
|
195
|
+
/** Adds the whitespace among the host's children between two of its children to `into`. */
|
|
196
|
+
private collectBlankBetween;
|
|
197
|
+
/** Gives a piece of whitespace its mirror, in its place in the default slot. */
|
|
198
|
+
private addMirror;
|
|
199
|
+
/** Removes the mirror of a piece of whitespace, from the DOM and from the slot. */
|
|
200
|
+
private dropMirror;
|
|
201
|
+
/**
|
|
202
|
+
* Appends the content end, right before the first render, so that Lit renders the template
|
|
203
|
+
* after it. Insertions with no reference node go before it (positionInHost()).
|
|
204
|
+
*
|
|
205
|
+
* It reports no next sibling. A Lit parent with no whitespace before the closing tag
|
|
206
|
+
* (`<pkt-button>${label}</pkt-button>`) has a part that runs to the end of the host, and
|
|
207
|
+
* clears it by following nextSibling until null, so the clear stops here instead of removing
|
|
208
|
+
* the template. Such a clear removes the content end itself, and getContentEnd() puts it back.
|
|
209
|
+
*/
|
|
210
|
+
private insertContentEnd;
|
|
211
|
+
/**
|
|
212
|
+
* Returns the content end, after putting it back in front of the template if a clear removed
|
|
213
|
+
* it. Null before the first render.
|
|
214
|
+
*/
|
|
215
|
+
private getContentEnd;
|
|
216
|
+
/** Whether a child of the host is the content end or comes after it: Lit's template. */
|
|
217
|
+
private isInTemplate;
|
|
218
|
+
/**
|
|
219
|
+
* Starts the MutationObserver on the host's subtree. It sees content added to the host,
|
|
220
|
+
* content removed wherever it is (in parts too), and nodes frameworks insert into parts.
|
|
79
221
|
*/
|
|
80
222
|
private startObserving;
|
|
81
|
-
|
|
223
|
+
/** Stops the observer. Pending records are dropped; resync() catches up on reconnect. */
|
|
82
224
|
private stopObserving;
|
|
225
|
+
/** Stops observing when the host is disconnected, or nobody needs the observer anymore. */
|
|
226
|
+
private stopObservingIfUnused;
|
|
83
227
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* Uses a guard flag to prevent recursive handling: when notifyDirectives()
|
|
88
|
-
* makes a directive move nodes (e.g., from host into a ChildPart container),
|
|
89
|
-
* that move triggers another mutation which must be ignored.
|
|
228
|
+
* Handles the observer's pending records now. `fromHostRender` marks them as changes Lit made
|
|
229
|
+
* while rendering the host, which are not content changes.
|
|
90
230
|
*/
|
|
231
|
+
private flushMutations;
|
|
232
|
+
/** Handles observer records as an own change, so the moves it makes are not handled again. */
|
|
91
233
|
private handleMutations;
|
|
234
|
+
/** Updates the content from what others added to and removed from the host's subtree. */
|
|
235
|
+
private applyMutations;
|
|
236
|
+
/**
|
|
237
|
+
* Handles nodes a framework inserted inside a part while removing some of this host's content
|
|
238
|
+
* from it, which is how Vue replaces a distributed element: it works through the element's
|
|
239
|
+
* current parent. Content is registered where it is, with a placeholder at the matching
|
|
240
|
+
* position among the host's children, so focus and state survive. Anything else (anchors) is
|
|
241
|
+
* moved to that position among the host's children, where the framework expects it.
|
|
242
|
+
*/
|
|
92
243
|
private adoptNodesInParts;
|
|
244
|
+
/**
|
|
245
|
+
* Where among the host's children a node in a part belongs: by the placeholders of the
|
|
246
|
+
* distributed nodes next to it in the part, or else where a node was just removed from the
|
|
247
|
+
* same part.
|
|
248
|
+
*/
|
|
93
249
|
private hostPositionFor;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
250
|
+
/**
|
|
251
|
+
* Catches up on changes made while the host was disconnected and nothing observed it:
|
|
252
|
+
* content removed meanwhile (or whose placeholder was removed) is dropped instead of being
|
|
253
|
+
* put back, content added meanwhile is registered, and moved placeholders reorder the slot.
|
|
254
|
+
*/
|
|
255
|
+
private resync;
|
|
256
|
+
/**
|
|
257
|
+
* Puts each slot in the order of its placeholders. When the order changed, the slot's nodes
|
|
258
|
+
* are taken out of their parts, and the parts place them again in the new order.
|
|
259
|
+
*/
|
|
260
|
+
private sortSlots;
|
|
261
|
+
/**
|
|
262
|
+
* Called after every content change: works out the whitespace between content again, has the
|
|
263
|
+
* parts and the managers that include this host place their nodes, and re-renders the host,
|
|
264
|
+
* so that anything computed from hasSlotContent() is up to date.
|
|
265
|
+
*/
|
|
266
|
+
private handleChange;
|
|
267
|
+
/** Tells the host's parts to place their nodes. */
|
|
268
|
+
private notifyDirectives;
|
|
269
|
+
/**
|
|
270
|
+
* Runs DOM changes made by this file, and drops the observer records they cause, so that they
|
|
271
|
+
* are not handled as changes by others. Restores the flag even if a change throws.
|
|
272
|
+
*/
|
|
273
|
+
private asOwnChange;
|
|
274
|
+
/** Registers a content node, at its place in its slot. */
|
|
275
|
+
private addContent;
|
|
276
|
+
/** Unregisters a content node. Its placeholder is left to the caller. */
|
|
277
|
+
private removeContent;
|
|
278
|
+
/** Marks a node as content of this host, and watches it if it is text. */
|
|
97
279
|
private track;
|
|
98
280
|
private untrack;
|
|
99
281
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
282
|
+
* Adds a node to its slot's list, ordered by where it stands among the host's children (by
|
|
283
|
+
* its placeholder, if it has one).
|
|
102
284
|
*/
|
|
103
|
-
private
|
|
285
|
+
private insertInSlotOrder;
|
|
286
|
+
/** Removes a node from whichever slot's list holds it. */
|
|
104
287
|
private removeFromSlots;
|
|
105
|
-
private notifyDirectives;
|
|
106
288
|
}
|
|
107
289
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* html`<div>${slotContent(this)}</div>` // default slot
|
|
112
|
-
* html`<div>${slotContent(this, 'helptext')}</div>` // named slot
|
|
290
|
+
* The directive behind slotContent(): one instance per part. It moves its slot's nodes into the
|
|
291
|
+
* part itself and always returns noChange, so Lit never commits the nodes. If Lit did, it would
|
|
292
|
+
* clear the whole part on every change, framework anchors in it included.
|
|
113
293
|
*/
|
|
114
294
|
declare class SlotContentDirective extends AsyncDirective {
|
|
115
295
|
private manager;
|
|
116
296
|
private host;
|
|
117
297
|
private part;
|
|
118
298
|
private slotName;
|
|
299
|
+
/** The manager's generation when the part last placed its nodes. */
|
|
119
300
|
private lastGeneration;
|
|
120
301
|
constructor(partInfo: PartInfo);
|
|
121
302
|
render(_host: LitElement, _slotName?: string): unknown;
|
|
303
|
+
/** Runs on each host render: registers the part with the host's manager, and places nodes. */
|
|
122
304
|
update(part: ChildPart, [host, slotName]: [LitElement, string?]): unknown;
|
|
123
|
-
/**
|
|
124
|
-
* Called by SlotManager when child mutations are detected.
|
|
125
|
-
*/
|
|
305
|
+
/** Called by the manager after a change. */
|
|
126
306
|
handleNodesChanged(): void;
|
|
307
|
+
/** Lit removed the part, or the host left the document. */
|
|
127
308
|
disconnected(): void;
|
|
128
309
|
reconnected(): void;
|
|
310
|
+
/** Whether a node sits in this part. */
|
|
129
311
|
contains(node: Node): boolean;
|
|
312
|
+
/** The part's start and end markers. */
|
|
130
313
|
bounds(): {
|
|
131
314
|
startNode: Node | null;
|
|
132
315
|
endNode: Node | null;
|
|
133
316
|
};
|
|
317
|
+
/** The part's container. ChildPart.parentNode skips the cloned fragment during a first render. */
|
|
134
318
|
parentOfPart(): Node | null;
|
|
319
|
+
/**
|
|
320
|
+
* Moves the slot's nodes that are not in the part yet into it, in order. Walking from the last
|
|
321
|
+
* node, each missing node goes before the node after it, or before the part's end. Nodes that
|
|
322
|
+
* are already in the part stay put, so focus and framework anchors there are left alone.
|
|
323
|
+
*/
|
|
135
324
|
private placeNodes;
|
|
325
|
+
/** Whether the part spans its whole container, so any node in the container is in the part. */
|
|
326
|
+
private coversContainer;
|
|
327
|
+
/** Whether a node is in the container, between the part's start and end markers. */
|
|
136
328
|
private isInsidePart;
|
|
137
329
|
}
|
|
138
330
|
/**
|
|
@@ -150,12 +342,17 @@ declare class SlotContentDirective extends AsyncDirective {
|
|
|
150
342
|
* html`<div class="help">${slotContent(this, 'helptext')}</div>`
|
|
151
343
|
*/
|
|
152
344
|
export declare const slotContent: (_host: LitElement, _slotName?: string | undefined) => import('lit-html/directive.js').DirectiveResult<typeof SlotContentDirective>;
|
|
345
|
+
/**
|
|
346
|
+
* The directive behind forwardSlots(), on a child component's element in the host's template.
|
|
347
|
+
* It makes the child's manager (the target) include the host's slots (the source).
|
|
348
|
+
*/
|
|
153
349
|
declare class ForwardSlotsDirective extends AsyncDirective {
|
|
154
350
|
private target;
|
|
155
351
|
private source;
|
|
156
352
|
private mapping;
|
|
157
353
|
constructor(partInfo: PartInfo);
|
|
158
354
|
render(_host: LitElement, _slots: ForwardedSlots): unknown;
|
|
355
|
+
/** Runs on each host render: connects the host's manager to the child element's manager. */
|
|
159
356
|
update(part: ElementPart, [host, slots]: [LitElement, ForwardedSlots]): unknown;
|
|
160
357
|
disconnected(): void;
|
|
161
358
|
reconnected(): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PktElement } from '../../base-elements/element';
|
|
2
2
|
export declare class Alert extends PktElement {
|
|
3
3
|
skins: ("info" | "success" | "warning" | "error")[];
|
|
4
|
-
sizes: ("
|
|
4
|
+
sizes: ("small" | "medium" | "xsmall")[];
|
|
5
5
|
shortMessage: string;
|
|
6
6
|
content: string;
|
|
7
7
|
private onClose;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { PktElement } from '../../base-elements/element';
|
|
3
|
+
export declare class SlotInternals extends PktElement {
|
|
4
|
+
private scenarioIndex;
|
|
5
|
+
private get scenario();
|
|
6
|
+
/** 'on' when the chosen scenario is one of the space-separated `scenarios` */
|
|
7
|
+
private on;
|
|
8
|
+
private layoutFigure;
|
|
9
|
+
private mapFigure;
|
|
10
|
+
private contentEndFigure;
|
|
11
|
+
private whitespaceFigure;
|
|
12
|
+
private forwardingFigure;
|
|
13
|
+
render(): TemplateResult<1>;
|
|
14
|
+
}
|