@schukai/monster 3.111.0 → 3.112.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/package.json +1 -1
  3. package/source/components/content/camera.mjs +339 -329
  4. package/source/components/content/stylesheet/camera-capture.mjs +13 -6
  5. package/source/components/datatable/status.mjs +175 -177
  6. package/source/components/form/reload.mjs +1 -2
  7. package/source/components/form/util/fetch.mjs +5 -2
  8. package/source/components/layout/popper.mjs +1 -1
  9. package/source/components/layout/slider.mjs +1 -1
  10. package/source/components/time/month-calendar.mjs +824 -0
  11. package/source/components/time/style/month-calendar.pcss +100 -0
  12. package/source/components/time/stylesheet/month-calendar.mjs +38 -0
  13. package/source/components/time/timeline/collection.mjs +218 -0
  14. package/source/components/time/timeline/item.mjs +192 -0
  15. package/source/components/time/timeline/segment.mjs +169 -0
  16. package/source/components/time/timeline/style/segment.pcss +18 -0
  17. package/source/components/time/timeline/stylesheet/segment.mjs +38 -0
  18. package/source/components/tree-menu/tree-menu.mjs +36 -20
  19. package/source/data/datasource/server/restapi/data-fetch-error.mjs +3 -3
  20. package/source/data/datasource/server/restapi.mjs +1 -1
  21. package/source/data/transformer.mjs +60 -0
  22. package/source/monster.mjs +4 -0
  23. package/source/text/bracketed-key-value-hash.mjs +187 -187
  24. package/source/types/base.mjs +6 -5
  25. package/source/types/basewithoptions.mjs +4 -1
  26. package/source/types/internal.mjs +1 -1
  27. package/source/types/version.mjs +1 -1
  28. package/test/cases/monster.mjs +1 -1
  29. package/test/web/test.html +2 -2
  30. package/test/web/tests.js +1139 -977
@@ -70,6 +70,12 @@ const controlElementSymbol = Symbol("controlElement");
70
70
  */
71
71
  const openEntryEventHandlerSymbol = Symbol("openEntryEventHandler");
72
72
 
73
+ /**
74
+ * @private
75
+ * @type {symbol}
76
+ */
77
+ const firstRunDoneSymbol = Symbol("firstRunDone");
78
+
73
79
  /**
74
80
  * TreeMenu
75
81
  *
@@ -161,23 +167,16 @@ class TreeMenu extends CustomElement {
161
167
  });
162
168
  }
163
169
 
164
- /**
165
- *
166
- */
167
- [initMethodSymbol]() {
168
- super[initMethodSymbol]();
169
- }
170
-
171
170
  /**
172
171
  * @return {void}
173
172
  */
174
173
  [assembleMethodSymbol]() {
175
174
  super[assembleMethodSymbol]();
176
175
 
177
- initControlReferences.call(this);
178
- initEventHandler.call(this);
179
- initObserver.call(this);
180
176
  queueMicrotask(() => {
177
+ initControlReferences.call(this);
178
+ initEventHandler.call(this);
179
+ initObserver.call(this);
181
180
  copyIconMap.call(this);
182
181
  });
183
182
  }
