@descope/web-components-ui 1.133.0 → 1.135.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.133.0",
3
+ "version": "1.135.0",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -97,7 +97,7 @@
97
97
  "@descope-ui/descope-link": "0.1.0",
98
98
  "@descope-ui/descope-enriched-text": "0.0.4",
99
99
  "@descope-ui/descope-badge": "0.1.0",
100
- "@descope-ui/descope-trusted-devices": "0.1.0"
100
+ "@descope-ui/descope-trusted-devices": "0.1.1"
101
101
  },
102
102
  "overrides": {
103
103
  "@vaadin/avatar": "24.3.4",
@@ -8,7 +8,6 @@ import {
8
8
  import { forwardAttrs, getComponentName } from '../../helpers/componentHelpers';
9
9
  import { compose } from '../../helpers';
10
10
  import {
11
- newDate,
12
11
  isValidEpoch,
13
12
  formatEpoch,
14
13
  isNumber,
@@ -30,6 +29,7 @@ import { DateCounter } from './DateCounterClass';
30
29
  import { TextFieldClass } from '../descope-text-field/TextFieldClass';
31
30
  import { injectStyle } from '@descope-ui/common/components-helpers';
32
31
  import { parseDateString } from './helpers';
32
+ import { newDate } from './date-utils';
33
33
 
34
34
  export const componentName = getComponentName('date-field');
35
35
 
@@ -0,0 +1,24 @@
1
+ // polyfill for safari Date API (which doesn't accept "YYYY-MM-DD" string as value)
2
+ export const newDate = (date, isUtcTime) => {
3
+ if (typeof date === 'number') {
4
+ return new Date(date);
5
+ }
6
+ if (typeof date === 'string') {
7
+ const d = new Date(date.replace(/-/g, '/'));
8
+ if (isUtcTime) {
9
+ return new Date(
10
+ Date.UTC(
11
+ d.getFullYear(),
12
+ d.getMonth(),
13
+ d.getDate(),
14
+ d.getHours(),
15
+ d.getMinutes(),
16
+ d.getSeconds(),
17
+ d.getMilliseconds()
18
+ )
19
+ );
20
+ }
21
+ return new Date(d);
22
+ }
23
+ return new Date();
24
+ };
@@ -7,7 +7,6 @@ import {
7
7
  getCurrentDay,
8
8
  getPartsFromEpoch,
9
9
  isValidEpoch,
10
- newDate,
11
10
  formatEpoch,
12
11
  getCurrentTime,
13
12
  getFullYear,
@@ -36,6 +35,7 @@ import {
36
35
  } from './helpers';
37
36
  import { ButtonClass } from '@descope-ui/descope-button/class';
38
37
  import { injectStyle } from '@descope-ui/common/components-helpers';
38
+ import { newDate } from '../date-utils';
39
39
 
40
40
  export const componentName = getComponentName('calendar');
41
41
 
@@ -1,5 +1,6 @@
1
1
  import { months, weekdays } from '../consts';
2
- import { getPartsFromEpoch, newDate } from '../helpers';
2
+ import { getPartsFromEpoch } from '../helpers';
3
+ import { newDate } from '../date-utils';
3
4
 
4
5
  const isValidAttrArr = (arr, count) =>
5
6
  Array.isArray(arr) && arr.length === count && arr.filter(Boolean).length === count;
@@ -1,5 +1,5 @@
1
1
  import { DIVIDER, SUPPORTED_FORMATS } from './consts';
2
- import { newDate } from './helpers';
2
+ import { newDate } from './date-utils';
3
3
 
4
4
  const patterns = {
5
5
  MM: '(0?[1-9]|1[0-2])',
@@ -1,4 +1,5 @@
1
1
  import { formats } from './formats';
2
+ import { newDate } from './date-utils';
2
3
 
3
4
  export const isValidEpoch = (val) => !Number.isNaN(Number(val));
4
5
 
@@ -24,31 +25,6 @@ export const formatEpoch = (epoch, format) => {
24
25
  return format.replace(/DD|MM|YYYY/g, (match) => parts[match]);
25
26
  };
26
27
 
27
- // polyfill for safari Date API (which doesn't accept "YYYY-MM-DD" string as value)
28
- export const newDate = (date, isUtcTime) => {
29
- if (typeof date === 'number') {
30
- return new Date(date);
31
- }
32
- if (typeof date === 'string') {
33
- const d = new Date(date.replace(/-/g, '/'));
34
- if (isUtcTime) {
35
- return new Date(
36
- Date.UTC(
37
- d.getFullYear(),
38
- d.getMonth(),
39
- d.getDate(),
40
- d.getHours(),
41
- d.getMinutes(),
42
- d.getSeconds(),
43
- d.getMilliseconds()
44
- )
45
- );
46
- }
47
- return new Date(d);
48
- }
49
- return new Date();
50
- };
51
-
52
28
  export const getCurrentTime = () => newDate().getTime();
53
29
  export const getFullYear = (epoch) => newDate(epoch).getFullYear().toString();
54
30
  export const getMonth = (epoch) => (newDate(epoch).getMonth() + 1).toString();