@schukai/monster 3.101.1 → 3.101.3

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.
@@ -88,7 +88,7 @@ class TreeSelect extends Select {
88
88
  * The individual configuration values can be found in the table.
89
89
  *
90
90
  * @extends Select
91
- * @property {String} mapping.rootReferences=['0', undefined, null]
91
+ * @property {Array} mapping.rootReferences=['0', undefined, null]
92
92
  * @property {String} mapping.idTemplate=id
93
93
  * @property {String} mapping.parentTemplate=parent
94
94
  * @property {String} mapping.selection
@@ -288,7 +288,6 @@ function formatKeyLabel(node) {
288
288
  * @return {Array}
289
289
  */
290
290
  function buildTreeLabels(value) {
291
-
292
291
  if (!this[internalNodesSymbol]) {
293
292
  return [value];
294
293
  }
@@ -12,20 +12,18 @@
12
12
  * SPDX-License-Identifier: AGPL-3.0
13
13
  */
14
14
 
15
- import {instanceSymbol} from "../../constants.mjs";
15
+ import { instanceSymbol } from "../../constants.mjs";
16
16
  import {
17
- assembleMethodSymbol,
18
- CustomElement,
19
- registerCustomElement,
17
+ assembleMethodSymbol,
18
+ CustomElement,
19
+ registerCustomElement,
20
20
  } from "../../dom/customelement.mjs";
21
- import {CallButtonStyleSheet} from "./stylesheet/call-button.mjs";
22
- import {isArray, isObject, isFunction} from "../../types/is.mjs";
23
- import {
24
- findElementWithSelectorUpwards,
25
- } from "../../dom/util.mjs";
26
- import {ATTRIBUTE_PREFIX} from "../../dom/constants.mjs";
21
+ import { CallButtonStyleSheet } from "./stylesheet/call-button.mjs";
22
+ import { isArray, isObject, isFunction } from "../../types/is.mjs";
23
+ import { findElementWithSelectorUpwards } from "../../dom/util.mjs";
24
+ import { ATTRIBUTE_PREFIX } from "../../dom/constants.mjs";
27
25
 
28
- export {CallButton};
26
+ export { CallButton };
29
27
 
30
28
  /**
31
29
  * @private
@@ -49,69 +47,69 @@ const ATTRIBUTE_CALL = `${ATTRIBUTE_PREFIX}call`;
49
47
  * @summary A call button component that can call a method of another element.
50
48
  */
51
49
  class CallButton extends CustomElement {
52
- /**
53
- * This method is called by the `instanceof` operator.
54
- * @return {symbol}
55
- */
56
- static get [instanceSymbol]() {
57
- return Symbol.for("@schukai/component-host/call-button@@instance");
58
- }
59
-
60
- /**
61
- * To set the options via the HTML tag, the attribute `data-monster-options` must be used.
62
- * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
63
- *
64
- * The individual configuration values can be found in the table.
65
- *
66
- * @property {Object} templates Template definitions
67
- * @property {string} templates.main Main template
68
- */
69
- get defaults() {
70
- return Object.assign(
71
- {},
72
- super.defaults,
73
- {
74
- templates: {
75
- main: getTemplate(),
76
- },
77
- references: {
78
- callableSelector: undefined,
79
- },
80
-
81
- call: undefined,
82
-
83
- labels: {
84
- button: "<slot>Toggle</slot>",
85
- },
86
- },
87
- initOptionsFromArguments.call(this),
88
- );
89
- }
90
-
91
- /**
92
- *
93
- * @return {string}
94
- */
95
- static getTag() {
96
- return "monster-call-button";
97
- }
98
-
99
- /**
100
- * @return {CallButton}
101
- */
102
- [assembleMethodSymbol]() {
103
- super[assembleMethodSymbol]();
104
-
105
- initControlReferences.call(this);
106
- initEventHandler.call(this);
107
- }
108
-
109
- /**
110
- * @return {Array}
111
- */
112
- static getCSSStyleSheet() {
113
- return [CallButtonStyleSheet];
114
- }
50
+ /**
51
+ * This method is called by the `instanceof` operator.
52
+ * @return {symbol}
53
+ */
54
+ static get [instanceSymbol]() {
55
+ return Symbol.for("@schukai/component-host/call-button@@instance");
56
+ }
57
+
58
+ /**
59
+ * To set the options via the HTML tag, the attribute `data-monster-options` must be used.
60
+ * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
61
+ *
62
+ * The individual configuration values can be found in the table.
63
+ *
64
+ * @property {Object} templates Template definitions
65
+ * @property {string} templates.main Main template
66
+ */
67
+ get defaults() {
68
+ return Object.assign(
69
+ {},
70
+ super.defaults,
71
+ {
72
+ templates: {
73
+ main: getTemplate(),
74
+ },
75
+ references: {
76
+ callableSelector: undefined,
77
+ },
78
+
79
+ call: undefined,
80
+
81
+ labels: {
82
+ button: "<slot>Toggle</slot>",
83
+ },
84
+ },
85
+ initOptionsFromArguments.call(this),
86
+ );
87
+ }
88
+
89
+ /**
90
+ *
91
+ * @return {string}
92
+ */
93
+ static getTag() {
94
+ return "monster-call-button";
95
+ }
96
+
97
+ /**
98
+ * @return {CallButton}
99
+ */
100
+ [assembleMethodSymbol]() {
101
+ super[assembleMethodSymbol]();
102
+
103
+ initControlReferences.call(this);
104
+ initEventHandler.call(this);
105
+ }
106
+
107
+ /**
108
+ * @return {Array}
109
+ */
110
+ static getCSSStyleSheet() {
111
+ return [CallButtonStyleSheet];
112
+ }
115
113
  }
116
114
 
117
115
  /**
@@ -119,14 +117,14 @@ class CallButton extends CustomElement {
119
117
  * @return {CallButton}
120
118
  */
121
119
  function initControlReferences() {
122
- if (!this.shadowRoot) {
123
- throw new Error("no shadow-root is defined");
124
- }
125
-
126
- this[callButtonElementSymbol] = this.shadowRoot.querySelector(
127
- "[data-monster-role=control]",
128
- );
129
- return this;
120
+ if (!this.shadowRoot) {
121
+ throw new Error("no shadow-root is defined");
122
+ }
123
+
124
+ this[callButtonElementSymbol] = this.shadowRoot.querySelector(
125
+ "[data-monster-role=control]",
126
+ );
127
+ return this;
130
128
  }
131
129
 
132
130
  /**
@@ -136,26 +134,26 @@ function initControlReferences() {
136
134
  * @throws {Error} the datasource could not be initialized
137
135
  */
138
136
  function initOptionsFromArguments() {
139
- const options = {};
140
- const value = this.getAttribute(ATTRIBUTE_REFERENCE);
141
- if (value) {
142
- if (!isObject(options.references)) {
143
- options.references = {};
144
- }
145
- const selectors = value.split(",");
146
- if (isArray(selectors) && selectors.length === 0) {
147
- throw new TypeError("incorrect arguments passed for the datasource");
148
- }
149
-
150
- options.references.callableSelector = selectors;
151
- }
152
-
153
- const call = this.getAttribute(ATTRIBUTE_CALL);
154
- if (call) {
155
- options.call = call;
156
- }
157
-
158
- return options;
137
+ const options = {};
138
+ const value = this.getAttribute(ATTRIBUTE_REFERENCE);
139
+ if (value) {
140
+ if (!isObject(options.references)) {
141
+ options.references = {};
142
+ }
143
+ const selectors = value.split(",");
144
+ if (isArray(selectors) && selectors.length === 0) {
145
+ throw new TypeError("incorrect arguments passed for the datasource");
146
+ }
147
+
148
+ options.references.callableSelector = selectors;
149
+ }
150
+
151
+ const call = this.getAttribute(ATTRIBUTE_CALL);
152
+ if (call) {
153
+ options.call = call;
154
+ }
155
+
156
+ return options;
159
157
  }
160
158
 
161
159
  /**
@@ -163,28 +161,28 @@ function initOptionsFromArguments() {
163
161
  * @throws {Error} The option references.callableSelector must be an array
164
162
  */
165
163
  function initEventHandler() {
166
- this[callButtonElementSymbol].addEventListener("click", (event) => {
167
- event.preventDefault();
168
-
169
- const selectors = this.getOption("references.callableSelector");
170
- if (!isArray(selectors)) {
171
- throw new Error(
172
- "The option references.callableSelector must be an array",
173
- );
174
- }
175
-
176
- const call = this.getOption("call");
177
- if (!call) {
178
- throw new Error("The option call must be defined");
179
- }
180
-
181
- for (const selector of selectors) {
182
- const element = findElementWithSelectorUpwards(this, selector);
183
- if (element instanceof HTMLElement && isFunction(element?.[call])) {
184
- element[call]();
185
- }
186
- }
187
- });
164
+ this[callButtonElementSymbol].addEventListener("click", (event) => {
165
+ event.preventDefault();
166
+
167
+ const selectors = this.getOption("references.callableSelector");
168
+ if (!isArray(selectors)) {
169
+ throw new Error(
170
+ "The option references.callableSelector must be an array",
171
+ );
172
+ }
173
+
174
+ const call = this.getOption("call");
175
+ if (!call) {
176
+ throw new Error("The option call must be defined");
177
+ }
178
+
179
+ for (const selector of selectors) {
180
+ const element = findElementWithSelectorUpwards(this, selector);
181
+ if (element instanceof HTMLElement && isFunction(element?.[call])) {
182
+ element[call]();
183
+ }
184
+ }
185
+ });
188
186
  }
189
187
 
190
188
  /**
@@ -192,8 +190,8 @@ function initEventHandler() {
192
190
  * @return {string}
193
191
  */
194
192
  function getTemplate() {
195
- // language=HTML
196
- return `
193
+ // language=HTML
194
+ return `
197
195
  <div data-monster-role="control" part="control"
198
196
  data-monster-attributes="class path:references.callableSelector | ?::hidden">
199
197
  <a href="#" data-monster-role="call-button" data-monster-replace="path:labels.button"></a>
@@ -71,7 +71,7 @@ class Viewer extends CustomElement {
71
71
  }
72
72
 
73
73
  /**
74
- *
74
+ *
75
75
  * @param html
76
76
  * @returns {Viewer}
77
77
  */
@@ -358,19 +358,15 @@ function attachResizeObserver() {
358
358
  });
359
359
 
360
360
  requestAnimationFrame(() => {
361
-
362
361
  let parent = this.parentNode;
363
- while(!(parent instanceof HTMLElement) && parent !== null) {
362
+ while (!(parent instanceof HTMLElement) && parent !== null) {
364
363
  parent = parent.parentNode;
365
364
  }
366
365
 
367
366
  if (parent instanceof HTMLElement) {
368
367
  this[resizeObserverSymbol].observe(parent);
369
368
  }
370
-
371
-
372
369
  });
373
-
374
370
  }
375
371
 
376
372
  function disconnectResizeObserver() {