@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/index.esm.js CHANGED
@@ -5239,63 +5239,6 @@ loadingIndicatorStyles = `
5239
5239
 
5240
5240
  customElements.define(componentName$17, ButtonClass);
5241
5241
 
5242
- const SUPPORTED_FORMATS = ['MM/DD/YYYY', 'DD/MM/YYYY', 'YYYY/MM/DD'];
5243
-
5244
- const DEFAULT_FORMAT = SUPPORTED_FORMATS[0];
5245
-
5246
- const NATIVE_FORMAT = 'YYYY-MM-DD';
5247
-
5248
- const YEARS_RANGE = 100;
5249
-
5250
- const DIVIDER = '/';
5251
-
5252
- const COUNTER_SUPPORTED_KEYS = [
5253
- 'Backspace',
5254
- 'ArrowLeft',
5255
- 'ArrowRight',
5256
- 'ArrowDown',
5257
- 'ArrowUp',
5258
- 'PageUp',
5259
- 'PageDown',
5260
- 'Meta',
5261
- 'Enter',
5262
- ];
5263
-
5264
- const months = [
5265
- 'January',
5266
- 'February',
5267
- 'March',
5268
- 'April',
5269
- 'May',
5270
- 'June',
5271
- 'July',
5272
- 'August',
5273
- 'September',
5274
- 'October',
5275
- 'November',
5276
- 'December',
5277
- ];
5278
-
5279
- const weekdays = [
5280
- 'Sunday',
5281
- 'Monday',
5282
- 'Tuesday',
5283
- 'Wednesday',
5284
- 'Thursday',
5285
- 'Friday',
5286
- 'Saturday',
5287
- ];
5288
-
5289
- const counterConfig = {
5290
- MONTH: { id: 'month', min: 1, max: 12, placeholder: 'MM', count: 5, shiftCount: 10 },
5291
- DAY: { id: 'day', min: 1, max: 31, placeholder: 'DD', count: 5, shiftCount: 10 },
5292
- YEAR: { id: 'year', min: 1900, max: 2099, placeholder: 'YYYY', count: 10, shiftCount: 100 },
5293
- };
5294
-
5295
- const BUTTON_LABEL_DONE = 'Done';
5296
- const BUTTON_LABEL_CANCEL = 'Cancel';
5297
- const CALENDAR_LABEL_TODAY = 'Today';
5298
-
5299
5242
  const isValidTimestamp = (val) => !Number.isNaN(Number(val));
5300
5243
 
5301
5244
  const isNumber = (val) => !Number.isNaN(Number(val));
@@ -5331,28 +5274,6 @@ const newDate = (date) => {
5331
5274
  return new Date();
5332
5275
  };
5333
5276
 
5334
- const isSupportedKey = (key) => COUNTER_SUPPORTED_KEYS.includes(key);
5335
-
5336
- const getKeyMap = (key, shiftKey, metaKey) => {
5337
- return {
5338
- refresh: metaKey && key.toLowerCase() === 'r',
5339
- tab: key === 'Tab',
5340
- shiftTab: shiftKey && key === 'Tab',
5341
- backspace: key === 'Backspace',
5342
- arrowUp: !shiftKey && key === 'ArrowUp',
5343
- arrowDown: !shiftKey && key === 'ArrowDown',
5344
- arrowLeft: !shiftKey && key === 'ArrowLeft',
5345
- arrowRight: !shiftKey && key === 'ArrowRight',
5346
- pageUp: !shiftKey && key === 'PageUp',
5347
- pageDown: !shiftKey && key === 'PageDown',
5348
- shiftArrowUp: shiftKey && key === 'ArrowUp',
5349
- shiftArrowDown: shiftKey && key === 'ArrowDown',
5350
- shiftPageUp: shiftKey && key === 'PageUp',
5351
- shiftPageDown: shiftKey && key === 'PageDown',
5352
- enter: key === 'Enter',
5353
- };
5354
- };
5355
-
5356
5277
  const getCurrentTime = () => newDate().getTime();
5357
5278
  const getFullYear = (timestamp) => newDate(timestamp).getFullYear().toString();
5358
5279
  const getMonth = (timestamp) => (newDate(timestamp).getMonth() + 1).toString();
@@ -5382,6 +5303,51 @@ const arrowLeftIcon = `<svg width="24" height="24" viewBox="0 0 24 24" fill="non
5382
5303
  <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"/>
