@descope/web-components-ui 3.26.5 → 3.27.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.
@@ -18465,6 +18465,20 @@ const asciiPattern =
18465
18465
  const unicodePattern =
18466
18466
  "^[\\p{L}\\p{M}\\p{N}._%+'\\-]+@(?:[\\p{L}\\p{M}\\p{N}](?:[\\p{L}\\p{M}\\p{N}\\-]*[\\p{L}\\p{M}\\p{N}])?\\.)+[\\p{L}\\p{M}][\\p{L}\\p{M}\\p{N}\\-]+$";
18467
18467
 
18468
+ // The autocomplete grammar is ordered (section-*, shipping/billing, field name, webauthn) and on/off can't be
18469
+ // combined with a field name, so `email` takes the field name's place, before webauthn
18470
+ const emailVerificationAutocomplete = (autocomplete) => {
18471
+ const tokens = (autocomplete || '')
18472
+ .split(/\s+/)
18473
+ .filter(
18474
+ (token) => token && !['username', 'email', 'on', 'off'].includes(token),
18475
+ );
18476
+ const webauthn = tokens.indexOf('webauthn');
18477
+ tokens.splice(webauthn === -1 ? tokens.length : webauthn, 0, 'email');
18478
+
18479
+ return tokens.join(' ');
18480
+ };
18481
+
18468
18482
  const componentName$U = getComponentName('email-field');
18469
18483
 
18470
18484
  const defaultAutocomplete = 'username';
@@ -18513,6 +18527,38 @@ const customMixin$a = (superclass) =>
18513
18527
  if (!this.validatesFormat) {
18514
18528
  this.disableFormatValidation();
18515
18529
  }
18530
+
18531
+ if (this.emailVerification) {
18532
+ this.enableEmailVerification();
18533
+ }
18534
+ }
18535
+
18536
+ // Read once, in `init`: descope-wc renders the screen html once
18537
+ get emailVerification() {
18538
+ return this.getAttribute('email-verification') === 'true';
18539
+ }
18540
+
18541
+ // Browser email verification needs the native input to be an email field (autocomplete `email`).
18542
+ // The host keeps its own autocomplete: descope-wc finds the passkey autofill field by an exact
18543
+ // `[autocomplete="webauthn"]` match on it, so changing the host would break passkeys
18544
+ enableEmailVerification() {
18545
+ const { baseElement } = this;
18546
+ const delegate = baseElement._delegateAttribute.bind(baseElement);
18547
+ // vaadin writes the native autocomplete only through here, so it writes ours
18548
+ baseElement._delegateAttribute = (name, value) =>
18549
+ delegate(
18550
+ name,
18551
+ name === 'autocomplete'
18552
+ ? emailVerificationAutocomplete(value)
18553
+ : value,
18554
+ );
18555
+ baseElement._delegateAttribute('autocomplete', baseElement.autocomplete);
18556
+
18557
+ // the external input copies the host autocomplete once, when it is created
18558
+ this.externalInput?.setAttribute(
18559
+ 'autocomplete',
18560
+ emailVerificationAutocomplete(this.getAttribute('autocomplete')),
18561
+ );
18516
18562
  }
18517
18563
 
18518
18564
  enableUnicode() {