@telperion/elements 5.4.2 → 6.0.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.
Files changed (57) hide show
  1. package/.build-manifest.json +12 -1
  2. package/README.md +37 -0
  3. package/custom-elements.json +5272 -0
  4. package/fesm/elements.mjs +477 -2
  5. package/fesm/elements.mjs.map +1 -1
  6. package/iife/elements.js +24 -24
  7. package/iife/elements.js.map +1 -1
  8. package/iife/portal/index.js +2 -0
  9. package/iife/portal/index.js.map +1 -0
  10. package/iife/router/index.js +16 -16
  11. package/iife/router/index.js.map +1 -1
  12. package/iife/select/index.js.map +1 -1
  13. package/index.cjs +4 -0
  14. package/index.cjs.map +1 -1
  15. package/index.d.cts +1 -0
  16. package/index.d.ts +1 -0
  17. package/index.js +2 -0
  18. package/index.js.map +1 -1
  19. package/package.json +42 -17
  20. package/portal/dom-ops.cjs +81 -0
  21. package/portal/dom-ops.cjs.map +1 -0
  22. package/portal/dom-ops.js +72 -0
  23. package/portal/dom-ops.js.map +1 -0
  24. package/portal/index.cjs +10 -0
  25. package/portal/index.cjs.map +1 -0
  26. package/portal/index.d.cts +125 -0
  27. package/portal/index.d.ts +125 -0
  28. package/portal/index.js +3 -0
  29. package/portal/index.js.map +1 -0
  30. package/portal/internal-props.cjs +13 -0
  31. package/portal/internal-props.cjs.map +1 -0
  32. package/portal/internal-props.js +9 -0
  33. package/portal/internal-props.js.map +1 -0
  34. package/portal/portal-element.cjs +196 -0
  35. package/portal/portal-element.cjs.map +1 -0
  36. package/portal/portal-element.js +194 -0
  37. package/portal/portal-element.js.map +1 -0
  38. package/portal/portal-outlet-element.cjs +64 -0
  39. package/portal/portal-outlet-element.cjs.map +1 -0
  40. package/portal/portal-outlet-element.js +62 -0
  41. package/portal/portal-outlet-element.js.map +1 -0
  42. package/portal/portal-registry.cjs +61 -0
  43. package/portal/portal-registry.cjs.map +1 -0
  44. package/portal/portal-registry.js +59 -0
  45. package/portal/portal-registry.js.map +1 -0
  46. package/portal/projection.cjs +81 -0
  47. package/portal/projection.cjs.map +1 -0
  48. package/portal/projection.js +79 -0
  49. package/portal/projection.js.map +1 -0
  50. package/portal/styles.cjs +28 -0
  51. package/portal/styles.cjs.map +1 -0
  52. package/portal/styles.js +26 -0
  53. package/portal/styles.js.map +1 -0
  54. package/router/history-managed.cjs +3 -1
  55. package/router/history-managed.cjs.map +1 -1
  56. package/router/history-managed.js +3 -1
  57. package/router/history-managed.js.map +1 -1
package/index.cjs CHANGED
@@ -17,6 +17,8 @@ var option_element = require('./select/option.element.cjs');
17
17
  var selectedContent_element = require('./select/selected-content.element.cjs');
18
18
  var selectChangeEvent = require('./select/select-change-event.cjs');
19
19
  var button_element = require('./button/button.element.cjs');
20
+ var portalElement = require('./portal/portal-element.cjs');
21
+ var portalOutletElement = require('./portal/portal-outlet-element.cjs');
20
22
 
21
23
 
22
24
 
@@ -82,4 +84,6 @@ Object.defineProperty(exports, "ButtonElement", {
82
84
  enumerable: true,
83
85
  get: function () { return button_element.ButtonElement; }
84
86
  });
87
+ exports.PortalElement = portalElement.PortalElement;
88
+ exports.PortalOutletElement = portalOutletElement.PortalOutletElement;
85
89
  //# sourceMappingURL=index.cjs.map
package/index.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/index.d.cts CHANGED
@@ -4,6 +4,7 @@ export { DetailsSetElement } from './details-set/index.cjs';
4
4
  export { PopoverElement } from './popover/index.cjs';
5
5
  export { OptionElement, SelectChangeEvent, SelectElement, SelectedContentElement } from './select/index.cjs';
