@pega/dx-component-builder-sdk 0.1.5 → 0.1.7

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 (35) hide show
  1. package/package.json +1 -1
  2. package/src/constants.js +8 -4
  3. package/src/tasks/build/helper.js +4 -22
  4. package/src/tasks/build/index.js +54 -7
  5. package/src/tasks/bundle/index.js +2 -2
  6. package/src/tasks/create/index.js +50 -4
  7. package/src/tasks/create/templates/SDK-React/Field/Boolean/demo.stories.jsx.mustache +26 -14
  8. package/src/tasks/create/templates/SDK-React/Field/Boolean/mock.stories.js.mustache +15 -0
  9. package/src/tasks/create/templates/SDK-React/Field/Decimal/demo.stories.jsx.mustache +17 -10
  10. package/src/tasks/create/templates/SDK-React/Field/Decimal/mock.stories.js.mustache +14 -0
  11. package/src/tasks/create/templates/SDK-React/Field/Decimal-Currency/demo.stories.jsx.mustache +16 -10
  12. package/src/tasks/create/templates/SDK-React/Field/Decimal-Currency/mock.stories.js.mustache +14 -0
  13. package/src/tasks/create/templates/SDK-React/Field/Decimal-Percentage/demo.stories.jsx.mustache +17 -10
  14. package/src/tasks/create/templates/SDK-React/Field/Decimal-Percentage/mock.stories.js.mustache +14 -0
  15. package/src/tasks/create/templates/SDK-React/Field/Integer/demo.stories.jsx.mustache +16 -10
  16. package/src/tasks/create/templates/SDK-React/Field/Integer/mock.stories.js.mustache +14 -0
  17. package/src/tasks/create/templates/SDK-React/Field/Picklist/demo.stories.jsx.mustache +25 -16
  18. package/src/tasks/create/templates/SDK-React/Field/Picklist/mock.stories.js.mustache +30 -0
  19. package/src/tasks/create/templates/SDK-React/Field/Text-Phone/demo.stories.jsx.mustache +3 -1
  20. package/src/tasks/create/templates/SDK-React/Template/PAGE/demo.stories.jsx.mustache +79 -0
  21. package/src/tasks/create/templates/SDK-React/Template/PAGE/mock.stories.js.mustache +115 -0
  22. package/src/tasks/delete/helper.js +9 -24
  23. package/src/tasks/delete/index.js +2 -3
  24. package/src/tasks/delete-all/helper.js +9 -23
  25. package/src/tasks/delete-all/index.js +2 -3
  26. package/src/tasks/list/helper.js +3 -21
  27. package/src/tasks/list/index.js +2 -3
  28. package/src/tasks/map/map.js +4 -3
  29. package/src/tasks/override/index.js +13 -13
  30. package/src/tasks/publish/helper.js +77 -15
  31. package/src/tasks/publish/index.js +103 -15
  32. package/src/tasks/publish-all/helper.js +77 -13
  33. package/src/tasks/publish-all/index.js +109 -25
  34. package/src/tasks/validator/index.js +7 -5
  35. package/src/util.js +69 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/dx-component-builder-sdk",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
package/src/constants.js CHANGED
@@ -22,6 +22,10 @@ export const COMPONENT_PREFIX_WIDGETS_PATH = "widgets/";
22
22
  export const COMPONENT_PREFIX_DSE_PATH = "designSystemExtensions/";
23
23
  export const COMPONENT_PREFIX_INFRA_PATH = "infra/";
24
24
 
25
+ export const CATEGORY_CUSTOM = "custom";
26
+ export const CATEGORY_OVERRIDE = "override";
27
+ export const CATEGORY_CONSTELLATION = "constellation";
28
+
25
29
  /* REST end points */
26
30
  export const PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/publish_component';
27
31
  export const LIST_COMPONENT_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/list_component';
@@ -225,7 +229,7 @@ export const COMPONENT_SCHEMA = {
225
229
  },
226
230
  {
227
231
  name: 'Radio Buttons',
228
- value: 'RadioButons'
232
+ value: 'RadioButtons'
229
233
  },
