@hubspot/ui-extensions 0.0.0
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/components.ts +92 -0
- package/hubspot.ts +20 -0
- package/index.ts +24 -0
- package/package.json +17 -0
- package/types.ts +213 -0
package/components.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { createRemoteReactComponent } from '@remote-ui/react';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
AlertProps,
|
|
5
|
+
ButtonProps,
|
|
6
|
+
ButtonRowProps,
|
|
7
|
+
DescriptionListProps,
|
|
8
|
+
DescriptionListItemProps,
|
|
9
|
+
FormProps,
|
|
10
|
+
HeadingProps,
|
|
11
|
+
ImageProps,
|
|
12
|
+
InputProps,
|
|
13
|
+
ProgressBarProps,
|
|
14
|
+
SelectProps,
|
|
15
|
+
TagProps,
|
|
16
|
+
TextProps,
|
|
17
|
+
TileProps,
|
|
18
|
+
StackProps,
|
|
19
|
+
StatisticsProps,
|
|
20
|
+
StatisticsItemProps,
|
|
21
|
+
StatisticsTrendProps,
|
|
22
|
+
} from './types';
|
|
23
|
+
|
|
24
|
+
interface CardProps {
|
|
25
|
+
style: React.CSSProperties;
|
|
26
|
+
title: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const Alert = createRemoteReactComponent<'Alert', AlertProps>('Alert');
|
|
30
|
+
const Button = createRemoteReactComponent<'Button', ButtonProps>('Button');
|
|
31
|
+
const ButtonRow = createRemoteReactComponent<'ButtonRow', ButtonRowProps>(
|
|
32
|
+
'ButtonRow'
|
|
33
|
+
);
|
|
34
|
+
const Card = createRemoteReactComponent<'Card', CardProps>('Card');
|
|
35
|
+
const DescriptionList = createRemoteReactComponent<
|
|
36
|
+
'DescriptionList',
|
|
37
|
+
DescriptionListProps
|
|
38
|
+
>('DescriptionList');
|
|
39
|
+
const DescriptionListItem = createRemoteReactComponent<
|
|
40
|
+
'DescriptionListItem',
|
|
41
|
+
DescriptionListItemProps
|
|
42
|
+
>('DescriptionListItem');
|
|
43
|
+
const Divider = createRemoteReactComponent<'Divider', {}>('Divider');
|
|
44
|
+
const Form = createRemoteReactComponent<'Form', FormProps>('Form');
|
|
45
|
+
const Heading = createRemoteReactComponent<'Heading', HeadingProps>('Heading');
|
|
46
|
+
const Image = createRemoteReactComponent<'Image', ImageProps>('Image');
|
|
47
|
+
const Input = createRemoteReactComponent<'Input', InputProps>('Input');
|
|
48
|
+
const ProgressBar = createRemoteReactComponent<'ProgressBar', ProgressBarProps>(
|
|
49
|
+
'ProgressBar'
|
|
50
|
+
);
|
|
51
|
+
const Select = createRemoteReactComponent<'Select', SelectProps>('Select');
|
|
52
|
+
const Tag = createRemoteReactComponent<'Tag', TagProps>('Tag');
|
|
53
|
+
const Text = createRemoteReactComponent<'Text', TextProps>('Text');
|
|
54
|
+
const Tile = createRemoteReactComponent<'Tile', TileProps>('Tile');
|
|
55
|
+
const Stack = createRemoteReactComponent<'Stack', StackProps>('Stack');
|
|
56
|
+
|
|
57
|
+
const StatisticsItem = createRemoteReactComponent<
|
|
58
|
+
'StatisticsItem',
|
|
59
|
+
StatisticsItemProps
|
|
60
|
+
>('StatisticsItem');
|
|
61
|
+
|
|
62
|
+
const Statistics = createRemoteReactComponent<'Statistics', StatisticsProps>(
|
|
63
|
+
'Statistics'
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const StatisticsTrend = createRemoteReactComponent<
|
|
67
|
+
'StatisticsTrend',
|
|
68
|
+
StatisticsTrendProps
|
|
69
|
+
>('StatisticsTrend');
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
Alert,
|
|
73
|
+
Button,
|
|
74
|
+
ButtonRow,
|
|
75
|
+
Card,
|
|
76
|
+
DescriptionList,
|
|
77
|
+
DescriptionListItem,
|
|
78
|
+
Divider,
|
|
79
|
+
Form,
|
|
80
|
+
Heading,
|
|
81
|
+
Image,
|
|
82
|
+
Input,
|
|
83
|
+
ProgressBar,
|
|
84
|
+
Select,
|
|
85
|
+
Stack,
|
|
86
|
+
Statistics,
|
|
87
|
+
StatisticsItem,
|
|
88
|
+
StatisticsTrend,
|
|
89
|
+
Tag,
|
|
90
|
+
Text,
|
|
91
|
+
Tile,
|
|
92
|
+
};
|
package/hubspot.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* eslint-disable hubspot-dev/no-confusing-browser-globals */
|
|
2
|
+
|
|
3
|
+
import { createRoot, RemoteRoot } from '@remote-ui/react';
|
|
4
|
+
import { ReactElement } from 'react';
|
|
5
|
+
import { Context } from './types';
|
|
6
|
+
|
|
7
|
+
export const hubspot = {
|
|
8
|
+
extend: render,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const extend = (...args) => (self as any).extend(...args);
|
|
12
|
+
|
|
13
|
+
function render(
|
|
14
|
+
renderCallback: (api: { context: Context }) => ReactElement<any>
|
|
15
|
+
) {
|
|
16
|
+
return extend((root: RemoteRoot, api: { context: Context }) => {
|
|
17
|
+
createRoot(root).render(renderCallback(api));
|
|
18
|
+
root.mount();
|
|
19
|
+
});
|
|
20
|
+
}
|
package/index.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Alert,
|
|
3
|
+
Button,
|
|
4
|
+
ButtonRow,
|
|
5
|
+
Card,
|
|
6
|
+
DescriptionList,
|
|
7
|
+
DescriptionListItem,
|
|
8
|
+
Divider,
|
|
9
|
+
Form,
|
|
10
|
+
Heading,
|
|
11
|
+
Image,
|
|
12
|
+
Input,
|
|
13
|
+
ProgressBar,
|
|
14
|
+
Select,
|
|
15
|
+
Stack,
|
|
16
|
+
Statistics,
|
|
17
|
+
StatisticsItem,
|
|
18
|
+
StatisticsTrend,
|
|
19
|
+
Tag,
|
|
20
|
+
Text,
|
|
21
|
+
Tile,
|
|
22
|
+
} from './components';
|
|
23
|
+
|
|
24
|
+
export { hubspot } from './hubspot';
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hubspot/ui-extensions",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.ts",
|
|
7
|
+
"scripts": {},
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@remote-ui/react": "^5.0.0",
|
|
14
|
+
"react": "^18.2.0"
|
|
15
|
+
},
|
|
16
|
+
"gitHead": "ca7c7648663fd4c60ce98b616ba6d3662d949f07"
|
|
17
|
+
}
|
package/types.ts
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// Do not manually update this file, changes will be overridden from ui-extensions-remote-renderer/static/js/types.ts
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface AlertProps {
|
|
5
|
+
title: string;
|
|
6
|
+
body?: string;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
variant?: 'info' | 'warning' | 'success' | 'error' | 'danger';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ButtonProps {
|
|
12
|
+
text: string;
|
|
13
|
+
onClick?: () => void;
|
|
14
|
+
href?: string;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
variant?: 'primary' | 'secondary' | 'destructive';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ButtonRowProps {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
disableDropdown?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface DescriptionListItemProps {
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
label: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface DescriptionListProps {
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
direction?: 'row' | 'column';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface DividerProps {
|
|
35
|
+
distance?:
|
|
36
|
+
| 'flush'
|
|
37
|
+
| 'extra-small'
|
|
38
|
+
| 'small'
|
|
39
|
+
| 'medium'
|
|
40
|
+
| 'large'
|
|
41
|
+
| 'extra-large';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface FormProps {
|
|
45
|
+
children: ReactNode;
|
|
46
|
+
onSubmit: () => void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface HeadingProps {
|
|
50
|
+
text: string;
|
|
51
|
+
format?: 'plaintext' | 'markdown';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ImageProps {
|
|
55
|
+
alt?: string;
|
|
56
|
+
href?: string;
|
|
57
|
+
onClick?: () => void;
|
|
58
|
+
src: string;
|
|
59
|
+
width?: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface InputProps {
|
|
63
|
+
label: string;
|
|
64
|
+
name: string;
|
|
65
|
+
value?: string;
|
|
66
|
+
required?: boolean;
|
|
67
|
+
readonly?: boolean;
|
|
68
|
+
description?: string;
|
|
69
|
+
tooltip?: string;
|
|
70
|
+
placeholder?: string;
|
|
71
|
+
error?: boolean;
|
|
72
|
+
errorMessage?: string;
|
|
73
|
+
visible?: boolean;
|
|
74
|
+
onChange: (value: string) => void;
|
|
75
|
+
onInput: (value: string) => void;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface ProgressBarProps {
|
|
79
|
+
title?: string;
|
|
80
|
+
showPercentage?: boolean;
|
|
81
|
+
type: 'progressBar';
|
|
82
|
+
value?: number;
|
|
83
|
+
valueMax?: number;
|
|
84
|
+
valueDescription?: string;
|
|
85
|
+
variant?: 'success' | 'danger' | 'warning';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface SelectProps {
|
|
89
|
+
label: string;
|
|
90
|
+
name: string;
|
|
91
|
+
value?: string | number | boolean;
|
|
92
|
+
required?: boolean;
|
|
93
|
+
readonly?: boolean;
|
|
94
|
+
description?: string;
|
|
95
|
+
tooltip?: string;
|
|
96
|
+
placeholder?: string;
|
|
97
|
+
error?: boolean;
|
|
98
|
+
errorMessage?: string;
|
|
99
|
+
onChange: (value: string) => void;
|
|
100
|
+
options: {
|
|
101
|
+
label: string;
|
|
102
|
+
value: string | number | boolean;
|
|
103
|
+
}[];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface TagProps {
|
|
107
|
+
text: string;
|
|
108
|
+
onClick?: () => void;
|
|
109
|
+
variant?: 'default' | 'warning' | 'success' | 'error';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface TextProps {
|
|
113
|
+
format?: 'plaintext' | 'markdown';
|
|
114
|
+
text: string;
|
|
115
|
+
variant?: 'bodytext' | 'microcopy';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface TileProps {
|
|
119
|
+
children: ReactNode;
|
|
120
|
+
flush?: boolean;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
interface Team {
|
|
124
|
+
id: number;
|
|
125
|
+
name: string;
|
|
126
|
+
teammates: number[];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface UserContext {
|
|
130
|
+
id: number;
|
|
131
|
+
emails: string[];
|
|
132
|
+
email: string;
|
|
133
|
+
firstName: string;
|
|
134
|
+
lastName: string;
|
|
135
|
+
roles: string[];
|
|
136
|
+
teams: Team[];
|
|
137
|
+
locale?: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface PortalContext {
|
|
141
|
+
id: number;
|
|
142
|
+
timezone: string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface Context {
|
|
146
|
+
user: UserContext;
|
|
147
|
+
portal: PortalContext;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
type distanceOptions = 'flush' | 'small';
|
|
151
|
+
|
|
152
|
+
export interface StackProps {
|
|
153
|
+
distance?: distanceOptions;
|
|
154
|
+
children?: React.ReactNode;
|
|
155
|
+
}
|
|
156
|
+
export interface StatisticsTrendProps {
|
|
157
|
+
value: string;
|
|
158
|
+
direction: 'increase' | 'decrease';
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface StatisticsItemProps {
|
|
162
|
+
id?: string;
|
|
163
|
+
label: string;
|
|
164
|
+
number: string;
|
|
165
|
+
children: ReactNode;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface StatisticsProps {
|
|
169
|
+
children: ReactNode;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
interface ServerlessRunnerParams {
|
|
173
|
+
name: string;
|
|
174
|
+
payload: Record<string, unknown>;
|
|
175
|
+
onError?: () => void;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export type ServerlessFuncRunner = (
|
|
179
|
+
params: ServerlessRunnerParams
|
|
180
|
+
) => Promise<any>;
|
|
181
|
+
|
|
182
|
+
export interface ServerlessSuccessResponse {
|
|
183
|
+
logId: string;
|
|
184
|
+
response: {
|
|
185
|
+
message?:
|
|
186
|
+
| {
|
|
187
|
+
type: 'SUCCESS' | 'ERROR';
|
|
188
|
+
body: string;
|
|
189
|
+
}
|
|
190
|
+
| string;
|
|
191
|
+
context?: Record<string, unknown>;
|
|
192
|
+
section?: Record<string, unknown>;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface ServerlessErrorResponse {
|
|
197
|
+
responseJSON?: {
|
|
198
|
+
message: string;
|
|
199
|
+
correlationId: string;
|
|
200
|
+
category: string;
|
|
201
|
+
subCategory?: string;
|
|
202
|
+
errors?: { message: string; subCategory: string }[];
|
|
203
|
+
};
|
|
204
|
+
status: number;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface ExtensionCardContextData {
|
|
208
|
+
cardId: string;
|
|
209
|
+
appId: number | string;
|
|
210
|
+
objectId: number | string;
|
|
211
|
+
objectTypeId: string;
|
|
212
|
+
location: string;
|
|
213
|
+
}
|