@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.
package/dist/index.esm.js CHANGED
@@ -2076,6 +2076,19 @@ const activeableMixin = (superclass) =>
2076
2076
  }
2077
2077
  };
2078
2078
 
2079
+ const inputOverrideValidConstraintsMixin$1 = (superclass) =>
2080
+ class InputOverrideValidConstraintsMixinClass extends superclass {
2081
+ init() {
2082
+ super.init?.();
2083
+
2084
+ // vaadin uses `validConstraints` (required, pattern, minlength, maxlength) to determine if it should validate
2085
+ // the input or not. We want to override this behavior, so we can enforce validation even if these attributes are not present.
2086
+ if (this.baseElement._hasValidConstraints) {
2087
+ this.baseElement._hasValidConstraints = () => true;
2088
+ }
2089
+ }
2090
+ };
2091
+
2079
2092
  const disableRules = [
2080
2093
  'blockquote',
2081
2094
  'list',
@@ -5225,7 +5238,7 @@ const componentName$1d = getComponentName$1('combo-box');
5225
5238
  const ComboBoxMixin = (superclass) =>
5226
5239
  class ComboBoxMixinClass extends superclass {
5227
5240
  static get observedAttributes() {
5228
- return ['label-type'];
5241
+ return ['label-type', 'require-match'];
5229
5242
  }
5230
5243
 
5231
5244
  // eslint-disable-next-line class-methods-use-this
@@ -5297,6 +5310,10 @@ const ComboBoxMixin = (superclass) =>
5297
5310
  }
5298
5311
  }
5299
5312
 
5313
+ get requireMatch() {
5314
+ return this.getAttribute('require-match') === 'true' && !this.allowCustomValue;
5315
+ }
5316
+
5300
5317
  // eslint-disable-next-line class-methods-use-this
5301
5318
  isValidDataType(data) {
5302
5319
  const isValid = Array.isArray(data);
@@ -5449,16 +5466,27 @@ const ComboBoxMixin = (superclass) =>
5449
5466
  }
5450
5467
  }
5451
5468
 
5469
+ isValueMatch() {
5470
+ return this.baseElement.items.some(val => val.getAttribute('data-id') === this.baseElement.querySelector('input').value);
5471
+ }
5472
+
5452
5473
  init() {
5453
5474
  super.init?.();
5454
5475
 
5455
5476
  // eslint-disable-next-line func-names
5456
5477
  this.getValidity = function () {
5478
+ if (this.requireMatch && !this.isValueMatch()) {
5479
+ return {
5480
+ patternMismatch: true,
5481
+ };
5482
+ }
5483
+
5457
5484
  if (!this.value && this.isRequired) {
5458
5485
  return {
5459
5486
  valueMissing: true,
5460
5487
  };
5461
5488
  }
5489
+
5462
5490
  return {};
5463
5491
  };
5464
5492
 
@@ -5510,6 +5538,10 @@ const ComboBoxMixin = (superclass) =>
5510
5538
  }
5511
5539
  }
5512
5540
 
5541
+ handleRequireMatchChange(shouldValidate) {
5542
+ this.baseElement.allowCustomValue = shouldValidate || this.allowCustomValue;
5543
+ }
5544
+
5513
5545
  attributeChangedCallback(attrName, oldValue, newValue) {
5514
5546
  super.attributeChangedCallback?.(attrName, oldValue, newValue);
5515
5547
 
@@ -5520,6 +5552,8 @@ const ComboBoxMixin = (superclass) =>
5520
5552
  } else {
5521
5553
  this.removeEventListener('click', this.onLabelClick);
5522
5554
  }
5555
+ } else if (attrName === 'require-match') {
5556
+ this.handleRequireMatchChange(newValue === 'true');
5523
5557
  }
5524
5558
  }
5525
5559
  }
@@ -5817,6 +5851,7 @@ const ComboBoxClass = compose$1(
5817
5851
  proxyProps: ['selectionStart'],
5818
5852
  inputEvent: 'value-changed',
5819
5853
  }),
5854
+ inputOverrideValidConstraintsMixin$1,
5820
5855
  componentNameValidationMixin$1,
5821
5856
  ComboBoxMixin,
5822
5857
  )(