@descope/web-components-ui 1.91.0 → 1.93.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 +89 -118
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +89 -118
- 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-descope-calendar-index-js.js +1 -1
- package/dist/umd/descope-date-field-descope-calendar-index-js.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/dist/umd/descope-hybrid-field-index-js.js +3 -3
- package/dist/umd/descope-hybrid-field-index-js.js.map +1 -1
- package/package.json +1 -1
- package/src/components/descope-date-field/DateFieldClass.js +41 -41
- package/src/components/descope-date-field/consts.js +0 -12
- package/src/components/descope-date-field/helpers.js +0 -24
- package/src/components/descope-hybrid-field/HybridFieldClass.js +3 -0
package/dist/cjs/index.cjs.js
CHANGED
@@ -15577,63 +15577,6 @@ var radioButton$1 = /*#__PURE__*/Object.freeze({
|
|
15577
15577
|
vars: vars$i
|
15578
15578
|
});
|
15579
15579
|
|
15580
|
-
const SUPPORTED_FORMATS = ['MM/DD/YYYY', 'DD/MM/YYYY', 'YYYY/MM/DD'];
|
15581
|
-
|
15582
|
-
const DEFAULT_FORMAT = SUPPORTED_FORMATS[0];
|
15583
|
-
|
15584
|
-
const NATIVE_FORMAT = 'YYYY-MM-DD';
|
15585
|
-
|
15586
|
-
const YEARS_RANGE = 100;
|
15587
|
-
|
15588
|
-
const DIVIDER = '/';
|
15589
|
-
|
15590
|
-
const COUNTER_SUPPORTED_KEYS = [
|
15591
|
-
'Backspace',
|
15592
|
-
'ArrowLeft',
|
15593
|
-
'ArrowRight',
|
15594
|
-
'ArrowDown',
|
15595
|
-
'ArrowUp',
|
15596
|
-
'PageUp',
|
15597
|
-
'PageDown',
|
15598
|
-
'Meta',
|
15599
|
-
'Enter',
|
15600
|
-
];
|
15601
|
-
|
15602
|
-
const months = [
|
15603
|
-
'January',
|
15604
|
-
'February',
|
15605
|
-
'March',
|
15606
|
-
'April',
|
15607
|
-
'May',
|
15608
|
-
'June',
|
15609
|
-
'July',
|
15610
|
-
'August',
|
15611
|
-
'September',
|
15612
|
-
'October',
|
15613
|
-
'November',
|
15614
|
-
'December',
|
15615
|
-
];
|
15616
|
-
|
15617
|
-
const weekdays = [
|
15618
|
-
'Sunday',
|
15619
|
-
'Monday',
|
15620
|
-
'Tuesday',
|
15621
|
-
'Wednesday',
|
15622
|
-
'Thursday',
|
15623
|
-
'Friday',
|
15624
|
-
'Saturday',
|
15625
|
-
];
|
15626
|
-
|
15627
|
-
const counterConfig = {
|
15628
|
-
MONTH: { id: 'month', min: 1, max: 12, placeholder: 'MM', count: 5, shiftCount: 10 },
|
15629
|
-
DAY: { id: 'day', min: 1, max: 31, placeholder: 'DD', count: 5, shiftCount: 10 },
|
15630
|
-
YEAR: { id: 'year', min: 1900, max: 2099, placeholder: 'YYYY', count: 10, shiftCount: 100 },
|
15631
|
-
};
|
15632
|
-
|
15633
|
-
const BUTTON_LABEL_DONE = 'Done';
|
15634
|
-
const BUTTON_LABEL_CANCEL = 'Cancel';
|
15635
|
-
const CALENDAR_LABEL_TODAY = 'Today';
|
15636
|
-
|
15637
15580
|
const isValidTimestamp = (val) => !Number.isNaN(Number(val));
|
15638
15581
|
|
15639
15582
|
const isNumber = (val) => !Number.isNaN(Number(val));
|
@@ -15669,28 +15612,6 @@ const newDate = (date) => {
|
|
15669
15612
|
return new Date();
|
15670
15613
|
};
|
15671
15614
|
|
15672
|
-
const isSupportedKey = (key) => COUNTER_SUPPORTED_KEYS.includes(key);
|
15673
|
-
|
15674
|
-
const getKeyMap = (key, shiftKey, metaKey) => {
|
15675
|
-
return {
|
15676
|
-
refresh: metaKey && key.toLowerCase() === 'r',
|
15677
|
-
tab: key === 'Tab',
|
15678
|
-
shiftTab: shiftKey && key === 'Tab',
|
15679
|
-
backspace: key === 'Backspace',
|
15680
|
-
arrowUp: !shiftKey && key === 'ArrowUp',
|
15681
|
-
arrowDown: !shiftKey && key === 'ArrowDown',
|
15682
|
-
arrowLeft: !shiftKey && key === 'ArrowLeft',
|
15683
|
-
arrowRight: !shiftKey && key === 'ArrowRight',
|
15684
|
-
pageUp: !shiftKey && key === 'PageUp',
|
15685
|
-
pageDown: !shiftKey && key === 'PageDown',
|
15686
|
-
shiftArrowUp: shiftKey && key === 'ArrowUp',
|
15687
|
-
shiftArrowDown: shiftKey && key === 'ArrowDown',
|
15688
|
-
shiftPageUp: shiftKey && key === 'PageUp',
|
15689
|
-
shiftPageDown: shiftKey && key === 'PageDown',
|
15690
|
-
enter: key === 'Enter',
|
15691
|
-
};
|
15692
|
-
};
|
15693
|
-
|
15694
15615
|
const getCurrentTime = () => newDate().getTime();
|
15695
15616
|
const getFullYear = (timestamp) => newDate(timestamp).getFullYear().toString();
|
15696
15617
|
const getMonth = (timestamp) => (newDate(timestamp).getMonth() + 1).toString();
|
@@ -15720,6 +15641,51 @@ const arrowLeftIcon = `<svg width="24" height="24" viewBox="0 0 24 24" fill="non
|
|
15720
15641
|
<path d="M14.7272 17.2193C15.1209 17.6584 15.0841 18.3334 14.6451 18.7272C14.206 19.1209 13.5309 19.0841 13.1372 18.6451C13.1372 18.6451 7.99776 13.0457 7.63399 12.64C7.27023 12.2343 7.27023 11.7608 7.63399 11.3552L13.1372 5.35492C13.5309 4.91587 14.206 4.87912 14.6451 5.27283C15.0841 5.66655 15.1209 6.34164 14.7272 6.78069L9.86322 12L14.7272 17.2193Z" fill="#808080"/>
|
15721
15642
|
</svg>`;
|
15722
15643
|
|
15644
|
+
const SUPPORTED_FORMATS = ['MM/DD/YYYY', 'DD/MM/YYYY', 'YYYY/MM/DD'];
|
15645
|
+
|
15646
|
+
const DEFAULT_FORMAT = SUPPORTED_FORMATS[0];
|
15647
|
+
|
15648
|
+
const NATIVE_FORMAT = 'YYYY-MM-DD';
|
15649
|
+
|
15650
|
+
const YEARS_RANGE = 100;
|
15651
|
+
|
15652
|
+
const DIVIDER = '/';
|
15653
|
+
|
15654
|
+
const months = [
|
15655
|
+
'January',
|
15656
|
+
'February',
|
15657
|
+
'March',
|
15658
|
+
'April',
|
15659
|
+
'May',
|
15660
|
+
'June',
|
15661
|
+
'July',
|
15662
|
+
'August',
|
15663
|
+
'September',
|
15664
|
+
'October',
|
15665
|
+
'November',
|
15666
|
+
'December',
|
15667
|
+
];
|
15668
|
+
|
15669
|
+
const weekdays = [
|
15670
|
+
'Sunday',
|
15671
|
+
'Monday',
|
15672
|
+
'Tuesday',
|
15673
|
+
'Wednesday',
|
15674
|
+
'Thursday',
|
15675
|
+
'Friday',
|
15676
|
+
'Saturday',
|
15677
|
+
];
|
15678
|
+
|
15679
|
+
const counterConfig = {
|
15680
|
+
MONTH: { id: 'month', min: 1, max: 12, placeholder: 'MM', count: 5, shiftCount: 10 },
|
15681
|
+
DAY: { id: 'day', min: 1, max: 31, placeholder: 'DD', count: 5, shiftCount: 10 },
|
15682
|
+
YEAR: { id: 'year', min: 1900, max: 2099, placeholder: 'YYYY', count: 10, shiftCount: 100 },
|
15683
|
+
};
|
15684
|
+
|
15685
|
+
const BUTTON_LABEL_DONE = 'Done';
|
15686
|
+
const BUTTON_LABEL_CANCEL = 'Cancel';
|
15687
|
+
const CALENDAR_LABEL_TODAY = 'Today';
|
15688
|
+
|
15723
15689
|
const isValidAttrArr = (arr, count) =>
|
15724
15690
|
Array.isArray(arr) && arr.length === count && arr.filter(Boolean).length === count;
|
15725
15691
|
|
@@ -17007,8 +16973,8 @@ class RawDateFieldClass extends BaseInputClass$1 {
|
|
17007
16973
|
this.inputElement.addEventListener('focus', this.onFocus.bind(this));
|
17008
16974
|
this.inputElement.addEventListener('blur', this.onBlur.bind(this));
|
17009
16975
|
this.inputElement.addEventListener('click', this.handleMouseCaretPositionChange.bind(this));
|
17010
|
-
this.inputElement.addEventListener('keydown', this.
|
17011
|
-
this.inputElement.addEventListener('
|
16976
|
+
this.inputElement.addEventListener('keydown', this.handleArrowKeys.bind(this));
|
16977
|
+
this.inputElement.addEventListener('input', this.handleInput.bind(this));
|
17012
16978
|
|
17013
16979
|
forwardAttrs$1(this, this.inputElement, {
|
17014
16980
|
includeAttrs: [
|
@@ -17034,6 +17000,15 @@ class RawDateFieldClass extends BaseInputClass$1 {
|
|
17034
17000
|
});
|
17035
17001
|
}
|
17036
17002
|
|
17003
|
+
handleInput(e) {
|
17004
|
+
if (e.data && isNumber(e.data)) {
|
17005
|
+
this.parseDigits(e.data);
|
17006
|
+
this.updateCountersDisplay();
|
17007
|
+
} else if (e.inputType) {
|
17008
|
+
this.handleNavKeys(e);
|
17009
|
+
}
|
17010
|
+
}
|
17011
|
+
|
17037
17012
|
initPopover() {
|
17038
17013
|
this.baseElement.trigger = ['click'];
|
17039
17014
|
this.baseElement.withBackdrop = true;
|
@@ -17229,18 +17204,14 @@ class RawDateFieldClass extends BaseInputClass$1 {
|
|
17229
17204
|
this.setAttribute('pattern', formats[format].pattern);
|
17230
17205
|
}
|
17231
17206
|
|
17232
|
-
|
17233
|
-
|
17234
|
-
e.preventDefault();
|
17207
|
+
parseDigits(value) {
|
17208
|
+
this.activeCounter.add(value);
|
17235
17209
|
|
17236
|
-
|
17237
|
-
|
17238
|
-
if (this.activeCounter.isFull) {
|
17239
|
-
this.selectNextCounter();
|
17240
|
-
}
|
17241
|
-
|
17242
|
-
this.setInputSelectionRange();
|
17210
|
+
if (this.activeCounter.isFull) {
|
17211
|
+
this.selectNextCounter();
|
17243
17212
|
}
|
17213
|
+
|
17214
|
+
this.setInputSelectionRange();
|
17244
17215
|
}
|
17245
17216
|
|
17246
17217
|
getCounterIdx(caretPos) {
|
@@ -17310,52 +17281,49 @@ class RawDateFieldClass extends BaseInputClass$1 {
|
|
17310
17281
|
});
|
17311
17282
|
}
|
17312
17283
|
|
17284
|
+
handleArrowKeys(e) {
|
17285
|
+
if (e.key === 'ArrowUp') {
|
17286
|
+
this.activeCounter.inc();
|
17287
|
+
} else if (e.key === 'ArrowDown') {
|
17288
|
+
this.activeCounter.dec();
|
17289
|
+
} else if (e.key === 'ArrowRight') {
|
17290
|
+
this.selectNextCounter();
|
17291
|
+
} else if (e.key === 'ArrowLeft') {
|
17292
|
+
this.selectPrevCounter();
|
17293
|
+
}
|
17294
|
+
|
17295
|
+
setTimeout(() => {
|
17296
|
+
this.setInputSelectionRange();
|
17297
|
+
});
|
17298
|
+
}
|
17299
|
+
|
17313
17300
|
handleNavKeys(e) {
|
17314
17301
|
if (this.isReadOnly) {
|
17315
17302
|
return;
|
17316
17303
|
}
|
17317
17304
|
|
17318
|
-
const { key, shiftKey, metaKey } = e;
|
17319
|
-
const keys = getKeyMap(key, shiftKey, metaKey);
|
17320
|
-
|
17321
17305
|
if (this.opened) {
|
17322
17306
|
this.closePopover();
|
17323
17307
|
}
|
17324
17308
|
|
17325
17309
|
e.preventDefault();
|
17326
17310
|
|
17327
|
-
if (
|
17328
|
-
const counter = this.activeCounter;
|
17311
|
+
if (!this.activeCounter) return;
|
17329
17312
|
|
17330
|
-
|
17331
|
-
|
17332
|
-
const counterData = Object.values(counterConfig).find((config) => config.id === counter.id);
|
17333
|
-
const { count, shiftCount } = counterData;
|
17334
|
-
|
17335
|
-
if (keys.backspace) this.handleBackspace();
|
17336
|
-
else if (keys.arrowUp) counter.inc();
|
17337
|
-
else if (keys.arrowDown) counter.dec();
|
17338
|
-
else if (keys.shiftArrowUp) counter.inc(count);
|
17339
|
-
else if (keys.shiftArrowDown) counter.dec(count);
|
17340
|
-
else if (keys.pageUp) counter.inc(count);
|
17341
|
-
else if (keys.pageDown) counter.dec(count);
|
17342
|
-
else if (keys.shiftPageUp) counter.inc(shiftCount);
|
17343
|
-
else if (keys.shiftPageDown) counter.dec(shiftCount);
|
17344
|
-
else if (keys.arrowRight) this.selectNextCounter();
|
17345
|
-
else if (keys.arrowLeft) this.selectPrevCounter();
|
17346
|
-
|
17347
|
-
this.setInputSelectionRange();
|
17313
|
+
if (e.inputType === 'deleteContentBackward') {
|
17314
|
+
this.handleBackspace();
|
17348
17315
|
}
|
17316
|
+
|
17317
|
+
this.setInputSelectionRange();
|
17349
17318
|
}
|
17350
17319
|
|
17351
17320
|
handleBackspace() {
|
17352
|
-
|
17353
|
-
|
17354
|
-
if (counter.isEmpty) {
|
17321
|
+
if (this.activeCounter.isEmpty) {
|
17322
|
+
this.activeCounter.clear();
|
17355
17323
|
this.selectPrevCounter();
|
17356
17324
|
this.setInputSelectionRange();
|
17357
17325
|
} else {
|
17358
|
-
|
17326
|
+
this.activeCounter.del();
|
17359
17327
|
}
|
17360
17328
|
}
|
17361
17329
|
|
@@ -19174,8 +19142,11 @@ class RawHybridField extends BaseClass$3 {
|
|
19174
19142
|
// On reportValidity we want to set the caret at the end of the input value.
|
19175
19143
|
// Since checkValidity triggers `focus` on the input, it sets the caret at the start of the input,
|
19176
19144
|
// regardless the existing value.
|
19145
|
+
const origInputType = ele.type;
|
19146
|
+
ele.setAttribute('type', 'text');
|
19177
19147
|
setTimeout(() => {
|
19178
19148
|
ele.setSelectionRange?.(ele.value.length, ele.value.length);
|
19149
|
+
ele.setAttribute('type', origInputType);
|
19179
19150
|
});
|
19180
19151
|
|
19181
19152
|
return this.activeInput.reportValidity();
|