@pega/custom-dx-components 0.23.31 → 0.23.33
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 +1 -1
- package/src/tasks/create/templates/Constellation/Field/Boolean/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Date/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/DateTime/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Decimal/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Integer/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Picklist/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Picklist-RadioButtons/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Text/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Text-Email/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Text-Input/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Text-URL/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Template/DETAILS/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Template/FORM/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Template/FORM-region/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Template/PAGE/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Widget/CASE/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Widget/PAGE/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.tsx.mustache +0 -2
- package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/index.tsx.mustache +0 -2
- package/src/tasks/init/template/.eslintrc.json +4 -1
- package/src/tasks/init/template/package.json.mustache +1 -1
- package/tests/assets/components/create/Pega_DXIL_MyTestText/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyAutocomplete/embed-utils.js +11 -22
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyAutocomplete/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyBoolean/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyCaseWidget/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyCurrency/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/date-utils.js +47 -41
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/date.js +67 -54
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDecimal/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyEmail/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyForm/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyInteger/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPage/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPage/utils.js +9 -12
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageWidget/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyParagraph/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPercentage/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPhone/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPicklist/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyRadioButtons/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyText/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTextInput/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/time-of-day.js +47 -41
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/index.tsx +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyURL/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyAutocomplete/embed-utils.js +11 -22
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyAutocomplete/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyBoolean/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyCurrency/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/date-utils.js +47 -41
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/date.js +67 -54
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDecimal/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyEmail/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyForm/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyInteger/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPage/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPage/utils.js +9 -12
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageCaseWidget/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageWidget/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyParagraph/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPercentage/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPhone/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPicklist/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyRadioButtons/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyText/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTextInput/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTimeOfDay/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTimeOfDay/time-of-day.js +47 -41
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnForm/index.tsx +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyURL/index.tsx +0 -2
package/package.json
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
-
import React from 'react';
|
|
3
1
|
import { useEffect, useState } from 'react';
|
|
4
2
|
import { DateTimeInput, FieldValueList, DateTimeDisplay, Text } from "@pega/cosmos-react-core";
|
|
5
3
|
import PropTypes from "prop-types";
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
-
import React from 'react';
|
|
3
1
|
import { useState, useEffect, useRef } from 'react';
|
|
4
2
|
import { NumberInput, NumberDisplay, CurrencyDisplay, FieldValueList, Text } from '@pega/cosmos-react-core';
|
|
5
3
|
import PropTypes from 'prop-types';
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
-
import React from 'react';
|
|
3
1
|
import { useState, useEffect, useRef } from 'react';
|
|
4
2
|
import { NumberInput, NumberDisplay, Slider, FieldValueList, CurrencyDisplay, Text } from '@pega/cosmos-react-core';
|
|
5
3
|
import PropTypes from 'prop-types';
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3
|
-
import React from 'react';
|
|
4
2
|
// @ts-nocheck
|
|
5
3
|
import { useState, useEffect, useRef } from 'react';
|
|
6
4
|
import { Select, Option, FieldValueList, Text } from '@pega/cosmos-react-core';
|
package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/index.tsx.mustache
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
2
|
/* eslint-disable sonarjs/cognitive-complexity */
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4
|
-
import React from 'react';
|
|
5
3
|
import { useEffect, useRef, useState, memo, useMemo, type MutableRefObject, type SetStateAction } from 'react';
|
|
6
4
|
import { ComboBox, menuHelpers, debounce, throttle, Button, Icon, type MenuGroupProps, type MenuItemProps } from '@pega/cosmos-react-core';
|
|
7
5
|
import PropTypes from 'prop-types';
|
package/src/tasks/create/templates/Constellation/Field/Picklist-RadioButtons/index.tsx.mustache
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3
|
-
import React from 'react';
|
|
4
2
|
import { useMemo } from 'react';
|
|
5
3
|
import PropTypes from 'prop-types';
|
|
6
4
|
import { RadioButton, RadioButtonGroup } from '@pega/cosmos-react-core';
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
-
import React from 'react';
|
|
3
1
|
import { useState, useEffect, useRef } from 'react';
|
|
4
2
|
import { Input, EmailDisplay, FieldValueList, Text, URLDisplay, PhoneDisplay } from '@pega/cosmos-react-core';
|
|
5
3
|
import PropTypes from 'prop-types';
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
-
import React from 'react';
|
|
3
1
|
import { useEffect, useState, useRef } from 'react';
|
|
4
2
|
import { Input, FieldValueList, Text, EmailDisplay, PhoneDisplay, URLDisplay } from '@pega/cosmos-react-core';
|
|
5
3
|
import PropTypes from 'prop-types';
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
-
import React from 'react';
|
|
3
1
|
import { useState, useEffect, useRef } from 'react';
|
|
4
2
|
import { TextArea as CosmosTextArea, FieldValueList, ParagraphDisplay, Text, EmailDisplay, PhoneDisplay, URLDisplay } from '@pega/cosmos-react-core';
|
|
5
3
|
import PropTypes from 'prop-types';
|
|
@@ -25,7 +25,10 @@
|
|
|
25
25
|
"!.storybook",
|
|
26
26
|
".storybook/public",
|
|
27
27
|
"**/demo.stories.jsx",
|
|
28
|
-
"
|
|
28
|
+
"**/mock.stories.js",
|
|
29
|
+
"**/demo.stories.tsx",
|
|
30
|
+
"**/mock.stories.ts",
|
|
31
|
+
"**/*.mdx"
|
|
29
32
|
],
|
|
30
33
|
"rules": {
|
|
31
34
|
// Prettier recommends running separately from a linter.
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@pega/configs": "^0.6.0",
|
|
72
|
-
"@pega/custom-dx-components": "0.23.
|
|
72
|
+
"@pega/custom-dx-components": "0.23.33",
|
|
73
73
|
"@pega/pcore-pconnect-typedefs": "2.0.0",
|
|
74
74
|
"@storybook/addon-actions": "^7.6.7",
|
|
75
75
|
"@storybook/addon-essentials": "^7.6.7",
|
package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyAutocomplete/embed-utils.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isEmbeddedField,
|
|
3
|
-
isPageListInPath,
|
|
4
|
-
PAGE,
|
|
5
|
-
PAGELIST,
|
|
6
|
-
buildAggOrCalcId
|
|
7
|
-
} from './repeat-utils.js';
|
|
1
|
+
import { isEmbeddedField, isPageListInPath, PAGE, PAGELIST, buildAggOrCalcId } from './repeat-utils.js';
|
|
8
2
|
|
|
9
3
|
export const AT_FILTEREDLIST = '@FILTERED_LIST';
|
|
10
4
|
export const AT_PROPERTY = '@P';
|
|
@@ -58,7 +52,7 @@ export function getEmbeddedFieldName(propertyName, classID) {
|
|
|
58
52
|
* @param {Array} metaFields Fields metadata Array. Contains metadata of all the fields.
|
|
59
53
|
*/
|
|
60
54
|
export function updateMetaEmbeddedFieldID(metaFields) {
|
|
61
|
-
return metaFields.forEach(metaField => {
|
|
55
|
+
return metaFields.forEach((metaField) => {
|
|
62
56
|
if (metaField.fieldID?.startsWith(PAGE) || metaField.fieldID?.startsWith(PAGELIST)) {
|
|
63
57
|
metaField.fieldID = getFieldNameFromEmbeddedFieldName(metaField.fieldID);
|
|
64
58
|
}
|
|
@@ -75,7 +69,7 @@ export function updateMetaEmbeddedFieldID(metaFields) {
|
|
|
75
69
|
*/
|
|
76
70
|
export function getConfigEmbeddedFieldsMeta(configFields, classID) {
|
|
77
71
|
const configEmbeddedFieldsMeta = [];
|
|
78
|
-
configFields.forEach(field => {
|
|
72
|
+
configFields.forEach((field) => {
|
|
79
73
|
let value = field;
|
|
80
74
|
if (isEmbeddedField(value)) {
|
|
81
75
|
// conversion Page.PageList[].property => Page.PageList.property
|
|
@@ -99,8 +93,8 @@ export function getConfigEmbeddedFieldsMeta(configFields, classID) {
|
|
|
99
93
|
*/
|
|
100
94
|
export function mergeConfigEmbeddedFieldsMeta(configEmbeddedFieldsMeta, metaFields) {
|
|
101
95
|
const mergedMetaFields = [...metaFields];
|
|
102
|
-
configEmbeddedFieldsMeta.forEach(configFieldMeta => {
|
|
103
|
-
const fieldMeta = metaFields.find(metaField => metaField.fieldID === configFieldMeta.fieldID);
|
|
96
|
+
configEmbeddedFieldsMeta.forEach((configFieldMeta) => {
|
|
97
|
+
const fieldMeta = metaFields.find((metaField) => metaField.fieldID === configFieldMeta.fieldID);
|
|
104
98
|
if (!fieldMeta) mergedMetaFields.push(configFieldMeta);
|
|
105
99
|
});
|
|
106
100
|
return mergedMetaFields;
|
|
@@ -158,7 +152,7 @@ export function preparePropertyValue(value) {
|
|
|
158
152
|
// FIXME #EmbeddedPropertyPatch
|
|
159
153
|
// TODO: Remove this utility when we have nested response for queryable pageList and supports scalarList component
|
|
160
154
|
export function updatePageListFieldsConfig(configFields) {
|
|
161
|
-
return configFields.forEach(item => {
|
|
155
|
+
return configFields.forEach((item) => {
|
|
162
156
|
if (item.type === 'ScalarList') {
|
|
163
157
|
if (!item.config.originalValue) {
|
|
164
158
|
item.config.originalValue = item.config.value;
|
|
@@ -172,7 +166,7 @@ export function updatePageListFieldsConfig(configFields) {
|
|
|
172
166
|
* Update the renderer type for the properties of type Page.
|
|
173
167
|
*/
|
|
174
168
|
export function updatePageFieldsConfig(configFields, parentClassID) {
|
|
175
|
-
return configFields.forEach(item => {
|
|
169
|
+
return configFields.forEach((item) => {
|
|
176
170
|
const {
|
|
177
171
|
type,
|
|
178
172
|
config: { value }
|
|
@@ -262,7 +256,7 @@ export function preparePropertyMaps(fields, classID, context) {
|
|
|
262
256
|
export function getPageListFields(fields) {
|
|
263
257
|
const parentPaths = new Set();
|
|
264
258
|
const pageListFields = [];
|
|
265
|
-
fields.forEach(field => {
|
|
259
|
+
fields.forEach((field) => {
|
|
266
260
|
const { name } = field;
|
|
267
261
|
if (isPageListProperty(name)) {
|
|
268
262
|
const parentPath = name.substring(0, name.lastIndexOf(':'));
|
|
@@ -275,12 +269,7 @@ export function getPageListFields(fields) {
|
|
|
275
269
|
return pageListFields;
|
|
276
270
|
}
|
|
277
271
|
|
|
278
|
-
export function mergePageListFieldAggregation(
|
|
279
|
-
pageListName,
|
|
280
|
-
select,
|
|
281
|
-
existingAggregations,
|
|
282
|
-
existingAggregationsName
|
|
283
|
-
) {
|
|
272
|
+
export function mergePageListFieldAggregation(pageListName, select, existingAggregations, existingAggregationsName) {
|
|
284
273
|
// Build a dummy genericAggregationId to check if any type of aggregation for that pagelist is included in existing aggregations.
|
|
285
274
|
const genericAggregationId = buildAggOrCalcId(pageListName, '');
|
|
286
275
|
if (existingAggregationsName.includes(genericAggregationId)) {
|
|
@@ -295,7 +284,7 @@ export function mergePageListFieldsAggregation(fields, select, existingAggregati
|
|
|
295
284
|
const parentPaths = new Set();
|
|
296
285
|
const existingAggregationsName = Object.keys(existingAggregations).toString();
|
|
297
286
|
const pageListFields = [];
|
|
298
|
-
fields.forEach(field => {
|
|
287
|
+
fields.forEach((field) => {
|
|
299
288
|
const { name } = field;
|
|
300
289
|
if (isPageListProperty(name)) {
|
|
301
290
|
const parentPath = name.substring(0, name.lastIndexOf(':'));
|
|
@@ -317,5 +306,5 @@ export function mergePageListFieldsAggregation(fields, select, existingAggregati
|
|
|
317
306
|
* @returns {object | undefined} value of first pageListProperty found
|
|
318
307
|
*/
|
|
319
308
|
export function hasPageListProperty(fieldDefs) {
|
|
320
|
-
return fieldDefs?.find(field => isPageListProperty(field.name));
|
|
309
|
+
return fieldDefs?.find((field) => isPageListProperty(field.name));
|
|
321
310
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
2
|
/* eslint-disable sonarjs/cognitive-complexity */
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4
|
-
import React from 'react';
|
|
5
3
|
import { useEffect, useRef, useState, memo, useMemo, type MutableRefObject, type SetStateAction } from 'react';
|
|
6
4
|
import { ComboBox, menuHelpers, debounce, throttle, Button, Icon, type MenuGroupProps, type MenuItemProps } from '@pega/cosmos-react-core';
|
|
7
5
|
import PropTypes from 'prop-types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import dayjs from
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
2
|
import relativeTime from 'dayjs/plugin/relativeTime.js';
|
|
3
3
|
import localizedFormat from 'dayjs/plugin/localizedFormat.js';
|
|
4
4
|
import utc from 'dayjs/plugin/utc.js';
|
|
@@ -16,11 +16,11 @@ dayjs.extend(timezone);
|
|
|
16
16
|
* @param {string} text datetime
|
|
17
17
|
* @returns {object} datetime as a dayjs object
|
|
18
18
|
*/
|
|
19
|
-
export const getDayJSObject = text => {
|
|
19
|
+
export const getDayJSObject = (text) => {
|
|
20
20
|
const momObj = dayjs(text);
|
|
21
21
|
if (momObj.isValid()) return momObj;
|
|
22
22
|
const timeStamp = text;
|
|
23
|
-
const isDateTime = timeStamp.indexOf(
|
|
23
|
+
const isDateTime = timeStamp.indexOf("GMT") !== -1;
|
|
24
24
|
const year = parseInt(timeStamp.substr(0, 4), 10);
|
|
25
25
|
const month = parseInt(timeStamp.substr(4, 2), 10) - 1;
|
|
26
26
|
const day = parseInt(timeStamp.substr(6, 2), 10);
|
|
@@ -46,7 +46,7 @@ export const getDayJSObject = text => {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
mom = dayjs(
|
|
49
|
-
mom.toLocaleString(
|
|
49
|
+
mom.toLocaleString("en-US", {
|
|
50
50
|
timeZone: CurrentTz
|
|
51
51
|
})
|
|
52
52
|
);
|
|
@@ -60,8 +60,8 @@ export const getDayJSObject = text => {
|
|
|
60
60
|
* @param {string} time datetime
|
|
61
61
|
* @returns {object} relative time from now
|
|
62
62
|
*/
|
|
63
|
-
export const getRelativeTime = time => {
|
|
64
|
-
let relativetime =
|
|
63
|
+
export const getRelativeTime = (time) => {
|
|
64
|
+
let relativetime = "";
|
|
65
65
|
if (dayjs(time).isUTC()) {
|
|
66
66
|
relativetime = dayjs(time).fromNow();
|
|
67
67
|
} else {
|
|
@@ -77,7 +77,7 @@ export const getRelativeTime = time => {
|
|
|
77
77
|
* @param {string} value from which Year needs to be taken out
|
|
78
78
|
* @returns {number} year for the date passed
|
|
79
79
|
*/
|
|
80
|
-
export const getFullYear = value =>
|
|
80
|
+
export const getFullYear = (value) =>
|
|
81
81
|
value ? new Date(value).getFullYear() : new Date().getFullYear();
|
|
82
82
|
|
|
83
83
|
/**
|
|
@@ -127,8 +127,8 @@ export const getMinDate = (previousYears, currentYear, yearFromValue) => {
|
|
|
127
127
|
*
|
|
128
128
|
* @returns {number} clockFormat
|
|
129
129
|
*/
|
|
130
|
-
export const parseClockFormat = clockFormat =>
|
|
131
|
-
typeof clockFormat ===
|
|
130
|
+
export const parseClockFormat = (clockFormat) =>
|
|
131
|
+
typeof clockFormat === "string" ? parseInt(clockFormat, 10) : clockFormat;
|
|
132
132
|
|
|
133
133
|
/**
|
|
134
134
|
* Return datetime value string off to seconds
|
|
@@ -140,9 +140,9 @@ export const parseClockFormat = clockFormat =>
|
|
|
140
140
|
*/
|
|
141
141
|
export const correctDateTimeToSeconds = (datetime, withSeconds) => {
|
|
142
142
|
if (withSeconds) {
|
|
143
|
-
return `${datetime.substring(0, datetime.indexOf(
|
|
143
|
+
return `${datetime.substring(0, datetime.indexOf("Z"))}.000Z`;
|
|
144
144
|
}
|
|
145
|
-
return `${datetime.substring(0, datetime.lastIndexOf(
|
|
145
|
+
return `${datetime.substring(0, datetime.lastIndexOf(":"))}:00.000Z`;
|
|
146
146
|
};
|
|
147
147
|
|
|
148
148
|
/**
|
|
@@ -155,9 +155,12 @@ export const correctDateTimeToSeconds = (datetime, withSeconds) => {
|
|
|
155
155
|
*/
|
|
156
156
|
export const timeCorrectedToSeconds = (datetime, withSeconds) => {
|
|
157
157
|
if (withSeconds) {
|
|
158
|
-
return datetime.substring(datetime.indexOf(
|
|
158
|
+
return datetime.substring(datetime.indexOf("T") + 1, datetime.indexOf("."));
|
|
159
159
|
}
|
|
160
|
-
return `${datetime.substring(
|
|
160
|
+
return `${datetime.substring(
|
|
161
|
+
datetime.indexOf("T") + 1,
|
|
162
|
+
datetime.lastIndexOf(":")
|
|
163
|
+
)}:00`;
|
|
161
164
|
};
|
|
162
165
|
|
|
163
166
|
/**
|
|
@@ -180,13 +183,14 @@ export const datetimeFireChangeBlurEvents = (
|
|
|
180
183
|
propName,
|
|
181
184
|
pConn
|
|
182
185
|
) => {
|
|
186
|
+
|
|
183
187
|
// TODO - clean up, we should not rely on timestamp from cosmos to check InComplete validation
|
|
184
188
|
// above triggerFieldChange should have validated this
|
|
185
189
|
if (errorState) {
|
|
186
190
|
pConn.getValidationApi().validate(errorState);
|
|
187
191
|
}
|
|
188
192
|
// BUG-640834 In errorState presist old values avoiding store update & re-render.
|
|
189
|
-
else
|
|
193
|
+
else{
|
|
190
194
|
if (formattedValue !== actualValue) {
|
|
191
195
|
actions.updateFieldValue(propName, formattedValue);
|
|
192
196
|
}
|
|
@@ -207,27 +211,27 @@ export const getDateFormat = (locale, options) => {
|
|
|
207
211
|
.formatToParts()
|
|
208
212
|
.map(({ type, value }) => {
|
|
209
213
|
switch (type) {
|
|
210
|
-
case
|
|
211
|
-
return
|
|
212
|
-
case
|
|
213
|
-
return
|
|
214
|
-
case
|
|
215
|
-
return
|
|
216
|
-
case
|
|
217
|
-
return
|
|
218
|
-
case
|
|
219
|
-
return
|
|
220
|
-
case
|
|
221
|
-
return
|
|
222
|
-
case
|
|
223
|
-
return
|
|
224
|
-
case
|
|
214
|
+
case "day":
|
|
215
|
+
return "DD";
|
|
216
|
+
case "month":
|
|
217
|
+
return "MM";
|
|
218
|
+
case "year":
|
|
219
|
+
return "YYYY";
|
|
220
|
+
case "hour":
|
|
221
|
+
return "hh";
|
|
222
|
+
case "minute":
|
|
223
|
+
return "mm";
|
|
224
|
+
case "second":
|
|
225
|
+
return "ss";
|
|
226
|
+
case "dayPeriod":
|
|
227
|
+
return "A";
|
|
228
|
+
case "literal":
|
|
225
229
|
return value;
|
|
226
230
|
default:
|
|
227
|
-
return
|
|
231
|
+
return "";
|
|
228
232
|
}
|
|
229
233
|
})
|
|
230
|
-
.join(
|
|
234
|
+
.join("");
|
|
231
235
|
};
|
|
232
236
|
|
|
233
237
|
/**
|
|
@@ -237,13 +241,15 @@ export const getDateFormat = (locale, options) => {
|
|
|
237
241
|
* @returns {boolean} True or False for the locale
|
|
238
242
|
* Example : getDateFormat("pl-PL") returns false
|
|
239
243
|
*/
|
|
240
|
-
export const is12HClockFormat = locale => {
|
|
244
|
+
export const is12HClockFormat = (locale) => {
|
|
241
245
|
const meridiem = new Intl.DateTimeFormat(locale, {
|
|
242
|
-
hour:
|
|
246
|
+
hour: "numeric"
|
|
243
247
|
})
|
|
244
248
|
.formatToParts()
|
|
245
|
-
.find(({ type }) => type ===
|
|
246
|
-
return !!(meridiem === null || meridiem === undefined
|
|
249
|
+
.find(({ type }) => type === "dayPeriod");
|
|
250
|
+
return !!(meridiem === null || meridiem === undefined
|
|
251
|
+
? undefined
|
|
252
|
+
: meridiem.value);
|
|
247
253
|
};
|
|
248
254
|
|
|
249
255
|
/**
|
|
@@ -256,9 +262,9 @@ export const is12HClockFormat = locale => {
|
|
|
256
262
|
*/
|
|
257
263
|
export const getTimeOptions = (withSeconds, is12h = false) => {
|
|
258
264
|
return {
|
|
259
|
-
hour:
|
|
260
|
-
minute:
|
|
261
|
-
...(withSeconds && { second:
|
|
265
|
+
hour: "numeric",
|
|
266
|
+
minute: "numeric",
|
|
267
|
+
...(withSeconds && { second: "numeric" }),
|
|
262
268
|
hour12: is12h
|
|
263
269
|
};
|
|
264
270
|
};
|
|
@@ -273,9 +279,9 @@ export const getTimeOptions = (withSeconds, is12h = false) => {
|
|
|
273
279
|
*/
|
|
274
280
|
export const getDateTimeOptions = (withSeconds, is12h = false) => {
|
|
275
281
|
return {
|
|
276
|
-
year:
|
|
277
|
-
month:
|
|
278
|
-
day:
|
|
282
|
+
year: "numeric",
|
|
283
|
+
month: "numeric",
|
|
284
|
+
day: "numeric",
|
|
279
285
|
...getTimeOptions(withSeconds, is12h)
|
|
280
286
|
};
|
|
281
287
|
};
|