iobroker.webui 1.25.2 → 1.26.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/README.md +6 -0
- package/io-package.json +14 -14
- package/package.json +14 -14
- package/www/dist/frontend/common/Common.globals.d.ts +1 -1
- package/www/dist/frontend/common/Runtime.d.ts +2 -2
- package/www/dist/frontend/config/IobrokerWebuiSolutionExplorer.js +4 -4
- package/www/dist/frontend/generated/ScriptCommands.json +8 -3
- package/www/dist/frontend/helper/DialogHelper.js +7 -4
- package/www/dist/frontend/runtime/ScreenViewer.js +13 -16
- package/www/dist/frontend/scripting/IobrokerWebuiScriptSystem.js +2 -1
- package/www/index.html +1 -1
- package/www/node_modules/@adobe/css-tools/dist/index.mjs +1 -1
- package/www/node_modules/@iobroker/socket-client/dist/esm/AdminConnection.js +7 -4
- package/www/node_modules/@iobroker/socket-client/dist/esm/Connection.d.ts +82 -2
- package/www/node_modules/@iobroker/socket-client/dist/esm/Connection.js +266 -2
- package/www/node_modules/@node-projects/base-custom-webcomponent/dist/BaseCustomWebComponent.d.ts +2 -1
- package/www/node_modules/@node-projects/base-custom-webcomponent/dist/BaseCustomWebComponent.js +63 -53
- package/www/node_modules/@node-projects/base-custom-webcomponent/dist/Effect.js +2 -0
- package/www/node_modules/@node-projects/base-custom-webcomponent/dist/SignalDecorator.js +16 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/BaseCustomWebComponent.js +795 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/Debounce.js +19 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/DeclaritiveBaseCustomWebcomponent.js +176 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/DomHelper.js +96 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/HotModuleReplacement.js +125 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/LazyLoader.js +52 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/TouchContextMenu.js +20 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/TypedEvent.js +48 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/WeakArray.js +27 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/index.js +9 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/jsr.json +5 -0
- package/www/node_modules/@node-projects/web-component-designer/dist/elements/helper/getBoxQuads.js +14 -15
- package/www/node_modules/@node-projects/web-component-designer/dist/elements/services/ServiceContainer.js +1 -0
- package/www/node_modules/@node-projects/web-component-designer/dist/elements/services/propertiesService/services/NativeElementsPropertiesService.js +37 -0
- package/www/node_modules/@node-projects/web-component-designer/dist/elements/widgets/designerView/designerCanvas.js +2 -0
- package/www/node_modules/@node-projects/web-component-designer/dist/elements/widgets/designerView/extensions/buttons/OptionsContextMenuButton.js +29 -4
- package/www/node_modules/es-module-shims/dist/es-module-shims.js +754 -628
- package/www/node_modules/long/index.js +360 -246
- package/www/node_modules/long/umd/index.js +1585 -1395
- package/www/node_modules/wunderbaum/dist/wunderbaum.css +1 -1
- package/www/node_modules/wunderbaum/dist/wunderbaum.esm.min.js +35 -35
|
@@ -0,0 +1,795 @@
|
|
|
1
|
+
import { addTouchFriendlyContextMenu } from "./TouchContextMenu.js";
|
|
2
|
+
import { TypedEvent } from './TypedEvent.js';
|
|
3
|
+
function toParString(strings, values) {
|
|
4
|
+
if (strings.length === 1)
|
|
5
|
+
return strings.raw[0];
|
|
6
|
+
else {
|
|
7
|
+
let r = '';
|
|
8
|
+
for (let i = 0; i < strings.length; i++) {
|
|
9
|
+
r += strings[i] + (values[i] ?? '');
|
|
10
|
+
}
|
|
11
|
+
return r;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export const html = function (strings, ...values) {
|
|
15
|
+
const template = document.createElement('template');
|
|
16
|
+
template.innerHTML = toParString(strings, values);
|
|
17
|
+
return template;
|
|
18
|
+
};
|
|
19
|
+
export const htmlFromString = function (value) {
|
|
20
|
+
const template = document.createElement('template');
|
|
21
|
+
template.innerHTML = value;
|
|
22
|
+
return template;
|
|
23
|
+
};
|
|
24
|
+
export const css = function (strings, ...values) {
|
|
25
|
+
const cssStyleSheet = new CSSStyleSheet();
|
|
26
|
+
//@ts-ignore
|
|
27
|
+
cssStyleSheet.replaceSync(toParString(strings, values));
|
|
28
|
+
return cssStyleSheet;
|
|
29
|
+
};
|
|
30
|
+
export const cssFromString = function (value) {
|
|
31
|
+
if (typeof value === 'object' && value.default instanceof CSSStyleSheet)
|
|
32
|
+
return value.default;
|
|
33
|
+
if (value instanceof CSSStyleSheet)
|
|
34
|
+
return value;
|
|
35
|
+
const cssStyleSheet = new CSSStyleSheet();
|
|
36
|
+
//@ts-ignore
|
|
37
|
+
cssStyleSheet.replaceSync(value);
|
|
38
|
+
return cssStyleSheet;
|
|
39
|
+
};
|
|
40
|
+
// decorators
|
|
41
|
+
export function property(par) {
|
|
42
|
+
return function (target, propertyKey) {
|
|
43
|
+
//@ts-ignore
|
|
44
|
+
if (!target.constructor.properties) {
|
|
45
|
+
//@ts-ignore
|
|
46
|
+
target.constructor.properties = {};
|
|
47
|
+
}
|
|
48
|
+
if (par && par.type != null) {
|
|
49
|
+
//@ts-ignore
|
|
50
|
+
target.constructor.properties[propertyKey] = par.type ? par.type : String;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
//@ts-ignore
|
|
54
|
+
target.constructor.properties[propertyKey] = par ? par : String;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export function customElement(tagname) {
|
|
59
|
+
return function (class_) {
|
|
60
|
+
//@ts-ignore
|
|
61
|
+
class_.is = tagname;
|
|
62
|
+
customElements.define(tagname, class_);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
let _bindingRegex = /\[\[.*?\]\]/g;
|
|
66
|
+
export class BaseCustomWebComponentNoAttachedTemplate extends HTMLElement {
|
|
67
|
+
static style;
|
|
68
|
+
static template;
|
|
69
|
+
//todo: bindings map should contain the name of the bound property
|
|
70
|
+
_bindings;
|
|
71
|
+
_repeatBindings;
|
|
72
|
+
_rootDocumentFragment;
|
|
73
|
+
_initialPropertyCache = new Map();
|
|
74
|
+
_noWarningOnBindingErrors;
|
|
75
|
+
_getDomElement(id) {
|
|
76
|
+
if (this.shadowRoot.children.length > 1 || (this.shadowRoot.children[0] !== undefined && this.shadowRoot.children[0].localName !== 'style'))
|
|
77
|
+
return this.shadowRoot.getElementById(id);
|
|
78
|
+
return this._rootDocumentFragment.getElementById(id);
|
|
79
|
+
}
|
|
80
|
+
_getDomElements(selector) {
|
|
81
|
+
if (this.shadowRoot.children.length > 1 || (this.shadowRoot.children[0] !== undefined && this.shadowRoot.children[0].localName !== 'style'))
|
|
82
|
+
return this.shadowRoot.querySelectorAll(selector);
|
|
83
|
+
return this._rootDocumentFragment.querySelectorAll(selector);
|
|
84
|
+
}
|
|
85
|
+
_assignEvents(node) {
|
|
86
|
+
if (!node) {
|
|
87
|
+
node = this.shadowRoot.children.length > 0 ? this.shadowRoot : this._rootDocumentFragment;
|
|
88
|
+
}
|
|
89
|
+
if (node instanceof Element) {
|
|
90
|
+
for (let a of node.attributes) {
|
|
91
|
+
if (a.name.startsWith('@') && !a.value.startsWith('[[')) {
|
|
92
|
+
try {
|
|
93
|
+
if (a.name == "@touch:contextmenu")
|
|
94
|
+
addTouchFriendlyContextMenu(node, this[a.value].bind(this));
|
|
95
|
+
else {
|
|
96
|
+
let sNm = a.name.substr(1);
|
|
97
|
+
if (sNm[0] === '@') {
|
|
98
|
+
sNm = sNm.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
99
|
+
}
|
|
100
|
+
let nm = sNm.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
101
|
+
if (node[nm] instanceof TypedEvent) {
|
|
102
|
+
node[nm].on(this[a.value].bind(this));
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
node.addEventListener(sNm, this[a.value].bind(this));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
console.warn(error.message, 'Failed to attach event "', a, node);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
for (let n of node.childNodes) {
|
|
116
|
+
this._assignEvents(n);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Parses Polymer like Bindings
|
|
121
|
+
*
|
|
122
|
+
* use [[expression]] for one way bindings
|
|
123
|
+
*
|
|
124
|
+
* use {{this.property::change;paste}} for two way wich binds to events 'change 'and 'paste'
|
|
125
|
+
*
|
|
126
|
+
* use @eventname="eventHandler" to bind a handler to a event
|
|
127
|
+
* or @eventname="[[this.eventHandler(par1, par2, ..)]]" for complexer event logic
|
|
128
|
+
* use @touch:contextmenu... for a context menu that also works with long press on touch
|
|
129
|
+
*
|
|
130
|
+
* use css:cssPropertyName=[[expression]] to bind to a css property
|
|
131
|
+
*
|
|
132
|
+
* use class:className=[[boolExpression]] to set/remove a css class
|
|
133
|
+
*
|
|
134
|
+
* sub <template></template> elements are not bound, so elemnts like <iron-list> of polymer also work
|
|
135
|
+
*
|
|
136
|
+
* use repeat:nameOfItem=[[enumerableExpression]] on a Template Element to repeate it for every instance of the enumarable
|
|
137
|
+
* ==> this could also be nested
|
|
138
|
+
*
|
|
139
|
+
*/
|
|
140
|
+
_bindingsParse(node, removeAttributes = false, host = null, context = null) {
|
|
141
|
+
this._bindingsInternalParse(node, null, removeAttributes, host, context);
|
|
142
|
+
}
|
|
143
|
+
_bindingsInternalParse(startNode, repeatBindingItems, removeAttributes, host, context) {
|
|
144
|
+
if (!this._bindings)
|
|
145
|
+
this._bindings = [];
|
|
146
|
+
if (!startNode)
|
|
147
|
+
startNode = this.shadowRoot.childNodes.length > 0 ? this.shadowRoot : this._rootDocumentFragment;
|
|
148
|
+
const walker = document.createTreeWalker(startNode, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, null);
|
|
149
|
+
let currNode = startNode;
|
|
150
|
+
let loopNode = currNode;
|
|
151
|
+
while (loopNode) {
|
|
152
|
+
loopNode = currNode;
|
|
153
|
+
if (!loopNode)
|
|
154
|
+
break;
|
|
155
|
+
currNode = walker.nextNode();
|
|
156
|
+
let node = loopNode;
|
|
157
|
+
if (node.nodeType === 1) { //node.nodeType === 1
|
|
158
|
+
const attributes = Array.from(node.attributes);
|
|
159
|
+
for (let a of attributes) {
|
|
160
|
+
if (a.value[0] === '[' && a.value[1] === '[' && a.value[a.value.length - 1] === ']' && a.value[a.value.length - 2] === ']') {
|
|
161
|
+
if (a.name.startsWith('css:')) {
|
|
162
|
+
const value = a.value.substring(2, a.value.length - 2).replaceAll('&', '&');
|
|
163
|
+
const camelCased = a.name.substring(4, a.name.length).replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
164
|
+
const b = () => this._bindingSetElementCssValue(node, camelCased, value, repeatBindingItems, host, context);
|
|
165
|
+
this._bindings.push([b, null]);
|
|
166
|
+
b();
|
|
167
|
+
}
|
|
168
|
+
else if (a.name.startsWith('class:')) {
|
|
169
|
+
const value = a.value.substring(2, a.value.length - 2).replaceAll('&', '&');
|
|
170
|
+
const camelCased = a.name.substring(6, a.name.length).replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
171
|
+
const b = () => this._bindingSetElementClass(node, camelCased, value, repeatBindingItems, host, context);
|
|
172
|
+
this._bindings.push([b, null]);
|
|
173
|
+
b();
|
|
174
|
+
}
|
|
175
|
+
else if (a.name.startsWith('bcw:')) {
|
|
176
|
+
if (a.name === 'bcw:visible') {
|
|
177
|
+
const value = a.value.substring(2, a.value.length - 2).replaceAll('&', '&');
|
|
178
|
+
const display = node.style.display;
|
|
179
|
+
const b = () => this._bindingSetElementCssValue(node, 'display', value + "?'" + display + "':'none'", repeatBindingItems, host, context);
|
|
180
|
+
this._bindings.push([b, null]);
|
|
181
|
+
b();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else if (a.name.length === 28 && a.name === 'repeat-changed-item-callback') {
|
|
185
|
+
//do nothing
|
|
186
|
+
}
|
|
187
|
+
else if (a.name === 'if' && node instanceof HTMLTemplateElement) {
|
|
188
|
+
const value = a.value.substring(2, a.value.length - 2).replaceAll('&', '&');
|
|
189
|
+
const elementsCache = [];
|
|
190
|
+
const b = () => this._bindingConditional(node, value, repeatBindingItems, elementsCache, host, context);
|
|
191
|
+
this._bindings.push([b, null]);
|
|
192
|
+
b();
|
|
193
|
+
}
|
|
194
|
+
else if (a.name.startsWith('repeat:')) {
|
|
195
|
+
const value = a.value.substring(2, a.value.length - 2).replaceAll('&', '&');
|
|
196
|
+
const bindingItemVariableName = a.name.substring(7, a.name.length).replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
197
|
+
const elementsCache = [];
|
|
198
|
+
let bindingIndexname = 'index';
|
|
199
|
+
let changeItemCallback = null;
|
|
200
|
+
const indexNameAttribute = attributes.find(x => x.name == 'repeat-index');
|
|
201
|
+
if (indexNameAttribute)
|
|
202
|
+
bindingIndexname = indexNameAttribute.value;
|
|
203
|
+
const changeItemCallbackAttribute = attributes.find(x => x.name == 'repeat-changed-item-callback');
|
|
204
|
+
if (changeItemCallbackAttribute)
|
|
205
|
+
changeItemCallback = changeItemCallbackAttribute.value;
|
|
206
|
+
const b = () => this._bindingRepeat(node, bindingItemVariableName, bindingIndexname, value, changeItemCallback, repeatBindingItems, elementsCache, host, context);
|
|
207
|
+
this._bindings.push([b, null]);
|
|
208
|
+
b();
|
|
209
|
+
}
|
|
210
|
+
else if (a.name[0] === '@') { //todo remove events on repeat refresh
|
|
211
|
+
let nm;
|
|
212
|
+
if (a.name[1] === '@')
|
|
213
|
+
nm = a.name.substring(2, a.name.length).replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
214
|
+
else
|
|
215
|
+
nm = a.name.substring(1, a.name.length);
|
|
216
|
+
const value = a.value.substring(2, a.value.length - 2).replaceAll('&', '&');
|
|
217
|
+
if (a.name == "@touch:contextmenu")
|
|
218
|
+
addTouchFriendlyContextMenu(node, (e) => this._bindingRunEval(value, repeatBindingItems, e, host, context));
|
|
219
|
+
else {
|
|
220
|
+
if (node[nm] instanceof TypedEvent) {
|
|
221
|
+
node[nm].on((e) => this._bindingRunEval(value, repeatBindingItems, e, host, context));
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
node.addEventListener(nm, (e) => this._bindingRunEval(value, repeatBindingItems, e, host, context));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
let value = a.value.substring(2, a.value.length - 2).replaceAll('&', '&');
|
|
230
|
+
let camelCased = a.name;
|
|
231
|
+
if (a.name[0] !== '$' && a.name[0] !== '?')
|
|
232
|
+
camelCased = a.name.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
233
|
+
let noNull = false;
|
|
234
|
+
if (value[0] === '?') {
|
|
235
|
+
value = value.substring(1);
|
|
236
|
+
noNull = true;
|
|
237
|
+
}
|
|
238
|
+
const b = (firstRun, onlyWhenChanged) => this._bindingSetNodeValue(firstRun, node, a, camelCased, value, repeatBindingItems, removeAttributes, host, context, noNull, onlyWhenChanged);
|
|
239
|
+
this._bindings.push([b, null]);
|
|
240
|
+
b(true, false);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
else if (a.value[0] === '{' && a.value[1] === '{' && a.value[a.value.length - 1] === '}' && a.value[a.value.length - 2] === '}') {
|
|
244
|
+
const attributeValues = a.value.substring(2, a.value.length - 2).split('::');
|
|
245
|
+
let nm = a.name;
|
|
246
|
+
if (nm[0] == '.')
|
|
247
|
+
nm = nm.substring(1);
|
|
248
|
+
let value = attributeValues[0];
|
|
249
|
+
let event = (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement) ? 'input' : (node instanceof HTMLSelectElement ? 'change' : nm + '-changed');
|
|
250
|
+
if (attributeValues.length > 1 && attributeValues[1])
|
|
251
|
+
event = attributeValues[1];
|
|
252
|
+
const camelCased = nm.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
253
|
+
let noNull = false;
|
|
254
|
+
if (value[0] === '?') {
|
|
255
|
+
value = value.substring(1);
|
|
256
|
+
noNull = true;
|
|
257
|
+
}
|
|
258
|
+
const b = (firstRun, onlyWhenChanged) => this._bindingSetNodeValue(firstRun, node, a, camelCased, value, repeatBindingItems, removeAttributes, host, context, noNull, onlyWhenChanged);
|
|
259
|
+
this._bindings.push([b, null]);
|
|
260
|
+
b(true, false);
|
|
261
|
+
if (event) {
|
|
262
|
+
for (let x of event.split(';')) {
|
|
263
|
+
if (node[x] instanceof TypedEvent)
|
|
264
|
+
node[x].on((e) => this._bindingsSetValue(host ?? this, value.replaceAll('?', ''), node[camelCased], context, repeatBindingItems));
|
|
265
|
+
else
|
|
266
|
+
node.addEventListener(x, (e) => this._bindingsSetValue(host ?? this, value.replaceAll('?', ''), node[camelCased], context, repeatBindingItems));
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
else if (node.nodeType === 3) {
|
|
273
|
+
if (node.nodeValue.indexOf('[[') >= 0) {
|
|
274
|
+
const text = node.nodeValue;
|
|
275
|
+
const matches = text.matchAll(_bindingRegex);
|
|
276
|
+
let lastindex = 0;
|
|
277
|
+
let fragment;
|
|
278
|
+
const trimmedLength = text.trim().length;
|
|
279
|
+
for (let m of matches) {
|
|
280
|
+
if ((m[0].length == trimmedLength || (m.index == 0 && m[0].length == text.length)) && node.parentNode.childNodes.length == 1) {
|
|
281
|
+
const parent = node.parentNode;
|
|
282
|
+
node.parentNode.removeChild(node);
|
|
283
|
+
this._textFragmentBinding(parent, m, repeatBindingItems, removeAttributes, host, context);
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
if (!fragment)
|
|
287
|
+
fragment = document.createDocumentFragment();
|
|
288
|
+
if (m.index - lastindex > 0) {
|
|
289
|
+
const tn = document.createTextNode(text.substr(lastindex, m.index - lastindex));
|
|
290
|
+
fragment.appendChild(tn);
|
|
291
|
+
}
|
|
292
|
+
const newNode = document.createElement('span');
|
|
293
|
+
this._textFragmentBinding(newNode, m, repeatBindingItems, removeAttributes, host, context);
|
|
294
|
+
fragment.appendChild(newNode);
|
|
295
|
+
lastindex = m.index + m[0].length;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (fragment) {
|
|
299
|
+
if (lastindex > 0 && text.length - lastindex > 0) {
|
|
300
|
+
let tn = document.createTextNode(text.substr(lastindex, text.length - lastindex));
|
|
301
|
+
fragment.appendChild(tn);
|
|
302
|
+
}
|
|
303
|
+
node.parentNode.replaceChild(fragment, node);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
_textFragmentBinding(node, m, repeatBindingItems, removeAttributes, host, context) {
|
|
310
|
+
let value = m[0].substr(2, m[0].length - 4);
|
|
311
|
+
let noNull = false;
|
|
312
|
+
if (value[0] === '?') {
|
|
313
|
+
value = value.substring(1);
|
|
314
|
+
noNull = true;
|
|
315
|
+
}
|
|
316
|
+
const b = (firstRun, onlyWhenChanged) => this._bindingSetNodeValue(firstRun, node, null, 'innerHTML', value, repeatBindingItems, removeAttributes, host, context, noNull, onlyWhenChanged);
|
|
317
|
+
this._bindings.push([b, null]);
|
|
318
|
+
b(true, false);
|
|
319
|
+
}
|
|
320
|
+
_bindingRunEval(expression, repeatBindingItems, event, host, context) {
|
|
321
|
+
if (host)
|
|
322
|
+
return this._bindingRunEvalInt.bind(host)(expression, repeatBindingItems, event, context);
|
|
323
|
+
return this._bindingRunEvalInt(expression, repeatBindingItems, event, context);
|
|
324
|
+
}
|
|
325
|
+
//This method can not use "this" anywhere, cause it's bound to different host via method above.
|
|
326
|
+
_bindingRunEvalInt(expression, repeatBindingItems, event, context) {
|
|
327
|
+
if (repeatBindingItems) {
|
|
328
|
+
let n = 0;
|
|
329
|
+
let set = new Set();
|
|
330
|
+
for (let b of repeatBindingItems) {
|
|
331
|
+
if (!set.has(b.name)) {
|
|
332
|
+
expression = 'let ' + b.name + ' = ___repeatBindingItems[' + n + '].item;' + expression;
|
|
333
|
+
set.add(b.name);
|
|
334
|
+
}
|
|
335
|
+
n++;
|
|
336
|
+
}
|
|
337
|
+
if (event) {
|
|
338
|
+
expression = 'let event = ___event;' + expression;
|
|
339
|
+
}
|
|
340
|
+
if (context) {
|
|
341
|
+
for (let i in context) {
|
|
342
|
+
expression = 'let ' + i + ' = ___context["' + i + '"];' + expression;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
//@ts-ignore
|
|
346
|
+
var ___repeatBindingItems = repeatBindingItems;
|
|
347
|
+
//@ts-ignore
|
|
348
|
+
var ___event = event;
|
|
349
|
+
//@ts-ignore
|
|
350
|
+
var ___context = context;
|
|
351
|
+
let value = eval(expression);
|
|
352
|
+
return value;
|
|
353
|
+
}
|
|
354
|
+
if (context) {
|
|
355
|
+
for (let i in context) {
|
|
356
|
+
expression = 'let ' + i + ' = ___context["' + i + '"];' + expression;
|
|
357
|
+
}
|
|
358
|
+
//@ts-ignore
|
|
359
|
+
var ___context = context;
|
|
360
|
+
let value = eval(expression);
|
|
361
|
+
return value;
|
|
362
|
+
}
|
|
363
|
+
let value = eval(expression);
|
|
364
|
+
return value;
|
|
365
|
+
}
|
|
366
|
+
_bindingConditional(node, expression, repeatBindingItems, elementsCache, host, context) {
|
|
367
|
+
try {
|
|
368
|
+
const value = this._bindingRunEval(expression, repeatBindingItems, null, host, context);
|
|
369
|
+
if (!value && elementsCache.length > 0) {
|
|
370
|
+
for (let c of elementsCache) {
|
|
371
|
+
c.parentNode.removeChild(c);
|
|
372
|
+
}
|
|
373
|
+
elementsCache.length = 0;
|
|
374
|
+
}
|
|
375
|
+
if (value && elementsCache.length === 0) {
|
|
376
|
+
let nd = node.content.cloneNode(true);
|
|
377
|
+
elementsCache.push(...nd.children);
|
|
378
|
+
this._bindingsInternalParse(nd, repeatBindingItems, true, host, context);
|
|
379
|
+
node.parentNode.insertBefore(nd, node);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
catch (error) {
|
|
383
|
+
if (!this._noWarningOnBindingErrors)
|
|
384
|
+
console.warn(error.message, 'Failed to bind Conditional to expression "' + expression + '"', this, node);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
_bindingRepeat(node, bindingProperty, bindingIndexName, expression, callback, repeatBindingItems, elementsCache, host, context) {
|
|
388
|
+
try {
|
|
389
|
+
const values = this._bindingRunEval(expression, repeatBindingItems, null, host, context);
|
|
390
|
+
if (callback) {
|
|
391
|
+
if (callback.startsWith('[[') && callback.endsWith(']]'))
|
|
392
|
+
callback = callback.substring(2, callback.length - 2);
|
|
393
|
+
else
|
|
394
|
+
callback = "this." + callback;
|
|
395
|
+
}
|
|
396
|
+
for (let c of elementsCache) {
|
|
397
|
+
if (c.parentNode) {
|
|
398
|
+
let intRepeatBindingItems = [];
|
|
399
|
+
intRepeatBindingItems.push({ name: 'nodes', item: [c] });
|
|
400
|
+
intRepeatBindingItems.push({ name: 'callbackType', item: 'remove' });
|
|
401
|
+
this._bindingRunEval(callback, intRepeatBindingItems, null, host, context);
|
|
402
|
+
const bnds = this._repeatBindings.get(c);
|
|
403
|
+
if (bnds?.length) {
|
|
404
|
+
for (const b of bnds) {
|
|
405
|
+
const idx = this._bindings.indexOf(b);
|
|
406
|
+
if (idx >= 0)
|
|
407
|
+
this._bindings.splice(idx, 1);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
c.parentNode.removeChild(c);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
elementsCache.length = 0;
|
|
414
|
+
if (values) {
|
|
415
|
+
if (!this._repeatBindings)
|
|
416
|
+
this._repeatBindings = new WeakMap();
|
|
417
|
+
//todo -> copy values to compare and only generate new controls...
|
|
418
|
+
let i = 0;
|
|
419
|
+
for (let e of values) {
|
|
420
|
+
let intRepeatBindingItems = [];
|
|
421
|
+
if (repeatBindingItems)
|
|
422
|
+
intRepeatBindingItems = repeatBindingItems.slice();
|
|
423
|
+
intRepeatBindingItems.push({ name: bindingProperty, item: e });
|
|
424
|
+
intRepeatBindingItems.push({ name: bindingIndexName, item: i });
|
|
425
|
+
let nd = node.content.cloneNode(true);
|
|
426
|
+
elementsCache.push(...nd.children);
|
|
427
|
+
const bndCount = this._bindings.length;
|
|
428
|
+
this._bindingsInternalParse(nd, intRepeatBindingItems, true, host, context);
|
|
429
|
+
this._repeatBindings.set(nd.children[0], this._bindings.toSpliced(0, bndCount));
|
|
430
|
+
if (callback) {
|
|
431
|
+
intRepeatBindingItems.push({ name: 'nodes', item: [...nd.children] });
|
|
432
|
+
intRepeatBindingItems.push({ name: 'callbackType', item: 'create' });
|
|
433
|
+
let nds = this._bindingRunEval(callback, intRepeatBindingItems, null, host, context);
|
|
434
|
+
if (nds === undefined)
|
|
435
|
+
nds = nd.children;
|
|
436
|
+
if (nds) {
|
|
437
|
+
for (let n of Array.from(nds))
|
|
438
|
+
node.parentNode.insertBefore(n, node);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
node.parentNode.insertBefore(nd, node);
|
|
443
|
+
}
|
|
444
|
+
i++;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
catch (error) {
|
|
449
|
+
if (!this._noWarningOnBindingErrors)
|
|
450
|
+
console.warn(error.message, 'Failed to bind Repeat "' + bindingProperty + '" to expression "' + expression + '"', this, node);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
_bindingSetNodeValue(firstRun, node, attribute, property, expression, repeatBindingItems, removeAttributes, host, context, noNull, onlyWhenChanged) {
|
|
454
|
+
try {
|
|
455
|
+
const value = this._bindingRunEval(expression, repeatBindingItems, null, host, context);
|
|
456
|
+
if (firstRun || node[property] !== value) {
|
|
457
|
+
if (removeAttributes && attribute)
|
|
458
|
+
node.removeAttribute(attribute.name);
|
|
459
|
+
if (property === 'innerHTML' && (value instanceof Element || value instanceof DocumentFragment)) {
|
|
460
|
+
for (let c = node.firstChild; c !== null; c = node.firstChild) {
|
|
461
|
+
node.removeChild(c);
|
|
462
|
+
}
|
|
463
|
+
this._bindingsInternalParse(value, repeatBindingItems, true, host, context);
|
|
464
|
+
node.appendChild(value);
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
if (property[0] === '$') {
|
|
468
|
+
if (!value && noNull)
|
|
469
|
+
node.setAttribute(property.substring(1), '');
|
|
470
|
+
else if (!value)
|
|
471
|
+
node.removeAttribute(property.substring(1));
|
|
472
|
+
else
|
|
473
|
+
node.setAttribute(property.substring(1), value);
|
|
474
|
+
}
|
|
475
|
+
else if (property[0] === '?') {
|
|
476
|
+
if (!value == true)
|
|
477
|
+
node.setAttribute(property.substring(1), '');
|
|
478
|
+
else
|
|
479
|
+
node.removeAttribute(property.substring(1));
|
|
480
|
+
}
|
|
481
|
+
else if (property == 'class')
|
|
482
|
+
node.setAttribute(property, value);
|
|
483
|
+
else {
|
|
484
|
+
if (property[0] === '.')
|
|
485
|
+
property = property.substring(1);
|
|
486
|
+
if (!value && noNull) {
|
|
487
|
+
if (!onlyWhenChanged || node[property] != value)
|
|
488
|
+
node[property] = '';
|
|
489
|
+
}
|
|
490
|
+
else {
|
|
491
|
+
if (!onlyWhenChanged || node[property] != value)
|
|
492
|
+
node[property] = value;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
catch (error) {
|
|
499
|
+
if (!this._noWarningOnBindingErrors)
|
|
500
|
+
console.warn(error.message, ' - Failed to bind Property "' + property + '" to expression "' + expression + '"', this, node);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
_bindingSetElementCssValue(node, property, expression, repeatBindingItems, host, context) {
|
|
504
|
+
try {
|
|
505
|
+
const value = this._bindingRunEval(expression, repeatBindingItems, null, host, context);
|
|
506
|
+
if (node.style[property] !== value)
|
|
507
|
+
node.style[property] = value;
|
|
508
|
+
}
|
|
509
|
+
catch (error) {
|
|
510
|
+
if (!this._noWarningOnBindingErrors)
|
|
511
|
+
console.warn(error.message, ' - Failed to bind CSS Property "' + property + '" to expression "' + expression + '"', this, node);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
_bindingSetElementClass(node, classname, expression, repeatBindingItems, host, context) {
|
|
515
|
+
try {
|
|
516
|
+
const value = this._bindingRunEval(expression, repeatBindingItems, null, host, context);
|
|
517
|
+
if (value) {
|
|
518
|
+
if (!node.classList.contains(classname))
|
|
519
|
+
node.classList.add(classname);
|
|
520
|
+
}
|
|
521
|
+
else {
|
|
522
|
+
if (node.classList.contains(classname))
|
|
523
|
+
node.classList.remove(classname);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
catch (error) {
|
|
527
|
+
if (!this._noWarningOnBindingErrors)
|
|
528
|
+
console.warn(error.message, 'Failed to bind CSS Class "' + classname + '" to expression "' + expression + '"', this, node);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
_bindingsRefresh(property, onlyWhenChanged) {
|
|
532
|
+
if (this._bindings)
|
|
533
|
+
this._bindings.forEach(x => x[0](false, onlyWhenChanged));
|
|
534
|
+
}
|
|
535
|
+
_bindingsSetValue(obj, path, value, context, repeatBindingItems) {
|
|
536
|
+
if (path === undefined || path === null) {
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
if (path.includes("[")) {
|
|
540
|
+
//support binding like this: {{this.picks?.[this.currentPick]?.ConfirmQuantity::value-changed}}
|
|
541
|
+
let p = path.replaceAll(".[", "[");
|
|
542
|
+
p += "=" + value + ";";
|
|
543
|
+
p = "try { " + p + " } catch (err) { console.warn(err); }";
|
|
544
|
+
eval(p);
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
let target = obj;
|
|
548
|
+
if (path.startsWith('this.')) {
|
|
549
|
+
path = path.substr(5);
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
target = context;
|
|
553
|
+
}
|
|
554
|
+
const pathParts = path.split('.');
|
|
555
|
+
for (let i = 0; i < pathParts.length - 1; i++) {
|
|
556
|
+
if (target != null) {
|
|
557
|
+
let newObj = target[pathParts[i]];
|
|
558
|
+
if (newObj == null) {
|
|
559
|
+
newObj = {};
|
|
560
|
+
target[pathParts[i]] = newObj;
|
|
561
|
+
}
|
|
562
|
+
target = newObj;
|
|
563
|
+
}
|
|
564
|
+
else {
|
|
565
|
+
if (repeatBindingItems) {
|
|
566
|
+
let p = pathParts[i];
|
|
567
|
+
target = repeatBindingItems.find(x => x.name == p).item;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
target[pathParts[pathParts.length - 1]] = value;
|
|
572
|
+
}
|
|
573
|
+
//@ts-ignore
|
|
574
|
+
static _propertiesDictionary;
|
|
575
|
+
_parseAttributesToProperties(noBindings = false) {
|
|
576
|
+
//@ts-ignore
|
|
577
|
+
if (!this.constructor._propertiesDictionary) {
|
|
578
|
+
//@ts-ignore
|
|
579
|
+
this.constructor._propertiesDictionary = new Map();
|
|
580
|
+
//@ts-ignore
|
|
581
|
+
for (let i in this.constructor.properties) {
|
|
582
|
+
//@ts-ignore
|
|
583
|
+
this.constructor._propertiesDictionary.set(i.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`), [i, this.constructor.properties[i]]);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
for (const a of this.attributes) {
|
|
587
|
+
//@ts-ignore
|
|
588
|
+
let pair = this.constructor._propertiesDictionary.get(a.name);
|
|
589
|
+
if (pair) {
|
|
590
|
+
if (pair[1] === Boolean)
|
|
591
|
+
this[pair[0]] = true;
|
|
592
|
+
else if (pair[1] === Object || pair[1] === Array) {
|
|
593
|
+
if (noBindings || !a.value.startsWith("{{") && !a.value.startsWith("[[")) //cause of this Array in Array Json Values are not possible atm.
|
|
594
|
+
this[pair[0]] = JSON.parse(a.value);
|
|
595
|
+
}
|
|
596
|
+
else if (pair[1] === Number)
|
|
597
|
+
this[pair[0]] = parseFloat(a.value);
|
|
598
|
+
else
|
|
599
|
+
this[pair[0]] = a.value;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
async _waitForChildrenReady() {
|
|
604
|
+
await Promise.all(Array.from(this.shadowRoot.querySelectorAll(':not(:defined)'), n => customElements.whenDefined(n.localName)));
|
|
605
|
+
}
|
|
606
|
+
_restoreCachedInititalValues() {
|
|
607
|
+
if (this._initialPropertyCache) {
|
|
608
|
+
for (const e of this._initialPropertyCache.entries()) {
|
|
609
|
+
delete this[e[0]];
|
|
610
|
+
this[e[0]] = e[1];
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
this._initialPropertyCache = undefined;
|
|
614
|
+
}
|
|
615
|
+
_restoreCachedInititalValue(name) {
|
|
616
|
+
if (this._initialPropertyCache) {
|
|
617
|
+
if (this._initialPropertyCache.has(name)) {
|
|
618
|
+
delete this[name];
|
|
619
|
+
this[name] = this._initialPropertyCache.get(name);
|
|
620
|
+
this._initialPropertyCache.delete(name);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
if (!this._initialPropertyCache.size)
|
|
624
|
+
this._initialPropertyCache = undefined;
|
|
625
|
+
}
|
|
626
|
+
static instanceCreatedCallback;
|
|
627
|
+
_hmrCallback(newClass) {
|
|
628
|
+
let oldIdx = -1;
|
|
629
|
+
//@ts-ignore
|
|
630
|
+
if (this.constructor.style) {
|
|
631
|
+
//@ts-ignore
|
|
632
|
+
oldIdx = this.shadowRoot.adoptedStyleSheets.indexOf(this.constructor.style);
|
|
633
|
+
if (oldIdx >= 0) {
|
|
634
|
+
let newArr = Array.from(this.shadowRoot.adoptedStyleSheets);
|
|
635
|
+
newArr.splice(oldIdx, 1);
|
|
636
|
+
this.shadowRoot.adoptedStyleSheets = newArr;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
if (newClass.style) {
|
|
640
|
+
if (oldIdx >= 0) {
|
|
641
|
+
let newArr = Array.from(this.shadowRoot.adoptedStyleSheets);
|
|
642
|
+
//@ts-ignore
|
|
643
|
+
newArr.splice(oldIdx, 0, newClass.style);
|
|
644
|
+
this.shadowRoot.adoptedStyleSheets = newArr;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
constructor(template, style) {
|
|
649
|
+
super();
|
|
650
|
+
if (BaseCustomWebComponentNoAttachedTemplate.instanceCreatedCallback)
|
|
651
|
+
BaseCustomWebComponentNoAttachedTemplate.instanceCreatedCallback(this);
|
|
652
|
+
if (!this.shadowRoot)
|
|
653
|
+
this.attachShadow({ mode: 'open' });
|
|
654
|
+
if (template) {
|
|
655
|
+
//@ts-ignore
|
|
656
|
+
this._rootDocumentFragment = template.content.cloneNode(true);
|
|
657
|
+
}
|
|
658
|
+
//@ts-ignore
|
|
659
|
+
else if (this.constructor.template) {
|
|
660
|
+
//@ts-ignore
|
|
661
|
+
this._rootDocumentFragment = this.constructor.template.content.cloneNode(true);
|
|
662
|
+
}
|
|
663
|
+
//@ts-ignore
|
|
664
|
+
if (this.templateCloned) {
|
|
665
|
+
//@ts-ignore
|
|
666
|
+
this.templateCloned();
|
|
667
|
+
}
|
|
668
|
+
if (style) {
|
|
669
|
+
//@ts-ignore
|
|
670
|
+
if (style instanceof Promise)
|
|
671
|
+
//@ts-ignore
|
|
672
|
+
style.then((s) => this.shadowRoot.adoptedStyleSheets = [s]);
|
|
673
|
+
else
|
|
674
|
+
//@ts-ignore
|
|
675
|
+
this.shadowRoot.adoptedStyleSheets = [style];
|
|
676
|
+
//@ts-ignore
|
|
677
|
+
}
|
|
678
|
+
else if (this.constructor.style) {
|
|
679
|
+
//@ts-ignore
|
|
680
|
+
if (this.constructor.style instanceof CSSStyleSheet) {
|
|
681
|
+
//@ts-ignore
|
|
682
|
+
this.shadowRoot.adoptedStyleSheets = [this.constructor.style];
|
|
683
|
+
//@ts-ignore
|
|
684
|
+
}
|
|
685
|
+
else if (Array.isArray(this.constructor.style)) {
|
|
686
|
+
//@ts-ignore
|
|
687
|
+
this.shadowRoot.adoptedStyleSheets = this.constructor.style;
|
|
688
|
+
//@ts-ignore
|
|
689
|
+
}
|
|
690
|
+
else if (this.constructor.style instanceof Promise)
|
|
691
|
+
//@ts-ignore
|
|
692
|
+
this.constructor.style.then((style) => this.shadowRoot.adoptedStyleSheets = [style]);
|
|
693
|
+
}
|
|
694
|
+
//@ts-ignore
|
|
695
|
+
if (this.constructor.properties) {
|
|
696
|
+
//@ts-ignore
|
|
697
|
+
for (let p in this.constructor.properties) {
|
|
698
|
+
if (this.hasOwnProperty(p))
|
|
699
|
+
this._initialPropertyCache.set(p, this[p]);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
export class BaseCustomWebComponentLazyAppend extends BaseCustomWebComponentNoAttachedTemplate {
|
|
705
|
+
constructor(template, style) {
|
|
706
|
+
super(template, style);
|
|
707
|
+
queueMicrotask(() => {
|
|
708
|
+
if (this._rootDocumentFragment)
|
|
709
|
+
this.shadowRoot.appendChild(this._rootDocumentFragment);
|
|
710
|
+
//@ts-ignore
|
|
711
|
+
if (this.oneTimeSetup && !this.constructor._oneTimeSetup) {
|
|
712
|
+
//@ts-ignore
|
|
713
|
+
this.constructor._oneTimeSetup = true;
|
|
714
|
+
//@ts-ignore
|
|
715
|
+
this.oneTimeSetup();
|
|
716
|
+
}
|
|
717
|
+
//@ts-ignore
|
|
718
|
+
if (this.ready)
|
|
719
|
+
//@ts-ignore
|
|
720
|
+
this.ready();
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
export class BaseCustomWebComponentConstructorAppend extends BaseCustomWebComponentNoAttachedTemplate {
|
|
725
|
+
constructor(template, style) {
|
|
726
|
+
super(template, style);
|
|
727
|
+
queueMicrotask(() => {
|
|
728
|
+
//@ts-ignore
|
|
729
|
+
if (this.oneTimeSetup && !this.constructor._oneTimeSetup) {
|
|
730
|
+
//@ts-ignore
|
|
731
|
+
this.constructor._oneTimeSetup = true;
|
|
732
|
+
//@ts-ignore
|
|
733
|
+
this.oneTimeSetup();
|
|
734
|
+
}
|
|
735
|
+
//@ts-ignore
|
|
736
|
+
if (this.ready)
|
|
737
|
+
//@ts-ignore
|
|
738
|
+
this.ready();
|
|
739
|
+
});
|
|
740
|
+
if (this._rootDocumentFragment)
|
|
741
|
+
this.shadowRoot.appendChild(this._rootDocumentFragment);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
export class BaseCustomWebComponentLazyAppendConnectedReady extends BaseCustomWebComponentNoAttachedTemplate {
|
|
745
|
+
constructor(template, style) {
|
|
746
|
+
super(template, style);
|
|
747
|
+
queueMicrotask(() => {
|
|
748
|
+
if (this._rootDocumentFragment)
|
|
749
|
+
this.shadowRoot.appendChild(this._rootDocumentFragment);
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
_isReady;
|
|
753
|
+
connectedCallback() {
|
|
754
|
+
//@ts-ignore
|
|
755
|
+
if (this.ready && !this._isReady)
|
|
756
|
+
//@ts-ignore
|
|
757
|
+
this.ready();
|
|
758
|
+
this._isReady = true;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
export class BaseCustomWebComponentConnectedReady extends BaseCustomWebComponentNoAttachedTemplate {
|
|
762
|
+
constructor(template, style) {
|
|
763
|
+
super(template, style);
|
|
764
|
+
if (this._rootDocumentFragment)
|
|
765
|
+
this.shadowRoot.appendChild(this._rootDocumentFragment);
|
|
766
|
+
}
|
|
767
|
+
_isReady;
|
|
768
|
+
connectedCallback() {
|
|
769
|
+
//@ts-ignore
|
|
770
|
+
if (this.ready && !this._isReady)
|
|
771
|
+
//@ts-ignore
|
|
772
|
+
this.ready();
|
|
773
|
+
this._isReady = true;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
export class BaseCustomWebComponentConstructorAppendLazyReady extends BaseCustomWebComponentNoAttachedTemplate {
|
|
777
|
+
constructor(template, style) {
|
|
778
|
+
super(template, style);
|
|
779
|
+
if (this._rootDocumentFragment)
|
|
780
|
+
this.shadowRoot.appendChild(this._rootDocumentFragment);
|
|
781
|
+
requestAnimationFrame(() => {
|
|
782
|
+
//@ts-ignore
|
|
783
|
+
if (this.oneTimeSetup && !this.constructor._oneTimeSetup) {
|
|
784
|
+
//@ts-ignore
|
|
785
|
+
this.constructor._oneTimeSetup = true;
|
|
786
|
+
//@ts-ignore
|
|
787
|
+
this.oneTimeSetup();
|
|
788
|
+
}
|
|
789
|
+
//@ts-ignore
|
|
790
|
+
if (this.ready)
|
|
791
|
+
//@ts-ignore
|
|
792
|
+
this.ready();
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
}
|