@schukai/monster 3.71.1 → 3.71.2

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
 
4
4
 
5
+ ## [3.71.2] - 2024-06-25
6
+
7
+ ### Bug Fixes
8
+
9
+ - data-monster-option-filter [#194](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/194)
10
+
11
+
12
+
5
13
  ## [3.71.1] - 2024-06-25
6
14
 
7
15
  ### Bug Fixes
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.6","@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":"3.71.1"}
1
+ {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.6","@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":"3.71.2"}
@@ -12,24 +12,24 @@
12
12
  * SPDX-License-Identifier: AGPL-3.0
13
13
  */
14
14
 
15
- import { instanceSymbol } from "../../constants.mjs";
16
- import { addAttributeToken } from "../../dom/attributes.mjs";
15
+ import {instanceSymbol} from "../../constants.mjs";
16
+ import {addAttributeToken} from "../../dom/attributes.mjs";
17
17
  import {
18
- ATTRIBUTE_ERRORMESSAGE,
19
- ATTRIBUTE_ROLE,
18
+ ATTRIBUTE_ERRORMESSAGE,
19
+ ATTRIBUTE_ROLE,
20
20
  } from "../../dom/constants.mjs";
21
21
  import {
22
- assembleMethodSymbol,
23
- attributeObserverSymbol,
24
- CustomElement,
25
- initMethodSymbol,
26
- registerCustomElement,
22
+ assembleMethodSymbol,
23
+ attributeObserverSymbol,
24
+ CustomElement,
25
+ initMethodSymbol,
26
+ registerCustomElement,
27
27
  } from "../../dom/customelement.mjs";
28
- import { isString } from "../../types/is.mjs";
29
- import { ATTRIBUTE_FORM_RELOAD, ATTRIBUTE_FORM_URL } from "./constants.mjs";
30
- import { loadAndAssignContent } from "./util/fetch.mjs";
28
+ import {isString} from "../../types/is.mjs";
29
+ import {ATTRIBUTE_FORM_RELOAD, ATTRIBUTE_FORM_URL} from "./constants.mjs";
30
+ import {loadAndAssignContent} from "./util/fetch.mjs";
31
31
 
32
- export { Reload };
32
+ export {Reload};
33
33
 
34
34
  /**
35
35
  * @private
@@ -106,128 +106,128 @@ const intersectionObserverWasInitialized = Symbol("wasInitialized");
106
106
  * @fires Monster.Components.event:monster-fetched
107
107
  */
108
108
  class Reload extends CustomElement {
109
- /**
110
- * This method is called by the `instanceof` operator.
111
- * @returns {symbol}
112
- * @since 2.1.0
113
- */
114
- static get [instanceSymbol]() {
115
- return Symbol.for("@schukai/monster/components/form/reload");
116
- }
117
-
118
- /**
119
- * To set the options via the html tag the attribute `data-monster-options` must be used.
120
- * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
121
- *
122
- * The individual configuration values can be found in the table.
123
- *
124
- * @property {Object} templates Template definitions
125
- * @property {string} templates.main Main template
126
- * @property {string} url=undefined
127
- * @property {string} reload=undefined currently the values defined are `onshow` and `always`. The default `onshow` removes the IntersectionObserver. This means that the content is only loaded once. reloading of the content does not occur.
128
- * @property {string} filter=undefined dom selectors to search for elements, if undefined then everything is taken
129
- * @property {Monster.Components.Form.Processor[]} processors
130
- * @property {Object} fetch Fetch [see Using Fetch mozilla.org](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch)
131
- * @property {String} fetch.redirect=error
132
- * @property {String} fetch.method=GET
133
- * @property {String} fetch.mode=same-origin
134
- * @property {String} fetch.credentials=same-origin
135
- * @property {Object} fetch.headers={"accept":"text/html"}}
136
- */
137
- get defaults() {
138
- return Object.assign(
139
- {},
140
- super.defaults,
141
- {
142
- templates: {
143
- main: getTemplate.call(this),
144
- },
145
- shadowMode: false,
146
- url: undefined,
147
- reload: "onshow",
148
- filter: undefined,
149
- fetch: {
150
- redirect: "error",
151
- method: "GET",
152
- mode: "same-origin",
153
- credentials: "same-origin",
154
- headers: {
155
- accept: "text/html",
156
- },
157
- },
158
- },
159
- initOptionsFromArguments.call(this),
160
- );
161
- }
162
-
163
- /**
164
- * This method determines which attributes are to be monitored by `attributeChangedCallback()`.
165
- *
166
- * @return {string[]}
167
- */
168
- static get observedAttributes() {
169
- const list = super.observedAttributes;
170
- list.push(ATTRIBUTE_FORM_URL);
171
- return list;
172
- }
173
-
174
- /**
175
- * @return {void}
176
- */
177
- [initMethodSymbol]() {
178
- super[initMethodSymbol]();
179
-
180
- // data-monster-options
181
- this[attributeObserverSymbol][ATTRIBUTE_FORM_URL] = (url) => {
182
- if (this.hasAttribute(ATTRIBUTE_FORM_URL)) {
183
- this.setOption("url", new URL(url, document.location).toString());
184
- } else {
185
- this.setOption("url", undefined);
186
- }
187
- };
188
- }
189
-
190
- /**
191
- * This method is called internal and should not be called directly.
192
- * @throws {Error} missing default slot
193
- * @throws {Error} no shadow-root is defined
194
- * @throws {Error} missing url
195
- * @throws {Error} we won't be able to read the data
196
- * @throws {Error} request failed
197
- * @throws {Error} not found
198
- * @throws {Error} undefined status or type
199
- * @fires Monster.Components.event:monster-fetched
200
- * @return {Monster.Components.Form.Form}
201
- */
202
- [assembleMethodSymbol]() {
203
- super[assembleMethodSymbol]();
204
- initIntersectionObserver.call(this);
205
- }
206
-
207
- /**
208
- * This method is called internal and should not be called directly.
209
- *
210
- * @return {string}
211
- */
212
- static getTag() {
213
- return "monster-reload";
214
- }
215
-
216
- /**
217
- * load content from url
218
- *
219
- * It is important to know that with this function the loading is executed
220
- * directly. it is loaded as well when the element is not visible.
221
- *
222
- * @param {string|undefined} url
223
- */
224
- fetch(url) {
225
- if (isString(url) || url instanceof URL) {
226
- this.setAttribute(ATTRIBUTE_FORM_URL, `${url}`);
227
- }
228
-
229
- return loadContent.call(this);
230
- }
109
+ /**
110
+ * This method is called by the `instanceof` operator.
111
+ * @returns {symbol}
112
+ * @since 2.1.0
113
+ */
114
+ static get [instanceSymbol]() {
115
+ return Symbol.for("@schukai/monster/components/form/reload");
116
+ }
117
+
118
+ /**
119
+ * To set the options via the html tag the attribute `data-monster-options` must be used.
120
+ * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
121
+ *
122
+ * The individual configuration values can be found in the table.
123
+ *
124
+ * @property {Object} templates Template definitions
125
+ * @property {string} templates.main Main template
126
+ * @property {string} url=undefined
127
+ * @property {string} reload=undefined currently the values defined are `onshow` and `always`. The default `onshow` removes the IntersectionObserver. This means that the content is only loaded once. reloading of the content does not occur.
128
+ * @property {string} filter=undefined dom selectors to search for elements, if undefined then everything is taken
129
+ * @property {Monster.Components.Form.Processor[]} processors
130
+ * @property {Object} fetch Fetch [see Using Fetch mozilla.org](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch)
131
+ * @property {String} fetch.redirect=error
132
+ * @property {String} fetch.method=GET
133
+ * @property {String} fetch.mode=same-origin
134
+ * @property {String} fetch.credentials=same-origin
135
+ * @property {Object} fetch.headers={"accept":"text/html"}}
136
+ */
137
+ get defaults() {
138
+ return Object.assign(
139
+ {},
140
+ super.defaults,
141
+ {
142
+ templates: {
143
+ main: getTemplate.call(this),
144
+ },
145
+ shadowMode: null,
146
+ url: null,
147
+ reload: "onshow",
148
+ filter: null,
149
+ fetch: {
150
+ redirect: "error",
151
+ method: "GET",
152
+ mode: "same-origin",
153
+ credentials: "same-origin",
154
+ headers: {
155
+ accept: "text/html",
156
+ },
157
+ },
158
+ },
159
+ initOptionsFromArguments.call(this),
160
+ );
161
+ }
162
+
163
+ /**
164
+ * This method determines which attributes are to be monitored by `attributeChangedCallback()`.
165
+ *
166
+ * @return {string[]}
167
+ */
168
+ static get observedAttributes() {
169
+ const list = super.observedAttributes;
170
+ list.push(ATTRIBUTE_FORM_URL);
171
+ return list;
172
+ }
173
+
174
+ /**
175
+ * @return {void}
176
+ */
177
+ [initMethodSymbol]() {
178
+ super[initMethodSymbol]();
179
+
180
+ // data-monster-options
181
+ this[attributeObserverSymbol][ATTRIBUTE_FORM_URL] = (url) => {
182
+ if (this.hasAttribute(ATTRIBUTE_FORM_URL)) {
183
+ this.setOption("url", new URL(url, document.location).toString());
184
+ } else {
185
+ this.setOption("url", undefined);
186
+ }
187
+ };
188
+ }
189
+
190
+ /**
191
+ * This method is called internal and should not be called directly.
192
+ * @throws {Error} missing default slot
193
+ * @throws {Error} no shadow-root is defined
194
+ * @throws {Error} missing url
195
+ * @throws {Error} we won't be able to read the data
196
+ * @throws {Error} request failed
197
+ * @throws {Error} not found
198
+ * @throws {Error} undefined status or type
199
+ * @fires Monster.Components.event:monster-fetched
200
+ * @return {Monster.Components.Form.Form}
201
+ */
202
+ [assembleMethodSymbol]() {
203
+ super[assembleMethodSymbol]();
204
+ initIntersectionObserver.call(this);
205
+ }
206
+
207
+ /**
208
+ * This method is called internal and should not be called directly.
209
+ *
210
+ * @return {string}
211
+ */
212
+ static getTag() {
213
+ return "monster-reload";
214
+ }
215
+
216
+ /**
217
+ * load content from url
218
+ *
219
+ * It is important to know that with this function the loading is executed
220
+ * directly. it is loaded as well when the element is not visible.
221
+ *
222
+ * @param {string|undefined} url
223
+ */
224
+ fetch(url) {
225
+ if (isString(url) || url instanceof URL) {
226
+ this.setAttribute(ATTRIBUTE_FORM_URL, `${url}`);
227
+ }
228
+
229
+ return loadContent.call(this);
230
+ }
231
231
  }
232
232
 
233
233
  /**
@@ -241,19 +241,19 @@ class Reload extends CustomElement {
241
241
  * @return {object}
242
242
  */
243
243
  function initOptionsFromArguments() {
244
- const options = {};
244
+ const options = {};
245
245
 
246
- const url = this.getAttribute(ATTRIBUTE_FORM_URL);
246
+ const url = this.getAttribute(ATTRIBUTE_FORM_URL);
247
247
 
248
- if (isString(url)) {
249
- options["url"] = new URL(url, document.location).toString();
250
- }
248
+ if (isString(url)) {
249
+ options["url"] = new URL(url, document.location).toString();
250
+ }
251
251
 
252
- if (this.hasAttribute(ATTRIBUTE_FORM_RELOAD)) {
253
- options["reload"] = this.getAttribute(ATTRIBUTE_FORM_RELOAD).toLowerCase();
254
- }
252
+ if (this.hasAttribute(ATTRIBUTE_FORM_RELOAD)) {
253
+ options["reload"] = this.getAttribute(ATTRIBUTE_FORM_RELOAD).toLowerCase();
254
+ }
255
255
 
256
- return options;
256
+ return options;
257
257
  }
258
258
 
259
259
  /**
@@ -268,37 +268,37 @@ function initOptionsFromArguments() {
268
268
  * @fires Monster.Components.event:monster-fetched
269
269
  */
270
270
  function initIntersectionObserver() {
271
- if (this[intersectionObserverWasInitialized] === true) {
272
- return;
273
- }
274
-
275
- this[intersectionObserverWasInitialized] = true;
276
-
277
- const options = {
278
- threshold: [0.5],
279
- };
280
-
281
- const callback = (entries, observer) => {
282
- for (const [, entry] of entries.entries()) {
283
- if (entry.isIntersecting === true) {
284
- // undefined or always do the same
285
- if (this.getOption("reload") === "onshow") {
286
- observer.disconnect();
287
- }
288
-
289
- try {
290
- loadContent.call(this).catch((e) => {
291
- addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.toString());
292
- });
293
- } catch (e) {
294
- addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.toString());
295
- }
296
- }
297
- }
298
- };
299
-
300
- const observer = new IntersectionObserver(callback, options);
301
- observer.observe(this);
271
+ if (this[intersectionObserverWasInitialized] === true) {
272
+ return;
273
+ }
274
+
275
+ this[intersectionObserverWasInitialized] = true;
276
+
277
+ const options = {
278
+ threshold: [0.5],
279
+ };
280
+
281
+ const callback = (entries, observer) => {
282
+ for (const [, entry] of entries.entries()) {
283
+ if (entry.isIntersecting === true) {
284
+ // undefined or always do the same
285
+ if (this.getOption("reload") === "onshow") {
286
+ observer.disconnect();
287
+ }
288
+
289
+ try {
290
+ loadContent.call(this).catch((e) => {
291
+ addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.toString());
292
+ });
293
+ } catch (e) {
294
+ addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.toString());
295
+ }
296
+ }
297
+ }
298
+ };
299
+
300
+ const observer = new IntersectionObserver(callback, options);
301
+ observer.observe(this);
302
302
  }
