@telperion/elements 5.4.3 → 6.1.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 (54) hide show
  1. package/.build-manifest.json +12 -1
  2. package/README.md +39 -0
  3. package/custom-elements.json +908 -0
  4. package/fesm/elements.mjs +492 -1
  5. package/fesm/elements.mjs.map +1 -1
  6. package/iife/elements.js +27 -27
  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/index.cjs +6 -0
  11. package/index.cjs.map +1 -1
  12. package/index.d.cts +1 -0
  13. package/index.d.ts +1 -0
  14. package/index.js +3 -0
  15. package/index.js.map +1 -1
  16. package/package.json +26 -2
  17. package/portal/dom-ops.cjs +81 -0
  18. package/portal/dom-ops.cjs.map +1 -0
  19. package/portal/dom-ops.js +72 -0
  20. package/portal/dom-ops.js.map +1 -0
  21. package/portal/index.cjs +12 -0
  22. package/portal/index.cjs.map +1 -0
  23. package/portal/index.d.cts +152 -0
  24. package/portal/index.d.ts +152 -0
  25. package/portal/index.js +4 -0
  26. package/portal/index.js.map +1 -0
  27. package/portal/internal-props.cjs +13 -0
  28. package/portal/internal-props.cjs.map +1 -0
  29. package/portal/internal-props.js +9 -0
  30. package/portal/internal-props.js.map +1 -0
  31. package/portal/portal-element.cjs +196 -0
  32. package/portal/portal-element.cjs.map +1 -0
  33. package/portal/portal-element.js +194 -0
  34. package/portal/portal-element.js.map +1 -0
  35. package/portal/portal-outlet-element.cjs +64 -0
  36. package/portal/portal-outlet-element.cjs.map +1 -0
  37. package/portal/portal-outlet-element.js +62 -0
  38. package/portal/portal-outlet-element.js.map +1 -0
  39. package/portal/portal-outlet-fallback-element.cjs +19 -0
  40. package/portal/portal-outlet-fallback-element.cjs.map +1 -0
  41. package/portal/portal-outlet-fallback-element.js +17 -0
  42. package/portal/portal-outlet-fallback-element.js.map +1 -0
  43. package/portal/portal-registry.cjs +61 -0
  44. package/portal/portal-registry.cjs.map +1 -0
  45. package/portal/portal-registry.js +59 -0
  46. package/portal/portal-registry.js.map +1 -0
  47. package/portal/projection.cjs +81 -0
  48. package/portal/projection.cjs.map +1 -0
  49. package/portal/projection.js +79 -0
  50. package/portal/projection.js.map +1 -0
  51. package/portal/styles.cjs +33 -0
  52. package/portal/styles.cjs.map +1 -0
  53. package/portal/styles.js +31 -0
  54. package/portal/styles.js.map +1 -0
