@pega/custom-dx-components 2.0.23 → 2.0.25
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/README.md +1 -1
- package/package.json +3 -6
- package/src/cli.js +0 -18
- package/src/constants.js +2 -32
- package/src/tasks/authenticate/helper.js +5 -63
- package/src/tasks/authenticate/index.js +50 -107
- package/src/tasks/create/index.js +63 -59
- package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +16 -33
- package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +2 -1
- package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +67 -179
- package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +17 -46
- package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +1 -3
- package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/{date-utils.js.mustache → date-utils.js} +0 -1
- package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +17 -46
- package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +17 -22
- package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +1 -2
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +17 -26
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +4 -3
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +17 -22
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +2 -8
- package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +17 -22
- package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +1 -2
- package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +16 -50
- package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +1 -44
- package/src/tasks/create/templates/Constellation/Field/Picklist/picklist.js.mustache +43 -0
- package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +16 -23
- package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +17 -21
- package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +2 -44
- package/src/tasks/create/templates/Constellation/Field/Text-Email/text-email.js.mustache +43 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/{StatusWork.jsx → StatusWork.js} +1 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +17 -21
- package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +3 -46
- package/src/tasks/create/templates/Constellation/Field/Text-Input/text-input.js.mustache +43 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +17 -21
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +2 -44
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache +43 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +17 -19
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +3 -47
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/text-phone.js.mustache +43 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +17 -19
- package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Field/Text-URL/{text-url.jsx.mustache → text-url.js.mustache} +1 -2
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +17 -30
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +29 -14
- package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +77 -3
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +29 -14
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +74 -3
- package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +10 -6
- package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +8 -10
- package/src/tasks/create/templates/Constellation/Template/PAGE/{GetNextWork.jsx.mustache → GetNextWork.js.mustache} +0 -6
- package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +7 -9
- package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +1 -4
- package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +8 -8
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Avatar.jsx.mustache → Avatar.js.mustache} +0 -2
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Operator.jsx.mustache → Operator.js.mustache} +1 -2
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +9 -9
- package/src/tasks/delete/helper.js +0 -4
- package/src/tasks/delete/index.js +0 -4
- package/src/tasks/index.js +0 -3
- package/src/tasks/init/index.js +3 -3
- package/src/tasks/init/template/.eslintrc.json +5 -186
- package/src/tasks/init/template/README.md +59 -75
- package/src/tasks/init/template/package.json.mustache +6 -21
- package/src/tasks/init/template/tasks.config.json +2 -5
- package/src/tasks/list/index.js +0 -4
- package/src/tasks/{bundle → publish/bundle}/builder/webpack.config.js +2 -0
- package/src/tasks/{bundle → publish/bundle}/index.js +2 -2
- package/src/tasks/publish/index.js +1 -14
- package/src/util.js +6 -11
- package/src/auth.js +0 -563
- package/src/tasks/build/helper.js +0 -123
- package/src/tasks/build/index.js +0 -54
- package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +0 -21
- package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +0 -61
- package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +0 -41
- package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +0 -23
- package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +0 -23
- package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +0 -21
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +0 -23
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +0 -21
- package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +0 -21
- package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +0 -67
- package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +0 -13
- package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +0 -22
- package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +0 -21
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +0 -20
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +0 -37
- package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +0 -22
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/mock.stories.js.mustache +0 -20
- package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +0 -26
- package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +0 -118
- package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +0 -179
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +0 -26
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +0 -123
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +0 -215
- package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +0 -93
- package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +0 -125
- package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +0 -100
- package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +0 -131
- package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +0 -101
- package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +0 -94
- package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +0 -78
- package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +0 -390
- package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +0 -30
- package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +0 -23
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +0 -68
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +0 -51
- package/src/tasks/delete-all/helper.js +0 -175
- package/src/tasks/delete-all/index.js +0 -49
- package/src/tasks/init/template/.eslintignore +0 -8
- package/src/tasks/linter/index.js +0 -46
- package/src/tasks/publish-all/helper.js +0 -139
- package/src/tasks/publish-all/index.js +0 -84
- /package/src/tasks/{bundle → publish/bundle}/builder/index.js +0 -0
- /package/src/tasks/{bundle → publish/bundle}/builder/modules.js +0 -0
- /package/src/tasks/{bundle → publish/bundle}/builder/paths.js +0 -0
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { withKnobs } from '@storybook/addon-knobs';
|
|
2
|
+
import { withKnobs, text, boolean } from '@storybook/addon-knobs';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {{COMPONENT_CLASS_NAME}} from './index';
|
|
4
|
+
import {{COMPONENT_CLASS_NAME}} from './index.jsx';
|
|
7
5
|
|
|
8
6
|
export default {
|
|
9
7
|
title: '{{COMPONENT_CLASS_NAME}}',
|
|
@@ -12,45 +10,30 @@ export default {
|
|
|
12
10
|
};
|
|
13
11
|
|
|
14
12
|
export const base{{COMPONENT_CLASS_NAME}} = () => {
|
|
15
|
-
|
|
16
|
-
const [value, setValue] = useState(configProps.value);
|
|
13
|
+
const [value, setValue] = useState('test value');
|
|
17
14
|
|
|
18
15
|
const props = {
|
|
19
|
-
value,
|
|
20
|
-
label: configProps.label,
|
|
21
|
-
helperText: configProps.helperText,
|
|
22
|
-
caption: configProps.caption,
|
|
23
|
-
validatemessage: configProps.validatemessage,
|
|
24
|
-
hideLabel: configProps.hideLabel,
|
|
25
|
-
testId: configProps.testId,
|
|
26
|
-
additionalProps: configProps.additionalProps,
|
|
27
|
-
displayMode: configProps.displayMode,
|
|
28
|
-
variant: configProps.variant,
|
|
29
|
-
trueLabel: configProps.trueLabel,
|
|
30
|
-
falseLabel: configProps.falseLabel,
|
|
31
|
-
disabled: configProps.disabled,
|
|
32
|
-
readOnly: configProps.readOnly,
|
|
33
|
-
required: configProps.required,
|
|
34
16
|
getPConnect: () => {
|
|
35
17
|
return {
|
|
36
|
-
getStateProps: () => {
|
|
37
|
-
return stateProps;
|
|
38
|
-
},
|
|
39
18
|
getActionsApi: () => {
|
|
40
19
|
return {
|
|
41
|
-
updateFieldValue: (propName,
|
|
42
|
-
setValue(
|
|
43
|
-
}
|
|
44
|
-
triggerFieldChange: () => { /* nothing */}
|
|
20
|
+
updateFieldValue: (propName, value) => {
|
|
21
|
+
setValue(value);
|
|
22
|
+
}
|
|
45
23
|
};
|
|
46
24
|
},
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
validate: () => { /* nothing */}
|
|
50
|
-
};
|
|
25
|
+
getStateProps: () => {
|
|
26
|
+
return { value: '.name' };
|
|
51
27
|
}
|
|
52
28
|
};
|
|
53
|
-
}
|
|
29
|
+
},
|
|
30
|
+
value,
|
|
31
|
+
placeholder: text('Placeholder', 'Test placeholder'),
|
|
32
|
+
disabled: boolean('Disabled', false),
|
|
33
|
+
readOnly: boolean('Disabled', false),
|
|
34
|
+
required: boolean('Disabled', false),
|
|
35
|
+
label: text('Label', 'Sample Label'),
|
|
36
|
+
testId: text('Test id', 'text-12344566')
|
|
54
37
|
};
|
|
55
38
|
|
|
56
39
|
return (
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import PropTypes from "prop-types";
|
|
8
8
|
|
|
9
9
|
// includes in bundle
|
|
10
|
+
import { format } from "./boolean-format";
|
|
10
11
|
import handleEvent from "./event-utils";
|
|
11
12
|
|
|
12
13
|
import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
|
|
@@ -69,7 +70,7 @@ const {{COMPONENT_CLASS_NAME}} = props => {
|
|
|
69
70
|
|
|
70
71
|
let displayComponent;
|
|
71
72
|
if (displayMode) {
|
|
72
|
-
displayComponent = <
|
|
73
|
+
displayComponent = <BooleanDisplay value={value} trueLabel={trueLabel} falseLabel={falseLabel}></BooleanDisplay>;
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
if (displayMode === 'DISPLAY_ONLY') {
|
|
@@ -1,90 +1,31 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
1
|
import dayjs from 'dayjs';
|
|
3
|
-
import DateFormatter from './DateFormatter';
|
|
4
2
|
|
|
5
3
|
const relativeTime = require('dayjs/plugin/relativeTime');
|
|
6
4
|
const utc = require('dayjs/plugin/utc');
|
|
7
|
-
const localizedFormat = require('dayjs/plugin/localizedFormat');
|
|
8
|
-
const tzone = require('dayjs/plugin/timezone');
|
|
9
5
|
|
|
10
6
|
dayjs.extend(relativeTime);
|
|
11
|
-
dayjs.extend(localizedFormat);
|
|
12
7
|
dayjs.extend(utc);
|
|
13
|
-
dayjs.extend(tzone);
|
|
14
8
|
|
|
15
|
-
|
|
16
|
-
if (!/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(str)) return false;
|
|
17
|
-
const d = new Date(str);
|
|
18
|
-
return d.toISOString() === str;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function getDateObject(text) {
|
|
22
|
-
// TODO - cleanup formatters util functions as DX APIs are returning values per ISO std now.
|
|
23
|
-
const timeStamp = text.replace(/-/g, '');
|
|
24
|
-
const isDateTime = timeStamp.indexOf('GMT') !== -1;
|
|
25
|
-
const year = parseInt(timeStamp.substr(0, 4), 10);
|
|
26
|
-
const month = parseInt(timeStamp.substr(4, 2), 10) - 1;
|
|
27
|
-
const day = parseInt(timeStamp.substr(6, 2), 10);
|
|
28
|
-
|
|
29
|
-
const date = new Date();
|
|
30
|
-
|
|
31
|
-
date.setDate(day);
|
|
32
|
-
date.setMonth(month);
|
|
33
|
-
date.setFullYear(year);
|
|
34
|
-
|
|
35
|
-
if (isDateTime) {
|
|
36
|
-
const hours = parseInt(timeStamp.substr(9, 2), 10);
|
|
37
|
-
const minutes = parseInt(timeStamp.substr(11, 2), 10);
|
|
38
|
-
const seconds = parseInt(timeStamp.substr(13, 2), 10);
|
|
39
|
-
const ms = parseInt(timeStamp.substr(16, 3), 10);
|
|
40
|
-
date.setHours(hours);
|
|
41
|
-
date.setMinutes(minutes);
|
|
42
|
-
date.setSeconds(seconds);
|
|
43
|
-
date.setMilliseconds(ms);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return date;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function parseDateInISO(value) {
|
|
50
|
-
const isMilliSeconds = new RegExp('^[0-9]+$').exec(value);
|
|
51
|
-
if (isMilliSeconds) {
|
|
52
|
-
const date = new Date(parseInt(value, 10));
|
|
53
|
-
return date.toISOString();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (isIsoDate(value)) {
|
|
57
|
-
const date = new Date(value);
|
|
58
|
-
return date.toISOString();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return value ? getDateObject(value).toISOString() : value;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export default {
|
|
65
|
-
...DateFormatter
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export const datetimedisplayformatter = formatter => {
|
|
9
|
+
export const datetimedisplayformatter = (formatter) => {
|
|
69
10
|
const objectvalues = {};
|
|
70
11
|
switch (formatter) {
|
|
71
|
-
case
|
|
72
|
-
objectvalues.variantVal =
|
|
73
|
-
objectvalues.formatVal =
|
|
12
|
+
case "DateTime-Long": {
|
|
13
|
+
objectvalues.variantVal = "datetime";
|
|
14
|
+
objectvalues.formatVal = "long";
|
|
74
15
|
break;
|
|
75
16
|
}
|
|
76
|
-
case
|
|
77
|
-
objectvalues.variantVal =
|
|
78
|
-
objectvalues.formatVal =
|
|
17
|
+
case "DateTime-Short": {
|
|
18
|
+
objectvalues.variantVal = "date";
|
|
19
|
+
objectvalues.formatVal = "short";
|
|
79
20
|
break;
|
|
80
21
|
}
|
|
81
|
-
case
|
|
82
|
-
objectvalues.variantVal =
|
|
22
|
+
case "DateTime-Since": {
|
|
23
|
+
objectvalues.variantVal = "relative";
|
|
83
24
|
break;
|
|
84
25
|
}
|
|
85
|
-
case
|
|
86
|
-
objectvalues.variantVal =
|
|
87
|
-
objectvalues.formatVal =
|
|
26
|
+
case "Time-Only": {
|
|
27
|
+
objectvalues.variantVal = "time";
|
|
28
|
+
objectvalues.formatVal = "short";
|
|
88
29
|
break;
|
|
89
30
|
}
|
|
90
31
|
// no default
|
|
@@ -92,8 +33,13 @@ export const datetimedisplayformatter = formatter => {
|
|
|
92
33
|
return objectvalues;
|
|
93
34
|
};
|
|
94
35
|
|
|
95
|
-
export const formatExists = formatterVal => {
|
|
96
|
-
const formatterValues = [
|
|
36
|
+
export const formatExists = (formatterVal) => {
|
|
37
|
+
const formatterValues = [
|
|
38
|
+
"DateTime-Long",
|
|
39
|
+
"DateTime-Short",
|
|
40
|
+
"DateTime-Since",
|
|
41
|
+
"Time-Only"
|
|
42
|
+
];
|
|
97
43
|
let isformatter = false;
|
|
98
44
|
if (formatterValues.includes(formatterVal)) {
|
|
99
45
|
isformatter = true;
|
|
@@ -101,6 +47,8 @@ export const formatExists = formatterVal => {
|
|
|
101
47
|
return isformatter;
|
|
102
48
|
};
|
|
103
49
|
|
|
50
|
+
|
|
51
|
+
|
|
104
52
|
/**
|
|
105
53
|
* Return relative time in fromNow for the given datetime
|
|
106
54
|
* @description Convert and return the given datetime in dayJSObject
|
|
@@ -108,11 +56,11 @@ export const formatExists = formatterVal => {
|
|
|
108
56
|
* @param {string} text datetime
|
|
109
57
|
* @returns {object} datetime as a dayjs object
|
|
110
58
|
*/
|
|
111
|
-
export const getDayJSObject = text => {
|
|
59
|
+
export const getDayJSObject = (text) => {
|
|
112
60
|
const momObj = dayjs(text);
|
|
113
61
|
if (momObj.isValid()) return momObj;
|
|
114
62
|
const timeStamp = text;
|
|
115
|
-
const isDateTime = timeStamp.indexOf(
|
|
63
|
+
const isDateTime = timeStamp.indexOf("GMT") !== -1;
|
|
116
64
|
const year = parseInt(timeStamp.substr(0, 4), 10);
|
|
117
65
|
const month = parseInt(timeStamp.substr(4, 2), 10) - 1;
|
|
118
66
|
const day = parseInt(timeStamp.substr(6, 2), 10);
|
|
@@ -138,7 +86,7 @@ export const getDayJSObject = text => {
|
|
|
138
86
|
}
|
|
139
87
|
|
|
140
88
|
mom = dayjs(
|
|
141
|
-
mom.toLocaleString(
|
|
89
|
+
mom.toLocaleString("en-US", {
|
|
142
90
|
timeZone: CurrentTz
|
|
143
91
|
})
|
|
144
92
|
);
|
|
@@ -152,8 +100,8 @@ export const getDayJSObject = text => {
|
|
|
152
100
|
* @param {string} time datetime
|
|
153
101
|
* @returns {object} relative time from now
|
|
154
102
|
*/
|
|
155
|
-
export const getRelativeTime = time => {
|
|
156
|
-
let relativetime =
|
|
103
|
+
export const getRelativeTime = (time) => {
|
|
104
|
+
let relativetime = "";
|
|
157
105
|
if (dayjs(time).isUTC()) {
|
|
158
106
|
relativetime = dayjs(time).fromNow();
|
|
159
107
|
} else {
|
|
@@ -169,7 +117,7 @@ export const getRelativeTime = time => {
|
|
|
169
117
|
* @param {string} value from which Year needs to be taken out
|
|
170
118
|
* @returns {number} year for the date passed
|
|
171
119
|
*/
|
|
172
|
-
export const getFullYear = value =>
|
|
120
|
+
export const getFullYear = (value) =>
|
|
173
121
|
value ? new Date(value).getFullYear() : new Date().getFullYear();
|
|
174
122
|
|
|
175
123
|
/**
|
|
@@ -219,8 +167,8 @@ export const getMinDate = (previousYears, currentYear, yearFromValue) => {
|
|
|
219
167
|
*
|
|
220
168
|
* @returns {number} clockFormat
|
|
221
169
|
*/
|
|
222
|
-
export const parseClockFormat = clockFormat =>
|
|
223
|
-
typeof clockFormat ===
|
|
170
|
+
export const parseClockFormat = (clockFormat) =>
|
|
171
|
+
typeof clockFormat === "string" ? parseInt(clockFormat, 10) : clockFormat;
|
|
224
172
|
|
|
225
173
|
/**
|
|
226
174
|
* Return datetime value string off to seconds
|
|
@@ -232,9 +180,9 @@ export const parseClockFormat = clockFormat =>
|
|
|
232
180
|
*/
|
|
233
181
|
export const correctDateTimeToSeconds = (datetime, withSeconds) => {
|
|
234
182
|
if (withSeconds) {
|
|
235
|
-
return `${datetime.substring(0, datetime.indexOf(
|
|
183
|
+
return `${datetime.substring(0, datetime.indexOf("Z"))}.000Z`;
|
|
236
184
|
}
|
|
237
|
-
return `${datetime.substring(0, datetime.lastIndexOf(
|
|
185
|
+
return `${datetime.substring(0, datetime.lastIndexOf(":"))}:00.000Z`;
|
|
238
186
|
};
|
|
239
187
|
|
|
240
188
|
/**
|
|
@@ -247,9 +195,12 @@ export const correctDateTimeToSeconds = (datetime, withSeconds) => {
|
|
|
247
195
|
*/
|
|
248
196
|
export const timeCorrectedToSeconds = (datetime, withSeconds) => {
|
|
249
197
|
if (withSeconds) {
|
|
250
|
-
return datetime.substring(datetime.indexOf(
|
|
198
|
+
return datetime.substring(datetime.indexOf("T") + 1, datetime.indexOf("."));
|
|
251
199
|
}
|
|
252
|
-
return `${datetime.substring(
|
|
200
|
+
return `${datetime.substring(
|
|
201
|
+
datetime.indexOf("T") + 1,
|
|
202
|
+
datetime.lastIndexOf(":")
|
|
203
|
+
)}:00`;
|
|
253
204
|
};
|
|
254
205
|
|
|
255
206
|
/**
|
|
@@ -272,13 +223,14 @@ export const datetimeFireChangeBlurEvents = (
|
|
|
272
223
|
propName,
|
|
273
224
|
pConn
|
|
274
225
|
) => {
|
|
226
|
+
|
|
275
227
|
// TODO - clean up, we should not rely on timestamp from cosmos to check InComplete validation
|
|
276
228
|
// above triggerFieldChange should have validated this
|
|
277
229
|
if (errorState) {
|
|
278
230
|
pConn.getValidationApi().validate(errorState);
|
|
279
231
|
}
|
|
280
232
|
// BUG-640834 In errorState presist old values avoiding store update & re-render.
|
|
281
|
-
else
|
|
233
|
+
else{
|
|
282
234
|
if (formattedValue !== actualValue) {
|
|
283
235
|
actions.updateFieldValue(propName, formattedValue);
|
|
284
236
|
}
|
|
@@ -299,27 +251,27 @@ export const getDateFormat = (locale, options) => {
|
|
|
299
251
|
.formatToParts()
|
|
300
252
|
.map(({ type, value }) => {
|
|
301
253
|
switch (type) {
|
|
302
|
-
case
|
|
303
|
-
return
|
|
304
|
-
case
|
|
305
|
-
return
|
|
306
|
-
case
|
|
307
|
-
return
|
|
308
|
-
case
|
|
309
|
-
return
|
|
310
|
-
case
|
|
311
|
-
return
|
|
312
|
-
case
|
|
313
|
-
return
|
|
314
|
-
case
|
|
315
|
-
return
|
|
316
|
-
case
|
|
254
|
+
case "day":
|
|
255
|
+
return "DD";
|
|
256
|
+
case "month":
|
|
257
|
+
return "MM";
|
|
258
|
+
case "year":
|
|
259
|
+
return "YYYY";
|
|
260
|
+
case "hour":
|
|
261
|
+
return "hh";
|
|
262
|
+
case "minute":
|
|
263
|
+
return "mm";
|
|
264
|
+
case "second":
|
|
265
|
+
return "ss";
|
|
266
|
+
case "dayPeriod":
|
|
267
|
+
return "A";
|
|
268
|
+
case "literal":
|
|
317
269
|
return value;
|
|
318
270
|
default:
|
|
319
|
-
return
|
|
271
|
+
return "";
|
|
320
272
|
}
|
|
321
273
|
})
|
|
322
|
-
.join(
|
|
274
|
+
.join("");
|
|
323
275
|
};
|
|
324
276
|
|
|
325
277
|
/**
|
|
@@ -329,13 +281,15 @@ export const getDateFormat = (locale, options) => {
|
|
|
329
281
|
* @returns {boolean} True or False for the locale
|
|
330
282
|
* Example : getDateFormat("pl-PL") returns false
|
|
331
283
|
*/
|
|
332
|
-
export const is12HClockFormat = locale => {
|
|
284
|
+
export const is12HClockFormat = (locale) => {
|
|
333
285
|
const meridiem = new Intl.DateTimeFormat(locale, {
|
|
334
|
-
hour:
|
|
286
|
+
hour: "numeric"
|
|
335
287
|
})
|
|
336
288
|
.formatToParts()
|
|
337
|
-
.find(({ type }) => type ===
|
|
338
|
-
return !!(meridiem === null || meridiem === undefined
|
|
289
|
+
.find(({ type }) => type === "dayPeriod");
|
|
290
|
+
return !!(meridiem === null || meridiem === undefined
|
|
291
|
+
? undefined
|
|
292
|
+
: meridiem.value);
|
|
339
293
|
};
|
|
340
294
|
|
|
341
295
|
/**
|
|
@@ -348,9 +302,9 @@ export const is12HClockFormat = locale => {
|
|
|
348
302
|
*/
|
|
349
303
|
export const getTimeOptions = (withSeconds, is12h = false) => {
|
|
350
304
|
return {
|
|
351
|
-
hour:
|
|
352
|
-
minute:
|
|
353
|
-
...(withSeconds && { second:
|
|
305
|
+
hour: "numeric",
|
|
306
|
+
minute: "numeric",
|
|
307
|
+
...(withSeconds && { second: "numeric" }),
|
|
354
308
|
hour12: is12h
|
|
355
309
|
};
|
|
356
310
|
};
|
|
@@ -365,75 +319,9 @@ export const getTimeOptions = (withSeconds, is12h = false) => {
|
|
|
365
319
|
*/
|
|
366
320
|
export const getDateTimeOptions = (withSeconds, is12h = false) => {
|
|
367
321
|
return {
|
|
368
|
-
year:
|
|
369
|
-
month:
|
|
370
|
-
day:
|
|
322
|
+
year: "numeric",
|
|
323
|
+
month: "numeric",
|
|
324
|
+
day: "numeric",
|
|
371
325
|
...getTimeOptions(withSeconds, is12h)
|
|
372
326
|
};
|
|
373
327
|
};
|
|
374
|
-
|
|
375
|
-
export function getCurrentTimezone(timezone) {
|
|
376
|
-
if (timezone) return timezone;
|
|
377
|
-
return PCore?.getLocaleUtils?.().getTimeZoneInUse?.();
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
export function format(value, type, options) {
|
|
381
|
-
let formattedValue;
|
|
382
|
-
|
|
383
|
-
switch (type?.toLowerCase()) {
|
|
384
|
-
case 'currency': {
|
|
385
|
-
const defaultOptions = {
|
|
386
|
-
locale: getLocale(),
|
|
387
|
-
position: 'before',
|
|
388
|
-
decPlaces: 2
|
|
389
|
-
};
|
|
390
|
-
const params = { ...defaultOptions, ...options };
|
|
391
|
-
formattedValue = Currency.Currency(value, params);
|
|
392
|
-
break;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
case 'decimal': {
|
|
396
|
-
const defaultOptions = { locale: getLocale(), decPlaces: 2 };
|
|
397
|
-
const params = { ...defaultOptions, ...options };
|
|
398
|
-
formattedValue = Currency.Decimal(value, params);
|
|
399
|
-
break;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
case 'integer': {
|
|
403
|
-
const defaultOptions = { locale: getLocale() };
|
|
404
|
-
const params = { ...defaultOptions, ...options };
|
|
405
|
-
formattedValue = Currency.Integer(value, params);
|
|
406
|
-
break;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
case 'date': {
|
|
410
|
-
const defaultOptions = {
|
|
411
|
-
format: 'MMM DD, YYYY',
|
|
412
|
-
timezone: getCurrentTimezone()
|
|
413
|
-
};
|
|
414
|
-
const params = { ...defaultOptions, ...options };
|
|
415
|
-
formattedValue = DateFormatter.Date(parseDateInISO(value), params);
|
|
416
|
-
break;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
case 'datetime': {
|
|
420
|
-
const defaultOptions = {
|
|
421
|
-
format: 'MMM DD, YYYY h:mm A',
|
|
422
|
-
timezone: getCurrentTimezone()
|
|
423
|
-
};
|
|
424
|
-
const params = { ...defaultOptions, ...options };
|
|
425
|
-
formattedValue = DateFormatter.Date(parseDateInISO(value), params);
|
|
426
|
-
break;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
case 'boolean':
|
|
430
|
-
case 'checkbox': {
|
|
431
|
-
formattedValue = Boolean.TrueFalse(value, { allowEmpty: false });
|
|
432
|
-
break;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
default:
|
|
436
|
-
formattedValue = value;
|
|
437
|
-
}
|
|
438
|
-
return formattedValue;
|
|
439
|
-
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { withKnobs, text, boolean } from '@storybook/addon-knobs';
|
|
3
|
+
|
|
3
4
|
import {{COMPONENT_CLASS_NAME}} from './index.jsx';
|
|
4
5
|
|
|
5
6
|
export default {
|
|
@@ -8,61 +9,31 @@ export default {
|
|
|
8
9
|
component: {{COMPONENT_CLASS_NAME}}
|
|
9
10
|
};
|
|
10
11
|
|
|
11
|
-
if (!window.PCore) {
|
|
12
|
-
window.PCore = {};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
window.PCore.getEnvironmentInfo = () => {
|
|
16
|
-
return {
|
|
17
|
-
getLocale: () => {
|
|
18
|
-
return 'en-GB';
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
|
|
23
12
|
export const base{{COMPONENT_CLASS_NAME}} = () => {
|
|
13
|
+
const [value, setValue] = useState('test value');
|
|
14
|
+
|
|
24
15
|
const props = {
|
|
25
16
|
getPConnect: () => {
|
|
26
17
|
return {
|
|
27
18
|
getActionsApi: () => {
|
|
28
19
|
return {
|
|
29
|
-
updateFieldValue: () => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
getValidationApi: () => {
|
|
34
|
-
return {
|
|
35
|
-
validate: () => {/* nothing */}
|
|
20
|
+
updateFieldValue: (propName, value) => {
|
|
21
|
+
setValue(value);
|
|
22
|
+
}
|
|
36
23
|
};
|
|
37
24
|
},
|
|
38
25
|
getStateProps: () => {
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
getConfigProps: () => {
|
|
42
|
-
return configProps;
|
|
43
|
-
},
|
|
44
|
-
ignoreSuggestion: () => {/* nothing */},
|
|
45
|
-
acceptSuggestion: () => {/* nothing */},
|
|
46
|
-
clearErrorMessages: () => {/* nothing */}
|
|
26
|
+
return { value: '.name' };
|
|
27
|
+
}
|
|
47
28
|
};
|
|
48
29
|
},
|
|
49
|
-
value
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
showWeekNumber: configProps.showWeekNumber,
|
|
57
|
-
testId: configProps.testId,
|
|
58
|
-
showAsFormattedText: configProps.showAsFormattedText,
|
|
59
|
-
additionalProps: configProps.additionalProps,
|
|
60
|
-
displayMode: configProps.displayMode,
|
|
61
|
-
variant: configProps.variant,
|
|
62
|
-
hasSuggestions: configProps.hasSuggestions,
|
|
63
|
-
disabled: configProps.disabled,
|
|
64
|
-
readOnly: configProps.readOnly,
|
|
65
|
-
required: configProps.required
|
|
30
|
+
value,
|
|
31
|
+
placeholder: text('Placeholder', 'Test placeholder'),
|
|
32
|
+
disabled: boolean('Disabled', false),
|
|
33
|
+
readOnly: boolean('Disabled', false),
|
|
34
|
+
required: boolean('Disabled', false),
|
|
35
|
+
label: text('Label', 'Sample Label'),
|
|
36
|
+
testId: text('Test id', 'text-12344566')
|
|
66
37
|
};
|
|
67
38
|
|
|
68
39
|
return (
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
1
|
import { useEffect, useState } from 'react';
|
|
3
|
-
import { DateInput, FieldValueList, DateTimeDisplay, Text
|
|
2
|
+
import { DateInput, FieldValueList, DateTimeDisplay, Text } from '@pega/cosmos-react-core';
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
5
|
-
import FormattedText from "./FormattedText.jsx";
|
|
6
4
|
|
|
7
5
|
import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
|
|
8
6
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { withKnobs, text, boolean } from '@storybook/addon-knobs';
|
|
3
|
+
|
|
3
4
|
import {{COMPONENT_CLASS_NAME}} from './index.jsx';
|
|
4
5
|
|
|
5
6
|
export default {
|
|
@@ -8,61 +9,31 @@ export default {
|
|
|
8
9
|
component: {{COMPONENT_CLASS_NAME}}
|
|
9
10
|
};
|
|
10
11
|
|
|
11
|
-
if (!window.PCore) {
|
|
12
|
-
window.PCore = {};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
window.PCore.getEnvironmentInfo = () => {
|
|
16
|
-
return {
|
|
17
|
-
getTimeZone: () => {
|
|
18
|
-
return '';
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
|
|
23
12
|
export const base{{COMPONENT_CLASS_NAME}} = () => {
|
|
13
|
+
const [value, setValue] = useState('test value');
|
|
14
|
+
|
|
24
15
|
const props = {
|
|
25
16
|
getPConnect: () => {
|
|
26
17
|
return {
|
|
27
18
|
getActionsApi: () => {
|
|
28
19
|
return {
|
|
29
|
-
updateFieldValue: () => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
getValidationApi: () => {
|
|
34
|
-
return {
|
|
35
|
-
validate: () => {/* nothing */}
|
|
20
|
+
updateFieldValue: (propName, value) => {
|
|
21
|
+
setValue(value);
|
|
22
|
+
}
|
|
36
23
|
};
|
|
37
24
|
},
|
|
38
25
|
getStateProps: () => {
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
getConfigProps: () => {
|
|
42
|
-
return configProps;
|
|
43
|
-
},
|
|
44
|
-
ignoreSuggestion: () => {/* nothing */},
|
|
45
|
-
acceptSuggestion: () => {/* nothing */},
|
|
46
|
-
clearErrorMessages: () => {/* nothing */}
|
|
26
|
+
return { value: '.name' };
|
|
27
|
+
}
|
|
47
28
|
};
|
|
48
29
|
},
|
|
49
|
-
value
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
previousYearRange: configProps.previousYearRange,
|
|
57
|
-
showWeekNumber: configProps.showWeekNumber,
|
|
58
|
-
testId: configProps.testId,
|
|
59
|
-
additionalProps: configProps.additionalProps,
|
|
60
|
-
displayMode: configProps.displayMode,
|
|
61
|
-
variant: configProps.variant,
|
|
62
|
-
hasSuggestions: configProps.hasSuggestions,
|
|
63
|
-
disabled: configProps.disabled,
|
|
64
|
-
readOnly: configProps.readOnly,
|
|
65
|
-
required: configProps.required
|
|
30
|
+
value,
|
|
31
|
+
placeholder: text('Placeholder', 'Test placeholder'),
|
|
32
|
+
disabled: boolean('Disabled', false),
|
|
33
|
+
readOnly: boolean('Disabled', false),
|
|
34
|
+
required: boolean('Disabled', false),
|
|
35
|
+
label: text('Label', 'Sample Label'),
|
|
36
|
+
testId: text('Test id', 'text-12344566')
|
|
66
37
|
};
|
|
67
38
|
|
|
68
39
|
return (
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
1
|
import { useEffect, useState } from 'react';
|
|
3
2
|
import { DateTimeInput, FieldValueList, DateTimeDisplay, Text } from "@pega/cosmos-react-core";
|
|
4
3
|
import PropTypes from "prop-types";
|
|
@@ -247,7 +246,6 @@ const {{COMPONENT_CLASS_NAME}} = props => {
|
|
|
247
246
|
displayMode: PropTypes.string,
|
|
248
247
|
variant: PropTypes.string,
|
|
249
248
|
formatter: PropTypes.string,
|
|
250
|
-
Format: PropTypes.string,
|
|
251
249
|
hasSuggestions: PropTypes.bool
|
|
252
250
|
};
|
|
253
251
|
|