@descope/flow-components 2.0.550 → 2.0.552

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.cjs.js CHANGED
@@ -92972,63 +92972,6 @@ descope-boolean-field-internal {
92972
92972
  vars: vars$i
92973
92973
  });
92974
92974
 
92975
- const SUPPORTED_FORMATS = ['MM/DD/YYYY', 'DD/MM/YYYY', 'YYYY/MM/DD'];
92976
-
92977
- const DEFAULT_FORMAT = SUPPORTED_FORMATS[0];
92978
-
92979
- const NATIVE_FORMAT = 'YYYY-MM-DD';
92980
-
92981
- const YEARS_RANGE = 100;
92982
-
92983
- const DIVIDER = '/';
92984
-
92985
- const COUNTER_SUPPORTED_KEYS = [
92986
- 'Backspace',
92987
- 'ArrowLeft',
92988
- 'ArrowRight',
92989
- 'ArrowDown',
92990
- 'ArrowUp',
92991
- 'PageUp',
92992
- 'PageDown',
92993
- 'Meta',
92994
- 'Enter',
92995
- ];
92996
-
92997
- const months = [
92998
- 'January',
92999
- 'February',
93000
- 'March',
93001
- 'April',
93002
- 'May',
93003
- 'June',
93004
- 'July',
93005
- 'August',
93006
- 'September',
93007
- 'October',
93008
- 'November',
93009
- 'December',
93010
- ];
93011
-
93012
- const weekdays = [
93013
- 'Sunday',
93014
- 'Monday',
93015
- 'Tuesday',
93016
- 'Wednesday',
93017
- 'Thursday',
93018
- 'Friday',
93019
- 'Saturday',
93020
- ];
93021
-
93022
- const counterConfig = {
93023
- MONTH: { id: 'month', min: 1, max: 12, placeholder: 'MM', count: 5, shiftCount: 10 },
93024
- DAY: { id: 'day', min: 1, max: 31, placeholder: 'DD', count: 5, shiftCount: 10 },
93025
- YEAR: { id: 'year', min: 1900, max: 2099, placeholder: 'YYYY', count: 10, shiftCount: 100 },
93026
- };
93027
-
93028
- const BUTTON_LABEL_DONE = 'Done';
93029
- const BUTTON_LABEL_CANCEL = 'Cancel';
93030
- const CALENDAR_LABEL_TODAY = 'Today';
93031
-
93032
92975
  const isValidTimestamp = (val) => !Number.isNaN(Number(val));
93033
92976
 
93034
92977
  const isNumber = (val) => !Number.isNaN(Number(val));
@@ -93064,28 +93007,6 @@ descope-boolean-field-internal {
93064
93007
  return new Date();
93065
93008
  };
93066
93009
 
93067
- const isSupportedKey = (key) => COUNTER_SUPPORTED_KEYS.includes(key);
93068
-
93069
- const getKeyMap = (key, shiftKey, metaKey) => {
93070
- return {
93071
- refresh: metaKey && key.toLowerCase() === 'r',
93072
- tab: key === 'Tab',
93073
- shiftTab: shiftKey && key === 'Tab',
93074
- backspace: key === 'Backspace',
93075
- arrowUp: !shiftKey && key === 'ArrowUp',
93076
- arrowDown: !shiftKey && key === 'ArrowDown',
93077
- arrowLeft: !shiftKey && key === 'ArrowLeft',
93078
- arrowRight: !shiftKey && key === 'ArrowRight',
93079
- pageUp: !shiftKey && key === 'PageUp',
93080
- pageDown: !shiftKey && key === 'PageDown',
93081
- shiftArrowUp: shiftKey && key === 'ArrowUp',
93082
- shiftArrowDown: shiftKey && key === 'ArrowDown',
93083
- shiftPageUp: shiftKey && key === 'PageUp',
93084
- shiftPageDown: shiftKey && key === 'PageDown',
93085
- enter: key === 'Enter',
93086
- };
93087
- };
93088
-
93089
93010
  const getCurrentTime = () => newDate().getTime();
93090
93011
  const getFullYear = (timestamp) => newDate(timestamp).getFullYear().toString();
93091
93012
  const getMonth = (timestamp) => (newDate(timestamp).getMonth() + 1).toString();
