@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
@@ -0,0 +1,43 @@
1
+ import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
2
+
3
+ export const formatExists = (formatterVal) => {
4
+ const formatterValues = [
5
+ "TextInput",
6
+ "WorkStatus",
7
+ "RichText",
8
+ "Email",
9
+ "Phone",
10
+ "URL",
11
+ "Operator"
12
+ ];
13
+ let isformatter = false;
14
+ if (formatterValues.includes(formatterVal)) {
15
+ isformatter = true;
16
+ }
17
+ return isformatter;
18
+ };
19
+
20
+
21
+ export const textFormatter = (formatter,value) => {
22
+ let displayComponent = null;
23
+ switch(formatter){
24
+ case "TextInput" : {
25
+ displayComponent = value;
26
+ break;
27
+ }
28
+ case "Email" : {
29
+ displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
30
+ break;
31
+ }
32
+ case "Phone" : {
33
+ displayComponent = (<PhoneDisplay value={value} variant="link" />);
34
+ break;
35
+ }
36
+ case "URL" : {
37
+ displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
38
+ break;
39
+ }
40
+ // no default
41
+ }
42
+ return displayComponent;
43
+ };
@@ -1,7 +1,5 @@
1
1
  import { useState } from 'react';
2
- import { withKnobs } from '@storybook/addon-knobs';
3
-
4
- import { stateProps, configProps } from './mock.stories';
2
+ import { withKnobs, text, boolean } from '@storybook/addon-knobs';
5
3
 
6
4
  import {{COMPONENT_CLASS_NAME}} from './index.jsx';
7
5
 
@@ -12,33 +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
- placeholder: configProps.placeholder,
21
- label: configProps.label,
22
- testId: configProps.testId,
23
- hasSuggestions: configProps.hasSuggestions,
24
-
25
16
  getPConnect: () => {
26
17
  return {
27
- getStateProps: () => {
28
- return stateProps;
29
- },
30
18
  getActionsApi: () => {
31
19
  return {
32
- updateFieldValue: () => {},
33
- triggerFieldChange: () => {}
20
+ updateFieldValue: (propName, value) => {
21
+ setValue(value);
22
+ }
34
23
  };
35
24
  },
36
- ignoreSuggestion: () => {},
37
- acceptSuggestion: () => {},
38
- setInheritedProps: () => {},
39
- resolveConfigProps: () => {}
25
+ getStateProps: () => {
26
+ return { value: '.name' };
27
+ }
40
28
  };
41
- }
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')
42
37
  };
43
38
 
