@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.
Files changed (122) hide show
  1. package/README.md +1 -1
  2. package/package.json +3 -6
  3. package/src/cli.js +0 -18
  4. package/src/constants.js +2 -32
  5. package/src/tasks/authenticate/helper.js +5 -63
  6. package/src/tasks/authenticate/index.js +50 -107
  7. package/src/tasks/create/index.js +63 -59
  8. package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +1 -1
  9. package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +16 -33
  10. package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +2 -1
  11. package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +67 -179
  12. package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +17 -46
  13. package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +1 -3
  14. package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +1 -0
  15. package/src/tasks/create/templates/Constellation/Field/DateTime/{date-utils.js.mustache → date-utils.js} +0 -1
  16. package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +0 -1
  17. package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +17 -46
  18. package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +0 -2
  19. package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +17 -22
  20. package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +1 -2
  21. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +17 -26
  22. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +4 -3
  23. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +17 -22
  24. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +2 -8
  25. package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +17 -22
  26. package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +1 -2
  27. package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +16 -50
  28. package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +1 -44
  29. package/src/tasks/create/templates/Constellation/Field/Picklist/picklist.js.mustache +43 -0
  30. package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +16 -23
  31. package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +17 -21
  32. package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +2 -44
  33. package/src/tasks/create/templates/Constellation/Field/Text-Email/text-email.js.mustache +43 -0
  34. package/src/tasks/create/templates/Constellation/Field/Text-Input/{StatusWork.jsx → StatusWork.js} +1 -0
  35. package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +17 -21
  36. package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +3 -46
  37. package/src/tasks/create/templates/Constellation/Field/Text-Input/text-input.js.mustache +43 -0
  38. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +17 -21
  39. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +2 -44
  40. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache +43 -0
  41. package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +17 -19
  42. package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +3 -47
  43. package/src/tasks/create/templates/Constellation/Field/Text-Phone/text-phone.js.mustache +43 -0
  44. package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +17 -19
  45. package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +1 -1
  46. package/src/tasks/create/templates/Constellation/Field/Text-URL/{text-url.jsx.mustache → text-url.js.mustache} +1 -2
  47. package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +17 -30
  48. package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +0 -1
  49. package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +29 -14
  50. package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +77 -3
  51. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +29 -14
  52. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +74 -3
  53. package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +10 -6
  54. package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +8 -10
  55. package/src/tasks/create/templates/Constellation/Template/PAGE/{GetNextWork.jsx.mustache → GetNextWork.js.mustache} +0 -6
  56. package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +7 -9
  57. package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +1 -4
  58. package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +0 -1
  59. package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +8 -8
  60. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Avatar.jsx.mustache → Avatar.js.mustache} +0 -2
  61. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Operator.jsx.mustache → Operator.js.mustache} +1 -2
  62. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +9 -9
  63. package/src/tasks/delete/helper.js +0 -4
  64. package/src/tasks/delete/index.js +0 -4
  65. package/src/tasks/index.js +0 -3
  66. package/src/tasks/init/index.js +3 -3
  67. package/src/tasks/init/template/.eslintrc.json +5 -186
  68. package/src/tasks/init/template/README.md +59 -75
  69. package/src/tasks/init/template/package.json.mustache +6 -21
  70. package/src/tasks/init/template/tasks.config.json +2 -5
  71. package/src/tasks/list/index.js +0 -4
  72. package/src/tasks/{bundle → publish/bundle}/builder/webpack.config.js +2 -0
  73. package/src/tasks/{bundle → publish/bundle}/index.js +2 -2
  74. package/src/tasks/publish/index.js +1 -14
  75. package/src/util.js +6 -11
  76. package/src/auth.js +0 -563
  77. package/src/tasks/build/helper.js +0 -123
  78. package/src/tasks/build/index.js +0 -54
  79. package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +0 -21
  80. package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +0 -61
  81. package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +0 -41
  82. package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +0 -23
  83. package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +0 -23
  84. package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +0 -21
  85. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +0 -23
  86. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +0 -21
  87. package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +0 -21
  88. package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +0 -67
  89. package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +0 -13
  90. package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +0 -22
  91. package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +0 -21
  92. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +0 -20
  93. package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +0 -37
  94. package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +0 -22
  95. package/src/tasks/create/templates/Constellation/Field/TimeofDay/mock.stories.js.mustache +0 -20
  96. package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +0 -26
  97. package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +0 -118
  98. package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +0 -179
  99. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +0 -26
  100. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +0 -123
  101. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +0 -215
  102. package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +0 -93
  103. package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +0 -125
  104. package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +0 -100
  105. package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +0 -131
  106. package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +0 -101
  107. package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +0 -94
  108. package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +0 -78
  109. package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +0 -390
  110. package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +0 -30
  111. package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +0 -23
  112. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +0 -68
  113. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +0 -51
  114. package/src/tasks/delete-all/helper.js +0 -175
  115. package/src/tasks/delete-all/index.js +0 -49
  116. package/src/tasks/init/template/.eslintignore +0 -8
  117. package/src/tasks/linter/index.js +0 -46
  118. package/src/tasks/publish-all/helper.js +0 -139
  119. package/src/tasks/publish-all/index.js +0 -84
  120. /package/src/tasks/{bundle → publish/bundle}/builder/index.js +0 -0
  121. /package/src/tasks/{bundle → publish/bundle}/builder/modules.js +0 -0
  122. /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 { configProps, stateProps } from './mock.stories';
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
- // eslint-disable-next-line react-hooks/rules-of-hooks
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, theValue) => {
42
- setValue(theValue);
43
- },
44
- triggerFieldChange: () => { /* nothing */}
20
+ updateFieldValue: (propName, value) => {
21
+ setValue(value);
22
+ }
45
23
  };
