@descope/web-components-ui 1.99.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 +43 -4
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +43 -4
- package/dist/index.esm.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 +1 -1
- package/src/components/descope-date-field/DateFieldClass.js +43 -4
package/dist/index.esm.js
CHANGED
@@ -6666,6 +6666,8 @@ class RawDateFieldClass extends BaseInputClass$a {
|
|
6666
6666
|
|
6667
6667
|
selectedCounterIdx = 0;
|
6668
6668
|
|
6669
|
+
#focused = false;
|
6670
|
+
|
6669
6671
|
updateCountersDisplay() {
|
6670
6672
|
this.inputElement.value = this.countersValue;
|
6671
6673
|
}
|
@@ -6876,6 +6878,22 @@ class RawDateFieldClass extends BaseInputClass$a {
|
|
6876
6878
|
this.inputElement.addEventListener('keydown', this.handleArrowKeys.bind(this));
|
6877
6879
|
this.inputElement.addEventListener('beforeinput', this.handleInput.bind(this));
|
6878
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
|
+
|
6879
6897
|
forwardAttrs$1(this, this.inputElement, {
|
6880
6898
|
includeAttrs: [
|
6881
6899
|
'label',
|
@@ -7073,20 +7091,34 @@ class RawDateFieldClass extends BaseInputClass$a {
|
|
7073
7091
|
}
|
7074
7092
|
|
7075
7093
|
onFocus() {
|
7076
|
-
if (this.isReadOnly) {
|
7094
|
+
if (this.isReadOnly || this.#focused) {
|
7077
7095
|
return;
|
7078
7096
|
}
|
7079
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() {
|
7080
7106
|
if (!this.inputElement.value) {
|
7081
7107
|
this.inputElement.value = this.format;
|
7082
7108
|
}
|
7083
7109
|
|
7084
7110
|
// On focus select the first part of the format placeholder
|
7085
7111
|
this.selectedCounterIdx = 0;
|
7086
|
-
|
7112
|
+
|
7113
|
+
setTimeout(() => {
|
7114
|
+
// set selection on first counter
|
7115
|
+
this.inputElement.setSelectionRange(0, this.sortedCounters[0].length);
|
7116
|
+
});
|
7087
7117
|
}
|
7088
7118
|
|
7089
7119
|
onBlur() {
|
7120
|
+
this.#focused = false;
|
7121
|
+
|
7090
7122
|
if (this.opened) {
|
7091
7123
|
return;
|
7092
7124
|
}
|
@@ -7130,7 +7162,9 @@ class RawDateFieldClass extends BaseInputClass$a {
|
|
7130
7162
|
}
|
7131
7163
|
|
7132
7164
|
setSelectedCounterByCaretPosition(e) {
|
7133
|
-
this.selectedCounterIdx = this.getCounterIdx(
|
7165
|
+
this.selectedCounterIdx = this.getCounterIdx(
|
7166
|
+
e.target.selectionStart || this.inputElement.selectionStart
|
7167
|
+
);
|
7134
7168
|
}
|
7135
7169
|
|
7136
7170
|
selectNextCounter() {
|
@@ -7236,7 +7270,12 @@ class RawDateFieldClass extends BaseInputClass$a {
|
|
7236
7270
|
}
|
7237
7271
|
e.preventDefault();
|
7238
7272
|
this.setSelectedCounterByCaretPosition(e);
|
7239
|
-
|
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
|
+
});
|
7240
7279
|
}
|
7241
7280
|
|
7242
7281
|
onInitialValueChange(val) {
|