6
6
  export { ButtonElement, ButtonType, ButtonVariant } from './button/index.cjs';
7
+ export { PortalElement, PortalOutletElement } from './portal/index.cjs';
7
8
  import './_chunks/signal-watcher-lit-element-B5xCaa26.cjs';
8
9
  import 'lit';
9
10
  import './_chunks/shade-mixer-lit-element-sw8t_VC5.cjs';
package/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export { DetailsSetElement } from './details-set/index.js';
4
4
  export { PopoverElement } from './popover/index.js';
5
5
  export { OptionElement, SelectChangeEvent, SelectElement, SelectedContentElement } from './select/index.js';
6
6
  export { ButtonElement, ButtonType, ButtonVariant } from './button/index.js';
7
+ export { PortalElement, PortalOutletElement } from './portal/index.js';
7
8
  import './_chunks/signal-watcher-lit-element-B-vV0yNG.js';
8
9
  import 'lit';
9
10
  import './_chunks/shade-mixer-lit-element-sw8t_VC5.js';
package/index.js CHANGED
@@ -15,4 +15,6 @@ export { OptionElement } from './select/option.element.js';
15
15
  export { SelectedContentElement } from './select/selected-content.element.js';
16
16
  export { SelectChangeEvent } from './select/select-change-event.js';
17
17
  export { ButtonElement } from './button/button.element.js';
18
+ export { PortalElement } from './portal/portal-element.js';
19
+ export { PortalOutletElement } from './portal/portal-outlet-element.js';
18
20
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@telperion/elements",
3
- "version": "5.4.2",
4
- "description": "Framework-agnostic web components built with Lit: Material Symbols / Simple Icons / theSVG icons, declarative client-side router, drag-and-drop primitives, details accordion with FIFO open caps, a CSS-anchored popover, a form-associated selectbox with single/multi-select, and a form-associated button.",
3
+ "version": "6.0.0",
4
+ "description": "Framework-agnostic web components built with Lit: Material Symbols / Simple Icons / theSVG icons, declarative client-side router, drag-and-drop primitives, details accordion with FIFO open caps, a CSS-anchored popover, a form-associated selectbox with single/multi-select, a form-associated button, and portals that render content into named outlets elsewhere in the document.",
5
5
  "keywords": [
6
6
  "web-components",
7
7
  "custom-elements",
@@ -28,6 +28,8 @@
28
28
  "multi-select",
29
29
  "button",
30
30
  "form-associated",
31
+ "portal",
32
+ "teleport",
31
33
  "themeable"
32
34
  ],
33
35
  "homepage": "https://open-source.telperion.tr/elements",
@@ -47,15 +49,16 @@
47
49
  "lit": "^3.3.1",
48
50
  "tslib": "^2.3.0"
49
51
  },
52
+ "customElements": "custom-elements.json",
50
53
  "exports": {
51
54
  ".": {
52
55
  "types": {
53
56
  "import": "./index.d.ts",
54
57
  "require": "./index.d.cts"
55
58
  },
56
- "node": "./index.cjs",
57
59
  "import": "./index.js",
58
60
  "require": "./index.cjs",
61
+ "node": "./index.cjs",
59
62
  "script": "./iife/elements.js",
60
63
  "default": "./index.js"
61
64
  },
@@ -64,9 +67,9 @@
64
67
  "import": "./router/index.d.ts",
65
68
  "require": "./router/index.d.cts"
66
69
  },
67
- "node": "./router/index.cjs",
68
70
  "import": "./router/index.js",
69
71
  "require": "./router/index.cjs",
72
+ "node": "./router/index.cjs",
70
73
  "script": "./iife/router/index.js",
71
74
  "default": "./router/index.js"
72
75
  },
@@ -75,9 +78,9 @@
75
78
  "import": "./router/index.d.ts",
76
79
  "require": "./router/index.d.cts"
77
80
  },
78
- "node": "./router/index.cjs",
79
81
  "import": "./router/index.js",
80
82
  "require": "./router/index.cjs",
83
+ "node": "./router/index.cjs",
81
84
  "script": "./iife/router/index.js",
82
85
  "default": "./router/index.js"
83
86
  },
@@ -86,9 +89,9 @@
86
89
  "import": "./drag-drop/index.d.ts",
