@schukai/monster 3.115.0 → 3.115.2

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,22 @@
2
2
 
3
3
 
4
4
 
5
+ ## [3.115.2] - 2025-04-01
6
+
7
+ ### Bug Fixes
8
+
9
+ - rename camera file
10
+
11
+
12
+
13
+ ## [3.115.1] - 2025-04-01
14
+
15
+ ### Bug Fixes
16
+
17
+ - update test and monster.mjs [#303](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/303)
18
+
19
+
20
+
5
21
  ## [3.115.0] - 2025-04-01
6
22
 
7
23
  ### Add Features
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.13","@popperjs/core":"^2.11.8","buffer":"^6.0.3"},"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":"3.115.0"}
1
+ {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.13","@popperjs/core":"^2.11.8","buffer":"^6.0.3"},"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":"3.115.2"}
@@ -108,39 +108,6 @@ class CameraCapture extends CustomElement {
108
108
  return this;
109
109
  }
110
110
 
111
- /**
112
- * This method is called when the element is connected to the dom.
113
- *
114
- * @return {void}
115
- */
116
- connectedCallback() {
117
- super.connectedCallback();
118
-
119
- // const document = getDocument();
120
- //
121
- // for (const [, type] of Object.entries(["click", "touch"])) {
122
- // // close on outside ui-events
123
- // document.addEventListener(type, this[closeEventHandler]);
124
- // }
125
- //
126
- // updatePopper.call(this);
127
- // attachResizeObserver.call(this);
128
- }
129
-
130
- /**
131
- * This method is called when the element is disconnected from the dom.
132
- *
133
- * @return {void}
134
- */
135
- disconnectedCallback() {
136
- super.disconnectedCallback();
137
-
138
- // // close on outside ui-events
139
- // for (const [, type] of Object.entries(["click", "touch"])) {
140
- // document.removeEventListener(type, this[closeEventHandler]);
141
- // }
142
- }
143
-
144
111
  /**
145
112
  * To set the options via the HTML Tag, the attribute `data-monster-options` must be used.
146
113
  * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
@@ -224,6 +191,9 @@ class CameraCapture extends CustomElement {
224
191
  }
225
192
  }
226
193
 
194
+ /**
195
+ * @private
196
+ */
227
197
  function initCameraControl() {
228
198
  const self = this;
229
199
 
@@ -10,21 +10,19 @@
10
10
  * For more information about purchasing a commercial license, please contact schukai GmbH.
11
11
  */
12
12
 
13
- import {instanceSymbol} from "../../constants.mjs";
13
+ import { instanceSymbol } from "../../constants.mjs";
14
+ import { ATTRIBUTE_ROLE } from "../../dom/constants.mjs";
15
+ import { CustomElement } from "../../dom/customelement.mjs";
14
16
  import {
15
- ATTRIBUTE_ROLE
16
- } from "../../dom/constants.mjs";
17
- import {CustomElement} from "../../dom/customelement.mjs";
18
- import {
19
- assembleMethodSymbol,
20
- registerCustomElement,
17
+ assembleMethodSymbol,
18
+ registerCustomElement,
21
19
  } from "../../dom/customelement.mjs";
22
- import {isString} from "../../types/is.mjs";
23
- import {FetchBoxStyleSheet} from "./stylesheet/fetch-box.mjs";
24
- import {addErrorAttribute} from "../../dom/error.mjs";
25
- import {Formatter} from "../../text/formatter.mjs";
20
+ import { isString } from "../../types/is.mjs";
21
+ import { FetchBoxStyleSheet } from "./stylesheet/fetch-box.mjs";
22
+ import { addErrorAttribute } from "../../dom/error.mjs";
23
+ import { Formatter } from "../../text/formatter.mjs";
26
24
 
27
- export {FetchBox};
25
+ export { FetchBox };
28
26
 
29
27
  /**
30
28
  * @private
@@ -44,185 +42,190 @@ export const fetchBoxElementSymbol = Symbol("fetchBoxElement");
44
42
  * @summary A beautiful FetchBox that can make your life easier and also looks good. Its like a box, but it fetches data from a URL.
45
43
  */
46
44
  class FetchBox extends CustomElement {
47
- /**
48
- * This method is called by the `instanceof` operator.
49
- * @returns {symbol}
50
- */
51
- static get [instanceSymbol]() {
52
- return Symbol.for("@schukai/monster/components/content/fetch-box@@instance");
53
- }
54
-
55
- /**
56
- *
57
- * @return {Components.Content.FetchBox
58
- */
59
- [assembleMethodSymbol]() {
60
- super[assembleMethodSymbol]();
61
- initControlReferences.call(this);
62
- return this;
63
- }
64
-
65
-
66
- /**
67
- * Handles the component's connection to the DOM.
68
- * Determines the styling of the component based on its parent's tag name.
69
- * Fetches necessary data for the component.
70
- *
71
- * @return {void} This method does not return a value.
72
- */
73
- connectedCallback() {
74
- super.connectedCallback();
75
-
76
-
77
- const parent = this.parentElement;
78
-
79
- if (parent) {
80
- const blockLevelElements = ['DIV', 'SECTION', 'ARTICLE', 'HEADER', 'FOOTER', 'MAIN', 'NAV', 'ASIDE'];
81
- const isBlockLevel = blockLevelElements.includes(parent.tagName);
82
-
83
- if (isBlockLevel) {
84
- this.style.display = 'block';
85
- this.style.width = '100%';
86
- this.style.height = '100%';
87
- } else {
88
- this.style.display = 'inline-flex';
89
- this.style.height = '100%';
90
- }
91
- }
92
-
93
- this.fetch();
94
-
95
- }
96
-
97
-
98
- /**
99
- * To set the options via the HTML Tag, the attribute `data-monster-options` must be used.
100
- * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
101
- *
102
- * The individual configuration values can be found in the table.
103
- *
104
- * @property {Object} templates Template definitions
105
- * @property {string} templates.main Main template
106
- * @property {Object} classes CSS classes
107
- * @property {string} classes.default CSS class for the main template
108
- * @property {string} classes.loading CSS class for the loading template
109
- * @property {string} classes.error CSS class for the error template
110
- * @property {string} classes.empty CSS class for the empty template
111
- * @property {Object} fetch fetch options for the request
112
- * @property {string} fetch.redirect error, follow, manual
113
- * @property {string} fetch.method GET, POST, PUT, DELETE
114
- * @property {string} fetch.mode same-origin, cors, no-cors, navigate
115
- * @property {string} fetch.credentials omit, same-origin, include
116
- * @property {Object} fetch.headers
117
- * @property {string} fetch.headers.accept text/html, application/json
118
- * @property {string} fetch.headers.content-type application/json
119
- * @property {string} parameter value for the data url
120
- * @property {Object} formatter
121
- * @property {Object} formatter.marker
122
- * @property {string} formatter.marker.open marker for the url
123
- * @property {string} formatter.marker.close marker for the url
124
- * @property {string} url url to fetch
125
- */
126
- get defaults() {
127
- return Object.assign({}, super.defaults, {
128
- templates: {
129
- main: getTemplate(),
130
- },
131
- classes: {
132
- default: "monster-fetch-box-default",
133
- loading: "loading",
134
- error: "error",
135
- empty: "empty",
136
- },
137
- data: {},
138
- url: null,
139
- fetch: {
140
- redirect: "error",
141
- method: "GET",
142
- mode: "same-origin",
143
- credentials: "same-origin",
144
- headers: {
145
- accept: "text/html",
146
- },
147
- },
148
-
149
- content: {
150
- // <slot name="loading"></slot>
151
- loading: `<div class="monster-skeleton-animated monster-skeleton-col-100"></div>`,
152
- error: `<slot name="error"></slot>`,
153
- empty: `<slot name="empty"></slot>`,
154
- },
155
- visible: "loading",
156
- parameter: null,
157
-
158
-
159
- formatter: {
160
- marker: {
161
- open: null,
162
- close: null,
163
- },
164
- },
165
-
166
- });
167
- }
168
-
169
- /**
170
- * @return {string}
171
- */
172
- static getTag() {
173
- return "monster-fetch-box";
174
- }
175
-
176
- /**
177
- * @return {CSSStyleSheet[]}
178
- */
179
- static getCSSStyleSheet() {
180
- return [FetchBoxStyleSheet];
181
- }
182
-
183
- /**
184
- * load content from url
185
- */
186
- fetch() {
187
- try {
188
- return loadContent.call(this).then(obj => {
189
-
190
- if (obj.type !== "application/json") {
191
- this.setOption("visible", "error");
192
- throw new Error("not a json response");
193
- }
194
-
195
- try {
196
- const content = obj.content;
197
- if (!isString(content)|| content === "") {
198
- this.setOption("visible", "empty");
199
- return
200
- }
201
-
202
- const jsonContent = JSON.parse(content);
203
- if (jsonContent === null) {
204
- this.setOption("visible", "empty");
205
- return
206
- }
207
-
208
- this.setOption("data", jsonContent);
209
- this.setOption("visible", "default");
210
-
211
- } catch (e) {
212
- this.setOption("visible", "error");
213
- throw e;
214
- }
215
-
216
- }).catch(e => {
217
- this.setOption("visible", "error");
218
- addErrorAttribute(this, e);
219
- });
220
- } catch (e) {
221
- addErrorAttribute(this, e);
222
- this.setOption("visible", "error");
223
- return Promise.reject(e);
224
- }
225
- }
45
+ /**
46
+ * This method is called by the `instanceof` operator.
47
+ * @returns {symbol}
48
+ */
49
+ static get [instanceSymbol]() {
50
+ return Symbol.for(
51
+ "@schukai/monster/components/content/fetch-box@@instance",
52
+ );
53
+ }
54
+
55
+ /**
56
+ *
57
+ * @return {Components.Content.FetchBox
58
+ */
59
+ [assembleMethodSymbol]() {
60
+ super[assembleMethodSymbol]();
61
+ initControlReferences.call(this);
62
+ return this;
63
+ }
64
+
65
+ /**
66
+ * Handles the component's connection to the DOM.
67
+ * Determines the styling of the component based on its parent's tag name.
68
+ * Fetches necessary data for the component.
69
+ *
70
+ * @return {void} This method does not return a value.
71
+ */
72
+ connectedCallback() {
73
+ super.connectedCallback();
74
+
75
+ const parent = this.parentElement;
76
+
77
+ if (parent) {
78
+ const blockLevelElements = [
79
+ "DIV",
80
+ "SECTION",
81
+ "ARTICLE",
82
+ "HEADER",
83
+ "FOOTER",
84
+ "MAIN",
85
+ "NAV",
86
+ "ASIDE",
87
+ ];
88
+ const isBlockLevel = blockLevelElements.includes(parent.tagName);
89
+
90
+ if (isBlockLevel) {
91
+ this.style.display = "block";
92
+ this.style.width = "100%";
93
+ this.style.height = "100%";
94
+ } else {
95
+ this.style.display = "inline-flex";
96
+ this.style.height = "100%";
97
+ }
98
+ }
99
+
100
+ this.fetch();
101
+ }
102
+
103
+ /**
104
+ * To set the options via the HTML Tag, the attribute `data-monster-options` must be used.
105
+ * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
106
+ *
107
+ * The individual configuration values can be found in the table.
108
+ *
109
+ * @property {Object} templates Template definitions
110
+ * @property {string} templates.main Main template
111
+ * @property {Object} classes CSS classes
112
+ * @property {string} classes.default CSS class for the main template
113
+ * @property {string} classes.loading CSS class for the loading template
114
+ * @property {string} classes.error CSS class for the error template
115
+ * @property {string} classes.empty CSS class for the empty template
116
+ * @property {Object} fetch fetch options for the request
117
+ * @property {string} fetch.redirect error, follow, manual
118
+ * @property {string} fetch.method GET, POST, PUT, DELETE
119
+ * @property {string} fetch.mode same-origin, cors, no-cors, navigate
120
+ * @property {string} fetch.credentials omit, same-origin, include
121
+ * @property {Object} fetch.headers
122
+ * @property {string} fetch.headers.accept text/html, application/json
123
+ * @property {string} fetch.headers.content-type application/json
124
+ * @property {string} parameter value for the data url
125
+ * @property {Object} formatter
126
+ * @property {Object} formatter.marker
127
+ * @property {string} formatter.marker.open marker for the url
128
+ * @property {string} formatter.marker.close marker for the url
129
+ * @property {string} url url to fetch
130
+ */
131
+ get defaults() {
132
+ return Object.assign({}, super.defaults, {
133
+ templates: {
134
+ main: getTemplate(),
135
+ },
136
+ classes: {
137
+ default: "monster-fetch-box-default",
138
+ loading: "loading",
139
+ error: "error",
140
+ empty: "empty",
141
+ },
142
+ data: {},
143
+ url: null,
144
+ fetch: {
145
+ redirect: "error",
146
+ method: "GET",
147
+ mode: "same-origin",
148
+ credentials: "same-origin",
149
+ headers: {
150
+ accept: "text/html",
151
+ },
152
+ },
153
+
154
+ content: {
155
+ // <slot name="loading"></slot>
156
+ loading: `<div class="monster-skeleton-animated monster-skeleton-col-100"></div>`,
157
+ error: `<slot name="error"></slot>`,
158
+ empty: `<slot name="empty"></slot>`,
159
+ },
160
+ visible: "loading",
161
+ parameter: null,
162
+
163
+ formatter: {
164
+ marker: {
165
+ open: null,
166
+ close: null,
167
+ },
168
+ },
169
+ });
170
+ }
171
+
172
+ /**
173
+ * @return {string}
174
+ */
175
+ static getTag() {
176
+ return "monster-fetch-box";
177
+ }
178
+
179
+ /**
180
+ * @return {CSSStyleSheet[]}
181
+ */
182
+ static getCSSStyleSheet() {
183
+ return [FetchBoxStyleSheet];
184
+ }
185
+
186
+ /**
187
+ * load content from url
188
+ */
189
+ fetch() {
190
+ try {
191
+ return loadContent
192
+ .call(this)
193
+ .then((obj) => {
194
+ if (obj.type !== "application/json") {
195
+ this.setOption("visible", "error");
196
+ throw new Error("not a json response");
197
+ }
198
+
199
+ try {
200
+ const content = obj.content;
201
+ if (!isString(content) || content === "") {
202
+ this.setOption("visible", "empty");
203
+ return;
204
+ }
205
+
206
+ const jsonContent = JSON.parse(content);
207
+ if (jsonContent === null) {
208
+ this.setOption("visible", "empty");
209
+ return;
210
+ }
211
+
212
+ this.setOption("data", jsonContent);
213
+ this.setOption("visible", "default");
214
+ } catch (e) {
215
+ this.setOption("visible", "error");
216
+ throw e;
217
+ }
218
+ })
219
+ .catch((e) => {
220
+ this.setOption("visible", "error");
221
+ addErrorAttribute(this, e);
222
+ });
223
+ } catch (e) {
224
+ addErrorAttribute(this, e);
225
+ this.setOption("visible", "error");
226
+ return Promise.reject(e);
227
+ }
228
+ }
226
229
  }
227
230
 
228
231
  /**
@@ -233,73 +236,65 @@ class FetchBox extends CustomElement {
233
236
  * @return {Promise}
234
237
  */
235
238
  function loadContent() {
236
- let url = this.getOption("url");
237
-
238
- if (url instanceof URL) {
239
- url = url.toString();
240
- }
241
-
242
- if (!isString(url) || url === "") {
243
- throw new Error("missing url");
244
- }
245
-
246
- let p = this.getOption("parameter", null);
247
- if (p === null) {
248
- p = "";
249
- }
250
-
251
- const data = {
252
- parameter : p
253
- }
254
-
255
- const formatter = new Formatter(data)
256
-
257
- if (this.getOption("formatter.marker.open")) {
258
-
259
- const open = this.getOption("formatter.marker.open");
260
- if (!isString(open)) {
261
- throw new TypeError("open is not a string");
262
- }
263
-
264
- const close = this.getOption("formatter.marker.close");
265
- if (close !== undefined && !isString(close)) {
266
- throw new TypeError("close is not a string");
267
- }
268
-
269
- formatter.setMarker(
270
- open,
271
- close
272
- );
273
- }
274
-
275
- const formattedUrl = formatter.format(
276
- url
277
- );
278
-
279
-
280
- const options = this.getOption("fetch", {});
281
-
282
- return fetch(formattedUrl, options).then((response) => {
283
- if (!response.ok) {
284
- if (["error", "opaque", "opaqueredirect"].includes(response.type)) {
285
- throw new Error(`we won't be able to read the data (${response.type})`);
286
- }
287
-
288
- const statusClass = String(response.status).charAt(0);
289
- if (statusClass === "4") {
290
- throw new Error(`client error ${response.statusText}`);
291
- }
292
- throw new Error(
293
- `undefined status (${response.status} / ${response.statusText}) or type (${response.type})`,
294
- );
295
- }
296
-
297
- return response.text().then((content) => ({
298
- content,
299
- type: response.headers.get("Content-Type"),
300
- }));
301
- });
302
-
239
+ let url = this.getOption("url");
240
+
241
+ if (url instanceof URL) {
242
+ url = url.toString();
243
+ }
244
+
245
+ if (!isString(url) || url === "") {
246
+ throw new Error("missing url");
247
+ }
248
+
249
+ let p = this.getOption("parameter", null);
250
+ if (p === null) {
251
+ p = "";
252
+ }
253
+
254
+ const data = {
255
+ parameter: p,
256
+ };
257
+
258
+ const formatter = new Formatter(data);
259
+
260
+ if (this.getOption("formatter.marker.open")) {
261
+ const open = this.getOption("formatter.marker.open");
262
+ if (!isString(open)) {
263
+ throw new TypeError("open is not a string");
264
+ }
265
+
266
+ const close = this.getOption("formatter.marker.close");
267
+ if (close !== undefined && !isString(close)) {
268
+ throw new TypeError("close is not a string");
269
+ }
270
+
271
+ formatter.setMarker(open, close);
272
+ }
273
+
274
+ const formattedUrl = formatter.format(url);
275
+
276
+ const options = this.getOption("fetch", {});
277
+
278
+ return fetch(formattedUrl, options).then((response) => {
279
+ if (!response.ok) {
280
+ if (["error", "opaque", "opaqueredirect"].includes(response.type)) {
281
+ throw new Error(`we won't be able to read the data (${response.type})`);
282
+ }
283
+
284
+ const statusClass = String(response.status).charAt(0);
285
+ if (statusClass === "4") {
286
+ throw new Error(`client error ${response.statusText}`);
287
+ }
288
+ throw new Error(
289
+ `undefined status (${response.status} / ${response.statusText}) or type (${response.type})`,
290
+ );
291
+ }
292
+
293
+ return response.text().then((content) => ({
294
+ content,
295
+ type: response.headers.get("Content-Type"),
296
+ }));
297
+ });
303
298
  }
304
299
 
305
300
  /**
@@ -307,9 +302,9 @@ function loadContent() {
307
302
  * @return {void}
308
303
  */
309
304
  function initControlReferences() {
310
- this[fetchBoxElementSymbol] = this.shadowRoot.querySelector(
311
- `[${ATTRIBUTE_ROLE}="control"]`,
312
- );
305
+ this[fetchBoxElementSymbol] = this.shadowRoot.querySelector(
306
+ `[${ATTRIBUTE_ROLE}="control"]`,
307
+ );
313
308
  }
314
309
 
315
310
  /**
@@ -317,8 +312,8 @@ function initControlReferences() {
317
312
  * @return {string}
318
313
  */
319
314
  function getTemplate() {
320
- // language=HTML
321
- return `
315
+ // language=HTML
316
+ return `
322
317
  <div data-monster-role="control" part="control">
323
318
  <div
324
319
  data-monster-attributes="class path:classes.default,
@@ -341,5 +336,4 @@ function getTemplate() {
341
336
  </div>`;
342
337
  }
343
338
 
344
-
345
339
  registerCustomElement(FetchBox);