@@ -0,0 +1,61 @@
1
+ 'use strict';
2
+
3
+ var internalProps = require('./internal-props.cjs');
4
+
5
+ /**
6
+ * Module-level name → outlet/portal bookkeeping.
7
+ *
8
+ * - Several outlets may share a name; the **most recently connected** one is
9
+ * active, and the previous one takes over when it disconnects.
10
+ * - Several portals may share a name; all of them project into the active
11
+ * outlet, in connection order.
12
+ */
13
+ class PortalRegistry {
14
+ #outlets = new Map();
15
+ #portals = new Map();
16
+ outletFor(name) {
17
+ const stack = this.#outlets.get(name);
18
+ return stack?.[stack.length - 1] ?? null;
19
+ }
20
+ addOutlet(name, outlet) {
21
+ const stack = this.#outlets.get(name) ?? [];
22
+ if (!stack.includes(outlet))
23
+ stack.push(outlet);
24
+ this.#outlets.set(name, stack);
25
+ this.#sync(name);
26
+ }
27
+ removeOutlet(name, outlet) {
28
+ const stack = this.#outlets.get(name);
29
+ if (!stack)
30
+ return;
31
+ const index = stack.indexOf(outlet);
32
+ if (index === -1)
33
+ return;
34
+ stack.splice(index, 1);
35
+ if (!stack.length)
36
+ this.#outlets.delete(name);
37
+ this.#sync(name);
38
+ }
39
+ addPortal(name, portal) {
40
+ const set = this.#portals.get(name) ?? new Set();
41
+ set.add(portal);
42
+ this.#portals.set(name, set);
43
+ portal[internalProps.SYNC_PORTAL]();
44
+ }
45
+ removePortal(name, portal) {
46
+ const set = this.#portals.get(name);
47
+ if (!set)
48
+ return;
49
+ set.delete(portal);
50
+ if (!set.size)
51
+ this.#portals.delete(name);
52
+ }
53
+ #sync(name) {
54
+ for (const portal of [...(this.#portals.get(name) ?? [])])
55
+ portal[internalProps.SYNC_PORTAL]();
56
+ }
57
+ }
58
+ const portalRegistry = new PortalRegistry();
59
+
60
+ exports.portalRegistry = portalRegistry;
61
+ //# sourceMappingURL=portal-registry.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal-registry.cjs","sources":["../../../../libs/elements/src/portal/portal-registry.ts"],"sourcesContent":[null],"names":["SYNC_PORTAL"],"mappings":";;;;AAIA;;;;;;;AAOG;AACH,MAAM,cAAc,CAAA;AACT,IAAA,QAAQ,GAAG,IAAI,GAAG,EAAiC;AACnD,IAAA,QAAQ,GAAG,IAAI,GAAG,EAA8B;AAEzD,IAAA,SAAS,CAAC,IAAY,EAAA;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;QACrC,OAAO,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,IAAI;IAC1C;IAEA,SAAS,CAAC,IAAY,EAAE,MAA2B,EAAA;AACjD,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE;AAC3C,QAAA,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;AAAE,YAAA,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;QAC/C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC;AAC9B,QAAA,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IAClB;IAEA,YAAY,CAAC,IAAY,EAAE,MAA2B,EAAA;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;AACrC,QAAA,IAAI,CAAC,KAAK;YAAE;QACZ,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QACnC,IAAI,KAAK,KAAK,EAAE;YAAE;AAClB,QAAA,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QACtB,IAAI,CAAC,KAAK,CAAC,MAAM;AAAE,YAAA,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;AAC7C,QAAA,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IAClB;IAEA,SAAS,CAAC,IAAY,EAAE,MAAqB,EAAA;AAC3C,QAAA,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,EAAE;AAChD,QAAA,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC;QACf,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC;AAC5B,QAAA,MAAM,CAACA,yBAAW,CAAC,EAAE;IACvB;IAEA,YAAY,CAAC,IAAY,EAAE,MAAqB,EAAA;QAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;AACnC,QAAA,IAAI,CAAC,GAAG;YAAE;AACV,QAAA,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC;QAClB,IAAI,CAAC,GAAG,CAAC,IAAI;AAAE,YAAA,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;IAC3C;AAEA,IAAA,KAAK,CAAC,IAAY,EAAA;AAChB,QAAA,KAAK,MAAM,MAAM,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AAAE,YAAA,MAAM,CAACA,yBAAW,CAAC,EAAE;IAClF;AACD;AAEM,MAAM,cAAc,GAAG,IAAI,cAAc;;;;"}
@@ -0,0 +1,59 @@
1
+ import { SYNC_PORTAL } from './internal-props.js';
2
+
3
+ /**
4
+ * Module-level name → outlet/portal bookkeeping.
5
+ *
6
+ * - Several outlets may share a name; the **most recently connected** one is
7
+ * active, and the previous one takes over when it disconnects.
8
+ * - Several portals may share a name; all of them project into the active
9
+ * outlet, in connection order.
10
+ */
11
+ class PortalRegistry {
12
+ #outlets = new Map();
13
+ #portals = new Map();
14
+ outletFor(name) {
15
+ const stack = this.#outlets.get(name);
16
+ return stack?.[stack.length - 1] ?? null;
17
+ }
18
+ addOutlet(name, outlet) {
19
+ const stack = this.#outlets.get(name) ?? [];
20
+ if (!stack.includes(outlet))
21
+ stack.push(outlet);
22
+ this.#outlets.set(name, stack);
23
+ this.#sync(name);
24
+ }
25
+ removeOutlet(name, outlet) {
26
+ const stack = this.#outlets.get(name);
27
+ if (!stack)
28
+ return;
29
+ const index = stack.indexOf(outlet);
30
+ if (index === -1)
31
+ return;
32
+ stack.splice(index, 1);
33
+ if (!stack.length)
34
+ this.#outlets.delete(name);
35
+ this.#sync(name);
36
+ }
37
+ addPortal(name, portal) {
38
+ const set = this.#portals.get(name) ?? new Set();
39
+ set.add(portal);
40
+ this.#portals.set(name, set);
41
+ portal[SYNC_PORTAL]();
42
+ }
43
+ removePortal(name, portal) {
44
+ const set = this.#portals.get(name);
45
+ if (!set)
46
+ return;
47
+ set.delete(portal);
48
+ if (!set.size)
49
+ this.#portals.delete(name);
50
+ }
51
+ #sync(name) {
52
+ for (const portal of [...(this.#portals.get(name) ?? [])])
53
+ portal[SYNC_PORTAL]();
54
+ }
55
+ }
56
+ const portalRegistry = new PortalRegistry();
57
+
58
+ export { portalRegistry };
59
+ //# sourceMappingURL=portal-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal-registry.js","sources":["../../../../libs/elements/src/portal/portal-registry.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;;;;;;;AAOG;AACH,MAAM,cAAc,CAAA;AACT,IAAA,QAAQ,GAAG,IAAI,GAAG,EAAiC;AACnD,IAAA,QAAQ,GAAG,IAAI,GAAG,EAA8B;AAEzD,IAAA,SAAS,CAAC,IAAY,EAAA;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,C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;IACvB;IAEA,YAAY,CAAC,IAAY,EAAE,MAAqB,EAAA;QAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;AACnC,QAAA,IAAI,CAAC,GAAG;YAAE;AACV,QAAA,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC;QAClB,IAAI,CAAC,GAAG,CAAC,IAAI;AAAE,YAAA,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;IAC3C;AAEA,IAAA,KAAK,CAAC,IAAY,EAAA;AAChB,QAAA,KAAK,MAAM,MAAM,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AAAE,YAAA,MAAM,CAAC,WAAW,CAAC,EAAE;IAClF;AACD;AAEM,MAAM,cAAc,GAAG,IAAI,cAAc;;;;"}
@@ -0,0 +1,81 @@
1
+ 'use strict';
2
+
3
+ var domOps = require('./dom-ops.cjs');
4
+
5
+ /**
6
+ * The part of an outlet a single portal owns: a `<!--tp-portal-->` …
7
+ * `<!--/tp-portal-->` comment pair, with the portal's nodes in between.
8
+ *
9
+ * Markers keep each portal's nodes contiguous even when several portals share
10
+ * an outlet, and give frameworks a stable `nextSibling` to insert before
11
+ * (Angular / Vue insert relative to siblings, which land inside the range).
12
+ */
13
+ class Projection {
14
+ #start = document.createComment("tp-portal");
15
+ #end = document.createComment("/tp-portal");
16
+ #container = null;
17
+ /** The node currently hosting the projected content, if any. */
18
+ get container() {
19
+ return this.#container;
20
+ }
21
+ get active() {
22
+ return this.#container !== null;
23
+ }
24
+ /** Nodes currently projected (in order). */
25
+ nodes() {
26
+ return this.#container ? domOps.nodesBetween(this.#start, this.#end) : [];
27
+ }
28
+ /** Whether `ref` is a valid insertion reference inside the projected range. */
29
+ owns(ref) {
30
+ return ref === null || (this.#container !== null && ref.parentNode === this.#container);
31
+ }
32
+ /** Opens the range at the end of `container` and moves `source`'s children into it. */
33
+ open(container, source) {
34
+ this.#container = container;
35
+ domOps.insertNode(container, this.#start, null);
36
+ domOps.insertNode(container, this.#end, null);
37
+ this.pull(source);
38
+ }
39
+ /** Moves every child of `source` into the range (keeps order). */
40
+ pull(source) {
41
+ if (!this.#container)
42
+ return;
43
+ for (const node of Array.from(source.childNodes))
44
+ domOps.moveNode(this.#container, node, this.#end);
45
+ }
46
+ /** Moves projected nodes back to `target`, removes the markers and closes the range. */
47
+ close(target) {
48
+ if (!this.#container)
49
+ return;
50
+ const nodes = this.nodes();
51
+ this.#container = null;
52
+ for (const node of nodes)
53
+ domOps.moveNode(target, node, null);
54
+ domOps.removeNode(this.#start);
55
+ domOps.removeNode(this.#end);
56
+ }
57
+ // -- Forwarded mutations (only valid while active) -------------------------
58
+ insert(node, ref) {
59
+ domOps.insertNode(this.#container, node, ref ?? this.#end);
60
+ }
61
+ prepend(node) {
62
+ domOps.insertNode(this.#container, node, this.#start.nextSibling);
63
+ }
64
+ remove(node) {
65
+ domOps.removeNode(node);
66
+ }
67
+ replace(next, prev) {
68
+ domOps.replaceNode(this.#container, next, prev);
69
+ }
70
+ clear() {
71
+ for (const node of this.nodes())
72
+ domOps.removeNode(node);
73
+ }
74
+ /** Reference node to use for `moveBefore` forwarding. */
75
+ refFor(ref) {
76
+ return ref ?? this.#end;
77
+ }
78
+ }
79
+
80
+ exports.Projection = Projection;
81
+ //# sourceMappingURL=projection.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection.cjs","sources":["../../../../libs/elements/src/portal/projection.ts"],"sourcesContent":[null],"names":["nodesBetween","insertNode","moveNode","removeNode","replaceNode"],"mappings":";;;;AAEA;;;;;;;AAOG;MACU,UAAU,CAAA;AACZ,IAAA,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC;AAC5C,IAAA,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,YAAY,CAAC;IACpD,UAAU,GAAgB,IAAI;;AAG9B,IAAA,IAA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AC;AACtD,QAAAC,iBAAU,CAAC,IAAI,CAAC,MAAM,CAAC;AACvB,QAAAA,iBAAU,CAAC,IAAI,CAAC,IAAI,CAAC;IACvB;;IAIA,MAAM,CAAC,IAAU,EAAE,GAAgB,EAAA;AACjC,QAAAF,iBAAU,CAAC,IAAI,CAAC,UAAW,EAAE,IAAI,EAAE,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC;IACtD;AAEA,IAAA,OAAO,CAAC,IAAU,EAAA;AAChB,QAAAA,iBAAU,CAAC,IAAI,CAAC,UAAW,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;IAC7D;AAEA,IAAA,MAAM,CAAC,IAAU,EAAA;QACfE,iBAAU,CAAC,IAAI,CAAC;IAClB;IAEA,OAAO,CAAC,IAAU,EAAE,IAAU,EAAA;QAC5BC,kBAAW,CAAC,IAAI,CAAC,UAAW,EAAE,IAAI,EAAE,IAAI,CAAC;IAC3C;IAEA,KAAK,GAAA;AACH,QAAA,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;YAAED,iBAAU,CAAC,IAAI,CAAC;IACnD;;AAGA,IAAA,MAAM,CAAC,GAAgB,EAAA;AACrB,QAAA,OAAO,GAAG,IAAI,IAAI,CAAC,IAAI;IACzB;AACD;;;;"}
@@ -0,0 +1,79 @@
1
+ import { nodesBetween, insertNode, moveNode, removeNode, replaceNode } from './dom-ops.js';
2
+
3
+ /**
4
+ * The part of an outlet a single portal owns: a `<!--tp-portal-->` …
5
+ * `<!--/tp-portal-->` comment pair, with the portal's nodes in between.
6
+ *
7
+ * Markers keep each portal's nodes contiguous even when several portals share
8
+ * an outlet, and give frameworks a stable `nextSibling` to insert before
9
+ * (Angular / Vue insert relative to siblings, which land inside the range).
10
+ */
11
+ class Projection {
12
+ #start = document.createComment("tp-portal");
13
+ #end = document.createComment("/tp-portal");
14
+ #container = null;
15
+ /** The node currently hosting the projected content, if any. */
16
+ get container() {
17
+ return this.#container;
18
+ }
19
+ get active() {
20
+ return this.#container !== null;
21
+ }
22
+ /** Nodes currently projected (in order). */
23
+ nodes() {
24
+ return this.#container ? nodesBetween(this.#start, this.#end) : [];
25
+ }
26
+ /** Whether `ref` is a valid insertion reference inside the projected range. */
27
+ owns(ref) {
28
+ return ref === null || (this.#container !== null && ref.parentNode === this.#container);
29
+ }
30
+ /** Opens the range at the end of `container` and moves `source`'s children into it. */
31
+ open(container, source) {
32
+ this.#container = container;
33
+ insertNode(container, this.#start, null);
34
+ insertNode(container, this.#end, null);
35
+ this.pull(source);
36
+ }
37
+ /** Moves every child of `source` into the range (keeps order). */
38
+ pull(source) {
39
+ if (!this.#container)
40
+ return;
41
+ for (const node of Array.from(source.childNodes))
42
+ moveNode(this.#container, node, this.#end);
43
+ }
44
+ /** Moves projected nodes back to `target`, removes the markers and closes the range. */
45
+ close(target) {
46
+ if (!this.#container)
47
+ return;
48
+ const nodes = this.nodes();
49
+ this.#container = null;
50
+ for (const node of nodes)
51
+ moveNode(target, node, null);
52
+ removeNode(this.#start);
53
+ removeNode(this.#end);
54
+ }
55
+ // -- Forwarded mutations (only valid while active) -------------------------
56
+ insert(node, ref) {
57
+ insertNode(this.#container, node, ref ?? this.#end);
58
+ }
59
+ prepend(node) {
60
+ insertNode(this.#container, node, this.#start.nextSibling);
61
+ }
62
+ remove(node) {
63
+ removeNode(node);
64
+ }
65
+ replace(next, prev) {
66
+ replaceNode(this.#container, next, prev);
67
+ }
68
+ clear() {
69
+ for (const node of this.nodes())
70
+ removeNode(node);
71
+ }
72
+ /** Reference node to use for `moveBefore` forwarding. */
73
+ refFor(ref) {
74
+ return ref ?? this.#end;
75
+ }
76
+ }
77
+
78
+ export { Projection };
79
+ //# sourceMappingURL=projection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection.js","sources":["../../../../libs/elements/src/portal/projection.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;;;AAOG;MACU,UAAU,CAAA;AACZ,IAAA,MAAM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AE;AAC1B,QAAA,IAAI,CAAC,UAAU,GAAG,IAAI;QACtB,KAAK,MAAM,IAAI,IAAI,KAAK;AAAE,YAAA,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC;AACtD,QAAA,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;AACvB,QAAA,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;IACvB;;IAIA,MAAM,CAAC,IAAU,EAAE,GAAgB,EAAA;AACjC,QAAA,UAAU,CAAC,IAAI,CAAC,UAAW,EAAE,IAAI,EAAE,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC;IACtD;AAEA,IAAA,OAAO,CAAC,IAAU,EAAA;AAChB,QAAA,UAAU,CAAC,IAAI,CAAC,UAAW,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;IAC7D;AAEA,IAAA,MAAM,CAAC,IAAU,EAAA;QACf,UAAU,CAAC,IAAI,CAAC;IAClB;IAEA,OAAO,CAAC,IAAU,EAAE,IAAU,EAAA;QAC5B,WAAW,CAAC,IAAI,CAAC,UAAW,EAAE,IAAI,EAAE,IAAI,CAAC;IAC3C;IAEA,KAAK,GAAA;AACH,QAAA,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;YAAE,UAAU,CAAC,IAAI,CAAC;IACnD;;AAGA,IAAA,MAAM,CAAC,GAAgB,EAAA;AACrB,QAAA,OAAO,GAAG,IAAI,IAAI,CAAC,IAAI;IACzB;AACD;;;;"}
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ let injected = false;
4
+ /**
5
+ * Document-level defaults, adopted once:
6
+ * - `tp-portal` never renders in place; its content only shows in an outlet.
7
+ * - `tp-portal-outlet` is layout-transparent so projected content behaves as
8
+ * if it were a direct child of the outlet's parent. Override freely.
9
+ * - `tp-portal-outlet-fallback` is layout-transparent too, and hidden while
10
+ * its outlet is `active`. The hide rule is `!important` on purpose: it
11
+ * reflects state, so a consumer's `display` styling must not reveal it.
12
+ */
13
+ function injectPortalStyles() {
14
+ if (injected || typeof document === "undefined")
15
+ return;
16
+ injected = true;
17
+ try {
18
+ const sheet = new CSSStyleSheet();
19
+ sheet.replaceSync(`
20
+ :where(tp-portal) { display: none; }
21
+ :where(tp-portal-outlet) { display: contents; }
22
+ :where(tp-portal-outlet-fallback) { display: contents; }
23
+ tp-portal-outlet[active] > tp-portal-outlet-fallback { display: none !important; }
24
+ `);
25
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
26
+ }
27
+ catch {
28
+ /* constructable stylesheets unsupported — styles are optional */
29
+ }
30
+ }
31
+
32
+ exports.injectPortalStyles = injectPortalStyles;
33
+ //# sourceMappingURL=styles.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.cjs","sources":["../../../../libs/elements/src/portal/styles.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA,IAAI,QAAQ,GAAG,KAAK;AAEpB;;;;;;;;AAQG;SACa,kBAAkB,GAAA;AAChC,IAAA,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE;IACjD,QAAQ,GAAG,IAAI;AACf,IAAA,IAAI;AACF,QAAA,MAAM,KAAK,GAAG,IAAI,aAAa,EAAE;QACjC,KAAK,CAAC,WAAW,CAAC;;;;;AAKjB,IAAA,CAAA,CAAC;QACF,QAAQ,CAAC,kBAAkB,GAAG,CAAC,GAAG,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC;IACvE;AAAE,IAAA,MAAM;;IAER;AACF;;;;"}
@@ -0,0 +1,31 @@
1
+ let injected = false;
2
+ /**
3
+ * Document-level defaults, adopted once:
4
+ * - `tp-portal` never renders in place; its content only shows in an outlet.
5
+ * - `tp-portal-outlet` is layout-transparent so projected content behaves as
6
+ * if it were a direct child of the outlet's parent. Override freely.
7
+ * - `tp-portal-outlet-fallback` is layout-transparent too, and hidden while
8
+ * its outlet is `active`. The hide rule is `!important` on purpose: it
9
+ * reflects state, so a consumer's `display` styling must not reveal it.
10
+ */
11
+ function injectPortalStyles() {
12
+ if (injected || typeof document === "undefined")
13
+ return;
14
+ injected = true;
15
+ try {
16
+ const sheet = new CSSStyleSheet();
17
+ sheet.replaceSync(`
18
+ :where(tp-portal) { display: none; }
19
+ :where(tp-portal-outlet) { display: contents; }
20
+ :where(tp-portal-outlet-fallback) { display: contents; }
21
+ tp-portal-outlet[active] > tp-portal-outlet-fallback { display: none !important; }
22
+ `);
23
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
24
+ }
25
+ catch {
26
+ /* constructable stylesheets unsupported — styles are optional */
27
+ }
28
+ }
29
+
30
+ export { injectPortalStyles };
31
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sources":["../../../../libs/elements/src/portal/styles.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA,IAAI,QAAQ,GAAG,KAAK;AAEpB;;;;;;;;AAQG;SACa,kBAAkB,GAAA;AAChC,IAAA,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE;IACjD,QAAQ,GAAG,IAAI;AACf,IAAA,IAAI;AACF,QAAA,MAAM,KAAK,GAAG,IAAI,aAAa,EAAE;QACjC,KAAK,CAAC,WAAW,CAAC;;;;;AAKjB,IAAA,CAAA,CAAC;QACF,QAAQ,CAAC,kBAAkB,GAAG,CAAC,GAAG,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC;IACvE;AAAE,IAAA,MAAM;;IAER;AACF;;;;"}