87
90
  "require": "./drag-drop/index.d.cts"
88
91
  },
89
- "node": "./drag-drop/index.cjs",
90
92
  "import": "./drag-drop/index.js",
91
93
  "require": "./drag-drop/index.cjs",
94
+ "node": "./drag-drop/index.cjs",
92
95
  "script": "./iife/drag-drop/index.js",
93
96
  "default": "./drag-drop/index.js"
94
97
  },
@@ -97,9 +100,9 @@
97
100
  "import": "./drag-drop/index.d.ts",
98
101
  "require": "./drag-drop/index.d.cts"
99
102
  },
100
- "node": "./drag-drop/index.cjs",
101
103
  "import": "./drag-drop/index.js",
102
104
  "require": "./drag-drop/index.cjs",
105
+ "node": "./drag-drop/index.cjs",
103
106
  "script": "./iife/drag-drop/index.js",
104
107
  "default": "./drag-drop/index.js"
105
108
  },
@@ -108,9 +111,9 @@
108
111
  "import": "./icon/index.d.ts",
109
112
  "require": "./icon/index.d.cts"
110
113
  },
111
- "node": "./icon/index.cjs",
112
114
  "import": "./icon/index.js",
113
115
  "require": "./icon/index.cjs",
116
+ "node": "./icon/index.cjs",
114
117
  "script": "./iife/icon/index.js",
115
118
  "default": "./icon/index.js"
116
119
  },
@@ -119,9 +122,9 @@
119
122
  "import": "./icon/index.d.ts",
120
123
  "require": "./icon/index.d.cts"
121
124
  },
122
- "node": "./icon/index.cjs",
123
125
  "import": "./icon/index.js",
124
126
  "require": "./icon/index.cjs",
127
+ "node": "./icon/index.cjs",
125
128
  "script": "./iife/icon/index.js",
126
129
  "default": "./icon/index.js"
127
130
  },
@@ -130,9 +133,9 @@
130
133
  "import": "./details-set/index.d.ts",
131
134
  "require": "./details-set/index.d.cts"
132
135
  },
133
- "node": "./details-set/index.cjs",
134
136
  "import": "./details-set/index.js",
135
137
  "require": "./details-set/index.cjs",
138
+ "node": "./details-set/index.cjs",
136
139
  "script": "./iife/details-set/index.js",
137
140
  "default": "./details-set/index.js"
138
141
  },
@@ -141,9 +144,9 @@
141
144
  "import": "./details-set/index.d.ts",
142
145
  "require": "./details-set/index.d.cts"
143
146
  },
144
- "node": "./details-set/index.cjs",
145
147
  "import": "./details-set/index.js",
146
148
  "require": "./details-set/index.cjs",
149
+ "node": "./details-set/index.cjs",
147
150
  "script": "./iife/details-set/index.js",
148
151
  "default": "./details-set/index.js"
149
152
  },
@@ -152,9 +155,9 @@
152
155
  "import": "./popover/index.d.ts",
153
156
  "require": "./popover/index.d.cts"
154
157
  },
155
- "node": "./popover/index.cjs",
156
158
  "import": "./popover/index.js",
157
159
  "require": "./popover/index.cjs",
160
+ "node": "./popover/index.cjs",
158
161
  "script": "./iife/popover/index.js",
159
162
  "default": "./popover/index.js"
160
163
  },
@@ -163,9 +166,9 @@
163
166
  "import": "./popover/index.d.ts",
164
167
  "require": "./popover/index.d.cts"
165
168
  },
166
- "node": "./popover/index.cjs",
167
169
  "import": "./popover/index.js",
168
170
  "require": "./popover/index.cjs",
171
+ "node": "./popover/index.cjs",
169
172
  "script": "./iife/popover/index.js",
170
173
  "default": "./popover/index.js"
171
174
  },
@@ -174,9 +177,9 @@
174
177
  "import": "./select/index.d.ts",
175
178
  "require": "./select/index.d.cts"
176
179
  },
177
- "node": "./select/index.cjs",
178
180
  "import": "./select/index.js",
179
181
  "require": "./select/index.cjs",
182
+ "node": "./select/index.cjs",
180
183
  "script": "./iife/select/index.js",
181
184
  "default": "./select/index.js"
182
185
  },
@@ -185,9 +188,9 @@
185
188
  "import": "./select/index.d.ts",
