@schukai/monster 4.42.2 → 4.43.1
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 +16 -0
- package/package.json +1 -1
- package/source/components/form/quantity.mjs +30 -3
- package/source/components/navigation/site-navigation.mjs +286 -0
- package/source/components/navigation/style/site-navigation.pcss +59 -0
- package/source/components/navigation/stylesheet/site-navigation.mjs +31 -0
- package/source/dom/customelement.mjs +964 -962
- package/source/dom/slotted.mjs +87 -87
- package/source/types/is.mjs +74 -64
- package/source/types/typeof.mjs +24 -15
package/source/dom/slotted.mjs
CHANGED
@@ -28,46 +28,46 @@ export { getSlottedElements, getSlottedNodes };
|
|
28
28
|
* @throws {Error} query must be a string
|
29
29
|
*/
|
30
30
|
function getSlottedNodes(query, name) {
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
31
|
+
const result = new Set();
|
32
|
+
|
33
|
+
if (!this.shadowRoot) {
|
34
|
+
return result;
|
35
|
+
}
|
36
|
+
|
37
|
+
let selector = "slot";
|
38
|
+
if (name !== undefined) {
|
39
|
+
if (name === null) {
|
40
|
+
selector += ":not([name])";
|
41
|
+
} else {
|
42
|
+
selector += `[name=${validateString(name)}]`;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
const slots = this.shadowRoot.querySelectorAll(selector);
|
47
|
+
|
48
|
+
for (const [, slot] of Object.entries(slots)) {
|
49
|
+
slot.assignedNodes().forEach(function (node) {
|
50
|
+
if (node === null || node === undefined) {
|
51
|
+
return;
|
52
|
+
}
|
53
|
+
|
54
|
+
if (isString(query)) {
|
55
|
+
node.querySelectorAll(query).forEach(function (n) {
|
56
|
+
result.add(n);
|
57
|
+
});
|
58
|
+
|
59
|
+
if (node.matches(query)) {
|
60
|
+
result.add(node);
|
61
|
+
}
|
62
|
+
} else if (query !== undefined) {
|
63
|
+
throw new Error("query must be a string");
|
64
|
+
} else {
|
65
|
+
result.add(node);
|
66
|
+
}
|
67
|
+
});
|
68
|
+
}
|
69
|
+
|
70
|
+
return result;
|
71
71
|
}
|
72
72
|
|
73
73
|
/**
|
@@ -81,51 +81,51 @@ function getSlottedNodes(query, name) {
|
|
81
81
|
* @throws {Error} query must be a string
|
82
82
|
*/
|
83
83
|
function getSlottedElements(query, name) {
|
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
|
-
|
84
|
+
const result = new Set();
|
85
|
+
|
86
|
+
if (!(this.shadowRoot instanceof ShadowRoot)) {
|
87
|
+
return result;
|
88
|
+
}
|
89
|
+
|
90
|
+
let selector = "slot";
|
91
|
+
if (name !== undefined) {
|
92
|
+
if (name === null) {
|
93
|
+
selector += ":not([name])";
|
94
|
+
} else {
|
95
|
+
selector += `[name=${validateString(name)}]`;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
const slots = this.shadowRoot.querySelectorAll(selector);
|
100
|
+
|
101
|
+
for (const [, slot] of Object.entries(slots)) {
|
102
|
+
slot.assignedElements().forEach(function (node) {
|
103
|
+
if (
|
104
|
+
!(node instanceof HTMLElement) &&
|
105
|
+
!(node instanceof SVGElement) &&
|
106
|
+
!(node instanceof MathMLElement)
|
107
|
+
)
|
108
|
+
return;
|
109
|
+
|
110
|
+
if (isString(query)) {
|
111
|
+
if (query.length > 0) {
|
112
|
+
node.querySelectorAll(query).forEach(function (n) {
|
113
|
+
result.add(n);
|
114
|
+
});
|
115
|
+
|
116
|
+
if (node.matches(query)) {
|
117
|
+
result.add(node);
|
118
|
+
}
|
119
|
+
} else {
|
120
|
+
result.add(node);
|
121
|
+
}
|
122
|
+
} else if (query !== undefined) {
|
123
|
+
throw new Error("query must be a string and not empty");
|
124
|
+
} else {
|
125
|
+
result.add(node);
|
126
|
+
}
|
127
|
+
});
|
128
|
+
}
|
129
|
+
|
130
|
+
return result;
|
131
131
|
}
|
package/source/types/is.mjs
CHANGED
@@ -15,19 +15,29 @@
|
|
15
15
|
import { proxyInstanceMarker } from "../constants.mjs";
|
16
16
|
|
17
17
|
export {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
18
|
+
isIterable,
|
19
|
+
isPrimitive,
|
20
|
+
isSymbol,
|
21
|
+
isBoolean,
|
22
|
+
isString,
|
23
|
+
isObject,
|
24
|
+
isInstance,
|
25
|
+
isArray,
|
26
|
+
isFunction,
|
27
|
+
isInteger,
|
28
|
+
isProxy,
|
29
|
+
isElement,
|
29
30
|
};
|
30
31
|
|
32
|
+
/**
|
33
|
+
* Checks whether the value passed is a DOM Element.
|
34
|
+
* @param {*} value
|
35
|
+
* @returns {boolean}
|
36
|
+
*/
|
37
|
+
function isElement(value) {
|
38
|
+
return value instanceof Element;
|
39
|
+
}
|
40
|
+
|
31
41
|
/**
|
32
42
|
* Checks whether the value passed is a Proxy.
|
33
43
|
*
|
@@ -35,7 +45,7 @@ export {
|
|
35
45
|
* @returns {boolean}
|
36
46
|
*/
|
37
47
|
function isProxy(value) {
|
38
|
-
|
48
|
+
return value?.[proxyInstanceMarker] === proxyInstanceMarker;
|
39
49
|
}
|
40
50
|
|
41
51
|
/**
|
@@ -53,9 +63,9 @@ function isProxy(value) {
|
|
53
63
|
* @copyright schukai GmbH
|
54
64
|
*/
|
55
65
|
function isIterable(value) {
|
56
|
-
|
57
|
-
|
58
|
-
|
66
|
+
if (value === undefined) return false;
|
67
|
+
if (value === null) return false;
|
68
|
+
return typeof value?.[Symbol.iterator] === "function";
|
59
69
|
}
|
60
70
|
|
61
71
|
/**
|
@@ -71,24 +81,24 @@ function isIterable(value) {
|
|
71
81
|
* @copyright schukai GmbH
|
72
82
|
*/
|
73
83
|
function isPrimitive(value) {
|
74
|
-
|
84
|
+
var type;
|
75
85
|
|
76
|
-
|
77
|
-
|
78
|
-
|
86
|
+
if (value === undefined || value === null) {
|
87
|
+
return true;
|
88
|
+
}
|
79
89
|
|
80
|
-
|
90
|
+
type = typeof value;
|
81
91
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
92
|
+
if (
|
93
|
+
type === "string" ||
|
94
|
+
type === "number" ||
|
95
|
+
type === "boolean" ||
|
96
|
+
type === "symbol"
|
97
|
+
) {
|
98
|
+
return true;
|
99
|
+
}
|
90
100
|
|
91
|
-
|
101
|
+
return false;
|
92
102
|
}
|
93
103
|
|
94
104
|
/**
|
@@ -104,7 +114,7 @@ function isPrimitive(value) {
|
|
104
114
|
* @copyright schukai GmbH
|
105
115
|
*/
|
106
116
|
function isSymbol(value) {
|
107
|
-
|
117
|
+
return "symbol" === typeof value ? true : false;
|
108
118
|
}
|
109
119
|
|
110
120
|
/**
|
@@ -120,11 +130,11 @@ function isSymbol(value) {
|
|
120
130
|
* @copyright schukai GmbH
|
121
131
|
*/
|
122
132
|
function isBoolean(value) {
|
123
|
-
|
124
|
-
|
125
|
-
|
133
|
+
if (value === true || value === false) {
|
134
|
+
return true;
|
135
|
+
}
|
126
136
|
|
127
|
-
|
137
|
+
return false;
|
128
138
|
}
|
129
139
|
|
130
140
|
/**
|
@@ -140,10 +150,10 @@ function isBoolean(value) {
|
|
140
150
|
* @copyright schukai GmbH
|
141
151
|
*/
|
142
152
|
function isString(value) {
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
153
|
+
if (value === undefined || typeof value !== "string") {
|
154
|
+
return false;
|
155
|
+
}
|
156
|
+
return true;
|
147
157
|
}
|
148
158
|
|
149
159
|
/**
|
@@ -159,14 +169,14 @@ function isString(value) {
|
|
159
169
|
* @copyright schukai GmbH
|
160
170
|
*/
|
161
171
|
function isObject(value) {
|
162
|
-
|
163
|
-
|
172
|
+
if (isArray(value)) return false;
|
173
|
+
if (isPrimitive(value)) return false;
|
164
174
|
|
165
|
-
|
166
|
-
|
167
|
-
|
175
|
+
if (typeof value === "object") {
|
176
|
+
return true;
|
177
|
+
}
|
168
178
|
|
169
|
-
|
179
|
+
return false;
|
170
180
|
}
|
171
181
|
|
172
182
|
/**
|
@@ -183,18 +193,18 @@ function isObject(value) {
|
|
183
193
|
* @copyright schukai GmbH
|
184
194
|
*/
|
185
195
|
function isInstance(value, instance) {
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
196
|
+
if (!isObject(value)) return false;
|
197
|
+
if (!isFunction(instance)) return false;
|
198
|
+
if (!instance.hasOwnProperty("prototype")) return false;
|
199
|
+
if (value instanceof instance) return true;
|
200
|
+
|
201
|
+
let proto = Object.getPrototypeOf(value);
|
202
|
+
while (proto != null) {
|
203
|
+
if (proto === instance.prototype) return true;
|
204
|
+
proto = Object.getPrototypeOf(proto);
|
205
|
+
}
|
206
|
+
|
207
|
+
return false;
|
198
208
|
}
|
199
209
|
|
200
210
|
/**
|
@@ -211,7 +221,7 @@ function isInstance(value, instance) {
|
|
211
221
|
* @see https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
|
212
222
|
*/
|
213
223
|
function isArray(value) {
|
214
|
-
|
224
|
+
return Array.isArray(value);
|
215
225
|
}
|
216
226
|
|
217
227
|
/**
|
@@ -227,14 +237,14 @@ function isArray(value) {
|
|
227
237
|
* @copyright schukai GmbH
|
228
238
|
*/
|
229
239
|
function isFunction(value) {
|
230
|
-
|
231
|
-
|
240
|
+
if (isArray(value)) return false;
|
241
|
+
if (isPrimitive(value)) return false;
|
232
242
|
|
233
|
-
|
234
|
-
|
235
|
-
|
243
|
+
if (typeof value === "function") {
|
244
|
+
return true;
|
245
|
+
}
|
236
246
|
|
237
|
-
|
247
|
+
return false;
|
238
248
|
}
|
239
249
|
|
240
250
|
/**
|
@@ -250,5 +260,5 @@ function isFunction(value) {
|
|
250
260
|
* @copyright schukai GmbH
|
251
261
|
*/
|
252
262
|
function isInteger(value) {
|
253
|
-
|
263
|
+
return Number.isInteger(value);
|
254
264
|
}
|
package/source/types/typeof.mjs
CHANGED
@@ -15,7 +15,8 @@
|
|
15
15
|
export { typeOf };
|
16
16
|
|
17
17
|
/**
|
18
|
-
* The built-in typeof method is known to have some historical weaknesses.
|
18
|
+
* The built-in typeof method is known to have some historical weaknesses.
|
19
|
+
* This function tries to provide a better and more accurate result.
|
19
20
|
*
|
20
21
|
* @param {*} value
|
21
22
|
* @return {string}
|
@@ -25,18 +26,26 @@ export { typeOf };
|
|
25
26
|
* @throws {TypeError} value is not a primitive
|
26
27
|
*/
|
27
28
|
function typeOf(value) {
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
29
|
+
if (value === null) {
|
30
|
+
return "null";
|
31
|
+
}
|
32
|
+
|
33
|
+
const baseType = typeof value;
|
34
|
+
|
35
|
+
if (baseType !== "object" && baseType !== "function") {
|
36
|
+
return baseType;
|
37
|
+
}
|
38
|
+
|
39
|
+
const internalType = {}.toString.call(value).slice(8, -1);
|
40
|
+
|
41
|
+
if (internalType !== "Object") {
|
42
|
+
return internalType.toLowerCase();
|
43
|
+
}
|
44
|
+
|
45
|
+
const constructorName = value.constructor?.name;
|
46
|
+
if (constructorName && constructorName !== "Object") {
|
47
|
+
return constructorName.toLowerCase();
|
48
|
+
}
|
49
|
+
|
50
|
+
return "object";
|
42
51
|
}
|