@descope/web-components-ui 1.98.0 → 1.100.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/cjs/index.cjs.js +113 -37
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +113 -37
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/8961.js +1 -1
- package/dist/umd/8961.js.map +1 -1
- package/dist/umd/9365.js +1 -1
- package/dist/umd/9365.js.map +1 -1
- package/dist/umd/DescopeDev.js +1 -1
- package/dist/umd/DescopeDev.js.map +1 -1
- package/dist/umd/descope-date-field-index-js.js +1 -1
- package/dist/umd/descope-date-field-index-js.js.map +1 -1
- package/package.json +14 -14
- package/src/components/descope-date-field/DateFieldClass.js +43 -4
- package/src/mixins/inputValidationMixin.js +19 -13
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
|
-
|
1476
|
+
return this.getCustomErrorMessage(
|
1477
|
+
errorAttributes$1.valueMissing,
|
1478
|
+
this.defaultErrorMsgValueMissing
|
1474
1479
|
);
|
1475
1480
|
case patternMismatch || stepMismatch || badInput:
|
1476
|
-
return (
|
1477
|
-
|
1481
|
+
return this.getCustomErrorMessage(
|
1482
|
+
errorAttributes$1.patternMismatch,
|
1478
1483
|
this.defaultErrorMsgPatternMismatch
|
1479
1484
|
);
|
1480
1485
|
case typeMismatch:
|
1481
|
-
return (
|
1482
|
-
|
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.
|
1491
|
+
return this.getCustomErrorMessage(errorAttributes$1.tooShort, this.defaultErrorMsgTooShort);
|
1488
1492
|
case tooLong:
|
1489
|
-
return this.
|
1493
|
+
return this.getCustomErrorMessage(errorAttributes$1.tooLong, this.defaultErrorMsgTooLong);
|
1490
1494
|
case rangeUnderflow:
|
1491
|
-
return (
|
1492
|
-
|
1495
|
+
return this.getCustomErrorMessage(
|
1496
|
+
errorAttributes$1.rangeUnderflow,
|
1497
|
+
this.defaultErrorMsgRangeUnderflow
|
1493
1498
|
);
|
1494
1499
|
case rangeOverflow:
|
1495
|
-
return (
|
1496
|
-
|
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
|
-
|
3757
|
+
return this.getCustomErrorMessage(
|
3758
|
+
errorAttributes.valueMissing,
|
3759
|
+
this.defaultErrorMsgValueMissing,
|
3747
3760
|
);
|
3748
3761
|
case patternMismatch || stepMismatch || badInput:
|
3749
|
-
return (
|
3750
|
-
|
3751
|
-
this.defaultErrorMsgPatternMismatch
|
3762
|
+
return this.getCustomErrorMessage(
|
3763
|
+
errorAttributes.patternMismatch,
|
3764
|
+
this.defaultErrorMsgPatternMismatch,
|
3752
3765
|
);
|
3753
3766
|
case typeMismatch:
|
3754
|
-
return (
|
3755
|
-
|
3756
|
-
this.
|
3757
|
-
this.defaultErrorMsgTypeMismatch
|
3767
|
+
return this.getCustomErrorMessage(
|
3768
|
+
errorAttributes.typeMismatch,
|
3769
|
+
this.defaultErrorMsgTypeMismatch,
|
3758
3770
|
);
|
3759
3771
|
case tooShort:
|
3760
|
-
return this.
|
3772
|
+
return this.getCustomErrorMessage(
|
3773
|
+
errorAttributes.tooShort,
|
3774
|
+
this.defaultErrorMsgTooShort,
|
3775
|
+
);
|
3761
3776
|
case tooLong:
|
3762
|
-
return this.
|
3777
|
+
return this.getCustomErrorMessage(
|
3778
|
+
errorAttributes.tooLong,
|
3779
|
+
this.defaultErrorMsgTooLong,
|
3780
|
+
);
|
3763
3781
|
case rangeUnderflow:
|
3764
|
-
return (
|
3765
|
-
|
3782
|
+
return this.getCustomErrorMessage(
|
3783
|
+
errorAttributes.rangeUnderflow,
|
3784
|
+
this.defaultErrorMsgRangeUnderflow,
|
3766
3785
|
);
|
3767
3786
|
case rangeOverflow:
|
3768
|
-
return (
|
3769
|
-
|
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(
|
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(
|
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
|
3853
|
+
return (
|
3854
|
+
this.hasAttribute('required') &&
|
3855
|
+
this.getAttribute('required') !== 'false'
|
3856
|
+
);
|
3826
3857
|
}
|
3827
3858
|
|
3828
3859
|
get isReadOnly() {
|
3829
|
-
return
|
3860
|
+
return (
|
3861
|
+
this.hasAttribute('readonly') &&
|
3862
|
+
this.getAttribute('readonly') !== 'false'
|
3863
|
+
);
|
3830
3864
|
}
|
3831
3865
|
|
3832
3866
|
get isDisabled() {
|
3833
|
-
return
|
3867
|
+
return (
|
3868
|
+
this.hasAttribute('disabled') &&
|
3869
|
+
this.getAttribute('disabled') !== 'false'
|
3870
|
+
);
|
3834
3871
|
}
|
3835
3872
|
|
3836
3873
|
get pattern() {
|
@@ -6629,6 +6666,8 @@ class RawDateFieldClass extends BaseInputClass$a {
|
|
6629
6666
|
|
6630
6667
|
selectedCounterIdx = 0;
|
6631
6668
|
|
6669
|
+
#focused = false;
|
6670
|
+
|
6632
6671
|
updateCountersDisplay() {
|
6633
6672
|
this.inputElement.value = this.countersValue;
|
6634
6673
|
}
|
@@ -6839,6 +6878,22 @@ class RawDateFieldClass extends BaseInputClass$a {
|
|
6839
6878
|
this.inputElement.addEventListener('keydown', this.handleArrowKeys.bind(this));
|
6840
6879
|
this.inputElement.addEventListener('beforeinput', this.handleInput.bind(this));
|
6841
6880
|
|
6881
|
+
// We want to handle touch events the same way we handle `click` events.
|
6882
|
+
// Since we can't seem to block touch events (`touch-action: none` or preventing default on `touchstart`
|
6883
|
+
// or `touchend`, we listen to `pointerdown` and in case it's of type `touch` we execute
|
6884
|
+
// the component's logic for range selection.
|
6885
|
+
this.inputElement.addEventListener('pointerdown', (e) => {
|
6886
|
+
if (e.pointerType === 'touch') {
|
6887
|
+
e.preventDefault();
|
6888
|
+
if (!this.#focused) {
|
6889
|
+
this.inputElement.focus();
|
6890
|
+
}
|
6891
|
+
setTimeout(() => {
|
6892
|
+
this.handleMouseCaretPositionChange(e);
|
6893
|
+
}, 250);
|
6894
|
+
}
|
6895
|
+
});
|
6896
|
+
|
6842
6897
|
forwardAttrs$1(this, this.inputElement, {
|
6843
6898
|
includeAttrs: [
|
6844
6899
|
'label',
|
@@ -7036,20 +7091,34 @@ class RawDateFieldClass extends BaseInputClass$a {
|
|
7036
7091
|
}
|
7037
7092
|
|
7038
7093
|
onFocus() {
|
7039
|
-
if (this.isReadOnly) {
|
7094
|
+
if (this.isReadOnly || this.#focused) {
|
7040
7095
|
return;
|
7041
7096
|
}
|
7042
7097
|
|
7098
|
+
// We use this flag to support mobile logic, which calls `focus` on touch event, we want to make sure
|
7099
|
+
// focus executes it logic only when needed.
|
7100
|
+
this.#focused = true;
|
7101
|
+
|
7102
|
+
this.resetDisplay();
|
7103
|
+
}
|
7104
|
+
|
7105
|
+
resetDisplay() {
|
7043
7106
|
if (!this.inputElement.value) {
|
7044
7107
|
this.inputElement.value = this.format;
|
7045
7108
|
}
|
7046
7109
|
|
7047
7110
|
// On focus select the first part of the format placeholder
|
7048
7111
|
this.selectedCounterIdx = 0;
|
7049
|
-
|
7112
|
+
|
7113
|
+
setTimeout(() => {
|
7114
|
+
// set selection on first counter
|
7115
|
+
this.inputElement.setSelectionRange(0, this.sortedCounters[0].length);
|
7116
|
+
});
|
7050
7117
|
}
|
7051
7118
|
|
7052
7119
|
onBlur() {
|
7120
|
+
this.#focused = false;
|
7121
|
+
|
7053
7122
|
if (this.opened) {
|
7054
7123
|
return;
|
7055
7124
|
}
|
@@ -7093,7 +7162,9 @@ class RawDateFieldClass extends BaseInputClass$a {
|
|
7093
7162
|
}
|
7094
7163
|
|
7095
7164
|
setSelectedCounterByCaretPosition(e) {
|
7096
|
-
this.selectedCounterIdx = this.getCounterIdx(
|
7165
|
+
this.selectedCounterIdx = this.getCounterIdx(
|
7166
|
+
e.target.selectionStart || this.inputElement.selectionStart
|
7167
|
+
);
|
7097
7168
|
}
|
7098
7169
|
|
7099
7170
|
selectNextCounter() {
|
@@ -7199,7 +7270,12 @@ class RawDateFieldClass extends BaseInputClass$a {
|
|
7199
7270
|
}
|
7200
7271
|
e.preventDefault();
|
7201
7272
|
this.setSelectedCounterByCaretPosition(e);
|
7202
|
-
|
7273
|
+
|
7274
|
+
// On keydown - in desktop mode - selection is sometimes not set, and instead there is a cursor.
|
7275
|
+
// We need to wait until we can set selection range.
|
7276
|
+
setTimeout(() => {
|
7277
|
+
this.setInputSelectionRange();
|
7278
|
+
});
|
7203
7279
|
}
|
7204
7280
|
|
7205
7281
|
onInitialValueChange(val) {
|