@schukai/monster 4.37.1 → 4.38.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 +19 -0
- package/package.json +1 -1
- package/source/components/content/viewer/html.mjs +131 -131
- package/source/components/content/viewer/message.mjs +739 -740
- package/source/components/content/viewer/stylesheet/html.mjs +13 -6
- package/source/components/content/viewer/stylesheet/message.mjs +13 -6
- package/source/components/data/kpi-tile.mjs +111 -0
- package/source/components/data/style/kpi-tile.pcss +161 -0
- package/source/components/data/stylesheet/kpi-tile.mjs +38 -0
- package/source/components/form/select.mjs +2850 -2850
- package/source/components/layout/tabs.mjs +1024 -1024
- package/source/components/layout/utils/attach-tabs-hash-sync.mjs +158 -152
- package/source/components/notify/stylesheet/message.mjs +13 -6
- package/source/components/state/log.mjs +1 -1
- package/source/dom/customelement.mjs +4 -2
- package/source/dom/error.mjs +54 -47
- package/source/types/version.mjs +1 -1
- package/test/cases/monster.mjs +1 -1
- package/test/web/test.html +2 -2
- package/test/web/tests.js +28 -7
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,25 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
+
## [4.38.0] - 2025-07-21
|
6
|
+
|
7
|
+
### Add Features
|
8
|
+
|
9
|
+
- new kpi pile control [#331](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/331)
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
## [4.37.2] - 2025-07-19
|
14
|
+
|
15
|
+
### Bug Fixes
|
16
|
+
|
17
|
+
- missing parameter
|
18
|
+
### Changes
|
19
|
+
|
20
|
+
- doc
|
21
|
+
|
22
|
+
|
23
|
+
|
5
24
|
## [4.37.1] - 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.
|
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.0"}
|
@@ -14,10 +14,10 @@
|
|
14
14
|
|
15
15
|
import { instanceSymbol } from "../../../constants.mjs";
|
16
16
|
import {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
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
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
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
|
-
|
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
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
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
|
-
|
191
|
-
|
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>
|