@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,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,
23
-
24
16
  getPConnect: () => {
25
17
  return {
26
- getStateProps: () => {
27
- return stateProps;
28
- },
29
18
  getActionsApi: () => {
30
19
  return {
31
- updateFieldValue: () => {/* nothing */},
32
- triggerFieldChange: () => {/* nothing */}
20
+ updateFieldValue: (propName, value) => {
21
+ setValue(value);
22
+ }
33
23
  };
34
24
  },
35
- ignoreSuggestion: () => {/* nothing */},
36
- acceptSuggestion: () => {/* nothing */},
37
- setInheritedProps: () => {/* nothing */},
38
- resolveConfigProps: () => {/* nothing */}
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,
23
-
24
16
  getPConnect: () => {
25
17
  return {
26
- getStateProps: () => {
27
- return stateProps;
28
- },
29
18
  getActionsApi: () => {
30
19
  return {
31
- updateFieldValue: () => {/* nothing */},
32
- triggerFieldChange: () => {/* nothing */}
20
+ updateFieldValue: (propName, value) => {
21
+ setValue(value);
22
+ }
33
23
  };
34
24
  },
35
- ignoreSuggestion: () => {/* nothing */},
36
- acceptSuggestion: () => {/* nothing */},
37
- setInheritedProps: () => {/* nothing */},
38
- resolveConfigProps: () => {/* nothing */}
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: () => {/* nothing */},
30
- triggerFieldChange: () => {/* nothing */}
20
+ updateFieldValue: (propName, value) => {
21
+ setValue(value);
22
+ }
31
23
  };
32
24
  },
33
- ignoreSuggestion: () => {/* nothing */},
34
- acceptSuggestion: () => {/* nothing */},
35
- setInheritedProps: () => {/* nothing */},
36
- resolveConfigProps: () => {/* nothing */}
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
@@ -245,7 +201,7 @@ const {{COMPONENT_CLASS_NAME}} = props => {
245
201
  {{COMPONENT_CLASS_NAME}}.propTypes = {
246
202
  value: PropTypes.string,
247
203
  placeholder: PropTypes.string,
248
- datasource: PropTypes.objectOf(PropTypes.any),
204
+ datasource: PropTypes.node,
249
205
  label: PropTypes.string.isRequired,
250
206
  hideLabel: PropTypes.bool,
251
207
  getPConnect: PropTypes.func.isRequired,
@@ -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
- helperText: configProps.helperText,
19
- testId: configProps.testId,
20
- hasSuggestions: configProps.hasSuggestions,
21
-
22
16
  getPConnect: () => {
23
17
  return {
24
- getStateProps: () => {
25
- return stateProps;
26
- },
27
18
  getActionsApi: () => {
28
19
  return {
29
- updateFieldValue: () => {/* nothing */},
30
- triggerFieldChange: () => {/* nothing */}
20
+ updateFieldValue: (propName, value) => {
21
+ setValue(value);
22
+ }
31
23
  };
32
24
  },
33
- ignoreSuggestion: () => {/* nothing */},
34
- acceptSuggestion: () => {/* nothing */},
35
- setInheritedProps: () => {/* nothing */},
36
- resolveConfigProps: () => {/* nothing */}
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 (
@@ -3,7 +3,7 @@ import { Input, 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, urlFormatter} from "./text-url.jsx";
6
+ import {formatExists,textFormatter, urlFormatter, suggestionHandler} from "./text-url";
7
7
  import handleEvent from "./event-utils";
8
8
  import { suggestionsHandler } from './suggestions-handler';
9
9