46
24
  },
47
- getValidationApi: () => {
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 = <{{COMPONENT_CLASS_NAME}} value={value} trueLabel={trueLabel} falseLabel={falseLabel} />;
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
- function isIsoDate(str) {
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 'DateTime-Long': {
72
- objectvalues.variantVal = 'datetime';
73
- objectvalues.formatVal = 'long';
12
+ case "DateTime-Long": {
13
+ objectvalues.variantVal = "datetime";
14
+ objectvalues.formatVal = "long";
74
15
  break;
75
16
  }
76
- case 'DateTime-Short': {
77
- objectvalues.variantVal = 'date';
78
- objectvalues.formatVal = 'short';
17
+ case "DateTime-Short": {
18
+ objectvalues.variantVal = "date";
19
+ objectvalues.formatVal = "short";
79
20
  break;
80
21
  }
81
- case 'DateTime-Since': {
82
- objectvalues.variantVal = 'relative';
22
+ case "DateTime-Since": {
23
+ objectvalues.variantVal = "relative";
83
24
  break;
84
25
  }
85
- case 'Time-Only': {
86
- objectvalues.variantVal = 'time';
87
- objectvalues.formatVal = 'short';
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 = ['DateTime-Long', 'DateTime-Short', 'DateTime-Since', 'Time-Only'];
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('GMT') !== -1;
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('en-US', {
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 === 'string' ? parseInt(clockFormat, 10) : 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('Z'))}.000Z`;
183
+ return `${datetime.substring(0, datetime.indexOf("Z"))}.000Z`;
236
184
  }
237
- return `${datetime.substring(0, datetime.lastIndexOf(':'))}:00.000Z`;
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('T') + 1, datetime.indexOf('.'));
198
+ return datetime.substring(datetime.indexOf("T") + 1, datetime.indexOf("."));
251
199
  }
252
- return `${datetime.substring(datetime.indexOf('T') + 1, datetime.lastIndexOf(':'))}:00`;
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 'day':
303
- return 'DD';
304
- case 'month':
305
- return 'MM';
306
- case 'year':
307
- return 'YYYY';
308
- case 'hour':
309
- return 'hh';
310
- case 'minute':
311
- return 'mm';
312
- case 'second':
313
- return 'ss';
314
- case 'dayPeriod':
315
- return 'A';
316
- case 'literal':
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: 'numeric'
286
+ hour: "numeric"
335
287
  })
336
288
  .formatToParts()
337
- .find(({ type }) => type === 'dayPeriod');
338
- return !!(meridiem === null || meridiem === undefined ? undefined : meridiem.value);
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: 'numeric',
352
- minute: 'numeric',
353
- ...(withSeconds && { second: 'numeric' }),
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: 'numeric',
369
- month: 'numeric',
370
- day: 'numeric',
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 { withKnobs } from '@storybook/addon-knobs';
2
- import { configProps, stateProps } from './mock.stories';
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: () => {/* nothing */},
30
- triggerFieldChange: () => {/* nothing */}
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 stateProps;
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: configProps.value,
50
- validatemessage: configProps.validatemessage,
51
- label: configProps.label,
52
- hideLabel: configProps.hideLabel,
53
- helperText: configProps.helperText,
54
- nextYearRange: configProps.nextYearRange,
55
- previousYearRange: configProps.previousYearRange,
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, } from '@pega/cosmos-react-core';
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
 
@@ -47,6 +47,7 @@ function TimeFormatter(value, options) {
47
47
  }
48
48
 
49
49
  export const DateTimeShortFormatter = (value, options) => {
50
+ //export function DateTimeShortFormatter(value, options) {
50
51
  return DateFormatter(value, {
51
52
  ...options,
52
53
  type: "customFormat",
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-undef */
2
1
  import dayjs from "dayjs";
3
2
 
4
3
  const relativeTime = require("dayjs/plugin/relativeTime");
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-undef */
2
1
  import dayjs from 'dayjs';
3
2
 
4
3
  const relativeTime = require('dayjs/plugin/relativeTime');
@@ -1,5 +1,6 @@
1
- import { withKnobs } from '@storybook/addon-knobs';
2
- import { configProps, stateProps } from './mock.stories';
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: () => {/* nothing */},
30
- triggerFieldChange: () => {/* nothing */}
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 stateProps;
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: configProps.value,
50
- validatemessage: configProps.validatemessage,
51
- label: configProps.label,
52
- hideLabel: configProps.hideLabel,
53
- helperText: configProps.helperText,
54
- withSeconds: configProps.withSeconds,
55
- nextYearRange: configProps.nextYearRange,
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