@descope/web-components-ui 2.2.54 → 2.2.55

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.
@@ -2988,6 +2988,19 @@ const activeableMixin = (superclass) =>
2988
2988
  }
2989
2989
  };
2990
2990
 
2991
+ const inputOverrideValidConstraintsMixin$1 = (superclass) =>
2992
+ class InputOverrideValidConstraintsMixinClass extends superclass {
2993
+ init() {
2994
+ super.init?.();
2995
+
2996
+ // vaadin uses `validConstraints` (required, pattern, minlength, maxlength) to determine if it should validate
2997
+ // the input or not. We want to override this behavior, so we can enforce validation even if these attributes are not present.
2998
+ if (this.baseElement._hasValidConstraints) {
2999
+ this.baseElement._hasValidConstraints = () => true;
3000
+ }
3001
+ }
3002
+ };
3003
+
2991
3004
  const getFileExtension = (path) => {
2992
3005
  const match = path.match(/\.([0-9a-z]+)(?:[\\?#]|$)/i);
2993
3006
  return match ? match[1] : null;
@@ -8239,7 +8252,7 @@ const componentName$V = getComponentName('combo-box');
8239
8252
  const ComboBoxMixin = (superclass) =>
8240
8253
  class ComboBoxMixinClass extends superclass {
8241
8254
  static get observedAttributes() {
8242
- return ['label-type'];
8255
+ return ['label-type', 'require-match'];
8243
8256
  }
8244
8257
 
8245
8258
  // eslint-disable-next-line class-methods-use-this
@@ -8311,6 +8324,10 @@ const ComboBoxMixin = (superclass) =>
8311
8324
  }
8312
8325
  }
8313
8326
 
8327
+ get requireMatch() {
8328
+ return this.getAttribute('require-match') === 'true' && !this.allowCustomValue;
8329
+ }
8330
+
8314
8331
  // eslint-disable-next-line class-methods-use-this
8315
8332
  isValidDataType(data) {
8316
8333
  const isValid = Array.isArray(data);
@@ -8463,16 +8480,27 @@ const ComboBoxMixin = (superclass) =>
8463
8480
  }
8464
8481
  }
8465
8482
 
8483
+ isValueMatch() {
8484
+ return this.baseElement.items.some(val => val.getAttribute('data-id') === this.baseElement.querySelector('input').value);
8485
+ }
8486
+
8466
8487
  init() {
8467
8488
  super.init?.();
8468
8489
 
8469
8490
  // eslint-disable-next-line func-names
8470
8491
  this.getValidity = function () {
8492
+ if (this.requireMatch && !this.isValueMatch()) {
8493
+ return {
8494
+ patternMismatch: true,
8495
+ };
8496
+ }
8497
+
8471
8498
  if (!this.value && this.isRequired) {
8472
8499
  return {
8473
8500
  valueMissing: true,
8474
8501
  };
8475
8502
  }
8503
+
8476
8504
  return {};
8477
8505
  };
8478
8506
 
@@ -8524,6 +8552,10 @@ const ComboBoxMixin = (superclass) =>
8524
8552
  }
8525
8553
  }
8526
8554
 
8555
+ handleRequireMatchChange(shouldValidate) {
8556
+ this.baseElement.allowCustomValue = shouldValidate || this.allowCustomValue;
8557
+ }
8558
+
8527
8559
  attributeChangedCallback(attrName, oldValue, newValue) {
8528
8560
  super.attributeChangedCallback?.(attrName, oldValue, newValue);
8529
8561
 
@@ -8534,6 +8566,8 @@ const ComboBoxMixin = (superclass) =>
8534
8566
  } else {
8535
8567
  this.removeEventListener('click', this.onLabelClick);
8536
8568
  }
8569
+ } else if (attrName === 'require-match') {
8570
+ this.handleRequireMatchChange(newValue === 'true');
8537
8571
  }
8538
8572
  }
8539
8573
  }
@@ -8831,6 +8865,7 @@ const ComboBoxClass = compose(
8831
8865
  proxyProps: ['selectionStart'],
8832
8866
  inputEvent: 'value-changed',
8833
8867
  }),
8868
+ inputOverrideValidConstraintsMixin$1,
8834
8869
  componentNameValidationMixin$1,
8835
8870
  ComboBoxMixin,
8836
8871
  )(