@trunkjs/content-pane 1.0.6 → 1.0.7
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 +4 -0
- package/components/tj-content-pane/TjContentPane.d.ts +4 -3
- package/index.js +96 -93
- package/package.json +1 -1
- package/web-types.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## 1.0.7 (2025-08-29)
|
|
2
|
+
|
|
3
|
+
This was a version bump only for content-pane to align it with other projects, there were no code changes.
|
|
4
|
+
|
|
1
5
|
## 1.0.6 (2025-08-29)
|
|
2
6
|
|
|
3
7
|
This was a version bump only for content-pane to align it with other projects, there were no code changes.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ReactiveElement } from 'lit';
|
|
2
2
|
declare const ContentAreaElement2_base: (abstract new (...args: any[]) => {
|
|
3
|
-
"__#
|
|
4
|
-
"__#
|
|
3
|
+
"__#2685@#debugCached": boolean | null;
|
|
4
|
+
"__#2685@#myElementId": number;
|
|
5
5
|
invalidateDebugCache(): void;
|
|
6
|
-
"__#
|
|
6
|
+
"__#2685@#myLoggerInstance": import('../../../../browser-utils/src/index.ts').Logger | null;
|
|
7
7
|
readonly _debug: boolean;
|
|
8
8
|
getLogger(instanceId?: string): import('../../../../browser-utils/src/index.ts').Logger;
|
|
9
9
|
log(...args: any[]): void;
|
|
@@ -15,6 +15,7 @@ export declare class ContentAreaElement2 extends ContentAreaElement2_base {
|
|
|
15
15
|
static get is(): string;
|
|
16
16
|
createRenderRoot(): HTMLElement | DocumentFragment;
|
|
17
17
|
constructor();
|
|
18
|
+
arrange(): void;
|
|
18
19
|
connectedCallback(): Promise<void>;
|
|
19
20
|
}
|
|
20
21
|
export {};
|
package/index.js
CHANGED
|
@@ -1,83 +1,16 @@
|
|
|
1
1
|
var C = Object.defineProperty;
|
|
2
2
|
var _ = (n, t, r) => t in n ? C(n, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[t] = r;
|
|
3
3
|
var h = (n, t, r) => _(n, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class S {
|
|
11
|
-
constructor(t, r = !1) {
|
|
12
|
-
h(this, "rootNode");
|
|
13
|
-
h(this, "currentContainerNode", null);
|
|
14
|
-
h(this, "containerPath", []);
|
|
15
|
-
h(this, "containerIndex", [0]);
|
|
16
|
-
h(this, "lastFixedI", 20);
|
|
17
|
-
this.debug = r, this.currentContainerNode = this.rootNode = t, this.containerPath.push(this.rootNode);
|
|
18
|
-
}
|
|
19
|
-
getI(t) {
|
|
20
|
-
const r = t.tagName, o = t.getAttribute("layout"), e = { i: -99, variant: "new", tag: "hr", hi: null };
|
|
21
|
-
if (o) {
|
|
22
|
-
const s = /^(\+|-|)([0-9]\.?[0-9]?|)(;|$)/, i = o.match(s);
|
|
23
|
-
i && (console.debug("Layout matches", i), e.variant = i[1] === "+" ? "append" : i[1] === "-" ? "skip" : "new", i[2] !== "" && (e.i = parseFloat(i[2]) * 10));
|
|
24
|
-
}
|
|
25
|
-
if (r.startsWith("H") && r.length === 2) {
|
|
26
|
-
let s = r.substring(1);
|
|
27
|
-
return e.tag = "h", e.hi = parseInt(s), s === "1" && (s = "2"), e.i === -99 && (e.i = parseInt(s) * 10, this.lastFixedI = e.i), e;
|
|
28
|
-
}
|
|
29
|
-
return e.i === -99 && r === "HR" ? (e.i = this.lastFixedI + 5, e) : null;
|
|
30
|
-
}
|
|
31
|
-
getAttributeRecords(t, r = !1) {
|
|
32
|
-
const o = {};
|
|
33
|
-
for (const e of t.attributes)
|
|
34
|
-
e.name.startsWith("section-") ? o[e.name] = e.value.replace(/^section-/, "") : e.name.startsWith("layout") ? (o[e.name] = e.value, t.removeAttribute(e.name)) : r && (o[e.name] = e.value);
|
|
35
|
-
if (!r)
|
|
36
|
-
for (const e of Array.from(t.classList))
|
|
37
|
-
e.startsWith("section-") && (o.class = (o.class || "") + " " + e.replace(/^section-/, ""), t.classList.remove(e));
|
|
38
|
-
return o;
|
|
39
|
-
}
|
|
40
|
-
createNewContainerNode(t, r) {
|
|
41
|
-
const o = this.getAttributeRecords(t, t.tagName === "HR"), e = b("section", o);
|
|
42
|
-
return e.__IT = r, e;
|
|
43
|
-
}
|
|
44
|
-
arrangeSingleNode(t, r) {
|
|
45
|
-
r.i;
|
|
46
|
-
let o = 0;
|
|
47
|
-
for (o = 0; o < this.containerIndex.length && !(this.containerIndex[o] >= r.i); o++)
|
|
48
|
-
;
|
|
49
|
-
let e = null;
|
|
50
|
-
r.variant === "append" ? (console.log("Appending to container at index", o, "with i", r.i), e = this.containerPath[o]) : e = this.createNewContainerNode(t, r);
|
|
51
|
-
const s = this.containerPath[o - 1];
|
|
52
|
-
this.containerPath.length = o, this.containerIndex.length = o, e.appendChild(t), s.appendChild(e), this.containerPath.push(e), this.containerIndex.push(r.i), this.currentContainerNode = e;
|
|
53
|
-
}
|
|
54
|
-
appendToCurrentContainer(t) {
|
|
55
|
-
if (this.currentContainerNode === null)
|
|
56
|
-
throw new Error("No current container node set");
|
|
57
|
-
this.currentContainerNode.appendChild(t);
|
|
58
|
-
}
|
|
59
|
-
arrange(t) {
|
|
60
|
-
for (let r of t) {
|
|
61
|
-
if (r.nodeType !== Node.ELEMENT_NODE) {
|
|
62
|
-
this.appendToCurrentContainer(r);
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
const o = r, e = this.getI(o);
|
|
66
|
-
if (!e || e.variant === "skip") {
|
|
67
|
-
this.appendToCurrentContainer(r);
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
this.arrangeSingleNode(o, e);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
const $ = ":host{--border-color: red;--background-color: lightgray;font-family:Arial,sans-serif}#error-fixed-indicator{position:fixed;top:10px;right:10px;cursor:pointer;z-index:100000;padding:5px 10px;width:auto;max-width:90vw;min-width:100px;height:auto;box-shadow:0 4px 8px #0003;border:5px solid white;color:#fff;background-color:red;animation:blink 1s infinite;border-radius:15px;font-size:20px;font-weight:700;font-family:Arial,sans-serif}@keyframes blink{0%,to{background-color:#000}50%{background-color:red}}#error{background-color:var(--background-color);border:3px solid var(--border-color);padding:10px;margin:10px;border-radius:5px}h1{color:red;font-size:24px;margin:0}.error-details{font-size:14px;max-height:200px;overflow:auto}";
|
|
75
|
-
var w = Object.defineProperty, M = Object.getOwnPropertyDescriptor, O = (n, t, r) => t in n ? w(n, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[t] = r, v = (n, t, r, o) => {
|
|
76
|
-
for (var e = o > 1 ? void 0 : o ? M(t, r) : t, s = n.length - 1, i; s >= 0; s--)
|
|
4
|
+
import { create_element as y, LoggingMixin as E, Stopwatch as A, waitForDomContentLoaded as N } from "@trunkjs/browser-utils";
|
|
5
|
+
import { unsafeCSS as I, LitElement as L, html as k, ReactiveElement as T } from "lit";
|
|
6
|
+
import { property as P, customElement as b } from "lit/decorators.js";
|
|
7
|
+
const S = ":host{--border-color: red;--background-color: lightgray;font-family:Arial,sans-serif}#error-fixed-indicator{position:fixed;top:10px;right:10px;cursor:pointer;z-index:100000;padding:5px 10px;width:auto;max-width:90vw;min-width:100px;height:auto;box-shadow:0 4px 8px #0003;border:5px solid white;color:#fff;background-color:red;animation:blink 1s infinite;border-radius:15px;font-size:20px;font-weight:700;font-family:Arial,sans-serif}@keyframes blink{0%,to{background-color:#000}50%{background-color:red}}#error{background-color:var(--background-color);border:3px solid var(--border-color);padding:10px;margin:10px;border-radius:5px}h1{color:red;font-size:24px;margin:0}.error-details{font-size:14px;max-height:200px;overflow:auto}";
|
|
8
|
+
var w = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, M = (n, t, r) => t in n ? w(n, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[t] = r, v = (n, t, r, o) => {
|
|
9
|
+
for (var e = o > 1 ? void 0 : o ? $(t, r) : t, s = n.length - 1, i; s >= 0; s--)
|
|
77
10
|
(i = n[s]) && (e = (o ? i(t, r, e) : i(e)) || e);
|
|
78
11
|
return o && e && w(t, r, e), e;
|
|
79
|
-
},
|
|
80
|
-
let f = class extends
|
|
12
|
+
}, O = (n, t, r) => M(n, t + "", r);
|
|
13
|
+
let f = class extends L {
|
|
81
14
|
constructor(t = "An error occurred", r) {
|
|
82
15
|
super();
|
|
83
16
|
h(this, "originalCode");
|
|
@@ -88,7 +21,7 @@ let f = class extends A {
|
|
|
88
21
|
return "tj-error-element";
|
|
89
22
|
}
|
|
90
23
|
render() {
|
|
91
|
-
return
|
|
24
|
+
return k`
|
|
92
25
|
<div id="error-fixed-indicator" @click=${() => this.scrollIntoView({ behavior: "smooth" })}>
|
|
93
26
|
Err: ${this.message}
|
|
94
27
|
</div>
|
|
@@ -104,14 +37,14 @@ let f = class extends A {
|
|
|
104
37
|
`;
|
|
105
38
|
}
|
|
106
39
|
};
|
|
107
|
-
|
|
40
|
+
O(f, "styles", [I(S)]);
|
|
108
41
|
v([
|
|
109
|
-
|
|
42
|
+
P({ type: String, reflect: !0 })
|
|
110
43
|
], f.prototype, "message", 2);
|
|
111
44
|
f = v([
|
|
112
|
-
|
|
45
|
+
b("tj-error-element")
|
|
113
46
|
], f);
|
|
114
|
-
function
|
|
47
|
+
function R(n, { allowAttributes: t = !0, ignoreGaps: r = !0 } = {}) {
|
|
115
48
|
let o = "div", e = null, s = [], i = [], l = {};
|
|
116
49
|
const d = /(^[a-z][\w-]*)|#[\w-]+|\.[\w:-]+|\[\s*([\w-]+)(?:\s*=\s*(['"]?)(.*?)\3)?\s*\]/gi;
|
|
117
50
|
let a = 0;
|
|
@@ -134,21 +67,21 @@ function j(n, { allowAttributes: t = !0, ignoreGaps: r = !0 } = {}) {
|
|
|
134
67
|
}
|
|
135
68
|
return { tag: o, id: e, classes: s, attrs: i, attrsMap: l, length: a, rest: n.slice(a) };
|
|
136
69
|
}
|
|
137
|
-
function
|
|
70
|
+
function j(n) {
|
|
138
71
|
return typeof n.beforeLayoutCallback == "function";
|
|
139
72
|
}
|
|
140
|
-
function
|
|
73
|
+
function D(n, t, r) {
|
|
141
74
|
var u, c;
|
|
142
75
|
console.log("Applying layout to element:", n, "with layout:", r);
|
|
143
|
-
const o = /^(\+|-|)([0-9]+\.?[0-9]*);?/, e = r.replace(o, ""), s =
|
|
76
|
+
const o = /^(\+|-|)([0-9]+\.?[0-9]*);?/, e = r.replace(o, ""), s = R(e), i = { class: "" };
|
|
144
77
|
s.attrsMap.class && (i.class = s.attrsMap.class + " "), i.class += s.classes.join(" "), i.id = s.id, ((u = i.class) == null ? void 0 : u.trim()) === "" && delete i.class, ((c = i.id) == null ? void 0 : c.trim()) === "" && delete i.id;
|
|
145
78
|
const l = s.tag || "div";
|
|
146
|
-
let d = !1, a =
|
|
79
|
+
let d = !1, a = y(l, { ...i, layoutOrig: r });
|
|
147
80
|
if (l.includes("-") && !customElements.get(l))
|
|
148
81
|
console.warn(`Custom element <${l}> is not registered.`), a = new f(`Custom element <${l}> is not registered.`, n.outerHTML), n.replaceWith(a), a.append(n), d = !0;
|
|
149
82
|
else {
|
|
150
83
|
const p = Array.from(n.children);
|
|
151
|
-
|
|
84
|
+
j(a) && (d = a.beforeLayoutCallback(n, a, p) === !1), console.log(
|
|
152
85
|
"Replacement element created:",
|
|
153
86
|
a,
|
|
154
87
|
"with children:",
|
|
@@ -172,18 +105,85 @@ function g(n, t = {}) {
|
|
|
172
105
|
return [];
|
|
173
106
|
const e = n.getAttribute("layout");
|
|
174
107
|
let s = !1, i = n;
|
|
175
|
-
if (e && ({ replacementElement: i, skipChildren: s } =
|
|
108
|
+
if (e && ({ replacementElement: i, skipChildren: s } = D(n, t, e)), r && !s) {
|
|
176
109
|
const l = Array.from(i.children);
|
|
177
110
|
console.log("Applying layout to children:", l, "of element:", i), l.forEach((d) => o.push(...g(d, t)));
|
|
178
111
|
}
|
|
179
112
|
return o;
|
|
180
113
|
}
|
|
114
|
+
function V(n) {
|
|
115
|
+
return n && typeof n == "object" && "__I__" in n && typeof n.__I__ == "object" && "i" in n.__I__;
|
|
116
|
+
}
|
|
117
|
+
class F {
|
|
118
|
+
constructor(t, r = !1) {
|
|
119
|
+
h(this, "rootNode");
|
|
120
|
+
h(this, "currentContainerNode", null);
|
|
121
|
+
h(this, "containerPath", []);
|
|
122
|
+
h(this, "containerIndex", [0]);
|
|
123
|
+
h(this, "lastFixedI", 20);
|
|
124
|
+
this.debug = r, this.currentContainerNode = this.rootNode = t, this.containerPath.push(this.rootNode);
|
|
125
|
+
}
|
|
126
|
+
getI(t) {
|
|
127
|
+
const r = t.tagName, o = t.getAttribute("layout"), e = { i: -99, variant: "new", tag: "hr", hi: null };
|
|
128
|
+
if (o) {
|
|
129
|
+
const s = /^(\+|-|)([0-9]\.?[0-9]?|)(;|$)/, i = o.match(s);
|
|
130
|
+
i && (console.debug("Layout matches", i), e.variant = i[1] === "+" ? "append" : i[1] === "-" ? "skip" : "new", i[2] !== "" && (e.i = parseFloat(i[2]) * 10));
|
|
131
|
+
}
|
|
132
|
+
if (r.startsWith("H") && r.length === 2) {
|
|
133
|
+
let s = r.substring(1);
|
|
134
|
+
return e.tag = "h", e.hi = parseInt(s), s === "1" && (s = "2"), e.i === -99 && (e.i = parseInt(s) * 10, this.lastFixedI = e.i), e;
|
|
135
|
+
}
|
|
136
|
+
return e.i === -99 && r === "HR" ? (e.i = this.lastFixedI + 5, e) : null;
|
|
137
|
+
}
|
|
138
|
+
getAttributeRecords(t, r = !1) {
|
|
139
|
+
const o = {};
|
|
140
|
+
for (const e of t.attributes)
|
|
141
|
+
e.name.startsWith("section-") ? o[e.name] = e.value.replace(/^section-/, "") : e.name.startsWith("layout") ? (o[e.name] = e.value, t.removeAttribute(e.name)) : r && (o[e.name] = e.value);
|
|
142
|
+
if (!r)
|
|
143
|
+
for (const e of Array.from(t.classList))
|
|
144
|
+
e.startsWith("section-") && (o.class = (o.class || "") + " " + e.replace(/^section-/, ""), t.classList.remove(e));
|
|
145
|
+
return o;
|
|
146
|
+
}
|
|
147
|
+
createNewContainerNode(t, r) {
|
|
148
|
+
const o = this.getAttributeRecords(t, t.tagName === "HR"), e = y("section", o);
|
|
149
|
+
return e.__IT = r, e;
|
|
150
|
+
}
|
|
151
|
+
arrangeSingleNode(t, r) {
|
|
152
|
+
r.i;
|
|
153
|
+
let o = 0;
|
|
154
|
+
for (o = 0; o < this.containerIndex.length && !(this.containerIndex[o] >= r.i); o++)
|
|
155
|
+
;
|
|
156
|
+
let e = null;
|
|
157
|
+
r.variant === "append" ? (console.log("Appending to container at index", o, "with i", r.i), e = this.containerPath[o]) : e = this.createNewContainerNode(t, r);
|
|
158
|
+
const s = this.containerPath[o - 1];
|
|
159
|
+
this.containerPath.length = o, this.containerIndex.length = o, e.appendChild(t), s.appendChild(e), this.containerPath.push(e), this.containerIndex.push(r.i), this.currentContainerNode = e;
|
|
160
|
+
}
|
|
161
|
+
appendToCurrentContainer(t) {
|
|
162
|
+
if (this.currentContainerNode === null)
|
|
163
|
+
throw new Error("No current container node set");
|
|
164
|
+
this.currentContainerNode.appendChild(t);
|
|
165
|
+
}
|
|
166
|
+
arrange(t) {
|
|
167
|
+
for (let r of t) {
|
|
168
|
+
if (r.nodeType !== Node.ELEMENT_NODE) {
|
|
169
|
+
this.appendToCurrentContainer(r);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const o = r, e = this.getI(o);
|
|
173
|
+
if (!e || e.variant === "skip") {
|
|
174
|
+
this.appendToCurrentContainer(r);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
this.arrangeSingleNode(o, e);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
181
|
var W = Object.getOwnPropertyDescriptor, z = (n, t, r, o) => {
|
|
182
182
|
for (var e = o > 1 ? void 0 : o ? W(t, r) : t, s = n.length - 1, i; s >= 0; s--)
|
|
183
183
|
(i = n[s]) && (e = i(e) || e);
|
|
184
184
|
return e;
|
|
185
185
|
};
|
|
186
|
-
let x = class extends
|
|
186
|
+
let x = class extends E(T) {
|
|
187
187
|
static get is() {
|
|
188
188
|
return "tj-content-pane";
|
|
189
189
|
}
|
|
@@ -193,15 +193,18 @@ let x = class extends k(I) {
|
|
|
193
193
|
constructor() {
|
|
194
194
|
super();
|
|
195
195
|
}
|
|
196
|
-
|
|
197
|
-
const n = new
|
|
198
|
-
|
|
199
|
-
const t = new
|
|
196
|
+
arrange() {
|
|
197
|
+
const n = new A("SectionTreeBuilder");
|
|
198
|
+
this.log("arrange() called");
|
|
199
|
+
const t = new F(this), r = Array.from(this.children);
|
|
200
200
|
t.arrange(r), g(Array.from(this.children), { recursive: !0 }), n.lap("after arrange");
|
|
201
201
|
}
|
|
202
|
+
async connectedCallback() {
|
|
203
|
+
await N(), super.connectedCallback(), this.arrange();
|
|
204
|
+
}
|
|
202
205
|
};
|
|
203
206
|
x = z([
|
|
204
|
-
|
|
207
|
+
b("tj-content-pane")
|
|
205
208
|
], x);
|
|
206
209
|
function J(n, t, r) {
|
|
207
210
|
const o = [], e = t.split("|");
|
|
@@ -218,7 +221,7 @@ function J(n, t, r) {
|
|
|
218
221
|
}
|
|
219
222
|
export {
|
|
220
223
|
x as ContentAreaElement2,
|
|
221
|
-
|
|
224
|
+
F as SectionTreeBuilder,
|
|
222
225
|
g as applyLayout,
|
|
223
226
|
J as attrAssign,
|
|
224
227
|
V as isSectionTreeElement
|
package/package.json
CHANGED