@pega/custom-dx-components 0.23.29 → 0.23.31
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/Date/DateFormatter.js.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/DateTime/date-utils.js.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/date.js.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/embed-utils.js.mustache +0 -3
- package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/repeat-utils.js.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/textformat-utils.jsx.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Picklist-RadioButtons/textformat-utils.jsx.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.jsx.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +1 -2
- package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Avatar.tsx.mustache +1 -1
- package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/Avatar.tsx.mustache +1 -1
- package/src/tasks/init/template/.eslintrc.json +13 -1
- package/src/tasks/init/template/package.json.mustache +1 -1
- package/src/tasks/init/template/tsconfig.json +2 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyAutocomplete/date.js +0 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyAutocomplete/embed-utils.js +22 -14
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyAutocomplete/repeat-utils.js +0 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyAutocomplete/textformat-utils.jsx +0 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/DateFormatter.js +0 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/FormattedText.jsx +0 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/date.js +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/date-time.js +0 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/date-utils.js +41 -49
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/date.js +54 -69
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/utils.js +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPage/utils.js +12 -11
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/Avatar.tsx +1 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyRadioButtons/textformat-utils.jsx +0 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/time-of-day.js +41 -48
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/utils.js +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyURL/text-url.jsx +0 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyAutocomplete/date.js +0 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyAutocomplete/embed-utils.js +22 -14
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyAutocomplete/repeat-utils.js +0 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyAutocomplete/textformat-utils.jsx +0 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/DateFormatter.js +0 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/FormattedText.jsx +0 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/date.js +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/date-time.js +0 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/date-utils.js +41 -49
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/date.js +54 -69
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/utils.js +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPage/utils.js +12 -11
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageCaseWidget/Avatar.tsx +1 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyRadioButtons/textformat-utils.jsx +0 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTimeOfDay/time-of-day.js +41 -48
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/utils.js +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyURL/text-url.jsx +0 -1
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/* eslint-disable no-undef */
|
|
3
|
-
import dayjs from "dayjs";
|
|
1
|
+
import dayjs from 'dayjs';
|
|
4
2
|
import relativeTime from 'dayjs/plugin/relativeTime.js';
|
|
5
3
|
import localizedFormat from 'dayjs/plugin/localizedFormat.js';
|
|
6
4
|
import utc from 'dayjs/plugin/utc.js';
|
|
@@ -18,11 +16,11 @@ dayjs.extend(timezone);
|
|
|
18
16
|
* @param {string} text datetime
|
|
19
17
|
* @returns {object} datetime as a dayjs object
|
|
20
18
|
*/
|
|
21
|
-
export const getDayJSObject =
|
|
19
|
+
export const getDayJSObject = text => {
|
|
22
20
|
const momObj = dayjs(text);
|
|
23
21
|
if (momObj.isValid()) return momObj;
|
|
24
22
|
const timeStamp = text;
|
|
25
|
-
const isDateTime = timeStamp.indexOf(
|
|
23
|
+
const isDateTime = timeStamp.indexOf('GMT') !== -1;
|
|
26
24
|
const year = parseInt(timeStamp.substr(0, 4), 10);
|
|
27
25
|
const month = parseInt(timeStamp.substr(4, 2), 10) - 1;
|
|
28
26
|
const day = parseInt(timeStamp.substr(6, 2), 10);
|
|
@@ -48,7 +46,7 @@ export const getDayJSObject = (text) => {
|
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
mom = dayjs(
|
|
51
|
-
mom.toLocaleString(
|
|
49
|
+
mom.toLocaleString('en-US', {
|
|
52
50
|
timeZone: CurrentTz
|
|
53
51
|
})
|
|
54
52
|
);
|
|
@@ -62,8 +60,8 @@ export const getDayJSObject = (text) => {
|
|
|
62
60
|
* @param {string} time datetime
|
|
63
61
|
* @returns {object} relative time from now
|
|
64
62
|
*/
|
|
65
|
-
export const getRelativeTime =
|
|
66
|
-
let relativetime =
|
|
63
|
+
export const getRelativeTime = time => {
|
|
64
|
+
let relativetime = '';
|
|
67
65
|
if (dayjs(time).isUTC()) {
|
|
68
66
|
relativetime = dayjs(time).fromNow();
|
|
69
67
|
} else {
|
|
@@ -79,7 +77,7 @@ export const getRelativeTime = (time) => {
|
|
|
79
77
|
* @param {string} value from which Year needs to be taken out
|
|
80
78
|
* @returns {number} year for the date passed
|
|
81
79
|
*/
|
|
82
|
-
export const getFullYear =
|
|
80
|
+
export const getFullYear = value =>
|
|
83
81
|
value ? new Date(value).getFullYear() : new Date().getFullYear();
|
|
84
82
|
|
|
85
83
|
/**
|
|
@@ -129,8 +127,8 @@ export const getMinDate = (previousYears, currentYear, yearFromValue) => {
|
|
|
129
127
|
*
|
|
130
128
|
* @returns {number} clockFormat
|
|
131
129
|
*/
|
|
132
|
-
export const parseClockFormat =
|
|
133
|
-
typeof clockFormat ===
|
|
130
|
+
export const parseClockFormat = clockFormat =>
|
|
131
|
+
typeof clockFormat === 'string' ? parseInt(clockFormat, 10) : clockFormat;
|
|
134
132
|
|
|
135
133
|
/**
|
|
136
134
|
* Return datetime value string off to seconds
|
|
@@ -142,9 +140,9 @@ export const parseClockFormat = (clockFormat) =>
|
|
|
142
140
|
*/
|
|
143
141
|
export const correctDateTimeToSeconds = (datetime, withSeconds) => {
|
|
144
142
|
if (withSeconds) {
|
|
145
|
-
return `${datetime.substring(0, datetime.indexOf(
|
|
143
|
+
return `${datetime.substring(0, datetime.indexOf('Z'))}.000Z`;
|
|
146
144
|
}
|
|
147
|
-
return `${datetime.substring(0, datetime.lastIndexOf(
|
|
145
|
+
return `${datetime.substring(0, datetime.lastIndexOf(':'))}:00.000Z`;
|
|
148
146
|
};
|
|
149
147
|
|
|
150
148
|
/**
|
|
@@ -157,12 +155,9 @@ export const correctDateTimeToSeconds = (datetime, withSeconds) => {
|
|
|
157
155
|
*/
|
|
158
156
|
export const timeCorrectedToSeconds = (datetime, withSeconds) => {
|
|
159
157
|
if (withSeconds) {
|
|
160
|
-
return datetime.substring(datetime.indexOf(
|
|
158
|
+
return datetime.substring(datetime.indexOf('T') + 1, datetime.indexOf('.'));
|
|
161
159
|
}
|
|
162
|
-
return `${datetime.substring(
|
|
163
|
-
datetime.indexOf("T") + 1,
|
|
164
|
-
datetime.lastIndexOf(":")
|
|
165
|
-
)}:00`;
|
|
160
|
+
return `${datetime.substring(datetime.indexOf('T') + 1, datetime.lastIndexOf(':'))}:00`;
|
|
166
161
|
};
|
|
167
162
|
|
|
168
163
|
/**
|
|
@@ -185,14 +180,13 @@ export const datetimeFireChangeBlurEvents = (
|
|
|
185
180
|
propName,
|
|
186
181
|
pConn
|
|
187
182
|
) => {
|
|
188
|
-
|
|
189
183
|
// TODO - clean up, we should not rely on timestamp from cosmos to check InComplete validation
|
|
190
184
|
// above triggerFieldChange should have validated this
|
|
191
185
|
if (errorState) {
|
|
192
186
|
pConn.getValidationApi().validate(errorState);
|
|
193
187
|
}
|
|
194
188
|
// BUG-640834 In errorState presist old values avoiding store update & re-render.
|
|
195
|
-
else{
|
|
189
|
+
else {
|
|
196
190
|
if (formattedValue !== actualValue) {
|
|
197
191
|
actions.updateFieldValue(propName, formattedValue);
|
|
198
192
|
}
|
|
@@ -213,27 +207,27 @@ export const getDateFormat = (locale, options) => {
|
|
|
213
207
|
.formatToParts()
|
|
214
208
|
.map(({ type, value }) => {
|
|
215
209
|
switch (type) {
|
|
216
|
-
case
|
|
217
|
-
return
|
|
218
|
-
case
|
|
219
|
-
return
|
|
220
|
-
case
|
|
221
|
-
return
|
|
222
|
-
case
|
|
223
|
-
return
|
|
224
|
-
case
|
|
225
|
-
return
|
|
226
|
-
case
|
|
227
|
-
return
|
|
228
|
-
case
|
|
229
|
-
return
|
|
230
|
-
case
|
|
210
|
+
case 'day':
|
|
211
|
+
return 'DD';
|
|
212
|
+
case 'month':
|
|
213
|
+
return 'MM';
|
|
214
|
+
case 'year':
|
|
215
|
+
return 'YYYY';
|
|
216
|
+
case 'hour':
|
|
217
|
+
return 'hh';
|
|
218
|
+
case 'minute':
|
|
219
|
+
return 'mm';
|
|
220
|
+
case 'second':
|
|
221
|
+
return 'ss';
|
|
222
|
+
case 'dayPeriod':
|
|
223
|
+
return 'A';
|
|
224
|
+
case 'literal':
|
|
231
225
|
return value;
|
|
232
226
|
default:
|
|
233
|
-
return
|
|
227
|
+
return '';
|
|
234
228
|
}
|
|
235
229
|
})
|
|
236
|
-
.join(
|
|
230
|
+
.join('');
|
|
237
231
|
};
|
|
238
232
|
|
|
239
233
|
/**
|
|
@@ -243,15 +237,13 @@ export const getDateFormat = (locale, options) => {
|
|
|
243
237
|
* @returns {boolean} True or False for the locale
|
|
244
238
|
* Example : getDateFormat("pl-PL") returns false
|
|
245
239
|
*/
|
|
246
|
-
export const is12HClockFormat =
|
|
240
|
+
export const is12HClockFormat = locale => {
|
|
247
241
|
const meridiem = new Intl.DateTimeFormat(locale, {
|
|
248
|
-
hour:
|
|
242
|
+
hour: 'numeric'
|
|
249
243
|
})
|
|
250
244
|
.formatToParts()
|
|
251
|
-
.find(({ type }) => type ===
|
|
252
|
-
return !!(meridiem === null || meridiem === undefined
|
|
253
|
-
? undefined
|
|
254
|
-
: meridiem.value);
|
|
245
|
+
.find(({ type }) => type === 'dayPeriod');
|
|
246
|
+
return !!(meridiem === null || meridiem === undefined ? undefined : meridiem.value);
|
|
255
247
|
};
|
|
256
248
|
|
|
257
249
|
/**
|
|
@@ -264,9 +256,9 @@ export const is12HClockFormat = (locale) => {
|
|
|
264
256
|
*/
|
|
265
257
|
export const getTimeOptions = (withSeconds, is12h = false) => {
|
|
266
258
|
return {
|
|
267
|
-
hour:
|
|
268
|
-
minute:
|
|
269
|
-
...(withSeconds && { second:
|
|
259
|
+
hour: 'numeric',
|
|
260
|
+
minute: 'numeric',
|
|
261
|
+
...(withSeconds && { second: 'numeric' }),
|
|
270
262
|
hour12: is12h
|
|
271
263
|
};
|
|
272
264
|
};
|
|
@@ -281,9 +273,9 @@ export const getTimeOptions = (withSeconds, is12h = false) => {
|
|
|
281
273
|
*/
|
|
282
274
|
export const getDateTimeOptions = (withSeconds, is12h = false) => {
|
|
283
275
|
return {
|
|
284
|
-
year:
|
|
285
|
-
month:
|
|
286
|
-
day:
|
|
276
|
+
year: 'numeric',
|
|
277
|
+
month: 'numeric',
|
|
278
|
+
day: 'numeric',
|
|
287
279
|
...getTimeOptions(withSeconds, is12h)
|
|
288
280
|
};
|
|
289
281
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable import/no-relative-packages */
|
|
2
|
-
/* eslint-disable no-undef */
|
|
3
1
|
import dayjs from 'dayjs';
|
|
4
2
|
import relativeTime from 'dayjs/plugin/relativeTime.js';
|
|
5
3
|
import localizedFormat from 'dayjs/plugin/localizedFormat.js';
|
|
@@ -11,26 +9,26 @@ dayjs.extend(localizedFormat);
|
|
|
11
9
|
dayjs.extend(utc);
|
|
12
10
|
dayjs.extend(timezone);
|
|
13
11
|
|
|
14
|
-
export const datetimedisplayformatter =
|
|
12
|
+
export const datetimedisplayformatter = formatter => {
|
|
15
13
|
const objectvalues = {};
|
|
16
14
|
switch (formatter) {
|
|
17
|
-
case
|
|
18
|
-
objectvalues.variantVal =
|
|
19
|
-
objectvalues.formatVal =
|
|
15
|
+
case 'DateTime-Long': {
|
|
16
|
+
objectvalues.variantVal = 'datetime';
|
|
17
|
+
objectvalues.formatVal = 'long';
|
|
20
18
|
break;
|
|
21
19
|
}
|
|
22
|
-
case
|
|
23
|
-
objectvalues.variantVal =
|
|
24
|
-
objectvalues.formatVal =
|
|
20
|
+
case 'DateTime-Short': {
|
|
21
|
+
objectvalues.variantVal = 'date';
|
|
22
|
+
objectvalues.formatVal = 'short';
|
|
25
23
|
break;
|
|
26
24
|
}
|
|
27
|
-
case
|
|
28
|
-
objectvalues.variantVal =
|
|
25
|
+
case 'DateTime-Since': {
|
|
26
|
+
objectvalues.variantVal = 'relative';
|
|
29
27
|
break;
|
|
30
28
|
}
|
|
31
|
-
case
|
|
32
|
-
objectvalues.variantVal =
|
|
33
|
-
objectvalues.formatVal =
|
|
29
|
+
case 'Time-Only': {
|
|
30
|
+
objectvalues.variantVal = 'time';
|
|
31
|
+
objectvalues.formatVal = 'short';
|
|
34
32
|
break;
|
|
35
33
|
}
|
|
36
34
|
// no default
|
|
@@ -38,13 +36,8 @@ export const datetimedisplayformatter = (formatter) => {
|
|
|
38
36
|
return objectvalues;
|
|
39
37
|
};
|
|
40
38
|
|
|
41
|
-
export const formatExists =
|
|
42
|
-
const formatterValues = [
|
|
43
|
-
"DateTime-Long",
|
|
44
|
-
"DateTime-Short",
|
|
45
|
-
"DateTime-Since",
|
|
46
|
-
"Time-Only"
|
|
47
|
-
];
|
|
39
|
+
export const formatExists = formatterVal => {
|
|
40
|
+
const formatterValues = ['DateTime-Long', 'DateTime-Short', 'DateTime-Since', 'Time-Only'];
|
|
48
41
|
let isformatter = false;
|
|
49
42
|
if (formatterValues.includes(formatterVal)) {
|
|
50
43
|
isformatter = true;
|
|
@@ -52,8 +45,6 @@ export const formatExists = (formatterVal) => {
|
|
|
52
45
|
return isformatter;
|
|
53
46
|
};
|
|
54
47
|
|
|
55
|
-
|
|
56
|
-
|
|
57
48
|
/**
|
|
58
49
|
* Return relative time in fromNow for the given datetime
|
|
59
50
|
* @description Convert and return the given datetime in dayJSObject
|
|
@@ -61,11 +52,11 @@ export const formatExists = (formatterVal) => {
|
|
|
61
52
|
* @param {string} text datetime
|
|
62
53
|
* @returns {object} datetime as a dayjs object
|
|
63
54
|
*/
|
|
64
|
-
export const getDayJSObject =
|
|
55
|
+
export const getDayJSObject = text => {
|
|
65
56
|
const momObj = dayjs(text);
|
|
66
57
|
if (momObj.isValid()) return momObj;
|
|
67
58
|
const timeStamp = text;
|
|
68
|
-
const isDateTime = timeStamp.indexOf(
|
|
59
|
+
const isDateTime = timeStamp.indexOf('GMT') !== -1;
|
|
69
60
|
const year = parseInt(timeStamp.substr(0, 4), 10);
|
|
70
61
|
const month = parseInt(timeStamp.substr(4, 2), 10) - 1;
|
|
71
62
|
const day = parseInt(timeStamp.substr(6, 2), 10);
|
|
@@ -91,7 +82,7 @@ export const getDayJSObject = (text) => {
|
|
|
91
82
|
}
|
|
92
83
|
|
|
93
84
|
mom = dayjs(
|
|
94
|
-
mom.toLocaleString(
|
|
85
|
+
mom.toLocaleString('en-US', {
|
|
95
86
|
timeZone: CurrentTz
|
|
96
87
|
})
|
|
97
88
|
);
|
|
@@ -105,8 +96,8 @@ export const getDayJSObject = (text) => {
|
|
|
105
96
|
* @param {string} time datetime
|
|
106
97
|
* @returns {object} relative time from now
|
|
107
98
|
*/
|
|
108
|
-
export const getRelativeTime =
|
|
109
|
-
let relativetime =
|
|
99
|
+
export const getRelativeTime = time => {
|
|
100
|
+
let relativetime = '';
|
|
110
101
|
if (dayjs(time).isUTC()) {
|
|
111
102
|
relativetime = dayjs(time).fromNow();
|
|
112
103
|
} else {
|
|
@@ -122,7 +113,7 @@ export const getRelativeTime = (time) => {
|
|
|
122
113
|
* @param {string} value from which Year needs to be taken out
|
|
123
114
|
* @returns {number} year for the date passed
|
|
124
115
|
*/
|
|
125
|
-
export const getFullYear =
|
|
116
|
+
export const getFullYear = value =>
|
|
126
117
|
value ? new Date(value).getFullYear() : new Date().getFullYear();
|
|
127
118
|
|
|
128
119
|
/**
|
|
@@ -172,8 +163,8 @@ export const getMinDate = (previousYears, currentYear, yearFromValue) => {
|
|
|
172
163
|
*
|
|
173
164
|
* @returns {number} clockFormat
|
|
174
165
|
*/
|
|
175
|
-
export const parseClockFormat =
|
|
176
|
-
typeof clockFormat ===
|
|
166
|
+
export const parseClockFormat = clockFormat =>
|
|
167
|
+
typeof clockFormat === 'string' ? parseInt(clockFormat, 10) : clockFormat;
|
|
177
168
|
|
|
178
169
|
/**
|
|
179
170
|
* Return datetime value string off to seconds
|
|
@@ -185,9 +176,9 @@ export const parseClockFormat = (clockFormat) =>
|
|
|
185
176
|
*/
|
|
186
177
|
export const correctDateTimeToSeconds = (datetime, withSeconds) => {
|
|
187
178
|
if (withSeconds) {
|
|
188
|
-
return `${datetime.substring(0, datetime.indexOf(
|
|
179
|
+
return `${datetime.substring(0, datetime.indexOf('Z'))}.000Z`;
|
|
189
180
|
}
|
|
190
|
-
return `${datetime.substring(0, datetime.lastIndexOf(
|
|
181
|
+
return `${datetime.substring(0, datetime.lastIndexOf(':'))}:00.000Z`;
|
|
191
182
|
};
|
|
192
183
|
|
|
193
184
|
/**
|
|
@@ -200,12 +191,9 @@ export const correctDateTimeToSeconds = (datetime, withSeconds) => {
|
|
|
200
191
|
*/
|
|
201
192
|
export const timeCorrectedToSeconds = (datetime, withSeconds) => {
|
|
202
193
|
if (withSeconds) {
|
|
203
|
-
return datetime.substring(datetime.indexOf(
|
|
194
|
+
return datetime.substring(datetime.indexOf('T') + 1, datetime.indexOf('.'));
|
|
204
195
|
}
|
|
205
|
-
return `${datetime.substring(
|
|
206
|
-
datetime.indexOf("T") + 1,
|
|
207
|
-
datetime.lastIndexOf(":")
|
|
208
|
-
)}:00`;
|
|
196
|
+
return `${datetime.substring(datetime.indexOf('T') + 1, datetime.lastIndexOf(':'))}:00`;
|
|
209
197
|
};
|
|
210
198
|
|
|
211
199
|
/**
|
|
@@ -228,14 +216,13 @@ export const datetimeFireChangeBlurEvents = (
|
|
|
228
216
|
propName,
|
|
229
217
|
pConn
|
|
230
218
|
) => {
|
|
231
|
-
|
|
232
219
|
// TODO - clean up, we should not rely on timestamp from cosmos to check InComplete validation
|
|
233
220
|
// above triggerFieldChange should have validated this
|
|
234
221
|
if (errorState) {
|
|
235
222
|
pConn.getValidationApi().validate(errorState);
|
|
236
223
|
}
|
|
237
224
|
// BUG-640834 In errorState presist old values avoiding store update & re-render.
|
|
238
|
-
else{
|
|
225
|
+
else {
|
|
239
226
|
if (formattedValue !== actualValue) {
|
|
240
227
|
actions.updateFieldValue(propName, formattedValue);
|
|
241
228
|
}
|
|
@@ -256,27 +243,27 @@ export const getDateFormat = (locale, options) => {
|
|
|
256
243
|
.formatToParts()
|
|
257
244
|
.map(({ type, value }) => {
|
|
258
245
|
switch (type) {
|
|
259
|
-
case
|
|
260
|
-
return
|
|
261
|
-
case
|
|
262
|
-
return
|
|
263
|
-
case
|
|
264
|
-
return
|
|
265
|
-
case
|
|
266
|
-
return
|
|
267
|
-
case
|
|
268
|
-
return
|
|
269
|
-
case
|
|
270
|
-
return
|
|
271
|
-
case
|
|
272
|
-
return
|
|
273
|
-
case
|
|
246
|
+
case 'day':
|
|
247
|
+
return 'DD';
|
|
248
|
+
case 'month':
|
|
249
|
+
return 'MM';
|
|
250
|
+
case 'year':
|
|
251
|
+
return 'YYYY';
|
|
252
|
+
case 'hour':
|
|
253
|
+
return 'hh';
|
|
254
|
+
case 'minute':
|
|
255
|
+
return 'mm';
|
|
256
|
+
case 'second':
|
|
257
|
+
return 'ss';
|
|
258
|
+
case 'dayPeriod':
|
|
259
|
+
return 'A';
|
|
260
|
+
case 'literal':
|
|
274
261
|
return value;
|
|
275
262
|
default:
|
|
276
|
-
return
|
|
263
|
+
return '';
|
|
277
264
|
}
|
|
278
265
|
})
|
|
279
|
-
.join(
|
|
266
|
+
.join('');
|
|
280
267
|
};
|
|
281
268
|
|
|
282
269
|
/**
|
|
@@ -286,15 +273,13 @@ export const getDateFormat = (locale, options) => {
|
|
|
286
273
|
* @returns {boolean} True or False for the locale
|
|
287
274
|
* Example : getDateFormat("pl-PL") returns false
|
|
288
275
|
*/
|
|
289
|
-
export const is12HClockFormat =
|
|
276
|
+
export const is12HClockFormat = locale => {
|
|
290
277
|
const meridiem = new Intl.DateTimeFormat(locale, {
|
|
291
|
-
hour:
|
|
278
|
+
hour: 'numeric'
|
|
292
279
|
})
|
|
293
280
|
.formatToParts()
|
|
294
|
-
.find(({ type }) => type ===
|
|
295
|
-
return !!(meridiem === null || meridiem === undefined
|
|
296
|
-
? undefined
|
|
297
|
-
: meridiem.value);
|
|
281
|
+
.find(({ type }) => type === 'dayPeriod');
|
|
282
|
+
return !!(meridiem === null || meridiem === undefined ? undefined : meridiem.value);
|
|
298
283
|
};
|
|
299
284
|
|
|
300
285
|
/**
|
|
@@ -307,9 +292,9 @@ export const is12HClockFormat = (locale) => {
|
|
|
307
292
|
*/
|
|
308
293
|
export const getTimeOptions = (withSeconds, is12h = false) => {
|
|
309
294
|
return {
|
|
310
|
-
hour:
|
|
311
|
-
minute:
|
|
312
|
-
...(withSeconds && { second:
|
|
295
|
+
hour: 'numeric',
|
|
296
|
+
minute: 'numeric',
|
|
297
|
+
...(withSeconds && { second: 'numeric' }),
|
|
313
298
|
hour12: is12h
|
|
314
299
|
};
|
|
315
300
|
};
|
|
@@ -324,9 +309,9 @@ export const getTimeOptions = (withSeconds, is12h = false) => {
|
|
|
324
309
|
*/
|
|
325
310
|
export const getDateTimeOptions = (withSeconds, is12h = false) => {
|
|
326
311
|
return {
|
|
327
|
-
year:
|
|
328
|
-
month:
|
|
329
|
-
day:
|
|
312
|
+
year: 'numeric',
|
|
313
|
+
month: 'numeric',
|
|
314
|
+
day: 'numeric',
|
|
330
315
|
...getTimeOptions(withSeconds, is12h)
|
|
331
316
|
};
|
|
332
317
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable import/no-relative-packages */
|
|
2
|
-
/* eslint-disable no-undef */
|
|
3
1
|
import { createUID } from '@pega/cosmos-react-core';
|
|
4
2
|
|
|
5
3
|
// import { LazyMap as LazyComponentMap } from '../../components_map';
|
|
@@ -19,15 +17,15 @@ export function getAllFields(pConnect) {
|
|
|
19
17
|
|
|
20
18
|
let allFields = [];
|
|
21
19
|
|
|
22
|
-
const makeField =
|
|
20
|
+
const makeField = f => ({
|
|
23
21
|
...pConnect().resolveConfigProps(f.config),
|
|
24
22
|
type: f.type
|
|
25
23
|
});
|
|
26
24
|
|
|
27
25
|
const hasRegions = !!metadata.children[0]?.children;
|
|
28
26
|
if (hasRegions) {
|
|
29
|
-
allFields = metadata.children.map(
|
|
30
|
-
region.children.map(
|
|
27
|
+
allFields = metadata.children.map(region =>
|
|
28
|
+
region.children.map(field => {
|
|
31
29
|
// Do not resolve the config props if is status work, instead create component here as status badge and mark as status display
|
|
32
30
|
if (field.config?.value === '@P .pyStatusWork') {
|
|
33
31
|
field.type = 'TextInput';
|
|
@@ -112,7 +110,9 @@ export function prepareComponentInCaseSummary(configObject, getPConnect, display
|
|
|
112
110
|
// createdComponent.props.getPConnect().setInheritedProp("hideLabel", true);
|
|
113
111
|
caseSummaryComponentObject.value = createdComponent;
|
|
114
112
|
if (type === 'reference') {
|
|
115
|
-
caseSummaryComponentObject.name = createdComponent.props
|
|
113
|
+
caseSummaryComponentObject.name = createdComponent.props
|
|
114
|
+
.getPConnect()
|
|
115
|
+
.getInheritedProps().label;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
return caseSummaryComponentObject;
|
|
@@ -131,12 +131,12 @@ export function getFilteredFields(getPConnect) {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// Filter out fields that are not visible and unsupported types for primary fields (for CaseSummary)
|
|
134
|
-
primaryFieldsRaw = primaryFieldsRaw.filter(
|
|
134
|
+
primaryFieldsRaw = primaryFieldsRaw.filter(item => {
|
|
135
135
|
const resolvedItem = getPConnect().resolveConfigProps(item.config);
|
|
136
136
|
return resolvedItem.visibility !== false && item.type !== 'TextContent';
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
-
secondaryFieldsRaw = secondaryFieldsRaw.filter(
|
|
139
|
+
secondaryFieldsRaw = secondaryFieldsRaw.filter(item => {
|
|
140
140
|
const resolvedItem = getPConnect().resolveConfigProps(item.config);
|
|
141
141
|
return resolvedItem.visibility !== false && item.type !== 'TextContent';
|
|
142
142
|
});
|
|
@@ -163,7 +163,9 @@ export function getLayoutDataFromRegion(regionData) {
|
|
|
163
163
|
const itemPConnect = item?.getPConnect();
|
|
164
164
|
|
|
165
165
|
return {
|
|
166
|
-
id: itemPConnect?.getComponentName()
|
|
166
|
+
id: itemPConnect?.getComponentName()
|
|
167
|
+
? `${itemPConnect.getComponentName()}--${index}`
|
|
168
|
+
: `item--${index}`,
|
|
167
169
|
content: itemPConnect?.getComponent(),
|
|
168
170
|
layoutConfig: {
|
|
169
171
|
...defaultLayoutConfig,
|
|
@@ -214,9 +216,8 @@ export function getInstructions(pConnect, instructions = 'casestep') {
|
|
|
214
216
|
|
|
215
217
|
// If the annotation wasn't processed correctly, don't return any instruction text
|
|
216
218
|
if (instructions?.startsWith('@PARAGRAPH')) {
|
|
217
|
-
/* eslint-disable no-console */
|
|
218
219
|
console.error('@PARAGRAPH annotation was not processed. Hiding custom instructions.');
|
|
219
|
-
|
|
220
|
+
|
|
220
221
|
return undefined;
|
|
221
222
|
}
|
|
222
223
|
|