@pega/dx-component-builder-sdk 0.1.4 → 0.1.6
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/package.json +1 -1
- package/src/tasks/create/index.js +48 -3
- package/src/tasks/create/templates/SDK-React/Field/Boolean/demo.stories.jsx.mustache +26 -14
- package/src/tasks/create/templates/SDK-React/Field/Boolean/mock.stories.js.mustache +15 -0
- package/src/tasks/create/templates/SDK-React/Field/Date/demo.stories.jsx.mustache +1 -1
- package/src/tasks/create/templates/SDK-React/Field/Date/index.tsx.mustache +3 -1
- package/src/tasks/create/templates/SDK-React/Field/DateTime/demo.stories.jsx.mustache +1 -1
- package/src/tasks/create/templates/SDK-React/Field/DateTime/index.tsx.mustache +3 -1
- package/src/tasks/create/templates/SDK-React/Field/Decimal/demo.stories.jsx.mustache +17 -10
- package/src/tasks/create/templates/SDK-React/Field/Decimal/mock.stories.js.mustache +14 -0
- package/src/tasks/create/templates/SDK-React/Field/Decimal-Currency/demo.stories.jsx.mustache +16 -10
- package/src/tasks/create/templates/SDK-React/Field/Decimal-Currency/mock.stories.js.mustache +14 -0
- package/src/tasks/create/templates/SDK-React/Field/Decimal-Percentage/demo.stories.jsx.mustache +17 -10
- package/src/tasks/create/templates/SDK-React/Field/Decimal-Percentage/mock.stories.js.mustache +14 -0
- package/src/tasks/create/templates/SDK-React/Field/Integer/demo.stories.jsx.mustache +16 -10
- package/src/tasks/create/templates/SDK-React/Field/Integer/mock.stories.js.mustache +14 -0
- package/src/tasks/create/templates/SDK-React/Field/Picklist/demo.stories.jsx.mustache +25 -16
- package/src/tasks/create/templates/SDK-React/Field/Picklist/mock.stories.js.mustache +30 -0
- package/src/tasks/create/templates/SDK-React/Field/Text/demo.stories.jsx.mustache +19 -3
- package/src/tasks/create/templates/SDK-React/Field/Text-Email/demo.stories.jsx.mustache +20 -4
- package/src/tasks/create/templates/SDK-React/Field/Text-Input/demo.stories.jsx.mustache +20 -3
- package/src/tasks/create/templates/SDK-React/Field/Text-Paragraph/demo.stories.jsx.mustache +19 -4
- package/src/tasks/create/templates/SDK-React/Field/Text-Phone/demo.stories.jsx.mustache +21 -3
- package/src/tasks/create/templates/SDK-React/Field/Text-URL/demo.stories.jsx.mustache +20 -4
- package/src/tasks/create/templates/SDK-React/Field/TimeofDay/demo.stories.jsx.mustache +1 -1
- package/src/tasks/create/templates/SDK-React/Field/TimeofDay/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/SDK-React/Widget/CASE/demo.stories.jsx.mustache +70 -0
- package/src/tasks/create/templates/SDK-React/Widget/CASE/mock.stories.js.mustache +390 -0
- package/src/tasks/create/templates/SDK-React/Widget/PAGE-CASE/demo.stories.jsx.mustache +60 -0
- package/src/tasks/create/templates/SDK-React/Widget/PAGE-CASE/index.tsx.mustache +2 -2
- package/src/tasks/create/templates/SDK-React/Widget/PAGE-CASE/mock.stories.js.mustache +52 -0
- package/src/tasks/delete/helper.js +3 -0
- package/src/tasks/delete-all/helper.js +3 -0
- package/src/util.js +13 -7
package/package.json
CHANGED
|
@@ -31,9 +31,17 @@ import { COMPONENT_SCHEMA } from '../../constants.js';
|
|
|
31
31
|
const copy = promisify(ncp);
|
|
32
32
|
|
|
33
33
|
const copyComponentTemplate = async options => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
if (options.targetDirectory) {
|
|
35
|
+
return copy(options.templateDirectory, options.targetDirectory, {
|
|
36
|
+
clobber: false
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return copy(options.templateDirectoryConstellation, options.targetDirectoryConstellation, {
|
|
41
|
+
clobber: false
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
37
45
|
};
|
|
38
46
|
|
|
39
47
|
const compileMustacheTemplates = async (
|
|
@@ -151,17 +159,34 @@ const validateCompile = async (
|
|
|
151
159
|
const templateDir = `./templates/${framework}/${type}/${sSubType}`;
|
|
152
160
|
const templateDirectory = fileURLToPath(new URL(templateDir, import.meta.url));
|
|
153
161
|
|
|
162
|
+
const templateDirConstellation = `./templates/Constellation/${type}/${sSubType}`;
|
|
163
|
+
const templateDirectoryConstellation = fileURLToPath(new URL(templateDirConstellation, import.meta.url));
|
|
164
|
+
|
|
154
165
|
const componentKey = `${organization}_${library}_${componentName}`;
|
|
155
166
|
|
|
156
167
|
const typeLC = type.toLowerCase();
|
|
157
168
|
const targetDirectory = await getComponentDirectoryPath(join(typeLC, "/",componentKey));
|
|
169
|
+
const targetDirectoryConstellation = await getComponentDirectoryPath(join(typeLC, "/",componentKey), "constellation");
|
|
158
170
|
|
|
159
171
|
const components = await getComponents(false);
|
|
160
172
|
if (components.includes(componentKey)) {
|
|
161
173
|
console.log(chalk.red(`${componentKey} component already exists in ${targetDirectory}`));
|
|
174
|
+
|
|
175
|
+
let componentsConstellation = await getComponents(false, "constellation");
|
|
176
|
+
if (components.includes(componentKey)) {
|
|
177
|
+
console.log(chalk.red(`${componentKey} companion component already exists in ${targetDirectoryConstellation}`));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
// test for constellation
|
|
183
|
+
const componentsConstellation = await getComponents(false, "constellation");
|
|
184
|
+
if (components.includes(componentKey)) {
|
|
185
|
+
console.log(chalk.red(`${componentKey} companion component already exists in ${targetDirectoryConstellation}`));
|
|
162
186
|
return;
|
|
163
187
|
}
|
|
164
188
|
|
|
189
|
+
// component
|
|
165
190
|
await copyComponentTemplate({
|
|
166
191
|
...options,
|
|
167
192
|
targetDirectory,
|
|
@@ -180,7 +205,27 @@ const validateCompile = async (
|
|
|
180
205
|
allowedApplications
|
|
181
206
|
});
|
|
182
207
|
|
|
208
|
+
// matching constellation
|
|
209
|
+
await copyComponentTemplate({
|
|
210
|
+
...options,
|
|
211
|
+
targetDirectoryConstellation,
|
|
212
|
+
templateDirectoryConstellation
|
|
213
|
+
});
|
|
214
|
+
await compileMustacheTemplates(targetDirectoryConstellation, {
|
|
215
|
+
componentKey,
|
|
216
|
+
componentName,
|
|
217
|
+
componentLabel,
|
|
218
|
+
library,
|
|
219
|
+
version,
|
|
220
|
+
type,
|
|
221
|
+
subtype,
|
|
222
|
+
description,
|
|
223
|
+
organization,
|
|
224
|
+
allowedApplications
|
|
225
|
+
});
|
|
226
|
+
|
|
183
227
|
console.log(chalk.green(`created ${componentKey} component in ${targetDirectory}`));
|
|
228
|
+
console.log(chalk.green(`created ${componentKey} companion component in ${targetDirectoryConstellation}`));
|
|
184
229
|
|
|
185
230
|
};
|
|
186
231
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { withKnobs
|
|
2
|
+
import { withKnobs } from '@storybook/addon-knobs';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { configProps, stateProps } from './mock.stories';
|
|
5
|
+
|
|
6
|
+
import {{COMPONENT_CLASS_NAME}} from './index.tsx';
|
|
5
7
|
|
|
6
8
|
export default {
|
|
7
9
|
title: '{{COMPONENT_CLASS_NAME}}',
|
|
@@ -10,30 +12,40 @@ export default {
|
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
export const Base{{COMPONENT_CLASS_NAME}} = () => {
|
|
13
|
-
const [value, setValue] = useState(
|
|
15
|
+
const [value, setValue] = useState(configProps.value);
|
|
14
16
|
|
|
15
17
|
const props = {
|
|
18
|
+
value,
|
|
19
|
+
label: configProps.label,
|
|
20
|
+
helperText: configProps.helperText,
|
|
21
|
+
caption: configProps.caption,
|
|
22
|
+
testId: configProps.testId,
|
|
23
|
+
trueLabel: configProps.trueLabel,
|
|
24
|
+
falseLabel: configProps.falseLabel,
|
|
25
|
+
|
|
16
26
|
getPConnect: () => {
|
|
17
27
|
return {
|
|
28
|
+
getStateProps: () => {
|
|
29
|
+
return stateProps;
|
|
30
|
+
},
|
|
31
|
+
getConfigProps: () => {
|
|
32
|
+
return configProps;
|
|
33
|
+
},
|
|
18
34
|
getActionsApi: () => {
|
|
19
35
|
return {
|
|
20
36
|
updateFieldValue: (propName, theValue) => {
|
|
21
37
|
setValue(theValue);
|
|
22
|
-
}
|
|
38
|
+
},
|
|
39
|
+
triggerFieldChange: () => { /* nothing */}
|
|
23
40
|
};
|
|
24
41
|
},
|
|
25
|
-
|
|
26
|
-
return {
|
|
42
|
+
getValidationApi: () => {
|
|
43
|
+
return {
|
|
44
|
+
validate: () => { /* nothing */}
|
|
45
|
+
};
|
|
27
46
|
}
|
|
28
47
|
};
|
|
29
|
-
}
|
|
30
|
-
value,
|
|
31
|
-
placeholder: text('Placeholder', 'Test placeholder'),
|
|
32
|
-
disabled: boolean('Disabled', false),
|
|
33
|
-
readOnly: boolean('Disabled', false),
|
|
34
|
-
required: boolean('Disabled', false),
|
|
35
|
-
label: text('Label', 'Sample Label'),
|
|
36
|
-
testId: text('Test id', 'text-12344566')
|
|
48
|
+
}
|
|
37
49
|
};
|
|
38
50
|
|
|
39
51
|
return (
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const configProps = {
|
|
2
|
+
"caption": "Boolean Caption",
|
|
3
|
+
"value": false,
|
|
4
|
+
"trueLabel": "Yes",
|
|
5
|
+
"falseLabel": "No",
|
|
6
|
+
"label": "Boolean Sample",
|
|
7
|
+
"helperText": "Boolean Helper Text",
|
|
8
|
+
"testId": "boolean-12345678",
|
|
9
|
+
"hasSuggestions": false
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const stateProps = {
|
|
13
|
+
"value": ".BooleanSample",
|
|
14
|
+
"hasSuggestions": false
|
|
15
|
+
};
|
|
@@ -3,7 +3,7 @@ import { withKnobs } from '@storybook/addon-knobs';
|
|
|
3
3
|
|
|
4
4
|
import { configProps, stateProps } from './mock.stories';
|
|
5
5
|
|
|
6
|
-
import {{COMPONENT_CLASS_NAME}} from './index.
|
|
6
|
+
import {{COMPONENT_CLASS_NAME}} from './index.tsx';
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
9
|
title: '{{COMPONENT_CLASS_NAME}}',
|
|
@@ -6,8 +6,10 @@ import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event
|
|
|
6
6
|
import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtensions/FieldValueList';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
|
|
9
|
+
|
|
9
10
|
import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
|
|
10
11
|
|
|
12
|
+
|
|
11
13
|
// Duplicated runtime code from React SDK
|
|
12
14
|
|
|
13
15
|
// props passed in combination of props from property panel (config.json) and run time props from Constellation
|
|
@@ -88,7 +90,7 @@ export default function {{COMPONENT_CLASS_NAME}}(props: any) {
|
|
|
88
90
|
InputProps={{ ...testProp }}
|
|
89
91
|
<%={{ }}=%> {{! revert delimiteres for mustache }}
|
|
90
92
|
/>
|
|
91
|
-
</MuiPickersUtilsProvider>
|
|
93
|
+
</MuiPickersUtilsProvider>
|
|
92
94
|
</Styled{{COMPONENT_CLASS_NAME}}Wrapper>
|
|
93
95
|
);
|
|
94
96
|
}
|
|
@@ -3,7 +3,7 @@ import { withKnobs } from '@storybook/addon-knobs';
|
|
|
3
3
|
|
|
4
4
|
import { configProps, stateProps } from './mock.stories';
|
|
5
5
|
|
|
6
|
-
import {{COMPONENT_CLASS_NAME}} from './index.
|
|
6
|
+
import {{COMPONENT_CLASS_NAME}} from './index.tsx';
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
9
|
title: '{{COMPONENT_CLASS_NAME}}',
|
|
@@ -6,8 +6,10 @@ import handleEvent from '@pega/react-sdk-components/lib/components/helpers/event
|
|
|
6
6
|
import FieldValueList from '@pega/react-sdk-components/lib/components/designSystemExtensions/FieldValueList';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
|
|
9
|
+
|
|
9
10
|
import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
|
|
10
11
|
|
|
12
|
+
|
|
11
13
|
// Duplicated runtime code from React SDK
|
|
12
14
|
|
|
13
15
|
// props passed in combination of props from property panel (config.json) and run time props from Constellation
|
|
@@ -78,7 +80,7 @@ export default function {{COMPONENT_CLASS_NAME}}(props: any) {
|
|
|
78
80
|
onAccept={handleAccept}
|
|
79
81
|
data-test-id={testId}
|
|
80
82
|
/>
|
|
81
|
-
</MuiPickersUtilsProvider>
|
|
83
|
+
</MuiPickersUtilsProvider>
|
|
82
84
|
</Styled{{COMPONENT_CLASS_NAME}}Wrapper>
|
|
83
85
|
);
|
|
84
86
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { withKnobs
|
|
2
|
+
import { withKnobs } from '@storybook/addon-knobs';
|
|
3
|
+
import { configProps, fieldMetadata } from './mock.stories.js';
|
|
3
4
|
|
|
4
|
-
import {{COMPONENT_CLASS_NAME}} from './index.
|
|
5
|
+
import {{COMPONENT_CLASS_NAME}} from './index.tsx';
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
title: '{{COMPONENT_CLASS_NAME}}',
|
|
@@ -10,9 +11,15 @@ export default {
|
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export const Base{{COMPONENT_CLASS_NAME}} = () => {
|
|
13
|
-
const [value, setValue] = useState(
|
|
14
|
+
const [value, setValue] = useState(configProps.value);
|
|
14
15
|
|
|
15
16
|
const props = {
|
|
17
|
+
value,
|
|
18
|
+
placeholder: configProps.placeholder,
|
|
19
|
+
label: configProps.label,
|
|
20
|
+
helperText: configProps.helperText,
|
|
21
|
+
testId: configProps.testId,
|
|
22
|
+
fieldMetadata,
|
|
16
23
|
getPConnect: () => {
|
|
17
24
|
return {
|
|
18
25
|
getActionsApi: () => {
|
|
@@ -27,13 +34,12 @@ export const Base{{COMPONENT_CLASS_NAME}} = () => {
|
|
|
27
34
|
}
|
|
28
35
|
};
|
|
29
36
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
testId: text('Test id', 'text-12344566')
|
|
37
|
+
onChange: event => {
|
|
38
|
+
setValue(event.target.value);
|
|
39
|
+
},
|
|
40
|
+
onBlur: () => {
|
|
41
|
+
return configProps.value;
|
|
42
|
+
}
|
|
37
43
|
};
|
|
38
44
|
|
|
39
45
|
return (
|
|
@@ -42,3 +48,4 @@ export const Base{{COMPONENT_CLASS_NAME}} = () => {
|
|
|
42
48
|
</>
|
|
43
49
|
);
|
|
44
50
|
};
|
|
51
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const configProps = {
|
|
2
|
+
value: '',
|
|
3
|
+
label: 'Decimal Sample',
|
|
4
|
+
placeholder: 'Decimal Placeholder',
|
|
5
|
+
helperText: 'Decimal Helper Text',
|
|
6
|
+
testId: 'decimal-12345678'
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const fieldMetadata = {
|
|
10
|
+
classID: 'DIXL-MediaCo-Work-NewService',
|
|
11
|
+
type: 'Decimal',
|
|
12
|
+
displayAs: 'pxNumber',
|
|
13
|
+
label: 'Decimal sample'
|
|
14
|
+
};
|
package/src/tasks/create/templates/SDK-React/Field/Decimal-Currency/demo.stories.jsx.mustache
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { withKnobs
|
|
2
|
+
import { withKnobs } from '@storybook/addon-knobs';
|
|
3
|
+
import { configProps, fieldMetadata } from './mock.stories.js';
|
|
3
4
|
|
|
4
|
-
import {{COMPONENT_CLASS_NAME}} from './index.
|
|
5
|
+
import {{COMPONENT_CLASS_NAME}} from './index.tsx';
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
title: '{{COMPONENT_CLASS_NAME}}',
|
|
@@ -10,9 +11,15 @@ export default {
|
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export const Base{{COMPONENT_CLASS_NAME}} = () => {
|
|
13
|
-
const [value, setValue] = useState(
|
|
14
|
+
const [value, setValue] = useState(configProps.value);
|
|
14
15
|
|
|
15
16
|
const props = {
|
|
17
|
+
value,
|
|
18
|
+
placeholder: configProps.placeholder,
|
|
19
|
+
label: configProps.label,
|
|
20
|
+
helperText: configProps.helperText,
|
|
21
|
+
testId: configProps.testId,
|
|
22
|
+
fieldMetadata,
|
|
16
23
|
getPConnect: () => {
|
|
17
24
|
return {
|
|
18
25
|
getActionsApi: () => {
|
|
@@ -27,13 +34,12 @@ export const Base{{COMPONENT_CLASS_NAME}} = () => {
|
|
|
27
34
|
}
|
|
28
35
|
};
|
|
29
36
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
testId: text('Test id', 'text-12344566')
|
|
37
|
+
onChange: event => {
|
|
38
|
+
setValue(event.target.value);
|
|
39
|
+
},
|
|
40
|
+
onBlur: () => {
|
|
41
|
+
return configProps.value;
|
|
42
|
+
}
|
|
37
43
|
};
|
|
38
44
|
|
|
39
45
|
return (
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const configProps = {
|
|
2
|
+
value: '',
|
|
3
|
+
label: 'Currency Sample',
|
|
4
|
+
placeholder: 'Currency Placeholder',
|
|
5
|
+
helperText: 'Currency Helper Text',
|
|
6
|
+
testId: 'currency-12345678'
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const fieldMetadata = {
|
|
10
|
+
classID: 'DIXL-MediaCo-Work-NewService',
|
|
11
|
+
type: 'Decimal',
|
|
12
|
+
displayAs: 'pxCurrency',
|
|
13
|
+
label: 'Currency sample'
|
|
14
|
+
};
|
package/src/tasks/create/templates/SDK-React/Field/Decimal-Percentage/demo.stories.jsx.mustache
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { withKnobs
|
|
2
|
+
import { withKnobs } from '@storybook/addon-knobs';
|
|
3
|
+
import { configProps, fieldMetadata } from './mock.stories.js';
|
|
3
4
|
|
|
4
|
-
import {{COMPONENT_CLASS_NAME}} from './index.
|
|
5
|
+
import {{COMPONENT_CLASS_NAME}} from './index.tsx';
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
title: '{{COMPONENT_CLASS_NAME}}',
|
|
@@ -10,9 +11,16 @@ export default {
|
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export const Base{{COMPONENT_CLASS_NAME}} = () => {
|
|
13
|
-
const [value, setValue] = useState(
|
|
14
|
+
const [value, setValue] = useState(configProps.value);
|
|
14
15
|
|
|
15
16
|
const props = {
|
|
17
|
+
value,
|
|
18
|
+
placeholder: configProps.placeholder,
|
|
19
|
+
label: configProps.label,
|
|
20
|
+
helperText: configProps.helperText,
|
|
21
|
+
hasSuggestions: configProps.hasSuggestions,
|
|
22
|
+
testId: configProps.testId,
|
|
23
|
+
fieldMetadata,
|
|
16
24
|
getPConnect: () => {
|
|
17
25
|
return {
|
|
18
26
|
getActionsApi: () => {
|
|
@@ -27,13 +35,12 @@ export const Base{{COMPONENT_CLASS_NAME}} = () => {
|
|
|
27
35
|
}
|
|
28
36
|
};
|
|
29
37
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
testId: text('Test id', 'text-12344566')
|
|
38
|
+
onChange: event => {
|
|
39
|
+
setValue(event.target.value);
|
|
40
|
+
},
|
|
41
|
+
onBlur: () => {
|
|
42
|
+
return configProps.value;
|
|
43
|
+
}
|
|
37
44
|
};
|
|
38
45
|
|
|
39
46
|
return (
|
package/src/tasks/create/templates/SDK-React/Field/Decimal-Percentage/mock.stories.js.mustache
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const configProps = {
|
|
2
|
+
value: '',
|
|
3
|
+
label: 'Percentage Sample',
|
|
4
|
+
placeholder: 'Percentage Placeholder',
|
|
5
|
+
helperText: 'Percentage Helper Text',
|
|
6
|
+
testId: 'percentage-12345678'
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const fieldMetadata = {
|
|
10
|
+
classID: 'DIXL-MediaCo-Work-NewService',
|
|
11
|
+
type: 'Decimal',
|
|
12
|
+
displayAs: 'pxPercentage',
|
|
13
|
+
label: 'Percentage sample'
|
|
14
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { withKnobs
|
|
2
|
+
import { withKnobs } from '@storybook/addon-knobs';
|
|
3
|
+
import { configProps, fieldMetadata } from './mock.stories.js';
|
|
3
4
|
|
|
4
|
-
import {{COMPONENT_CLASS_NAME}} from './index.
|
|
5
|
+
import {{COMPONENT_CLASS_NAME}} from './index.tsx';
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
title: '{{COMPONENT_CLASS_NAME}}',
|
|
@@ -10,9 +11,15 @@ export default {
|
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export const Base{{COMPONENT_CLASS_NAME}} = () => {
|
|
13
|
-
const [value, setValue] = useState(
|
|
14
|
+
const [value, setValue] = useState(configProps.value);
|
|
14
15
|
|
|
15
16
|
const props = {
|
|
17
|
+
value,
|
|
18
|
+
placeholder: configProps.placeholder,
|
|
19
|
+
label: configProps.label,
|
|
20
|
+
helperText: configProps.helperText,
|
|
21
|
+
testId: configProps.testId,
|
|
22
|
+
fieldMetadata,
|
|
16
23
|
getPConnect: () => {
|
|
17
24
|
return {
|
|
18
25
|
getActionsApi: () => {
|
|
@@ -27,13 +34,12 @@ export const Base{{COMPONENT_CLASS_NAME}} = () => {
|
|
|
27
34
|
}
|
|
28
35
|
};
|
|
29
36
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
testId: text('Test id', 'text-12344566')
|
|
37
|
+
onChange: event => {
|
|
38
|
+
setValue(event.target.value);
|
|
39
|
+
},
|
|
40
|
+
onBlur: () => {
|
|
41
|
+
return configProps.value;
|
|
42
|
+
}
|
|
37
43
|
};
|
|
38
44
|
|
|
39
45
|
return (
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const configProps = {
|
|
2
|
+
value: '',
|
|
3
|
+
label: 'Integer Sample',
|
|
4
|
+
placeholder: 'Integer Placeholder',
|
|
5
|
+
helperText: 'Integer Helper Text',
|
|
6
|
+
testId: 'integer-12345678'
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const fieldMetadata = {
|
|
10
|
+
classID: 'DIXL-MediaCo-Work-NewService',
|
|
11
|
+
type: 'Integer',
|
|
12
|
+
displayAs: 'pxInteger',
|
|
13
|
+
label: 'Integer sample'
|
|
14
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { withKnobs
|
|
2
|
+
import { withKnobs } from '@storybook/addon-knobs';
|
|
3
|
+
import { configProps, stateProps } from './mock.stories';
|
|
3
4
|
|
|
4
|
-
import {{COMPONENT_CLASS_NAME}} from './index.
|
|
5
|
+
import {{COMPONENT_CLASS_NAME}} from './index.tsx';
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
title: '{{COMPONENT_CLASS_NAME}}',
|
|
@@ -10,30 +11,37 @@ export default {
|
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export const Base{{COMPONENT_CLASS_NAME}} = () => {
|
|
13
|
-
const [value, setValue] = useState(
|
|
14
|
+
const [value, setValue] = useState(configProps.value);
|
|
14
15
|
|
|
15
16
|
const props = {
|
|
17
|
+
value,
|
|
18
|
+
placeholder: configProps.placeholder,
|
|
19
|
+
label: configProps.label,
|
|
20
|
+
helperText: configProps.helperText,
|
|
21
|
+
datasource: configProps.datasource,
|
|
22
|
+
testId: configProps.testId,
|
|
23
|
+
hasSuggestions: configProps.hasSuggestions,
|
|
24
|
+
listType: configProps.listType,
|
|
16
25
|
getPConnect: () => {
|
|
17
26
|
return {
|
|
27
|
+
getDataObject: () => {
|
|
28
|
+
return undefined;
|
|
29
|
+
},
|
|
30
|
+
getStateProps: () => {
|
|
31
|
+
return stateProps;
|
|
32
|
+
},
|
|
18
33
|
getActionsApi: () => {
|
|
19
34
|
return {
|
|
20
|
-
updateFieldValue: (propName,
|
|
21
|
-
setValue(
|
|
35
|
+
updateFieldValue: (propName, val) => {
|
|
36
|
+
setValue(val);
|
|
37
|
+
},
|
|
38
|
+
triggerFieldChange: () => {
|
|
39
|
+
return undefined;
|
|
22
40
|
}
|
|
23
41
|
};
|
|
24
|
-
},
|
|
25
|
-
getStateProps: () => {
|
|
26
|
-
return { value: '.name' };
|
|
27
42
|
}
|
|
28
43
|
};
|
|
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')
|
|
44
|
+
}
|
|
37
45
|
};
|
|
38
46
|
|
|
39
47
|
return (
|
|
@@ -42,3 +50,4 @@ export const Base{{COMPONENT_CLASS_NAME}} = () => {
|
|
|
42
50
|
</>
|
|
43
51
|
);
|
|
44
52
|
};
|
|
53
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import {{COMPONENT_CLASS_NAME}} from './index.tsx';
|
|
2
3
|
import { withKnobs } from '@storybook/addon-knobs';
|
|
3
4
|
import { configProps } from './mock.stories';
|
|
4
5
|
|
|
@@ -9,9 +10,10 @@ export default {
|
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
export const Base{{COMPONENT_CLASS_NAME}} = () => {
|
|
13
|
+
const [value, setValue] = useState(configProps.value);
|
|
12
14
|
|
|
13
15
|
const props = {
|
|
14
|
-
value
|
|
16
|
+
value,
|
|
15
17
|
placeholder: configProps.placeholder,
|
|
16
18
|
label: configProps.label,
|
|
17
19
|
testId: configProps.testId,
|
|
@@ -21,7 +23,21 @@ export const Base{{COMPONENT_CLASS_NAME}} = () => {
|
|
|
21
23
|
required: configProps.required,
|
|
22
24
|
readOnly: configProps.readOnly,
|
|
23
25
|
displayMode: configProps.displayMode,
|
|
24
|
-
|
|
26
|
+
getPConnect: () => {
|
|
27
|
+
return {
|
|
28
|
+
getActionsApi: () => {
|
|
29
|
+
return {
|
|
30
|
+
updateFieldValue: (propName, theValue) => {
|
|
31
|
+
setValue(theValue);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
getStateProps: () => {
|
|
36
|
+
return { value: '.name' };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
onChange: (event) => { setValue(event.target.value); },
|
|
25
41
|
onBlur: () => { return configProps.value; }
|
|
26
42
|
};
|
|
27
43
|
|