@descope/web-components-ui 1.115.0 → 1.117.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/web-components-ui",
3
- "version": "1.115.0",
3
+ "version": "1.117.0",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -89,7 +89,7 @@
89
89
  "@descope-ui/descope-list": "0.0.1",
90
90
  "@descope-ui/descope-list-item": "0.0.1",
91
91
  "@descope-ui/descope-apps-list": "0.0.1",
92
- "@descope-ui/descope-outbound-apps": "0.0.4",
92
+ "@descope-ui/descope-outbound-apps": "0.0.5",
93
93
  "@descope-ui/descope-password-strength": "0.0.13",
94
94
  "@descope-ui/descope-collapsible-container": "0.0.18",
95
95
  "@descope-ui/descope-recovery-codes": "0.0.6",
@@ -9,11 +9,12 @@ import { forwardAttrs, getComponentName } from '../../helpers/componentHelpers';
9
9
  import { compose } from '../../helpers';
10
10
  import {
11
11
  newDate,
12
- isValidTimestamp,
13
- formatTimestamp,
12
+ isValidEpoch,
13
+ formatEpoch,
14
14
  isNumber,
15
15
  getCurrentTime,
16
16
  overrideConstructedStylesheet,
17
+ dateToEpoch,
17
18
  } from './helpers';
18
19
  import { formats } from './formats';
19
20
  import { calendarIcon } from './icons';
@@ -37,12 +38,19 @@ export const componentName = getComponentName('date-field');
37
38
  const BASE_SELECTOR = 'vaadin-popover';
38
39
  const BaseInputClass = createBaseInputClass({ componentName, baseSelector: BASE_SELECTOR });
39
40
 
40
- const dateFieldAttrs = ['format', 'opened', 'initial-value', 'readonly', 'disable-calendar'];
41
+ const dateFieldAttrs = [
42
+ 'format',
43
+ 'opened',
44
+ 'initial-value',
45
+ 'readonly',
46
+ 'disable-calendar',
47
+ 'utc-time',
48
+ ];
41
49
  const calendarAttrs = ['years-range', 'calendar-months', 'calendar-weekdays'];
42
50
  const observedAttrs = [...dateFieldAttrs, ...calendarAttrs];
43
51
 