@@ -93115,6 +93036,51 @@ descope-boolean-field-internal {
93115
93036
  <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"/>
93116
93037
  </svg>`;
93117
93038
 
93039
+ const SUPPORTED_FORMATS = ['MM/DD/YYYY', 'DD/MM/YYYY', 'YYYY/MM/DD'];
93040
+
93041
+ const DEFAULT_FORMAT = SUPPORTED_FORMATS[0];
93042
+
93043
+ const NATIVE_FORMAT = 'YYYY-MM-DD';
93044
+
93045
+ const YEARS_RANGE = 100;
93046
+
93047
+ const DIVIDER = '/';
93048
+
93049
+ const months = [
93050
+ 'January',
93051
+ 'February',
93052
+ 'March',
93053
+ 'April',
93054
+ 'May',
93055
+ 'June',
93056
+ 'July',
93057
+ 'August',
93058
+ 'September',
93059
+ 'October',
93060
+ 'November',
93061
+ 'December',
93062
+ ];
93063
+
93064
+ const weekdays = [
93065
+ 'Sunday',
93066
+ 'Monday',
93067
+ 'Tuesday',
93068
+ 'Wednesday',
93069
+ 'Thursday',
93070
+ 'Friday',
93071
+ 'Saturday',
93072
+ ];
93073
+
93074
+ const counterConfig = {
93075
+ MONTH: { id: 'month', min: 1, max: 12, placeholder: 'MM', count: 5, shiftCount: 10 },
93076
+ DAY: { id: 'day', min: 1, max: 31, placeholder: 'DD', count: 5, shiftCount: 10 },
93077
+ YEAR: { id: 'year', min: 1900, max: 2099, placeholder: 'YYYY', count: 10, shiftCount: 100 },
93078
+ };
93079
+
93080
+ const BUTTON_LABEL_DONE = 'Done';
93081
+ const BUTTON_LABEL_CANCEL = 'Cancel';
93082
+ const CALENDAR_LABEL_TODAY = 'Today';
93083
+
93118
93084
  const isValidAttrArr = (arr, count) =>
93119
93085
  Array.isArray(arr) && arr.length === count && arr.filter(Boolean).length === count;
93120
93086
 
@@ -94402,8 +94368,8 @@ descope-boolean-field-internal {
94402
94368
  this.inputElement.addEventListener('focus', this.onFocus.bind(this));
94403
94369
  this.inputElement.addEventListener('blur', this.onBlur.bind(this));
94404
94370
  this.inputElement.addEventListener('click', this.handleMouseCaretPositionChange.bind(this));
94405
- this.inputElement.addEventListener('keydown', this.handleNavKeys.bind(this));
94406
- this.inputElement.addEventListener('keydown', this.handleDigitKeys.bind(this));
94371
+ this.inputElement.addEventListener('keydown', this.handleArrowKeys.bind(this));
94372
+ this.inputElement.addEventListener('input', this.handleInput.bind(this));
94407
94373
 
94408
94374
  forwardAttrs$1(this, this.inputElement, {
94409
94375
  includeAttrs: [
@@ -94429,6 +94395,15 @@ descope-boolean-field-internal {
94429
94395
  });
94430
94396
  }
94431
94397
 
94398
+ handleInput(e) {
94399
+ if (e.data && isNumber(e.data)) {
94400
+ this.parseDigits(e.data);
94401
+ this.updateCountersDisplay();
94402
+ } else if (e.inputType) {
94403
+ this.handleNavKeys(e);
94404
+ }
94405
+ }
94406
+
94432
94407
  initPopover() {
94433
94408
  this.baseElement.trigger = ['click'];
94434
94409
  this.baseElement.withBackdrop = true;
@@ -94624,18 +94599,14 @@ descope-boolean-field-internal {
94624
94599
  this.setAttribute('pattern', formats[format].pattern);
94625
94600
  }
94626
94601
 
94627
- handleDigitKeys(e) {
94628
- if (isNumber(e.key)) {
94629
- e.preventDefault();
94602
+ parseDigits(value) {
94603
+ this.activeCounter.add(value);
94630
94604
 
94631
- this.activeCounter.add(e.key);
94632
-
94633
- if (this.activeCounter.isFull) {
94634
- this.selectNextCounter();
94635
- }
94636
-
94637
- this.setInputSelectionRange();
94605
+ if (this.activeCounter.isFull) {
94606
+ this.selectNextCounter();
94638
94607
  }
94608
+
94609
+ this.setInputSelectionRange();
94639
94610
  }
94640
94611
 
94641
94612
  getCounterIdx(caretPos) {
@@ -94705,52 +94676,49 @@ descope-boolean-field-internal {
94705
94676
  });
94706
94677
  }
94707
94678
 
94679
+ handleArrowKeys(e) {
94680
+ if (e.key === 'ArrowUp') {
94681
+ this.activeCounter.inc();
94682
+ } else if (e.key === 'ArrowDown') {
94683
+ this.activeCounter.dec();
94684
+ } else if (e.key === 'ArrowRight') {
94685
+ this.selectNextCounter();
94686
+ } else if (e.key === 'ArrowLeft') {
94687
+ this.selectPrevCounter();
94688
+ }
94689
+
94690
+ setTimeout(() => {
94691
+ this.setInputSelectionRange();
94692
+ });
94693
+ }
94694
+
94708
94695
  handleNavKeys(e) {
94709
94696
  if (this.isReadOnly) {
94710
94697
  return;
94711
94698
  }
94712
94699
 
94713
- const { key, shiftKey, metaKey } = e;
94714
- const keys = getKeyMap(key, shiftKey, metaKey);
94715
-
94716
94700
  if (this.opened) {
94717
94701
  this.closePopover();
94718
94702
  }
94719
94703
 
94720
94704
  e.preventDefault();
94721
94705
 
94722
- if (isSupportedKey(key)) {
94723
- const counter = this.activeCounter;
94706
+ if (!this.activeCounter) return;
94724
94707
 
94725
- if (!counter) return;
94726
-
94727
- const counterData = Object.values(counterConfig).find((config) => config.id === counter.id);
94728
- const { count, shiftCount } = counterData;
94729
-
94730
- if (keys.backspace) this.handleBackspace();
94731
- else if (keys.arrowUp) counter.inc();
94732
- else if (keys.arrowDown) counter.dec();
94733
- else if (keys.shiftArrowUp) counter.inc(count);
94734
- else if (keys.shiftArrowDown) counter.dec(count);
94735
- else if (keys.pageUp) counter.inc(count);
94736
- else if (keys.pageDown) counter.dec(count);
94737
- else if (keys.shiftPageUp) counter.inc(shiftCount);
94738
- else if (keys.shiftPageDown) counter.dec(shiftCount);
94739
- else if (keys.arrowRight) this.selectNextCounter();
94740
- else if (keys.arrowLeft) this.selectPrevCounter();
94741
-
94742
- this.setInputSelectionRange();
94708
+ if (e.inputType === 'deleteContentBackward') {
94709
+ this.handleBackspace();
94743
94710
  }
94711
+
94712
+ this.setInputSelectionRange();
94744
94713
  }
94745
94714
 
94746
94715
  handleBackspace() {
94747
- const counter = this.activeCounter;
94748
-
94749
- if (counter.isEmpty) {
94716
+ if (this.activeCounter.isEmpty) {
94717
+ this.activeCounter.clear();
94750
94718
  this.selectPrevCounter();
94751
94719
  this.setInputSelectionRange();
94752
94720
  } else {
94753
- counter.del();
94721
+ this.activeCounter.del();
94754
94722
  }
94755
94723
  }
94756
94724
 
@@ -96569,8 +96537,11 @@ descope-boolean-field-internal {
96569
96537
  // On reportValidity we want to set the caret at the end of the input value.
96570
96538
  // Since checkValidity triggers `focus` on the input, it sets the caret at the start of the input,
96571
96539
  // regardless the existing value.
96540
+ const origInputType = ele.type;
96541
+ ele.setAttribute('type', 'text');
96572
96542
  setTimeout(() => {
96573
96543
  ele.setSelectionRange?.(ele.value.length, ele.value.length);
96544
+ ele.setAttribute('type', origInputType);
96574
96545
  });
96575
96546
 
96576
96547
  return this.activeInput.reportValidity();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/flow-components",
3
- "version": "2.0.550",
3
+ "version": "2.0.552",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -112,7 +112,7 @@
112
112
  "webpack-dev-server": "5.2.1"
113
113
  },
114
114
  "dependencies": {
115
- "@descope/web-components-ui": "1.91.0"
115
+ "@descope/web-components-ui": "1.93.0"
116
116
  },
117
117
  "peerDependencies": {
118
118
  "react": ">= 18"