@@ -230,15 +229,15 @@ class TreeMenu extends CustomElement {
230
229
 
231
230
  currentNode.click();
232
231
 
233
- let intend = parseInt(currentNode.getAttribute(ATTRIBUTE_INTEND));
232
+ let intend = Number.parseInt(currentNode.getAttribute(ATTRIBUTE_INTEND));
234
233
 
235
234
  if (intend > 0) {
236
235
  const refSet = new Set();
237
236
  let ref = currentNode.previousElementSibling;
238
- while (ref && ref.hasAttribute(ATTRIBUTE_INTEND)) {
239
- const i = parseInt(ref.getAttribute(ATTRIBUTE_INTEND));
237
+ while (ref?.hasAttribute(ATTRIBUTE_INTEND)) {
238
+ const i = Number.parseInt(ref.getAttribute(ATTRIBUTE_INTEND));
240
239
 
241
- if (isNaN(i)) {
240
+ if (Number.isNaN(i)) {
242
241
  break;
243
242
  }
244
243
 
@@ -342,10 +341,10 @@ function initEventHandler() {
342
341
  let intend = currentEntry.intend;
343
342
  if (intend > 0) {
344
343
  let ref = container.previousElementSibling;
345
- while (ref && ref.hasAttribute(ATTRIBUTE_INTEND)) {
346
- const i = parseInt(ref.getAttribute(ATTRIBUTE_INTEND));
344
+ while (ref?.hasAttribute(ATTRIBUTE_INTEND)) {
345
+ const i = Number.parseInt(ref.getAttribute(ATTRIBUTE_INTEND));
347
346
 
348
- if (isNaN(i)) {
347
+ if (Number.isNaN(i)) {
349
348
  break;
350
349
  }
351
350
 
@@ -393,10 +392,10 @@ function initEventHandler() {
393
392
  return a >= b;
394
393
  };
395
394
 
396
- while (ref && ref.hasAttribute(ATTRIBUTE_INTEND)) {
395
+ while (ref?.hasAttribute(ATTRIBUTE_INTEND)) {
397
396
  const refIntend = ref.getAttribute(ATTRIBUTE_INTEND);
398
397
 
399
- if (!cmp(parseInt(refIntend), childIntend)) {
398
+ if (!cmp(Number.parseInt(refIntend), childIntend)) {
400
399
  if (refIntend === intend) {
401
400
  break;
402
401
  }
@@ -456,9 +455,26 @@ function importEntries() {
456
455
 
457
456
  const selector = mappingOptions?.["selector"];
458
457
 
458
+ let filteredData;
459
+ if (this[firstRunDoneSymbol] !== true) {
460
+ filteredData = data.filter(
461
+ (entry) =>
462
+ !entry[parentKey] ||
463
+ entry[parentKey] === null ||
464
+ entry[parentKey] === undefined ||
465
+ entry[parentKey] === 0,
466
+ );
467
+ setTimeout(() => {
468
+ this[firstRunDoneSymbol] = true;
469
+ importEntries.call(this);
470
+ }, 0);
471
+ } else {
472
+ filteredData = data;
473
+ }
474
+
459
475
  let nodes;
460
476
  try {
461
- nodes = buildTree(data, selector, id, parentKey, {
477
+ nodes = buildTree(filteredData, selector, id, parentKey, {
462
478
  filter,
463
479
  rootReferences,
464
480
  });
@@ -33,19 +33,19 @@ class DataFetchError extends Error {
33
33
  constructor(message, response) {
34
34
  super(message);
35
35
 
36
- let body = null
36
+ let body = null;
37
37
 
38
38
  if (response instanceof Response) {
39
39
  body = response.text();
40
40
  }
41
41
 
42
- if(!(body instanceof Promise)) {
42
+ if (!(body instanceof Promise)) {
43
43
  body = Promise.resolve(body);
44
44
  }
45
45
 
46
46
  this[internalSymbol] = {
47
47
  response: response,
48
- body : body
48
+ body: body,
49
49
  };
50
50
  }
51
51
 
@@ -245,7 +245,7 @@ function fetchData(init, key, callback) {
245
245
  if (body.length > 100) {
246
246
  body = `${body.substring(0, 97)}...`;
247
247
  }
248
-
248
+
249
249
  throw new DataFetchError(
250
250
  getInternalLocalizationMessage(
251
251
  `i18n{the-response-does-not-contain-a-valid-json::actual=${body}}`,
@@ -33,6 +33,7 @@ import {
33
33
  import { clone } from "../util/clone.mjs";
34
34
  import { Pathfinder } from "./pathfinder.mjs";
35
35
  import { formatTimeAgo } from "../i18n/time-ago.mjs";
36
+ import { UUID } from "../types/uuid.mjs";
36
37
 
37
38
  export { Transformer };
38
39
 
@@ -323,6 +324,14 @@ function transform(value) {
323
324
  validateString(value);
324
325
  return value.trim();
325
326
 
327
+ case "ltrim":
328
+ validateString(value);
329
+ return value.replace(/^\s+/, "");
330
+
331
+ case "rtrim":
332
+ validateString(value);
333
+ return value.replace(/\s+$/, "");
334
+
326
335
  case "rawurlencode":
327
336
  validateString(value);
328
337
  return encodeURIComponent(value)
@@ -367,6 +376,16 @@ function transform(value) {
367
376
  const doc = new DOMParser().parseFromString(value, "text/html");
368
377
  return doc.body.textContent || "";
369
378
 
379
+ case "replace":
380
+ const search = args.shift();
381
+ const replace = args.shift();
382
+
383
+ validateString(search);
384
+ validateString(replace);
385
+ validateString(value);
386
+
387
+ return value.replace(new RegExp(search, "g"), replace);
388
+
370
389
  case "if":
371
390
  case "?":
372
391
  validatePrimitive(value);
@@ -395,6 +414,44 @@ function transform(value) {
395
414
  },
396
415
  );
397
416
 
417
+ case "gt":
418
+ case "greaterthan":
419
+ case "greater-than":
420
+ case ">":
421
+ validatePrimitive(value);
422
+ const compareValue = args.shift();
423
+ validatePrimitive(compareValue);
424
+
425
+ return value > compareValue;
426
+
427
+ case "gte":
428
+ case "greaterthanorequal":
429
+ case "greater-than-or-equal":
430
+ validatePrimitive(value);
431
+ const compareValue3 = args.shift();
432
+ validatePrimitive(compareValue3);
433
+
434
+ return value >= compareValue3;
435
+
436
+ case "lt":
437
+ case "lessthan":
438
+ case "less-than":
439
+ case "<":
440
+ validatePrimitive(value);
441
+ const compareValue2 = args.shift();
442
+ validatePrimitive(compareValue2);
443
+
444
+ return value < compareValue2;
445
+
446
+ case "lte":
447
+ case "lessthanorequal":
448
+ case "less-than-or-equal":
449
+ validatePrimitive(value);
450
+ const compareValue4 = args.shift();
451
+ validatePrimitive(compareValue4);
452
+
453
+ return value <= compareValue4;
454
+
398
455
  case "count":
399
456
  case "length":
400
457
  if (
@@ -444,6 +501,9 @@ function transform(value) {
444
501
  case "uniqid":
445
502
  return new ID().toString();
446
503
 
504
+ case "uuid":
505
+ return new UUID().toString();
506
+
447
507
  case "first-key":
448
508
  case "last-key":
449
509
  case "nth-last-key":
@@ -29,6 +29,10 @@ export * from "./components/layout/details.mjs";
29
29
  export * from "./components/layout/slider.mjs";
30
30
  export * from "./components/content/viewer.mjs";
31
31
  export * from "./components/content/copy.mjs";
32
+ export * from "./components/content/camera.mjs";
33
+ export * from "./components/time/timeline/segment.mjs";
34
+ export * from "./components/time/timeline/item.mjs";
35
+ export * from "./components/time/month-calendar.mjs";
32
36
  export * from "./components/form/message-state-button.mjs";
33
37
  export * from "./components/form/password.mjs";
34
38
  export * from "./components/form/button-bar.mjs";
@@ -12,7 +12,7 @@
12
12
  * SPDX-License-Identifier: AGPL-3.0
13
13
  */
14
14
 
15
- export {parseBracketedKeyValueHash, createBracketedKeyValueHash};
15
+ export { parseBracketedKeyValueHash, createBracketedKeyValueHash };
16
16
 
17
17
  /**
18
18
  * Parses a string containing bracketed key-value pairs and returns an object representing the parsed result.
@@ -51,155 +51,155 @@ export {parseBracketedKeyValueHash, createBracketedKeyValueHash};
51
51
  * @return {Object} - An object representing the parsed result, with keys representing the selectors and values representing the key-value pairs associated with each selector.
52
52
  * - Returns an empty object if there was an error during parsing. */
53
53
  function parseBracketedKeyValueHash(hashString) {
54
- const selectors = {};
55
- //const selectorStack = [];
56
- //const keyValueStack = [];
57
-
58
- const trimmedHashString = hashString.trim();
59
- const cleanedHashString =
60
- trimmedHashString.charAt(0) === "#"
61
- ? trimmedHashString.slice(1)
62
- : trimmedHashString;
63
-
64
- //const selectors = (keyValueStack.length > 0) ? result[selectorStack[selectorStack.length - 1]] : result;
65
- let currentSelector = "";
66
-
67
- function addToResult(key, value) {
68
- if (currentSelector && key) {
69
- if (!selectors[currentSelector]) {
70
- selectors[currentSelector] = {};
71
- }
72
-
73
- selectors[currentSelector][key] = value;
74
- }
75
- }
76
-
77
- let currentKey = "";
78
- let currentValue = "";
79
- let inKey = true;
80
- let inValue = false;
81
- let inQuotedValue = false;
82
- let inSelector = true;
83
- let escaped = false;
84
- let quotedValueStartChar = "";
85
-
86
- for (let i = 0; i < cleanedHashString.length; i++) {
87
- const c = cleanedHashString[i];
88
- const nextChar = cleanedHashString?.[i + 1];
89
-
90
- if (c === "\\" && !escaped) {
91
- escaped = true;
92
- continue;
93
- }
94
-
95
- if (escaped) {
96
- if (inSelector) {
97
- currentSelector += c;
98
- } else if (inKey) {
99
- currentKey += c;
100
- } else if (inValue) {
101
- currentValue += c;
102
- }
103
- escaped = false;
104
- continue;
105
- }
106
-
107
- if (inQuotedValue && quotedValueStartChar !== c) {
108
- if (inSelector) {
109
- currentSelector += c;
110
- } else if (inKey) {
111
- currentKey += c;
112
- } else if (inValue) {
113
- currentValue += c;
114
- }
115
-
116
- continue;
117
- }
118
-
119
- if (c === ";" && inSelector) {
120
- inSelector = true;
121
- currentSelector = "";
122
- continue;
123
- }
124
-
125
- if (inSelector === true && c !== "(") {
126
- currentSelector += c;
127
- continue;
128
- }
129
-
130
- if (c === "(" && inSelector) {
131
- inSelector = false;
132
- inKey = true;
133
-
134
- currentKey = "";
135
- continue;
136
- }
137
-
138
- if (inKey === true && c !== "=") {
139
- currentKey += c;
140
- continue;
141
- }
142
-
143
- if (c === "=" && inKey) {
144
- inKey = false;
145
- inValue = true;
146
-
147
- if (nextChar === '"' || nextChar === "'") {
148
- inQuotedValue = true;
149
- quotedValueStartChar = nextChar;
150
- i++;
151
- continue;
152
- }
153
-
154
- currentValue = "";
155
- continue;
156
- }
157
-
158
- if (inValue === true) {
159
- if (inQuotedValue) {
160
- if (c === quotedValueStartChar) {
161
- inQuotedValue = false;
162
- continue;
163
- }
164
-
165
- currentValue += c;
166
- continue;
167
- }
168
-
169
- if (c === ",") {
170
- inValue = false;
171
- inKey = true;
172
- const decodedCurrentValue = decodeURIComponent(currentValue);
173
- addToResult(currentKey, decodedCurrentValue);
174
- currentKey = "";
175
- currentValue = "";
176
- continue;
177
- }
178
-
179
- if (c === ")") {
180
- inValue = false;
181
- //inKey = true;
182
- inSelector = true;
183
-
184
- const decodedCurrentValue = decodeURIComponent(currentValue);
185
- addToResult(currentKey, decodedCurrentValue);
186
- currentKey = "";
187
- currentValue = "";
188
- currentSelector = "";
189
- continue;
190
- }
191
-
192
- currentValue += c;
193
-
194
- continue;
195
- }
196
- }
197
-
198
- if (inSelector) {
199
- return selectors;
200
- }
201
-
202
- return {};
54
+ const selectors = {};
55
+ //const selectorStack = [];
56
+ //const keyValueStack = [];
57
+
58
+ const trimmedHashString = hashString.trim();
59
+ const cleanedHashString =
60
+ trimmedHashString.charAt(0) === "#"
61
+ ? trimmedHashString.slice(1)
62
+ : trimmedHashString;
63
+
64
+ //const selectors = (keyValueStack.length > 0) ? result[selectorStack[selectorStack.length - 1]] : result;
65
+ let currentSelector = "";
66
+
67
+ function addToResult(key, value) {
68
+ if (currentSelector && key) {
69
+ if (!selectors[currentSelector]) {
70
+ selectors[currentSelector] = {};
71
+ }
72
+
73
+ selectors[currentSelector][key] = value;
74
+ }
75
+ }
76
+
77
+ let currentKey = "";
78
+ let currentValue = "";
79
+ let inKey = true;
80
+ let inValue = false;
81
+ let inQuotedValue = false;
82
+ let inSelector = true;
83
+ let escaped = false;
84
+ let quotedValueStartChar = "";
85
+
86
+ for (let i = 0; i < cleanedHashString.length; i++) {
87
+ const c = cleanedHashString[i];
88
+ const nextChar = cleanedHashString?.[i + 1];
89
+
90
+ if (c === "\\" && !escaped) {
91
+ escaped = true;
92
+ continue;
93
+ }
94
+
95
+ if (escaped) {
96
+ if (inSelector) {
97
+ currentSelector += c;
98
+ } else if (inKey) {
99
+ currentKey += c;
100
+ } else if (inValue) {
101
+ currentValue += c;
102
+ }
103
+ escaped = false;
104
+ continue;
105
+ }
106
+
107
+ if (inQuotedValue && quotedValueStartChar !== c) {
108
+ if (inSelector) {
109
+ currentSelector += c;
110
+ } else if (inKey) {
111
+ currentKey += c;
112
+ } else if (inValue) {
113
+ currentValue += c;
114
+ }
115
+
116
+ continue;
117
+ }
118
+
119
+ if (c === ";" && inSelector) {
120
+ inSelector = true;
121
+ currentSelector = "";
122
+ continue;
123
+ }
124
+
125
+ if (inSelector === true && c !== "(") {
126
+ currentSelector += c;
127
+ continue;
128
+ }
129
+
130
+ if (c === "(" && inSelector) {
131
+ inSelector = false;
132
+ inKey = true;
133
+
134
+ currentKey = "";
135
+ continue;
136
+ }
137
+
138
+ if (inKey === true && c !== "=") {
139
+ currentKey += c;
140
+ continue;
141
+ }
142
+
143
+ if (c === "=" && inKey) {
144
+ inKey = false;
145
+ inValue = true;
146
+
147
+ if (nextChar === '"' || nextChar === "'") {
148
+ inQuotedValue = true;
149
+ quotedValueStartChar = nextChar;
150
+ i++;
151
+ continue;
152
+ }
153
+
154
+ currentValue = "";
155
+ continue;
156
+ }
157
+
158
+ if (inValue === true) {
159
+ if (inQuotedValue) {
160
+ if (c === quotedValueStartChar) {
161
+ inQuotedValue = false;
162
+ continue;
163
+ }
164
+
165
+ currentValue += c;
166
+ continue;
167
+ }
168
+
169
+ if (c === ",") {
170
+ inValue = false;
171
+ inKey = true;
172
+ const decodedCurrentValue = decodeURIComponent(currentValue);
173
+ addToResult(currentKey, decodedCurrentValue);
174
+ currentKey = "";
175
+ currentValue = "";
176
+ continue;
177
+ }
178
+
179
+ if (c === ")") {
180
+ inValue = false;
181
+ //inKey = true;
182
+ inSelector = true;
183
+
184
+ const decodedCurrentValue = decodeURIComponent(currentValue);
185
+ addToResult(currentKey, decodedCurrentValue);
186
+ currentKey = "";
187
+ currentValue = "";
188
+ currentSelector = "";
189
+ continue;
190
+ }
191
+
192
+ currentValue += c;
193
+
194
+ continue;
195
+ }
196
+ }
197
+
198
+ if (inSelector) {
199
+ return selectors;
200
+ }
201
+
202
+ return {};
203
203
  }
204
204
 
205
205
  /**
@@ -211,41 +211,41 @@ function parseBracketedKeyValueHash(hashString) {
211
211
  * @since 3.37.0
212
212
  */
213
213
  function createBracketedKeyValueHash(object, addHashPrefix = true) {
214
- if (!object) {
215
- return addHashPrefix ? "#" : "";
216
- }
217
-
218
- let hashString = "";
219
-
220
- function encodeKeyValue(key, value) {
221
- return encodeURIComponent(key) + "=" + encodeURIComponent(value);
222
- }
223
-
224
- for (const selector in object) {
225
- if (object.hasOwnProperty(selector)) {
226
- const keyValuePairs = object[selector];
227
- let selectorString = selector;
228
- let keyValueString = "";
229
-
230
- for (const key in keyValuePairs) {
231
- if (keyValuePairs.hasOwnProperty(key)) {
232
- const value = keyValuePairs[key];
233
- keyValueString += keyValueString.length === 0 ? "" : ",";
234
- keyValueString += encodeKeyValue(key, value);
235
- }
236
- }
237
-
238
- if (keyValueString.length > 0) {
239
- selectorString += "(" + keyValueString + ")";
240
- hashString += hashString.length === 0 ? "" : ";";
241
- hashString += selectorString;
242
- }
243
- }
244
- }
245
-
246
- if (hashString.length>0 && addHashPrefix) {
247
- hashString = "#" + hashString;
248
- }
249
-
250
- return hashString;
214
+ if (!object) {
215
+ return addHashPrefix ? "#" : "";
216
+ }
217
+
218
+ let hashString = "";
219
+
220
+ function encodeKeyValue(key, value) {
221
+ return encodeURIComponent(key) + "=" + encodeURIComponent(value);
222
+ }
223
+
224
+ for (const selector in object) {
225
+ if (object.hasOwnProperty(selector)) {
226
+ const keyValuePairs = object[selector];
227
+ let selectorString = selector;
228
+ let keyValueString = "";
229
+
230
+ for (const key in keyValuePairs) {
231
+ if (keyValuePairs.hasOwnProperty(key)) {
232
+ const value = keyValuePairs[key];
233
+ keyValueString += keyValueString.length === 0 ? "" : ",";
234
+ keyValueString += encodeKeyValue(key, value);
235
+ }
236
+ }
237
+
238
+ if (keyValueString.length > 0) {
239
+ selectorString += "(" + keyValueString + ")";
240
+ hashString += hashString.length === 0 ? "" : ";";
241
+ hashString += selectorString;
242
+ }
243
+ }
244
+ }
245
+
246
+ if (hashString.length > 0 && addHashPrefix) {
247
+ hashString = "#" + hashString;
248
+ }
249
+
250
+ return hashString;
251
251
  }
@@ -22,18 +22,18 @@ export { Base };
22
22
  * This class has besides a `toString` which returns the json representation of the object
23
23
  * also a functionality to check if an object is an instance of a class.
24
24
  *
25
- * Therefore, the class has a static method ` [Symbol.hasInstance](that)` which returns true if the object
25
+ * Therefore, the class has a static method <code>[Symbol.hasInstance](that)</code> which returns true if the object
26
26
  * is an instance of the class.
27
27
  *
28
- * @see [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance](developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance)
28
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance">MDN Symbol.hasInstance</a>
29
29
  *
30
30
  * Derived classes should implement a static getter `instanceSymbol` which returns a unique symbol.
31
31
  *
32
- * ```javascript
32
+ * <code lang="javascript">
33
33
  * static get [instanceSymbol]() {
34
34
  * return Symbol.for("@schukai/monster/types/base");
35
35
  * }
36
- * ```
36
+ * </code>
37
37
  *
38
38
  * The class was formerly called Object.
39
39
  *
@@ -92,7 +92,8 @@ class Base extends Object {
92
92
  }
93
93
 
94
94
  /**
95
- * this function checks if the class has a static getter `instanceSymbol` and if the value of this getter is equal to the
95
+ * this function checks if the class has a static getter <code>instanceSymbol</code>,
96
+ * and if the value of this getter is equal to the
96
97
  *
97
98
  * @private
98
99
  * @param obj