@schukai/monster 3.104.1 → 3.105.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 CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
 
4
4
 
5
+ ## [3.105.1] - 2025-02-06
6
+
7
+ ### Bug Fixes
8
+
9
+ - **select:** lookup after setSelection
10
+
11
+
12
+
13
+ ## [3.105.0] - 2025-02-05
14
+
15
+ ### Add Features
16
+
17
+ - new internal Translation
18
+
19
+
20
+
5
21
  ## [3.104.1] - 2025-02-04
6
22
 
7
23
  ### Bug Fixes
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.13","@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.104.1"}
1
+ {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.13","@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.105.1"}
@@ -314,7 +314,7 @@ function getTemplate() {
314
314
  <button data-monster-attributes="disabled path:disabled | if:true,
315
315
  class path:classes.button,
316
316
  aria-role path:aria.role,
317
- path:aria.label | if:true,
317
+ path:aria.label | if:true,
318
318
  type path:type"
319
319
  data-monster-role="button"
320
320
  part="button"
@@ -2282,6 +2282,7 @@ function isValueIsEmptyThenGetNormalize(value) {
2282
2282
  * @returns {Promise<unknown | void>}
2283
2283
  */
2284
2284
  function setSelection(selection) {
2285
+ const self = this;
2285
2286
 
2286
2287
  if (isString(selection) || isInteger(selection)) {
2287
2288
  const result = convertValueToSelection.call(this, selection);
@@ -2328,6 +2329,14 @@ function setSelection(selection) {
2328
2329
 
2329
2330
  fireEvent(this, "change"); // https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/291
2330
2331
 
2332
+ const lazyLoadFlag =
2333
+ this.getOption("features.lazyLoad") && this[lazyLoadDoneSymbol] !== true;
2334
+ let remoteFilterFlag = getFilterMode.call(this) === FILTER_MODE_REMOTE;
2335
+
2336
+ if (lazyLoadFlag || remoteFilterFlag) {
2337
+ lookupSelection.call(self);
2338
+ }
2339
+
2331
2340
  return new Processing(() => {
2332
2341
  const CLASSNAME = "selected";
2333
2342
 
@@ -19,6 +19,7 @@ import { Server } from "../server.mjs";
19
19
  import { WriteError } from "./restapi/writeerror.mjs";
20
20
  import { DataFetchError } from "./restapi/data-fetch-error.mjs";
21
21
  import { clone } from "../../../util/clone.mjs";
22
+ import {getInternalLocalizationMessage} from "../../../i18n/internal.mjs";
22
23
 
23
24
  export { RestAPI };
24
25
 
@@ -224,7 +225,9 @@ function fetchData(init, key, callback) {
224
225
 
225
226
  if (acceptedStatus.indexOf(resp.status) === -1) {
226
227
  throw new DataFetchError(
227
- `the response does not contain an accepted status (actual: ${resp.status}).`,
228
+ getInternalLocalizationMessage(
229
+ `i18n{the-response-does-not-contain-an-accepted-status::status=${resp.status}}`
230
+ ),
228
231
  response,
229
232
  );
230
233
  }
@@ -244,7 +247,9 @@ function fetchData(init, key, callback) {
244
247
  }
245
248
 
246
249
  throw new DataFetchError(
247
- `the response does not contain a valid json (actual: ${body}).`,
250
+ getInternalLocalizationMessage(
251
+ `i18n{the-response-does-not-contain-a-valid-json::actual=${body}}`
252
+ ),
248
253
  response,
249
254
  );
250
255
  }
@@ -39,6 +39,8 @@ class Formatter extends TextFormatter {
39
39
  * Default values for the markers are `${` and `}`
40
40
  *
41
41
  * @param {object} object
42
+ * @param {Translations} translation
43
+ * @param {object} [options]
42
44
  * @throws {TypeError} value is not a object
43
45
  */
44
46
  constructor(object, translation, options) {
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Copyright © schukai GmbH and all contributing authors, {{copyRightYear}}. 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
+ * SPDX-License-Identifier: AGPL-3.0
13
+ */
14
+
15
+ import {Formatter} from "./formatter.mjs";
16
+ import {getLocaleOfDocument} from "../dom/locale.mjs";
17
+ import {Translations} from "./translations.mjs";
18
+
19
+ export {getInternalLocalizationMessage};
20
+
21
+ let internalTranslations = null;
22
+ getInternalTranslations();
23
+
24
+
25
+ function getInternalTranslations() {
26
+
27
+ if (internalTranslations) {
28
+ return internalTranslations;
29
+ }
30
+
31
+ let locale = "en";
32
+ try {
33
+ let locale = getLocaleOfDocument();
34
+ } catch (error) {
35
+ }
36
+
37
+ let messages = {};
38
+
39
+ switch (locale.language) {
40
+ case "de":
41
+ messages = {
42
+ "the-response-does-not-contain-an-accepted-status": `Der Server hat die Anfrage nicht akzeptiert (Status \${status}).`,
43
+ "the-response-does-not-contain-a-valid-json": `Die Antwort des Servers ist kein gültiges JSON (actual=\${actual}).`,
44
+ };
45
+ break;
46
+ case "es":
47
+ messages = {
48
+ "the-response-does-not-contain-an-accepted-status": `El servidor no ha aceptado la solicitud (Estado \${status}).`,
49
+ "the-response-does-not-contain-a-valid-json": `La respuesta del servidor no es un JSON válido (actual=\${actual}).`,
50
+ };
51
+ break;
52
+ case "zh":
53
+ messages = {
54
+ "the-response-does-not-contain-an-accepted-status": `服务器未接受请求(状态 \${status})。`,
55
+ "the-response-does-not-contain-a-valid-json": `服务器响应不是有效的JSON(实际=\${actual})。`,
56
+ };
57
+ break;
58
+ case "fr":
59
+ messages = {
60
+ "the-response-does-not-contain-an-accepted-status": `Le serveur n'a pas accepté la demande (Statut \${status}).`,
61
+ "the-response-does-not-contain-a-valid-json": `La réponse du serveur n'est pas un JSON valide (actuel=\${actual}).`,
62
+ };
63
+ break;
64
+ case "it":
65
+ messages = {
66
+ "the-response-does-not-contain-an-accepted-status": `Il server non ha accettato la richiesta (Stato \${status}).`,
67
+ "the-response-does-not-contain-a-valid-json": `La risposta del server non è un JSON valido (attuale=\${actual}).`,
68
+ };
69
+ break;
70
+ case "nl":
71
+ messages = {
72
+ "the-response-does-not-contain-an-accepted-status": `De server heeft het verzoek niet geaccepteerd (Status \${status}).`,
73
+ "the-response-does-not-contain-a-valid-json": `De serverrespons is geen geldige JSON (actueel=\${actual}).`,
74
+ };
75
+ break;
76
+ case "sv":
77
+ messages = {
78
+ "the-response-does-not-contain-an-accepted-status": `Servern accepterade inte begäran (Status \${status}).`,
79
+ "the-response-does-not-contain-a-valid-json": `Serverns svar är inte en giltig JSON (faktisk=\${actual}).`,
80
+ };
81
+ break;
82
+ case "pl":
83
+ messages = {
84
+ "the-response-does-not-contain-an-accepted-status": `Serwer nie zaakceptował żądania (Status \${status}).`,
85
+ "the-response-does-not-contain-a-valid-json": `Odpowiedź serwera nie jest prawidłowym JSON-em (aktualne=\${actual}).`,
86
+ };
87
+ break;
88
+ case "da":
89
+ messages = {
90
+ "the-response-does-not-contain-an-accepted-status": `Serveren accepterede ikke forespørgslen (Status \${status}).`,
91
+ "the-response-does-not-contain-a-valid-json": `Serverens svar er ikke en gyldig JSON (aktuel=\${actual}).`,
92
+ };
93
+ break;
94
+ case "fi":
95
+ messages = {
96
+ "the-response-does-not-contain-an-accepted-status": `Palvelin ei hyväksynyt pyyntöä (Tila \${status}).`,
97
+ "the-response-does-not-contain-a-valid-json": `Palvelimen vastaus ei ole kelvollinen JSON (todellinen=\${actual}).`,
98
+ };
99
+ break;
100
+ case "no":
101
+ messages = {
102
+ "the-response-does-not-contain-an-accepted-status": `Serveren aksepterte ikke forespørselen (Status \${status}).`,
103
+ "the-response-does-not-contain-a-valid-json": `Serverens respons er ikke en gyldig JSON (faktisk=\${actual}).`,
104
+ };
105
+ break;
106
+ case "cs":
107
+ messages = {
108
+ "the-response-does-not-contain-an-accepted-status": `Server nepřijal požadavek (Stav \${status}).`,
109
+ "the-response-does-not-contain-a-valid-json": `Odpověď serveru není platný JSON (skutečný=\${actual}).`,
110
+ };
111
+ break;
112
+ default: // English
113
+ messages = {
114
+ "the-response-does-not-contain-an-accepted-status": `The server did not accept the request (Status \${status}).`,
115
+ "the-response-does-not-contain-a-valid-json": `The server response is not a valid JSON (actual=\${actual}).`,
116
+ };
117
+ }
118
+
119
+
120
+ const translation = new Translations(locale);
121
+ translation.assignTranslations(messages);
122
+
123
+ internalTranslations = translation;
124
+
125
+ return translation
126
+ }
127
+
128
+
129
+ /**
130
+ * Returns the internal localization message.
131
+ * @param message
132
+ * @returns {string}
133
+ */
134
+
135
+ function getInternalLocalizationMessage(message) {
136
+ const formatter = new Formatter({}, getInternalTranslations());
137
+ return formatter.format(message);
138
+
139
+ }
@@ -12,6 +12,35 @@
12
12
  * SPDX-License-Identifier: AGPL-3.0
13
13
  */
14
14
 
15
+ /**
16
+ * Curretnly from Monster supported languages.
17
+ * @type {string[]}
18
+ */
19
+ export const currentSupportedLanguages = [
20
+ "en", // English
21
+ "de", // German
22
+ "es", // Spanish
23
+ "zh", // Mandarin
24
+ "hi", // Hindi
25
+ "bn", // Bengali
26
+ "pt", // Portuguese
27
+ "ru", // Russian
28
+ "ja", // Japanese
29
+ "pa", // Western Punjabi
30
+ "mr", // Marathi
31
+ "fr", // French
32
+ "it", // Italian
33
+ "nl", // Dutch
34
+ "sv", // Swedish
35
+ "pl", // Polish
36
+ "da", // Danish
37
+ "fi", // Finnish
38
+ "no", // Norwegian
39
+ "cs" // Czech
40
+ ];
41
+
42
+
43
+
15
44
  export const languages = {
16
45
  en: "English",
17
46
  "en-GB": "English (United Kingdom)",
@@ -13,12 +13,12 @@
13
13
  */
14
14
 
15
15
  import {
16
- validateFunction,
17
- validateObject,
18
- validateString,
16
+ validateFunction,
17
+ validateObject,
18
+ validateString,
19
19
  } from "./validate.mjs";
20
20
 
21
- export { getGlobal, getGlobalObject, getGlobalFunction };
21
+ export {getGlobal, getGlobalObject, getGlobalFunction};
22
22
 
23
23
  /**
24
24
  * @type {object}
@@ -31,39 +31,40 @@ let globalReference;
31
31
  * @throws {Error} unsupported environment.
32
32
  */
33
33
  (function () {
34
- if (typeof globalThis === "object") {
35
- globalReference = globalThis;
36
- return;
37
- }
34
+ if (typeof globalThis === "object") {
35
+ globalReference = globalThis;
36
+ return;
37
+ }
38
38
 
39
- if (typeof self !== "undefined") {
40
- globalReference = self;
41
- return;
42
- } else if (typeof window !== "undefined") {
43
- globalReference = window;
44
- return;
45
- }
39
+ if (typeof self !== "undefined") {
40
+ globalReference = self;
41
+ return;
42
+ } else if (typeof window !== "undefined") {
43
+ globalReference = window;
44
+ return;
45
+ }
46
46
 
47
- Object.defineProperty(Object.prototype, "__monster__", {
48
- get: function () {
49
- return this;
50
- },
51
- configurable: true,
52
- });
47
+ Object.defineProperty(Object.prototype, "__monster__", {
48
+ get: function () {
49
+ return this;
50
+ },
51
+ configurable: true,
52
+ });
53
53
 
54
- if (typeof __monster__ === "object") {
55
- __monster__.globalThis = __monster__;
56
- delete Object.prototype.__monster__;
54
+ if (typeof __monster__ === "object") {
55
+ __monster__.globalThis = __monster__;
56
+ delete Object.prototype.__monster__;
57
57
 
58
- globalReference = globalThis;
59
- return;
60
- }
58
+ globalReference = globalThis;
59
+ return;
60
+ }
61
61
 
62
- try {
63
- globalReference = Function("return this")();
64
- } catch (e) {}
62
+ try {
63
+ globalReference = Function("return this")();
64
+ } catch (e) {
65
+ }
65
66
 
66
- throw new Error("unsupported environment.");
67
+ throw new Error("unsupported environment.");
67
68
  })();
68
69
 
69
70
  /**
@@ -76,7 +77,7 @@ let globalReference;
76
77
  * @return {object} globalThis
77
78
  */
78
79
  function getGlobal() {
79
- return globalReference;
80
+ return globalReference;
80
81
  }
81
82
 
82
83
  /**
@@ -111,12 +112,12 @@ function getGlobal() {
111
112
  * @throws {TypeError} value is not a string
112
113
  */
113
114
  function getGlobalObject(name) {
114
- validateString(name);
115
- const o = globalReference?.[name];
116
- if (typeof o === "undefined")
117
- throw new Error(`the object ${name} is not defined`);
118
- validateObject(o);
119
- return o;
115
+ validateString(name);
116
+ const o = globalReference?.[name];
117
+ if (typeof o === "undefined")
118
+ throw new Error(`the object ${name} is not defined`);
119
+ validateObject(o);
120
+ return o;
120
121
  }
121
122
 
122
123
  /**
@@ -149,10 +150,11 @@ function getGlobalObject(name) {
149
150
  * @throws {TypeError} value is not a string
150
151
  */
151
152
  function getGlobalFunction(name) {
152
- validateString(name);
153
- const f = globalReference?.[name];
154
- if (typeof f === "undefined")
155
- throw new Error(`the function ${name} is not defined`);
156
- validateFunction(f);
157
- return f;
153
+ validateString(name);
154
+ const f = globalReference?.[name];
155
+ if (typeof f === "undefined") {
156
+ throw new Error(`the function ${name} is not defined`);
157
+ }
158
+ validateFunction(f);
159
+ return f;
158
160
  }
@@ -156,7 +156,7 @@ function getMonsterVersion() {
156
156
  }
157
157
 
158
158
  /** don't touch, replaced by make with package.json version */
159
- monsterVersion = new Version("3.102.6");
159
+ monsterVersion = new Version("3.104.1");
160
160
 
161
161
  return monsterVersion;
162
162
  }
@@ -7,7 +7,7 @@ describe('Monster', function () {
7
7
  let monsterVersion
8
8
 
9
9
  /** don´t touch, replaced by make with package.json version */
10
- monsterVersion = new Version("3.102.6")
10
+ monsterVersion = new Version("3.104.1")
11
11
 
12
12
  let m = getMonsterVersion();
13
13
 
@@ -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.102.6</h1>
13
- <div id="lastupdate" style='font-size:0.7em'>last update So 2. Feb 23:18:18 CET 2025</div>
12
+ <h1 style='margin-bottom: 0.1em;'>Monster 3.104.1</h1>
13
+ <div id="lastupdate" style='font-size:0.7em'>last update Mi 5. Feb 19:28:33 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>