@pega/custom-dx-components 2.0.14 → 2.0.16

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 (118) hide show
  1. package/README.md +3 -3
  2. package/package.json +2 -2
  3. package/src/cli.js +0 -18
  4. package/src/tasks/authenticate/index.js +1 -3
  5. package/src/tasks/create/index.js +3 -6
  6. package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +1 -1
  7. package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +18 -29
  8. package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +2 -1
  9. package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +67 -179
  10. package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +16 -39
  11. package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +1 -3
  12. package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +1 -0
  13. package/src/tasks/create/templates/Constellation/Field/DateTime/{date-utils.js.mustache → date-utils.js} +0 -1
  14. package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +0 -1
  15. package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +15 -39
  16. package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +0 -2
  17. package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +17 -22
  18. package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +1 -2
  19. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +17 -25
  20. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +4 -3
  21. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +17 -22
  22. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +2 -8
  23. package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +17 -22
  24. package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +1 -2
  25. package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +14 -42
  26. package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +1 -44
  27. package/src/tasks/create/templates/Constellation/Field/Picklist/picklist.js.mustache +43 -0
  28. package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +16 -21
  29. package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +16 -20
  30. package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +2 -44
  31. package/src/tasks/create/templates/Constellation/Field/Text-Email/text-email.js.mustache +43 -0
  32. package/src/tasks/create/templates/Constellation/{Template/DETAILS/StatusWork.jsx.mustache → Field/Text-Input/StatusWork.js} +1 -0
  33. package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +17 -21
  34. package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +3 -46
  35. package/src/tasks/create/templates/Constellation/Field/Text-Input/text-input.js.mustache +43 -0
  36. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +17 -21
  37. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +2 -44
  38. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache +43 -0
  39. package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +17 -19
  40. package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +2 -46
  41. package/src/tasks/create/templates/Constellation/Field/Text-Phone/text-phone.js.mustache +43 -0
  42. package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +17 -19
  43. package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +3 -174
  44. package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.js.mustache +172 -0
  45. package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +16 -24
  46. package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +0 -1
  47. package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +29 -14
  48. package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +77 -3
  49. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +29 -14
  50. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +74 -3
  51. package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +10 -6
  52. package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +8 -10
  53. package/src/tasks/create/templates/Constellation/Template/PAGE/{GetNextWork.jsx.mustache → GetNextWork.js.mustache} +0 -6
  54. package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +7 -9
  55. package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +1 -4
  56. package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +0 -1
  57. package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +8 -8
  58. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Avatar.jsx.mustache → Avatar.js.mustache} +0 -2
  59. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Operator.jsx.mustache → Operator.js.mustache} +1 -2
  60. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +9 -9
  61. package/src/tasks/delete/helper.js +0 -4
  62. package/src/tasks/delete/index.js +0 -4
  63. package/src/tasks/index.js +0 -3
  64. package/src/tasks/init/index.js +1 -1
  65. package/src/tasks/init/template/.eslintrc.json +5 -186
  66. package/src/tasks/init/template/package.json.mustache +4 -19
  67. package/src/tasks/init/template/tasks.config.json +0 -1
  68. package/src/tasks/list/index.js +0 -4
  69. package/src/tasks/{bundle → publish/bundle}/builder/index.js +0 -0
  70. package/src/tasks/{bundle → publish/bundle}/builder/modules.js +0 -0
  71. package/src/tasks/{bundle → publish/bundle}/builder/paths.js +0 -0
  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 +0 -10
  76. package/src/tasks/build/helper.js +0 -123
  77. package/src/tasks/build/index.js +0 -54
  78. package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +0 -21
  79. package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +0 -61
  80. package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +0 -41
  81. package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +0 -23
  82. package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +0 -23
  83. package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +0 -21
  84. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +0 -23
  85. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +0 -21
  86. package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +0 -21
  87. package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +0 -67
  88. package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +0 -13
  89. package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +0 -22
  90. package/src/tasks/create/templates/Constellation/Field/Text-Input/StatusWork.jsx +0 -26
  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/demo.stories.jsx.mustache +0 -110
  97. package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +0 -179
  98. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +0 -26
  99. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +0 -118
  100. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +0 -215
  101. package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +0 -89
  102. package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +0 -125
  103. package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +0 -92
  104. package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +0 -125
  105. package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +0 -102
  106. package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +0 -94
  107. package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +0 -78
  108. package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +0 -389
  109. package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +0 -30
  110. package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +0 -22
  111. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +0 -68
  112. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +0 -51
  113. package/src/tasks/delete-all/helper.js +0 -175
  114. package/src/tasks/delete-all/index.js +0 -49
  115. package/src/tasks/init/template/.eslintignore +0 -8
  116. package/src/tasks/linter/index.js +0 -46
  117. package/src/tasks/publish-all/helper.js +0 -139
  118. package/src/tasks/publish-all/index.js +0 -84
