@descope/web-components-ui 1.97.0 → 1.99.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.
package/dist/index.esm.js CHANGED
@@ -1453,6 +1453,10 @@ const inputValidationMixin$1 = (superclass) =>
1453
1453
  return `Please match the requested type.`;
1454
1454
  }
1455
1455
 
1456
+ getCustomErrorMessage(attr, defaultMsg) {
1457
+ return this.hasAttribute(attr) ? this.getAttribute(attr) || ' ' : defaultMsg;
1458
+ }
1459
+
1456
1460
  getErrorMessage(flags) {
1457
1461
  const {
1458
1462
  valueMissing,
@@ -1469,31 +1473,33 @@ const inputValidationMixin$1 = (superclass) =>
1469
1473
 
1470
1474
  switch (true) {
1471
1475
  case valueMissing:
1472
- return (
1473
- this.getAttribute(errorAttributes$1.valueMissing) || this.defaultErrorMsgValueMissing
1476
+ return this.getCustomErrorMessage(
1477
+ errorAttributes$1.valueMissing,
1478
+ this.defaultErrorMsgValueMissing
1474
1479
  );
1475
1480
  case patternMismatch || stepMismatch || badInput:
1476
- return (
1477
- this.getAttribute(errorAttributes$1.patternMismatch) ||
1481
+ return this.getCustomErrorMessage(
1482
+ errorAttributes$1.patternMismatch,
1478
1483
  this.defaultErrorMsgPatternMismatch
1479
1484
  );
1480
1485
  case typeMismatch:
1481
- return (
1482
- this.getAttribute(errorAttributes$1.typeMismatch) ||
1483
- this.getAttribute(errorAttributes$1.patternMismatch) ||
1486
+ return this.getCustomErrorMessage(
1487
+ errorAttributes$1.typeMismatch,
1484
1488
  this.defaultErrorMsgTypeMismatch
1485
1489
  );
1486
1490
  case tooShort:
1487
- return this.getAttribute(errorAttributes$1.tooShort) || this.defaultErrorMsgTooShort;
1491
+ return this.getCustomErrorMessage(errorAttributes$1.tooShort, this.defaultErrorMsgTooShort);
1488
1492
  case tooLong:
1489
- return this.getAttribute(errorAttributes$1.tooLong) || this.defaultErrorMsgTooLong;
1493
+ return this.getCustomErrorMessage(errorAttributes$1.tooLong, this.defaultErrorMsgTooLong);
1490
1494
  case rangeUnderflow:
1491
- return (
1492
- this.getAttribute(errorAttributes$1.rangeUnderflow) || this.defaultErrorMsgRangeUnderflow
1495
+ return this.getCustomErrorMessage(
1496
+ errorAttributes$1.rangeUnderflow,
1497
+ this.defaultErrorMsgRangeUnderflow
1493
1498
  );
1494
1499
  case rangeOverflow:
1495
- return (
1496
- this.getAttribute(errorAttributes$1.rangeOverflow) || this.defaultErrorMsgRangeOverflow
1500
+ return this.getCustomErrorMessage(
1501
+ errorAttributes$1.rangeOverflow,
1502
+ this.defaultErrorMsgRangeOverflow
1497
1503
  );
1498
1504
  case customError:
1499
1505
  return this.validationMessage;
@@ -3726,6 +3732,12 @@ const inputValidationMixin = (superclass) =>
3726
3732
  return `Please match the requested type.`;
3727
3733
  }
3728
3734
 
3735
+ getCustomErrorMessage(attr, defaultMsg) {
3736
+ return this.hasAttribute(attr)
3737
+ ? this.getAttribute(attr) || ' '
3738
+ : defaultMsg;
3739
+ }
3740
+
3729
3741
  getErrorMessage(flags) {
3730
3742
  const {
3731
3743
  valueMissing,
@@ -3742,31 +3754,39 @@ const inputValidationMixin = (superclass) =>
3742
3754
 
3743
3755
  switch (true) {
3744
3756
  case valueMissing:
3745
- return (
3746
- this.getAttribute(errorAttributes.valueMissing) || this.defaultErrorMsgValueMissing
3757
+ return this.getCustomErrorMessage(
3758
+ errorAttributes.valueMissing,
3759
+ this.defaultErrorMsgValueMissing,
3747
3760
  );
3748
3761
  case patternMismatch || stepMismatch || badInput:
3749
- return (
3750
- this.getAttribute(errorAttributes.patternMismatch) ||
3751
- this.defaultErrorMsgPatternMismatch
3762
+ return this.getCustomErrorMessage(
3763
+ errorAttributes.patternMismatch,
3764
+ this.defaultErrorMsgPatternMismatch,
3752
3765
  );
3753
3766
  case typeMismatch:
3754
- return (
3755
- this.getAttribute(errorAttributes.typeMismatch) ||
3756
- this.getAttribute(errorAttributes.patternMismatch) ||
3757
- this.defaultErrorMsgTypeMismatch
3767
+ return this.getCustomErrorMessage(
3768
+ errorAttributes.typeMismatch,
3769
+ this.defaultErrorMsgTypeMismatch,
3758
3770
  );
3759
3771
  case tooShort:
3760
- return this.getAttribute(errorAttributes.tooShort) || this.defaultErrorMsgTooShort;
3772
+ return this.getCustomErrorMessage(
3773
+ errorAttributes.tooShort,
3774
+ this.defaultErrorMsgTooShort,
3775
+ );
3761
3776
  case tooLong:
3762
- return this.getAttribute(errorAttributes.tooLong) || this.defaultErrorMsgTooLong;
3777
+ return this.getCustomErrorMessage(
3778
+ errorAttributes.tooLong,
3779
+ this.defaultErrorMsgTooLong,
3780
+ );
3763
3781
  case rangeUnderflow:
3764
- return (
3765
- this.getAttribute(errorAttributes.rangeUnderflow) || this.defaultErrorMsgRangeUnderflow
3782
+ return this.getCustomErrorMessage(
3783
+ errorAttributes.rangeUnderflow,
3784
+ this.defaultErrorMsgRangeUnderflow,
3766
3785
  );
3767
3786
  case rangeOverflow:
3768
- return (
3769
- this.getAttribute(errorAttributes.rangeOverflow) || this.defaultErrorMsgRangeOverflow
3787
+ return this.getCustomErrorMessage(
3788
+ errorAttributes.rangeOverflow,
3789
+ this.defaultErrorMsgRangeOverflow,
3770
3790
  );
3771
3791
  case customError:
3772
3792
  return this.validationMessage;
@@ -3777,7 +3797,11 @@ const inputValidationMixin = (superclass) =>
3777
3797
 
3778
3798
  #setValidity() {
3779
3799
  const validity = this.isReadOnly ? {} : this.getValidity();
3780
- this.#internals.setValidity(validity, this.getErrorMessage(validity), this.validationTarget);
3800
+ this.#internals.setValidity(
3801
+ validity,
3802
+ this.getErrorMessage(validity),
3803
+ this.validationTarget,
3804
+ );
3781
3805
  }
3782
3806
 
3783
3807
  get validationMessage() {
@@ -3814,7 +3838,11 @@ const inputValidationMixin = (superclass) =>
3814
3838
 
3815
3839
  setCustomValidity(errorMessage) {
3816
3840
  if (errorMessage) {
3817
- this.#internals.setValidity({ customError: true }, errorMessage, this.validationTarget);
3841
+ this.#internals.setValidity(
3842
+ { customError: true },
3843
+ errorMessage,
3844
+ this.validationTarget,
3845
+ );
3818
3846
  } else {
3819
3847
  this.#internals.setValidity({});
3820
3848
  this.#setValidity();
@@ -3822,15 +3850,24 @@ const inputValidationMixin = (superclass) =>
3822
3850
  }
3823
3851
 
3824
3852
  get isRequired() {
3825
- return this.hasAttribute('required') && this.getAttribute('required') !== 'false';
3853
+ return (
3854
+ this.hasAttribute('required') &&
3855
+ this.getAttribute('required') !== 'false'
3856
+ );
3826
3857
  }
3827
3858
 
3828
3859
  get isReadOnly() {
3829
- return this.hasAttribute('readonly') && this.getAttribute('readonly') !== 'false';
3860
+ return (
3861
+ this.hasAttribute('readonly') &&
3862
+ this.getAttribute('readonly') !== 'false'
3863
+ );
3830
3864
  }
3831
3865
 
3832
3866
  get isDisabled() {
3833
- return this.hasAttribute('disabled') && this.getAttribute('disabled') !== 'false';
3867
+ return (
3868
+ this.hasAttribute('disabled') &&
3869
+ this.getAttribute('disabled') !== 'false'
3870
+ );
3834
3871
  }
3835
3872
 
3836
3873
  get pattern() {
@@ -5339,9 +5376,13 @@ const weekdays = [
5339
5376
  ];
5340
5377
 
5341
5378
  const counterConfig = {
5342
- MONTH: { id: 'month', min: 1, max: 12, placeholder: 'MM', count: 5, shiftCount: 10 },
5343
- DAY: { id: 'day', min: 1, max: 31, placeholder: 'DD', count: 5, shiftCount: 10 },
5344
- YEAR: { id: 'year', min: 1900, max: 2099, placeholder: 'YYYY', count: 10, shiftCount: 100 },
5379
+ MONTH: { id: 'month', min: 1, max: 12, placeholder: 'MM' },
5380
+ DAY: { id: 'day', min: 1, max: 31, placeholder: 'DD' },
5381
+ YEAR: { id: 'year', min: 0, max: 9999, placeholder: 'YYYY' },
5382
+ };
5383
+
5384
+ const valRange = {
5385
+ year: { min: 1900, max: 2099 },
5345
5386
  };
5346
5387
 
5347
5388
  const BUTTON_LABEL_DONE = 'Done';
@@ -7208,16 +7249,6 @@ class RawDateFieldClass extends BaseInputClass$a {
7208
7249
  });
7209
7250
  }
7210
7251
 
7211
- setYearRange(val) {
7212
- if (!val) return;
7213
- const [min, max] = val.split?.('-');
7214
- if (min && max) {
7215
- const counter = this.getCounterById('year');
7216
- counter.setMin(min);
7217
- counter.setMax(max);
7218
- }
7219
- }
7220
-
7221
7252
  togglePopoverAccess(visibility) {
7222
7253
  if (visibility) {
7223
7254
  this.popoverToggleButton.classList.remove('hidden');
@@ -7230,9 +7261,6 @@ class RawDateFieldClass extends BaseInputClass$a {
7230
7261
  super.attributeChangedCallback?.(attrName, oldValue, newValue);
7231
7262
 
7232
7263
  if (oldValue !== newValue) {
7233
- if (attrName === 'years-range') {
7234
- this.setYearRange(newValue);
7235
- }
7236
7264
  if (attrName === 'disable-calendar') {
7237
7265
  this.togglePopoverAccess(newValue !== 'true');
7238
7266
  }
@@ -7258,9 +7286,17 @@ class RawDateFieldClass extends BaseInputClass$a {
7258
7286
  // To prevent this error from being submitted, we evaluate the
7259
7287
  // date parts against their generated Date value.
7260
7288
  isInvalidDate() {
7261
- return Object.entries(this.getDateVals()).some(
7262
- ([key, val]) => !val || this.getCounterById(key).numberValue !== val
7263
- );
7289
+ const yearCounter = this.getCounterById('year');
7290
+ const isYearOutOfRange =
7291
+ yearCounter.numberValue > valRange['year'].max ||
7292
+ yearCounter.numberValue < valRange['year'].min;
7293
+
7294
+ const isDateDisplayMismatch = Object.entries(this.getDateVals()).some(([key, val]) => {
7295
+ const counter = this.getCounterById(key);
7296
+ return !val || counter.numberValue !== val;
7297
+ });
7298
+
7299
+ return isYearOutOfRange || isDateDisplayMismatch;
7264
7300
  }
7265
7301
 
7266
7302
  getValidity() {