@klauswuestefeld/jux-web 2026.3.16 → 2026.10.9

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/dist/jux-web.js CHANGED
@@ -203,12 +203,15 @@ var juxWeb = (function (exports) {
203
203
  if (iconHTML) {
204
204
  const icon = document.createElement('login-icon');
205
205
  icon.style.gridColumnStart = '2';
206
- icon.style.width = '28px';
207
- icon.style.padding = '6px';
208
- icon.style.marginLeft = '4px';
206
+ icon.style.width = '16px';
207
+ icon.style.padding = '0';
208
+ icon.style.marginLeft = '0';
209
+ icon.style.display = 'flex';
210
+ icon.style.alignItems = 'center';
209
211
  icon.style.boxSizing = 'border-box';
210
212
  icon.className = 'ico';
211
213
  icon.innerHTML = iconHTML;
214
+ icon.querySelector('svg').style.display = 'block';
212
215
  result.appendChild(icon);
213
216
  }
214
217
  const label = document.createElement('login-label');
@@ -227,234 +230,6 @@ var juxWeb = (function (exports) {
227
230
  return result;
228
231
  };
229
232
 
230
- const juxWhite = '#FFF';
231
- const juxDarkGrey = '#282828';
232
- const juxDimmedDarkGrey = '#28282822';
233
- const juxDimmedBlack = '#00000088';
234
- const juxLightGreen = '#20B03D';
235
- const juxMediumGreen = '#0D631E';
236
-
237
- const onKeyDown = (ev, el, persitent, onClose) => {
238
- if (ev.key === 'Escape') {
239
- if (persitent) {
240
- return;
241
- }
242
- close(el, onClose);
243
- }
244
- else if (ev.key === 'Enter') {
245
- if (ev.target.id === 'members-textarea') {
246
- return;
247
- }
248
- el.dispatchEvent(new CustomEvent('ok'));
249
- }
250
- };
251
- const close = (el, onClose) => {
252
- el.remove();
253
- if (onClose) {
254
- onClose();
255
- }
256
- };
257
- const attachEventHandlers = (el, persitent, onClose) => {
258
- const cancelButton = el.querySelector('.cancel');
259
- cancelButton === null || cancelButton === void 0 ? void 0 : cancelButton.addEventListener('click', (_e) => {
260
- el.dispatchEvent(new CustomEvent('cancel'));
261
- if (el.hasAttribute('dont-remove')) {
262
- return;
263
- }
264
- close(el, onClose);
265
- });
266
- const closeButton = el.querySelector('.close');
267
- if (closeButton) {
268
- closeButton.addEventListener('click', (_e) => {
269
- close(el, onClose);
270
- });
271
- }
272
- const okButton = el.querySelector('.ok');
273
- okButton === null || okButton === void 0 ? void 0 : okButton.addEventListener('click', (_e) => {
274
- el.dispatchEvent(new CustomEvent('ok'));
275
- });
276
- el.removeEventListener('keydown', (ev) => onKeyDown(ev, el, persitent, () => onClose));
277
- el.addEventListener('keydown', (ev) => onKeyDown(ev, el, persitent, () => onClose));
278
- el === null || el === void 0 ? void 0 : el.addEventListener('click', (e) => {
279
- if (e.target === el) {
280
- if (persitent) {
281
- return;
282
- }
283
- close(el, onClose);
284
- }
285
- });
286
- };
287
- // TODO: Mudar construtor para usar essa interface
288
- // interface JuxModalOptions {
289
- // title?: string,
290
- // btns?: string[],
291
- // content?: string,
292
- // isPersistent?: boolean,
293
- // isBusy?: boolean,
294
- // body?: HTMLElement,
295
- // okTxt?: string,
296
- // cancelTxt?: string,
297
- // onClose?: any,
298
- // titleStyle?: string,
299
- // }
300
- const applyWrapperStyle = (wrapper) => {
301
- wrapper.style.alignItems = 'center';
302
- wrapper.style.backgroundColor = juxWhite;
303
- wrapper.style.borderRadius = '.3125rem';
304
- wrapper.style.boxShadow = `0 0 1.33rem ${juxDimmedBlack}`;
305
- wrapper.style.boxSizing = 'content-box';
306
- wrapper.style.display = 'flex';
307
- wrapper.style.flexDirection = 'column';
308
- wrapper.style.justifyContent = 'flex-start';
309
- wrapper.style.margin = '0';
310
- wrapper.style.maxHeight = '88%';
311
- wrapper.style.maxWidth = '40%';
312
- wrapper.style.minWidth = '20%';
313
- wrapper.style.padding = '2.8rem';
314
- wrapper.style.position = 'relative';
315
- };
316
- const applyModalStyle = (modal) => {
317
- modal.style.alignItems = 'center';
318
- modal.style.backgroundColor = juxDimmedBlack;
319
- modal.style.display = 'flex';
320
- modal.style.height = '100vh';
321
- modal.style.justifyContent = 'center';
322
- modal.style.left = '0';
323
- modal.style.overflow = 'hidden';
324
- modal.style.position = 'fixed';
325
- modal.style.top = '0';
326
- modal.style.width = '100%';
327
- modal.style.zIndex = '9999';
328
- };
329
- const applyHeaderStyle = (header) => {
330
- header.style.alignItems = 'center';
331
- header.style.color = juxMediumGreen;
332
- header.style.flexDirection = 'row';
333
- header.style.fontSize = '16px';
334
- header.style.fontWeight = '700';
335
- header.style.justifyContent = 'space-between';
336
- header.style.margin = '0';
337
- header.style.display = 'flex';
338
- header.style.position = 'relative';
339
- header.style.width = '100%';
340
- };
341
- const applyJuxModalContentStyle = (el) => {
342
- el.style.display = 'flex';
343
- el.style.position = 'relative';
344
- el.style.width = '100%';
345
- el.style.flexFlow = 'column';
346
- el.style.marginTop = '1.33rem';
347
- el.style.fontSize = '14px';
348
- el.style.rowGap = '8px';
349
- };
350
- const applyFooterStyle = (footer) => {
351
- footer.style.display = 'flex';
352
- footer.style.width = '100%';
353
- footer.style.justifyContent = 'flex-end';
354
- footer.style.alignItems = 'center';
355
- footer.style.gap = '0.75rem';
356
- footer.style.marginTop = '1.5rem';
357
- footer.style.paddingTop = '1rem';
358
- };
359
- const applyModalButtonStyle = (btn) => {
360
- btn.style.display = 'inline-flex';
361
- btn.style.alignItems = 'center';
362
- btn.style.justifyContent = 'center';
363
- btn.style.height = '36px';
364
- btn.style.minWidth = '88px';
365
- btn.style.padding = '0 16px';
366
- btn.style.background = 'rgb(255, 255, 255)';
367
- btn.style.border = '1px solid rgb(160, 160, 160)';
368
- btn.style.borderRadius = '4px';
369
- btn.style.boxShadow = '0 1px 2px rgba(0,0,0,0.15)';
370
- btn.style.color = 'rgb(68, 68, 68)';
371
- btn.style.fontSize = '14px';
372
- btn.style.fontWeight = '500';
373
- btn.style.whiteSpace = 'nowrap';
374
- btn.style.cursor = 'pointer';
375
- };
376
- const juxModal = (title, btns = ['ok', 'cancel'], content = '', persistent = false, busy = false, body, okTxt = getTranslation('alert-ok-btn-txt'), cancelTxt = getTranslation('alert-cancel-btn-txt'), onClose, titleStyle) => {
377
- const result = document.createElement('jux-modal');
378
- applyModalStyle(result);
379
- const wrapper = document.createElement('modal-wrapper');
380
- applyWrapperStyle(wrapper);
381
- // START close
382
- const closeBtn = document.createElement('button');
383
- if (!persistent) {
384
- closeBtn.className = 'close';
385
- closeBtn.setAttribute('aria-label', getTranslation('close'));
386
- }
387
- // END close
388
- // START header
389
- const header = document.createElement('modal-header');
390
- applyHeaderStyle(header);
391
- if (title) {
392
- if (titleStyle) {
393
- header.classList.add(titleStyle);
394
- }
395
- const h3 = document.createElement('h3');
396
- h3.textContent = title;
397
- h3.style.margin = '0';
398
- header.appendChild(h3);
399
- }
400
- // END header
401
- // START content
402
- const modalContent = document.createElement('jux-modal-content');
403
- applyJuxModalContentStyle(modalContent);
404
- if (content) {
405
- modalContent.innerHTML = content;
406
- }
407
- else if (body) {
408
- modalContent.appendChild(body);
409
- }
410
- // END content
411
- // START footer
412
- const footer = document.createElement('modal-footer');
413
- applyFooterStyle(footer);
414
- if (btns.includes('cancel')) {
415
- const cancelBtn = document.createElement('button');
416
- cancelBtn.classList.add('secondary-button', 'modal-button', 'action', 'cancel-btn', 'cancel');
417
- applyModalButtonStyle(cancelBtn);
418
- const cancelText = document.createElement('button-text');
419
- cancelText.textContent = cancelTxt;
420
- const cancelSpinner = document.createElement('loading-spinner');
421
- if (!busy)
422
- cancelSpinner.style.display = 'none';
423
- cancelBtn.append(cancelText, cancelSpinner);
424
- footer.appendChild(cancelBtn);
425
- }
426
- if (btns.includes('ok')) {
427
- const okBtn = document.createElement('button');
428
- okBtn.classList.add('primary-button', 'modal-button', 'action', 'ok');
429
- applyModalButtonStyle(okBtn);
430
- const okText = document.createElement('button-text');
431
- okText.textContent = okTxt;
432
- const okSpinner = document.createElement('loading-spinner');
433
- if (!busy)
434
- okSpinner.style.display = 'none';
435
- okBtn.append(okText, okSpinner);
436
- footer.appendChild(okBtn);
437
- }
438
- // END footer
439
- if (footer.hasChildNodes()) {
440
- wrapper.append(closeBtn, header, modalContent, footer);
441
- }
442
- else {
443
- wrapper.append(closeBtn, header, modalContent);
444
- }
445
- result.appendChild(wrapper);
446
- if (!persistent) {
447
- result.querySelector('.close').focus();
448
- }
449
- else {
450
- if (btns.includes('ok')) {
451
- result.querySelector('.ok').focus();
452
- }
453
- }
454
- attachEventHandlers(result, persistent, onClose);
455
- return result;
456
- };
457
-
458
233
  /******************************************************************************
459
234
  Copyright (c) Microsoft Corporation.
460
235
 
@@ -865,79 +640,360 @@ var juxWeb = (function (exports) {
865
640
  endpoint += `${k}=${params[k]}`;
866
641
  });
867
642
  }
868
- get(endpoint, onJsonResponse, onHelpMessage, null, handleUnauthorized);
869
- };
870
- const requestMagicLink = (data, onJsonResponse, onUnauthorized) => {
871
- const { email, token } = data;
872
- const url = getMagicAuthReqUrl() +
873
- encodeURIComponent(email) +
874
- '&destination=' +
875
- extractTokenFromWindowLocation('destination') +
876
- '&token=' +
877
- token;
878
- const options = {};
879
- backendRequest(url, options, onJsonResponse, console.error, undefined, // ← use undefined instead of null
880
- 'query', onUnauthorized);
881
- };
882
- const openMagicLink = (magicToken, onJsonResponse, onHelpMessage) => {
883
- backendRequest(getMagicAuthUrl() + magicToken, {}, onJsonResponse, onHelpMessage);
884
- };
885
- const googleLogin = (token, onLogin, onLoginError) => {
886
- const url = getBackendUrl() + 'auth-google?google-id-token=' + token;
887
- backendRequest(url, {}, onLogin, onLoginError);
888
- };
889
- const microsoftLogin = (token, onLogin, onLoginError) => {
890
- const url = getBackendUrl() + 'auth-microsoft?access-token=' + token;
891
- backendRequest(url, {}, onLogin, onLoginError);
892
- };
893
- const getSSOAuthorizationEndpoint = (onSuccess, onError) => {
894
- backendGet('openid/authorization-endpoint', null, onSuccess, onError);
895
- };
896
- const validateSSOToken = (token, redirectUri, onLogin, onError, handleUnauthorized) => {
897
- backendGet('openid/callback', { code: token, 'redirect-uri': redirectUri }, onLogin, onError, handleUnauthorized);
898
- };
899
- const authPasswordLogin = (credentials, onLogin, onLoginError, handleUnauthorized) => {
900
- backendPost('auth-password', credentials, onLogin, onLoginError, handleUnauthorized);
901
- };
902
- const getMXData = (domainName) => __awaiter$2(void 0, void 0, void 0, function* () {
903
- try {
904
- const records = yield fetch(`https://dns.google.com/resolve?name=${domainName}&type=MX`, {
905
- method: 'GET',
906
- mode: 'cors'
907
- });
908
- if (!records.ok) {
909
- console.log('response was not ok');
910
- return null;
911
- }
912
- const recordsJson = yield records.json();
913
- const answer = recordsJson.Answer;
914
- if (!answer) {
915
- return null;
643
+ get(endpoint, onJsonResponse, onHelpMessage, null, handleUnauthorized);
644
+ };
645
+ const requestMagicLink = (data, onJsonResponse, onUnauthorized) => {
646
+ const { email, token } = data;
647
+ const url = getMagicAuthReqUrl() +
648
+ encodeURIComponent(email) +
649
+ '&destination=' +
650
+ extractTokenFromWindowLocation('destination') +
651
+ '&token=' +
652
+ token;
653
+ const options = {};
654
+ backendRequest(url, options, onJsonResponse, console.error, undefined, // ← use undefined instead of null
655
+ 'query', onUnauthorized);
656
+ };
657
+ const openMagicLink = (magicToken, onJsonResponse, onHelpMessage) => {
658
+ backendRequest(getMagicAuthUrl() + magicToken, {}, onJsonResponse, onHelpMessage);
659
+ };
660
+ const googleLogin = (token, onLogin, onLoginError) => {
661
+ const url = getBackendUrl() + 'auth-google?google-id-token=' + token;
662
+ backendRequest(url, {}, onLogin, onLoginError);
663
+ };
664
+ const microsoftLogin = (token, onLogin, onLoginError) => {
665
+ const url = getBackendUrl() + 'auth-microsoft?access-token=' + token;
666
+ backendRequest(url, {}, onLogin, onLoginError);
667
+ };
668
+ const getSSOAuthorizationEndpoint = (onSuccess, onError) => {
669
+ backendGet('openid/authorization-endpoint', null, onSuccess, onError);
670
+ };
671
+ const validateSSOToken = (token, redirectUri, onLogin, onError, handleUnauthorized) => {
672
+ backendGet('openid/callback', { code: token, 'redirect-uri': redirectUri }, onLogin, onError, handleUnauthorized);
673
+ };
674
+ const authPasswordLogin = (credentials, onLogin, onLoginError, handleUnauthorized) => {
675
+ backendPost('auth-password', credentials, onLogin, onLoginError, handleUnauthorized);
676
+ };
677
+ const getMXData = (domainName) => __awaiter$2(void 0, void 0, void 0, function* () {
678
+ try {
679
+ const records = yield fetch(`https://dns.google.com/resolve?name=${domainName}&type=MX`, {
680
+ method: 'GET',
681
+ mode: 'cors'
682
+ });
683
+ if (!records.ok) {
684
+ console.log('response was not ok');
685
+ return null;
686
+ }
687
+ const recordsJson = yield records.json();
688
+ const answer = recordsJson.Answer;
689
+ if (!answer) {
690
+ return null;
691
+ }
692
+ return Array.from(answer).map((a) => a.data);
693
+ }
694
+ catch (error) {
695
+ console.error('Fetch failed: ', error);
696
+ return null;
697
+ }
698
+ });
699
+
700
+ // TODO: find a better way to import external scripts
701
+ const script$1 = document.createElement('script');
702
+ script$1.type = 'text/javascript';
703
+ script$1.src = 'https://www.google.com/recaptcha/api.js?render=explicit';
704
+ document.head.appendChild(script$1);
705
+ const googleCaptcha = () => {
706
+ const result = document.createElement('google-captcha');
707
+ const notifyCaptchaChange = () => result.dispatchEvent(new Event('captcha-change'));
708
+ const renderCaptcha = () => grecaptcha.ready(() => {
709
+ grecaptcha.render(result, {
710
+ sitekey: process.env.GOOGLE_CAPTCHA_KEY,
711
+ callback: (token) => {
712
+ result.setAttribute('token', token);
713
+ notifyCaptchaChange();
714
+ },
715
+ 'expired-callback': () => {
716
+ result.removeAttribute('token');
717
+ notifyCaptchaChange();
718
+ }
719
+ });
720
+ result.dispatchEvent(new Event('captcha-rendered'));
721
+ });
722
+ if (typeof grecaptcha === 'undefined') {
723
+ script$1.addEventListener('load', renderCaptcha, { once: true });
724
+ }
725
+ else {
726
+ renderCaptcha();
727
+ }
728
+ return result;
729
+ };
730
+
731
+ const juxWhite = '#FFF';
732
+ const juxDarkGrey = '#282828';
733
+ const juxDimmedBlack = '#00000088';
734
+ const juxLightGreen = '#20B03D';
735
+ const juxMediumGreen = '#0D631E';
736
+
737
+ const onKeyDown = (ev, el, persitent, onClose) => {
738
+ if (ev.key === 'Escape') {
739
+ if (persitent) {
740
+ return;
741
+ }
742
+ close(el, onClose);
743
+ }
744
+ else if (ev.key === 'Enter') {
745
+ if (ev.target.id === 'members-textarea') {
746
+ return;
747
+ }
748
+ el.dispatchEvent(new CustomEvent('ok'));
749
+ }
750
+ };
751
+ const close = (el, onClose) => {
752
+ el.remove();
753
+ if (onClose) {
754
+ onClose();
755
+ }
756
+ };
757
+ const attachEventHandlers = (el, persitent, onClose) => {
758
+ const cancelButton = el.querySelector('.cancel');
759
+ cancelButton === null || cancelButton === void 0 ? void 0 : cancelButton.addEventListener('click', (_e) => {
760
+ el.dispatchEvent(new CustomEvent('cancel'));
761
+ if (el.hasAttribute('dont-remove')) {
762
+ return;
763
+ }
764
+ close(el, onClose);
765
+ });
766
+ const closeButton = el.querySelector('.close');
767
+ if (closeButton) {
768
+ closeButton.addEventListener('click', (_e) => {
769
+ close(el, onClose);
770
+ });
771
+ }
772
+ const okButton = el.querySelector('.ok');
773
+ okButton === null || okButton === void 0 ? void 0 : okButton.addEventListener('click', (_e) => {
774
+ el.dispatchEvent(new CustomEvent('ok'));
775
+ });
776
+ el.removeEventListener('keydown', (ev) => onKeyDown(ev, el, persitent, () => onClose));
777
+ el.addEventListener('keydown', (ev) => onKeyDown(ev, el, persitent, () => onClose));
778
+ el === null || el === void 0 ? void 0 : el.addEventListener('click', (e) => {
779
+ if (e.target === el) {
780
+ if (persitent) {
781
+ return;
782
+ }
783
+ close(el, onClose);
784
+ }
785
+ });
786
+ };
787
+ // TODO: Mudar construtor para usar essa interface
788
+ // interface JuxModalOptions {
789
+ // title?: string,
790
+ // btns?: string[],
791
+ // content?: string,
792
+ // isPersistent?: boolean,
793
+ // isBusy?: boolean,
794
+ // body?: HTMLElement,
795
+ // okTxt?: string,
796
+ // cancelTxt?: string,
797
+ // onClose?: any,
798
+ // titleStyle?: string,
799
+ // }
800
+ const applyWrapperStyle = (wrapper) => {
801
+ wrapper.style.alignItems = 'center';
802
+ wrapper.style.backgroundColor = juxWhite;
803
+ wrapper.style.borderRadius = '.3125rem';
804
+ wrapper.style.boxShadow = `0 0 1.33rem ${juxDimmedBlack}`;
805
+ wrapper.style.boxSizing = 'content-box';
806
+ wrapper.style.display = 'flex';
807
+ wrapper.style.flexDirection = 'column';
808
+ wrapper.style.justifyContent = 'flex-start';
809
+ wrapper.style.margin = '0';
810
+ wrapper.style.maxHeight = '88%';
811
+ wrapper.style.maxWidth = '40%';
812
+ wrapper.style.minWidth = '20%';
813
+ wrapper.style.padding = '2.8rem';
814
+ wrapper.style.position = 'relative';
815
+ };
816
+ const applyModalStyle = (modal) => {
817
+ modal.style.alignItems = 'center';
818
+ modal.style.backgroundColor = juxDimmedBlack;
819
+ modal.style.display = 'flex';
820
+ modal.style.height = '100vh';
821
+ modal.style.justifyContent = 'center';
822
+ modal.style.left = '0';
823
+ modal.style.overflow = 'hidden';
824
+ modal.style.position = 'fixed';
825
+ modal.style.top = '0';
826
+ modal.style.width = '100%';
827
+ modal.style.zIndex = '9999';
828
+ };
829
+ const applyHeaderStyle = (header) => {
830
+ header.style.alignItems = 'center';
831
+ header.style.color = juxMediumGreen;
832
+ header.style.flexDirection = 'row';
833
+ header.style.fontSize = '16px';
834
+ header.style.fontWeight = '700';
835
+ header.style.justifyContent = 'space-between';
836
+ header.style.margin = '0';
837
+ header.style.display = 'flex';
838
+ header.style.position = 'relative';
839
+ header.style.width = '100%';
840
+ };
841
+ const applyJuxModalContentStyle = (el) => {
842
+ el.style.display = 'flex';
843
+ el.style.position = 'relative';
844
+ el.style.width = '100%';
845
+ el.style.flexFlow = 'column';
846
+ el.style.marginTop = '1.33rem';
847
+ el.style.fontSize = '14px';
848
+ el.style.rowGap = '8px';
849
+ };
850
+ const applyFooterStyle = (footer) => {
851
+ footer.style.display = 'flex';
852
+ footer.style.width = '100%';
853
+ footer.style.justifyContent = 'flex-end';
854
+ footer.style.alignItems = 'center';
855
+ footer.style.gap = '0.75rem';
856
+ footer.style.marginTop = '1.5rem';
857
+ footer.style.paddingTop = '1rem';
858
+ };
859
+ const applyModalButtonStyle = (btn) => {
860
+ btn.style.display = 'inline-flex';
861
+ btn.style.alignItems = 'center';
862
+ btn.style.justifyContent = 'center';
863
+ btn.style.height = '36px';
864
+ btn.style.minWidth = '88px';
865
+ btn.style.padding = '0 16px';
866
+ btn.style.background = 'rgb(255, 255, 255)';
867
+ btn.style.border = '1px solid rgb(160, 160, 160)';
868
+ btn.style.borderRadius = '4px';
869
+ btn.style.boxShadow = '0 1px 2px rgba(0,0,0,0.15)';
870
+ btn.style.color = 'rgb(68, 68, 68)';
871
+ btn.style.fontSize = '14px';
872
+ btn.style.fontWeight = '500';
873
+ btn.style.whiteSpace = 'nowrap';
874
+ btn.style.cursor = 'pointer';
875
+ };
876
+ const juxModal = (title, btns = ['ok', 'cancel'], content = '', persistent = false, busy = false, body, okTxt = getTranslation('alert-ok-btn-txt'), cancelTxt = getTranslation('alert-cancel-btn-txt'), onClose, titleStyle) => {
877
+ const result = document.createElement('jux-modal');
878
+ applyModalStyle(result);
879
+ const wrapper = document.createElement('modal-wrapper');
880
+ applyWrapperStyle(wrapper);
881
+ // START close
882
+ const closeBtn = document.createElement('button');
883
+ if (!persistent) {
884
+ closeBtn.className = 'close';
885
+ closeBtn.setAttribute('aria-label', getTranslation('close'));
886
+ }
887
+ // END close
888
+ // START header
889
+ const header = document.createElement('modal-header');
890
+ applyHeaderStyle(header);
891
+ if (title) {
892
+ if (titleStyle) {
893
+ header.classList.add(titleStyle);
894
+ }
895
+ const h3 = document.createElement('h3');
896
+ h3.textContent = title;
897
+ h3.style.margin = '0';
898
+ header.appendChild(h3);
899
+ }
900
+ // END header
901
+ // START content
902
+ const modalContent = document.createElement('jux-modal-content');
903
+ applyJuxModalContentStyle(modalContent);
904
+ if (content) {
905
+ modalContent.innerHTML = content;
906
+ }
907
+ else if (body) {
908
+ modalContent.appendChild(body);
909
+ }
910
+ // END content
911
+ // START footer
912
+ const footer = document.createElement('modal-footer');
913
+ applyFooterStyle(footer);
914
+ if (btns.includes('cancel')) {
915
+ const cancelBtn = document.createElement('button');
916
+ cancelBtn.classList.add('secondary-button', 'modal-button', 'action', 'cancel-btn', 'cancel');
917
+ applyModalButtonStyle(cancelBtn);
918
+ const cancelText = document.createElement('button-text');
919
+ cancelText.textContent = cancelTxt;
920
+ const cancelSpinner = document.createElement('loading-spinner');
921
+ if (!busy)
922
+ cancelSpinner.style.display = 'none';
923
+ cancelBtn.append(cancelText, cancelSpinner);
924
+ footer.appendChild(cancelBtn);
925
+ }
926
+ if (btns.includes('ok')) {
927
+ const okBtn = document.createElement('button');
928
+ okBtn.classList.add('primary-button', 'modal-button', 'action', 'ok');
929
+ applyModalButtonStyle(okBtn);
930
+ const okText = document.createElement('button-text');
931
+ okText.textContent = okTxt;
932
+ const okSpinner = document.createElement('loading-spinner');
933
+ if (!busy)
934
+ okSpinner.style.display = 'none';
935
+ okBtn.append(okText, okSpinner);
936
+ footer.appendChild(okBtn);
937
+ }
938
+ // END footer
939
+ if (footer.hasChildNodes()) {
940
+ wrapper.append(closeBtn, header, modalContent, footer);
941
+ }
942
+ else {
943
+ wrapper.append(closeBtn, header, modalContent);
944
+ }
945
+ result.appendChild(wrapper);
946
+ if (!persistent) {
947
+ result.querySelector('.close').focus();
948
+ }
949
+ else {
950
+ if (btns.includes('ok')) {
951
+ result.querySelector('.ok').focus();
916
952
  }
917
- return Array.from(answer).map((a) => a.data);
918
- }
919
- catch (error) {
920
- console.error('Fetch failed: ', error);
921
- return null;
922
953
  }
923
- });
924
-
925
- // TODO: find a better way to import external scripts
926
- const script$1 = document.createElement('script');
927
- script$1.type = 'text/javascript';
928
- script$1.src = 'https://www.google.com/recaptcha/api.js';
929
- document.head.appendChild(script$1);
930
- const googleCaptcha = () => {
931
- const result = document.createElement('google-captcha');
932
- window.submitCaptcha = (token) => result.setAttribute('token', token);
933
- result.className = 'g-recaptcha';
934
- // @ts-ignore
935
- result.setAttribute('data-sitekey', process.env.GOOGLE_CAPTCHA_KEY);
936
- result.setAttribute('data-callback', 'submitCaptcha');
937
- grecaptcha.render(result);
954
+ attachEventHandlers(result, persistent, onClose);
938
955
  return result;
939
956
  };
940
957
 
958
+ const loginFieldClass = 'jux-login-field';
959
+ const addLoginFieldStyles = () => {
960
+ if (document.querySelector(`style[data-${loginFieldClass}]`))
961
+ return;
962
+ const style = document.createElement('style');
963
+ style.setAttribute(`data-${loginFieldClass}`, '');
964
+ style.textContent = `
965
+ .${loginFieldClass}:hover {
966
+ outline: 1px solid #999 !important;
967
+ outline-offset: -1px;
968
+ }
969
+ .${loginFieldClass}:focus {
970
+ outline: 2px solid #3943B7 !important;
971
+ outline-offset: -2px;
972
+ }
973
+ `;
974
+ document.head.appendChild(style);
975
+ };
976
+ const applyTextFieldStyle = (field) => {
977
+ addLoginFieldStyles();
978
+ field.classList.add(loginFieldClass);
979
+ field.style.backgroundColor = '#fff';
980
+ field.style.border = '1px solid #ccc';
981
+ field.style.borderRadius = '8px';
982
+ field.style.boxShadow = 'inset 0 2px 3px #28282822';
983
+ field.style.boxSizing = 'border-box';
984
+ field.style.color = '#444';
985
+ field.style.cursor = 'text';
986
+ field.style.fontFamily = 'Helvetica, Arial, sans-serif';
987
+ field.style.fontSize = '16px';
988
+ field.style.height = '40px';
989
+ field.style.lineHeight = '38px';
990
+ field.style.margin = '0';
991
+ field.style.outline = 'none';
992
+ field.style.overflow = 'hidden';
993
+ field.style.padding = '0 12px';
994
+ field.style.width = '100%';
995
+ };
996
+
941
997
  const socialLoginModal = (userEmail, mailExchanger, token, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal, handlers) => {
942
998
  const result = document.createElement('social-login-modal');
943
999
  const email = document.createElement('p');
@@ -1011,77 +1067,118 @@ var juxWeb = (function (exports) {
1011
1067
  closeMagicLinkModal();
1012
1068
  });
1013
1069
  const applyMagicEmailFieldStyle = (el) => {
1070
+ el.style.alignItems = 'center';
1014
1071
  el.style.display = 'flex';
1015
- el.style.flexFlow = 'column';
1072
+ el.style.flexFlow = 'row';
1073
+ el.style.gap = '0';
1016
1074
  el.style.marginTop = '8px';
1017
- el.style.rowGap = '8px';
1018
1075
  el.style.width = '100%';
1019
1076
  };
1020
- const applyInputStyle = (input) => {
1021
- input.style.border = `1px solid ${juxDarkGrey}`;
1022
- input.style.maxWidth = '390px';
1023
- input.style.padding = '10px';
1024
- input.style.width = '100%';
1025
- input.style.backgroundColor = juxWhite;
1026
- input.style.borderRadius = '8px';
1027
- input.style.boxShadow = `inset 0 2px 3px ${juxDimmedDarkGrey}`;
1028
- input.style.height = '40px';
1029
- input.style.whiteSpace = 'pre-line';
1030
- input.style.boxSizing = 'border-box';
1077
+ const applyCaptchaStyle = (captcha) => {
1078
+ const captchaFrameWidth = 304;
1079
+ const captchaHeight = 78;
1080
+ const contentWidth = 356;
1081
+ const horizontalInset = 1;
1082
+ const scale = (contentWidth - horizontalInset * 2) / captchaFrameWidth;
1083
+ captcha.style.height = `${captchaHeight * scale}px`;
1084
+ captcha.style.overflow = 'visible';
1085
+ captcha.style.width = '100%';
1086
+ const applyWidgetStyle = () => {
1087
+ const widget = captcha.firstElementChild;
1088
+ widget.style.marginLeft = `${horizontalInset}px`;
1089
+ widget.style.width = `${captchaFrameWidth}px`;
1090
+ widget.style.transform = `scale(${scale})`;
1091
+ widget.style.transformOrigin = 'top left';
1092
+ };
1093
+ if (captcha.firstElementChild) {
1094
+ applyWidgetStyle();
1095
+ }
1096
+ else {
1097
+ captcha.addEventListener('captcha-rendered', applyWidgetStyle, { once: true });
1098
+ }
1031
1099
  };
1032
1100
  const applyBtnStyle = (btn) => {
1033
- btn.style.alignSelf = 'flex-end';
1034
1101
  btn.style.backgroundColor = juxLightGreen;
1035
1102
  btn.style.border = `2px solid ${juxLightGreen}`;
1036
1103
  btn.style.borderRadius = '8px';
1104
+ btn.style.boxSizing = 'border-box';
1037
1105
  btn.style.color = juxWhite;
1038
1106
  btn.style.cursor = 'pointer';
1039
1107
  btn.style.display = 'inline-block';
1108
+ btn.style.fontSize = '16px';
1040
1109
  btn.style.fontWeight = '700';
1041
1110
  btn.style.height = '40px';
1042
1111
  btn.style.lineHeight = '1';
1043
- btn.style.marginLeft = '10px';
1044
1112
  btn.style.padding = '10px 16px';
1045
1113
  btn.style.position = 'relative';
1046
1114
  };
1115
+ const captchaModal = (onVerified, onClose) => {
1116
+ const body = document.createElement('captcha-modal-body');
1117
+ body.style.width = '356px';
1118
+ const modal = juxModal('Security check', [], '', false, false, body, '', '', onClose);
1119
+ modal.id = 'magic-email-captcha-modal';
1120
+ const wrapper = modal.querySelector('modal-wrapper');
1121
+ wrapper.style.maxWidth = '356px';
1122
+ wrapper.style.minWidth = '356px';
1123
+ wrapper.style.width = '356px';
1124
+ modal.querySelector('modal-header h3').style.color = juxDarkGrey;
1125
+ document.body.appendChild(modal);
1126
+ const captcha = googleCaptcha();
1127
+ applyCaptchaStyle(captcha);
1128
+ captcha.addEventListener('captcha-change', () => {
1129
+ const token = captcha.getAttribute('token');
1130
+ if (!token)
1131
+ return;
1132
+ modal.remove();
1133
+ onVerified(token);
1134
+ });
1135
+ body.appendChild(captcha);
1136
+ return modal;
1137
+ };
1047
1138
  const magicEmailField = (onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal, loginTypes, handlers) => {
1048
1139
  const result = document.createElement('magic-email-field');
1049
1140
  applyMagicEmailFieldStyle(result);
1050
- const captcha = googleCaptcha();
1051
1141
  const input = document.createElement('input');
1052
1142
  input.id = 'mail-magic';
1053
1143
  input.type = 'text';
1054
- input.className = 'textfield';
1055
- input.placeholder = 'e-mail';
1056
- applyInputStyle(input);
1057
- input.addEventListener('keydown', (ev) => {
1058
- if (ev.key === 'Enter') {
1059
- onMagicLinkRequest(captcha.getAttribute('token'), input, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal, loginTypes, handlers);
1060
- }
1061
- });
1144
+ input.placeholder = 'Email';
1145
+ applyTextFieldStyle(input);
1146
+ input.style.borderRadius = '8px 0 0 8px';
1147
+ input.style.flex = '1';
1148
+ input.style.minWidth = '0';
1062
1149
  const btn = document.createElement('button');
1063
1150
  applyBtnStyle(btn);
1064
1151
  btn.id = 'send-magic';
1065
1152
  btn.className = 'primary-button';
1066
- btn.addEventListener('click', (_ev) => onMagicLinkRequest(captcha.getAttribute('token'), input, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal, loginTypes, handlers));
1067
1153
  btn.textContent = getTranslation('send-magic');
1068
- result.append(input, captcha, btn);
1069
- return result;
1070
- };
1071
-
1072
- const magicLinkModal = (onUserLogin, onReturn, backgroundImage, currentPage, clientBody, loginTypes, handlers) => {
1073
- const result = document.createElement('magic-link-modal');
1074
- const subtitle = document.createElement('magic-link-request-subtitle');
1075
- subtitle.style.fontSize = '14px';
1076
- subtitle.textContent = getTranslation('magic-link-request-subtitle');
1077
- const body = document.createElement('magic-link-request-body');
1078
- body.append(subtitle, magicEmailField(onUserLogin, onReturn, backgroundImage, currentPage, clientBody, () => result.remove(), loginTypes, handlers));
1079
- const modal = juxModal(getTranslation('magic-link-request-title'), [], '', false, false, body, '', '', () => result.remove());
1080
- modal.setAttribute('data-cy', 'magic-link-modal');
1081
- result.appendChild(modal);
1082
- const wrapper = modal.querySelector('modal-wrapper');
1083
- wrapper.style.maxWidth = '360px';
1084
- wrapper.style.width = '100%';
1154
+ btn.style.borderRadius = '0 8px 8px 0';
1155
+ btn.style.margin = '0';
1156
+ let openCaptchaModal = null;
1157
+ const requestMagicLink = (token) => onMagicLinkRequest(token, input, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal, loginTypes, handlers);
1158
+ btn.addEventListener('click', () => {
1159
+ if (input.value.includes('-test@')) {
1160
+ requestMagicLink(null);
1161
+ return;
1162
+ }
1163
+ if (openCaptchaModal === null || openCaptchaModal === void 0 ? void 0 : openCaptchaModal.isConnected)
1164
+ return;
1165
+ openCaptchaModal = captchaModal((token) => {
1166
+ openCaptchaModal = null;
1167
+ requestMagicLink(token);
1168
+ }, () => openCaptchaModal = null);
1169
+ });
1170
+ const updateButtonState = () => {
1171
+ btn.disabled = !isValidEmail(input.value);
1172
+ btn.style.cursor = btn.disabled ? 'not-allowed' : 'pointer';
1173
+ btn.style.opacity = btn.disabled ? '0.5' : '1';
1174
+ };
1175
+ input.addEventListener('input', updateButtonState);
1176
+ input.addEventListener('keydown', (ev) => {
1177
+ if (ev.key === 'Enter' && !btn.disabled)
1178
+ btn.click();
1179
+ });
1180
+ updateButtonState();
1181
+ result.append(input, btn);
1085
1182
  return result;
1086
1183
  };
1087
1184
 
@@ -1129,6 +1226,78 @@ var juxWeb = (function (exports) {
1129
1226
  return result;
1130
1227
  };
1131
1228
 
1229
+ class JuxWebGlobal {
1230
+ setCurrentUser(newUser) {
1231
+ this._currentUser = newUser;
1232
+ }
1233
+ getCurrentUser() {
1234
+ return this._currentUser;
1235
+ }
1236
+ setBackendToken(token) {
1237
+ this._backendToken = token;
1238
+ }
1239
+ getBackendToken() {
1240
+ return this._backendToken;
1241
+ }
1242
+ }
1243
+
1244
+ const resetJuxWebGlobal = () => {
1245
+ window.juxWebGlobal = new JuxWebGlobal();
1246
+ };
1247
+ const getCurrentUser = () => {
1248
+ var _a;
1249
+ return (_a = window.juxWebGlobal) === null || _a === void 0 ? void 0 : _a.getCurrentUser();
1250
+ };
1251
+
1252
+ const setBackendToken = (token) => {
1253
+ var _a;
1254
+ (_a = window.juxWebGlobal) === null || _a === void 0 ? void 0 : _a.setBackendToken(token);
1255
+ if (token)
1256
+ setLocalStorageItem('token', token);
1257
+ };
1258
+ const clearSession = () => {
1259
+ removeLocalStorageItem('token');
1260
+ resetJuxWebGlobal();
1261
+ };
1262
+ const onTokenAcquired = (token, onUserLogin) => {
1263
+ setBackendToken(token);
1264
+ onUserLogin();
1265
+ };
1266
+
1267
+ const applyLoginTokenStyle = (textarea) => {
1268
+ applyTextFieldStyle(textarea);
1269
+ textarea.style.resize = 'none';
1270
+ textarea.style.setProperty('-webkit-text-security', 'disc');
1271
+ };
1272
+ const loginTokenTextarea = (onUserLogin, onLoginError) => {
1273
+ const juxWebGlobal = window.juxWebGlobal;
1274
+ const textarea = document.createElement('textarea');
1275
+ textarea.id = 'input-login-token';
1276
+ textarea.autocomplete = 'off';
1277
+ textarea.placeholder = 'Paste sign-in token';
1278
+ textarea.rows = 1;
1279
+ textarea.spellcheck = false;
1280
+ textarea.setAttribute('aria-label', 'Sign-in token');
1281
+ applyLoginTokenStyle(textarea);
1282
+ let loginInProgress = false;
1283
+ textarea.addEventListener('input', () => {
1284
+ const loginToken = textarea.value.trim();
1285
+ if (loginToken.length !== 16 || loginInProgress)
1286
+ return;
1287
+ loginInProgress = true;
1288
+ juxWebGlobal.setBackendToken(loginToken);
1289
+ backendGet('profile', null, (res) => {
1290
+ juxWebGlobal.setCurrentUser(res);
1291
+ onTokenAcquired(loginToken, onUserLogin);
1292
+ }, (err) => {
1293
+ loginInProgress = false;
1294
+ juxWebGlobal.setBackendToken('');
1295
+ onLoginError(err);
1296
+ });
1297
+ });
1298
+ return textarea;
1299
+ };
1300
+
1132
1301
  const authPasswordRow = (type, autoCompleteValue) => {
1133
1302
  const result = document.createElement(`${type}-row`);
1134
1303
  result.style.display = 'flex';
@@ -1192,10 +1361,6 @@ var juxWeb = (function (exports) {
1192
1361
  });
1193
1362
  return result;
1194
1363
  };
1195
- const onEmailLoginRequest = (clientApp, loginPage, onUserLogin, backgroundImage, loginTypes, handlers) => {
1196
- const onReturn = () => clientApp.appendChild(loginPage);
1197
- loginPage.appendChild(magicLinkModal(onUserLogin, onReturn, backgroundImage, loginPage, clientApp, loginTypes, handlers));
1198
- };
1199
1364
  const appendLoginTypes = (loginPage, btnsContainer, clientApp, onUserLogin, onLoginError, loginTypes, backgroundImg, explanation, handleSSOLogin, handlers) => {
1200
1365
  const upperLoginTypes = loginTypes.map(str => str.toUpperCase());
1201
1366
  if (upperLoginTypes.length === 0) {
@@ -1205,7 +1370,42 @@ var juxWeb = (function (exports) {
1205
1370
  }
1206
1371
  const onlyAuth = upperLoginTypes.length > 0 &&
1207
1372
  upperLoginTypes.every(type => type === 'AUTH-PASSWORD');
1373
+ const onlyEmail = upperLoginTypes.every(type => type === 'EMAIL');
1208
1374
  applyFormattedTranslation(explanation, 'sign-in-explanation');
1375
+ const showLoginTypes = () => {
1376
+ btnsContainer.replaceChildren();
1377
+ appendLoginTypes(loginPage, btnsContainer, clientApp, onUserLogin, onLoginError, loginTypes, backgroundImg, explanation, handleSSOLogin, handlers);
1378
+ };
1379
+ const showEmailLogin = () => {
1380
+ btnsContainer.replaceChildren();
1381
+ applyFormattedTranslation(explanation, 'magic-link-request-title');
1382
+ const subtitle = document.createElement('magic-link-request-subtitle');
1383
+ subtitle.style.fontSize = '14px';
1384
+ subtitle.style.lineHeight = '20px';
1385
+ subtitle.style.marginLeft = '2px';
1386
+ subtitle.style.marginTop = '12px';
1387
+ subtitle.style.width = 'calc(100% - 2px)';
1388
+ subtitle.textContent = getTranslation('magic-link-request-subtitle');
1389
+ const onReturn = () => {
1390
+ showLoginTypes();
1391
+ clientApp.appendChild(loginPage);
1392
+ };
1393
+ const content = document.createElement('email-login-content');
1394
+ content.style.alignItems = 'center';
1395
+ content.style.display = 'flex';
1396
+ content.style.flexDirection = 'column';
1397
+ content.style.width = '356px';
1398
+ const tokenInput = loginTokenTextarea(onUserLogin, onLoginError);
1399
+ tokenInput.style.marginTop = '24px';
1400
+ content.append(subtitle, magicEmailField(onUserLogin, onReturn, backgroundImg, loginPage, clientApp, () => { }, upperLoginTypes, handlers), tokenInput);
1401
+ btnsContainer.appendChild(content);
1402
+ if (!onlyEmail)
1403
+ btnsContainer.appendChild(backButton('Back', showLoginTypes));
1404
+ };
1405
+ if (onlyEmail) {
1406
+ showEmailLogin();
1407
+ return;
1408
+ }
1209
1409
  if (upperLoginTypes.includes('AUTH-PASSWORD2') || onlyAuth) {
1210
1410
  btnsContainer.replaceChildren();
1211
1411
  btnsContainer.appendChild(authPasswordForm(clientApp, loginPage, onUserLogin, onLoginError, backgroundImg, handlers));
@@ -1234,7 +1434,7 @@ var juxWeb = (function (exports) {
1234
1434
  btnsContainer.appendChild(loginButton('LINKEDIN', () => console.log('login with Linkedin')));
1235
1435
  }
1236
1436
  if (upperLoginTypes.includes('EMAIL')) {
1237
- btnsContainer.appendChild(loginButton('EMAIL', () => onEmailLoginRequest(clientApp, loginPage, onUserLogin, backgroundImg, upperLoginTypes, handlers)));
1437
+ btnsContainer.appendChild(loginButton('EMAIL', showEmailLogin));
1238
1438
  }
1239
1439
  if (upperLoginTypes.includes('AUTH-PASSWORD')) {
1240
1440
  upperLoginTypes.push('AUTH-PASSWORD2');
@@ -14627,44 +14827,6 @@ var juxWeb = (function (exports) {
14627
14827
  document.body.style.pointerEvents = 'auto';
14628
14828
  };
14629
14829
 
14630
- class JuxWebGlobal {
14631
- setCurrentUser(newUser) {
14632
- this._currentUser = newUser;
14633
- }
14634
- getCurrentUser() {
14635
- return this._currentUser;
14636
- }
14637
- setBackendToken(token) {
14638
- this._backendToken = token;
14639
- }
14640
- getBackendToken() {
14641
- return this._backendToken;
14642
- }
14643
- }
14644
-
14645
- const resetJuxWebGlobal = () => {
14646
- window.juxWebGlobal = new JuxWebGlobal();
14647
- };
14648
- const getCurrentUser = () => {
14649
- var _a;
14650
- return (_a = window.juxWebGlobal) === null || _a === void 0 ? void 0 : _a.getCurrentUser();
14651
- };
14652
-
14653
- const setBackendToken = (token) => {
14654
- var _a;
14655
- (_a = window.juxWebGlobal) === null || _a === void 0 ? void 0 : _a.setBackendToken(token);
14656
- if (token)
14657
- setLocalStorageItem('token', token);
14658
- };
14659
- const clearSession = () => {
14660
- removeLocalStorageItem('token');
14661
- resetJuxWebGlobal();
14662
- };
14663
- const onTokenAcquired = (token, onUserLogin) => {
14664
- setBackendToken(token);
14665
- onUserLogin();
14666
- };
14667
-
14668
14830
  // TODO: find a better way to import external scripts
14669
14831
  const script = document.createElement('script');
14670
14832
  script.type = 'text/javascript';
@@ -14787,139 +14949,50 @@ var juxWeb = (function (exports) {
14787
14949
  }
14788
14950
  };
14789
14951
 
14790
- const contactField = (tag = 'input', elType, elName, required = true, value) => {
14791
- const result = document.createElement('contact-field');
14792
- const elId = 'contact-' + elName;
14793
- const label = document.createElement('label');
14794
- label.textContent = getTranslation(elId + '-label');
14795
- label.htmlFor = elId;
14796
- const el = document.createElement(tag);
14797
- el.id = elId;
14798
- el.setAttribute('name', elName);
14799
- el.setAttribute('placeholder', getTranslation(elId + '-placeholder'));
14800
- if (tag === 'input') {
14801
- el.setAttribute('type', elType);
14802
- }
14803
- if (required) {
14804
- el.setAttribute('required', 'true');
14805
- }
14806
- if (value) {
14807
- el.setAttribute('value', value);
14808
- }
14809
- result.append(label, el);
14810
- return result;
14811
- };
14812
-
14813
- const getNestedElValue = (el, nestedTag) => {
14814
- const nestedEl = el.querySelector(nestedTag);
14815
- return nestedEl.value;
14816
- };
14817
- const sendInquiry = (name, email, msg, whatsapp, subject, token) => {
14818
- const inquiryPayload = {
14819
- subject: `[${subject.charAt(0).toUpperCase()}${subject.slice(1)}] ${getNestedElValue(name, 'input')}`,
14820
- body: `<strong>Name</strong>: ${getNestedElValue(name, 'input')}<br><br>
14821
- <strong>E-mail</strong>: ${getNestedElValue(email, 'input')}<br><br>
14822
- <strong>Whatsapp</strong>: ${getNestedElValue(whatsapp, 'input')}<br><br>
14823
- <strong>Message</strong>: ${getNestedElValue(msg, 'textarea')}`,
14824
- token,
14825
- };
14826
- backendPost('contact-us', inquiryPayload, (_res) => {
14827
- var _a;
14828
- // success(getTranslation('form-success'), Length.long);
14829
- (_a = document.querySelector('#contact-us-modal')) === null || _a === void 0 ? void 0 : _a.remove();
14830
- }, () => { } // TODO: change it to be an error handling fn provided by the client
14831
- );
14832
- // checkMixpanel(() => mixpanel.track('Sent Contact Inquiry', {}));
14833
- };
14834
- const contactUsModal = (subject) => {
14835
- var _a, _b, _c, _d, _e, _f, _g, _h;
14836
- const result = document.createElement('contact-us-modal');
14837
- const currentUser = (_a = window.juxWebGlobal) === null || _a === void 0 ? void 0 : _a.getCurrentUser();
14838
- const currentName = currentUser ? currentUser.name : '';
14839
- const currentEmail = currentUser ? currentUser.email : (_b = document.querySelector('#magic-link-email')) === null || _b === void 0 ? void 0 : _b.textContent;
14840
- const modalBody = document.createElement('modal-body');
14841
- const form = document.createElement('form');
14842
- form.id = 'contact-form';
14843
- const nameField = contactField('input', 'text', 'name', true, currentName);
14844
- const emailField = contactField('input', 'email', 'email', true, currentEmail);
14845
- const messageField = contactField('textarea', 'text', 'message', true);
14846
- const whatsappField = contactField('input', 'tel', 'whatsapp', false);
14847
- const btn = document.createElement('button');
14848
- btn.textContent = getTranslation('contact-submit');
14849
- btn.className = 'primary-button';
14850
- form.append(nameField, emailField, whatsappField, messageField, btn);
14851
- modalBody.appendChild(form);
14852
- const modal = juxModal(getTranslation('contact-page'), [], '', false, false, modalBody, '', '', () => result.remove());
14853
- modal.id = 'contact-us-modal';
14854
- document.body.appendChild(modal);
14855
- (_c = modal.querySelector('modal-wrapper')) === null || _c === void 0 ? void 0 : _c.setAttribute('style', 'max-width: 680px; width: 100%; overflow-y: auto;');
14856
- const captcha = googleCaptcha();
14857
- if (subject !== 'email-not-sent') {
14858
- const admin = ((_e = (_d = window.juxWebGlobal) === null || _d === void 0 ? void 0 : _d.selectedTeam) === null || _e === void 0 ? void 0 : _e.admin) || ((_g = (_f = window.juxWebGlobal) === null || _f === void 0 ? void 0 : _f.getCurrentUser()) === null || _g === void 0 ? void 0 : _g.email);
14859
- backendGet('credits-balance-for', { admin }, (res) => {
14860
- const balance = res;
14861
- if (balance <= 0) {
14862
- form.insertBefore(captcha, btn);
14863
- }
14864
- }, () => { } // TODO: change it to be an error handling fn provided by the client
14865
- );
14866
- }
14867
- else {
14868
- form.insertBefore(captcha, btn);
14869
- }
14870
- (_h = nameField.querySelector('input')) === null || _h === void 0 ? void 0 : _h.select();
14871
- form.addEventListener('submit', (event) => {
14872
- event.preventDefault();
14873
- sendInquiry(nameField, emailField, messageField, whatsappField, subject, captcha.getAttribute('token'));
14874
- });
14875
- return result;
14876
- };
14877
-
14878
- const applyBtnStyles = (btn) => {
14879
- btn.style.cursor = 'pointer';
14880
- btn.style.textDecoration = 'underline';
14881
- btn.style.border = 'none';
14882
- btn.style.backgroundColor = '';
14883
- btn.style.background = 'none';
14884
- btn.style.boxSizing = 'border-box';
14885
- btn.style.margin = '0';
14886
- btn.style.outline = 'none';
14887
- btn.style.padding = '0';
14888
- btn.style.whiteSpace = 'normal';
14889
- btn.style.font = 'inherit';
14890
- };
14891
- const magicLinkRequestedPage = (backgroundImg, onReturn) => {
14892
- const content = [];
14952
+ const magicLinkRequestedPage = (backgroundImg, onReturn, onUserLogin, onLoginError) => {
14953
+ const title = document.createElement('h2');
14954
+ title.textContent = getTranslation('magic-link-confirmation-title');
14955
+ title.style.fontSize = '24px';
14956
+ title.style.lineHeight = '1.25';
14957
+ title.style.margin = '0 0 12px';
14893
14958
  const sent = document.createElement('p');
14894
14959
  sent.id = 'magic-link-sent';
14895
14960
  sent.textContent = getTranslation(sent.id);
14896
- sent.style.marginBottom = '10px';
14961
+ sent.style.margin = '0';
14897
14962
  const email = document.createElement('p');
14898
14963
  email.id = 'magic-link-email';
14899
14964
  email.style.fontWeight = '700';
14900
- email.style.marginBottom = '10px';
14965
+ email.style.margin = '4px 0 0';
14966
+ email.style.overflowWrap = 'anywhere';
14901
14967
  const howTo = document.createElement('p');
14902
14968
  howTo.id = 'magic-link-how-to';
14903
14969
  applyFormattedTranslation(howTo, howTo.id);
14904
- howTo.style.padding = '0 30px';
14905
- howTo.style.textAlign = 'center';
14906
- const btn = document.createElement('button');
14907
- btn.id = 'email-not-received-btn';
14908
- btn.addEventListener('click', () => document.body.appendChild(contactUsModal('email-not-sent')));
14909
- btn.textContent = getTranslation('magic-link-let-us-know');
14910
- applyBtnStyles(btn);
14911
- const returnLink = document.createElement('a');
14912
- returnLink.textContent = getTranslation('return-link');
14913
- returnLink.onclick = () => {
14970
+ howTo.style.margin = '28px 0 12px';
14971
+ const tokenInput = loginTokenTextarea(onUserLogin, onLoginError);
14972
+ tokenInput.style.textAlign = 'left';
14973
+ const help = document.createElement('p');
14974
+ applyFormattedTranslation(help, 'magic-link-check-spam');
14975
+ help.style.margin = '20px 0 0';
14976
+ const back = backButton('Back', () => {
14914
14977
  result.remove();
14915
14978
  onReturn();
14916
- };
14917
- returnLink.style.marginTop = '32px';
14918
- returnLink.style.cursor = 'pointer';
14919
- returnLink.style.fontWeight = '700';
14920
- returnLink.style.textDecoration = 'underline';
14921
- content.push(sent, email, howTo, btn, returnLink);
14979
+ });
14980
+ const content = [title, sent, email, howTo, tokenInput, help];
14981
+ content.forEach(element => {
14982
+ element.style.width = '356px';
14983
+ element.style.maxWidth = '100%';
14984
+ });
14922
14985
  const result = basePage('magic-link-requested-page', backgroundImg, content);
14986
+ result.style.overflowY = 'auto';
14987
+ result.style.scrollbarGutter = 'stable both-edges';
14988
+ const section = result.querySelector('section');
14989
+ section.style.maxWidth = 'calc(100% - 48px)';
14990
+ section.style.lineHeight = '1.5';
14991
+ section.style.textAlign = 'center';
14992
+ const buttons = result.querySelector('btns-container');
14993
+ buttons.style.width = '356px';
14994
+ buttons.style.maxWidth = '100%';
14995
+ buttons.appendChild(back);
14923
14996
  return result;
14924
14997
  };
14925
14998
 
@@ -15049,7 +15122,8 @@ var juxWeb = (function (exports) {
15049
15122
  }));
15050
15123
  return;
15051
15124
  }
15052
- displayPage(clientApp, loginPage(clientApp, backgroundImage, onUserLogin, onLoginError, supportedLoginTypesArray, handleSSOLogin, { onAuthPasswordLogin, onGoogleSignIn, onMicrosoftSignIn, handleMagicLinkRequest }));
15125
+ const requestSignInLink = (token, onReturn, backgroundImage, currentPage, clientBody, email = '') => handleMagicLinkRequest(token, onReturn, backgroundImage, currentPage, clientBody, email, onUserLogin, onLoginError);
15126
+ displayPage(clientApp, loginPage(clientApp, backgroundImage, onUserLogin, onLoginError, supportedLoginTypesArray, handleSSOLogin, { onAuthPasswordLogin, onGoogleSignIn, onMicrosoftSignIn, handleMagicLinkRequest: requestSignInLink }));
15053
15127
  // validateThirdPartyCookies(initGapi, () => displayPage(Page.LOGIN));
15054
15128
  // checkMixpanel(() => mixpanel.track('View Login Page'));
15055
15129
  };
@@ -15114,7 +15188,7 @@ var juxWeb = (function (exports) {
15114
15188
  };
15115
15189
  authPasswordLogin(credentials, onSuccess, onError, onUnauthorized);
15116
15190
  };
15117
- const handleMagicLinkRequest = (token, onReturn, backgroundImage, currentPage, clientBody, email = '') => {
15191
+ const handleMagicLinkRequest = (token, onReturn, backgroundImage, currentPage, clientBody, email, onUserLogin, onLoginError) => {
15118
15192
  var _a;
15119
15193
  if (!email) {
15120
15194
  const mailMagic = document.querySelector('#mail-magic');
@@ -15128,7 +15202,7 @@ var juxWeb = (function (exports) {
15128
15202
  const magicLinkEmail = page.querySelector('#magic-link-email');
15129
15203
  magicLinkEmail.textContent = email;
15130
15204
  };
15131
- const onSuccess = () => onResponse(magicLinkRequestedPage(backgroundImage, onReturn));
15205
+ const onSuccess = () => onResponse(magicLinkRequestedPage(backgroundImage, onReturn, onUserLogin, onLoginError));
15132
15206
  const onUnauthorized = () => onResponse(unauthorizedMagicLinkRequestPage(backgroundImage, onReturn));
15133
15207
  requestMagicLink(payload, onSuccess, onUnauthorized);
15134
15208
  };
@@ -15142,6 +15216,22 @@ var juxWeb = (function (exports) {
15142
15216
  onRequestMagicLink();
15143
15217
  };
15144
15218
 
15219
+ const magicLinkModal = (onUserLogin, onReturn, backgroundImage, currentPage, clientBody, loginTypes, handlers) => {
15220
+ const result = document.createElement('magic-link-modal');
15221
+ const subtitle = document.createElement('magic-link-request-subtitle');
15222
+ subtitle.style.fontSize = '14px';
15223
+ subtitle.textContent = getTranslation('magic-link-request-subtitle');
15224
+ const body = document.createElement('magic-link-request-body');
15225
+ body.append(subtitle, magicEmailField(onUserLogin, onReturn, backgroundImage, currentPage, clientBody, () => result.remove(), loginTypes, handlers));
15226
+ const modal = juxModal(getTranslation('magic-link-request-title'), [], '', false, false, body, '', '', () => result.remove());
15227
+ modal.setAttribute('data-cy', 'magic-link-modal');
15228
+ result.appendChild(modal);
15229
+ const wrapper = modal.querySelector('modal-wrapper');
15230
+ wrapper.style.maxWidth = '360px';
15231
+ wrapper.style.width = '100%';
15232
+ return result;
15233
+ };
15234
+
15145
15235
  class JuxEvent extends Event {
15146
15236
  constructor(type, method, endpoint, onResult, params, onError, onRedirect, extras) {
15147
15237
  super('jux-event', { bubbles: true, cancelable: true, composed: true });