5383
5304
  </svg>`;
5384
5305
 
5306
+ const SUPPORTED_FORMATS = ['MM/DD/YYYY', 'DD/MM/YYYY', 'YYYY/MM/DD'];
5307
+
5308
+ const DEFAULT_FORMAT = SUPPORTED_FORMATS[0];
5309
+
5310
+ const NATIVE_FORMAT = 'YYYY-MM-DD';
5311
+
5312
+ const YEARS_RANGE = 100;
5313
+
5314
+ const DIVIDER = '/';
5315
+
5316
+ const months = [
5317
+ 'January',
5318
+ 'February',
5319
+ 'March',
5320
+ 'April',
5321
+ 'May',
5322
+ 'June',
5323
+ 'July',
5324
+ 'August',
5325
+ 'September',
5326
+ 'October',
5327
+ 'November',
5328
+ 'December',
5329
+ ];
5330
+
5331
+ const weekdays = [
5332
+ 'Sunday',
5333
+ 'Monday',
5334
+ 'Tuesday',
5335
+ 'Wednesday',
5336
+ 'Thursday',
5337
+ 'Friday',
5338
+ 'Saturday',
5339
+ ];
5340
+
5341
+ 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 },
5345
+ };
5346
+
5347
+ const BUTTON_LABEL_DONE = 'Done';
5348
+ const BUTTON_LABEL_CANCEL = 'Cancel';
5349
+ const CALENDAR_LABEL_TODAY = 'Today';
5350
+
5385
5351
  const isValidAttrArr = (arr, count) =>
5386
5352
  Array.isArray(arr) && arr.length === count && arr.filter(Boolean).length === count;
5387
5353
 
@@ -6862,8 +6828,8 @@ class RawDateFieldClass extends BaseInputClass$a {
6862
6828
  this.inputElement.addEventListener('focus', this.onFocus.bind(this));
6863
6829
  this.inputElement.addEventListener('blur', this.onBlur.bind(this));
6864
6830
  this.inputElement.addEventListener('click', this.handleMouseCaretPositionChange.bind(this));
6865
- this.inputElement.addEventListener('keydown', this.handleNavKeys.bind(this));
6866
- this.inputElement.addEventListener('keydown', this.handleDigitKeys.bind(this));
6831
+ this.inputElement.addEventListener('keydown', this.handleArrowKeys.bind(this));
6832
+ this.inputElement.addEventListener('input', this.handleInput.bind(this));
6867
6833
 
6868
6834
  forwardAttrs$1(this, this.inputElement, {
6869
6835
  includeAttrs: [
@@ -6889,6 +6855,15 @@ class RawDateFieldClass extends BaseInputClass$a {
6889
6855
  });
6890
6856
  }
6891
6857
 
6858
+ handleInput(e) {
6859
+ if (e.data && isNumber(e.data)) {
6860
+ this.parseDigits(e.data);
6861
+ this.updateCountersDisplay();
6862
+ } else if (e.inputType) {
6863
+ this.handleNavKeys(e);
6864
+ }
6865
+ }
6866
+
6892
6867
  initPopover() {
6893
6868
  this.baseElement.trigger = ['click'];
6894
6869
  this.baseElement.withBackdrop = true;
@@ -7084,18 +7059,14 @@ class RawDateFieldClass extends BaseInputClass$a {
7084
7059
  this.setAttribute('pattern', formats[format].pattern);
7085
7060
  }
7086
7061
 
7087
- handleDigitKeys(e) {
7088
- if (isNumber(e.key)) {
7089
- e.preventDefault();
7062
+ parseDigits(value) {
7063
+ this.activeCounter.add(value);
7090
7064
 
7091
- this.activeCounter.add(e.key);
7092
-
7093
- if (this.activeCounter.isFull) {
7094
- this.selectNextCounter();
7095
- }
7096
-
7097
- this.setInputSelectionRange();
7065
+ if (this.activeCounter.isFull) {
7066
+ this.selectNextCounter();
7098
7067
  }
7068
+
7069
+ this.setInputSelectionRange();
7099
7070
  }
7100
7071
 
7101
7072
  getCounterIdx(caretPos) {
@@ -7165,52 +7136,49 @@ class RawDateFieldClass extends BaseInputClass$a {
7165
7136
  });
7166
7137
  }
7167
7138
 
7139
+ handleArrowKeys(e) {
7140
+ if (e.key === 'ArrowUp') {
7141
+ this.activeCounter.inc();
7142
+ } else if (e.key === 'ArrowDown') {
7143
+ this.activeCounter.dec();
7144
+ } else if (e.key === 'ArrowRight') {
7145
+ this.selectNextCounter();
7146
+ } else if (e.key === 'ArrowLeft') {
7147
+ this.selectPrevCounter();
7148
+ }
7149
+
7150
+ setTimeout(() => {
7151
+ this.setInputSelectionRange();
7152
+ });
7153
+ }
7154
+
7168
7155
  handleNavKeys(e) {
7169
7156
  if (this.isReadOnly) {
7170
7157
  return;
7171
7158
  }
7172
7159
 
7173
- const { key, shiftKey, metaKey } = e;
7174
- const keys = getKeyMap(key, shiftKey, metaKey);
7175
-
7176
7160
  if (this.opened) {
7177
7161
  this.closePopover();
7178
7162
  }
7179
7163
 
7180
7164
  e.preventDefault();
7181
7165
 
7182
- if (isSupportedKey(key)) {
7183
- const counter = this.activeCounter;
7166
+ if (!this.activeCounter) return;
7184
7167
 
7185
- if (!counter) return;
7186
-
7187
- const counterData = Object.values(counterConfig).find((config) => config.id === counter.id);
7188
- const { count, shiftCount } = counterData;
7189
-
7190
- if (keys.backspace) this.handleBackspace();
7191
- else if (keys.arrowUp) counter.inc();
7192
- else if (keys.arrowDown) counter.dec();
7193
- else if (keys.shiftArrowUp) counter.inc(count);
7194
- else if (keys.shiftArrowDown) counter.dec(count);
7195
- else if (keys.pageUp) counter.inc(count);
7196
- else if (keys.pageDown) counter.dec(count);
7197
- else if (keys.shiftPageUp) counter.inc(shiftCount);
7198
- else if (keys.shiftPageDown) counter.dec(shiftCount);
7199
- else if (keys.arrowRight) this.selectNextCounter();
7200
- else if (keys.arrowLeft) this.selectPrevCounter();
7201
-
7202
- this.setInputSelectionRange();
7168
+ if (e.inputType === 'deleteContentBackward') {
7169
+ this.handleBackspace();
7203
7170
  }
7171
+
7172
+ this.setInputSelectionRange();
7204
7173
  }
7205
7174
 
7206
7175
  handleBackspace() {
7207
- const counter = this.activeCounter;
7208
-
7209
- if (counter.isEmpty) {
7176
+ if (this.activeCounter.isEmpty) {
7177
+ this.activeCounter.clear();
7210
7178
  this.selectPrevCounter();
7211
7179
  this.setInputSelectionRange();
7212
7180
  } else {
7213
- counter.del();
7181
+ this.activeCounter.del();
7214
7182
  }
7215
7183
  }
7216
7184
 
@@ -18488,8 +18456,11 @@ class RawHybridField extends BaseClass$2 {
18488
18456
  // On reportValidity we want to set the caret at the end of the input value.
18489
18457
  // Since checkValidity triggers `focus` on the input, it sets the caret at the start of the input,
18490
18458
  // regardless the existing value.
18459
+ const origInputType = ele.type;
18460
+ ele.setAttribute('type', 'text');
18491
18461
  setTimeout(() => {
18492
18462
  ele.setSelectionRange?.(ele.value.length, ele.value.length);
18463
+ ele.setAttribute('type', origInputType);
18493
18464
  });
18494
18465
 
18495
18466
  return this.activeInput.reportValidity();