@descope/web-components-ui 1.0.240 → 1.0.241

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.
@@ -1887,6 +1887,14 @@ const inputValidationMixin = (superclass) =>
1887
1887
  return `Maximum length is ${this.getAttribute('maxlength')}. `;
1888
1888
  }
1889
1889
 
1890
+ get defaultErrorMsgRangeUnderflow() {
1891
+ return `At least ${this.minItemsSelection} items are required.`;
1892
+ }
1893
+
1894
+ get defaultErrorMsgRangeOverflow() {
1895
+ return `At most ${this.maxItemsSelection} items are allowed.`;
1896
+ }
1897
+
1890
1898
  getErrorMessage(flags) {
1891
1899
  const {
1892
1900
  valueMissing,
@@ -1905,12 +1913,7 @@ const inputValidationMixin = (superclass) =>
1905
1913
  return (
1906
1914
  this.getAttribute(errorAttributes.valueMissing) || this.defaultErrorMsgValueMissing
1907
1915
  );
1908
- case patternMismatch ||
1909
- typeMismatch ||
1910
- stepMismatch ||
1911
- rangeOverflow ||
1912
- rangeUnderflow ||
1913
- badInput:
1916
+ case patternMismatch || typeMismatch || stepMismatch || badInput:
1914
1917
  return (
1915
1918
  this.getAttribute(errorAttributes.patternMismatch) ||
1916
1919
  this.defaultErrorMsgPatternMismatch
@@ -1919,6 +1922,10 @@ const inputValidationMixin = (superclass) =>
1919
1922
  return this.getAttribute(errorAttributes.tooShort) || this.defaultErrorMsgTooShort;
1920
1923
  case tooLong:
1921
1924
  return this.getAttribute(errorAttributes.tooLong) || this.defaultErrorMsgTooLong;
1925
+ case rangeUnderflow:
1926
+ return this.defaultErrorMsgRangeUnderflow;
1927
+ case rangeOverflow:
1928
+ return this.defaultErrorMsgRangeOverflow;
1922
1929
  case customError:
1923
1930
  return this.validationMessage;
1924
1931
  default:
@@ -8716,6 +8723,14 @@ const MultiSelectComboBoxMixin = (superclass) =>
8716
8723
  return this.getAttribute('allow-custom-value') === 'true';
8717
8724
  }
8718
8725
 
8726
+ get minItemsSelection() {
8727
+ return parseInt(this.getAttribute('min-items-selection'), 10) || 0;
8728
+ }
8729
+
8730
+ get maxItemsSelection() {
8731
+ return parseInt(this.getAttribute('max-items-selection'), 10) || 0;
8732
+ }
8733
+
8719
8734
  // eslint-disable-next-line class-methods-use-this
8720
8735
  isValidDataType(data) {
8721
8736
  const isValid = Array.isArray(data);
@@ -8860,18 +8875,37 @@ const MultiSelectComboBoxMixin = (superclass) =>
8860
8875
  }
8861
8876
  }
8862
8877
 
8863
- init() {
8864
- super.init?.();
8865
-
8878
+ setGetValidity() {
8866
8879
  // eslint-disable-next-line func-names
8867
8880
  this.getValidity = function () {
8868
- if (!this.value.length && this.isRequired) {
8881
+ if (this.isRequired && !this.value.length) {
8869
8882
  return {
8870
8883
  valueMissing: true,
8871
8884
  };
8872
8885
  }
8886
+ // If the field is not required, no minimum selection can be set
8887
+ if (
8888
+ this.isRequired &&
8889
+ this.minItemsSelection &&
8890
+ this.value.length < this.minItemsSelection
8891
+ ) {
8892
+ return {
8893
+ rangeUnderflow: true,
8894
+ };
8895
+ }
8896
+ if (this.maxItemsSelection && this.value.length > this.maxItemsSelection) {
8897
+ return {
8898
+ rangeOverflow: true,
8899
+ };
8900
+ }
8873
8901
  return {};
8874
8902
  };
8903
+ }
8904
+
8905
+ init() {
8906
+ super.init?.();
8907
+
8908
+ this.setGetValidity();
8875
8909
 
8876
8910
  this.setComboBoxDescriptor();
8877
8911