@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
|
@@ -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
|
};
|
|
@@ -9,26 +9,26 @@ dayjs.extend(localizedFormat);
|
|
|
9
9
|
dayjs.extend(utc);
|
|
10
10
|
dayjs.extend(timezone);
|
|
11
11
|
|
|
12
|
-
export const datetimedisplayformatter = formatter => {
|
|
12
|
+
export const datetimedisplayformatter = (formatter) => {
|
|
13
13
|
const objectvalues = {};
|
|
14
14
|
switch (formatter) {
|
|
15
|
-
case
|
|
16
|
-
objectvalues.variantVal =
|
|
17
|
-
objectvalues.formatVal =
|
|
15
|
+
case "DateTime-Long": {
|
|
16
|
+
objectvalues.variantVal = "datetime";
|
|
17
|
+
objectvalues.formatVal = "long";
|
|
18
18
|
break;
|
|
19
19
|
}
|
|
20
|
-
case
|
|
21
|
-
objectvalues.variantVal =
|
|
22
|
-
objectvalues.formatVal =
|
|
20
|
+
case "DateTime-Short": {
|
|
21
|
+
objectvalues.variantVal = "date";
|
|
22
|
+
objectvalues.formatVal = "short";
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
25
|
-
case
|
|
26
|
-
objectvalues.variantVal =
|
|
25
|
+
case "DateTime-Since": {
|
|
26
|
+
objectvalues.variantVal = "relative";
|
|
27
27
|
break;
|
|
28
28
|
}
|
|
29
|
-
case
|
|
30
|
-
objectvalues.variantVal =
|
|
31
|
-
objectvalues.formatVal =
|
|
29
|
+
case "Time-Only": {
|
|
30
|
+
objectvalues.variantVal = "time";
|
|
31
|
+
objectvalues.formatVal = "short";
|
|
32
32
|
break;
|
|
33
33
|
}
|
|
34
34
|
// no default
|
|
@@ -36,8 +36,13 @@ export const datetimedisplayformatter = formatter => {
|
|
|
36
36
|
return objectvalues;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
export const formatExists = formatterVal => {
|
|
40
|
-
const formatterValues = [
|
|
39
|
+
export const formatExists = (formatterVal) => {
|
|
40
|
+
const formatterValues = [
|
|
41
|
+
"DateTime-Long",
|
|
42
|
+
"DateTime-Short",
|
|
43
|
+
"DateTime-Since",
|
|
44
|
+
"Time-Only"
|
|
45
|
+
];
|
|
41
46
|
let isformatter = false;
|
|
42
47
|
if (formatterValues.includes(formatterVal)) {
|
|
43
48
|
isformatter = true;
|
|
@@ -45,6 +50,8 @@ export const formatExists = formatterVal => {
|
|
|
45
50
|
return isformatter;
|
|
46
51
|
};
|
|
47
52
|
|
|
53
|
+
|
|
54
|
+
|
|
48
55
|
/**
|
|
49
56
|
* Return relative time in fromNow for the given datetime
|
|
50
57
|
* @description Convert and return the given datetime in dayJSObject
|
|
@@ -52,11 +59,11 @@ export const formatExists = formatterVal => {
|
|
|
52
59
|
* @param {string} text datetime
|
|
53
60
|
* @returns {object} datetime as a dayjs object
|
|
54
61
|
*/
|
|
55
|
-
export const getDayJSObject = text => {
|
|
62
|
+
export const getDayJSObject = (text) => {
|
|
56
63
|
const momObj = dayjs(text);
|
|
57
64
|
if (momObj.isValid()) return momObj;
|
|
58
65
|
const timeStamp = text;
|
|
59
|
-
const isDateTime = timeStamp.indexOf(
|
|
66
|
+
const isDateTime = timeStamp.indexOf("GMT") !== -1;
|
|
60
67
|
const year = parseInt(timeStamp.substr(0, 4), 10);
|
|
61
68
|
const month = parseInt(timeStamp.substr(4, 2), 10) - 1;
|
|
62
69
|
const day = parseInt(timeStamp.substr(6, 2), 10);
|
|
@@ -82,7 +89,7 @@ export const getDayJSObject = text => {
|
|
|
82
89
|
}
|
|
83
90
|
|
|
84
91
|
mom = dayjs(
|
|
85
|
-
mom.toLocaleString(
|
|
92
|
+
mom.toLocaleString("en-US", {
|
|
86
93
|
timeZone: CurrentTz
|
|
87
94
|
})
|
|
88
95
|
);
|
|
@@ -96,8 +103,8 @@ export const getDayJSObject = text => {
|
|
|
96
103
|
* @param {string} time datetime
|
|
97
104
|
* @returns {object} relative time from now
|
|
98
105
|
*/
|
|
99
|
-
export const getRelativeTime = time => {
|
|
100
|
-
let relativetime =
|
|
106
|
+
export const getRelativeTime = (time) => {
|
|
107
|
+
let relativetime = "";
|
|
101
108
|
if (dayjs(time).isUTC()) {
|
|
102
109
|
relativetime = dayjs(time).fromNow();
|
|
103
110
|
} else {
|
|
@@ -113,7 +120,7 @@ export const getRelativeTime = time => {
|
|
|
113
120
|
* @param {string} value from which Year needs to be taken out
|
|
114
121
|
* @returns {number} year for the date passed
|
|
115
122
|
*/
|
|
116
|
-
export const getFullYear = value =>
|
|
123
|
+
export const getFullYear = (value) =>
|
|
117
124
|
value ? new Date(value).getFullYear() : new Date().getFullYear();
|
|
118
125
|
|
|
119
126
|
/**
|
|
@@ -163,8 +170,8 @@ export const getMinDate = (previousYears, currentYear, yearFromValue) => {
|
|
|
163
170
|
*
|
|
164
171
|
* @returns {number} clockFormat
|
|
165
172
|
*/
|
|
166
|
-
export const parseClockFormat = clockFormat =>
|
|
167
|
-
typeof clockFormat ===
|
|
173
|
+
export const parseClockFormat = (clockFormat) =>
|
|
174
|
+
typeof clockFormat === "string" ? parseInt(clockFormat, 10) : clockFormat;
|
|
168
175
|
|
|
169
176
|
/**
|
|
170
177
|
* Return datetime value string off to seconds
|
|
@@ -176,9 +183,9 @@ export const parseClockFormat = clockFormat =>
|
|
|
176
183
|
*/
|
|
177
184
|
export const correctDateTimeToSeconds = (datetime, withSeconds) => {
|
|
178
185
|
if (withSeconds) {
|
|
179
|
-
return `${datetime.substring(0, datetime.indexOf(
|
|
186
|
+
return `${datetime.substring(0, datetime.indexOf("Z"))}.000Z`;
|
|
180
187
|
}
|
|
181
|
-
return `${datetime.substring(0, datetime.lastIndexOf(
|
|
188
|
+
return `${datetime.substring(0, datetime.lastIndexOf(":"))}:00.000Z`;
|
|
182
189
|
};
|
|
183
190
|
|
|
184
191
|
/**
|
|
@@ -191,9 +198,12 @@ export const correctDateTimeToSeconds = (datetime, withSeconds) => {
|
|
|
191
198
|
*/
|
|
192
199
|
export const timeCorrectedToSeconds = (datetime, withSeconds) => {
|
|
193
200
|
if (withSeconds) {
|
|
194
|
-
return datetime.substring(datetime.indexOf(
|
|
201
|
+
return datetime.substring(datetime.indexOf("T") + 1, datetime.indexOf("."));
|
|
195
202
|
}
|
|
196
|
-
return `${datetime.substring(
|
|
203
|
+
return `${datetime.substring(
|
|
204
|
+
datetime.indexOf("T") + 1,
|
|
205
|
+
datetime.lastIndexOf(":")
|
|
206
|
+
)}:00`;
|
|
197
207
|
};
|
|
198
208
|
|
|
199
209
|
/**
|
|
@@ -216,13 +226,14 @@ export const datetimeFireChangeBlurEvents = (
|
|
|
216
226
|
propName,
|
|
217
227
|
pConn
|
|
218
228
|
) => {
|
|
229
|
+
|
|
219
230
|
// TODO - clean up, we should not rely on timestamp from cosmos to check InComplete validation
|
|
220
231
|
// above triggerFieldChange should have validated this
|
|
221
232
|
if (errorState) {
|
|
222
233
|
pConn.getValidationApi().validate(errorState);
|
|
223
234
|
}
|
|
224
235
|
// BUG-640834 In errorState presist old values avoiding store update & re-render.
|
|
225
|
-
else
|
|
236
|
+
else{
|
|
226
237
|
if (formattedValue !== actualValue) {
|
|
227
238
|
actions.updateFieldValue(propName, formattedValue);
|
|
228
239
|
}
|
|
@@ -243,27 +254,27 @@ export const getDateFormat = (locale, options) => {
|
|
|
243
254
|
.formatToParts()
|
|
244
255
|
.map(({ type, value }) => {
|
|
245
256
|
switch (type) {
|
|
246
|
-
case
|
|
247
|
-
return
|
|
248
|
-
case
|
|
249
|
-
return
|
|
250
|
-
case
|
|
251
|
-
return
|
|
252
|
-
case
|
|
253
|
-
return
|
|
254
|
-
case
|
|
255
|
-
return
|
|
256
|
-
case
|
|
257
|
-
return
|
|
258
|
-
case
|
|
259
|
-
return
|
|
260
|
-
case
|
|
257
|
+
case "day":
|
|
258
|
+
return "DD";
|
|
259
|
+
case "month":
|
|
260
|
+
return "MM";
|
|
261
|
+
case "year":
|
|
262
|
+
return "YYYY";
|
|
263
|
+
case "hour":
|
|
264
|
+
return "hh";
|
|
265
|
+
case "minute":
|
|
266
|
+
return "mm";
|
|
267
|
+
case "second":
|
|
268
|
+
return "ss";
|
|
269
|
+
case "dayPeriod":
|
|
270
|
+
return "A";
|
|
271
|
+
case "literal":
|
|
261
272
|
return value;
|
|
262
273
|
default:
|
|
263
|
-
return
|
|
274
|
+
return "";
|
|
264
275
|
}
|
|
265
276
|
})
|
|
266
|
-
.join(
|
|
277
|
+
.join("");
|
|
267
278
|
};
|
|
268
279
|
|
|
269
280
|
/**
|
|
@@ -273,13 +284,15 @@ export const getDateFormat = (locale, options) => {
|
|
|
273
284
|
* @returns {boolean} True or False for the locale
|
|
274
285
|
* Example : getDateFormat("pl-PL") returns false
|
|
275
286
|
*/
|
|
276
|
-
export const is12HClockFormat = locale => {
|
|
287
|
+
export const is12HClockFormat = (locale) => {
|
|
277
288
|
const meridiem = new Intl.DateTimeFormat(locale, {
|
|
278
|
-
hour:
|
|
289
|
+
hour: "numeric"
|
|
279
290
|
})
|
|
280
291
|
.formatToParts()
|
|
281
|
-
.find(({ type }) => type ===
|
|
282
|
-
return !!(meridiem === null || meridiem === undefined
|
|
292
|
+
.find(({ type }) => type === "dayPeriod");
|
|
293
|
+
return !!(meridiem === null || meridiem === undefined
|
|
294
|
+
? undefined
|
|
295
|
+
: meridiem.value);
|
|
283
296
|
};
|
|
284
297
|
|
|
285
298
|
/**
|
|
@@ -292,9 +305,9 @@ export const is12HClockFormat = locale => {
|
|
|
292
305
|
*/
|
|
293
306
|
export const getTimeOptions = (withSeconds, is12h = false) => {
|
|
294
307
|
return {
|
|
295
|
-
hour:
|
|
296
|
-
minute:
|
|
297
|
-
...(withSeconds && { second:
|
|
308
|
+
hour: "numeric",
|
|
309
|
+
minute: "numeric",
|
|
310
|
+
...(withSeconds && { second: "numeric" }),
|
|
298
311
|
hour12: is12h
|
|
299
312
|
};
|
|
300
313
|
};
|
|
@@ -309,9 +322,9 @@ export const getTimeOptions = (withSeconds, is12h = false) => {
|
|
|
309
322
|
*/
|
|
310
323
|
export const getDateTimeOptions = (withSeconds, is12h = false) => {
|
|
311
324
|
return {
|
|
312
|
-
year:
|
|
313
|
-
month:
|
|
314
|
-
day:
|
|
325
|
+
year: "numeric",
|
|
326
|
+
month: "numeric",
|
|
327
|
+
day: "numeric",
|
|
315
328
|
...getTimeOptions(withSeconds, is12h)
|
|
316
329
|
};
|
|
317
330
|
};
|
|
@@ -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 { 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 { 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';
|