303
303
 
304
304
  /**
@@ -318,41 +318,41 @@ function initIntersectionObserver() {
318
318
  * @return {Promise}
319
319
  */
320
320
  function loadContent() {
321
- const url = this.getOption("url", undefined);
322
- if (!isString(url) || url === "") {
323
- throw new Error("missing url");
324
- }
325
-
326
- const options = this.getOption("fetch", {});
327
-
328
- let parentNode = this;
329
- if (this.shadowRoot) {
330
- parentNode = this.shadowRoot;
331
- }
332
-
333
- let container = parentNode.querySelector(`[${ATTRIBUTE_ROLE}=container]`);
334
- let currentDisplayMode = container?.style?.display;
335
-
336
- if (currentDisplayMode === undefined) {
337
- currentDisplayMode = "inherit";
338
- }
339
-
340
- if (!(container instanceof HTMLElement)) {
341
- container = document.createElement("div");
342
- container.style.display = "none";
343
- container.setAttribute(ATTRIBUTE_ROLE, "container");
344
- parentNode.appendChild(container);
345
- }
346
-
347
- return loadAndAssignContent(container, url, options, this.getOption("filter"))
348
- .then(() => {
349
- if (currentDisplayMode !== undefined) {
350
- container.style.display = currentDisplayMode;
351
- }
352
- })
353
- .catch((e) => {
354
- throw e;
355
- });
321
+ const url = this.getOption("url", undefined);
322
+ if (!isString(url) || url === "") {
323
+ throw new Error("missing url");
324
+ }
325
+
326
+ const options = this.getOption("fetch", {});
327
+
328
+ let parentNode = this;
329
+ if (this.shadowRoot) {
330
+ parentNode = this.shadowRoot;
331
+ }
332
+
333
+ let container = parentNode.querySelector(`[${ATTRIBUTE_ROLE}=container]`);
334
+ let currentDisplayMode = container?.style?.display;
335
+
336
+ if (currentDisplayMode === undefined) {
337
+ currentDisplayMode = "inherit";
338
+ }
339
+
340
+ if (!(container instanceof HTMLElement)) {
341
+ container = document.createElement("div");
342
+ container.style.display = "none";
343
+ container.setAttribute(ATTRIBUTE_ROLE, "container");
344
+ parentNode.appendChild(container);
345
+ }
346
+
347
+ return loadAndAssignContent(container, url, options, this.getOption("filter"))
348
+ .then(() => {
349
+ if (currentDisplayMode !== undefined) {
350
+ container.style.display = currentDisplayMode;
351
+ }
352
+ })
353
+ .catch((e) => {
354
+ throw e;
355
+ });
356
356
  }
357
357
 
358
358
  /**
@@ -360,7 +360,7 @@ function loadContent() {
360
360
  * @return {string}
361
361
  */
362
362
  function getTemplate() {
363
- return this.innerHTML;
363
+ return this.innerHTML;
364
364
  }
365
365
 
366
366
  registerCustomElement(Reload);