@schukai/monster 4.37.2 → 4.38.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
 
4
4
 
5
+ ## [4.38.1] - 2025-07-23
6
+
7
+ ### Bug Fixes
8
+
9
+ - add event to tree-menu action, selected
10
+ ### Changes
11
+
12
+ - update nix
13
+
14
+
15
+
16
+ ## [4.38.0] - 2025-07-21
17
+
18
+ ### Add Features
19
+
20
+ - new kpi pile control [#331](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/331)
21
+
22
+
23
+
5
24
  ## [4.37.2] - 2025-07-19
6
25
 
7
26
  ### Bug Fixes
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.2","@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.37.2"}
1
+ {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.2","@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.38.1"}
@@ -14,10 +14,10 @@
14
14
 
15
15
  import { instanceSymbol } from "../../../constants.mjs";
16
16
  import {
17
- assembleMethodSymbol,
18
- CustomElement,
19
- registerCustomElement,
20
- updaterTransformerMethodsSymbol,
17
+ assembleMethodSymbol,
18
+ CustomElement,
19
+ registerCustomElement,
20
+ updaterTransformerMethodsSymbol,
21
21
  } from "../../../dom/customelement.mjs";
22
22
  import { HtmlStyleSheet } from "./stylesheet/html.mjs";
23
23
  import { sanitizeHtml } from "../../../dom/sanitize-html.mjs";
@@ -38,125 +38,125 @@ const htmlContentElementSymbol = Symbol("htmlContentElement");
38
38
  * @summary An HTML content component that can display sanitized HTML.
39
39
  */
40
40
  class HtmlContent extends CustomElement {
41
- /**
42
- * This method is called by the `instanceof` operator.
43
- * @return {symbol}
44
- */
45
- static get [instanceSymbol]() {
46
- return Symbol.for(
47
- "@schukai/monster/components/content/viewer/html-content@@instance",
48
- );
49
- }
50
-
51
- /**
52
- * To set the options via the HTML tag, the attribute `data-monster-options` must be used.
53
- * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
54
- *
55
- * The individual configuration values can be found in the table.
56
- *
57
- * @property {Object} templates Template definitions
58
- * @property {string} templates.main Main template
59
- * @property {string} content The HTML string to be displayed.
60
- * @property {Object} features Features to enable or disable specific functionalities.
61
- * @property {boolean} features.sanitize Whether to sanitize the HTML content (removes scripts, etc.). Defaults to true.
62
- * @property {object} sanitize Sanitization options.
63
- * @property {function} sanitize.callback A callback function to sanitize the HTML content. Defaults to a built-in sanitizer. You can use libraries like DOMPurify for this purpose.
64
- */
65
- get defaults() {
66
- return Object.assign({}, super.defaults, {
67
- templates: {
68
- main: getTemplate(),
69
- },
70
- content: "", // Default content is an empty slot
71
-
72
- features: {
73
- sanitize: true,
74
- },
75
-
76
- sanitize: {
77
- callback: sanitizeHtml.bind(this),
78
- },
79
- });
80
- }
81
-
82
- /**
83
- * Returns the updater transformer methods for this component.
84
- * @returns {{sanitizeHtml: ((function(*): (*))|*)}}
85
- */
86
- [updaterTransformerMethodsSymbol]() {
87
- return {
88
- sanitizeHtml: (value) => {
89
- if (this.getOption("features.sanitize")) {
90
- return this.getOption("sanitize.callback")(value);
91
- }
92
- return value;
93
- },
94
- addErrorHandler: (value) => {
95
- // Add error handling for images
96
- if (typeof value === "string") {
97
- const parser = new DOMParser();
98
- const doc = parser.parseFromString(value, "text/html");
99
- const images = doc.querySelectorAll("img");
100
- images.forEach((img) => {
101
- img.setAttribute(
102
- "onerror",
103
- "this.classList.add('notFoundImage'); this.src='data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';",
104
- );
105
- img.classList.add("notFoundError");
106
- });
107
-
108
- return doc.body.innerHTML;
109
- }
110
- return value;
111
- },
112
- };
113
- }
114
-
115
- /**
116
- * Sets the content of the HtmlContent component.
117
- * @param content
118
- * @returns {HtmlContent}
119
- */
120
- setContent(content) {
121
- this.setOption("content", content);
122
- return this;
123
- }
124
-
125
- /**
126
- * @return {string}
127
- */
128
- static getTag() {
129
- return "monster-html-content";
130
- }
131
-
132
- /**
133
- * @return {HtmlContent}
134
- */
135
- [assembleMethodSymbol]() {
136
- super[assembleMethodSymbol]();
137
- initControlReferences.call(this);
138
- initEventHandler.call(this);
139
- grabChildren.call(this);
140
- }
141
-
142
- /**
143
- * @return {Array}
144
- */
145
- static getCSSStyleSheet() {
146
- return [HtmlStyleSheet];
147
- }
41
+ /**
42
+ * This method is called by the `instanceof` operator.
43
+ * @return {symbol}
44
+ */
45
+ static get [instanceSymbol]() {
46
+ return Symbol.for(
47
+ "@schukai/monster/components/content/viewer/html-content@@instance",
48
+ );
49
+ }
50
+
51
+ /**
52
+ * To set the options via the HTML tag, the attribute `data-monster-options` must be used.
53
+ * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
54
+ *
55
+ * The individual configuration values can be found in the table.
56
+ *
57
+ * @property {Object} templates Template definitions
58
+ * @property {string} templates.main Main template
59
+ * @property {string} content The HTML string to be displayed.
60
+ * @property {Object} features Features to enable or disable specific functionalities.
61
+ * @property {boolean} features.sanitize Whether to sanitize the HTML content (removes scripts, etc.). Defaults to true.
62
+ * @property {object} sanitize Sanitization options.
63
+ * @property {function} sanitize.callback A callback function to sanitize the HTML content. Defaults to a built-in sanitizer. You can use libraries like DOMPurify for this purpose.
64
+ */
65
+ get defaults() {
66
+ return Object.assign({}, super.defaults, {
67
+ templates: {
68
+ main: getTemplate(),
69
+ },
70
+ content: "", // Default content is an empty slot
71
+
72
+ features: {
73
+ sanitize: true,
74
+ },
75
+
76
+ sanitize: {
77
+ callback: sanitizeHtml.bind(this),
78
+ },
79
+ });
80
+ }
81
+
82
+ /**
83
+ * Returns the updater transformer methods for this component.
84
+ * @returns {{sanitizeHtml: ((function(*): (*))|*)}}
85
+ */
86
+ [updaterTransformerMethodsSymbol]() {
87
+ return {
88
+ sanitizeHtml: (value) => {
89
+ if (this.getOption("features.sanitize")) {
90
+ return this.getOption("sanitize.callback")(value);
91
+ }
92
+ return value;
93
+ },
94
+ addErrorHandler: (value) => {
95
+ // Add error handling for images
96
+ if (typeof value === "string") {
97
+ const parser = new DOMParser();
98
+ const doc = parser.parseFromString(value, "text/html");
99
+ const images = doc.querySelectorAll("img");
100
+ images.forEach((img) => {
101
+ img.setAttribute(
102
+ "onerror",
103
+ "this.classList.add('notFoundImage'); this.src='data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';",
104
+ );
105
+ img.classList.add("notFoundError");
106
+ });
107
+
108
+ return doc.body.innerHTML;
109
+ }
110
+ return value;
111
+ },
112
+ };
113
+ }
114
+
115
+ /**
116
+ * Sets the content of the HtmlContent component.
117
+ * @param content
118
+ * @returns {HtmlContent}
119
+ */
120
+ setContent(content) {
121
+ this.setOption("content", content);
122
+ return this;
123
+ }
124
+
125
+ /**
126
+ * @return {string}
127
+ */
128
+ static getTag() {
129
+ return "monster-html-content";
130
+ }
131
+
132
+ /**
133
+ * @return {HtmlContent}
134
+ */
135
+ [assembleMethodSymbol]() {
136
+ super[assembleMethodSymbol]();
137
+ initControlReferences.call(this);
138
+ initEventHandler.call(this);
139
+ grabChildren.call(this);
140
+ }
141
+
142
+ /**
143
+ * @return {Array}
144
+ */
145
+ static getCSSStyleSheet() {
146
+ return [HtmlStyleSheet];
147
+ }
148
148
  }
149
149
 
150
150
  function grabChildren() {
151
- // If there are children, we grab them and set the content
152
- if (this.children.length > 0) {
153
- const content = Array.from(this.children)
154
- .map((child) => child.outerHTML)
155
- .join("");
156
- this.setContent(content);
157
-
158
- this.innerHTML = "";
159
- }
151
+ // If there are children, we grab them and set the content
152
+ if (this.children.length > 0) {
153
+ const content = Array.from(this.children)
154
+ .map((child) => child.outerHTML)
155
+ .join("");
156
+ this.setContent(content);
157
+
158
+ this.innerHTML = "";
159
+ }
160
160
  }
161
161
 
162
162
  /**
@@ -164,7 +164,7 @@ function grabChildren() {
164
164
  * @return {HtmlContent}
165
165
  */
166
166
  function initEventHandler() {
167
- return this;
167
+ return this;
168
168
  }
169
169
 
170
170
  /**
@@ -172,14 +172,14 @@ function initEventHandler() {
172
172
  * @return {HtmlContent}
173
173
  */
174
174
  function initControlReferences() {
175
- if (!this.shadowRoot) {
176
- throw new Error("no shadow-root is defined");
177
- }
178
-
179
- this[htmlContentElementSymbol] = this.shadowRoot.querySelector(
180
- "[data-monster-role=content-container]",
181
- );
182
- return this;
175
+ if (!this.shadowRoot) {
176
+ throw new Error("no shadow-root is defined");
177
+ }
178
+
179
+ this[htmlContentElementSymbol] = this.shadowRoot.querySelector(
180
+ "[data-monster-role=content-container]",
181
+ );
182
+ return this;
183
183
  }
184
184
 
185
185
  /**
@@ -187,8 +187,8 @@ function initControlReferences() {
187
187
  * @return {string}
188
188
  */
189
189
  function getTemplate() {
190
- // language=HTML
191
- return `
190
+ // language=HTML
191
+ return `
192
192
  <div data-monster-role="content-container" part="content-container"
193
193
  data-monster-replace="path:content | call:sanitizeHtml | call:addErrorHandler | default: "
194
194
  ></div>