186
189
  "require": "./select/index.d.cts"
187
190
  },
188
- "node": "./select/index.cjs",
189
191
  "import": "./select/index.js",
190
192
  "require": "./select/index.cjs",
193
+ "node": "./select/index.cjs",
191
194
  "script": "./iife/select/index.js",
192
195
  "default": "./select/index.js"
193
196
  },
@@ -196,9 +199,9 @@
196
199
  "import": "./button/index.d.ts",
197
200
  "require": "./button/index.d.cts"
198
201
  },
199
- "node": "./button/index.cjs",
200
202
  "import": "./button/index.js",
201
203
  "require": "./button/index.cjs",
204
+ "node": "./button/index.cjs",
202
205
  "script": "./iife/button/index.js",
203
206
  "default": "./button/index.js"
204
207
  },
@@ -207,12 +210,34 @@
207
210
  "import": "./button/index.d.ts",
208
211
  "require": "./button/index.d.cts"
209
212
  },
210
- "node": "./button/index.cjs",
211
213
  "import": "./button/index.js",
212
214
  "require": "./button/index.cjs",
215
+ "node": "./button/index.cjs",
213
216
  "script": "./iife/button/index.js",
214
217
  "default": "./button/index.js"
215
218
  },
219
+ "./portal/index": {
220
+ "types": {
221
+ "import": "./portal/index.d.ts",
222
+ "require": "./portal/index.d.cts"
223
+ },
224
+ "import": "./portal/index.js",
225
+ "require": "./portal/index.cjs",
226
+ "node": "./portal/index.cjs",
227
+ "script": "./iife/portal/index.js",
228
+ "default": "./portal/index.js"
229
+ },
230
+ "./portal": {
231
+ "types": {
232
+ "import": "./portal/index.d.ts",
233
+ "require": "./portal/index.d.cts"
234
+ },
235
+ "import": "./portal/index.js",
236
+ "require": "./portal/index.cjs",
237
+ "node": "./portal/index.cjs",
238
+ "script": "./iife/portal/index.js",
239
+ "default": "./portal/index.js"
240
+ },
216
241
  "./icon/material-symbols.css": "./icon/material-symbols.css"
217
242
  },
218
243
  "bugs": "https://github.com/telperiontech/telperion/issues",
