@schukai/monster 4.49.1 → 4.51.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
+ ## [4.51.0] - 2025-12-25
6
+
7
+ ### Add Features
8
+
9
+ - Enhance success URL handling in login component
10
+
11
+
12
+
13
+ ## [4.50.0] - 2025-12-21
14
+
15
+ ### Add Features
16
+
17
+ - Refactor login component to centralize field mappings
18
+
19
+
20
+
5
21
  ## [4.49.1] - 2025-12-21
6
22
 
7
23
  ### Bug Fixes
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.4","@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":"4.49.1"}
1
+ {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.4","@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":"4.51.0"}
@@ -34,6 +34,8 @@ import "./digits.mjs";
34
34
  import "../layout/collapse.mjs";
35
35
  import "../datatable/datasource/rest.mjs";
36
36
 
37
+ import { isArray, isString, isObject, isFunction } from "../../types/is.mjs";
38
+
37
39
  import { InvalidStyleSheet } from "./stylesheet/invalid.mjs";
38
40
  import { getLocaleOfDocument } from "../../dom/locale.mjs";
39
41
  import { getWindow } from "../../dom/util.mjs";
@@ -214,9 +216,6 @@ class Login extends CustomElement {
214
216
  * @property {boolean} features.redirectToFirstSuccessUrl If true, redirects to the first success URL after login
215
217
  * @property {Object} actions Action definitions for custom event handling
216
218
  * @property {Function} actions.click Callback function for generic click actions within the login component
217
- * @property {Object} fields Field mappings for form inputs
218
- * @property {string} fields.identifier Name of the identifier field (username/email)
219
- * @property {string} fields.password Name of the password field
220
219
  * @property {Object} callbacks Optional callback hooks for modifying internal behavior
221
220
  * @property {Function} callbacks.username A function that receives and can transform the entered username before submission
222
221
  * @property {Function} callbacks.forgotPassword A function that receives and can transform the entered email before submission
@@ -247,6 +246,9 @@ class Login extends CustomElement {
247
246
  * @property {string} fetch.login.headers.accept Accept header value
248
247
  * @property {string} fetch.login.headers.Content-Type Content-Type header value
249
248
  * @property {string} fetch.login.credentials Credential mode (e.g., "same-origin")
249
+ * @property {Object} fetch.login.payload Field mappings for form inputs
250
+ * @property {string} fetch.login.payload.identifier Name of the identifier field (username/email)
251
+ * @property {string} fetch.login.payload.password Name of the password field
250
252
  * @property {Object} fetch.forgotPassword Fetch config for password reset code request
251
253
  * @property {string} fetch.forgotPassword.url Endpoint to request a reset link/code
252
254
  * @property {string} fetch.forgotPassword.method HTTP method
@@ -291,11 +293,6 @@ class Login extends CustomElement {
291
293
  },
292
294
  actions: {},
293
295
 
294
- fields: {
295
- identifier: "username",
296
- password: "password",
297
- },
298
-
299
296
  callbacks: {
300
297
  username: null,
301
298
  forgotPassword: null,
@@ -345,6 +342,11 @@ class Login extends CustomElement {
345
342
  "Content-Type": "application/json; charset=utf-8",
346
343
  },
347
344
  credentials: "same-origin",
345
+
346
+ payload: {
347
+ identifier: "identifier",
348
+ password: "password",
349
+ },
348
350
  },
349
351
  forgotPassword: {
350
352
  url: "",
@@ -439,11 +441,22 @@ class Login extends CustomElement {
439
441
  fireEvent(this, "redirect-to-first-success-url");
440
442
 
441
443
  const successUrl = this.getOption("successUrls");
442
- if (successUrl.length > 0) {
444
+ if (isArray(successUrl) && successUrl.length > 0) {
443
445
  const success = successUrl[0].url;
444
446
  if (success) {
445
447
  getWindow().location.href = success;
446
448
  }
449
+ } else if (isFunction(successUrl)) {
450
+ const url = successUrl();
451
+ if (url) {
452
+ getWindow().location.href = url;
453
+ }
454
+ } else if (isString(successUrl)) {
455
+ getWindow().location.href = successUrl;
456
+ } else {
457
+ console.warn(
458
+ "[Monster Login] No valid success URL found for redirection.",
459
+ );
447
460
  }
448
461
  }, this.getOption("timeoutForSuccess"));
449
462
 
@@ -1302,9 +1315,10 @@ function initEventHandler() {
1302
1315
  }
1303
1316
 
1304
1317
  const identifierField =
1305
- this.getOption("fields.login.identifier") || "username";
1318
+ this.getOption("fetch.login.payload.identifier") || "username";
1306
1319
 
1307
- const passwordField = this.getOption("fields.login.password") || "password";
1320
+ const passwordField =
1321
+ this.getOption("fetch.login.payload.password") || "password";
1308
1322
 
1309
1323
  const payload = {
1310
1324
  [identifierField]: username,