230
234
  {
231
235
  name: 'Semantic Link',
@@ -312,8 +316,8 @@ export const COMPONENT_SCHEMA = {
312
316
  value: 'DeferLoad'
313
317
  },
314
318
  {
315
- name: 'Error Boundry',
316
- value: 'ErrorBoundry'
319
+ name: 'Error Boundary',
320
+ value: 'ErrorBoundary'
317
321
  },
318
322
  {
319
323
  name: 'Multi Step',
@@ -493,7 +497,7 @@ export const COMPONENT_SCHEMA = {
493
497
  widgets: [
494
498
  {
495
499
  name: 'App Announcement',
496
- value: 'AppAnnoucement'
500
+ value: 'AppAnnouncement'
497
501
  },
498
502
  {
499
503
  name: 'Case History',
@@ -12,31 +12,13 @@ import {
12
12
  getComponents,
13
13
  getComponentsObj,
14
14
  getPegaServerConfig,
15
- validateRulesetVersion
15
+ validateRulesetVersion,
16
+ getOptionsCategory,
16
17
  } from '../../util.js';
17
- import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH, COMPONENT_SCHEMA } from '../../constants.js';
18
+ import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH, COMPONENT_SCHEMA, CATEGORY_CUSTOM } from '../../constants.js';
18
19
 
19
- export const getOptionsCategory = (options) => {
20
- let categoryType = null;
21
- if (options.params[3]) {
22
- let catType = options.params[3];
23
-
24
- switch (catType.toLowerCase()) {
25
- case "override" :
26
- case "o" :
27
- categoryType = "override";
28
- break;
29
- case "custom" :
30
- case "c" :
31
- categoryType = "custom";
32
- break;
33
- }
34
- }
35
- return categoryType;
36
- }
37
20
 
38
21
  export const getBuildCategory = async (options) => {
39
- const defaultPegaServerConfig = await getPegaServerConfig();
40
22
  const categoryType = getOptionsCategory(options);
41
23
 
42
24
  return [
@@ -83,7 +65,7 @@ export const getBuildComponentQuestions = async (category) => {
83
65
  ];
84
66
  };
85
67
 
86
- export const zipComponent = async (componentKey, category = "custom") => {
68
+ export const zipComponent = async (componentKey, category = CATEGORY_CUSTOM) => {
87
69
  const srcDirectory = await getComponentDirectoryPath(componentKey, category);
88
70
  const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
89
71
  const configJson = `${srcDirectory}/config.json`;
@@ -6,8 +6,10 @@ import validate from '../validator/index.js';
6
6
 
7
7
  import bundleComponent from '../bundle/index.js';
8
8
  import lintComponent from '../linter/index.js';
9
- import { getBuildComponentQuestions, getBuildCategory, getOptionsCategory } from './helper.js';
10
- import { getComponentDirectoryPath, showVersion } from '../../util.js';
9
+ import { getBuildComponentQuestions, getBuildCategory } from './helper.js';
10
+ import { getComponentDirectoryPath, showVersion, getOptionsCategory } from '../../util.js';
11
+
12
+ import { CATEGORY_CUSTOM } from '../../constants.js';
11
13
 
12
14
  export default async options => {
13
15
  showVersion();
@@ -28,7 +30,45 @@ export default async options => {
28
30
  ...answers
29
31
  };
30
32
 
31
- const tasks = new Listr(
33
+ const customTasks = new Listr(
34
+ [
35
+ {
36
+ title: 'Validate config schema',
37
+ task: async () => {
38
+ await validate(componentKey, category);
39
+ }
40
+ },
41
+ {
42
+ title: 'Lint component',
43
+ task: async () => {
44
+ const targetDirectory = await getComponentDirectoryPath(componentKey, category);
45
+ // console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
46
+ await lintComponent(targetDirectory);
47
+ }
48
+ },
49
+ {
50
+ title: 'Bundle component',
51
+ task: async () => await bundleComponent(componentKey, sourceMap, devBuild, category),
52
+ },
53
+ {
54
+ title: 'Lint companion component',
55
+ task: async () => {
56
+ const targetDirectory = await getComponentDirectoryPath(componentKey, "constellation");
57
+ // console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
58
+ await lintComponent(targetDirectory);
59
+ }
60
+ },
61
+ {
62
+ title: 'Bundle companion component',
63
+ task: async () => await bundleComponent(componentKey, sourceMap, devBuild, "constellation")
64
+ }
65
+ ],
66
+ {
67
+ exitOnError: true
68
+ }
69
+ );
70
+
71
+ const overrideTasks = new Listr(
32
72
  [
33
73
  {
34
74
  title: 'Validate config schema',
@@ -47,7 +87,6 @@ export default async options => {
47
87
  {
48
88
  title: 'Bundle Component',
49
89
  task: async () => await bundleComponent(componentKey, sourceMap, devBuild, category),
50
- skip: () => (options.skipBundle ? 'Skipped bundling component' : undefined)
51
90
  }
52
91
  ],
53
92
  {
@@ -55,8 +94,16 @@ export default async options => {
55
94
  }
56
95
  );
57
96
 
58
- await tasks.run().catch(err => {
59
- console.log(chalk.bold.red(err.toString()));
60
- });
97
+ if (category == CATEGORY_CUSTOM) {
98
+ await customTasks.run().catch(err => {
99
+ console.log(chalk.bold.red(err.toString()));
100
+ });
101
+ }
102
+ else {
103
+ await overrideTasks.run().catch(err => {
104
+ console.log(chalk.bold.red(err.toString()));
105
+ });
106
+ }
107
+
61
108
  return true;
62
109
  };
@@ -2,14 +2,14 @@ import path from 'path';
2
2
  import fs from 'fs';
3
3
  import { stat } from 'fs/promises';
4
4
 
5
- import { BUILD_CONFIG_JSON_FILENAME } from '../../constants.js';
5
+ import { BUILD_CONFIG_JSON_FILENAME, CATEGORY_CUSTOM } from '../../constants.js';
6
6
  import { getComponentDirectoryPath } from '../../util.js';
7
7
 
8
8
  import buildComponent from './builder/index.js';
9
9
 
10
10
  const extensions = ['ts', 'tsx', 'js', 'jsx'];
11
11
 
12
- const bundleComponent = async (componentKey, sourceMap, devBuild, category = "custom") => {
12
+ const bundleComponent = async (componentKey, sourceMap, devBuild, category = CATEGORY_CUSTOM) => {
13
13
  const componentDirectory = await getComponentDirectoryPath(componentKey, category);
14
14
 
15
15
  const idx = (
@@ -9,6 +9,7 @@ import ncp from 'ncp';
9
9
  import chalk from 'chalk';
10
10
 
11
11
  import { checkPathAccess, getTokenUrl, showVersion } from '../../util.js';
12
+ import { CATEGORY_CONSTELLATION } from '../../constants.js';
12
13
 
13
14
 
14
15
  export const DXCB_CONFIG_JSON_FILENAME = 'dxcb.config.json';
@@ -31,12 +32,20 @@ import { COMPONENT_SCHEMA } from '../../constants.js';
31
32
  const copy = promisify(ncp);
32
33
 
33
34
  const copyComponentTemplate = async options => {
34
- return copy(options.templateDirectory, options.targetDirectory, {
35
- clobber: false
36
- });
35
+ if (options.targetDirectory) {
36
+ return copy(options.templateDirectory, options.targetDirectory, {
37
+ clobber: false
38
+ });
39
+ }
40
+ else {
41
+ return copy(options.templateDirectoryConstellation, options.targetDirectoryConstellation, {
42
+ clobber: false
43
+ });
44
+ }
45
+
37
46
  };
38
47
 
39
- const compileMustacheTemplates = async (
48
+ export const compileMustacheTemplates = async (
40
49
  componentDirectory,
41
50
  {
42
51
  componentKey,
@@ -151,17 +160,34 @@ const validateCompile = async (
151
160
  const templateDir = `./templates/${framework}/${type}/${sSubType}`;
152
161
  const templateDirectory = fileURLToPath(new URL(templateDir, import.meta.url));
153
162
 
163
+ const templateDirConstellation = `./templates/Constellation/${type}/${sSubType}`;
164
+ const templateDirectoryConstellation = fileURLToPath(new URL(templateDirConstellation, import.meta.url));
165
+
154
166
  const componentKey = `${organization}_${library}_${componentName}`;
155
167
 
156
168
  const typeLC = type.toLowerCase();
157
169
  const targetDirectory = await getComponentDirectoryPath(join(typeLC, "/",componentKey));
170
+ const targetDirectoryConstellation = await getComponentDirectoryPath(join(typeLC, "/",componentKey), CATEGORY_CONSTELLATION);
158
171
 
159
172
  const components = await getComponents(false);
160
173
  if (components.includes(componentKey)) {
161
174
  console.log(chalk.red(`${componentKey} component already exists in ${targetDirectory}`));
175
+
176
+ let componentsConstellation = await getComponents(false, CATEGORY_CONSTELLATION);
177
+ if (components.includes(componentKey)) {
178
+ console.log(chalk.red(`${componentKey} companion component already exists in ${targetDirectoryConstellation}`));
179
+ }
180
+
181
+ return;
182
+ }
183
+ // test for constellation
184
+ const componentsConstellation = await getComponents(false, CATEGORY_CONSTELLATION);
185
+ if (components.includes(componentKey)) {
186
+ console.log(chalk.red(`${componentKey} companion component already exists in ${targetDirectoryConstellation}`));
162
187
  return;
163
188
  }
164
189
 
190
+ // component
165
191
  await copyComponentTemplate({
166
192
  ...options,
167
193
  targetDirectory,
@@ -180,7 +206,27 @@ const validateCompile = async (
180
206
  allowedApplications
181
207
  });
182
208
 
209
+ // matching constellation
210
+ await copyComponentTemplate({
211
+ ...options,
212
+ targetDirectoryConstellation,
213
+ templateDirectoryConstellation
214
+ });
215
+ await compileMustacheTemplates(targetDirectoryConstellation, {
216
+ componentKey,
217
+ componentName,
218
+ componentLabel,
219
+ library,
220
+ version,
221
+ type,
222
+ subtype,
223
+ description,
224
+ organization,
225
+ allowedApplications
226
+ });
227
+
183
228
  console.log(chalk.green(`created ${componentKey} component in ${targetDirectory}`));
229
+ console.log(chalk.green(`created ${componentKey} companion component in ${targetDirectoryConstellation}`));
184
230
 
185
231
  };
186
232
 
@@ -1,7 +1,9 @@
1
1
  import { useState } from 'react';
2
- import { withKnobs, text, boolean } from '@storybook/addon-knobs';
2
+ import { withKnobs } from '@storybook/addon-knobs';
3
3
 
4
- import {{COMPONENT_CLASS_NAME}} from './index.jsx';
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('test value');
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
- getStateProps: () => {
26
- return { value: '.name' };
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
+ };
@@ -1,7 +1,8 @@
1
1
  import { useState } from 'react';
2
- import { withKnobs, text, boolean } from '@storybook/addon-knobs';
2
+ import { withKnobs } from '@storybook/addon-knobs';
3
+ import { configProps, fieldMetadata } from './mock.stories.js';
3
4
 
4
- import {{COMPONENT_CLASS_NAME}} from './index.jsx';
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('test value');
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
- 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')
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
+ };
@@ -1,7 +1,8 @@
1
1
  import { useState } from 'react';
2
- import { withKnobs, text, boolean } from '@storybook/addon-knobs';
2
+ import { withKnobs } from '@storybook/addon-knobs';
3
+ import { configProps, fieldMetadata } from './mock.stories.js';
3
4
 
4
- import {{COMPONENT_CLASS_NAME}} from './index.jsx';
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('test value');
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
- 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')
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
+ };
@@ -1,7 +1,8 @@
1
1
  import { useState } from 'react';
2
- import { withKnobs, text, boolean } from '@storybook/addon-knobs';
2
+ import { withKnobs } from '@storybook/addon-knobs';
3
+ import { configProps, fieldMetadata } from './mock.stories.js';
3
4
 
4
- import {{COMPONENT_CLASS_NAME}} from './index.jsx';
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('test value');
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
- 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
+ onChange: event => {
39
+ setValue(event.target.value);
40
+ },
41
+ onBlur: () => {
42
+ return configProps.value;
43
+ }
37
44
  };
38
45
 
39
46
  return (
@@ -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, text, boolean } from '@storybook/addon-knobs';
2
+ import { withKnobs } from '@storybook/addon-knobs';
3
+ import { configProps, fieldMetadata } from './mock.stories.js';
3
4
 
4
- import {{COMPONENT_CLASS_NAME}} from './index.jsx';
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('test value');
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
- 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')
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
+ };