@schukai/monster 4.6.1 → 4.8.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.8.0] - 2025-05-16
6
+
7
+ ### Add Features
8
+
9
+ - Enhance login functionality with additional event emissions
10
+
11
+
12
+
13
+ ## [4.7.0] - 2025-05-15
14
+
15
+ ### Add Features
16
+
17
+ - Add forgot password callback support in login component
18
+
19
+
20
+
5
21
  ## [4.6.1] - 2025-05-15
6
22
 
7
23
  ### Bug Fixes
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.0","@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.6.1"}
1
+ {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.0","@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.8.0"}
@@ -131,6 +131,9 @@ const digitsCollapseSymbol = Symbol("digitsCollapse");
131
131
  *
132
132
  * @fires login-success
133
133
  * @fires redirect-to-first-success-url
134
+ * @fires second-factor-success
135
+ * @fires digits-success
136
+ * @fires monster-login-clicked
134
137
  */
135
138
  class Login extends CustomElement {
136
139
  /**
@@ -205,6 +208,7 @@ class Login extends CustomElement {
205
208
  * @property {Function} actions.click Callback function for generic click actions within the login component
206
209
  * @property {Object} callbacks Optional callback hooks for modifying internal behavior
207
210
  * @property {Function} callbacks.username A function that receives and can transform the entered username before submission
211
+ * @property {Function} callbacks.forgotPassword A function that receives and can transform the entered email before submission
208
212
  * @property {number} digits Number of digits required for second factor or password reset code input
209
213
  * @property {Object[]} successUrls List of URLs shown after successful login (e.g., home or logout)
210
214
  * @property {string} successUrls.label Label for the success URL (displayed)
@@ -274,6 +278,7 @@ class Login extends CustomElement {
274
278
 
275
279
  callbacks : {
276
280
  username : null,
281
+ forgotPassword : null,
277
282
  },
278
283
 
279
284
  digits: 6,
@@ -386,7 +391,7 @@ class Login extends CustomElement {
386
391
  }
387
392
 
388
393
  /**
389
- * Opens the digits collapse and focuses the digits control.
394
+ * Opens the digits collapse and focuses the digit control.
390
395
  * @returns {Login}
391
396
  */
392
397
  openDigits() {
@@ -1310,8 +1315,17 @@ function initEventHandler() {
1310
1315
  const emailElement = this.shadowRoot.querySelector("input[name='email']");
1311
1316
 
1312
1317
  // get username and password
1313
- const mail = emailElement.value;
1314
- const valid = emailElement.checkValidity();
1318
+ let mail = emailElement.value;
1319
+ let valid = emailElement.checkValidity();
1320
+
1321
+ const mailCallback = this.getOption("callbacks.forgotPassword");
1322
+ if (isFunction(mailCallback)) {
1323
+ const mailCallbackResult = mailCallback.call(this, mail);
1324
+ if (mailCallbackResult !== undefined) {
1325
+ mail = mailCallbackResult;
1326
+ valid = true;
1327
+ }
1328
+ }
1315
1329
 
1316
1330
  let msg = null;
1317
1331
  if (mail === "" || mail === null) {
@@ -1444,6 +1458,7 @@ function initEventHandler() {
1444
1458
  if (response.ok) {
1445
1459
  const timeout = this.getOption("timeoutForSuccess");
1446
1460
  this[secondFactorButtonSymbol].setState("successful", timeout);
1461
+ fireEvent(this, "second-factor-success");
1447
1462
  setTimeout(() => {
1448
1463
  this.openLoggedIn();
1449
1464
  }, timeout);
@@ -1527,6 +1542,7 @@ function initEventHandler() {
1527
1542
 
1528
1543
  if (response.ok) {
1529
1544
  this[digitsButtonSymbol].setState("successful", timeout);
1545
+ fireEvent(this, "digits-success");
1530
1546
  setTimeout(() => {
1531
1547
  this.openLoggedIn();
1532
1548
  }, timeout);