@schukai/monster 4.12.0 → 4.13.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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
 
4
4
 
5
+ ## [4.13.0] - 2025-06-03
6
+
7
+ ### Add Features
8
+
9
+ - Enhance CustomElement with validation and customization capabilities
10
+
11
+
12
+
5
13
  ## [4.12.0] - 2025-05-29
6
14
 
7
15
  ### Add Features
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.0","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.12.0"}
1
+ {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.0","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.13.0"}
@@ -197,9 +197,22 @@ class CustomElement extends HTMLElement {
197
197
  super();
198
198
 
199
199
  this[attributeObserverSymbol] = {};
200
- this[internalSymbol] = new ProxyObserver({
201
- options: initOptionsFromAttributes(this, extend({}, this.defaults)),
202
- });
200
+
201
+ const options = initOptionsFromAttributes(this, extend({}, this.defaults));
202
+ if (!isObject(options)) {
203
+ throw new Error(
204
+ `The options are not defined correctly in the ${this.getTag()} element.`,
205
+ );
206
+ }
207
+
208
+ if (this.customization instanceof Map) {
209
+ const pathfinder = new Pathfinder(options);
210
+ this.customization.forEach((value, key) => {
211
+ pathfinder.setVia(key, value);
212
+ });
213
+ }
214
+
215
+ this[internalSymbol] = new ProxyObserver({ options });
203
216
  this[initMethodSymbol]();
204
217
  initOptionObserver.call(this);
205
218
  this[scriptHostElementSymbol] = [];
@@ -249,6 +262,17 @@ class CustomElement extends HTMLElement {
249
262
  return this;
250
263
  }
251
264
 
265
+ /**
266
+ * The `customization` property allows overwriting the defaults.
267
+ * Unlike the defaults that expect an object, the customization is a Map.
268
+ * This also allows overwriting individual values in a deeper structure
269
+ * without having to redefine the entire structure and thus changing the defaults.
270
+ * @returns {Map}
271
+ */
272
+ get customization() {
273
+ return new Map();
274
+ }
275
+
252
276
  /**
253
277
  * The `defaults` property defines the default values for a control. If you want to override these,
254
278
  * you can use various methods, which are described in the documentation available at