@@ -0,0 +1,81 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Native DOM operations captured before `<tp-portal>` overrides them, so the
5
+ * element can still reach its *own* light DOM while forwarding framework
6
+ * mutations to its outlet.
7
+ */
8
+ const nativeInsertBefore = Node.prototype.insertBefore;
9
+ const nativeRemoveChild = Node.prototype.removeChild;
10
+ const nativeReplaceChild = Node.prototype.replaceChild;
11
+ const nativeMoveBefore = Element.prototype.moveBefore;
12
+ function insertNode(parent, node, ref) {
13
+ nativeInsertBefore.call(parent, node, ref);
14
+ }
15
+ function removeNode(node) {
16
+ if (node.parentNode)
17
+ nativeRemoveChild.call(node.parentNode, node);
18
+ }
19
+ function replaceNode(parent, next, prev) {
20
+ nativeReplaceChild.call(parent, next, prev);
21
+ }
22
+ /**
23
+ * Moves `node` into `parent` before `ref`. Prefers the state-preserving
24
+ * `moveBefore()` (focus, iframes, animations, no disconnect/connect
25
+ * reactions) and falls back to a plain insertion where it is unsupported or
26
+ * not allowed (e.g. one side is disconnected).
27
+ */
28
+ function moveNode(parent, node, ref, preferMove = true) {
29
+ if (preferMove && nativeMoveBefore && node.isConnected && parent.isConnected) {
30
+ try {
31
+ nativeMoveBefore.call(parent, node, ref);
32
+ return;
33
+ }
34
+ catch {
35
+ /* fall back to insertBefore */
36
+ }
37
+ }
38
+ nativeInsertBefore.call(parent, node, ref);
39
+ }
40
+ function hasNativeMoveBefore() {
41
+ return nativeMoveBefore !== undefined;
42
+ }
43
+ function nativeMove(parent, node, ref) {
44
+ if (!nativeMoveBefore)
45
+ throw new DOMException("moveBefore is not supported", "NotSupportedError");
46
+ nativeMoveBefore.call(parent, node, ref);
47
+ }
48
+ /** Nodes strictly between two sibling markers (empty when the markers were torn out). */
49
+ function nodesBetween(start, end) {
50
+ const nodes = [];
51
+ if (!start.parentNode || start.parentNode !== end.parentNode)
52
+ return nodes;
53
+ for (let n = start.nextSibling; n && n !== end; n = n.nextSibling)
54
+ nodes.push(n);
55
+ return nodes;
56
+ }
57
+ const ESCAPES = { "&": "&amp;", "<": "&lt;", ">": "&gt;", " ": "&nbsp;" };
58
+ /** Minimal HTML serialization of a node list (used for `innerHTML` while projected). */
59
+ function serializeNodes(nodes) {
60
+ return nodes
61
+ .map((n) => {
62
+ if (n instanceof Element)
63
+ return n.outerHTML;
64
+ if (n.nodeType === Node.TEXT_NODE)
65
+ return (n.nodeValue ?? "").replace(/[&<> ]/g, (c) => ESCAPES[c] ?? c);
66
+ if (n.nodeType === Node.COMMENT_NODE)
67
+ return `<!--${n.nodeValue ?? ""}-->`;
68
+ return "";
69
+ })
70
+ .join("");
71
+ }
72
+
73
+ exports.hasNativeMoveBefore = hasNativeMoveBefore;
74
+ exports.insertNode = insertNode;
75
+ exports.moveNode = moveNode;
76
+ exports.nativeMove = nativeMove;
77
+ exports.nodesBetween = nodesBetween;
78
+ exports.removeNode = removeNode;
79
+ exports.replaceNode = replaceNode;
80
+ exports.serializeNodes = serializeNodes;
81
+ //# sourceMappingURL=dom-ops.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom-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AI,CAAC,EAAE,CAAC;AACb;;;;;;;;;;;"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Native DOM operations captured before `<tp-portal>` overrides them, so the
3
+ * element can still reach its *own* light DOM while forwarding framework
4
+ * mutations to its outlet.
5
+ */
6
+ const nativeInsertBefore = Node.prototype.insertBefore;
7
+ const nativeRemoveChild = Node.prototype.removeChild;
8
+ const nativeReplaceChild = Node.prototype.replaceChild;
9
+ const nativeMoveBefore = Element.prototype.moveBefore;
10
+ function insertNode(parent, node, ref) {
11
+ nativeInsertBefore.call(parent, node, ref);
12
+ }
13
+ function removeNode(node) {
14
+ if (node.parentNode)
15
+ nativeRemoveChild.call(node.parentNode, node);
16
+ }
17
+ function replaceNode(parent, next, prev) {
18
+ nativeReplaceChild.call(parent, next, prev);
19
+ }
20
+ /**
21
+ * Moves `node` into `parent` before `ref`. Prefers the state-preserving
22
+ * `moveBefore()` (focus, iframes, animations, no disconnect/connect
23
+ * reactions) and falls back to a plain insertion where it is unsupported or
24
+ * not allowed (e.g. one side is disconnected).
25
+ */
26
+ function moveNode(parent, node, ref, preferMove = true) {
27
+ if (preferMove && nativeMoveBefore && node.isConnected && parent.isConnected) {
28
+ try {
29
+ nativeMoveBefore.call(parent, node, ref);
30
+ return;
31
+ }
32
+ catch {
33
+ /* fall back to insertBefore */
34
+ }
35
+ }
36
+ nativeInsertBefore.call(parent, node, ref);
37
+ }
38
+ function hasNativeMoveBefore() {
39
+ return nativeMoveBefore !== undefined;
40
+ }
41
+ function nativeMove(parent, node, ref) {
42
+ if (!nativeMoveBefore)
43
+ throw new DOMException("moveBefore is not supported", "NotSupportedError");
44
+ nativeMoveBefore.call(parent, node, ref);
45
+ }
46
+ /** Nodes strictly between two sibling markers (empty when the markers were torn out). */
47
+ function nodesBetween(start, end) {
48
+ const nodes = [];
49
+ if (!start.parentNode || start.parentNode !== end.parentNode)
50
+ return nodes;
51
+ for (let n = start.nextSibling; n && n !== end; n = n.nextSibling)
52
+ nodes.push(n);
53
+ return nodes;
54
+ }
55
+ const ESCAPES = { "&": "&amp;", "<": "&lt;", ">": "&gt;", " ": "&nbsp;" };
56
+ /** Minimal HTML serialization of a node list (used for `innerHTML` while projected). */
57
+ function serializeNodes(nodes) {
58
+ return nodes
59
+ .map((n) => {
60
+ if (n instanceof Element)
61
+ return n.outerHTML;
62
+ if (n.nodeType === Node.TEXT_NODE)
63
+ return (n.nodeValue ?? "").replace(/[&<> ]/g, (c) => ESCAPES[c] ?? c);
64
+ if (n.nodeType === Node.COMMENT_NODE)
65
+ return `<!--${n.nodeValue ?? ""}-->`;
66
+ return "";
67
+ })
68
+ .join("");
69
+ }
70
+
71
+ export { hasNativeMoveBefore, insertNode, moveNode, nativeMove, nodesBetween, removeNode, replaceNode, serializeNodes };
72
+ //# sourceMappingURL=dom-ops.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom-ops.js","sources":["../../../../libs/elements/src/portal/dom-ops.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;AAIG;AAIH,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY;AACtD,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW;AACpD,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY;AACtD,MAAM,gBAAgB,GAAI,OAAO,CAAC,SAAoD,CAAC,UAAU;SAEjF,UAAU,CAAC,MAAY,EAAE,IAAU,EAAE,GAAgB,EAAA;IACnE,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC;AAC5C;AAEM,SAAU,UAAU,CAAC,IAAU,EAAA;IACnC,IAAI,IAAI,CAAC,UAAU;QAAE,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC;AACpE;SAEgB,WAAW,CAAC,MAAY,EAAE,IAAU,EAAE,IAAU,EAAA;IAC9D,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,IA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,EAAE;AAEjG;AACM,SAAU,cAAc,CAAC,KAAa,EAAA;AAC1C,IAAA,OAAO;AACJ,SAAA,GAAG,CAAC,CAAC,CAAC,KAAI;QACT,IAAI,CAAC,YAAY,OAAO;YAAE,OAAO,CAAC,CAAC,SAAS;AAC5C,QAAA,IAAI,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,SAAS;YAAE,OAAO,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACxG,QAAA,IAAI,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY;AAAE,YAAA,OAAO,OAAO,CAAC,CAAC,SAAS,IAAI,EAAE,KAAK;AAC1E,QAAA,OAAO,EAAE;AACX,IAAA,CAAC;SACA,IAAI,CAAC,EAAE,CAAC;AACb;;;;"}
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var portalElement = require('./portal-element.cjs');
4
+ var portalOutletElement = require('./portal-outlet-element.cjs');
5
+
6
+
7
+
8
+ exports.PortalElement = portalElement.PortalElement;
9
+ exports.PortalOutletElement = portalOutletElement.PortalOutletElement;
10
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -0,0 +1,125 @@
1
+ /** Registry → portal: re-resolve the active outlet and (re)project into it. */
2
+ declare const SYNC_PORTAL: unique symbol;
3
+ /** Portal → outlet: a portal started projecting into the outlet. */
4
+ declare const ATTACH_PORTAL: unique symbol;
5
+ /** Portal → outlet: a portal stopped projecting into the outlet. */
6
+ declare const DETACH_PORTAL: unique symbol;
7
+
8
+ declare global {
9
+ interface HTMLElementTagNameMap {
10
+ /**
11
+ * Render target for `<tp-portal>` elements with the same `name`.
12
+ *
13
+ * Content of every matching portal is appended after the outlet's own
14
+ * children, in the order the portals connected. When several outlets share
15
+ * a name, the most recently connected one is active; if it disconnects,
16
+ * the previous one takes over and the content moves there.
17
+ *
18
+ * The outlet is `display: contents` by default, so projected content lays
19
+ * out as if it were a child of the outlet's parent.
20
+ *
21
+ * @example
22
+ * ```html
23
+ * <tp-portal-outlet name="toolbar"></tp-portal-outlet>
24
+ * ```
25
+ *
26
+ * @attr name - Name that `<tp-portal>` elements target.
27
+ * @attr active - Reflected (read-only) while at least one portal projects here.
28
+ */
29
+ "tp-portal-outlet": PortalOutletElement;
30
+ }
31
+ }
32
+ declare class PortalOutletElement extends HTMLElement {
33
+ #private;
34
+ static readonly observedAttributes: string[];
35
+ /** Name that `<tp-portal>` elements target. */
36
+ get name(): string;
37
+ set name(value: string);
38
+ /** Portals currently projecting into this outlet, in projection order. */
39
+ get portals(): readonly PortalElement[];
40
+ connectedCallback(): void;
41
+ disconnectedCallback(): void;
42
+ attributeChangedCallback(): void;
43
+ /** @internal */
44
+ [ATTACH_PORTAL](portal: PortalElement): void;
45
+ /** @internal */
46
+ [DETACH_PORTAL](portal: PortalElement): void;
47
+ }
48
+
49
+ declare global {
50
+ interface HTMLElementTagNameMap {
51
+ /**
52
+ * Renders its children inside the `<tp-portal-outlet>` with the same
53
+ * `name`, wherever that outlet is in the document.
54
+ *
55
+ * The child **nodes themselves** are moved (not cloned), so event
56
+ * listeners, element state and framework bindings stay intact. While no
57
+ * matching outlet is connected the children stay inside the portal, which
58
+ * is `display: none` by default.
59
+ *
60
+ * Framework-safe: frameworks (React, Angular, Vue, Lit, …) keep calling
61
+ * `appendChild` / `insertBefore` / `removeChild` / `replaceChild` /
62
+ * `textContent` / `innerHTML` on the portal; while projected, those calls
63
+ * are forwarded to the outlet, so no "node is not a child of this node"
64
+ * errors are thrown.
65
+ *
66
+ * Uses the state-preserving `moveBefore()` when the browser supports it
67
+ * (focus, iframes, CSS animations survive projection).
68
+ *
69
+ * @example
70
+ * ```html
71
+ * <tp-portal name="toolbar">
72
+ * <button>Save</button>
73
+ * </tp-portal>
74
+ *
75
+ * <header>
76
+ * <tp-portal-outlet name="toolbar"></tp-portal-outlet>
77
+ * </header>
78
+ * ```
79
+ *
80
+ * @attr name - Outlet name to project into.
81
+ * @attr projected - Reflected (read-only) while the content is in an outlet.
82
+ */
83
+ "tp-portal": PortalElement;
84
+ }
85
+ }
86
+ declare class PortalElement extends HTMLElement {
87
+ #private;
88
+ static readonly observedAttributes: string[];
89
+ /** Outlet name to project into. */
90
+ get name(): string;
91
+ set name(value: string);
92
+ /** The outlet currently hosting this portal's content, if any. */
93
+ get outlet(): PortalOutletElement | null;
94
+ /** The portal's content nodes, wherever they currently live. */
95
+ get projectedNodes(): Node[];
96
+ connectedCallback(): void;
97
+ disconnectedCallback(): void;
98
+ attributeChangedCallback(): void;
99
+ /** @internal */
100
+ [SYNC_PORTAL](): void;
101
+ /** @internal Forwarded to the outlet while projected. */
102
+ appendChild<T extends Node>(node: T): T;
103
+ /** @internal Forwarded to the outlet while projected. */
104
+ insertBefore<T extends Node>(node: T, ref: Node | null): T;
105
+ /** @internal Forwarded to the outlet while projected. */
106
+ removeChild<T extends Node>(child: T): T;
107
+ /** @internal Forwarded to the outlet while projected. */
108
+ replaceChild<T extends Node>(next: Node, prev: T): T;
109
+ /** @internal Forwarded to the outlet while projected. */
110
+ append(...nodes: Array<Node | string>): void;
111
+ /** @internal Forwarded to the outlet while projected. */
112
+ prepend(...nodes: Array<Node | string>): void;
113
+ /** @internal Forwarded to the outlet while projected. */
114
+ replaceChildren(...nodes: Array<Node | string>): void;
115
+ /** @internal Forwarded to the outlet while projected. */
116
+ get textContent(): string;
117
+ /** @internal */
118
+ set textContent(value: string | null);
119
+ /** @internal Forwarded to the outlet while projected. */
120
+ get innerHTML(): string;
121
+ /** @internal */
122
+ set innerHTML(value: string);
123
+ }
124
+
125
+ export { PortalElement, PortalOutletElement };