44
52
  class RawDateFieldClass extends BaseInputClass {
45
- timestamp = '';
53
+ epoch = '';
46
54
 
47
55
  format = DEFAULT_FORMAT;
48
56
 
@@ -54,10 +62,10 @@ class RawDateFieldClass extends BaseInputClass {
54
62
 
55
63
  updateValue() {
56
64
  if (this.isCountersOutOfRange) {
57
- this.updateTimestamp('');
65
+ this.updateEpoch('');
58
66
  } else {
59
67
  const date = formats[this.format].getDate(this.inputElement.value);
60
- this.updateTimestamp(date.getTime());
68
+ this.updateEpoch(dateToEpoch(date, this.isUtcTime));
61
69
  }
62
70
  }
63
71
 
@@ -68,11 +76,11 @@ class RawDateFieldClass extends BaseInputClass {
68
76
  this.#dispatchInput();
69
77
  };
70
78
 
71
- updateTimestamp(epochOrDate) {
79
+ updateEpoch(epochOrDate) {
72
80
  if (!epochOrDate) {
73
- this.timestamp = '';
81
+ this.epoch = '';
74
82
  } else {
75
- this.timestamp = newDate(epochOrDate).getTime();
83
+ this.epoch = dateToEpoch(newDate(epochOrDate), this.isUtcTime);
76
84
  }
77
85
  }
78
86
 
@@ -145,11 +153,11 @@ class RawDateFieldClass extends BaseInputClass {
145
153
  return this.getAttribute('opened') === 'true';
146
154
  }
147
155
 
148
- // returns the input's value as a timestamp
156
+ // returns the input's value as a epoch
149
157
  get displayValueEpoch() {
150
158
  const date = formats[this.format].getDate(this.inputElement.value);
151
159
 
152
- if (!isValidTimestamp(date?.getTime())) {
160
+ if (!isValidEpoch(date?.getTime())) {
153
161
  return null;
154
162
  }
155
163
 
@@ -197,15 +205,15 @@ class RawDateFieldClass extends BaseInputClass {
197
205
  if (this.isInvalidDate()) {
198
206
  return '';
199
207
  }
200
- return this.timestamp;
208
+ return this.epoch;
201
209
  }
202
210
 
203
211
  set value(val) {
204
212
  if (val) {
205
- this.updateTimestamp(val);
213
+ this.updateEpoch(val);
206
214
  this.updateDateCounters(newDate(val));
207
215
  } else {
208
- this.updateTimestamp('');
216
+ this.updateEpoch('');
209
217
  }
210
218
  }
211
219
 
@@ -221,6 +229,10 @@ class RawDateFieldClass extends BaseInputClass {
221
229
  return this.getAttribute('disable-calendar') === 'true';
222
230
  }
223
231
 
232
+ get isUtcTime() {
233
+ return this.getAttribute('utc-time') === 'true';
234
+ }
235
+
224
236
  get isSelectAll() {
225
237
  const inputEle = this.inputElement.baseElement.inputElement;
226
238
  return inputEle.value.length === inputEle.selectionStart + inputEle.selectionEnd;
@@ -235,7 +247,7 @@ class RawDateFieldClass extends BaseInputClass {
235
247
  }
236
248
 
237
249
  updateInputDisplay() {
238
- this.inputElement.value = formatTimestamp(newDate(this.countersValue).getTime(), this.format);
250
+ this.inputElement.value = formatEpoch(newDate(this.countersValue).getTime(), this.format);
239
251
  }
240
252
 
241
253
  init() {
@@ -426,7 +438,7 @@ class RawDateFieldClass extends BaseInputClass {
426
438
 
427
439
  const calendarDate = newDate(this.calendar.value);
428
440
 
429
- this.value = calendarDate.getTime();
441
+ this.value = dateToEpoch(calendarDate, this.isUtcTime);
430
442
 
431
443
  this.getCounterById('year').replaceValue(calendarDate.getFullYear());
432
444
  this.getCounterById('month').replaceValue(calendarDate.getMonth() + 1);
@@ -440,17 +452,17 @@ class RawDateFieldClass extends BaseInputClass {
440
452
 
441
453
  updateCalendarView() {
442
454
  const validInputVal =
443
- isValidTimestamp(newDate(this.inputElement.value || '').getTime()) &&
455
+ isValidEpoch(newDate(this.inputElement.value || '').getTime()) &&
444
456
  formats[this.format].validate(this.inputElement.value);
445
457
 
446
458
  if (this.displayValueEpoch || validInputVal) {
447
459
  this.calendar.setAttribute(
448
460
  'initial-value',
449
- formatTimestamp(this.displayValueEpoch || this.timestamp, NATIVE_FORMAT)
461
+ formatEpoch(this.displayValueEpoch || this.epoch, NATIVE_FORMAT)
450
462
  );
451
463
  } else {
452
464
  this.calendar.clearValue();
453
- this.calendar.setAttribute('preview', formatTimestamp(getCurrentTime(), NATIVE_FORMAT));
465
+ this.calendar.setAttribute('preview', formatEpoch(getCurrentTime(), NATIVE_FORMAT));
454
466
  }
455
467
 
456
468
  forwardAttrs(this, this.calendar, {
@@ -599,13 +611,13 @@ class RawDateFieldClass extends BaseInputClass {
599
611
  this.dateCounters.forEach((dc) => {
600
612
  switch (dc.id) {
601
613
  case counterConfig.MONTH.id:
602
- dc.set(date.getMonth() + 1);
614
+ dc.set(this.isUtcTime ? date.getUTCMonth() + 1 : date.getMonth() + 1);
603
615
  break;
604
616
  case counterConfig.YEAR.id:
605
- dc.set(date.getFullYear());
617
+ dc.set(this.isUtcTime ? date.getUTCFullYear() : date.getFullYear());
606
618
  break;
607
619
  case counterConfig.DAY.id:
608
- dc.set(date.getDate());
620
+ dc.set(this.isUtcTime ? date.getUTCDate() : date.getDate());
609
621
  break;
610
622
  default:
611
623
  break;
@@ -768,12 +780,22 @@ class RawDateFieldClass extends BaseInputClass {
768
780
  year: '',
769
781
  };
770
782
 
771
- try {
772
- const date = newDate(this.timestamp);
783
+ if (!this.epoch) {
784
+ return ret;
785
+ }
773
786
 
774
- ret.month = date.getMonth() + 1;
775
- ret.day = date.getDate();
776
- ret.year = date.getFullYear();
787
+ try {
788
+ const date = newDate(this.epoch);
789
+
790
+ if (this.isUtcTime) {
791
+ ret.month = date.getUTCMonth() + 1;
792
+ ret.day = date.getUTCDate();
793
+ ret.year = date.getUTCFullYear();
794
+ } else {
795
+ ret.month = date.getMonth() + 1;
796
+ ret.day = date.getDate();
797
+ ret.year = date.getFullYear();
798
+ }
777
799
  } catch (e) {}
778
800
 
779
801
  return ret;
@@ -817,7 +839,7 @@ class RawDateFieldClass extends BaseInputClass {
817
839
  const validDate = parseDateString(pastedData, this.format);
818
840
 
819
841
  if (validDate) {
820
- this.value = validDate.getTime();
842
+ this.value = dateToEpoch(validDate, this.isUtcTime);
821
843
  this.onDateCounterChange();
822
844
 
823
845
  // select all
@@ -5,10 +5,10 @@ import { inputFloatingLabelStyle } from '../../../helpers/themeHelpers/resetHelp
5
5
  import { componentNameValidationMixin, createStyleMixin, draggableMixin } from '../../../mixins';
6
6
  import {
7
7
  getCurrentDay,
8
- getTimestampParts,
9
- isValidTimestamp,
8
+ getPartsFromEpoch,
9
+ isValidEpoch,
10
10
  newDate,
11
- formatTimestamp,
11
+ formatEpoch,
12
12
  getCurrentTime,
13
13
  getFullYear,
14
14
  getMonth,
@@ -61,11 +61,11 @@ class RawCalendar extends BaseInputClass {
61
61
  return [].concat(BaseInputClass.observedAttributes || [], observedAttrs, calendarUiAttrs);
62
62
  }
63
63
 
64
- // preview state timestamp
64
+ // preview state epoch
65
65
  preview;
66
66
 
67
- // value timestamp
68
- timestamp;
67
+ // value epoch
68
+ epoch;
69
69
 
70
70
  constructor() {
71
71
  super();
@@ -151,23 +151,23 @@ class RawCalendar extends BaseInputClass {
151
151
  set value(val) {
152
152
  if (!val) return;
153
153
 
154
- const timestamp = newDate(val).getTime();
154
+ const epoch = newDate(val).getTime();
155
155
 
156
- if (!isValidTimestamp(timestamp) || timestamp === this.timestmap) {
156
+ if (!isValidEpoch(epoch) || epoch === this.epoch) {
157
157
  return;
158
158
  }
159
159
 
160
- this.timestamp = timestamp;
160
+ this.epoch = epoch;
161
161
 
162
162
  this.renderCalendar();
163
163
  }
164
164
 
165
165
  get value() {
166
- return this.timestamp ? formatTimestamp(this.timestamp, NATIVE_FORMAT) : '';
166
+ return this.epoch ? formatEpoch(this.epoch, NATIVE_FORMAT) : '';
167
167
  }
168
168
 
169
169
  get isSelectedView() {
170
- return isViewVisible(this.preview, this.timestamp);
170
+ return isViewVisible(this.preview, this.epoch);
171
171
  }
172
172
 
173
173
  get isTodayView() {
@@ -284,14 +284,14 @@ class RawCalendar extends BaseInputClass {
284
284
  clearSelectedDay() {
285
285
  this.getSelectedDayEle()?.removeAttribute('data-selected');
286
286
  this.submitButton.setAttribute('disabled', 'true');
287
- this.timestamp = '';
287
+ this.epoch = '';
288
288
  }
289
289
 
290
290
  updateInputs() {
291
291
  if (this.yearInput && this.monthInput) {
292
- const timestamp = this.preview || getCurrentTime();
293
- const year = getFullYear(timestamp);
294
- const month = getMonth(timestamp);
292
+ const epoch = this.preview || getCurrentTime();
293
+ const year = getFullYear(epoch);
294
+ const month = getMonth(epoch);
295
295
  this.monthInput.value = month;
296
296
  // For the yearInput we update the base element directly to properly trigger the change event
297
297
  // since this can be a custom value
@@ -303,9 +303,9 @@ class RawCalendar extends BaseInputClass {
303
303
 
304
304
  renderCalendar() {
305
305
  const date = newDate(this.preview || getCurrentTime());
306
- const timestamp = date.getTime();
306
+ const epoch = date.getTime();
307
307
 
308
- const [year, month] = getTimestampParts(timestamp);
308
+ const [year, month] = getPartsFromEpoch(epoch);
309
309
 
310
310
  if (this.calendar) {
311
311
  this.calendar.innerHTML = createMonthView(year, month, truncateWeekdays(this.weekdayNames));
@@ -324,7 +324,7 @@ class RawCalendar extends BaseInputClass {
324
324
  if (this.isDisabled) return;
325
325
  const date = newDate(this.preview);
326
326
  date.setDate(Number(e.target.getAttribute('data-date-day')));
327
- this.value = formatTimestamp(date.getTime(), NATIVE_FORMAT);
327
+ this.value = formatEpoch(date.getTime(), NATIVE_FORMAT);
328
328
  this.dispatchEvent(new CustomEvent('day-changed', { detail: date }));
329
329
  }
330
330
 
@@ -355,7 +355,7 @@ class RawCalendar extends BaseInputClass {
355
355
  }
356
356
 
357
357
  getSelectedDayEle() {
358
- const day = newDate(this.timestamp).getDate();
358
+ const day = newDate(this.epoch).getDate();
359
359
  return this.calendar?.querySelector(`[data-date-day="${day}"]`);
360
360
  }
361
361
 
@@ -380,8 +380,8 @@ class RawCalendar extends BaseInputClass {
380
380
  if (this.isTodayView) {
381
381
  const ele = this.getCurrentDayEle();
382
382
  const title = this.getAttribute('calendar-label-today') || CALENDAR_LABEL_TODAY;
383
- ele.setAttribute('data-current-day', 'true');
384
- ele.setAttribute('title', title);
383
+ ele?.setAttribute('data-current-day', 'true');
384
+ ele?.setAttribute('title', title);
385
385
  }
386
386
  }
387
387
 
@@ -404,7 +404,7 @@ class RawCalendar extends BaseInputClass {
404
404
  }
405
405
 
406
406
  clearValue() {
407
- this.timestamp = '';
407
+ this.epoch = '';
408
408
  this.value = '';
409
409
  this.removeAttribute('preview');
410
410
  this.submitButton.setAttribute('disabled', 'true');
@@ -417,11 +417,11 @@ class RawCalendar extends BaseInputClass {
417
417
  }
418
418
 
419
419
  const date = newDate(newValue);
420
- const timestamp = date.getTime();
420
+ const epoch = date.getTime();
421
421
 
422
- if (isValidTimestamp(timestamp)) {
423
- this.timestamp = timestamp;
424
- this.preview = timestamp;
422
+ if (isValidEpoch(epoch)) {
423
+ this.epoch = epoch;
424
+ this.preview = epoch;
425
425
  } else {
426
426
  this.clearValue();
427
427
  }
@@ -1,5 +1,5 @@
1
1
  import { months, weekdays } from '../consts';
2
- import { getTimestampParts, newDate } from '../helpers';
2
+ import { getPartsFromEpoch, newDate } from '../helpers';
3
3
 
4
4
  const isValidAttrArr = (arr, count) =>
5
5
  Array.isArray(arr) && arr.length === count && arr.filter(Boolean).length === count;
@@ -91,9 +91,9 @@ export const getMonthsOptions = (customMonths = months) =>
91
91
  .map((item, index) => comboBoxItemTpl({ label: item, dataId: index + 1, dataName: item }))
92
92
  .join('');
93
93
 
94
- export const isViewVisible = (selectionTimestamp, previewTimestamp) => {
95
- const [previewYear, previewMonth] = getTimestampParts(previewTimestamp);
96
- const [selectedYear, selectedMonth] = getTimestampParts(selectionTimestamp);
94
+ export const isViewVisible = (selectionEpoch, previewEpoch) => {
95
+ const [previewYear, previewMonth] = getPartsFromEpoch(previewEpoch);
96
+ const [selectedYear, selectedMonth] = getPartsFromEpoch(selectionEpoch);
97
97
  return selectedYear === previewYear && selectedMonth === previewMonth;
98
98
  };
99
99
 
@@ -154,8 +154,8 @@ export const ensureShortWeekdayNamesArr = (attrVal) => {
154
154
 
155
155
  export const truncateWeekdays = (arr) => arr.map((d) => d.substring(0, 3));
156
156
 
157
- export const prevMonth = (timestamp) => {
158
- const date = newDate(timestamp);
157
+ export const prevMonth = (epoch) => {
158
+ const date = newDate(epoch);
159
159
  const month = date.getMonth();
160
160
 
161
161
  if (month === 0) {
@@ -169,8 +169,8 @@ export const prevMonth = (timestamp) => {
169
169
  return date;
170
170
  };
171
171
 
172
- export const nextMonth = (timestamp) => {
173
- const date = newDate(timestamp);
172
+ export const nextMonth = (epoch) => {
173
+ const date = newDate(epoch);
174
174
  const month = date.getMonth();
175
175
 
176
176
  if (month === 11) {
@@ -1,19 +1,19 @@
1
1
  import { formats } from './formats';
2
2
 
3
- export const isValidTimestamp = (val) => !Number.isNaN(Number(val));
3
+ export const isValidEpoch = (val) => !Number.isNaN(Number(val));
4
4
 
5
5
  export const isNumber = (val) => !!String(val || '').trim() && !Number.isNaN(Number(val));
6
6
 
7
- export const getTimestampParts = (timestamp) => {
8
- const date = newDate(timestamp);
7
+ export const getPartsFromEpoch = (epoch) => {
8
+ const date = newDate(epoch);
9
9
  const year = date.getFullYear();
10
10
  const month = date.getMonth() + 1;
11
11
  const day = date.getDate();
12
12
  return [year, month, day];
13
13
  };
14
14
 
15
- export const formatTimestamp = (timestamp, format) => {
16
- const [year, month, day] = getTimestampParts(timestamp);
15
+ export const formatEpoch = (epoch, format) => {
16
+ const [year, month, day] = getPartsFromEpoch(epoch);
17
17
 
18
18
  const parts = {
19
19
  DD: String(day).padStart(2, '0'),
@@ -36,8 +36,8 @@ export const newDate = (date) => {
36
36
  };
37
37
 
38
38
  export const getCurrentTime = () => newDate().getTime();
39
- export const getFullYear = (timestamp) => newDate(timestamp).getFullYear().toString();
40
- export const getMonth = (timestamp) => (newDate(timestamp).getMonth() + 1).toString();
39
+ export const getFullYear = (epoch) => newDate(epoch).getFullYear().toString();
40
+ export const getMonth = (epoch) => (newDate(epoch).getMonth() + 1).toString();
41
41
  export const getCurrentDay = () => newDate().getDate();
42
42
  export const getCurrentYear = () => newDate().getFullYear().toString();
43
43
 
@@ -55,3 +55,10 @@ export const parseDateString = (val, format) => {
55
55
  if (!trimmed) return null;
56
56
  return formats[format].getDate(trimmed);
57
57
  };
58
+
59
+ export const dateToEpoch = (date, isUtc) => {
60
+ if (isUtc) {
61
+ return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())).getTime();
62
+ }
63
+ return date.getTime();
64
+ };
package/src/constants.js CHANGED
@@ -2,3 +2,5 @@ export const DESCOPE_PREFIX = 'descope';
2
2
  export const CSS_SELECTOR_SPECIFIER_MULTIPLY = 3;
3
3
  export const BASE_THEME_SECTION = 'host';
4
4
  export const PORTAL_THEME_PREFIX = '@';
5
+
6
+ export const TEST_CONST_FOR_RELEASE_TRIGGER = 'true';