@pega/custom-dx-components 0.0.1

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 (71) hide show
  1. package/.eslintrc.json +18 -0
  2. package/.prettierignore +2 -0
  3. package/.prettierrc.json +1 -0
  4. package/.vscode/extensions.json +9 -0
  5. package/.vscode/settings.json +48 -0
  6. package/LICENSE +185 -0
  7. package/README.md +204 -0
  8. package/bin/index.js +5 -0
  9. package/cspell.json +26 -0
  10. package/package.json +67 -0
  11. package/src/cli.js +92 -0
  12. package/src/constants.js +92 -0
  13. package/src/tasks/authenticate/helper.js +60 -0
  14. package/src/tasks/authenticate/index.js +75 -0
  15. package/src/tasks/create/index.js +304 -0
  16. package/src/tasks/create/template/config.json.mustache +67 -0
  17. package/src/tasks/create/template/demo.stories.jsx.mustache +44 -0
  18. package/src/tasks/create/template/index.jsx.mustache +55 -0
  19. package/src/tasks/create/template/styles.js.mustache +7 -0
  20. package/src/tasks/delete/helper.js +105 -0
  21. package/src/tasks/delete/index.js +45 -0
  22. package/src/tasks/index.js +9 -0
  23. package/src/tasks/init/helper.js +63 -0
  24. package/src/tasks/init/index.js +165 -0
  25. package/src/tasks/init/template/.eslintrc.json +10 -0
  26. package/src/tasks/init/template/.prettierrc.json +1 -0
  27. package/src/tasks/init/template/.storybook/main.js +6 -0
  28. package/src/tasks/init/template/.storybook/pega-logo.svg +16 -0
  29. package/src/tasks/init/template/.storybook/preview.tsx +44 -0
  30. package/src/tasks/init/template/.storybook/theme.js +44 -0
  31. package/src/tasks/init/template/.stylelintrc.json +4 -0
  32. package/src/tasks/init/template/.vscode/extensions.json +9 -0
  33. package/src/tasks/init/template/.vscode/settings.json +48 -0
  34. package/src/tasks/init/template/README.md +204 -0
  35. package/src/tasks/init/template/build.config.json +1 -0
  36. package/src/tasks/init/template/cspell.json +14 -0
  37. package/src/tasks/init/template/package.json.mustache +69 -0
  38. package/src/tasks/init/template/src/components/MBTAList/MBTAList.stories.tsx +10 -0
  39. package/src/tasks/init/template/src/components/MBTAList/MBTAList.tsx +122 -0
  40. package/src/tasks/init/template/src/components/MBTAList/icons/accessible.icon.tsx +14 -0
  41. package/src/tasks/init/template/src/components/MBTAList/icons/bus.icon.tsx +13 -0
  42. package/src/tasks/init/template/src/components/MBTAList/icons/mbta.icon.tsx +10 -0
  43. package/src/tasks/init/template/src/components/MBTAList/icons/subway.icon.tsx +14 -0
  44. package/src/tasks/init/template/src/components/MBTAList/index.ts +2 -0
  45. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURL.stories.tsx +19 -0
  46. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURL.styles.ts +5 -0
  47. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURL.types.ts +10 -0
  48. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURLDisplay.tsx +25 -0
  49. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURLInput.tsx +24 -0
  50. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/config.json +13 -0
  51. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/index.ts +2 -0
  52. package/src/tasks/init/template/src/components/Organization_Library_VideoPlayer/config.json +44 -0
  53. package/src/tasks/init/template/src/components/Organization_Library_VideoPlayer/demo.stories.jsx +40 -0
  54. package/src/tasks/init/template/src/components/Organization_Library_VideoPlayer/index.jsx +42 -0
  55. package/src/tasks/init/template/src/components/Organization_Library_VideoPlayer/styles.js +5 -0
  56. package/src/tasks/init/template/tasks.config.json +21 -0
  57. package/src/tasks/init/template/tsconfig.build.json +16 -0
  58. package/src/tasks/init/template/tsconfig.json +8 -0
  59. package/src/tasks/list/helper.js +118 -0
  60. package/src/tasks/list/index.js +51 -0
  61. package/src/tasks/publish/bundle/builder/index.js +174 -0
  62. package/src/tasks/publish/bundle/builder/modules.js +139 -0
  63. package/src/tasks/publish/bundle/builder/paths.js +50 -0
  64. package/src/tasks/publish/bundle/builder/webpack.config.js +334 -0
  65. package/src/tasks/publish/bundle/index.js +65 -0
  66. package/src/tasks/publish/helper.js +145 -0
  67. package/src/tasks/publish/index.js +55 -0
  68. package/src/tasks/update/index.js +5 -0
  69. package/src/tasks/upgrade/index.js +31 -0
  70. package/src/tasks/validator/index.js +102 -0
  71. package/src/util.js +277 -0