package/README.md CHANGED
@@ -8,13 +8,13 @@ This project provides you with an environment to extend Constellation by giving
8
8
 
9
9
  Ensure you have access to the following in your system:
10
10
 
11
- - Pega Infinity Server version 8.7 or later
11
+ - Pega Infinity Server version 8.8 or later
12
12
 
13
13
  - Git version 2.30 or later
14
14
 
15
- - System node version 16
15
+ - System node version 18
16
16
 
17
- - System npm version 7
17
+ - System npm version 8
18
18
 
19
19
  ## Initialize a project
20
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/custom-dx-components",
3
- "version": "2.0.14",
3
+ "version": "2.0.16",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -26,7 +26,6 @@
26
26
  "css-loader": "6.7.1",
27
27
  "css-minimizer-webpack-plugin": "^4.1.0",
28
28
  "execa": "^6.1.0",
29
- "eslint": "^8.4.1",
30
29
  "file-loader": "6.2.0",
31
30
  "fs-extra": "^10.1.0",
32
31
  "gitignore": "^0.7.0",
@@ -62,6 +61,7 @@
62
61
  "devDependencies": {
63
62
  "@pega/configs": "^0.3.3",
64
63
  "cspell": "^6.9.0",
64
+ "eslint": "^8.23.1",
65
65
  "prettier": "2.7.1"
66
66
  }
67
67
  }
package/src/cli.js CHANGED
@@ -3,14 +3,11 @@ import chalk from 'chalk';
3
3
 
