@lexriver/dome 2.0.1 → 2.0.3
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/out/index.cjs +802 -0
- package/out/index.mjs +1987 -0
- package/out/src/AnimatedArray.d.ts +29 -0
- package/out/src/AnimatedTable.d.mts +2 -1
- package/out/src/AnimatedTable.d.ts +39 -0
- package/out/src/AnimatedTable.mjs +2 -1
- package/out/src/AnimatedText.d.mts +1 -1
- package/out/src/AnimatedText.d.ts +13 -0
- package/out/src/AnimatedText.mjs +1 -1
- package/out/src/Animation.d.ts +4 -0
- package/out/src/Dome.d.ts +9 -0
- package/out/src/Dome.mjs +1 -1
- package/out/src/DomeComponent.d.mts +4 -1
- package/out/src/DomeComponent.d.ts +25 -0
- package/out/src/DomeComponent.mjs +24 -3
- package/out/src/DomeManipulator.d.mts +4 -0
- package/out/src/DomeManipulator.d.ts +52 -0
- package/out/src/DomeManipulator.mjs +24 -13
- package/out/src/DomeRouter.console-test.d.ts +1 -0
- package/out/src/DomeRouter.d.ts +32 -0
- package/out/src/LongestCommonSubsequence.d.ts +15 -0
- package/out/src/concurrent-updates.test.d.mts +1 -0
- package/out/src/concurrent-updates.test.d.ts +1 -0
- package/out/src/concurrent-updates.test.mjs +203 -0
- package/out/src/index.d.ts +11 -0
- package/out/src/temp-test.d.ts +1 -0
- package/package.json +20 -3
- package/out/vitest.config.d.ts +0 -2
- package/out/vitest.config.js +0 -9
- package/src/AnimatedArray.mts +0 -74
- package/src/AnimatedTable.mts +0 -120
- package/src/AnimatedText.mts +0 -30
- package/src/Animation.mts +0 -4
- package/src/Dome.mts +0 -346
- package/src/DomeComponent.mts +0 -63
- package/src/DomeManipulator.mts +0 -380
- package/src/DomeRouter.console-test.mts +0 -52
- package/src/DomeRouter.mts +0 -287
- package/src/LongestCommonSubsequence.mts +0 -201
- package/src/index.mts +0 -12
- package/src/temp-test.mts +0 -23
- package/tsconfig.json +0 -59
- package/vitest.config.ts +0 -10
package/out/index.cjs
ADDED
|
@@ -0,0 +1,802 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
+
|
|
23
|
+
// src/index.mts
|
|
24
|
+
var src_exports = {};
|
|
25
|
+
__export(src_exports, {
|
|
26
|
+
AnimatedArray: () => AnimatedArray,
|
|
27
|
+
AnimatedTable: () => AnimatedTable,
|
|
28
|
+
AnimatedText: () => AnimatedText,
|
|
29
|
+
DomeComponent: () => DomeComponent,
|
|
30
|
+
DomeManipulator: () => DomeManipulator,
|
|
31
|
+
React: () => React,
|
|
32
|
+
h: () => h
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(src_exports);
|
|
35
|
+
__reExport(src_exports, require("@lexriver/async"), module.exports);
|
|
36
|
+
__reExport(src_exports, require("@lexriver/data-types"), module.exports);
|
|
37
|
+
__reExport(src_exports, require("@lexriver/observable"), module.exports);
|
|
38
|
+
__reExport(src_exports, require("@lexriver/type-event"), module.exports);
|
|
39
|
+
|
|
40
|
+
// src/DomeManipulator.mts
|
|
41
|
+
var import_async = require("@lexriver/async");
|
|
42
|
+
var import_data_types = require("@lexriver/data-types");
|
|
43
|
+
var import_observable = require("@lexriver/observable");
|
|
44
|
+
var replacementPromiseByElement = /* @__PURE__ */ new WeakMap();
|
|
45
|
+
var DomeManipulator;
|
|
46
|
+
((DomeManipulator2) => {
|
|
47
|
+
async function hideElementAsync(element, animation) {
|
|
48
|
+
if (!element) throw new Error("hideElementAsync failed, no element");
|
|
49
|
+
if (element.hidden) return;
|
|
50
|
+
if (animation) {
|
|
51
|
+
await addCssClassAsync(element, animation.cssClassName, animation.timeMs);
|
|
52
|
+
}
|
|
53
|
+
element.style.display = "none";
|
|
54
|
+
element.hidden = true;
|
|
55
|
+
}
|
|
56
|
+
DomeManipulator2.hideElementAsync = hideElementAsync;
|
|
57
|
+
async function unhideElementAsync(element, animation) {
|
|
58
|
+
if (!element) throw new Error("unhideElementAsync failed, no element");
|
|
59
|
+
if (!element.hidden) return;
|
|
60
|
+
element.style.display = "";
|
|
61
|
+
element.hidden = false;
|
|
62
|
+
if (animation) {
|
|
63
|
+
await addCssClassAsync(element, animation.cssClassName, animation.timeMs);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
DomeManipulator2.unhideElementAsync = unhideElementAsync;
|
|
67
|
+
async function insertAsFirstChildAsync(elementToInsert, parentElement, animation) {
|
|
68
|
+
parentElement.insertBefore(elementToInsert, parentElement.firstChild);
|
|
69
|
+
if (animation) {
|
|
70
|
+
await addCssClassAsync(elementToInsert, animation.cssClassName, animation.timeMs);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
DomeManipulator2.insertAsFirstChildAsync = insertAsFirstChildAsync;
|
|
74
|
+
async function insertBeforeAsync(elementToInsert, refElement, parentElement, animation) {
|
|
75
|
+
parentElement.insertBefore(elementToInsert, refElement);
|
|
76
|
+
if (animation) {
|
|
77
|
+
await addCssClassAsync(elementToInsert, animation.cssClassName, animation.timeMs);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
DomeManipulator2.insertBeforeAsync = insertBeforeAsync;
|
|
81
|
+
async function insertAfterAsync(elementToInsert, refElement, parentElement, animation) {
|
|
82
|
+
if (refElement) {
|
|
83
|
+
parentElement.insertBefore(elementToInsert, refElement.nextSibling);
|
|
84
|
+
} else {
|
|
85
|
+
parentElement.appendChild(elementToInsert);
|
|
86
|
+
}
|
|
87
|
+
if (animation) {
|
|
88
|
+
await addCssClassAsync(elementToInsert, animation.cssClassName, animation.timeMs);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
DomeManipulator2.insertAfterAsync = insertAfterAsync;
|
|
92
|
+
async function insertByIndexAsync(elementToInsert, index, parentElement, animation) {
|
|
93
|
+
if (index == 0) {
|
|
94
|
+
parentElement.appendChild(elementToInsert);
|
|
95
|
+
if (animation) {
|
|
96
|
+
await addCssClassAsync(elementToInsert, animation.cssClassName, animation.timeMs);
|
|
97
|
+
}
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
await insertAfterAsync(elementToInsert, parentElement.children[index], parentElement, animation);
|
|
101
|
+
}
|
|
102
|
+
DomeManipulator2.insertByIndexAsync = insertByIndexAsync;
|
|
103
|
+
async function replaceAsync(oldElement, newElement, animationHide, animationShow) {
|
|
104
|
+
if (!oldElement.parentNode) {
|
|
105
|
+
console.error("replaceAsync() failed, no parentNode.", "oldElement=", oldElement);
|
|
106
|
+
throw new Error("no parent node for replaceAsync");
|
|
107
|
+
}
|
|
108
|
+
if (animationHide) {
|
|
109
|
+
await addCssClassAsync(oldElement, animationHide.cssClassName, animationHide.timeMs);
|
|
110
|
+
}
|
|
111
|
+
const parent = oldElement.parentNode;
|
|
112
|
+
if (!parent) {
|
|
113
|
+
console.error("replaceAsync() failed, no parent. Probably node was deleted while hide animation.", "oldElement=", oldElement, "type=", typeof oldElement, "parent=", oldElement.parentElement, oldElement.parentNode);
|
|
114
|
+
throw new Error("no parent for replaceAsync()");
|
|
115
|
+
}
|
|
116
|
+
parent.replaceChild(newElement, oldElement);
|
|
117
|
+
if (animationShow) {
|
|
118
|
+
await addCssClassAsync(newElement, animationShow.cssClassName, animationShow.timeMs);
|
|
119
|
+
}
|
|
120
|
+
return newElement;
|
|
121
|
+
}
|
|
122
|
+
DomeManipulator2.replaceAsync = replaceAsync;
|
|
123
|
+
async function removeElementAsync(element, animation) {
|
|
124
|
+
if (animation) {
|
|
125
|
+
await addCssClassAsync(element, animation.cssClassName, animation.timeMs);
|
|
126
|
+
}
|
|
127
|
+
element.remove();
|
|
128
|
+
}
|
|
129
|
+
DomeManipulator2.removeElementAsync = removeElementAsync;
|
|
130
|
+
function forEachChildrenOf(element, action) {
|
|
131
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
132
|
+
action(element.childNodes[i]);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
DomeManipulator2.forEachChildrenOf = forEachChildrenOf;
|
|
136
|
+
async function removeAllChildrenAsync(element, animation) {
|
|
137
|
+
if (!animation) {
|
|
138
|
+
while (element.firstChild) {
|
|
139
|
+
element.firstChild.remove();
|
|
140
|
+
}
|
|
141
|
+
} else {
|
|
142
|
+
forEachChildrenOf(element, (child) => child.nodeType == Node.ELEMENT_NODE && child.classList.add(animation.cssClassName));
|
|
143
|
+
await import_async.Async.waitMsAsync(animation.timeMs);
|
|
144
|
+
Array.from(element.childNodes).forEach((child) => child.remove());
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
DomeManipulator2.removeAllChildrenAsync = removeAllChildrenAsync;
|
|
148
|
+
async function appendChildAsync(containerElement, child, animation) {
|
|
149
|
+
containerElement.appendChild(child);
|
|
150
|
+
if (animation) {
|
|
151
|
+
await addCssClassAsync(child, animation.cssClassName, animation.timeMs);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
DomeManipulator2.appendChildAsync = appendChildAsync;
|
|
155
|
+
async function appendChildrenAsync(containerElement, children, animation) {
|
|
156
|
+
if (import_data_types.DataTypes.isString(children)) {
|
|
157
|
+
containerElement.appendChild(document.createTextNode(children));
|
|
158
|
+
} else if (import_data_types.DataTypes.isArray(children)) {
|
|
159
|
+
await Promise.all(
|
|
160
|
+
children.map((child) => appendChildAsync(containerElement, child, animation))
|
|
161
|
+
);
|
|
162
|
+
} else if (children) {
|
|
163
|
+
await appendChildAsync(containerElement, children, animation);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
DomeManipulator2.appendChildrenAsync = appendChildrenAsync;
|
|
167
|
+
async function replaceAllChildrenAsync(containerElement, childrenToInsert, animationForHide, animationForShow) {
|
|
168
|
+
const previousReplacement = replacementPromiseByElement.get(containerElement);
|
|
169
|
+
const replacement = (previousReplacement != null ? previousReplacement : Promise.resolve()).catch(() => void 0).then(async () => {
|
|
170
|
+
if (containerElement.childNodes.length > 0) {
|
|
171
|
+
await removeAllChildrenAsync(containerElement, animationForHide);
|
|
172
|
+
}
|
|
173
|
+
await appendChildrenAsync(containerElement, childrenToInsert, animationForShow);
|
|
174
|
+
});
|
|
175
|
+
replacementPromiseByElement.set(containerElement, replacement);
|
|
176
|
+
try {
|
|
177
|
+
await replacement;
|
|
178
|
+
} finally {
|
|
179
|
+
if (replacementPromiseByElement.get(containerElement) === replacement) {
|
|
180
|
+
replacementPromiseByElement.delete(containerElement);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
DomeManipulator2.replaceAllChildrenAsync = replaceAllChildrenAsync;
|
|
185
|
+
function isInDom(el) {
|
|
186
|
+
if (!el) return false;
|
|
187
|
+
return document.body.contains(el);
|
|
188
|
+
}
|
|
189
|
+
DomeManipulator2.isInDom = isInDom;
|
|
190
|
+
function isOnScreen(el) {
|
|
191
|
+
if (!el) return false;
|
|
192
|
+
var rect = el.getBoundingClientRect();
|
|
193
|
+
var viewHeight = Math.max(document.documentElement.clientHeight, window.innerHeight);
|
|
194
|
+
return !(rect.bottom < 0 || rect.top - viewHeight >= 0);
|
|
195
|
+
}
|
|
196
|
+
DomeManipulator2.isOnScreen = isOnScreen;
|
|
197
|
+
async function addCssClassAsync(element, cssClassName, removeAfterMs) {
|
|
198
|
+
if (element.nodeType !== Node.ELEMENT_NODE) return;
|
|
199
|
+
element.classList.add(cssClassName);
|
|
200
|
+
if (removeAfterMs && removeAfterMs > 0) {
|
|
201
|
+
await import_async.Async.waitMsAsync(removeAfterMs);
|
|
202
|
+
element.classList.remove(cssClassName);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
DomeManipulator2.addCssClassAsync = addCssClassAsync;
|
|
206
|
+
async function addCssClassesAsync(element, cssClassNames, removeAfterMs) {
|
|
207
|
+
await Promise.all(cssClassNames.map((cssClassName) => addCssClassAsync(element, cssClassName, removeAfterMs)));
|
|
208
|
+
}
|
|
209
|
+
DomeManipulator2.addCssClassesAsync = addCssClassesAsync;
|
|
210
|
+
function removeCssClass(element, cssClassName) {
|
|
211
|
+
element.classList.remove(cssClassName);
|
|
212
|
+
}
|
|
213
|
+
DomeManipulator2.removeCssClass = removeCssClass;
|
|
214
|
+
function removeCssClasses(element, cssClassNames) {
|
|
215
|
+
for (let cssClassName of cssClassNames) {
|
|
216
|
+
element.classList.remove(cssClassName);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
DomeManipulator2.removeCssClasses = removeCssClasses;
|
|
220
|
+
function setCssClasses(element, value) {
|
|
221
|
+
if (!value) return;
|
|
222
|
+
if (import_data_types.DataTypes.isArray(value)) {
|
|
223
|
+
setAttribute(element, "class", value.join(" "));
|
|
224
|
+
} else if (import_data_types.DataTypes.isObjectWithKeys(value)) {
|
|
225
|
+
let classNameArray = [];
|
|
226
|
+
for (let [k, v] of Object.entries(value)) {
|
|
227
|
+
if ((0, import_observable.checkIfObservable)(v)) {
|
|
228
|
+
if (v.get()) {
|
|
229
|
+
classNameArray.push(k);
|
|
230
|
+
}
|
|
231
|
+
} else if (v) {
|
|
232
|
+
classNameArray.push(k);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
setAttribute(element, "class", classNameArray.join(" "));
|
|
236
|
+
} else {
|
|
237
|
+
setAttribute(element, "class", value);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
DomeManipulator2.setCssClasses = setCssClasses;
|
|
241
|
+
function setAttribute(element, name, value) {
|
|
242
|
+
if (value === void 0 || value === null) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (/^xlink[AHRST]/.test(name)) {
|
|
246
|
+
element.setAttributeNS("http://www.w3.org/1999/xlink", name.replace("xlink", "xlink:").toLowerCase(), value);
|
|
247
|
+
} else {
|
|
248
|
+
element.setAttribute(name, value);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
DomeManipulator2.setAttribute = setAttribute;
|
|
252
|
+
function hasFocus(el) {
|
|
253
|
+
return document.activeElement == el;
|
|
254
|
+
}
|
|
255
|
+
DomeManipulator2.hasFocus = hasFocus;
|
|
256
|
+
function scrollIntoView(element, paddingFromTop = 100) {
|
|
257
|
+
if (isOnScreen(element)) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
let expectedPosition = element.getBoundingClientRect().top + window.pageYOffset;
|
|
261
|
+
expectedPosition -= paddingFromTop;
|
|
262
|
+
window.scrollTo({ top: expectedPosition, behavior: "smooth" });
|
|
263
|
+
}
|
|
264
|
+
DomeManipulator2.scrollIntoView = scrollIntoView;
|
|
265
|
+
DomeManipulator2.scrollToTop = () => {
|
|
266
|
+
let position = getCurrentScrollPosition();
|
|
267
|
+
if (position > 0) {
|
|
268
|
+
window.requestAnimationFrame(DomeManipulator2.scrollToTop);
|
|
269
|
+
if (position < 20) {
|
|
270
|
+
window.scrollTo(0, 0);
|
|
271
|
+
} else {
|
|
272
|
+
window.scrollTo(0, position - position / 9);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
function getCurrentScrollPosition() {
|
|
277
|
+
return document.documentElement.scrollTop || document.body.scrollTop;
|
|
278
|
+
}
|
|
279
|
+
DomeManipulator2.getCurrentScrollPosition = getCurrentScrollPosition;
|
|
280
|
+
async function scrollToAsync(p) {
|
|
281
|
+
var _a, _b;
|
|
282
|
+
const msStep = (_a = p.msStep) != null ? _a : 50;
|
|
283
|
+
const maxMsToWait = (_b = p.maxMsToWait) != null ? _b : 5e3;
|
|
284
|
+
let scrollOptions = {};
|
|
285
|
+
if (p.pxFromTop) {
|
|
286
|
+
scrollOptions.top = p.pxFromTop;
|
|
287
|
+
}
|
|
288
|
+
if (p.pxFromLeft) {
|
|
289
|
+
scrollOptions.left = p.pxFromLeft;
|
|
290
|
+
}
|
|
291
|
+
if (p.smooth) {
|
|
292
|
+
scrollOptions.behavior = "smooth";
|
|
293
|
+
}
|
|
294
|
+
try {
|
|
295
|
+
if (p.pxFromLeft || p.pxFromTop) {
|
|
296
|
+
await import_async.Async.waitForFunctionToReturnTrueAsync(() => {
|
|
297
|
+
if (p.pxFromTop) {
|
|
298
|
+
return document.body.scrollHeight >= p.pxFromTop;
|
|
299
|
+
}
|
|
300
|
+
if (p.pxFromLeft) {
|
|
301
|
+
return document.body.scrollWidth >= p.pxFromLeft;
|
|
302
|
+
}
|
|
303
|
+
return false;
|
|
304
|
+
}, msStep, maxMsToWait);
|
|
305
|
+
}
|
|
306
|
+
} catch (error) {
|
|
307
|
+
}
|
|
308
|
+
window.scrollTo(scrollOptions);
|
|
309
|
+
}
|
|
310
|
+
DomeManipulator2.scrollToAsync = scrollToAsync;
|
|
311
|
+
})(DomeManipulator || (DomeManipulator = {}));
|
|
312
|
+
|
|
313
|
+
// src/LongestCommonSubsequence.mts
|
|
314
|
+
var LongestCommonSubsequence;
|
|
315
|
+
((LongestCommonSubsequence2) => {
|
|
316
|
+
function getLongestCommonSubsequence(set1, set2) {
|
|
317
|
+
const lcsMatrix = Array(set2.length + 1).fill(null).map(() => Array(set1.length + 1).fill(null));
|
|
318
|
+
for (let columnIndex2 = 0; columnIndex2 <= set1.length; columnIndex2 += 1) {
|
|
319
|
+
lcsMatrix[0][columnIndex2] = 0;
|
|
320
|
+
}
|
|
321
|
+
for (let rowIndex2 = 0; rowIndex2 <= set2.length; rowIndex2 += 1) {
|
|
322
|
+
lcsMatrix[rowIndex2][0] = 0;
|
|
323
|
+
}
|
|
324
|
+
for (let rowIndex2 = 1; rowIndex2 <= set2.length; rowIndex2 += 1) {
|
|
325
|
+
for (let columnIndex2 = 1; columnIndex2 <= set1.length; columnIndex2 += 1) {
|
|
326
|
+
if (set1[columnIndex2 - 1] === set2[rowIndex2 - 1]) {
|
|
327
|
+
lcsMatrix[rowIndex2][columnIndex2] = lcsMatrix[rowIndex2 - 1][columnIndex2 - 1] + 1;
|
|
328
|
+
} else {
|
|
329
|
+
lcsMatrix[rowIndex2][columnIndex2] = Math.max(
|
|
330
|
+
lcsMatrix[rowIndex2 - 1][columnIndex2],
|
|
331
|
+
lcsMatrix[rowIndex2][columnIndex2 - 1]
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (!lcsMatrix[set2.length][set1.length]) {
|
|
337
|
+
return [""];
|
|
338
|
+
}
|
|
339
|
+
const longestSequence = [];
|
|
340
|
+
let columnIndex = set1.length;
|
|
341
|
+
let rowIndex = set2.length;
|
|
342
|
+
while (columnIndex > 0 || rowIndex > 0) {
|
|
343
|
+
if (set1[columnIndex - 1] === set2[rowIndex - 1]) {
|
|
344
|
+
longestSequence.unshift(set1[columnIndex - 1]);
|
|
345
|
+
columnIndex -= 1;
|
|
346
|
+
rowIndex -= 1;
|
|
347
|
+
} else if (lcsMatrix[rowIndex][columnIndex] === lcsMatrix[rowIndex][columnIndex - 1]) {
|
|
348
|
+
columnIndex -= 1;
|
|
349
|
+
} else {
|
|
350
|
+
rowIndex -= 1;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return longestSequence;
|
|
354
|
+
}
|
|
355
|
+
LongestCommonSubsequence2.getLongestCommonSubsequence = getLongestCommonSubsequence;
|
|
356
|
+
function getPatch({ oldArray, newArray, onRemove, onAdd }) {
|
|
357
|
+
const lcsArray = getLongestCommonSubsequence(oldArray, newArray);
|
|
358
|
+
let countOfOperations = 0;
|
|
359
|
+
let lcsIndex = 0;
|
|
360
|
+
for (let oldIndex = 0; oldIndex < oldArray.length; oldIndex++) {
|
|
361
|
+
let oldItem = oldArray[oldIndex];
|
|
362
|
+
let oldItemInLcs = lcsArray[lcsIndex] == oldItem;
|
|
363
|
+
if (oldItemInLcs) {
|
|
364
|
+
lcsIndex++;
|
|
365
|
+
} else {
|
|
366
|
+
onRemove(oldIndex - countOfOperations, oldItem);
|
|
367
|
+
countOfOperations++;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
lcsIndex = 0;
|
|
371
|
+
for (let newIndex = 0; newIndex < newArray.length; newIndex++) {
|
|
372
|
+
let newItem = newArray[newIndex];
|
|
373
|
+
let newItemInLcs = lcsArray[lcsIndex] == newItem;
|
|
374
|
+
if (newItemInLcs) {
|
|
375
|
+
lcsIndex++;
|
|
376
|
+
} else {
|
|
377
|
+
onAdd(newIndex, newItem);
|
|
378
|
+
countOfOperations++;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return countOfOperations;
|
|
382
|
+
}
|
|
383
|
+
LongestCommonSubsequence2.getPatch = getPatch;
|
|
384
|
+
function getPatchOrdered({ oldArray, newArray, onRemove, onAdd }) {
|
|
385
|
+
const lcsArray = getLongestCommonSubsequence(oldArray, newArray);
|
|
386
|
+
let lcsIndexForOld = 0;
|
|
387
|
+
let lcsIndexForNew = 0;
|
|
388
|
+
let oldIndex = 0;
|
|
389
|
+
let newIndex = 0;
|
|
390
|
+
let countOfRemoveOperations = 0;
|
|
391
|
+
let countOfAddOperations = 0;
|
|
392
|
+
let indexForOperation = 0;
|
|
393
|
+
while (oldIndex < oldArray.length || newIndex < newArray.length) {
|
|
394
|
+
while (oldIndex < oldArray.length) {
|
|
395
|
+
let oldItem = oldArray[oldIndex];
|
|
396
|
+
let oldItemInLcs = lcsArray[lcsIndexForOld] == oldItem;
|
|
397
|
+
if (oldItemInLcs) {
|
|
398
|
+
lcsIndexForOld++;
|
|
399
|
+
oldIndex++;
|
|
400
|
+
break;
|
|
401
|
+
} else {
|
|
402
|
+
onRemove(indexForOperation, oldItem);
|
|
403
|
+
countOfRemoveOperations++;
|
|
404
|
+
oldIndex++;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
while (newIndex < newArray.length) {
|
|
408
|
+
let newItem = newArray[newIndex];
|
|
409
|
+
let newItemInLcs = lcsArray[lcsIndexForNew] == newItem;
|
|
410
|
+
if (newItemInLcs) {
|
|
411
|
+
lcsIndexForNew++;
|
|
412
|
+
indexForOperation++;
|
|
413
|
+
newIndex++;
|
|
414
|
+
break;
|
|
415
|
+
} else {
|
|
416
|
+
onAdd(indexForOperation, newItem);
|
|
417
|
+
indexForOperation++;
|
|
418
|
+
countOfAddOperations++;
|
|
419
|
+
newIndex++;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return countOfAddOperations + countOfRemoveOperations;
|
|
424
|
+
}
|
|
425
|
+
LongestCommonSubsequence2.getPatchOrdered = getPatchOrdered;
|
|
426
|
+
})(LongestCommonSubsequence || (LongestCommonSubsequence = {}));
|
|
427
|
+
|
|
428
|
+
// src/AnimatedArray.mts
|
|
429
|
+
var AnimatedArray = class {
|
|
430
|
+
constructor(params) {
|
|
431
|
+
this.params = params;
|
|
432
|
+
__publicField(this, "arrayOfKeyToElement", []);
|
|
433
|
+
if (params.array && params.parentElement) {
|
|
434
|
+
this.update(params.array);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
get size() {
|
|
438
|
+
return this.arrayOfKeyToElement.length;
|
|
439
|
+
}
|
|
440
|
+
update(array, parentElement) {
|
|
441
|
+
parentElement = parentElement || this.params.parentElement;
|
|
442
|
+
if (!parentElement) {
|
|
443
|
+
console.warn("AnimatedArray unable to update, no parentElement");
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
if (array.length == 0 && this.params.emptyList) {
|
|
447
|
+
DomeManipulator.replaceAllChildrenAsync(parentElement, this.params.emptyList);
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
if (array.length > 0 && this.params.emptyList) {
|
|
451
|
+
DomeManipulator.removeElementAsync(this.params.emptyList, this.params.animationHide);
|
|
452
|
+
}
|
|
453
|
+
let newArrayOfKeys = array.map((item) => this.params.getKey(item));
|
|
454
|
+
let oldArrayOfKeys = this.arrayOfKeyToElement.map((x) => x.key);
|
|
455
|
+
LongestCommonSubsequence.getPatchOrdered({
|
|
456
|
+
oldArray: oldArrayOfKeys,
|
|
457
|
+
newArray: newArrayOfKeys,
|
|
458
|
+
onAdd: (index, key) => {
|
|
459
|
+
if (!parentElement) throw new Error("no parent element");
|
|
460
|
+
let itemIndex = newArrayOfKeys.indexOf(key);
|
|
461
|
+
if (itemIndex == -1) throw new Error("no itemIndex");
|
|
462
|
+
let item = array[itemIndex];
|
|
463
|
+
let element = this.params.getHtmlElement(item);
|
|
464
|
+
this.arrayOfKeyToElement.splice(index, 0, { key, element });
|
|
465
|
+
DomeManipulator.insertByIndexAsync(element, index, parentElement, this.params.animationShow);
|
|
466
|
+
},
|
|
467
|
+
onRemove: (index, key) => {
|
|
468
|
+
DomeManipulator.removeElementAsync(this.arrayOfKeyToElement[index].element, this.params.animationHide);
|
|
469
|
+
this.arrayOfKeyToElement.splice(index, 1);
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
// src/DomeComponent.mts
|
|
476
|
+
var import_ts_debounce = require("ts-debounce");
|
|
477
|
+
var DomeComponent = class {
|
|
478
|
+
constructor(attrs, children) {
|
|
479
|
+
this.attrs = attrs;
|
|
480
|
+
this.children = children;
|
|
481
|
+
__publicField(this, "rootElement");
|
|
482
|
+
__publicField(this, "updateInProgress", false);
|
|
483
|
+
__publicField(this, "updateRequested", false);
|
|
484
|
+
__publicField(this, "scheduleUpdate", (0, import_ts_debounce.debounce)(() => this.runScheduledUpdateAsync(), 5));
|
|
485
|
+
}
|
|
486
|
+
//abstract render(attrs:Attrs, children:any):HTMLElement
|
|
487
|
+
init() {
|
|
488
|
+
}
|
|
489
|
+
afterRender() {
|
|
490
|
+
}
|
|
491
|
+
// protected onMount(){
|
|
492
|
+
// }
|
|
493
|
+
async updateAsync() {
|
|
494
|
+
if (!this.rootElement) {
|
|
495
|
+
console.error("DomeComponent: unable to update, no rootElement", "this=", this);
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
if (!this.rootElement.parentNode) {
|
|
499
|
+
console.error("DomeComponent: unable to update, no parent for rootElement, not mounted?", "this=", this);
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
const newEl = this.render();
|
|
503
|
+
await DomeManipulator.replaceAsync(this.rootElement, newEl, this.attrs.onHideAnimation, this.attrs.onShowAnimation);
|
|
504
|
+
this.rootElement = newEl;
|
|
505
|
+
this.afterUpdate();
|
|
506
|
+
}
|
|
507
|
+
async runScheduledUpdateAsync() {
|
|
508
|
+
if (this.updateInProgress) {
|
|
509
|
+
this.updateRequested = true;
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
this.updateInProgress = true;
|
|
513
|
+
try {
|
|
514
|
+
do {
|
|
515
|
+
this.updateRequested = false;
|
|
516
|
+
try {
|
|
517
|
+
await this.updateAsync();
|
|
518
|
+
} catch (error) {
|
|
519
|
+
console.error("DomeComponent: scheduled update failed", error);
|
|
520
|
+
}
|
|
521
|
+
} while (this.updateRequested);
|
|
522
|
+
} finally {
|
|
523
|
+
this.updateInProgress = false;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
afterUpdate() {
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
DomeComponent.prototype["__DomeComponent"] = true;
|
|
530
|
+
|
|
531
|
+
// src/AnimatedTable.mts
|
|
532
|
+
var AnimatedTable = class extends DomeComponent {
|
|
533
|
+
constructor() {
|
|
534
|
+
super(...arguments);
|
|
535
|
+
// rootElement
|
|
536
|
+
// table
|
|
537
|
+
// thead
|
|
538
|
+
// tbody
|
|
539
|
+
// tfooter
|
|
540
|
+
// emptyList
|
|
541
|
+
__publicField(this, "refRoot", this.attrs.rootElement || document.createElement("div"));
|
|
542
|
+
__publicField(this, "refTable", this.attrs.tableElement || document.createElement("table"));
|
|
543
|
+
__publicField(this, "refTableHead", this.attrs.renderTableHead ? this.attrs.renderTableHead(this.attrs.itemsO.get()) : document.createElement("thead"));
|
|
544
|
+
__publicField(this, "refTableBody", this.attrs.tableBody || document.createElement("tbody"));
|
|
545
|
+
__publicField(this, "refTableFooter", this.attrs.renderTableFooter ? this.attrs.renderTableFooter(this.attrs.itemsO.get()) : document.createElement("tfoot"));
|
|
546
|
+
__publicField(this, "refEmptyList", this.attrs.renderEmptyList ? this.attrs.renderEmptyList() : document.createElement("div"));
|
|
547
|
+
__publicField(this, "refLoading", this.attrs.renderLoading ? this.attrs.renderLoading() : document.createElement("div"));
|
|
548
|
+
__publicField(this, "animatedArray", new AnimatedArray({
|
|
549
|
+
animationHide: this.attrs.animationHideRow,
|
|
550
|
+
animationShow: this.attrs.animationShowRow,
|
|
551
|
+
array: [],
|
|
552
|
+
getKey: this.attrs.getKey,
|
|
553
|
+
getHtmlElement: this.attrs.renderTableRow
|
|
554
|
+
}));
|
|
555
|
+
}
|
|
556
|
+
render() {
|
|
557
|
+
this.refRoot.appendChild(this.refTable);
|
|
558
|
+
this.refRoot.appendChild(this.refEmptyList);
|
|
559
|
+
this.refRoot.appendChild(this.refLoading);
|
|
560
|
+
if (this.refTableHead) this.refTable.appendChild(this.refTableHead);
|
|
561
|
+
if (this.refTableBody) this.refTable.appendChild(this.refTableBody);
|
|
562
|
+
if (this.refTableFooter) this.refTable.appendChild(this.refTableFooter);
|
|
563
|
+
console.log("AnimatedTable render()", "refRoot=", this.refRoot);
|
|
564
|
+
return this.refRoot;
|
|
565
|
+
}
|
|
566
|
+
afterRender() {
|
|
567
|
+
this.updateAsync();
|
|
568
|
+
}
|
|
569
|
+
async updateAsync() {
|
|
570
|
+
try {
|
|
571
|
+
if (this.attrs.renderLoading) {
|
|
572
|
+
this.refLoading = await DomeManipulator.replaceAsync(this.refLoading, this.attrs.renderLoading());
|
|
573
|
+
}
|
|
574
|
+
if (this.attrs.isLoadingO && this.attrs.isLoadingO.get()) {
|
|
575
|
+
await DomeManipulator.unhideElementAsync(this.refLoading, this.attrs.animationShowLoading);
|
|
576
|
+
} else {
|
|
577
|
+
await DomeManipulator.hideElementAsync(this.refLoading, this.attrs.animationHideLoading);
|
|
578
|
+
}
|
|
579
|
+
const items = this.attrs.itemsO.get();
|
|
580
|
+
const currentCount = items.length;
|
|
581
|
+
if (currentCount == 0) {
|
|
582
|
+
await DomeManipulator.hideElementAsync(this.refTable, this.attrs.animationHideTable);
|
|
583
|
+
if (this.attrs.renderEmptyList) {
|
|
584
|
+
this.refEmptyList = await DomeManipulator.replaceAsync(this.refEmptyList, this.attrs.renderEmptyList());
|
|
585
|
+
}
|
|
586
|
+
await DomeManipulator.unhideElementAsync(this.refEmptyList, this.attrs.animationShowEmptyList);
|
|
587
|
+
} else {
|
|
588
|
+
await DomeManipulator.hideElementAsync(this.refEmptyList, this.attrs.animationHideEmptyList);
|
|
589
|
+
if (this.attrs.renderTableHead) {
|
|
590
|
+
this.refTableHead = await DomeManipulator.replaceAsync(this.refTableHead, this.attrs.renderTableHead(items));
|
|
591
|
+
}
|
|
592
|
+
if (this.attrs.renderTableFooter) {
|
|
593
|
+
this.refTableFooter = await DomeManipulator.replaceAsync(this.refTableFooter, this.attrs.renderTableFooter(items));
|
|
594
|
+
}
|
|
595
|
+
await DomeManipulator.unhideElementAsync(this.refTable, this.attrs.animationShowTable);
|
|
596
|
+
this.animatedArray.update(items, this.refTableBody);
|
|
597
|
+
}
|
|
598
|
+
} catch (x) {
|
|
599
|
+
console.error("AnimatedTable update failed", x);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
// src/AnimatedText.mts
|
|
605
|
+
var AnimatedText = class extends DomeComponent {
|
|
606
|
+
render() {
|
|
607
|
+
const result = document.createElement(this.attrs.tag || "span");
|
|
608
|
+
if (this.attrs.class) {
|
|
609
|
+
DomeManipulator.setCssClasses(result, this.attrs.class);
|
|
610
|
+
}
|
|
611
|
+
result.append(this.attrs.textO.get());
|
|
612
|
+
return result;
|
|
613
|
+
}
|
|
614
|
+
async updateAsync() {
|
|
615
|
+
if (!this.rootElement) return;
|
|
616
|
+
try {
|
|
617
|
+
this.rootElement = await DomeManipulator.replaceAsync(this.rootElement, this.render(), this.attrs.onHideAnimation, this.attrs.onShowAnimation);
|
|
618
|
+
} catch (x) {
|
|
619
|
+
console.error("AnimatedText update failed", x);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
// src/Dome.mts
|
|
625
|
+
var import_svg_tag_names = require("svg-tag-names");
|
|
626
|
+
var import_data_types2 = require("@lexriver/data-types");
|
|
627
|
+
var import_observable2 = require("@lexriver/observable");
|
|
628
|
+
function flattenArray(arr, res = []) {
|
|
629
|
+
var i = 0, cur;
|
|
630
|
+
var len = arr.length;
|
|
631
|
+
for (; i < len; i++) {
|
|
632
|
+
cur = arr[i];
|
|
633
|
+
Array.isArray(cur) ? flattenArray(cur, res) : res.push(cur);
|
|
634
|
+
}
|
|
635
|
+
return res;
|
|
636
|
+
}
|
|
637
|
+
function checkIfNonDimensionalCssName(name) {
|
|
638
|
+
const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i;
|
|
639
|
+
return IS_NON_DIMENSIONAL.test(name);
|
|
640
|
+
}
|
|
641
|
+
var excludeSvgTags = [
|
|
642
|
+
"a",
|
|
643
|
+
"audio",
|
|
644
|
+
"canvas",
|
|
645
|
+
"iframe",
|
|
646
|
+
"script",
|
|
647
|
+
"video"
|
|
648
|
+
];
|
|
649
|
+
var svgTags = import_svg_tag_names.svgTagNames.filter((name) => !excludeSvgTags.includes(name));
|
|
650
|
+
var isSVG = (tagName) => svgTags.includes(tagName);
|
|
651
|
+
var setCSSProps = (el, style) => {
|
|
652
|
+
if (import_data_types2.DataTypes.isString(style)) {
|
|
653
|
+
el.style = style;
|
|
654
|
+
} else if (import_data_types2.DataTypes.isObjectWithKeys(style)) {
|
|
655
|
+
Object.keys(style).forEach((name) => {
|
|
656
|
+
let value = style[name];
|
|
657
|
+
if (typeof value === "number" && !checkIfNonDimensionalCssName(name)) {
|
|
658
|
+
value = `${value}px`;
|
|
659
|
+
}
|
|
660
|
+
el.style[name] = value;
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
var createElement = (tagName) => {
|
|
665
|
+
if (isSVG(tagName)) {
|
|
666
|
+
return document.createElementNS("http://www.w3.org/2000/svg", tagName);
|
|
667
|
+
}
|
|
668
|
+
if (tagName === DocumentFragment) {
|
|
669
|
+
return document.createDocumentFragment();
|
|
670
|
+
}
|
|
671
|
+
return document.createElement(tagName);
|
|
672
|
+
};
|
|
673
|
+
var build = (tagName, attrs, children) => {
|
|
674
|
+
if (!tagName) {
|
|
675
|
+
console.trace();
|
|
676
|
+
throw new Error("tagName=" + tagName);
|
|
677
|
+
}
|
|
678
|
+
if (tagName == DocumentFragment) {
|
|
679
|
+
const el = createElement(tagName);
|
|
680
|
+
el.appendChild(children);
|
|
681
|
+
return el;
|
|
682
|
+
}
|
|
683
|
+
if (tagName.prototype && tagName.prototype["__DomeComponent"]) {
|
|
684
|
+
try {
|
|
685
|
+
const instance = new tagName(attrs, children);
|
|
686
|
+
if (instance["render"] && import_data_types2.DataTypes.isFunction(instance["render"])) {
|
|
687
|
+
if (attrs.ref && import_data_types2.DataTypes.isFunction(attrs.ref)) {
|
|
688
|
+
attrs.ref(instance);
|
|
689
|
+
}
|
|
690
|
+
instance["init"]();
|
|
691
|
+
instance.rootElement = instance["render"]();
|
|
692
|
+
for (let attribute of Object.values(attrs)) {
|
|
693
|
+
if ((0, import_observable2.checkIfObservable)(attribute)) {
|
|
694
|
+
attribute.eventOnChange.subscribe(() => {
|
|
695
|
+
instance.scheduleUpdate();
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
instance["afterRender"]();
|
|
700
|
+
return instance.rootElement;
|
|
701
|
+
}
|
|
702
|
+
} catch (error) {
|
|
703
|
+
console.error("error while creating DomeComponent class", error);
|
|
704
|
+
}
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
if (import_data_types2.DataTypes.isFunction(tagName)) {
|
|
708
|
+
return tagName(attrs, children);
|
|
709
|
+
} else if (import_data_types2.DataTypes.isString(tagName)) {
|
|
710
|
+
const el = createElement(tagName);
|
|
711
|
+
Object.keys(attrs).forEach((name) => {
|
|
712
|
+
const value = attrs[name];
|
|
713
|
+
if (name === "class" || name === "className" || name === "cssClasses") {
|
|
714
|
+
assignDynamicCssClasses(name, value, el);
|
|
715
|
+
} else if (name === "style") {
|
|
716
|
+
setCSSProps(el, value);
|
|
717
|
+
} else if (["disabled", "autocomplete", "selected", "checked"].indexOf(name) >= 0) {
|
|
718
|
+
if (attrs[name]) {
|
|
719
|
+
DomeManipulator.setAttribute(el, name, name);
|
|
720
|
+
}
|
|
721
|
+
} else if (name === "onCreate" || name === "ref") {
|
|
722
|
+
if (import_data_types2.DataTypes.isFunction(value) == false) throw new Error(`Please provide function <${tagName} ${name}={ref => myRef=ref} />`);
|
|
723
|
+
value(el);
|
|
724
|
+
} else if (name == "visibleIf") {
|
|
725
|
+
if ((0, import_observable2.checkIfObservable)(value) == false) {
|
|
726
|
+
console.error("value=", value);
|
|
727
|
+
throw new Error("Please provide Observable<boolean> as argument for visibleIf");
|
|
728
|
+
}
|
|
729
|
+
let obs = value;
|
|
730
|
+
obs.eventOnChange.subscribe((isVisible) => {
|
|
731
|
+
if (isVisible) {
|
|
732
|
+
DomeManipulator.unhideElementAsync(el);
|
|
733
|
+
} else {
|
|
734
|
+
DomeManipulator.hideElementAsync(el);
|
|
735
|
+
}
|
|
736
|
+
});
|
|
737
|
+
setTimeout(() => {
|
|
738
|
+
obs.eventOnChange.triggerAsync(obs.get());
|
|
739
|
+
}, 1);
|
|
740
|
+
} else if (name.indexOf("on") === 0 && value) {
|
|
741
|
+
const eventName = name.slice(2).toLowerCase();
|
|
742
|
+
if (import_data_types2.DataTypes.isFunction(value) == false) {
|
|
743
|
+
console.error("unable to subscribe for event", eventName, "listener is not a function", "element=", el, "listener=", value);
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
el.addEventListener(eventName, value);
|
|
747
|
+
} else if (name === "innerHtml") {
|
|
748
|
+
el.innerHTML = value;
|
|
749
|
+
} else if (name !== "key" && value !== false) {
|
|
750
|
+
DomeManipulator.setAttribute(el, name, value === true ? "" : value);
|
|
751
|
+
}
|
|
752
|
+
});
|
|
753
|
+
if (!attrs.innerHtml) {
|
|
754
|
+
el.appendChild(children);
|
|
755
|
+
}
|
|
756
|
+
return el;
|
|
757
|
+
} else throw new Error("not implemented");
|
|
758
|
+
};
|
|
759
|
+
function assignDynamicCssClasses(name, value, element) {
|
|
760
|
+
if (import_data_types2.DataTypes.isObjectWithKeys(value) == false) {
|
|
761
|
+
DomeManipulator.setCssClasses(element, value);
|
|
762
|
+
return;
|
|
763
|
+
}
|
|
764
|
+
let resultArray = [];
|
|
765
|
+
for (let [k, v] of Object.entries(value)) {
|
|
766
|
+
if (v === void 0) {
|
|
767
|
+
} else if (import_data_types2.DataTypes.isBoolean(v)) {
|
|
768
|
+
if (v) {
|
|
769
|
+
resultArray.push(k);
|
|
770
|
+
}
|
|
771
|
+
} else if ((0, import_observable2.checkIfObservable)(v)) {
|
|
772
|
+
let o = v;
|
|
773
|
+
o.eventOnChange.subscribe((showThiCssClass) => {
|
|
774
|
+
if (!DomeManipulator.isInDom(element)) return { unsubscribe: true };
|
|
775
|
+
DomeManipulator.setCssClasses(element, value);
|
|
776
|
+
});
|
|
777
|
+
if (o.get()) {
|
|
778
|
+
resultArray.push(k);
|
|
779
|
+
}
|
|
780
|
+
} else {
|
|
781
|
+
console.error(`Please provide classNames as a keys and boolean or Observable<boolean> for values., ex: {class1:true, class2:myVarO}`, "name=", name, "value=", value, "typeof value =", typeof value);
|
|
782
|
+
throw new Error("Wrong value for `class` attribute");
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
DomeManipulator.setCssClasses(element, resultArray);
|
|
786
|
+
}
|
|
787
|
+
function h(tagName, attrs, ...childrenArgs) {
|
|
788
|
+
const children = document.createDocumentFragment();
|
|
789
|
+
flattenArray(childrenArgs).forEach((child) => {
|
|
790
|
+
if (child instanceof Node) {
|
|
791
|
+
children.appendChild(child);
|
|
792
|
+
} else if (typeof child !== "boolean" && typeof child !== "undefined" && child !== null) {
|
|
793
|
+
children.appendChild(document.createTextNode(child));
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
return build(tagName, attrs || {}, children);
|
|
797
|
+
}
|
|
798
|
+
var React = {
|
|
799
|
+
createElement: h,
|
|
800
|
+
Fragment: typeof DocumentFragment === "function" ? DocumentFragment : () => {
|
|
801
|
+
}
|
|
802
|
+
};
|