@descope/web-components-ui 3.20.3 → 3.20.4

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.
@@ -19462,25 +19462,80 @@ var numberField$1 = /*#__PURE__*/Object.freeze({
19462
19462
  vars: vars$E
19463
19463
  });
19464
19464
 
19465
+ // Kept in its own module (with no imports) so it can be unit tested without
19466
+ // pulling in the whole component / vaadin dependency chain.
19467
+
19468
+ const asciiPattern = "^[\\w\\.\\%\\+\\-']+@[\\w\\.\\-]+\\.[A-Za-z]{2,}$";
19469
+
19470
+ const unicodePattern =
19471
+ "^[\\p{L}\\p{M}\\p{N}._%+'\\-]+@[\\p{L}\\p{M}\\p{N}.\\-]+\\.[\\p{L}\\p{M}][\\p{L}\\p{M}\\p{N}\\-]+$";
19472
+
19465
19473
  const componentName$P = getComponentName$1('email-field');
19466
19474
 
19467
- const defaultPattern = "^[\\w\\.\\%\\+\\-']+@[\\w\\.\\-]+\\.[A-Za-z]{2,}$";
19468
19475
  const defaultAutocomplete = 'username';
19476
+ const defaultInputMode = 'email';
19469
19477
 
19470
19478
  const customMixin$8 = (superclass) =>
19471
19479
  class EmailFieldMixinClass extends superclass {
19480
+ // On by default - `accept-unicode="false"` restores the pre-unicode field:
19481
+ // native `type="email"` validation and the ASCII pattern.
19482
+ //
19483
+ // Read once, in `init`. Changing the attribute afterwards has no effect; it
19484
+ // is static configuration, which is how every consumer sets it.
19485
+ get acceptsUnicode() {
19486
+ return this.getAttribute('accept-unicode') !== 'false';
19487
+ }
19488
+
19472
19489
  init() {
19473
19490
  super.init?.();
19474
19491
 
19475
19492
  // we need to set the pattern on the base element because vaadin-email-field is overriding it
19476
- this.baseElement.setAttribute('pattern', defaultPattern);
19493
+ this.baseElement.setAttribute('pattern', asciiPattern);
19477
19494
 
19478
19495
  if (!this.getAttribute('autocomplete')) {
19479
19496
  this.setAttribute('autocomplete', defaultAutocomplete);
19480
19497
  }
19481
19498
 
19482
19499
  this.createExternalInput();
19500
+
19501
+ [this.inputElement, this.externalInput].filter(Boolean).forEach((input) => {
19502
+ input.addEventListener('change', this.stripSurroundingWhitespace);
19503
+ });
19504
+
19505
+ if (this.acceptsUnicode) {
19506
+ this.enableUnicode();
19507
+ }
19508
+ }
19509
+
19510
+ enableUnicode() {
19511
+ this.baseElement.setAttribute('pattern', unicodePattern);
19512
+
19513
+ // native `type="email"` validation is ASCII only and sets typeMismatch
19514
+ // before `pattern` is consulted, so `text` is what lets the pattern decide.
19515
+ // Through vaadin's `_setType` because `type` is a readOnly property bound
19516
+ // to the inner input - assigning `input.type` is re-applied over.
19517
+ this.baseElement._setType('text');
19518
+
19519
+ if (this.externalInput) {
19520
+ this.externalInput.type = 'text';
19521
+ }
19522
+
19523
+ // `type="text"` loses the email keyboard on mobile
19524
+ if (!this.getAttribute('inputmode')) {
19525
+ this.setAttribute('inputmode', defaultInputMode);
19526
+ }
19527
+
19528
+ this.externalInput?.setAttribute('inputmode', defaultInputMode);
19483
19529
  }
19530
+
19531
+ stripSurroundingWhitespace = (e) => {
19532
+ const trimmed = e.target.value.trim();
19533
+ if (trimmed === e.target.value) return;
19534
+ this.value = trimmed;
19535
+
19536
+ // validity is cached and was computed against the untrimmed value
19537
+ this.inputElement.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
19538
+ };
19484
19539
  };
19485
19540
 
19486
19541
  const EmailFieldClass = compose$1(