@pega/custom-dx-components 2.0.15 → 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 (117) hide show
  1. package/package.json +2 -2
  2. package/src/cli.js +0 -18
  3. package/src/tasks/authenticate/index.js +1 -3
  4. package/src/tasks/create/index.js +3 -6
  5. package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +1 -1
  6. package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +18 -29
  7. package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +2 -1
  8. package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +67 -179
  9. package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +16 -40
  10. package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +1 -3
  11. package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +1 -0
  12. package/src/tasks/create/templates/Constellation/Field/DateTime/{date-utils.js.mustache → date-utils.js} +0 -1
  13. package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +0 -1
  14. package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +15 -40
  15. package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +0 -2
  16. package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +17 -22
  17. package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +1 -2
  18. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +17 -25
  19. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +4 -3
  20. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +17 -22
  21. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +2 -8
  22. package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +17 -22
  23. package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +1 -2
  24. package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +14 -42
  25. package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +1 -44
  26. package/src/tasks/create/templates/Constellation/Field/Picklist/picklist.js.mustache +43 -0
  27. package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +16 -21
  28. package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +16 -20
  29. package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +2 -44
  30. package/src/tasks/create/templates/Constellation/Field/Text-Email/text-email.js.mustache +43 -0
  31. package/src/tasks/create/templates/Constellation/{Template/DETAILS/StatusWork.jsx.mustache → Field/Text-Input/StatusWork.js} +1 -0
  32. package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +17 -21
  33. package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +3 -46
  34. package/src/tasks/create/templates/Constellation/Field/Text-Input/text-input.js.mustache +43 -0
  35. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +17 -21
  36. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +2 -44
  37. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache +43 -0
  38. package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +17 -19
  39. package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +2 -46
  40. package/src/tasks/create/templates/Constellation/Field/Text-Phone/text-phone.js.mustache +43 -0
  41. package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +17 -19
  42. package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +3 -174
  43. package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.js.mustache +172 -0
  44. package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +16 -24
  45. package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +0 -1
  46. package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +29 -14
  47. package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +77 -3
  48. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +29 -14
  49. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +74 -3
  50. package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +10 -6
  51. package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +8 -10
  52. package/src/tasks/create/templates/Constellation/Template/PAGE/{GetNextWork.jsx.mustache → GetNextWork.js.mustache} +0 -6
  53. package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +7 -9
  54. package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +1 -4
  55. package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +0 -1
  56. package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +8 -8
  57. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Avatar.jsx.mustache → Avatar.js.mustache} +0 -2
  58. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Operator.jsx.mustache → Operator.js.mustache} +1 -2
  59. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +9 -9
  60. package/src/tasks/delete/helper.js +0 -4
  61. package/src/tasks/delete/index.js +0 -4
  62. package/src/tasks/index.js +0 -3
  63. package/src/tasks/init/index.js +1 -1
  64. package/src/tasks/init/template/.eslintrc.json +5 -186
  65. package/src/tasks/init/template/package.json.mustache +4 -19
  66. package/src/tasks/init/template/tasks.config.json +0 -1
  67. package/src/tasks/list/index.js +0 -4
  68. package/src/tasks/{bundle → publish/bundle}/builder/index.js +0 -0
  69. package/src/tasks/{bundle → publish/bundle}/builder/modules.js +0 -0
  70. package/src/tasks/{bundle → publish/bundle}/builder/paths.js +0 -0
  71. package/src/tasks/{bundle → publish/bundle}/builder/webpack.config.js +2 -0
  72. package/src/tasks/{bundle → publish/bundle}/index.js +2 -2
  73. package/src/tasks/publish/index.js +1 -14
  74. package/src/util.js +0 -10
  75. package/src/tasks/build/helper.js +0 -123
  76. package/src/tasks/build/index.js +0 -54
  77. package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +0 -21
  78. package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +0 -61
  79. package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +0 -41
  80. package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +0 -23
  81. package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +0 -23
  82. package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +0 -21
  83. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +0 -23
  84. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +0 -21
  85. package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +0 -21
  86. package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +0 -67
  87. package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +0 -13
  88. package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +0 -22
  89. package/src/tasks/create/templates/Constellation/Field/Text-Input/StatusWork.jsx +0 -26
  90. package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +0 -21
  91. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +0 -20
  92. package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +0 -37
  93. package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +0 -22
  94. package/src/tasks/create/templates/Constellation/Field/TimeofDay/mock.stories.js.mustache +0 -20
  95. package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +0 -110
  96. package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +0 -179
  97. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +0 -26
  98. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +0 -118
  99. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +0 -215
  100. package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +0 -89
  101. package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +0 -125
  102. package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +0 -100
  103. package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +0 -131
  104. package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +0 -102
  105. package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +0 -94
  106. package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +0 -78
  107. package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +0 -389
  108. package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +0 -30
  109. package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +0 -22
  110. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +0 -68
  111. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +0 -51
  112. package/src/tasks/delete-all/helper.js +0 -175
  113. package/src/tasks/delete-all/index.js +0 -49
  114. package/src/tasks/init/template/.eslintignore +0 -8
  115. package/src/tasks/linter/index.js +0 -46
  116. package/src/tasks/publish-all/helper.js +0 -139
  117. package/src/tasks/publish-all/index.js +0 -84
@@ -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, 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
- 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 (
@@ -4,60 +4,16 @@ import {
4
4
  getPhoneNumberParts,
5
5
  PhoneDisplay,
6
6
  FieldValueList,
7
- Text,
8
- EmailDisplay, URLDisplay
7
+ Text
9
8
  } from '@pega/cosmos-react-core';
10
9
  import PropTypes from 'prop-types';
11
10
 
12
11
  // includes in bundle
12
+ import {formatExists,textFormatter} from "./text-phone";
13
13
  import handleEvent from "./event-utils";
14
14
  import { suggestionsHandler } from './suggestions-handler';
15
15
 
16
16
  import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
17
- import { } from "@pega/cosmos-react-core";
18
-
19
- export const formatExists = (formatterVal) => {
20
- const formatterValues = [
21
- "TextInput",
22
- "WorkStatus",
23
- "RichText",
24
- "Email",
25
- "Phone",
26
- "URL",
27
- "Operator"
28
- ];
29
- let isformatter = false;
30
- if (formatterValues.includes(formatterVal)) {
31
- isformatter = true;
32
- }
33
- return isformatter;
34
- };
35
-
36
-
37
- export const textFormatter = (formatter,value) => {
38
- let displayComponent = null;
39
- switch(formatter){
40
- case "TextInput" : {
41
- displayComponent = value;
42
- break;
43
- }
44
- case "Email" : {
45
- displayComponent = (<EmailDisplay value={value} displayText={value} variant="link" />);
46
- break;
47
- }
48
- case "Phone" : {
49
- displayComponent = (<PhoneDisplay value={value} variant="link" />);
50
- break;
51
- }
52
- case "URL" : {
53
- displayComponent = (<URLDisplay target="_blank" value={value} displayText={value} variant="link" />);
54
- break;
55
- }
56
- // no default
57
- }
58
- return displayComponent;
59
- };
60
-
61
17
 
62
18
 
63
19
  // Duplicated runtime code from Constellation Design System Component