@schukai/monster 3.97.1 → 3.98.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 +20 -0
- package/package.json +1 -1
- package/source/components/accessibility/locale-picker.mjs +549 -543
- package/source/components/datatable/columnbar.mjs +50 -3
- package/source/components/datatable/constants.mjs +7 -0
- package/source/components/datatable/datatable/header.mjs +1 -0
- package/source/components/datatable/datatable.mjs +1168 -942
- package/source/components/datatable/filter/date-range.mjs +145 -14
- package/source/components/datatable/filter/input.mjs +50 -3
- package/source/components/datatable/filter/range.mjs +92 -7
- package/source/components/datatable/filter-button.mjs +46 -3
- package/source/components/datatable/filter.mjs +95 -10
- package/source/components/datatable/pagination.mjs +82 -7
- package/source/components/datatable/save-button.mjs +46 -3
- package/source/components/datatable/style/datatable.pcss +1 -0
- package/source/components/datatable/stylesheet/datatable.mjs +7 -14
- package/source/components/form/field-set.mjs +77 -6
- package/source/components/form/select.mjs +149 -30
- package/source/components/layout/details.mjs +50 -3
- package/source/components/layout/tabs.mjs +50 -3
- package/source/components/notify/monitor-attribute-errors.mjs +235 -0
- package/source/components/notify/style/monitor-attribute-errors.pcss +0 -0
- package/source/components/notify/stylesheet/monitor-attribute-errors.mjs +38 -0
- package/source/dom/customelement.mjs +3 -3
- package/source/i18n/util.mjs +122 -122
- package/source/types/version.mjs +1 -1
- package/test/cases/monster.mjs +1 -1
- package/test/web/import.js +1 -0
- package/test/web/test.html +2 -2
- package/test/web/tests.js +432 -13
File without changes
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright © schukai GmbH and all contributing authors, 2025. All rights reserved.
|
3
|
+
* Node module: @schukai/monster
|
4
|
+
*
|
5
|
+
* This source code is licensed under the GNU Affero General Public License version 3 (AGPLv3).
|
6
|
+
* The full text of the license can be found at: https://www.gnu.org/licenses/agpl-3.0.en.html
|
7
|
+
*
|
8
|
+
* For those who do not wish to adhere to the AGPLv3, a commercial license is available.
|
9
|
+
* Acquiring a commercial license allows you to use this software without complying with the AGPLv3 terms.
|
10
|
+
* For more information about purchasing a commercial license, please contact schukai GmbH.
|
11
|
+
*/
|
12
|
+
|
13
|
+
import { addAttributeToken } from "../../../dom/attributes.mjs";
|
14
|
+
import { ATTRIBUTE_ERRORMESSAGE } from "../../../dom/constants.mjs";
|
15
|
+
|
16
|
+
export { MonitorAttributeErrorsStyleSheet };
|
17
|
+
|
18
|
+
/**
|
19
|
+
* @private
|
20
|
+
* @type {CSSStyleSheet}
|
21
|
+
*/
|
22
|
+
const MonitorAttributeErrorsStyleSheet = new CSSStyleSheet();
|
23
|
+
|
24
|
+
try {
|
25
|
+
MonitorAttributeErrorsStyleSheet.insertRule(
|
26
|
+
`
|
27
|
+
@layer monitorattributeerrors {
|
28
|
+
|
29
|
+
}`,
|
30
|
+
0,
|
31
|
+
);
|
32
|
+
} catch (e) {
|
33
|
+
addAttributeToken(
|
34
|
+
document.getRootNode().querySelector("html"),
|
35
|
+
ATTRIBUTE_ERRORMESSAGE,
|
36
|
+
e + "",
|
37
|
+
);
|
38
|
+
}
|
@@ -235,7 +235,7 @@ class CustomElement extends HTMLElement {
|
|
235
235
|
*
|
236
236
|
* @param attribute
|
237
237
|
* @param callback
|
238
|
-
* @return {
|
238
|
+
* @return {CustomElement}
|
239
239
|
*/
|
240
240
|
addAttributeObserver(attribute, callback) {
|
241
241
|
validateFunction(callback);
|
@@ -246,7 +246,7 @@ class CustomElement extends HTMLElement {
|
|
246
246
|
/**
|
247
247
|
*
|
248
248
|
* @param attribute
|
249
|
-
* @return {
|
249
|
+
* @return {CustomElement}
|
250
250
|
*/
|
251
251
|
removeAttributeObserver(attribute) {
|
252
252
|
delete this[attributeObserverSymbol][attribute];
|
@@ -308,7 +308,7 @@ class CustomElement extends HTMLElement {
|
|
308
308
|
*
|
309
309
|
* Before you can use this method, you must have loaded the translations.
|
310
310
|
*
|
311
|
-
* @return {
|
311
|
+
* @return {CustomElement}
|
312
312
|
* @throws {Error} Cannot find an element with translations. Add a translation object to the document.
|
313
313
|
*/
|
314
314
|
updateI18n() {
|
package/source/i18n/util.mjs
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
* SPDX-License-Identifier: AGPL-3.0
|
13
13
|
*/
|
14
14
|
|
15
|
-
import {languages} from "./map/languages.mjs";
|
15
|
+
import { languages } from "./map/languages.mjs";
|
16
16
|
|
17
17
|
/**
|
18
18
|
* Determines the user's preferred language based on browser settings and available language options.
|
@@ -23,125 +23,125 @@ import {languages} from "./map/languages.mjs";
|
|
23
23
|
* @return {Object} An object containing information about the detected language, preferred language, and available languages.
|
24
24
|
*/
|
25
25
|
export function detectUserLanguagePreference() {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
26
|
+
const currentLang = document.documentElement.lang;
|
27
|
+
|
28
|
+
let preferredLanguages = [];
|
29
|
+
|
30
|
+
if (typeof navigator.language === "string" && navigator.language.length > 0) {
|
31
|
+
preferredLanguages = [navigator.language];
|
32
|
+
}
|
33
|
+
|
34
|
+
if (Array.isArray(navigator.languages) && navigator.languages.length > 0) {
|
35
|
+
preferredLanguages = navigator.languages;
|
36
|
+
}
|
37
|
+
|
38
|
+
// add to preferredLanguages all the base languages of the preferred languages
|
39
|
+
preferredLanguages = preferredLanguages.concat(
|
40
|
+
preferredLanguages.map((lang) => lang.split("-")[0]),
|
41
|
+
);
|
42
|
+
|
43
|
+
if (!currentLang && preferredLanguages.length === 0) {
|
44
|
+
return {
|
45
|
+
message: "No language information available.",
|
46
|
+
};
|
47
|
+
}
|
48
|
+
|
49
|
+
const linkTags = document.querySelectorAll("link[hreflang]");
|
50
|
+
if (linkTags.length === 0) {
|
51
|
+
return {
|
52
|
+
current: currentLang || null,
|
53
|
+
message: "No <link> tags with hreflang available.",
|
54
|
+
};
|
55
|
+
}
|
56
|
+
|
57
|
+
const availableLanguages = [...linkTags].map((link) => {
|
58
|
+
const fullLang = link.hreflang;
|
59
|
+
const baseLang = fullLang.split("-")[0];
|
60
|
+
let label = link.getAttribute("data-monster-label");
|
61
|
+
if (!label) {
|
62
|
+
label = link.getAttribute("title");
|
63
|
+
if (!label) {
|
64
|
+
label = languages?.[fullLang];
|
65
|
+
if (!label) {
|
66
|
+
label = languages?.[baseLang];
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
return {
|
72
|
+
fullLang,
|
73
|
+
baseLang,
|
74
|
+
label,
|
75
|
+
href: link.href,
|
76
|
+
};
|
77
|
+
});
|
78
|
+
|
79
|
+
// filter availableLanguages to only include languages that are in the preferredLanguages array
|
80
|
+
const offerableLanguages = availableLanguages.filter(
|
81
|
+
(lang) =>
|
82
|
+
preferredLanguages.includes(lang.fullLang) ||
|
83
|
+
preferredLanguages.includes(lang.baseLang),
|
84
|
+
);
|
85
|
+
|
86
|
+
if (offerableLanguages.length === 0) {
|
87
|
+
return {
|
88
|
+
current: currentLang || null,
|
89
|
+
message: "No available languages match the user's preferences.",
|
90
|
+
available: availableLanguages.map((lang) => ({
|
91
|
+
...lang,
|
92
|
+
weight: 1,
|
93
|
+
})),
|
94
|
+
};
|
95
|
+
}
|
96
|
+
|
97
|
+
// Helper function to determine the "weight" of a language match
|
98
|
+
function getWeight(langEntry) {
|
99
|
+
// Full match has priority 3
|
100
|
+
if (preferredLanguages.includes(langEntry.fullLang)) return 3;
|
101
|
+
// Base language match has priority 2
|
102
|
+
if (preferredLanguages.includes(langEntry.baseLang)) return 2;
|
103
|
+
// No match is priority 1
|
104
|
+
return 1;
|
105
|
+
}
|
106
|
+
|
107
|
+
// Sort the available languages by descending weight
|
108
|
+
offerableLanguages.sort((a, b) => getWeight(b) - getWeight(a));
|
109
|
+
|
110
|
+
// The best match is the first in the sorted list
|
111
|
+
const bestMatch = offerableLanguages[0];
|
112
|
+
const bestMatchWeight = getWeight(bestMatch);
|
113
|
+
|
114
|
+
const currentLabel = languages?.[currentLang] || currentLang;
|
115
|
+
|
116
|
+
// If we found a language that matches user preferences (weight > 1)
|
117
|
+
if (bestMatchWeight > 0) {
|
118
|
+
return {
|
119
|
+
current: currentLang || null,
|
120
|
+
currentLabel: currentLabel,
|
121
|
+
preferred: {
|
122
|
+
full: bestMatch.fullLang,
|
123
|
+
base: bestMatch.baseLang,
|
124
|
+
label: bestMatch.label,
|
125
|
+
href: bestMatch.href,
|
126
|
+
},
|
127
|
+
available: availableLanguages.map((lang) => ({
|
128
|
+
...lang,
|
129
|
+
weight: getWeight(lang),
|
130
|
+
})),
|
131
|
+
offerable: offerableLanguages.map((lang) => ({
|
132
|
+
...lang,
|
133
|
+
weight: getWeight(lang),
|
134
|
+
})),
|
135
|
+
};
|
136
|
+
}
|
137
|
+
|
138
|
+
// If no language matched the user's preferences
|
139
|
+
return {
|
140
|
+
current: currentLang || null,
|
141
|
+
message: "None of the preferred languages are available.",
|
142
|
+
available: availableLanguages.map((lang) => ({
|
143
|
+
...lang,
|
144
|
+
weight: getWeight(lang),
|
145
|
+
})),
|
146
|
+
};
|
147
147
|
}
|
package/source/types/version.mjs
CHANGED
package/test/cases/monster.mjs
CHANGED
package/test/web/import.js
CHANGED
package/test/web/test.html
CHANGED
@@ -9,8 +9,8 @@
|
|
9
9
|
</head>
|
10
10
|
<body>
|
11
11
|
<div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
|
12
|
-
<h1 style='margin-bottom: 0.1em;'>Monster 3.
|
13
|
-
<div id="lastupdate" style='font-size:0.7em'>last update
|
12
|
+
<h1 style='margin-bottom: 0.1em;'>Monster 3.97.1</h1>
|
13
|
+
<div id="lastupdate" style='font-size:0.7em'>last update So 5. Jan 14:38:20 CET 2025</div>
|
14
14
|
</div>
|
15
15
|
<div id="mocha-errors"
|
16
16
|
style="color: red;font-weight: bold;display: flex;align-items: center;justify-content: center;flex-direction: column;margin:20px;"></div>
|