44
39
  return (
@@ -1,9 +1,8 @@
1
+ import { useState } from 'react';
1
2
  import { withKnobs, text, boolean } from '@storybook/addon-knobs';
2
3
 
3
4
  import {{COMPONENT_CLASS_NAME}} from './index.jsx';
4
5
 
5
- import { stateProps, configProps, fieldMetadata } from './mock.stories';
6
-
7
6
  export default {
8
7
  title: '{{COMPONENT_CLASS_NAME}}',
9
8
  decorators: [withKnobs],
@@ -11,33 +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
15
  const props = {
16
- value: configProps.value,
17
- label: configProps.label,
18
- placeholder: configProps.placeholder,
19
- helperText: configProps.helperText,
20
- testId: configProps.testId,
21
- hasSuggestions: configProps.hasSuggestions,
22
- fieldMetadata: fieldMetadata,
23
-
24
16
  getPConnect: () => {
25
17
  return {
26
- getStateProps: () => {
27
- return stateProps;
28
- },
29
18
  getActionsApi: () => {
30
19
  return {
31
- updateFieldValue: () => {},
32
- triggerFieldChange: () => {}
20
+ updateFieldValue: (propName, value) => {
21
+ setValue(value);
22
+ }
33
23
  };
34
24
  },
35
- ignoreSuggestion: () => {},
36
- acceptSuggestion: () => {},
37
- setInheritedProps: () => {},
38
- resolveConfigProps: () => {}
25
+ getStateProps: () => {
26
+ return { value: '.name' };
27
+ }
39
28
  };
40
- }
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')
41
37
  };
42
38
 
43
39
  return (
@@ -1,56 +1,14 @@
1
1
  import { useState, useEffect, useRef } from 'react';
2
- import { Input, EmailDisplay, FieldValueList, Text, URLDisplay, PhoneDisplay } from '@pega/cosmos-react-core';
2
+ import { Input, EmailDisplay, FieldValueList, Text } from '@pega/cosmos-react-core';
3
3
  import PropTypes from 'prop-types';
4
4
 
5
5
  // includes in bundle
6
+ import {formatExists,textFormatter} from "./text-email";
6
7
  import { suggestionsHandler } from './suggestions-handler';
7
8
  import handleEvent from "./event-utils";
8
9
 
9
10
  import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
10
11
 
11
- export const formatExists = (formatterVal) => {
12
- const formatterValues = [
13
- "TextInput",
14
- "WorkStatus",
15
- "RichText",
16
- "Email",
17
- "Phone",
18
- "URL",
19
- "Operator"
20
- ];
21
- let isformatter = false;
22
- if (formatterValues.includes(formatterVal)) {
23
- isformatter = true;
24
- }
25
- return isformatter;
26
- };
27
-
28
-
29
- export const textFormatter = (formatter,value) => {
30
- let displayComponent = null;
31
- switch(formatter){
32
- case "TextInput" : {
33
- displayComponent = value;
34
- break;
35
- }
36
- case "Email" : {
37
- displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
38
- break;
39
- }
40
- case "Phone" : {
41
- displayComponent = (<PhoneDisplay value={value} variant="link" />);
42
- break;
43
- }
44
- case "URL" : {
45
- displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
46
- break;
47
- }
48
- // no default
49
- }
50
- return displayComponent;
51
- };
52
-
53
-
54
12
 
55
13
  // Duplicated runtime code from Constellation Design System Component
56
14
 
@@ -0,0 +1,43 @@
1
+ import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
2
+
3
+ export const formatExists = (formatterVal) => {
4
+ const formatterValues = [
5
+ "TextInput",
6
+ "WorkStatus",
7
+ "RichText",
8
+ "Email",
9
+ "Phone",
10
+ "URL",
11
+ "Operator"
12
+ ];
13
+ let isformatter = false;
14
+ if (formatterValues.includes(formatterVal)) {
15
+ isformatter = true;
16
+ }
17
+ return isformatter;
18
+ };
19
+
20
+
21
+ export const textFormatter = (formatter,value) => {
22
+ let displayComponent = null;
23
+ switch(formatter){
24
+ case "TextInput" : {
25
+ displayComponent = value;
26
+ break;
27
+ }
28
+ case "Email" : {
29
+ displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
30
+ break;
31
+ }
32
+ case "Phone" : {
33
+ displayComponent = (<PhoneDisplay value={value} variant="link" />);
34
+ break;
35
+ }
36
+ case "URL" : {
37
+ displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
38
+ break;
39
+ }
40
+ // no default
41
+ }
42
+ return displayComponent;
43
+ };
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react/prop-types */
1
2
  import { Status } from "@pega/cosmos-react-core";
2
3
 
3
4
  export default function StatusWorkRenderer({ value }) {
@@ -1,9 +1,8 @@
1
- import { withKnobs } from '@storybook/addon-knobs';
1
+ import { useState } from 'react';
2
+ import { withKnobs, text, boolean } from '@storybook/addon-knobs';
2
3
 
3
4
  import {{COMPONENT_CLASS_NAME}} from './index.jsx';
4
5
 
5
- import { stateProps, fieldMetadata, configProps } from './mock.stories';
6
-
7
6
  export default {
8
7
  title: '{{COMPONENT_CLASS_NAME}}',
9
8
  decorators: [withKnobs],
@@ -11,33 +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
15
  const props = {
16
- value: configProps.value,
17
- placeholder: configProps.placeholder,
18
- label: configProps.label,
19
- helperText: configProps.helperText,
20
- testId: configProps.testId,
21
- hasSuggestions: configProps.hasSuggestions,
22
- fieldMetadata: fieldMetadata,
23
-
24
16
  getPConnect: () => {
25
17
  return {
26
- getStateProps: () => {
27
- return stateProps;
28
- },
29
18
  getActionsApi: () => {
30
19
  return {
31
- updateFieldValue: () => {},
32
- triggerFieldChange: () => {}
20
+ updateFieldValue: (propName, value) => {
21
+ setValue(value);
22
+ }
33
23
  };
34
24
  },
35
- ignoreSuggestion: () => {},
36
- acceptSuggestion: () => {},
37
- setInheritedProps: () => {},
38
- resolveConfigProps: () => {}
25
+ getStateProps: () => {
26
+ return { value: '.name' };
27
+ }
39
28
  };
40
- }
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')
41
37
  };
42
38
 
43
39
  return (
@@ -1,59 +1,16 @@
1
1
  import { useEffect, useState, useRef } from 'react';
2
- import { Input, FieldValueList, Text, EmailDisplay, PhoneDisplay, URLDisplay } from '@pega/cosmos-react-core';
2
+ import { Input, FieldValueList, Text } from '@pega/cosmos-react-core';
3
3
  import PropTypes from 'prop-types';
4
4
 
5
5
  // include in bundle
6
6
  import handleEvent from "./event-utils";
7
- import StatusWorkRenderer from "./StatusWork.jsx";
7
+ import StatusWorkRenderer from "./StatusWork";
8
+ import {formatExists,textFormatter} from "./text-input";
8
9
  import { suggestionsHandler } from './suggestions-handler';
9
10
 
10
11
  import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
11
12
 
12
13
 
13
- export const formatExists = (formatterVal) => {
14
- const formatterValues = [
15
- "TextInput",
16
- "WorkStatus",
17
- "RichText",
18
- "Email",
19
- "Phone",
20
- "URL",
21
- "Operator"
22
- ];
23
- let isformatter = false;
24
- if (formatterValues.includes(formatterVal)) {
25
- isformatter = true;
26
- }
27
- return isformatter;
28
- };
29
-
30
-
31
- export const textFormatter = (formatter,value) => {
32
- let displayComponent = null;
33
- switch(formatter){
34
- case "TextInput" : {
35
- displayComponent = value;
36
- break;
37
- }
38
- case "Email" : {
39
- displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
40
- break;
41
- }
42
- case "Phone" : {
43
- displayComponent = (<PhoneDisplay value={value} variant="link" />);
44
- break;
45
- }
46
- case "URL" : {
47
- displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
48
- break;
49
- }
50
- // no default
51
- }
52
- return displayComponent;
53
- };
54
-
55
-
56
-
57
14
  // Duplicated runtime code from Constellation Design System Component
58
15
 
59
16
  // props passed in combination of props from property panel (config.json) and run time props from Constellation
@@ -0,0 +1,43 @@
1
+ import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
2
+
3
+ export const formatExists = (formatterVal) => {
4
+ const formatterValues = [
5
+ "TextInput",
6
+ "WorkStatus",
7
+ "RichText",
8
+ "Email",
9
+ "Phone",
10
+ "URL",
11
+ "Operator"
12
+ ];
13
+ let isformatter = false;
14
+ if (formatterValues.includes(formatterVal)) {
15
+ isformatter = true;
16
+ }
17
+ return isformatter;
18
+ };
19
+
20
+
21
+ export const textFormatter = (formatter,value) => {
22
+ let displayComponent = null;
23
+ switch(formatter){
24
+ case "TextInput" : {
25
+ displayComponent = value;
26
+ break;
27
+ }
28
+ case "Email" : {
29
+ displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
30
+ break;
31
+ }
32
+ case "Phone" : {
33
+ displayComponent = (<PhoneDisplay value={value} variant="link" />);
34
+ break;
35
+ }
36
+ case "URL" : {
37
+ displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
38
+ break;
39
+ }
40
+ // no default
41
+ }
42
+ return displayComponent;
43
+ };
@@ -1,9 +1,8 @@
1
- import { withKnobs } from '@storybook/addon-knobs';
1
+ import { useState } from 'react';
2
+ import { withKnobs, text, boolean } from '@storybook/addon-knobs';
2
3
 
3
4
  import {{COMPONENT_CLASS_NAME}} from './index.jsx';
4
5
 
5
- import { stateProps, configProps } from './mock.stories';
6
-
7
6
  export default {
8
7
  title: '{{COMPONENT_CLASS_NAME}}',
9
8
  decorators: [withKnobs],
@@ -11,33 +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
15
  const props = {
16
- value: configProps.value,
17
- placeholder: configProps.placeholder,
18
- label: configProps.label,
19
- helperText: configProps.helperText,
20
- testId: configProps.testId,
21
- hasSuggestions: configProps.hasSuggestions,
22
- fieldMetadata: fieldMetadata,
23
-
24
16
  getPConnect: () => {
25
17
  return {
26
- getStateProps: () => {
27
- return stateProps;
28
- },
29
18
  getActionsApi: () => {
30
19
  return {
31
- updateFieldValue: () => {},
32
- triggerFieldChange: () => {}
20
+ updateFieldValue: (propName, value) => {
21
+ setValue(value);
22
+ }
33
23
  };
34
24
  },
35
- ignoreSuggestion: () => {},
36
- acceptSuggestion: () => {},
37
- setInheritedProps: () => {},
38
- resolveConfigProps: () => {}
25
+ getStateProps: () => {
26
+ return { value: '.name' };
27
+ }
39
28
  };
40
- }
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')
41
37
  };
42
38
 
43
39
  return (
@@ -1,56 +1,14 @@
1
1
  import { useState, useEffect, useRef } from 'react';
2
- import { TextArea as CosmosTextArea, FieldValueList, ParagraphDisplay, Text, EmailDisplay, PhoneDisplay, URLDisplay } from '@pega/cosmos-react-core';
2
+ import { TextArea as CosmosTextArea, FieldValueList, ParagraphDisplay, Text } from '@pega/cosmos-react-core';
3
3
  import PropTypes from 'prop-types';
4
4
 
5
5
  // includes in bundle
6
+ import {formatExists,textFormatter} from "./text-paragraph";
6
7
  import { suggestionsHandler } from './suggestions-handler';
7
8
  import handleEvent from "./event-utils";
8
9
 
9
10
  import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
10
11
 
11
- export const formatExists = (formatterVal) => {
12
- const formatterValues = [
13
- "TextInput",
14
- "WorkStatus",
15
- "RichText",
16
- "Email",
17
- "Phone",
18
- "URL",
19
- "Operator"
20
- ];
21
- let isformatter = false;
22
- if (formatterValues.includes(formatterVal)) {
23
- isformatter = true;
24
- }
25
- return isformatter;
26
- };
27
-
28
-
29
- export const textFormatter = (formatter,value) => {
30
- let displayComponent = null;
31
- switch(formatter){
32
- case "TextInput" : {
33
- displayComponent = value;
34
- break;
35
- }
36
- case "Email" : {
37
- displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
38
- break;
39
- }
40
- case "Phone" : {
41
- displayComponent = (<PhoneDisplay value={value} variant="link" />);
42
- break;
43
- }
44
- case "URL" : {
45
- displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
46
- break;
47
- }
48
- // no default
49
- }
50
- return displayComponent;
51
- };
52
-
53
-
54
12
 
55
13
  // Duplicated runtime code from Constellation Design System Component
56
14
 
@@ -0,0 +1,43 @@
1
+ import {EmailDisplay, PhoneDisplay, URLDisplay } from "@pega/cosmos-react-core";
2
+
3
+ export const formatExists = (formatterVal) => {
4
+ const formatterValues = [
5
+ "TextInput",
6
+ "WorkStatus",
7
+ "RichText",
8
+ "Email",
9
+ "Phone",
10
+ "URL",
11
+ "Operator"
12
+ ];
13
+ let isformatter = false;
14
+ if (formatterValues.includes(formatterVal)) {
15
+ isformatter = true;
16
+ }
17
+ return isformatter;
18
+ };
19
+
20
+
21
+ export const textFormatter = (formatter,value) => {
22
+ let displayComponent = null;
23
+ switch(formatter){
24
+ case "TextInput" : {
25
+ displayComponent = value;
26
+ break;
27
+ }
28
+ case "Email" : {
29
+ displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
30
+ break;
31
+ }
32
+ case "Phone" : {
33
+ displayComponent = (<PhoneDisplay value={value} variant="link" />);
34
+ break;
35
+ }
36
+ case "URL" : {
37
+ displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
38
+ break;
39
+ }
40
+ // no default
41
+ }
42
+ return displayComponent;
43
+ };
@@ -1,7 +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
4
  import {{COMPONENT_CLASS_NAME}} from './index.jsx';
4
- import { stateProps, configProps } from './mock.stories';
5
5
 
6
6
  export default {
7
7
  title: '{{COMPONENT_CLASS_NAME}}',
@@ -10,32 +10,30 @@ export default {
10
10
  };
11
11
 
12
12
  export const base{{COMPONENT_CLASS_NAME}} = () => {
13
+ const [value, setValue] = useState('test value');
13
14
 
14
15
  const props = {
15
- value: configProps.value,
16
- placeholder: configProps.placeholder,
17
- label: configProps.label,
18
- testId: configProps.testId,
19
- hasSuggestions: configProps.hasSuggestions,
20
- datasource: configProps.datasource,
21
-
22
16
  getPConnect: () => {
23
17
  return {
24
- getStateProps: () => {
25
- return stateProps;
26
- },
27
18
  getActionsApi: () => {
28
19
  return {
29
- updateFieldValue: () => {},
30
- triggerFieldChange: () => {}
20
+ updateFieldValue: (propName, value) => {
21
+ setValue(value);
22
+ }
31
23
  };
32
24
  },
33
- ignoreSuggestion: () => {},
34
- acceptSuggestion: () => {},
35
- setInheritedProps: () => {},
36
- resolveConfigProps: () => {}
25
+ getStateProps: () => {
26
+ return { value: '.name' };
27
+ }
37
28
  };
38
- }
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')
39
37
  };
40
38
 
41
39
  return (