@pega/custom-dx-components 2.0.11 → 2.0.12
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.
- package/README.md +73 -57
- package/package.json +1 -1
- package/src/cli.js +18 -0
- package/src/tasks/authenticate/index.js +3 -1
- package/src/tasks/build/helper.js +123 -0
- package/src/tasks/build/index.js +54 -0
- package/src/tasks/{publish/bundle → bundle}/builder/index.js +0 -0
- package/src/tasks/{publish/bundle → bundle}/builder/modules.js +0 -0
- package/src/tasks/{publish/bundle → bundle}/builder/paths.js +0 -0
- package/src/tasks/{publish/bundle → bundle}/builder/webpack.config.js +0 -2
- package/src/tasks/{publish/bundle → bundle}/index.js +2 -2
- package/src/tasks/create/index.js +6 -3
- package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +29 -18
- package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +1 -2
- package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +61 -0
- package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +41 -0
- package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +179 -67
- package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +39 -16
- package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +3 -1
- package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/DateTime/{date-utils.js → date-utils.js.mustache} +1 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +39 -15
- package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +2 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +22 -17
- package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +2 -1
- package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +25 -17
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +3 -4
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +22 -17
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +8 -2
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +22 -17
- package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +2 -1
- package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +42 -14
- package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +44 -1
- package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +67 -0
- package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +21 -16
- package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +13 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +20 -16
- package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +44 -2
- package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/{StatusWork.js → StatusWork.jsx} +0 -1
- package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +21 -17
- package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +46 -3
- package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +21 -17
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +44 -2
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +20 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +19 -17
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +46 -2
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +37 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +19 -17
- package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +174 -3
- package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +24 -16
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/mock.stories.js.mustache +20 -0
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +110 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +14 -29
- package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +179 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +3 -77
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +118 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +14 -29
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +215 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +3 -74
- package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +89 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +6 -10
- package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +125 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +92 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +10 -8
- package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +125 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/{GetNextWork.js.mustache → GetNextWork.jsx.mustache} +6 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +102 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +9 -7
- package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +94 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +4 -1
- package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +389 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +30 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +8 -8
- package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Avatar.js.mustache → Avatar.jsx.mustache} +2 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Operator.js.mustache → Operator.jsx.mustache} +2 -1
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +68 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +9 -9
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +51 -0
- package/src/tasks/delete/helper.js +4 -0
- package/src/tasks/delete/index.js +4 -0
- package/src/tasks/delete-all/helper.js +175 -0
- package/src/tasks/delete-all/index.js +49 -0
- package/src/tasks/index.js +3 -0
- package/src/tasks/init/index.js +1 -1
- package/src/tasks/init/template/.eslintignore +8 -0
- package/src/tasks/init/template/.eslintrc.json +186 -5
- package/src/tasks/init/template/package.json.mustache +19 -4
- package/src/tasks/linter/index.js +46 -0
- package/src/tasks/list/index.js +4 -0
- package/src/tasks/publish/index.js +14 -1
- package/src/tasks/publish-all/helper.js +139 -0
- package/src/tasks/publish-all/index.js +84 -0
- package/src/util.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/picklist.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Email/text-email.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Input/text-input.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/text-phone.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.js.mustache +0 -172
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export const configProps = {
|
|
2
|
+
value: '',
|
|
3
|
+
label: 'Picklist Sample',
|
|
4
|
+
placeholder: 'Select...',
|
|
5
|
+
listType: 'associated',
|
|
6
|
+
datasource: [
|
|
7
|
+
{
|
|
8
|
+
key: 'Option 1',
|
|
9
|
+
value: 'Option 1'
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
key: 'Option 2',
|
|
13
|
+
value: 'Option 2'
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
key: 'Option 3',
|
|
17
|
+
value: 'Option 3'
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
helperText: 'Picklist Helper Text',
|
|
21
|
+
testId: 'picklist-12345678',
|
|
22
|
+
hasSuggestions: false
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const stateProps = {
|
|
26
|
+
value: '.PicklistSample',
|
|
27
|
+
placeholder: 'Select...',
|
|
28
|
+
datasource: '.PicklistSample',
|
|
29
|
+
hasSuggestions: false
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const rawMetadata = {
|
|
33
|
+
type: 'Dropdown',
|
|
34
|
+
config: {
|
|
35
|
+
value: '@P .PicklistSample',
|
|
36
|
+
label: '@L Picklist Sample',
|
|
37
|
+
placeholder: '@L Select...',
|
|
38
|
+
listType: 'associated',
|
|
39
|
+
datasource: '@ASSOCIATED .PicklistSample',
|
|
40
|
+
helperText: '@L Picklist Helper Text',
|
|
41
|
+
testId: 'picklist-12345678'
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const fieldMetadata = {
|
|
46
|
+
classID: 'DIXL-MediaCo-Work-NewService',
|
|
47
|
+
type: 'Text',
|
|
48
|
+
displayAs: 'pxDropdown',
|
|
49
|
+
label: 'Picklist sample',
|
|
50
|
+
datasource: {
|
|
51
|
+
tableType: 'PromptList',
|
|
52
|
+
records: [
|
|
53
|
+
{
|
|
54
|
+
key: 'Option 1',
|
|
55
|
+
value: 'Option 1'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
key: 'Option 2',
|
|
59
|
+
value: 'Option 2'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
key: 'Option 3',
|
|
63
|
+
value: 'Option 3'
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { withKnobs
|
|
2
|
+
import { withKnobs } from '@storybook/addon-knobs';
|
|
3
|
+
|
|
4
|
+
import { stateProps, configProps } from './mock.stories';
|
|
3
5
|
|
|
4
6
|
import {{COMPONENT_CLASS_NAME}} from './index.jsx';
|
|
5
7
|
|
|
@@ -10,30 +12,33 @@ export default {
|
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
export const base{{COMPONENT_CLASS_NAME}} = () => {
|
|
13
|
-
|
|
15
|
+
|
|
16
|
+
const [value, setValue] = useState(configProps.value);
|
|
14
17
|
|
|
15
18
|
const props = {
|
|
19
|
+
value,
|
|
20
|
+
placeholder: configProps.placeholder,
|
|
21
|
+
label: configProps.label,
|
|
22
|
+
testId: configProps.testId,
|
|
23
|
+
hasSuggestions: configProps.hasSuggestions,
|
|
24
|
+
|
|
16
25
|
getPConnect: () => {
|
|
17
26
|
return {
|
|
27
|
+
getStateProps: () => {
|
|
28
|
+
return stateProps;
|
|
29
|
+
},
|
|
18
30
|
getActionsApi: () => {
|
|
19
31
|
return {
|
|
20
|
-
updateFieldValue: (
|
|
21
|
-
|
|
22
|
-
}
|
|
32
|
+
updateFieldValue: () => {},
|
|
33
|
+
triggerFieldChange: () => {}
|
|
23
34
|
};
|
|
24
35
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
36
|
+
ignoreSuggestion: () => {},
|
|
37
|
+
acceptSuggestion: () => {},
|
|
38
|
+
setInheritedProps: () => {},
|
|
39
|
+
resolveConfigProps: () => {}
|
|
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
44
|
return (
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const configProps = {
|
|
2
|
+
value: '',
|
|
3
|
+
label: 'Text Sample',
|
|
4
|
+
placeholder: 'Text Placeholder',
|
|
5
|
+
helperText: 'Text Helper Text',
|
|
6
|
+
testId: 'Text-12345678',
|
|
7
|
+
hasSuggestions: false
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const stateProps = {
|
|
11
|
+
value: '.TextSample',
|
|
12
|
+
hasSuggestions: false
|
|
13
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
1
|
import { withKnobs, text, boolean } from '@storybook/addon-knobs';
|
|
3
2
|
|
|
4
3
|
import {{COMPONENT_CLASS_NAME}} from './index.jsx';
|
|
5
4
|
|
|
5
|
+
import { stateProps, configProps, fieldMetadata } from './mock.stories';
|
|
6
|
+
|
|
6
7
|
export default {
|
|
7
8
|
title: '{{COMPONENT_CLASS_NAME}}',
|
|
8
9
|
decorators: [withKnobs],
|
|
@@ -10,30 +11,33 @@ export default {
|
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
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
|
+
|
|
16
24
|
getPConnect: () => {
|
|
17
25
|
return {
|
|
26
|
+
getStateProps: () => {
|
|
27
|
+
return stateProps;
|
|
28
|
+
},
|
|
18
29
|
getActionsApi: () => {
|
|
19
30
|
return {
|
|
20
|
-
updateFieldValue: (
|
|
21
|
-
|
|
22
|
-
}
|
|
31
|
+
updateFieldValue: () => {},
|
|
32
|
+
triggerFieldChange: () => {}
|
|
23
33
|
};
|
|
24
34
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
35
|
+
ignoreSuggestion: () => {},
|
|
36
|
+
acceptSuggestion: () => {},
|
|
37
|
+
setInheritedProps: () => {},
|
|
38
|
+
resolveConfigProps: () => {}
|
|
28
39
|
};
|
|
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')
|
|
40
|
+
}
|
|
37
41
|
};
|
|
38
42
|
|
|
39
43
|
return (
|
|
@@ -1,14 +1,56 @@
|
|
|
1
1
|
import { useState, useEffect, useRef } from 'react';
|
|
2
|
-
import { Input, EmailDisplay, FieldValueList, Text } from '@pega/cosmos-react-core';
|
|
2
|
+
import { Input, EmailDisplay, FieldValueList, Text, URLDisplay, PhoneDisplay } 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";
|
|
7
6
|
import { suggestionsHandler } from './suggestions-handler';
|
|
8
7
|
import handleEvent from "./event-utils";
|
|
9
8
|
|
|
10
9
|
import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
|
|
11
10
|
|
|
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
|
+
|
|
12
54
|
|
|
13
55
|
// Duplicated runtime code from Constellation Design System Component
|
|
14
56
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const configProps = {
|
|
2
|
+
value: '',
|
|
3
|
+
label: 'Email Sample',
|
|
4
|
+
placeholder: 'Email Placeholder',
|
|
5
|
+
helperText: 'Email Helper Text',
|
|
6
|
+
testId: 'email-12345678',
|
|
7
|
+
hasSuggestions: false
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const stateProps = {
|
|
11
|
+
value: '.EmailSample',
|
|
12
|
+
hasSuggestions: false
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const fieldMetadata = {
|
|
16
|
+
classID: 'DIXL-MediaCo-Work-NewService',
|
|
17
|
+
type: 'Text',
|
|
18
|
+
maxLength: 256,
|
|
19
|
+
displayAs: 'pxEmail',
|
|
20
|
+
label: 'Email sample',
|
|
21
|
+
validateAs: 'ValidEmailAddress'
|
|
22
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { withKnobs, text, boolean } from '@storybook/addon-knobs';
|
|
1
|
+
import { withKnobs } from '@storybook/addon-knobs';
|
|
3
2
|
|
|
4
3
|
import {{COMPONENT_CLASS_NAME}} from './index.jsx';
|
|
5
4
|
|
|
5
|
+
import { stateProps, fieldMetadata, configProps } from './mock.stories';
|
|
6
|
+
|
|
6
7
|
export default {
|
|
7
8
|
title: '{{COMPONENT_CLASS_NAME}}',
|
|
8
9
|
decorators: [withKnobs],
|
|
@@ -10,30 +11,33 @@ export default {
|
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
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
|
+
|
|
16
24
|
getPConnect: () => {
|
|
17
25
|
return {
|
|
26
|
+
getStateProps: () => {
|
|
27
|
+
return stateProps;
|
|
28
|
+
},
|
|
18
29
|
getActionsApi: () => {
|
|
19
30
|
return {
|
|
20
|
-
updateFieldValue: (
|
|
21
|
-
|
|
22
|
-
}
|
|
31
|
+
updateFieldValue: () => {},
|
|
32
|
+
triggerFieldChange: () => {}
|
|
23
33
|
};
|
|
24
34
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
35
|
+
ignoreSuggestion: () => {},
|
|
36
|
+
acceptSuggestion: () => {},
|
|
37
|
+
setInheritedProps: () => {},
|
|
38
|
+
resolveConfigProps: () => {}
|
|
28
39
|
};
|
|
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')
|
|
40
|
+
}
|
|
37
41
|
};
|
|
38
42
|
|
|
39
43
|
return (
|
|
@@ -1,16 +1,59 @@
|
|
|
1
1
|
import { useEffect, useState, useRef } from 'react';
|
|
2
|
-
import { Input, FieldValueList, Text } from '@pega/cosmos-react-core';
|
|
2
|
+
import { Input, FieldValueList, Text, EmailDisplay, PhoneDisplay, URLDisplay } 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";
|
|
8
|
-
import {formatExists,textFormatter} from "./text-input";
|
|
7
|
+
import StatusWorkRenderer from "./StatusWork.jsx";
|
|
9
8
|
import { suggestionsHandler } from './suggestions-handler';
|
|
10
9
|
|
|
11
10
|
import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
|
|
12
11
|
|
|
13
12
|
|
|
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
|
+
|
|
14
57
|
// Duplicated runtime code from Constellation Design System Component
|
|
15
58
|
|
|
16
59
|
// props passed in combination of props from property panel (config.json) and run time props from Constellation
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const configProps = {
|
|
2
|
+
value: '',
|
|
3
|
+
label: 'TextInput Sample',
|
|
4
|
+
placeholder: 'TextInput Placeholder',
|
|
5
|
+
helperText: 'TextInput Helper Text',
|
|
6
|
+
testId: 'TextInput-12345678',
|
|
7
|
+
hasSuggestions: false
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const stateProps = {
|
|
11
|
+
value: '.TextInputSample',
|
|
12
|
+
hasSuggestions: false
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const fieldMetadata = {
|
|
16
|
+
classID: 'DIXL-MediaCo-Work-NewService',
|
|
17
|
+
type: 'Text',
|
|
18
|
+
maxLength: 256,
|
|
19
|
+
displayAs: 'pxTextInput',
|
|
20
|
+
label: 'TextInput Sample'
|
|
21
|
+
};
|
package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { withKnobs, text, boolean } from '@storybook/addon-knobs';
|
|
1
|
+
import { withKnobs } from '@storybook/addon-knobs';
|
|
3
2
|
|
|
4
3
|
import {{COMPONENT_CLASS_NAME}} from './index.jsx';
|
|
5
4
|
|
|
5
|
+
import { stateProps, configProps } from './mock.stories';
|
|
6
|
+
|
|
6
7
|
export default {
|
|
7
8
|
title: '{{COMPONENT_CLASS_NAME}}',
|
|
8
9
|
decorators: [withKnobs],
|
|
@@ -10,30 +11,33 @@ export default {
|
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
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
|
+
|
|
16
24
|
getPConnect: () => {
|
|
17
25
|
return {
|
|
26
|
+
getStateProps: () => {
|
|
27
|
+
return stateProps;
|
|
28
|
+
},
|
|
18
29
|
getActionsApi: () => {
|
|
19
30
|
return {
|
|
20
|
-
updateFieldValue: (
|
|
21
|
-
|
|
22
|
-
}
|
|
31
|
+
updateFieldValue: () => {},
|
|
32
|
+
triggerFieldChange: () => {}
|
|
23
33
|
};
|
|
24
34
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
35
|
+
ignoreSuggestion: () => {},
|
|
36
|
+
acceptSuggestion: () => {},
|
|
37
|
+
setInheritedProps: () => {},
|
|
38
|
+
resolveConfigProps: () => {}
|
|
28
39
|
};
|
|
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')
|
|
40
|
+
}
|
|
37
41
|
};
|
|
38
42
|
|
|
39
43
|
return (
|
|
@@ -1,14 +1,56 @@
|
|
|
1
1
|
import { useState, useEffect, useRef } from 'react';
|
|
2
|
-
import { TextArea as CosmosTextArea, FieldValueList, ParagraphDisplay, Text } from '@pega/cosmos-react-core';
|
|
2
|
+
import { TextArea as CosmosTextArea, FieldValueList, ParagraphDisplay, Text, EmailDisplay, PhoneDisplay, URLDisplay } 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";
|
|
7
6
|
import { suggestionsHandler } from './suggestions-handler';
|
|
8
7
|
import handleEvent from "./event-utils";
|
|
9
8
|
|
|
10
9
|
import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
|
|
11
10
|
|
|
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
|
+
|
|
12
54
|
|
|
13
55
|
// Duplicated runtime code from Constellation Design System Component
|
|
14
56
|
|
package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const configProps = {
|
|
2
|
+
value: '',
|
|
3
|
+
label: 'Paragraph Sample',
|
|
4
|
+
placeholder: 'Paragraph Placeholder',
|
|
5
|
+
helperText: 'Paragraph Helper Text',
|
|
6
|
+
testId: 'paragraph-12345678',
|
|
7
|
+
hasSuggestions: false
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const fieldMetadata = {
|
|
11
|
+
classID: 'DIXL-MediaCo-Work-NewService',
|
|
12
|
+
type: 'Text',
|
|
13
|
+
displayAs: 'pxTextArea',
|
|
14
|
+
label: 'Paragraph sample'
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const stateProps = {
|
|
18
|
+
value: '.ParagraphSample',
|
|
19
|
+
hasSuggestions: false
|
|
20
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { withKnobs, text, boolean } from '@storybook/addon-knobs';
|
|
1
|
+
import { withKnobs } from '@storybook/addon-knobs';
|
|
3
2
|
|
|
4
3
|
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,30 +10,32 @@ export default {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export const base{{COMPONENT_CLASS_NAME}} = () => {
|
|
13
|
-
const [value, setValue] = useState('test value');
|
|
14
13
|
|
|
15
14
|
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
|
+
|
|
16
22
|
getPConnect: () => {
|
|
17
23
|
return {
|
|
24
|
+
getStateProps: () => {
|
|
25
|
+
return stateProps;
|
|
26
|
+
},
|
|
18
27
|
getActionsApi: () => {
|
|
19
28
|
return {
|
|
20
|
-
updateFieldValue: (
|
|
21
|
-
|
|
22
|
-
}
|
|
29
|
+
updateFieldValue: () => {},
|
|
30
|
+
triggerFieldChange: () => {}
|
|
23
31
|
};
|
|
24
32
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
33
|
+
ignoreSuggestion: () => {},
|
|
34
|
+
acceptSuggestion: () => {},
|
|
35
|
+
setInheritedProps: () => {},
|
|
36
|
+
resolveConfigProps: () => {}
|
|
28
37
|
};
|
|
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')
|
|
38
|
+
}
|
|
37
39
|
};
|
|
38
40
|
|
|
39
41
|
return (
|