@schukai/monster 3.82.0 → 3.83.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,22 @@
2
2
 
3
3
 
4
4
 
5
+ ## [3.83.0] - 2024-10-27
6
+
7
+ ### Add Features
8
+
9
+ - New disableButton for monster-state-message-button [#254](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/254)
10
+
11
+
12
+
13
+ ## [3.82.1] - 2024-10-16
14
+
15
+ ### Bug Fixes
16
+
17
+ - wrong feature in iframe
18
+
19
+
20
+
5
21
  ## [3.82.0] - 2024-10-16
6
22
 
7
23
  ### Add Features
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.11","@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.82.0"}
1
+ {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.11","@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.83.0"}
@@ -121,6 +121,9 @@ class MessageStateButton extends Popper {
121
121
  throw new Error("the click action is not defined");
122
122
  },
123
123
  },
124
+ features: {
125
+ disableButton: false,
126
+ },
124
127
  });
125
128
  }
126
129
 
@@ -208,7 +211,7 @@ class MessageStateButton extends Popper {
208
211
 
209
212
  /**
210
213
  * @param {number} timeout
211
- * @return {Monster.Components.Form.MessageStateButton}
214
+ * @return {MessageStateButton}
212
215
  */
213
216
  showMessage(timeout) {
214
217
  super.showDialog();
@@ -363,7 +366,7 @@ function getTemplate() {
363
366
  <div data-monster-role="control" part="control">
364
367
 
365
368
  <monster-state-button exportparts="button:button-button,control:button-control"
366
- data-monster-attributes="data-monster-option-classes-button path:classes.button"
369
+ data-monster-attributes="data-monster-option-classes-button path:classes.button, disabled path:features.disableButton"
367
370
  part="button"
368
371
  name="button"
369
372
  data-monster-role="button">
@@ -199,8 +199,6 @@ class ConfigManager extends CustomElement {
199
199
  }
200
200
 
201
201
  /**
202
- *
203
- * @return {Monster.Components.Host.Host}
204
202
  */
205
203
  [assembleMethodSymbol]() {
206
204
  super[assembleMethodSymbol]();
@@ -10,20 +10,20 @@
10
10
  * For more information about purchasing a commercial license, please contact schukai GmbH.
11
11
  */
12
12
 
13
- import {instanceSymbol} from "../../constants.mjs";
14
- import {ATTRIBUTE_ROLE} from "../../dom/constants.mjs";
15
- import {CustomElement} from "../../dom/customelement.mjs";
13
+ import { instanceSymbol } from "../../constants.mjs";
14
+ import { ATTRIBUTE_ROLE } from "../../dom/constants.mjs";
15
+ import { CustomElement } from "../../dom/customelement.mjs";
16
16
  import {
17
- assembleMethodSymbol,
18
- registerCustomElement,
17
+ assembleMethodSymbol,
18
+ registerCustomElement,
19
19
  } from "../../dom/customelement.mjs";
20
- import {findTargetElementFromEvent} from "../../dom/events.mjs";
21
- import {isFunction} from "../../types/is.mjs";
22
- import {DeadMansSwitch} from "../../util/deadmansswitch.mjs";
23
- import {IframeStyleSheet} from "./stylesheet/iframe.mjs";
24
- import {fireCustomEvent} from "../../dom/events.mjs";
20
+ import { findTargetElementFromEvent } from "../../dom/events.mjs";
21
+ import { isFunction } from "../../types/is.mjs";
22
+ import { DeadMansSwitch } from "../../util/deadmansswitch.mjs";
23
+ import { IframeStyleSheet } from "./stylesheet/iframe.mjs";
24
+ import { fireCustomEvent } from "../../dom/events.mjs";
25
25
 
26
- export {Iframe};
26
+ export { Iframe };
27
27
 
28
28
  /**
29
29
  * @private
@@ -62,133 +62,134 @@ const timerCallbackSymbol = Symbol("timerCallback");
62
62
  * @summary A cool and fancy Iframe that can make your life easier and also looks good.
63
63
  */
64
64
  class Iframe extends CustomElement {
65
- /**
66
- * This method is called by the `instanceof` operator.
67
- * @return {symbol}
68
- */
69
- static get [instanceSymbol]() {
70
- return Symbol.for("@schukai/monster/components/layout/iframe@@instance");
71
- }
72
-
73
- /**
74
- *
75
- * @return {Components.Layout.Iframe
76
- */
77
- [assembleMethodSymbol]() {
78
- super[assembleMethodSymbol]();
79
- initControlReferences.call(this);
80
- initEventHandler.call(this);
81
- calcHeight.call(this);
82
- return this;
83
- }
84
-
85
- /**
86
- * This method is called by the dom and should not be called directly.
87
- *
88
- * @return {void}
89
- */
90
- connectedCallback() {
91
- super.connectedCallback();
92
- attachResizeObserver.call(this);
93
-
94
- // disable scrolling in parent node
95
- if (this.parentNode && this.parentNode instanceof HTMLElement) {
96
- this.parentNode.style.overflow = "hidden";
97
- }
98
- }
99
-
100
- /**
101
- * This method is called by the dom and should not be called directly.
102
- *
103
- * @return {void}
104
- */
105
- disconnectedCallback() {
106
- super.disconnectedCallback();
107
- disconnectResizeObserver.call(this);
108
- }
109
-
110
- /**
111
- * To set the options via the HTML tag, the attribute `data-monster-options` must be used.
112
- * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
113
- *
114
- * The individual configuration values can be found in the table.
115
- *
116
- * @property {Object} templates Template definitions
117
- * @property {string} templates.main Main template
118
- * @property {Object} labels Label definitions
119
- * @property {Object} actions Callbacks
120
- * @property {string} actions.click="throw Error" Callback when clicked
121
- * @property {Object} features Features
122
- * @property {boolean} features.allowFullScreen=true Allow fullscreen
123
- * @property {boolean} features.allowPaymentRequest=true Allow payment request
124
- * @property {boolean} features.replaceTargets=true Replace parent target in iframe
125
- * @property {string} loading="eager" Loading state
126
- * @property {string} referrerPolicy="no-referrer" Referrer policy
127
- * @property {string} src Source
128
- * @property {Object} classes CSS classes
129
- * @property {boolean} disabled=false Disabled state
130
- */
131
- get defaults() {
132
- return Object.assign({}, super.defaults, {
133
- templates: {
134
- main: getTemplate(),
135
- },
136
- src: null,
137
-
138
- /* "allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-top-navigation"*/
139
- sandbox: null,
140
-
141
- labels: {},
142
- classes: {},
143
-
144
- name: "",
145
-
146
- referrerPolicy: "no-referrer",
147
-
148
- disabled: false,
149
- features: {
150
- allowFullScreen: true,
151
- allowPaymentRequest: true,
152
- replaceTargets: true,
153
- },
154
-
155
- loading: "eager",
156
-
157
- actions: {
158
- click: () => {
159
- throw new Error("the click action is not defined");
160
- },
161
- },
162
- });
163
- }
164
-
165
- /**
166
- * @return {string}
167
- */
168
- static getTag() {
169
- return "monster-iframe";
170
- }
171
-
172
- /**
173
- * @return {CSSStyleSheet[]}
174
- */
175
- static getCSSStyleSheet() {
176
- return [IframeStyleSheet];
177
- }
65
+ /**
66
+ * This method is called by the `instanceof` operator.
67
+ * @return {symbol}
68
+ */
69
+ static get [instanceSymbol]() {
70
+ return Symbol.for("@schukai/monster/components/layout/iframe@@instance");
71
+ }
72
+
73
+ /**
74
+ *
75
+ * @return {Components.Layout.Iframe
76
+ * @fires monster-iframe-clicked
77
+ */
78
+ [assembleMethodSymbol]() {
79
+ super[assembleMethodSymbol]();
80
+ initControlReferences.call(this);
81
+ initEventHandler.call(this);
82
+ calcHeight.call(this);
83
+ return this;
84
+ }
85
+
86
+ /**
87
+ * This method is called by the dom and should not be called directly.
88
+ *
89
+ * @return {void}
90
+ */
91
+ connectedCallback() {
92
+ super.connectedCallback();
93
+ attachResizeObserver.call(this);
94
+
95
+ // disable scrolling in parent node
96
+ if (this.parentNode && this.parentNode instanceof HTMLElement) {
97
+ this.parentNode.style.overflow = "hidden";
98
+ }
99
+ }
100
+
101
+ /**
102
+ * This method is called by the dom and should not be called directly.
103
+ *
104
+ * @return {void}
105
+ */
106
+ disconnectedCallback() {
107
+ super.disconnectedCallback();
108
+ disconnectResizeObserver.call(this);
109
+ }
110
+
111
+ /**
112
+ * To set the options via the HTML tag, the attribute `data-monster-options` must be used.
113
+ * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
114
+ *
115
+ * The individual configuration values can be found in the table.
116
+ *
117
+ * @property {Object} templates Template definitions
118
+ * @property {string} templates.main Main template
119
+ * @property {Object} labels Label definitions
120
+ * @property {Object} actions Callbacks
121
+ * @property {string} actions.click="throw Error" Callback when clicked
122
+ * @property {Object} features Features
123
+ * @property {boolean} features.allowFullScreen=true Allow fullscreen
124
+ * @property {boolean} features.allowPaymentRequest=true Allow payment request
125
+ * @property {boolean} features.replaceTargets=true Replace parent target in iframe
126
+ * @property {string} loading="eager" Loading state
127
+ * @property {string} referrerPolicy="no-referrer" Referrer policy
128
+ * @property {string} src Source
129
+ * @property {Object} classes CSS classes
130
+ * @property {boolean} disabled=false Disabled state
131
+ */
132
+ get defaults() {
133
+ return Object.assign({}, super.defaults, {
134
+ templates: {
135
+ main: getTemplate(),
136
+ },
137
+ src: null,
138
+
139
+ /* "allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-top-navigation"*/
140
+ sandbox: null,
141
+
142
+ labels: {},
143
+ classes: {},
144
+
145
+ name: "",
146
+
147
+ referrerPolicy: "no-referrer",
148
+
149
+ disabled: false,
150
+ features: {
151
+ allowFullScreen: true,
152
+ allowPaymentRequest: true,
153
+ replaceTargets: true,
154
+ },
155
+
156
+ loading: "eager",
157
+
158
+ actions: {
159
+ click: () => {
160
+ throw new Error("the click action is not defined");
161
+ },
162
+ },
163
+ });
164
+ }
165
+
166
+ /**
167
+ * @return {string}
168
+ */
169
+ static getTag() {
170
+ return "monster-iframe";
171
+ }
172
+
173
+ /**
174
+ * @return {CSSStyleSheet[]}
175
+ */
176
+ static getCSSStyleSheet() {
177
+ return [IframeStyleSheet];
178
+ }
178
179
  }
179
180
 
180
181
  /**
181
182
  * @private
182
183
  */
183
184
  function calcHeight() {
184
- this.style.boxSizing = "border-box";
185
+ this.style.boxSizing = "border-box";
185
186
 
186
- const height = calculateMaximumHeight.call(this, this.parentNode);
187
- if (height < 0 || isNaN(height)) {
188
- return;
189
- }
187
+ const height = calculateMaximumHeight.call(this, this.parentNode);
188
+ if (height < 0 || isNaN(height)) {
189
+ return;
190
+ }
190
191
 
191
- this[iframeElementSymbol].style.height = `${height}px`;
192
+ this[iframeElementSymbol].style.height = `${height}px`;
192
193
  }
193
194
 
194
195
  /**
@@ -197,138 +198,139 @@ function calcHeight() {
197
198
  * @return {*}
198
199
  */
199
200
  function calculateMaximumHeight(element) {
200
- let totalBottomBorder = 0;
201
- let totalBottomPadding = 0;
202
- let totalBottomMargin = 0;
203
- let totalOutlineHeight = 0;
204
- let totalBoxShadowHeight = 0;
205
- let currentElement = element;
206
-
207
- while (currentElement && currentElement !== document.body) {
208
- const style = window.getComputedStyle(currentElement);
209
- const boxSizing = style.boxSizing;
210
-
211
- const elementHeight = currentElement.getBoundingClientRect().height;
212
-
213
- const borderBottomWidth = parseFloat(style.borderBottomWidth);
214
- const paddingBottom = parseFloat(style.paddingBottom);
215
- const marginBottom = parseFloat(style.marginBottom);
216
-
217
- const outlineHeight = parseFloat(style.outlineWidth);
218
-
219
- totalBottomBorder += isNaN(borderBottomWidth) ? 0 : borderBottomWidth;
220
- totalBottomPadding +=
221
- isNaN(paddingBottom) || boxSizing === "border-box" ? 0 : paddingBottom;
222
- totalBottomMargin += isNaN(marginBottom) ? 0 : marginBottom;
223
- totalOutlineHeight += isNaN(outlineHeight) ? 0 : outlineHeight;
224
-
225
- const boxShadow = style.boxShadow;
226
- let boxShadowVerticalTotal = 0;
227
-
228
- if (boxShadow !== "none") {
229
- const boxShadowValues = boxShadow.split(" ");
230
- const verticalOffset = parseFloat(boxShadowValues[3]);
231
- const blurRadius = parseFloat(boxShadowValues[4]);
232
- const spreadRadius = parseFloat(boxShadowValues[5]);
233
-
234
- boxShadowVerticalTotal = verticalOffset + blurRadius + spreadRadius;
235
- }
236
-
237
- totalBoxShadowHeight += isNaN(boxShadowVerticalTotal)
238
- ? 0
239
- : boxShadowVerticalTotal;
240
-
241
- if (elementHeight > 200) {
242
- return (
243
- elementHeight -
244
- totalBottomBorder -
245
- totalBottomPadding -
246
- totalBottomMargin -
247
- totalOutlineHeight -
248
- totalBoxShadowHeight
249
- );
250
- }
251
-
252
- currentElement = currentElement.parentNode || currentElement.host;
253
- }
201
+ let totalBottomBorder = 0;
202
+ let totalBottomPadding = 0;
203
+ let totalBottomMargin = 0;
204
+ let totalOutlineHeight = 0;
205
+ let totalBoxShadowHeight = 0;
206
+ let currentElement = element;
207
+
208
+ while (currentElement && currentElement !== document.body) {
209
+ const style = window.getComputedStyle(currentElement);
210
+ const boxSizing = style.boxSizing;
211
+
212
+ const elementHeight = currentElement.getBoundingClientRect().height;
213
+
214
+ const borderBottomWidth = parseFloat(style.borderBottomWidth);
215
+ const paddingBottom = parseFloat(style.paddingBottom);
216
+ const marginBottom = parseFloat(style.marginBottom);
217
+
218
+ const outlineHeight = parseFloat(style.outlineWidth);
219
+
220
+ totalBottomBorder += isNaN(borderBottomWidth) ? 0 : borderBottomWidth;
221
+ totalBottomPadding +=
222
+ isNaN(paddingBottom) || boxSizing === "border-box" ? 0 : paddingBottom;
223
+ totalBottomMargin += isNaN(marginBottom) ? 0 : marginBottom;
224
+ totalOutlineHeight += isNaN(outlineHeight) ? 0 : outlineHeight;
225
+
226
+ const boxShadow = style.boxShadow;
227
+ let boxShadowVerticalTotal = 0;
228
+
229
+ if (boxShadow !== "none") {
230
+ const boxShadowValues = boxShadow.split(" ");
231
+ const verticalOffset = parseFloat(boxShadowValues[3]);
232
+ const blurRadius = parseFloat(boxShadowValues[4]);
233
+ const spreadRadius = parseFloat(boxShadowValues[5]);
234
+
235
+ boxShadowVerticalTotal = verticalOffset + blurRadius + spreadRadius;
236
+ }
237
+
238
+ totalBoxShadowHeight += isNaN(boxShadowVerticalTotal)
239
+ ? 0
240
+ : boxShadowVerticalTotal;
241
+
242
+ if (elementHeight > 200) {
243
+ return (
244
+ elementHeight -
245
+ totalBottomBorder -
246
+ totalBottomPadding -
247
+ totalBottomMargin -
248
+ totalOutlineHeight -
249
+ totalBoxShadowHeight
250
+ );
251
+ }
252
+
253
+ currentElement = currentElement.parentNode || currentElement.host;
254
+ }
254
255
  }
255
256
 
256
257
  /**
257
258
  * @private
258
259
  */
259
260
  function attachResizeObserver() {
260
- // against flickering
261
- this[resizeObserverSymbol] = new ResizeObserver(() => {
262
- if (this[timerCallbackSymbol] instanceof DeadMansSwitch) {
263
- try {
264
- this[timerCallbackSymbol].touch();
265
- return;
266
- } catch (e) {
267
- delete this[timerCallbackSymbol];
268
- }
269
- }
270
-
271
- this[timerCallbackSymbol] = new DeadMansSwitch(200, () => {
272
- calcHeight.call(this);
273
- });
274
- });
275
-
276
- this[resizeObserverSymbol].observe(this.ownerDocument.body);
277
- this[resizeObserverSymbol].observe(document.scrollingElement);
261
+ // against flickering
262
+ this[resizeObserverSymbol] = new ResizeObserver(() => {
263
+ if (this[timerCallbackSymbol] instanceof DeadMansSwitch) {
264
+ try {
265
+ this[timerCallbackSymbol].touch();
266
+ return;
267
+ } catch (e) {
268
+ delete this[timerCallbackSymbol];
269
+ }
270
+ }
271
+
272
+ this[timerCallbackSymbol] = new DeadMansSwitch(200, () => {
273
+ calcHeight.call(this);
274
+ });
275
+ });
276
+
277
+ this[resizeObserverSymbol].observe(this.ownerDocument.body);
278
+ this[resizeObserverSymbol].observe(document.scrollingElement);
278
279
  }
279
280
 
280
281
  function disconnectResizeObserver() {
281
- if (this[resizeObserverSymbol] instanceof ResizeObserver) {
282
- this[resizeObserverSymbol].disconnect();
283
- }
282
+ if (this[resizeObserverSymbol] instanceof ResizeObserver) {
283
+ this[resizeObserverSymbol].disconnect();
284
+ }
284
285
  }
285
286
 
286
287
  /**
287
288
  * @private
288
289
  * @return {initEventHandler}
289
- * @fires monster-iframe-clicked
290
290
  */
291
291
  function initEventHandler() {
292
- const self = this;
293
- const element = this[iframeElementSymbol];
294
-
295
- const type = "click";
296
-
297
- element.addEventListener(type, function (event) {
298
- const callback = self.getOption("actions.click");
299
-
300
- fireCustomEvent(self, "monster-iframe-clicked", {
301
- element: self,
302
- });
303
-
304
- if (!isFunction(callback)) {
305
- return;
306
- }
307
-
308
- const element = findTargetElementFromEvent(
309
- event,
310
- ATTRIBUTE_ROLE,
311
- "control",
312
- );
313
-
314
- if (!(element instanceof Node && self.hasNode(element))) {
315
- return;
316
- }
317
-
318
- callback.call(self, event);
319
- });
320
-
321
- this[iframeElementSymbol].addEventListener("load", () => {
322
- calcHeight.call(this);
323
- if (this.getOption("features.replaceParentTarget")) {
324
- var links = this[iframeElementSymbol].contentDocument.querySelectorAll('a[target="_parent"], form[target="_parent"], a[target="_top"], form[target="_top"]');
325
- links.forEach(function(link) {
326
- link.target = '_self';
327
- });
328
- }
329
- });
330
-
331
- return this;
292
+ const self = this;
293
+ const element = this[iframeElementSymbol];
294
+
295
+ const type = "click";
296
+
297
+ element.addEventListener(type, function (event) {
298
+ const callback = self.getOption("actions.click");
299
+
300
+ fireCustomEvent(self, "monster-iframe-clicked", {
301
+ element: self,
302
+ });
303
+
304
+ if (!isFunction(callback)) {
305
+ return;
306
+ }
307
+
308
+ const element = findTargetElementFromEvent(
309
+ event,
310
+ ATTRIBUTE_ROLE,
311
+ "control",
312
+ );
313
+
314
+ if (!(element instanceof Node && self.hasNode(element))) {
315
+ return;
316
+ }
317
+
318
+ callback.call(self, event);
319
+ });
320
+
321
+ this[iframeElementSymbol].addEventListener("load", () => {
322
+ calcHeight.call(this);
323
+ if (this.getOption("features.replaceTargets")) {
324
+ const links = this[iframeElementSymbol].contentDocument.querySelectorAll(
325
+ 'a[target="_parent"], form[target="_parent"], a[target="_top"], form[target="_top"]',
326
+ );
327
+ links.forEach(function (link) {
328
+ link.target = "_self";
329
+ });
330
+ }
331
+ });
332
+
333
+ return this;
332
334
  }
333
335
 
334
336
  /**
@@ -336,17 +338,17 @@ function initEventHandler() {
336
338
  * @return {void}
337
339
  */
338
340
  function initControlReferences() {
339
- if (!this.shadowRoot) {
340
- throw new Error("no shadow-root is defined");
341
- }
341
+ if (!this.shadowRoot) {
342
+ throw new Error("no shadow-root is defined");
343
+ }
342
344
 
343
- this[PanelElementSymbol] = this.shadowRoot.querySelector(
344
- "[data-monster-role=control]",
345
- );
345
+ this[PanelElementSymbol] = this.shadowRoot.querySelector(
346
+ "[data-monster-role=control]",
347
+ );
346
348
 
347
- this[iframeElementSymbol] = this.shadowRoot.querySelector(
348
- `[${ATTRIBUTE_ROLE}="control"] iframe`,
349
- );
349
+ this[iframeElementSymbol] = this.shadowRoot.querySelector(
350
+ `[${ATTRIBUTE_ROLE}="control"] iframe`,
351
+ );
350
352
  }
351
353
 
352
354
  /**
@@ -354,8 +356,8 @@ function initControlReferences() {
354
356
  * @return {string}
355
357
  */
356
358
  function getTemplate() {
357
- // language=HTML
358
- return `
359
+ // language=HTML
360
+ return `
359
361
  <div data-monster-role="control" part="control">
360
362
  <iframe data-monster-role="iframe"
361
363
  data-monster-attributes="sandbox path:sandbox,
@@ -205,5 +205,6 @@ export { Monster };
205
205
  * @license AGPLv3 or commercial license
206
206
  * @since 2.0.0
207
207
  * @copyright schukai GmbH
208
+ * @memberOf Monster
208
209
  */
209
210
  class Monster {}