@pega/custom-dx-components 2.0.4 → 2.0.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/README.md CHANGED
@@ -8,13 +8,13 @@ This project provides you with an environment to extend Constellation by giving
8
8
 
9
9
  Ensure you have access to the following in your system:
10
10
 
11
- - Pega Infinity Server version 8.7 and above
11
+ - Pega Infinity Server version 8.7 or later
12
12
 
13
- - Git version 2.30 and above
13
+ - Git version 2.30 or later
14
14
 
15
- - System node version latest 14
15
+ - System node version 16
16
16
 
17
- - System npm version latest 6
17
+ - System npm version 7
18
18
 
19
19
  ## Initialize a project
20
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/custom-dx-components",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -13,44 +13,44 @@
13
13
  "type": "module",
14
14
  "sideEffects": false,
15
15
  "dependencies": {
16
- "@babel/core": "^7.17.10",
17
- "@babel/plugin-proposal-class-properties": "^7.16.7",
18
- "@babel/preset-env": "^7.17.10",
19
- "@babel/preset-react": "^7.16.7",
16
+ "@babel/core": "^7.19.1",
17
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
18
+ "@babel/preset-env": "^7.19.1",
19
+ "@babel/preset-react": "^7.18.6",
20
20
  "adm-zip": "^0.5.9",
21
21
  "ajv": "^8.11.0",
22
- "arg": "^5.0.1",
22
+ "arg": "^5.0.2",
23
23
  "babel-loader": "^8.2.5",
24
24
  "chalk": "^5.0.1",
25
- "compression-webpack-plugin": "^9.2.0",
25
+ "compression-webpack-plugin": "^10.0.0",
26
26
  "css-loader": "6.7.1",
27
- "css-minimizer-webpack-plugin": "^3.4.1",
27
+ "css-minimizer-webpack-plugin": "^4.1.0",
28
28
  "execa": "^6.1.0",
29
29
  "file-loader": "6.2.0",
30
30
  "fs-extra": "^10.1.0",
31
31
  "gitignore": "^0.7.0",
32
- "inquirer": "^8.2.4",
32
+ "inquirer": "^9.1.1",
33
33
  "listr": "^0.14.3",
34
- "mini-css-extract-plugin": "2.6.0",
34
+ "mini-css-extract-plugin": "2.6.1",
35
35
  "mustache": "^4.2.0",
36
36
  "ncp": "^2.0.0",
37
- "node-fetch": "^3.2.4",
38
- "ora": "^6.1.0",
37
+ "node-fetch": "^3.2.10",
38
+ "ora": "^6.1.2",
39
39
  "pascalcase": "^2.0.0",
40
- "postcss": "^8.4.13",
41
- "postcss-loader": "6.2.1",
42
- "postcss-preset-env": "7.5.0",
40
+ "postcss": "^8.4.16",
41
+ "postcss-loader": "7.0.1",
42
+ "postcss-preset-env": "7.8.2",
43
43
  "prop-types": "^15.8.1",
44
- "react": "^17.0.2",
44
+ "react": "^18.2.0",
45
45
  "react-dev-utils": "^12.0.1",
46
- "resolve": "1.22.0",
46
+ "resolve": "1.22.1",
47
47
  "resolve-url-loader": "^5.0.0",
48
- "sass-loader": "^12.6.0",
49
- "terser-webpack-plugin": "5.3.1",
50
- "ts-loader": "^9.3.0",
51
- "typescript": "^4.6.4",
48
+ "sass-loader": "^13.0.2",
49
+ "terser-webpack-plugin": "5.3.6",
50
+ "ts-loader": "^9.3.1",
51
+ "typescript": "^4.8.3",
52
52
  "url-loader": "4.1.1",
53
- "webpack": "5.72.1"
53
+ "webpack": "5.74.0"
54
54
  },
55
55
  "author": "Custom component dev",
56
56
  "license": "SEE LICENSE IN LICENSE",
@@ -60,8 +60,8 @@
60
60
  ],