4
4
  import {
5
5
  authenticate,
6
- buildComponent,
7
6
  createComponent,
8
7
  deleteComponent,
9
- deleteAllComponents,
10
8
  initProject,
11
9
  listComponents,
12
10
  publishComponent,
13
- publishAllComponents,
14
11
  updateComponent,
15
12
  validate,
16
13
  upgrade
@@ -19,14 +16,11 @@ import {
19
16
  const TASKS = {
20
17
  INIT: 'init',
21
18
  CREATE: 'create',
22
- BUILD: 'buildComponent',
23
19
  PUBLISH: 'publish',
24
- PUBLISH_All: 'publishAll',
25
20
  LIST: 'list',
26
21
  VALIDATE_SCHEMA: 'validateSchema',
27
22
  UPDATE: 'update',
28
23
  DELETE: 'delete',
29
- DELETE_ALL: "deleteAll",
30
24
  AUTHENTICATE: 'authenticate',
31
25
  UPGRADE: 'upgrade'
32
26
  };
@@ -66,14 +60,6 @@ export default async (args = []) => {
66
60
  publishComponent(options);
67
61
  break;
68
62
  }
69
- case TASKS.PUBLISH_All: {
70
- publishAllComponents(options);
71
- break;
72
- }
73
- case TASKS.BUILD: {
74
- buildComponent(options);
75
- break;
76
- }
77
63
  case TASKS.LIST: {
78
64
  listComponents(options);
79
65
  break;
@@ -90,10 +76,6 @@ export default async (args = []) => {
90
76
  deleteComponent(options);
91
77
  break;
92
78
  }
93
- case TASKS.DELETE_ALL: {
94
- deleteAllComponents(options);
95
- break;
96
- }
97
79
  case TASKS.AUTHENTICATE: {
98
80
  authenticate(options);
99
81
  break;
@@ -6,7 +6,7 @@ import chalk from 'chalk';
6
6
  import inquirer from 'inquirer';
7
7
  import fetch from 'node-fetch';
8
8
 
9
- import { checkPathAccess, getTokenUrl, showVersion } from '../../util.js';
9
+ import { checkPathAccess, getTokenUrl } from '../../util.js';
10
10
  import { TOKEN_PATH } from '../../constants.js';
11
11
 
12
12
  import { getAuthQuestions } from './helper.js';
@@ -57,8 +57,6 @@ const generateAccessToken = async config => {
57
57
  };
58
58
 
59
59
  export default async options => {
60
- showVersion();
61
-
62
60
  await checkPathAccess(pegaConfigJsonPath);
63
61
 
64
62
  let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
@@ -14,8 +14,7 @@ import {
14
14
  getComponents,
15
15
  getComponentDefaults,
16
16
  sanitize,
17
- validateSemver,
18
- showVersion
17
+ validateSemver
19
18
  } from '../../util.js';
20
19
  import { COMPONENT_SCHEMA } from '../../constants.js';
21
20
 
@@ -88,7 +87,7 @@ const compileMustacheTemplates = async (
88
87
  ALLOWEDAPPS: JSON.stringify(allowedApplications),
89
88
  TYPE: type,
90
89
  SUB_TYPE: JSON.stringify(mustacheSubType),
91
- DESCRIPTION: description || componentLabel,
90
+ DESCRIPTION: description,
92
91
  IS_TEMPLATE: isTemplate,
93
92
  IS_PICKLIST: isPicklist,
94
93
  IS_BOOLEAN: isBool,
@@ -173,8 +172,6 @@ const validateCompile = async (
173
172
  };
174
173
 
175
174
  export default async options => {
176
- showVersion();
177
-
178
175
  if (options.params[10]) {
179
176
  const componentName = options.params[3];
180
177
  const componentLabel = options.params[4];
@@ -229,7 +226,6 @@ export default async options => {
229
226
  {
230
227
  name: 'version',
231
228
  message: 'Enter component version',
232
- default: componentDefaults.version,
233
229
  validate: value => {
234
230
  if (validateSemver(value)) {
235
231
  return true;
@@ -316,6 +312,7 @@ export default async options => {
316
312
  }
317
313
  ];
318
314
 
315
+ console.log(chalk.green("DX Component Builder v2.0.16"));
319
316
  await inquirer.prompt(questions).then(async answers => {
320
317
  const {
321
318
  componentName,
@@ -7,7 +7,7 @@ export default {
7
7
 
8
8
 
9
9
 
10
- export function format(value, type) {
10
+ export function format(value, type, options) {
11
11
  let formattedValue;
12
12
 
13
13
  switch (type?.toLowerCase()) {
@@ -1,8 +1,7 @@
1
- import { withKnobs } from '@storybook/addon-knobs';
1
+ import { useState } from 'react';
2
+ import { withKnobs, text, boolean } from '@storybook/addon-knobs';
2
3
 
3
- import { configProps, stateProps } from './mock.stories';
4
-
5
- import {{COMPONENT_CLASS_NAME}} from './index';
4
+ import {{COMPONENT_CLASS_NAME}} from './index.jsx';
6
5
 
7
6
  export default {
8
7
  title: '{{COMPONENT_CLASS_NAME}}',
@@ -11,40 +10,30 @@ export default {
11
10
  };
12
11
 
13
12
  export const base{{COMPONENT_CLASS_NAME}} = () => {
13
+ const [value, setValue] = useState('test value');
14
+
14
15
  const props = {
15
- value: configProps.value,
16
- label: configProps.label,
17
- helperText: configProps.helperText,
18
- caption: configProps.caption,
19
- validatemessage: configProps.validatemessage,
20
- hideLabel: configProps.hideLabel,
21
- testId: configProps.testId,
22
- additionalProps: configProps.additionalProps,
23
- displayMode: configProps.displayMode,
24
- variant: configProps.variant,
25
- trueLabel: configProps.trueLabel,
26
- falseLabel: configProps.falseLabel,
27
- disabled: configProps.disabled,
28
- readOnly: configProps.readOnly,
29
- required: configProps.required,
30
16
  getPConnect: () => {
31
17
  return {
32
- getStateProps: () => {
33
- return stateProps;
34
- },
35
18
  getActionsApi: () => {
36
19
  return {
37
- updateFieldValue: () => { /* nothing */},
38
- triggerFieldChange: () => { /* nothing */}
20
+ updateFieldValue: (propName, value) => {
21
+ setValue(value);
22
+ }
39
23
  };
40
24
  },
41
- getValidationApi: () => {
42
- return {
43
- validate: () => { /* nothing */}
44
- };
25
+ getStateProps: () => {
26
+ return { value: '.name' };
45
27
  }
46
28
  };
47
- }
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')
48
37
  };
49
38
 
50
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
- }