@@ -0,0 +1,204 @@
1
+ # Using Custom Components in Constellation
2
+
3
+ ## Overview
4
+
5
+ This project provides you with an environment to extend Constellation by giving you tools to create and publish custom components that are not available from the Constellation installation.
6
+
7
+ ## Prerequisites
8
+
9
+ Ensure you have access to the following in your system:
10
+
11
+ - Pega Infinity Server version 8.7 and above
12
+
13
+ - Git version 2.30 and above
14
+
15
+ - System node version 14 and above
16
+
17
+ - System npm version 6 and above
18
+
19
+ ## Initialize a project
20
+
21
+ Initialize the project by performing the following procedure in a terminal:
22
+
23
+ 1. Enter the following command to initialize the project.
24
+ `npx @pega/custom-dx-components init`
25
+
26
+ 2. If prompted, enter `y` to install the Custom UI Components package.
27
+ You will then be asked to set up the project by entering the required details.
28
+
29
+ 3. Enter the following details:
30
+ - Name of the project (required)
31
+ Example - `mycustomcomponents`
32
+ - Name of the organization (required)
33
+ Example - `customorg`
34
+ - Version (required)
35
+ Example - `1.0.0`
36
+ - Description of the project (optional)
37
+ Example - `This project is intended to create and publish a custom component.`
38
+ - Git repository URL (optional)
39
+ Example - `https://git.custom-components.io/custom-cc.git`
40
+ - Author (optional)
41
+ Example - `Michelle`
42
+
43
+ The workspace is now set up to create custom components and publish them to the server.
44
+
45
+ ## Create custom components
46
+
47
+ Create custom components using the following procedure:
48
+
49
+ 1. Enter the following command to create a component:
50
+ `npm run create`
51
+ You will then be asked to enter or review the following details of the component:
52
+ - Name of the component (required)
53
+ Example - `customcomp0`
54
+ - Name of component label (required)
55
+ Example - `custom component`
56
+ - Name of the library (required)
57
+ Example - `basic`
58
+ - Component version (required)
59
+ Example - `0.0.1`
60
+ - Type of component (required)
61
+ Example - `Field`
62
+ - Sub-type of component (required)
63
+ Example - `Text`
64
+ - Description of the component (optional)
65
+ Example - `This is a customized searchbox that filters data.`
66
+ The component is created in the following path: _/Users/your_user_name/project_name/src/components/component_name_
67
+ You can also pre-configure the values for the above options in a tasks.config.json file as shown below.
68
+
69
+ ```json
70
+ {
71
+ "component": {
72
+ "library": "basic",
73
+ "type": "field",
74
+ "subtype": "text",
75
+ "description": "basic field for capturing textual data",
76
+ "icon": "basic-field-text.svg"
77
+ }
78
+ }
79
+ ```
80
+ >**Note**:
81
+ Alternatively, you can enter the following command to skip entering the details of the component now and can manually enter the details in the config.json file after the component is created:
82
+ `npm run create <enter_component_name>`
83
+
84
+ A _src/components_ folder is created and the necessary files required to build the component are initialized as seen below.
85
+
86
+ ```sh
87
+ ├── src
88
+    ├── components
89
+ ├── <component_name>
90
+ ├── index.js
91
+ ├── demo.stories.js
92
+ ├── config.json
93
+ ```
94
+
95
+
96
+ The *index.js* file contains the actual component rendering logic.
97
+ The *demo.stories.js* file contains the demo that can be viewed in the storybook.
98
+ The *config.json* file contains the mapping of properties for configuring the auto generated property panel. This property panel appears in AppStudio when an application is being authored to use the custom component.
99
+
100
+
101
+ 2. Enter the following command to start the storybook to view the demo.
102
+ `npm start`
103
+
104
+ 3. Modify the source files to build your own component. You can also install and import third-party libraries if required for your component.
105
+
106
+ The custom component is now created. We use the information provided to create uniquely namespaced components in this convention - `<organization>_<library>_<component name>`.
107
+
108
+ ## Authenticate the user
109
+ Before we publish the custom component to the Pega Infinity Server, authenticate the user to access the resources in the Pega Infinity Server.
110
+
111
+ >**Note**:
112
+ It is required that you configure a value for clientId, clientSecret, and accessTokenUri.
113
+ 1. Login to Pega Infinity Server, navigate to Records / Security / OAuth 2.0 Client Registration landing page and open the *DX-CustomComponents* record.
114
+ 2. Click **Regenerate Client Secret**, download the Client Credentials (as the Client ID, Client Secret, and Access token endpoint will be needed), and save the record.
115
+ 3. Update the the task.config.json file with these downloaded values:
116
+ ```json
117
+ "server-config": {
118
+ "server": "https://127.0.0.1:8080/prweb",
119
+ "user": "customcomponentoperator",
120
+ "password": "pwd",
121
+ "clientId": "<mention client ID here>",
122
+ "clientSecret": "<mention client secret here>",
123
+ "accessTokenUri": "https://127.0.0.1:8080/prweb/PRRestService/oauth2/v1/token"
124
+ },
125
+ ```
126
+ 4. Enter the following command to initiate authentication.
127
+ `npm run authenticate`
128
+
129
+ The user is now authenticated and can proceed to either publish or list the components.
130
+
131
+ ## Publish custom components
132
+ Enter the following command to publish custom components to Pega Infinity Server:
133
+ `npm run publish`
134
+ Publish the finalized custom components changes to Pega Infinity Server so that it can be discoverable in authoring (design palette).
135
+ You will then be asked to enter the following details:
136
+
137
+ - The component to be published to Pega Infinity Server. It will be updated if the component exists.
138
+ - The name of the ruleset where the component must be published.
139
+ - The version of the ruleset where the component must be published.
140
+ - Specify if the development build should be generated for debugging.
141
+ You can also pre-configure the values for the above options in a tasks.config.json file as shown below. The server, user name, and password must be pre-configured.
142
+
143
+ ```json
144
+ {
145
+ "components-server-config": {
146
+ "server": "http://127.0.0.1:8080/prweb",
147
+ "user": "customcomponentoperator",
148
+ "password": "pwd"
149
+ "rulesetName": "TestPega-C11nGall",
150
+ "rulesetVersion": "01-01-03",
151
+ "sourceOfComponents": "Server",
152
+ "devBuild": false,
153
+ }
154
+ }
155
+ ```
156
+ When the component is successfully published, you can use the newly published component in App Studio's view authoring.
157
+
158
+
159
+ >**Note**:
160
+ The Rule-UI-Component instance (with component name) is created on the Pega Infinity Server after publishing the component.
161
+
162
+ ## List custom components
163
+ View the available components in the local machine or the server.
164
+
165
+ Enter the following command to list custom components:
166
+ `npm run list`
167
+
168
+ You will then be asked to enter the following details:
169
+
170
+ - List components from Server or Local?
171
+ Example - `Server`
172
+
173
+ The custom components will now be listed in the terminal.
174
+
175
+ ## Delete custom components
176
+ Delete the available or published components in the local machine or the server.
177
+
178
+ Enter the following command to delete custom components:
179
+ `npm run delete`
180
+
181
+ You will then be asked to enter the following details:
182
+
183
+ - Delete components from Server or Local?
184
+ Example - `Local`
185
+
186
+ - Select component to delete
187
+ The list of available components in the following path will be displayed: _/Users/your_user_name/project_name/src/components
188
+ Select the component to be deleted from this list.
189
+
190
+ - Are you sure?
191
+ Example - `yes`
192
+
193
+ >**Note**:
194
+ If you choose to delete components from the server, the successfully published components along with their ruleset name and ruleset version from the Pega Infinity Server will be displayed. Select the component to be deleted from this list.
195
+
196
+ ## View existing custom components in storybook
197
+ View custom components in a storybook by performing the following procedure:
198
+ 1. Enter the following command to open the project.
199
+ `cd <enter your project's name>`
200
+
201
+ 2. Enter the following command to start the storybook in development mode.
202
+ `npm start`
203
+
204
+ The storybook is launched in a browser where you can view the components working in isolation.
@@ -0,0 +1,14 @@
1
+ {
2
+ "version": "0.2",
3
+ "import": "@pega/cspell-config",
4
+ "language": "en-US",
5
+ "ignorePaths": [
6
+ "package-lock.json",
7
+ "**/*.tsbuildinfo",
8
+ "**/node_modules/**",
9
+ "lib",
10
+ "**/.DS_Store",
11
+ "**/*.zip",
12
+ "**/*.tgz"
13
+ ]
14
+ }
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "{{projectName}}",
3
+ "version": "{{version}}",
4
+ "description": "{{description}}",
5
+ "organization": "{{organization}}",
6
+ "main": "src/index.js",
7
+ "scripts": {
8
+ "start": "start-storybook --port 6040 --quiet",
9
+ "build": "tsc -b tsconfig.build.json",
10
+ "lint": "run-p -cl lint:*",
11
+ "fix": "run-p -cl fix:*",
12
+ "authenticate": "custom-dx-components authenticate",
13
+ "create": "custom-dx-components create",
14
+ "publish": "custom-dx-components publish",
15
+ "list": "custom-dx-components list",
16
+ "validate-schema": "custom-dx-components validateSchema",
17
+ "update": "custom-dx-components update",
18
+ "delete": "custom-dx-components delete",
19
+ "lint:types": "tsc --noEmit",
20
+ "lint:es": "eslint .",
21
+ "lint:styles": "stylelint \"./**/*.@(js|jsx|ts|tsx)\"",
22
+ "lint:format": "prettier -c .",
23
+ "lint:spelling": "cspell --no-progress **/*",
24
+ "fix:es": "eslint --fix .",
25
+ "fix:format": "prettier -w ."
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": ""
30
+ },
31
+ "keywords": [
32
+ "pega"
33
+ ],
34
+ "author": "",
35
+ "license": "Enter License",
36
+ "sideEffects": false,
37
+ "dependencies": {
38
+ "@pega/cosmos-react-core": "^3.0.0-dev.3.0",
39
+ "polished": "^4.1.4",
40
+ "react": "^17.0.2",
41
+ "react-autosuggest": "^10.1.0",
42
+ "react-dom": "^17.0.2",
43
+ "react-player": "^2.9.0",
44
+ "styled-components": "^5.3.3",
45
+ "prop-types": "^15.8.1",
46
+ "@storybook/addon-knobs": "^6.3.1"
47
+ },
48
+ "devDependencies": {
49
+ "@pega/configs": "^0.3.2",
50
+ "@pega/custom-dx-components": "^0.0.1",
51
+ "@storybook/addon-actions": "^6.4.19",
52
+ "@storybook/addon-essentials": "^6.4.19",
53
+ "@storybook/addon-links": "^6.4.19",
54
+ "@storybook/addon-storysource": "^6.4.19",
55
+ "@storybook/builder-webpack5": "^6.4.19",
56
+ "@storybook/manager-webpack5": "^6.4.19",
57
+ "@storybook/react": "^6.4.19",
58
+ "@types/emoji-mart": "^3.0.9",
59
+ "@types/react": "^17.0.39",
60
+ "@types/react-color": "^3.0.6",
61
+ "@types/react-dom": "^17.0.11",
62
+ "@types/styled-components": "^5.1.22",
63
+ "eslint": "^8.9.0",
64
+ "npm-run-all": "^4.1.5",
65
+ "prettier": "2.5.1",
66
+ "stylelint": "^14.5.1",
67
+ "typescript": "~4.5.5"
68
+ }
69
+ }
@@ -0,0 +1,10 @@
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
+ };
@@ -0,0 +1,122 @@
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;
@@ -0,0 +1,14 @@
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';
@@ -0,0 +1,13 @@
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';
@@ -0,0 +1,10 @@
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';
@@ -0,0 +1,14 @@
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';
@@ -0,0 +1,2 @@
1
+ export { default } from './MBTAList';
2
+ export type { MBTAListProps } from './MBTAList';
@@ -0,0 +1,19 @@
1
+ import type { Meta, Story } from '@storybook/react';
2
+
3
+ import MediaURLInput from './MediaURLInput';
4
+ import MediaURLDisplay from './MediaURLDisplay';
5
+
6
+ export default {
7
+ title: 'MediaURL',
8
+ parameters: {
9
+ layout: 'centered'
10
+ }
11
+ } as Meta;
12
+
13
+ export const InputMode: Story = () => {
14
+ return <MediaURLInput label='Media src url' />;
15
+ };
16
+
17
+ export const DisplayMode: Story = () => {
18
+ return <MediaURLDisplay value='https://youtu.be/BxogmCLpy0w' />;
19
+ };
@@ -0,0 +1,5 @@
1
+ import styled, { css } from 'styled-components';
2
+
3
+ export default styled.div(() => {
4
+ return css``;
5
+ });
@@ -0,0 +1,10 @@
1
+ import type { FormControlProps, OmitStrict, URLDisplayProps } from '@pega/cosmos-react-core';
2
+
3
+ export interface MediaURLInputProps extends OmitStrict<FormControlProps, 'defaultValue'> {
4
+ testId?: string;
5
+ }
6
+
7
+ export interface MediaURLDisplayProps extends OmitStrict<URLDisplayProps, 'variant' | 'ref'> {
8
+ variant?: 'player' | URLDisplayProps['variant'];
9
+ testId?: string;
10
+ }
@@ -0,0 +1,25 @@
1
+ import type { FunctionComponent } from 'react';
2
+ import { URLDisplay } from '@pega/cosmos-react-core';
3
+ import ReactPlayer from 'react-player';
4
+
5
+ import StyledMediaURLDisplay from './MediaURL.styles';
6
+ import type { MediaURLDisplayProps } from './MediaURL.types';
7
+
8
+ const MediaURLDisplay: FunctionComponent<MediaURLDisplayProps> = ({
9
+ value,
10
+ variant = 'player',
11
+ testId,
12
+ ...restProps
13
+ }) => {
14
+ if ((!value && variant !== 'player') || variant !== 'player') {
15
+ return <URLDisplay value={value} variant={variant} {...restProps} />;
16
+ }
17
+
18
+ return (
19
+ <StyledMediaURLDisplay data-testid={testId}>
20
+ <ReactPlayer url={value} />
21
+ </StyledMediaURLDisplay>
22
+ );
23
+ };
24
+
25
+ export default MediaURLDisplay;
@@ -0,0 +1,24 @@
1
+ import { ChangeEvent, FunctionComponent, useState } from 'react';
2
+ import { Input } from '@pega/cosmos-react-core';
3
+
4
+ import type { MediaURLInputProps } from './MediaURL.types';
5
+
6
+ const MediaURLInput: FunctionComponent<MediaURLInputProps> = ({
7
+ value,
8
+ ...restProps
9
+ }: MediaURLInputProps) => {
10
+ const [url, setURL] = useState(value);
11
+
12
+ return (
13
+ <Input
14
+ {...restProps}
15
+ type='url'
16
+ value={url}
17
+ onChange={(e: ChangeEvent<HTMLInputElement>) => {
18
+ setURL(e.target.value);
19
+ }}
20
+ />
21
+ );
22
+ };
23
+
24
+ export default MediaURLInput;
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "Organization_Library_MediaURL",
3
+ "label": "MediaURL",
4
+ "description": "A pair of components for taking input and displaying teh value of a video or audio url.",
5
+ "organization": "TBD",
6
+ "version": "0.0.1",
7
+ "library": "TBD",
8
+ "componentKey": "Organization_Library_MediaURL",
9
+ "type": "Field",
10
+ "subtype": "Text",
11
+ "icon": "TBD",
12
+ "properties": ["TBD"]
13
+ }
@@ -0,0 +1,2 @@
1
+ export { default as MediaURLInput } from './MediaURLInput';
2
+ export { default as MediaURLDisplay } from './MediaURLDisplay';
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "Organization_Library_VideoPlayer",
3
+ "label": "Video Player",
4
+ "description": "video player",
5
+ "organization": "apple",
6
+ "version": "0.0.1",
7
+ "library": "basic",
8
+ "componentKey": "Organization_Library_VideoPlayer",
9
+ "type": "Field",
10
+ "subtype": "Text",
11
+ "icon": "images/pz-text-input-active.svg",
12
+ "properties": [
13
+ {
14
+ "name": "value",
15
+ "label": "Property",
16
+ "format": "PROPERTY"
17
+ },
18
+ {
19
+ "name": "label",
20
+ "label": "Label value",
21
+ "format": "TEXT"
22
+ },
23
+ {
24
+ "name": "placeholder",
25
+ "label": "Placeholder",
26
+ "format": "TEXT"
27
+ },
28
+ {
29
+ "name": "visibility",
30
+ "label": "Visible",
31
+ "format": "VISIBILITY"
32
+ },
33
+ {
34
+ "name": "disabled",
35
+ "label": "Disabled",
36
+ "format": "DISABLED"
37
+ },
38
+ {
39
+ "name": "required",
40
+ "label": "Required",
41
+ "format": "REQUIRED"
42
+ }
43
+ ]
44
+ }