61
61
  "devDependencies": {
62
62
  "@pega/configs": "^0.3.3",
63
- "cspell": "^5.20.0",
64
- "eslint": "^8.15.0",
65
- "prettier": "2.6.2"
63
+ "cspell": "^6.9.0",
64
+ "eslint": "^8.23.1",
65
+ "prettier": "2.7.1"
66
66
  }
67
- }
67
+ }
package/src/constants.js CHANGED
@@ -25,6 +25,10 @@ export const COMPONENT_SCHEMA = {
25
25
  {
26
26
  name: 'Widget',
27
27
  value: 'Widget'
28
+ },
29
+ {
30
+ name: 'Table',
31
+ value: 'Table'
28
32
  }
29
33
  ],
30
34
  subtype: {
@@ -30,7 +30,13 @@ const generateAccessToken = async config => {
30
30
  headers: { 'content-type': 'application/x-www-form-urlencoded' },
31
31
  body: formData.toString()
32
32
  })
33
- .then(response => response.json())
33
+ .then(response => {
34
+ if (response.ok && response.status === 200) {
35
+ return response.json();
36
+ } else {
37
+ throw new Error(`Failed with status: ${response.status}`);
38
+ }
39
+ })
34
40
  .then(data => {
35
41
  if (data && data.errors) {
36
42
  const errMessages = data.errors;
@@ -269,6 +269,23 @@ export default async options => {
269
269
  return 'Please select subtype';
270
270
  }
271
271
  },
272
+ {
273
+ name: 'subtype',
274
+ type: 'rawlist',
275
+ message: 'Enter subtype of component',
276
+ default: [componentDefaults.subtype || COMPONENT_SCHEMA.subtype.table[0]],
277
+ choices: COMPONENT_SCHEMA.subtype.table,
278
+ when(answers) {
279
+ return answers.type === 'Table';
280
+ },
281
+ validate: value => {
282
+ /* value should not be empty */
283
+ if (Array.isArray(value) && value.length) {
284
+ return true;
285
+ }
286
+ return 'Please select subtype';
287
+ }
288
+ },
272
289
  {
273
290
  name: 'description',
274
291
  message: 'Enter description for the component',
@@ -8,13 +8,13 @@ This project provides you with an environment to extend Constellation by giving
8
8
 
9
9
  Ensure you have access to the following in your system:
10
10
 
11
- - Pega Infinity Server version 8.7 and above
11
+ - Pega Infinity Server version 8.7 or later
12
12
 
13
- - Git version 2.30 and above
13
+ - Git version 2.30 or later
14
14
 
15
- - System node version latest 14
15
+ - System node version 16
16
16
 
17
- - System npm version latest 6
17
+ - System npm version 7
18
18
 
19
19
  ## Initialize a project
20
20
 
@@ -35,35 +35,35 @@
35
35
  "license": "Enter License",
36
36
  "sideEffects": false,
37
37
  "dependencies": {
38
- "@pega/cosmos-react-core": "^3.0.0-dev.16.0",
38
+ "@pega/cosmos-react-core": "^3.0.0-rc.4",
39
+ "@storybook/addon-knobs": "^6.3.1",
39
40
  "polished": "^4.2.2",
41
+ "prop-types": "^15.8.1",
40
42
  "react": "^17.0.2",
41
43
  "react-autosuggest": "^10.1.0",
42
44
  "react-dom": "^17.0.2",
43
- "react-player": "^2.9.0",
44
- "styled-components": "^5.3.5",
45
- "prop-types": "^15.8.1",
46
- "@storybook/addon-knobs": "^6.3.1"
45
+ "react-player": "^2.10.1",
46
+ "styled-components": "^5.3.5"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@pega/configs": "^0.3.3",
50
- "@pega/custom-dx-components": "^2.0.4",
51
- "@storybook/addon-actions": "^6.4.22",
52
- "@storybook/addon-essentials": "^6.4.22",
53
- "@storybook/addon-links": "^6.4.22",
54
- "@storybook/addon-storysource": "^6.4.22",
55
- "@storybook/builder-webpack5": "^6.4.22",
56
- "@storybook/manager-webpack5": "^6.4.22",
57
- "@storybook/react": "^6.4.22",
50
+ "@pega/custom-dx-components": "^2.0.6",
51
+ "@storybook/addon-actions": "^6.5.12",
52
+ "@storybook/addon-essentials": "^6.5.12",
53
+ "@storybook/addon-links": "^6.5.12",
54
+ "@storybook/addon-storysource": "^6.5.12",
55
+ "@storybook/builder-webpack5": "^6.5.12",
56
+ "@storybook/manager-webpack5": "^6.5.12",
57
+ "@storybook/react": "^6.5.12",
58
58
  "@types/emoji-mart": "^3.0.9",
59
59
  "@types/react": "^17.0.39",
60
60
  "@types/react-color": "^3.0.6",
61
61
  "@types/react-dom": "^17.0.11",
62
- "@types/styled-components": "^5.1.25",
63
- "eslint": "^8.15.0",
62
+ "@types/styled-components": "^5.1.26",
63
+ "eslint": "^8.23.1",
64
64
  "npm-run-all": "^4.1.5",
65
- "prettier": "2.6.2",
66
- "stylelint": "^14.8.2",
67
- "typescript": "~4.6.4"
65
+ "prettier": "2.7.1",
66
+ "stylelint": "^14.11.0",
67
+ "typescript": "~4.8.3"
68
68
  }
69
69
  }
@@ -1,10 +0,0 @@
1
- import MBTAListComp from './MBTAList';
2
-
3
- export default {
4
- title: 'MBTAList',
5
- component: MBTAListComp
6
- };
7
-
8
- export const MBTAList = () => {
9
- return <MBTAListComp />;
10
- };
@@ -1,122 +0,0 @@
1
- import { useEffect, useState, useContext } from 'react';
2
- import {
3
- Flex,
4
- SummaryList,
5
- SummaryListItem,
6
- ViewAll,
7
- ModalManagerContext,
8
- Modal,
9
- registerIcon,
10
- Icon,
11
- MetaList,
12
- MetaListProps
13
- } from '@pega/cosmos-react-core';
14
-
15
- import * as accessibleIcon from './icons/accessible.icon';
16
- import * as busIcon from './icons/bus.icon';
17
- import * as mbtaIcon from './icons/mbta.icon';
18
- import * as subwayIcon from './icons/subway.icon';
19
-
20
- registerIcon(accessibleIcon, busIcon, mbtaIcon, subwayIcon);
21
-
22
- export interface MBTAListProps {}
23
-
24
- const params = new URLSearchParams([
25
- ['page[offset]', '0'],
26
- ['page[limit]', '1000'],
27
- ['filter[latitude]', '42.362339984866466'],
28
- ['filter[longitude]', '-71.07999650212442'],
29
- ['filter[radius]', '0.01'],
30
- ['filter[route_type]', '1,3']
31
- ]);
32
-
33
- const MBTAList = (props: MBTAListProps) => {
34
- const [items, setItems] = useState<SummaryListItem[]>();
35
- const [error, setError] = useState<string>();
36
- const { create } = useContext(ModalManagerContext);
37
-
38
- useEffect(() => {
39
- const controller = new AbortController();
40
-
41
- fetch(`https://api-v3.mbta.com/stops?${params}`, { signal: controller.signal })
42
- .then(async res => {
43
- if (!res.ok) throw new Error(`Responded with "${res.status}"`);
44
-
45
- const { data } = await res.json();
46
- if (controller.signal.aborted) return;
47
-
48
- setItems(
49
- // TODO: Type the api response: https://api-v3.mbta.com/docs/swagger/index.html#/Stop/ApiWeb_StopController_index
50
- data.map(({ id, attributes }: any) => {
51
- const meta: MetaListProps['items'] = [];
52
-
53
- if (attributes.wheelchair_boarding) {
54
- meta.push(
55
- <>
56
- <Icon name='accessible' style={{ width: '1em', height: '1em' }} />
57
- &nbsp;Wheelchair boarding
58
- </>
59
- );
60
- }
61
-
62
- if (attributes.vehicle_type === 1) {
63
- meta.push(attributes.platform_name);
64
- return {
65
- id,
66
- visual: <Icon name='subway' />,
67
- primary: attributes.name,
68
- secondary: <MetaList items={meta} />
69
- };
70
- }
71
-
72
- meta.push(attributes.name);
73
- return {
74
- id,
75
- visual: <Icon name='bus' />,
76
- primary: attributes.on_street,
77
- secondary: <MetaList items={meta} />
78
- };
79
- })
80
- );
81
- })
82
- .catch((err: unknown) => {
83
- if (controller.signal.aborted) return;
84
-
85
- if (err instanceof Error) {
86
- setError(err.message);
87
- } else {
88
- setError('An error occurred.');
89
- }
90
- });
91
-
92
- return () => {
93
- controller.abort();
94
- };
95
- }, []);
96
-
97
- return (
98
- <SummaryList
99
- {...props}
100
- icon='mbta'
101
- name='Stops near Pega'
102
- count={items?.length}
103
- items={items?.slice(0, 3) ?? []}
104
- loading={!items && !error}
105
- error={error ? { message: error } : undefined}
106
- onViewAll={() => {
107
- create(Modal, {
108
- heading: (
109
- <Flex container={{ gap: 1, alignItems: 'center' }}>
110
- <Icon name='mbta' />
111
- Stops near Pega
112
- </Flex>
113
- ),
114
- count: items?.length,
115
- children: <ViewAll items={items ?? []} />
116
- });
117
- }}
118
- />
119
- );
120
- };
121
-
122
- export default MBTAList;
@@ -1,14 +0,0 @@
1
- // FontAwesome "accessible" icon
2
- // https://fontawesome.com/license
3
- // Converted from SVG to Cosmos Icon format
4
-
5
- export const name = 'accessible';
6
-
7
- export const Component = () => (
8
- <path
9
- fill='currentColor'
10
- d='M423.9 255.8L411 413.1c-3.3 40.7-63.9 35.1-60.6-4.9l10-122.5-41.1 2.3c10.1 20.7 15.8 43.9 15.8 68.5 0 41.2-16.1 78.7-42.3 106.5l-39.3-39.3c57.9-63.7 13.1-167.2-74-167.2-25.9 0-49.5 9.9-67.2 26L73 243.2c22-20.7 50.1-35.1 81.4-40.2l75.3-85.7-42.6-24.8-51.6 46c-30 26.8-70.6-18.5-40.5-45.4l68-60.7c9.8-8.8 24.1-10.2 35.5-3.6 0 0 139.3 80.9 139.5 81.1 16.2 10.1 20.7 36 6.1 52.6L285.7 229l106.1-5.9c18.5-1.1 33.6 14.4 32.1 32.7zm-64.9-154c28.1 0 50.9-22.8 50.9-50.9C409.9 22.8 387.1 0 359 0c-28.1 0-50.9 22.8-50.9 50.9 0 28.1 22.8 50.9 50.9 50.9zM179.6 456.5c-80.6 0-127.4-90.6-82.7-156.1l-39.7-39.7C36.4 287 24 320.3 24 356.4c0 130.7 150.7 201.4 251.4 122.5l-39.7-39.7c-16 10.9-35.3 17.3-56.1 17.3z'
11
- />
12
- );
13
-
14
- export const viewBox = '0 0 448 512';
@@ -1,13 +0,0 @@
1
- export const name = 'bus';
2
-
3
- export const Component = () => (
4
- <>
5
- <path d='m12.06 24c6.72-.17 12.11-5.64 11.94-12.06a12 12 0 1 0 -11.94 12.06' fill='#ffc72c' />
6
- <path
7
- d='m18.78 10.67-.66-5.17c-.16-.93-.75-1.3-1.63-1.68a14.25 14.25 0 0 0 -4.49-.82 14.32 14.32 0 0 0 -4.5.82c-.86.37-1.45.75-1.63 1.68l-.66 5.17v7.15h1.17v1.25a1 1 0 0 0 1.91 0v-1.25h7.45v1.25a.91.91 0 0 0 .48.8 1 1 0 0 0 1 0 .88.88 0 0 0 .47-.8v-1.25h1.13zm-9.57-6.36h5.61a.42.42 0 0 1 .43.41.42.42 0 0 1 -.43.42h-5.61a.43.43 0 0 1 -.43-.42.42.42 0 0 1 .43-.41zm-2.79 6.21.58-4.09a.54.54 0 0 1 .51-.43h9.06a.56.56 0 0 1 .54.44l.54 4.09a.33.33 0 0 1 0 .14.49.49 0 0 1 -.16.37.54.54 0 0 1 -.38.15h-10.17a.56.56 0 0 1 -.38-.19.57.57 0 0 1 -.14-.38.33.33 0 0 1 0-.1zm.92 5.09a1 1 0 1 1 1-1 1 1 0 0 1 -.3.7 1 1 0 0 1 -.7.3zm9.36 0a1 1 0 1 1 1-1 1 1 0 0 1 -.3.7 1.06 1.06 0 0 1 -.72.29z'
8
- fill='#1c1e23'
9
- />
10
- </>
11
- );
12
-
13
- export const viewBox = '0 0 24 24';
@@ -1,10 +0,0 @@
1
- export const name = 'mbta';
2
-
3
- export const Component = () => (
4
- <>
5
- <circle cx='250' cy='250' r='239' stroke='#000' strokeWidth='22' fill='#fff' />
6
- <path d='M92,138.5h316v79.5h-118.25v194h-79.5v-194h-118.25z' />
7
- </>
8
- );
9
-
10
- export const viewBox = '0 0 500 500';
@@ -1,14 +0,0 @@
1
- export const name = 'subway';
2
-
3
- export const Component = () => (
4
- <>
5
- <path d='m24 0a24 24 0 1 0 24 24 24 24 0 0 0 -24-24' fill='#494f5b' />
6
- <g fill='#fff'>
7
- <path d='m25.8889 5.8222a1.4111 1.4111 0 1 0 -1.4111-1.4111 1.411 1.411 0 0 0 1.4111 1.4111z' />
8
- <path d='m31.4555 34.2111a4.9779 4.9779 0 0 0 3.889-4.8222v-18.1445a5.0112 5.0112 0 0 0 -5.0778-4.9111h-12.5333a5.0112 5.0112 0 0 0 -5.1 4.9v18.1556a4.9779 4.9779 0 0 0 3.8889 4.8222l-5.8556 8.7889h3.4l4.1889-6.1445h11.5555l4.1889 6.1445h3.3333zm-10.7555-25.9889a.8445.8445 0 0 1 .8445-.8111h4.9555a.8444.8444 0 0 1 .8333.8111v1.4445l-.0006.0339a.8334.8334 0 0 1 -.866.7994l-4.9222-.0111a.8333.8333 0 0 1 -.8445-.8222zm-3.1111 23.3334a2.2223 2.2223 0 1 1 2.2222-2.2223 2.2223 2.2223 0 0 1 -2.2222 2.2223zm.2889-11.8112c-.0758.0036-.1518.0036-.2276 0a2.4221 2.4221 0 0 1 -2.3057-2.5333v-3.2667a2.4109 2.4109 0 0 1 2.5333-2.5444h12.2222a2.4113 2.4113 0 0 1 2.5333 2.5444v3.2667q.0054.1137 0 .2276a2.4221 2.4221 0 0 1 -2.5333 2.3057zm12.4333 11.8112a2.2334 2.2334 0 1 1 .0223 0z' />
9
- <path d='m22.1445 5.8222h-.0334.0337a1.4113 1.4113 0 1 0 -1.4115-1.4115 1.4111 1.4111 0 0 0 1.4115 1.4119z' />
10
- </g>
11
- </>
12
- );
13
-
14
- export const viewBox = '0 0 48 48';
@@ -1,2 +0,0 @@
1
- export { default } from './MBTAList';
2
- export type { MBTAListProps } from './MBTAList';