@hubspot/ui-extensions 0.0.1-prealpha.7 → 0.1.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/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # ui-extensions-components
1
+ # UI Extensions
2
+
3
+ React components and utilities for extending HubSpot's UI.
2
4
 
3
5
  ## TOC
4
6
 
@@ -7,31 +9,35 @@
7
9
  - [ButtonRow](#buttonrow)
8
10
  - [Card](#card)
9
11
  - [DescriptionList](#descriptionlist)
10
- - [DescriptionListItem](#descriptionlistitem)
12
+ - [DescriptionListItem](#descriptionlistitem)
11
13
  - [Divider](#divider)
12
14
  - [Form](#form)
15
+ - [EmptyState](#emptystate)
16
+ - [ErrorState](#errorstate)
13
17
  - [Heading](#heading)
14
18
  - [Image](#image)
15
19
  - [Input](#input)
16
20
  - [Link](#link)
17
21
  - [LoadingSpinner](#loadingspinner)
22
+ - [NumberInput](#numberInput)
18
23
  - [ProgressBar](#progressbar)
19
24
  - [Select](#select)
20
25
  - [Stack](#stack)
21
26
  - [Statistics](#statistics)
22
- - [StatisticsItem](#statisticsitem)
23
- - [StatisticsTrend](#statisticstrend)
27
+ - [StatisticsItem](#statisticsitem)
28
+ - [StatisticsTrend](#statisticstrend)
24
29
  - [Table](#table)
25
- - [TableBody](#tablebody)
26
- - [TableCell](#tablecell)
27
- - [TableFooter](#tablefooter)
28
- - [TableHead](#tablehead)
29
- - [TableHeader](#tableheader)
30
- - [TableRow](#tablerow)
30
+ - [TableBody](#tablebody)
31
+ - [TableCell](#tablecell)
32
+ - [TableFooter](#tablefooter)
33
+ - [TableHead](#tablehead)
34
+ - [TableHeader](#tableheader)
35
+ - [TableRow](#tablerow)
31
36
  - [Tag](#tag)
32
37
  - [Text](#text)
33
38
  - [Textarea](#textarea)
34
39
  - [Tile](#tile)
40
+ - [ToggleGroup](#togglegroup)
35
41
 
36
42
  ## Components
37
43
 
@@ -50,7 +56,6 @@ The Alert component accepts the following props:
50
56
  ```typescript
51
57
  export interface AlertProps {
52
58
  title: string;
53
- body?: string;
54
59
  children?: ReactNode;
55
60
  variant?: 'info' | 'warning' | 'success' | 'error' | 'danger';
56
61
  }
@@ -59,7 +64,6 @@ export interface AlertProps {
59
64
  | Prop | Type | Default | Description |
60
65
  | --- | --- | --- | --- |
61
66
  | `title` | `string` | `N/A` | The title text for the alert message. |
62
- | `body` | `string(optional)` | `N/A` | The main content of the alert message. If not provided, the children prop is used. |
63
67
  | `children` | `ReactNode(optional)` | `N/A` | The main content of the alert message when the body prop is not provided. |
64
68
  | `variant` | `'info' \| 'warning' \| 'success' \|'error' \| 'danger'` `(optional)` | `'info'` | Sets the color variation of the alert |
65
69
 
@@ -72,22 +76,18 @@ const Extension = () => {
72
76
  <Alert title="Important Info" variant="info">
73
77
  This is an informative message.
74
78
  </Alert>
75
- <Alert
76
- title="Success"
77
- body="Operation completed successfully."
78
- variant="success"
79
- />
80
- <Alert title="Warning" body="Proceed with caution." variant="warning" />
81
- <Alert
82
- title="Error"
83
- body="Something went wrong. Please try again."
84
- variant="error"
85
- />
86
- <Alert
87
- title="Danger"
88
- body="This action cannot be undone. Be careful."
89
- variant="danger"
90
- />
79
+ <Alert title="Success"variant="success">
80
+ Operation completed successfully.
81
+ </Alert>
82
+ <Alert title="Warning" variant="warning" >
83
+ Proceed with caution.
84
+ </Alert>
85
+ <Alert title="Error" variant="error" >
86
+ Something went wrong. Please try again.
87
+ </Alert>
88
+ <Alert title="Danger" variant="danger" >
89
+ This action cannot be undone. Be careful.
90
+ </Alert>
91
91
  </>
92
92
  );
93
93
  };
@@ -96,14 +96,16 @@ const Extension = () => {
96
96
  ### Button
97
97
 
98
98
  ##### Import
99
+
99
100
  ```javascript
100
101
  import { Button } from '@hubspot/ui-extensions';
101
102
  ```
102
103
 
103
104
  ##### Props
105
+
104
106
  ```typescript
105
107
  interface ButtonProps {
106
- text: string;
108
+ children: string;
107
109
  onClick?: () => void;
108
110
  href?: string;
109
111
  disabled?: boolean;
@@ -111,194 +113,219 @@ interface ButtonProps {
111
113
  type?: 'button' | 'reset' | 'submit';
112
114
  }
113
115
  ```
116
+
114
117
  | Prop | Type | Default | Description |
115
- | - | - | - | - |
116
- | `text` | `string` | `N/A` | The displayable text for the Button |
117
- | `onClick` | `() => void` `(optional)` | `N/A` | A function that will be invoked when the button is clicked. It receives no arguments and it's return value is ignored|
118
- | `href` | `string(optional)`| `N/A` | A URL that will be opened when the button is clicked. If the value is a URL external to HubSpot it will be opened in a new tab. |
119
- | `disabled` | `boolean(optional)` | `N/A` | Determines if the button should be disabled or not.|
118
+ | --- | --- | --- | --- |
119
+ | `children` | `string` | `N/A` | The displayable text for the Button |
120
+ | `onClick` | `() => void` `(optional)` | `N/A` | A function that will be invoked when the button is clicked. It receives no arguments and it's return value is ignored |
121
+ | `href` | `string(optional)` | `N/A` | A URL that will be opened when the button is clicked. If the value is a URL external to HubSpot it will be opened in a new tab. |
122
+ | `disabled` | `boolean(optional)` | `N/A` | Determines if the button should be disabled or not. |
120
123
  | `variant` | `'primary' \| 'secondary' \| 'destructive'` `(optional)` | `'secondary'` | Sets the color variation of the button |
121
124
  | `type` | `'button' \| 'reset' \| 'submit'` `(optional)` | `'button'` | Sets the HTML attribute "role" of the button |
122
125
 
123
126
  ##### Usage
127
+
124
128
  ```javascript
125
129
  const Extension = () => {
126
130
  return (
127
131
  <Button
128
- text="Click me!"
129
132
  onClick={() => {
130
133
  console.log('Someone clicked on the button!');
131
134
  }}
132
135
  href="https://hubspot.com"
133
136
  variant="destructive"
134
137
  type="button"
135
- />
138
+ >
139
+ Click me!
140
+ </Button>
136
141
  );
137
- }
142
+ };
138
143
  ```
139
144
 
140
145
  ### ButtonRow
141
146
 
142
147
  ##### Import
148
+
143
149
  ```javascript
144
150
  import { ButtonRow } from '@hubspot/ui-extensions';
145
151
  ```
146
152
 
147
153
  ##### Props
154
+
148
155
  ```typescript
149
156
  interface ButtonRowProps {
150
157
  children: ReactNode;
151
158
  disableDropdown?: boolean;
152
159
  }
153
160
  ```
161
+
154
162
  | Prop | Type | Default | Description |
155
- | - | - | - | - |
156
- | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
163
+ | --- | --- | --- | --- |
164
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
157
165
  | `disableDropdown` | `boolean(optional)` | `false` | Disables the dropdown list of buttons that appears the the children expand beyond the horizontal space |
158
166
 
159
167
  ##### Usage
168
+
160
169
  ```javascript
161
170
  const Extension = () => {
162
171
  return (
163
172
  <ButtonRow disableDropdown={false}>
164
173
  <Button
165
- text="Regular Button"
166
174
  onClick={() => {
167
175
  console.log('Regular button clicked');
168
176
  }}
169
- />
177
+ >
178
+ Regular Button
179
+ </Button>
170
180
  <Button
171
- text="Reset"
172
181
  onClick={() => {
173
182
  console.log('Reset button clicked');
174
183
  }}
175
184
  variant="destructive"
176
185
  type="reset"
177
- />
186
+ >
187
+ Reset
188
+ </Button>
178
189
  <Button
179
- text="Submit"
180
190
  onClick={() => {
181
191
  console.log('Submit button clicked');
182
192
  }}
183
193
  variant="primary"
184
194
  type="submit"
185
- />
195
+ >
196
+ Submit
197
+ </Button>
186
198
  </ButtonRow>
187
199
  );
188
- }
200
+ };
189
201
  ```
190
202
 
191
203
  ### Card
192
204
 
193
205
  ##### Import
206
+
194
207
  ```javascript
195
208
  import { Card } from '@hubspot/ui-extensions';
196
209
  ```
197
210
 
198
211
  ##### Props
212
+
199
213
  ```typescript
200
214
  interface CardProps {
201
215
  children: ReactNode;
202
216
  }
203
217
  ```
218
+
204
219
  | Prop | Type | Default | Description |
205
- | - | - | - | - |
206
- | `children` | `ReactNode`| `N/A`| Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
220
+ | --- | --- | --- | --- |
221
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
207
222
 
208
223
  ##### Usage
224
+
209
225
  ```javascript
210
226
  const Extension = () => {
211
227
  return (
212
228
  <Card>
213
229
  <Button
214
- text="Regular Button"
215
230
  onClick={() => {
216
231
  console.log('Regular button clicked');
217
232
  }}
218
- />
233
+ >
234
+ Regular Button
235
+ </Button>
219
236
  </Card>
220
237
  );
221
- }
238
+ };
222
239
  ```
223
240
 
224
241
  ### DescriptionList
225
242
 
226
243
  ##### Import
244
+
227
245
  ```javascript
228
246
  import { DescriptionList } from '@hubspot/ui-extensions';
229
247
  ```
230
248
 
231
249
  ##### Props
250
+
232
251
  ```typescript
233
252
  interface DescriptionListProps {
234
253
  children: ReactNode;
235
254
  direction?: 'row' | 'column';
236
255
  }
237
256
  ```
257
+
238
258
  | Prop | Type | Default | Description |
239
- | - | - | - | - |
240
- | `children` | `ReactNode` | `N/A`| Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. The children should be [DescriptionListItem](#descriptionlistitem) |
241
- | `direction` | `'row' \| 'column'` `(optional)` | `'column'`| The direction the label/value pairs are placed in the description list container. |
259
+ | --- | --- | --- | --- |
260
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. The children should be [DescriptionListItem](#descriptionlistitem) |
261
+ | `direction` | `'row' \| 'column'` `(optional)` | `'column'` | The direction the label/value pairs are placed in the description list container. |
242
262
 
243
263
  ##### Usage
264
+
244
265
  ```javascript
245
266
  const Extension = () => {
246
267
  return (
247
268
  <DescriptionList direction="row">
248
- <DescriptionListItem label={"First Name"}>
249
- <Text text="Alan" />
269
+ <DescriptionListItem label={'First Name'}>
270
+ <Text>Alan</Text>
250
271
  </DescriptionListItem>
251
- <DescriptionListItem label={"Last Name"}>
252
- <Text text="Turing" />
272
+ <DescriptionListItem label={'Last Name'}>
273
+ <Text>Turing</Text>
253
274
  </DescriptionListItem>
254
275
  </DescriptionList>
255
276
  );
256
- }
277
+ };
257
278
  ```
258
279
 
259
280
  #### DescriptionListItem
260
281
 
261
282
  ##### Import
283
+
262
284
  ```javascript
263
285
  import { DescriptionListItem } from '@hubspot/ui-extensions';
264
286
  ```
265
287
 
266
288
  ##### Props
289
+
267
290
  ```typescript
268
291
  interface DescriptionListItemProps {
269
292
  children: ReactNode;
270
293
  label: string;
271
294
  }
272
295
  ```
296
+
273
297
  | Prop | Type | Default | Description |
274
- | - | - | - | - |
275
- | `children` | `ReactNode`| `N/A`| Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
276
- | `label` | `string` | `N/A` | Text to be displayed as the label |
298
+ | --- | --- | --- | --- |
299
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
300
+ | `label` | `string` | `N/A` | Text to be displayed as the label |
277
301
 
278
302
  ##### Usage
303
+
279
304
  ```javascript
280
305
  const Extension = () => {
281
306
  return (
282
307
  <DescriptionList direction="row">
283
- <DescriptionListItem label={"First Name"}>
284
- <Text text="Alan" />
308
+ <DescriptionListItem label={'First Name'}>
309
+ <Text>Alan</Text>
285
310
  </DescriptionListItem>
286
- <DescriptionListItem label={"Last Name"}>
287
- <Text text="Turing" />
311
+ <DescriptionListItem label={'Last Name'}>
312
+ <Text>Turing</Text>
288
313
  </DescriptionListItem>
289
314
  </DescriptionList>
290
315
  );
291
- }
316
+ };
292
317
  ```
293
318
 
294
319
  ### Divider
295
320
 
296
321
  ##### Import
322
+
297
323
  ```javascript
298
324
  import { Divider } from '@hubspot/ui-extensions';
299
325
  ```
300
326
 
301
327
  ##### Props
328
+
302
329
  ```typescript
303
330
  interface DividerProps {
304
331
  distance?:
@@ -310,27 +337,29 @@ interface DividerProps {
310
337
  | 'extra-large';
311
338
  }
312
339
  ```
340
+
313
341
  | Prop | Type | Default | Description |
314
- | - | - | - | - |
315
- | `distance` | `'flush'\| 'extra-small' \| 'small' \| 'medium' \| 'large'\| 'extra-large'` `(optional)`| `'small'` | The size of the padding above and below the divider. |
342
+ | --- | --- | --- | --- |
343
+ | `distance` | `'flush'\| 'extra-small' \| 'small' \| 'medium' \| 'large'\| 'extra-large'` `(optional)` | `'small'` | The size of the padding above and below the divider. |
316
344
 
317
345
  ##### Usage
346
+
318
347
  ```javascript
319
348
  const Extension = () => {
320
- return (
321
- <Divider distance="extra-large"/>
322
- );
323
- }
349
+ return <Divider distance="extra-large" />;
350
+ };
324
351
  ```
325
352
 
326
353
  ### Form
327
354
 
328
355
  ##### Import
356
+
329
357
  ```javascript
330
358
  import { Form } from '@hubspot/ui-extensions';
331
359
  ```
332
360
 
333
361
  ##### Props
362
+
334
363
  ```typescript
335
364
  interface FormProps {
336
365
  children: ReactNode;
@@ -338,13 +367,15 @@ interface FormProps {
338
367
  preventDefault?: boolean;
339
368
  }
340
369
  ```
370
+
341
371
  | Prop | Type | Default | Description |
342
- | - | - | - | - |
343
- | `children` | `ReactNode` | `N/A`| Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
344
- | `onSubmit` | `function(optional)` | `N/A`| A function that will be called when the form is submitted. It will receive a `RemoteEvent` as argument and it's return value will be ignored. |
345
- | `preventDefault` | `boolean(optional)` | `false`| If set to `true` `event.preventDefault()` will be invoked before your `onSubmit` function is called, preventing the default html form behavior. |
372
+ | --- | --- | --- | --- |
373
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
374
+ | `onSubmit` | `function(optional)` | `N/A` | A function that will be called when the form is submitted. It will receive a `RemoteEvent` as argument and it's return value will be ignored. |
375
+ | `preventDefault` | `boolean(optional)` | `false` | If set to `true` `event.preventDefault()` will be invoked before your `onSubmit` function is called, preventing the default html form behavior. |
346
376
 
347
377
  ##### Usage
378
+
348
379
  ```javascript
349
380
  const Extension = () => {
350
381
  return (
@@ -352,13 +383,14 @@ const Extension = () => {
352
383
  <Input {...} />
353
384
  <Select {...} />
354
385
  <Button
355
- text="Submit"
356
386
  onClick={() => {
357
387
  console.log('Submit button clicked');
358
388
  }}
359
389
  variant="primary"
360
390
  type="submit"
361
- />
391
+ >
392
+ Submit
393
+ </Button>
362
394
  </Form>
363
395
  );
364
396
  }
@@ -367,11 +399,13 @@ const Extension = () => {
367
399
  ### EmptyState
368
400
 
369
401
  ##### Import
402
+
370
403
  ```javascript
371
404
  import { EmptyState } from '@hubspot/ui-extensions';
372
405
  ```
373
406
 
374
407
  ##### Props
408
+
375
409
  ```typescript
376
410
  interface EmptyStateProps {
377
411
  children: ReactNode;
@@ -382,22 +416,24 @@ interface EmptyStateProps {
382
416
  title?: string;
383
417
  }
384
418
  ```
419
+
385
420
  | Prop | Type | Default | Description |
386
- | - | - | - | - |
387
- | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
421
+ | --- | --- | --- | --- |
422
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
388
423
  | `flush` | `boolean(optional)` | `false` | Removes the default vertical margins for the component. |
389
- | `imageWidth` | `number(optional)` | `250`| The max-width for the image container. |
424
+ | `imageWidth` | `number(optional)` | `250` | The max-width for the image container. |
390
425
  | `layout` | `'horizontal' \| 'vertical'` `(optional)` | `'horizontal'` | Sets the layout direction for the content. |
391
426
  | `reverseOrder` | `boolean(optional)` | `false` | Swaps the visual order of the text (primary) and image (secondary) content. This ensures the primary content is still presented first to assistive technology. |
392
- | `title` | `string(optional)` | `Intl("All is not lost.")` | The text for the title header rendered above the `children`. |
427
+ | `title` | `string(optional)` | `Intl('All is not lost.')` | The text for the title header rendered above the `children`. |
393
428
 
394
429
  ##### Usage
430
+
395
431
  ```javascript
396
432
  const Extension = ({ data }) => {
397
433
  if (!data || !data.length) {
398
434
  return (
399
435
  <EmptyState title="Nothing here yet" layout="vertical" reverseOrder={true}>
400
- <Text text="Go out there and get some leads!" />
436
+ <Text>Go out there and get some leads!</Text>
401
437
  </EmptyState>
402
438
  )
403
439
  }
@@ -413,11 +449,13 @@ const Extension = ({ data }) => {
413
449
  ### ErrorState
414
450
 
415
451
  ##### Import
452
+
416
453
  ```javascript
417
454
  import { ErrorState } from '@hubspot/ui-extensions';
418
455
  ```
419
456
 
420
457
  ##### Props
458
+
421
459
  ```typescript
422
460
  interface ErrorStateProps {
423
461
  children: ReactNode;
@@ -425,21 +463,27 @@ interface ErrorStateProps {
425
463
  type?: 'error' | 'support' | 'lock';
426
464
  }
427
465
  ```
466
+
428
467
  | Prop | Type | Default | Description |
429
- | - | - | - | - |
430
- | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
431
- | `title` | `string(optional)` | `Intl("All is not lost.")` | The text for the title header rendered above the `children`. |
468
+ | --- | --- | --- | --- |
469
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
470
+ | `title` | `string(optional)` | `Intl('All is not lost.')` | The text for the title header rendered above the `children`. |
432
471
  | `type` | `'error' \| 'support' \| 'lock'` `(optional)` | `'error'` | Sets the type of error image that will be shown. |
433
472
 
434
473
  ##### Usage
474
+
435
475
  ```javascript
436
476
  const Extension = ({ data, error, fetchData }) => {
437
477
  if (error) {
438
478
  return (
439
479
  <ErrorState title="Trouble fetching properties." layout="vertical" reverseOrder={true}>
440
480
  <Stack>
441
- <Text text="Please try again in a few moments." />
442
- <Button text="Try again" onClick={fetchData} />
481
+ <Text>
482
+ Please try again in a few moments.
483
+ </Text>
484
+ <Button onClick={fetchData}>
485
+ Try again
486
+ </Button>
443
487
  </Stack>
444
488
  </ErrorState>
445
489
  )
@@ -456,78 +500,65 @@ const Extension = ({ data, error, fetchData }) => {
456
500
  ### Heading
457
501
 
458
502
  ##### Import
503
+
459
504
  ```javascript
460
505
  import { Heading } from '@hubspot/ui-extensions';
461
506
  ```
462
507
 
463
508
  ##### Props
509
+
464
510
  ```typescript
465
511
  interface HeadingProps {
466
- text: string;
467
- format?: 'plaintext' | 'markdown';
512
+ children: ReactNode;
513
+ inline?: boolean;
468
514
  }
469
515
  ```
470
- | Prop | Type | Default | Description |
471
- | - | - | - | - |
472
- | `text` | `string` | `N/A`| Text to be displayed as heading text. If format is `"markdown"`, inline markdown elements (i.e. bold, italics, code, links) are supported|
473
- | `format` | `'plaintext' \| 'markdown'` `(optional)` | `'plaintext'`| Type of formatting for the display text. |
474
-
475
- #### Markdown
476
- Markdown syntax supported in the component:
477
516
 
478
- - bold text: `**like this**` or `__like this__`
479
- - italicized text: `*like this*` or `_like this_`
480
- - inline code: `` `like this` ``
481
- - links: `[visible anchor text](https://www.hubspot.com/)`
517
+ | Prop | Type | Default | Description |
518
+ | --- | --- | --- | --- |
519
+ | `children` | `string` | `N/A` | Text to be displayed as heading text. |
520
+ | `inline` | `boolean(optional)` | `false` | Determines if the text will break line or share the space. |
482
521
 
483
522
  ##### Usage
523
+
484
524
  ```javascript
485
525
  const Extension = () => {
486
- return (
487
- <>
488
- <Heading text="Plain text, nothing special here"/>
489
- <Heading text="**It's a Bold Strategy Cotton, lets see if it pays off for them.**" format="markdown"/>
490
- </>
491
- );
492
- }
526
+ return <Heading>Plain text, nothing special here</Heading>;
527
+ };
493
528
  ```
494
529
 
495
530
  ### Image
496
- ##### Import
497
531
 
532
+ ##### Import
498
533
 
499
534
  ```javascript
500
535
  import { Image } from '@hubspot/ui-extensions';
501
536
  ```
502
537
 
503
538
  ##### Props
539
+
504
540
  ```typescript
505
- interface ImageProps {
541
+ interface ImageProps {
506
542
  alt?: string;
507
543
  href?: string;
508
544
  onClick?: () => void;
509
545
  src: string;
510
546
  width?: number;
547
+ height?: number;
511
548
  }
512
549
  ```
513
550
 
514
- | Prop | Type | Description |
515
- | - | - | - |
551
+ | Prop | Type | Description |
552
+ | --- | --- | --- |
516
553
  | `alt` | `string(optional)` | The alt text for the image, similar to the `alt` attribute for the html [img tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attributes) |
517
554
  | `href` | `string(optional)` | If provided, it will be used as a href that will be opened in a new tag when the image is clicked |
518
555
  | `onClick` | `function(optional)` | A function that will be called when the image is clicked on. This function will receive no arguments any returned values will be ignored. |
519
- | `src` | | `string` | The url to the image to display, similar to [img tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attributes)|
520
- | `width` | `number(optional)` | The pixel width of the image |
521
-
522
- | Prop | Type | Description |
523
- | - | - | - |
524
- | `alt` | `string(optional)` | The alt text for the image, similar to the `alt` attribute for the html [img tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attributes) |
525
- | `href` | `string(optional)` | If provided, it will be used as a href that will be opened in a new tag when the image is clicked |
526
- | `onClick` | `function(optional)` | A function that will be called when the image is clicked on. This function will receive no arguments any returned values will be ignored. |
527
- | `src` | | `string` | The url to the image to display, similar to [img tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attributes)|
556
+ | `src` | `string` | The url to the image to display, similar to [img tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attributes) |
528
557
  | `width` | `number(optional)` | The pixel width of the image |
558
+ | `height` | `number(optional)` | The pixel height of the image |
529
559
 
530
560
  ##### Usage
561
+
531
562
  ```javascript
532
563
  const Extension = () => {
533
564
  return (
@@ -536,22 +567,24 @@ const Extension = () => {
536
567
  src="https://picsum.photos/id/237/200/300"
537
568
  href="https://picsum.photos/id/237"
538
569
  onClick={() => {
539
- console.log('Someone clicked on the image!')
570
+ console.log('Someone clicked on the image!');
540
571
  }}
541
572
  width={200}
542
573
  />
543
574
  );
544
- }
575
+ };
545
576
  ```
546
577
 
547
578
  ### Input
548
579
 
549
580
  ##### Import
581
+
550
582
  ```javascript
551
583
  import { Input } from '@hubspot/ui-extensions';
552
584
  ```
553
585
 
554
586
  ##### Props
587
+
555
588
  ```typescript
556
589
  interface InputProps {
557
590
  label: string;
@@ -570,31 +603,33 @@ interface InputProps {
570
603
  onFocus?: (value: string) => void;
571
604
  }
572
605
  ```
606
+
573
607
  | Prop | Type | Default | Description |
574
- | - | - | - | - |
575
- | `label` | `string` | `N/A`| The label text to display for the form input element |
576
- | `name` | `string` | `N/A`| The unique identifier for the input element, this could be thought of as the HTML5 [Input element's name attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name) |
577
- | `value` | `string(optional)` | `''`| The value of the input |
578
- | `required` | `boolean(optional)` | `false`| Determines if the required indicator should be displayed |
579
- | `readOnly` | `boolean(optional)` | `false`| Determines if the field is editable or not. |
580
- | `description` | `string(optional)` | `N/A`| Instructional message to display to the user to help understand the purpose of the input. |
581
- | `tooltip` | `string(optional)` | `N/A`| Text that will appear in a tooltip next to the input label. |
582
- | `placeholder` | `string(optional)` | `N/A`| Text that appears in the input when it has no value set. |
583
- | `error` | `boolean(optional)` | `false`| If set to true, `validationMessage` is displayed as an error message, if it was provided. The input will also render it's error state to let the user know there is an error. If false, `validationMessage` is displayed as a success message. |
584
- | `validationMessage` | `string(optional)` | `''`| The text to show if the input has an error. |
585
- | `onChange` | `(value: string) => void(optional)` | `N/A`| A callback function that is invoked when the value is committed. Currently these times are `onBlur` of the input and when the user submits the form. |
586
- | `onInput` | `(value: string) => void(optional)` | `N/A`| A function that is called and passed the value every time the field is edited by the user. It is recommended that you do not use this value to update state, that is what `onChange` should be used for. Instead this should be used for validation. |
587
- | `onBlur` | `(value: string) => void(optional)` | `N/A`| A function that is called and passed the value every time the field loses focus. |
588
- | `onFocus` | `(value: string) => void(optional)` | `N/A`| A function that is called and passed the value every time the field gets focused. |
608
+ | --- | --- | --- | --- |
609
+ | `label` | `string` | `N/A` | The label text to display for the form input element |
610
+ | `name` | `string` | `N/A` | The unique identifier for the input element, this could be thought of as the HTML5 [Input element's name attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name) |
611
+ | `value` | `string(optional)` | `''` | The value of the input |
612
+ | `required` | `boolean(optional)` | `false` | Determines if the required indicator should be displayed |
613
+ | `readOnly` | `boolean(optional)` | `false` | Determines if the field is editable or not. |
614
+ | `description` | `string(optional)` | `N/A` | Instructional message to display to the user to help understand the purpose of the input. |
615
+ | `tooltip` | `string(optional)` | `N/A` | Text that will appear in a tooltip next to the input label. |
616
+ | `placeholder` | `string(optional)` | `N/A` | Text that appears in the input when it has no value set. |
617
+ | `error` | `boolean(optional)` | `false` | If set to true, `validationMessage` is displayed as an error message, if it was provided. The input will also render it's error state to let the user know there is an error. If false, `validationMessage` is displayed as a success message. |
618
+ | `validationMessage` | `string(optional)` | `''` | The text to show if the input has an error. |
619
+ | `onChange` | `(value: string) => void(optional)` | `N/A` | A callback function that is invoked when the value is committed. Currently these times are `onBlur` of the input and when the user submits the form. |
620
+ | `onInput` | `(value: string) => void(optional)` | `N/A` | A function that is called and passed the value every time the field is edited by the user. It is recommended that you do not use this value to update state, that is what `onChange` should be used for. Instead this should be used for validation. |
621
+ | `onBlur` | `(value: string) => void(optional)` | `N/A` | A function that is called and passed the value every time the field loses focus. |
622
+ | `onFocus` | `(value: string) => void(optional)` | `N/A` | A function that is called and passed the value every time the field gets focused. |
589
623
 
590
624
  ##### Usage
625
+
591
626
  ```javascript
592
627
  import { useState } from 'react';
593
628
 
594
629
  const Extension = () => {
595
- const [ name, setName ] = useState('');
596
- const [ validationMessage, setValidationMessage ] = useState('');
597
- const [ isValid, setIsValid ] = useState(true);
630
+ const [name, setName] = useState('');
631
+ const [validationMessage, setValidationMessage] = useState('');
632
+ const [isValid, setIsValid] = useState(true);
598
633
 
599
634
  return (
600
635
  <Form>
@@ -607,95 +642,180 @@ const Extension = () => {
607
642
  required={true}
608
643
  error={!isValid}
609
644
  validationMessage={validationMessage}
610
- onChange={(value) => {
611
- setName(value)
645
+ onChange={value => {
646
+ setName(value);
612
647
  }}
613
- onInput={(value) => {
614
- if(value !== 'Bill') {
648
+ onInput={value => {
649
+ if (value !== 'Bill') {
615
650
  setValidationMessage('This form only works for people named Bill');
616
651
  setIsValid(false);
617
652
  } else if (value === '') {
618
- setValidationMessage('First name is required')
653
+ setValidationMessage('First name is required');
619
654
  setIsValid(false);
620
655
  } else {
621
- setValidationMessage('Valid first name!')
656
+ setValidationMessage('Valid first name!');
622
657
  setIsValid(true);
623
658
  }
624
659
  }}
625
660
  />
626
661
  </Form>
627
662
  );
628
- }
663
+ };
629
664
  ```
630
665
 
631
666
  ### Link
632
667
 
633
668
  ##### Import
669
+
634
670
  ```javascript
635
671
  import { Link } from '@hubspot/ui-extensions';
636
672
  ```
637
673
 
638
674
  ##### Props
675
+
639
676
  ```typescript
640
677
  export interface LinkProps {
641
678
  href: string;
642
679
  variant?: 'primary' | 'destructive' | 'light' | 'dark';
643
680
  children: ReactNode;
681
+ onClick?: () => void;
644
682
  }
645
683
  ```
684
+
646
685
  | Prop | Type | Default | Description |
647
686
  | --- | --- | --- | --- |
648
- | `href` | `string`| `N/A` | A URL that will be opened when the link is clicked. If the value is a URL external to HubSpot it will be opened in a new tab. |
687
+ | `href` | `string` | `N/A` | A URL that will be opened when the link is clicked. If the value is a URL external to HubSpot it will be opened in a new tab. |
649
688
  | `variant` | `'primary' \| 'light' \| 'dark' \| 'destructive'` `(optional)` | `'primary'` | Sets the color variation of the link |
650
- | `children` | `ReactNode` | `N/A`| Sets the content that will render inside the component. |
689
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. |
690
+ | `onClick` | `() => void` `(optional)` | `N/A` | A function that will be invoked when the link is clicked. It receives no arguments and it's return value is ignored |
651
691
 
652
692
  ##### Usage
693
+
653
694
  ```javascript
654
695
  const Extension = () => {
655
- return <Link href="https://app.hubspot.com/">HubSpot</Link>
656
- }
696
+ return <Link href="https://app.hubspot.com/">HubSpot</Link>;
697
+ };
657
698
  ```
699
+
658
700
  ### LoadingSpinner
659
701
 
660
702
  ##### Import
703
+
661
704
  ```javascript
662
705
  import { LoadingSpinner } from '@hubspot/ui-extensions';
663
706
  ```
664
707
 
665
708
  ##### Props
709
+
666
710
  ```typescript
667
711
  export interface LoadingSpinnerProps {
668
712
  label: string;
669
713
  showLabel?: boolean;
670
- size?: 'xs' | 'sm' | 'md';
714
+ size?: 'xs' | 'extra-small' | 'sm' | 'small' | 'md' | 'medium';
671
715
  layout?: 'inline' | 'centered';
672
- grow?: boolean;
673
716
  }
674
717
  ```
718
+
675
719
  | Prop | Type | Default | Description |
676
720
  | --- | --- | --- | --- |
677
- | `label` | `string` | `N/A`| The companion text for the loading spinner. |
721
+ | `label` | `string` | `N/A` | The companion text for the loading spinner. |
678
722
  | `showLabel` | `boolean(optional)` | `false` | if `true`, the label will be visible alongside the loading spinner. |
679
- | `size` | `'xs'\| 'sm' \| 'md'` `(optional)`| `'sm'` | The size of the loading spinner icon. |
680
- | `layout` | `'inline'\| 'centered'` `(optional)`| `N/A` | Use the `centered` option for layout as a convenience for the common pattern of filling the space of its parent. |
681
- | `grow` | `boolean(optional)` | `false` | if `true`, sets the height and width of the loading spinner to 100%.|
723
+ | `size` | `'xs' \| 'sm' \| 'md' \| 'extra-small' \| 'small' \| 'medium'` `(optional)` | `'sm'` | The size of the loading spinner icon. |
724
+ | `layout` | `'inline'\| 'centered'` `(optional)` | `N/A` | Use the `centered` option for layout as a convenience for the common pattern of filling the space of its parent. |
682
725
 
683
726
  ##### Usage
727
+
684
728
  ```javascript
685
729
  const Extension = () => {
686
730
  return <LoadingSpinner label="Loading..." />;
731
+ };
732
+ ```
733
+ ### NumberInput
734
+
735
+ ##### Import
736
+
737
+ ```javascript
738
+ import { NumberInput } from '@hubspot/ui-extensions';
739
+ ```
740
+
741
+ ##### Props
742
+
743
+ ```typescript
744
+ export interface NumberInputProps {
745
+ label: string;
746
+ name: string;
747
+ value?: number;
748
+ required?: boolean;
749
+ readOnly?: boolean;
750
+ description?: string;
751
+ tooltip?: string;
752
+ placeholder?: string;
753
+ error?: boolean;
754
+ defaultValue?: number;
755
+ validationMessage?: string;
756
+ onChange?: (value: number) => void;
757
+ onInput?: (value: number) => void;
758
+ onBlur?: (value: number) => void;
759
+ onFocus?: (value: number) => void;
760
+ min?: number;
761
+ max?: number;
762
+ precision?: number;
763
+ formatStyle?: 'decimal' | 'percentage';
687
764
  }
688
765
  ```
766
+
767
+ | Prop | Type | Default | Description |
768
+ | --- | --- | --- | --- |
769
+ | `label` | `string` | `N/A` | The label text to display for the form input element |
770
+ | `name` | `string` | `N/A` | The unique identifier for the input element, this could be thought of as the HTML5 [Input element's name attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name) |
771
+ | `value` | `number(optional)` | `''` | The value of the input |
772
+ | `required` | `boolean(optional)` | `false` | Determines if the required indicator should be displayed |
773
+ | `readOnly` | `boolean(optional)` | `false` | Determines if the field is editable or not. |
774
+ | `description` | `string(optional)` | `N/A` | Instructional message to display to the user to help understand the purpose of the input. |
775
+ | `tooltip` | `string(optional)` | `N/A` | Text that will appear in a tooltip next to the input label. |
776
+ | `placeholder` | `string(optional)` | `N/A` | Text that appears in the input when it has no value set. |
777
+ | `error` | `boolean(optional)` | `false` | If set to true, `validationMessage` is displayed as an error message, if it was provided. The input will also render it's error state to let the user know there is an error. If false, `validationMessage` is displayed as a success message. |
778
+ | `validationMessage` | `string(optional)` | `''` | The text to show if the input has an error. |
779
+ | `onChange` | `(value: number) => void(optional)` | `N/A` | A callback function that is invoked when the value is committed. Currently these times are `onBlur` of the input and when the user submits the form. |
780
+ | `onInput` | `(value: number) => void(optional)` | `N/A` | A function that is called and passed the value every time the field is edited by the user. It is recommended that you do not use this value to update state, that is what `onChange` should be used for. Instead this should be used for validation. |
781
+ | `onBlur` | `(value: number) => void(optional)` | `N/A` | A function that is called and passed the value every time the field loses focus. |
782
+ | `onFocus` | `(value: number) => void(optional)` | `N/A` | A function that is called and passed the value every time the field gets focused. |
783
+ | `min` | `number(optional)` | `N/A` | Sets the lower bound of your input. |
784
+ | `max` | `number(optional)` | `N/A` | Sets the upper bound of your input. |
785
+ | `precision` | `number(optional)` | `N/A` | Represents the number of digits to the right of the decimal point. |
786
+ | `precision` | `number(optional)` | `N/A` | Represents the number of digits to the right of the decimal point. |
787
+ | `formatStyle` | `'decimal' \| 'percentage'` | `'decimal'` | Formats the input as a decimal point number or a percentage. |
788
+
789
+ ##### Usage
790
+
791
+ ```javascript
792
+ const Extension = () => {
793
+ const [portalCount, setPortalCount] = useState(0);
794
+ return (
795
+ <NumberInput
796
+ label={'HubSpot Portal Count'}
797
+ name="portalsNumber"
798
+ description={'Number of active portals'}
799
+ placeholder={'number of portals'}
800
+ value={portalCount}
801
+ onChange={value => setPortalCount(value)}
802
+ />
803
+ );
804
+ };
805
+ ```
806
+
689
807
  ### ProgressBar
690
808
 
691
809
  ##### Import
810
+
692
811
  ```javascript
693
812
  import { ProgressBar } from '@hubspot/ui-extensions';
694
813
  ```
695
814
 
696
815
  ##### Props
816
+
697
817
  ```typescript
698
- export interface ProgressBarProps {
818
+ export interface ProgressBarProps {
699
819
  title?: string;
700
820
  showPercentage?: boolean;
701
821
  value?: number;
@@ -704,16 +824,18 @@ import { ProgressBar } from '@hubspot/ui-extensions';
704
824
  variant?: 'success' | 'danger' | 'warning';
705
825
  }
706
826
  ```
827
+
707
828
  | Prop | Type | Default | Description |
708
829
  | --- | --- | --- | --- |
709
830
  | `title` | `string(optional)` | `N/A` | Text to be displayed in the progressbar title. |
710
- | `showPercentage` | `boolean(optional)` | `false` | Toggles the display of the completion percentage. |
711
- | `value` | `number(optional)` | `0` | The value of the progress indicator.
712
- | `valueMax` | `number(optional)` | `100` | The maximum value of the progress.
713
- | `valueDescription` | `string(optional)` | `N/A` | Text that explains the current state of the `value` prop. Renders to the right of `title`. **Example: "10,000 of 7,500"**
714
- | `variant` | `'success' \| 'danger' \| 'warning'` | `'success'` | The type of progressbar to display. Defaults to success.
831
+ | `showPercentage` | `boolean(optional)` | `false` | Toggles the display of the completion percentage. |
832
+ | `value` | `number(optional)` | `0` | The value of the progress indicator. |
833
+ | `valueMax` | `number(optional)` | `100` | The maximum value of the progress. |
834
+ | `valueDescription` | `string(optional)` | `N/A` | Text that explains the current state of the `value` prop. Renders to the right of `title`. **Example: "10,000 of 7,500"** |
835
+ | `variant` | `'success' \| 'danger' \| 'warning'` | `'success'` | The type of progressbar to display. Defaults to success. |
715
836
 
716
837
  ##### Usage
838
+
717
839
  ```javascript
718
840
  const Extension = () => {
719
841
  return (
@@ -723,18 +845,20 @@ const Extension = () => {
723
845
  valueMax={200}
724
846
  showPercentage={true}
725
847
  />
726
- );
727
- }
848
+ );
849
+ };
728
850
  ```
729
851
 
730
852
  ### Select
731
853
 
732
854
  ##### Import
855
+
733
856
  ```javascript
734
857
  import { Select } from '@hubspot/ui-extensions';
735
858
  ```
736
859
 
737
860
  ##### Props
861
+
738
862
  ```typescript
739
863
  interface SelectProps {
740
864
  label: string;
@@ -753,33 +877,34 @@ interface SelectProps {
753
877
  value: string | number | boolean;
754
878
  }[];
755
879
  }
756
-
757
880
  ```
881
+
758
882
  | Prop | Type | Default | Description |
759
- | - | - | - | - |
760
- | `label` | `string` | `N/A`| The label text to display for the select element |
761
- | `name` | `string` | `N/A`| The unique identifier for the select element. |
762
- | `value` | `string \| number \| boolean` | `''`| The value of the select input. |
763
- | `required` | `boolean` | `false`| Determines if the required indicator should be displayed |
764
- | `readOnly` | `boolean` | `false`| Determines if the field is editable or not. |
765
- | `description` | `string` | `N/A`| Instructional message to display to the user to help understand the purpose of the input. |
766
- | `tooltip` | `string` | `N/A`| Text that will appear in a tooltip next to the input label. |
767
- | `placeholder` | `string` | `N/A`| Text that appears in the input when it has no value set. |
768
- | `error` | `boolean(optional)` | `false`| If set to true, `validationMessage` is displayed as an error message, if it was provided. The input will also render it's error state to let the user know there is an error. If false, `validationMessage` is displayed as a success message. |
769
- | `validationMessage` | `string(optional)` | `''`| The text to show if the input has an error. |
770
- | `onChange` | `(value: string) => void` | `N/A`| Function that is called with the new value when it is updated. |
771
- | `options` | `Array<{label: string; value: string \| number \| boolean}>` | `N/A`| Array of options to be displayed in the select. `label` will be used as the display text in the dropdown list and `value` should be a **unique** identifier. `value` is the data that will be submitted with the form. |
883
+ | --- | --- | --- | --- |
884
+ | `label` | `string` | `N/A` | The label text to display for the select element |
885
+ | `name` | `string` | `N/A` | The unique identifier for the select element. |
886
+ | `value` | `string \| number \| boolean` | `''` | The value of the select input. |
887
+ | `required` | `boolean` | `false` | Determines if the required indicator should be displayed |
888
+ | `readOnly` | `boolean` | `false` | Determines if the field is editable or not. |
889
+ | `description` | `string` | `N/A` | Instructional message to display to the user to help understand the purpose of the input. |
890
+ | `tooltip` | `string` | `N/A` | Text that will appear in a tooltip next to the input label. |
891
+ | `placeholder` | `string` | `N/A` | Text that appears in the input when it has no value set. |
892
+ | `error` | `boolean(optional)` | `false` | If set to true, `validationMessage` is displayed as an error message, if it was provided. The input will also render it's error state to let the user know there is an error. If false, `validationMessage` is displayed as a success message. |
893
+ | `validationMessage` | `string(optional)` | `''` | The text to show if the input has an error. |
894
+ | `onChange` | `(value: string) => void` | `N/A` | Function that is called with the new value when it is updated. |
895
+ | `options` | `Array<{label: string; value: string \| number \| boolean}>` | `N/A` | Array of options to be displayed in the select. `label` will be used as the display text in the dropdown list and `value` should be a **unique** identifier. `value` is the data that will be submitted with the form. |
772
896
 
773
897
  ##### Usage
898
+
774
899
  ```javascript
775
900
  const Extension = () => {
776
- const [ name, setName ] = useState(null);
777
- const [ validationMessage, setValidationMessage ] = useState('');
778
- const [ isValid, setIsValid ] = useState(true);
901
+ const [name, setName] = useState(null);
902
+ const [validationMessage, setValidationMessage] = useState('');
903
+ const [isValid, setIsValid] = useState(true);
779
904
 
780
905
  const options = [
781
- {label: 'Bill', value: 42},
782
- {label: 'Ted', value: 43}
906
+ { label: 'Bill', value: 42 },
907
+ { label: 'Ted', value: 43 },
783
908
  ];
784
909
 
785
910
  return (
@@ -793,9 +918,9 @@ const Extension = () => {
793
918
  required={true}
794
919
  error={!isValid}
795
920
  validationMessage={validationMessage}
796
- onChange={(value) => {
797
- setName(value)
798
- if(!value) {
921
+ onChange={value => {
922
+ setName(value);
923
+ if (!value) {
799
924
  setValidationMessage('This is required');
800
925
  setIsValid(false);
801
926
  } else {
@@ -807,31 +932,46 @@ const Extension = () => {
807
932
  />
808
933
  </Form>
809
934
  );
810
- }
935
+ };
811
936
  ```
812
937
 
813
938
  ### Stack
814
939
 
815
940
  ##### Import
941
+
816
942
  ```javascript
817
943
  import { Stack } from '@hubspot/ui-extensions';
818
944
  ```
819
945
 
820
946
  ##### Props
947
+
821
948
  ```typescript
822
949
  interface StackProps {
823
- distance?: 'flush' | 'small' | 'extra-small' | 'medium' | 'large';
950
+ distance?:
951
+ | 'flush'
952
+ | 'small'
953
+ | 'extra-small'
954
+ | 'medium'
955
+ | 'large'
956
+ | 'extra-large'
957
+ | 'xs'
958
+ | 'sm'
959
+ | 'md'
960
+ | 'lg'
961
+ | 'xl';
824
962
  direction?: 'row' | 'column';
825
963
  children?: ReactNode;
826
964
  }
827
965
  ```
966
+
828
967
  | Prop | Type | Default | Description |
829
- | - | - | - | - |
830
- | `distance` | `'flush' \| 'extra-small' \| 'small' \| 'medium' \| 'large'` | `'small'`| Amount of space between each child component passed as children |
831
- | `direction` | `'row' \| 'column'` | `'column'`| Stacks elements in the vertical or horizontal direction. |
832
- | `children` | `ReactNode` | `N/A`| Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
968
+ | --- | --- | --- | --- |
969
+ | `distance` | `'flush' \| 'extra-small' \| 'small' \| 'medium' \| 'large' \| 'extra-large' \| 'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | `'small'` | Amount of space between each child component passed as children |
970
+ | `direction` | `'row' \| 'column'` | `'column'` | Stacks elements in the vertical or horizontal direction. |
971
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
833
972
 
834
973
  ##### Usage
974
+
835
975
  ```javascript
836
976
  const Extension = () => {
837
977
  return (
@@ -846,21 +986,25 @@ const Extension = () => {
846
986
  ### Statistics
847
987
 
848
988
  ##### Import
989
+
849
990
  ```javascript
850
991
  import { Statistics } from '@hubspot/ui-extensions';
851
992
  ```
852
993
 
853
994
  ##### Props
995
+
854
996
  ```typescript
855
997
  interface StatisticsProps {
856
998
  children: ReactNode;
857
999
  }
858
1000
  ```
1001
+
859
1002
  | Prop | Type | Default | Description |
860
- | - | - | - | - |
861
- | `children` | `ReactNode` | `N/A`| Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. These children should be [StatisticsItem](#statisticsitem) or [StatisticsTrend](#statisticstrend) |
1003
+ | --- | --- | --- | --- |
1004
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. These children should be [StatisticsItem](#statisticsitem) or [StatisticsTrend](#statisticstrend) |
862
1005
 
863
1006
  ##### Usage
1007
+
864
1008
  ```javascript
865
1009
  const Extension = () => {
866
1010
  return (
@@ -875,11 +1019,13 @@ const Extension = () => {
875
1019
  #### StatisticsItem
876
1020
 
877
1021
  ##### Import
1022
+
878
1023
  ```javascript
879
1024
  import { StatisticsItem } from '@hubspot/ui-extensions';
880
1025
  ```
881
1026
 
882
1027
  ##### Props
1028
+
883
1029
  ```typescript
884
1030
  interface StatisticsItemProps {
885
1031
  id?: string;
@@ -888,46 +1034,52 @@ interface StatisticsItemProps {
888
1034
  children: ReactNode;
889
1035
  }
890
1036
  ```
1037
+
891
1038
  | Prop | Type | Default | Description |
892
- | - | - | - | - |
893
- | `id` | `string(optional)` | `N/A`| The unique identifier |
894
- | `label` | `string` | `N/A`| The text to be used as a label |
895
- | `number` | `string` | `N/A`| Fully formatted string to be displayed as the item's primary number |
896
- | `children` | `ReactNode` | `N/A`| Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. These children should be [Text](#text) or [StatisticsTrend](#statisticstrend) |
1039
+ | --- | --- | --- | --- |
1040
+ | `id` | `string(optional)` | `N/A` | The unique identifier |
1041
+ | `label` | `string` | `N/A` | The text to be used as a label |
1042
+ | `number` | `string` | `N/A` | Fully formatted string to be displayed as the item's primary number |
1043
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. These children should be [Text](#text) or [StatisticsTrend](#statisticstrend) |
897
1044
 
898
1045
  ##### Usage
1046
+
899
1047
  ```javascript
900
1048
  const Extension = () => {
901
1049
  return (
902
1050
  <Statistics>
903
1051
  <StatisticsItem label="Sales" number={'30000'}>
904
- <Text text="Big Numbers" />
1052
+ <Text>Big Numbers</Text>
905
1053
  </StatisticsItem>
906
1054
  </Statistics>
907
1055
  );
908
- }
1056
+ };
909
1057
  ```
910
1058
 
911
1059
  #### StatisticsTrend
912
1060
 
913
1061
  ##### Import
1062
+
914
1063
  ```javascript
915
1064
  import { StatisticsTrend } from '@hubspot/ui-extensions';
916
1065
  ```
917
1066
 
918
1067
  ##### Props
1068
+
919
1069
  ```typescript
920
1070
  interface StatisticsTrendProps {
921
1071
  value: string;
922
1072
  direction: 'increase' | 'decrease';
923
1073
  }
924
1074
  ```
1075
+
925
1076
  | Prop | Type | Default | Description |
926
- | - | - | - | - |
927
- | `value` | `string` | `N/A`| Formatted string to be displayed as trend value |
928
- | `direction` | `'increase' \| 'decrease'` | `N/A`| Direction in which the trend arrow should be displayed |
1077
+ | --- | --- | --- | --- |
1078
+ | `value` | `string` | `N/A` | Formatted string to be displayed as trend value |
1079
+ | `direction` | `'increase' \| 'decrease'` | `N/A` | Direction in which the trend arrow should be displayed |
929
1080
 
930
1081
  ##### Usage
1082
+
931
1083
  ```javascript
932
1084
  const Extension = () => {
933
1085
  return (
@@ -940,18 +1092,19 @@ const Extension = () => {
940
1092
  </StatisticsItem>
941
1093
  </Statistics>
942
1094
  );
943
- }
1095
+ };
944
1096
  ```
945
1097
 
946
-
947
1098
  ### Table
948
1099
 
949
1100
  ##### Import
1101
+
950
1102
  ```javascript
951
1103
  import { Table } from '@hubspot/ui-extensions';
952
1104
  ```
953
1105
 
954
1106
  ##### Props
1107
+
955
1108
  ```typescript
956
1109
  interface TableProps {
957
1110
  children: ReactNode;
@@ -967,26 +1120,27 @@ interface TableProps {
967
1120
  page?: number;
968
1121
  }
969
1122
  ```
1123
+
970
1124
  | Prop | Type | Default | Description |
971
- | - | - | - | - |
972
- | `children` | `ReactNode` | `N/A`| Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. These children should be [TableHead](#tablehead), [TableFooter](#tablefooter), or [TableBody](#tablebody) |
973
- | `flush` | `boolean(optional)` | `false`| If true the table will not have bottom margin. |
974
- | `bordered` | `boolean(optional)` | `true`| If false the table will not haver borders around its content. |
975
- | `paginated` | `boolean(optional)` | `false`| If true, the table will display the paginator component and consumer will have to provide extra pagination props. |
1125
+ | --- | --- | --- | --- |
1126
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. These children should be [TableHead](#tablehead), [TableFooter](#tablefooter), or [TableBody](#tablebody) |
1127
+ | `flush` | `boolean(optional)` | `false` | If true the table will not have bottom margin. |
1128
+ | `bordered` | `boolean(optional)` | `true` | If false the table will not haver borders around its content. |
1129
+ | `paginated` | `boolean(optional)` | `false` | If true, the table will display the paginator component and consumer will have to provide extra pagination props. |
976
1130
 
977
1131
  **Props for paginated=true**
978
1132
 
979
1133
  | Prop | Type | Default | Description |
980
- | - | - | - | - |
981
- | `pageCount` | `number` | `N/A`| The total number of pages available |
982
- | `onPageChange` | `onPageChange: (pageNumber: number) => void` |`N/A`| A function that will be invoked when the pagination button is clicked. It receives the new page number as argument. |
1134
+ | --- | --- | --- | --- |
1135
+ | `pageCount` | `number` | `N/A` | The total number of pages available |
1136
+ | `onPageChange` | `onPageChange: (pageNumber: number) => void` | `N/A` | A function that will be invoked when the pagination button is clicked. It receives the new page number as argument. |
983
1137
  | `showButtonLabels` | `boolean(optional)` | `true` | if `false`, it hides the text labels for the First/Prev/Next/Last buttons. The button labels will still be accessible for screen readers. |
984
1138
  | `showFirstLastButtons` | `boolean(optional)` | `false` | if `true`, it displays the First page and Last page buttons. |
985
1139
  | `maxVisiblePageButtons` | `number(optional)` | `5` | Changes how many page buttons are shown. |
986
1140
  | `page` | `number(optional)` | `N/A` | Denotes the current page. |
987
1141
 
988
-
989
1142
  ##### Usage
1143
+
990
1144
  ```javascript
991
1145
  const Extension = () => {
992
1146
  return (
@@ -1005,8 +1159,7 @@ const Extension = () => {
1005
1159
  </TableBody>
1006
1160
  </Table>
1007
1161
  );
1008
- }
1009
-
1162
+ };
1010
1163
 
1011
1164
  // Paginated example
1012
1165
 
@@ -1065,24 +1218,29 @@ function PaginatedTable() {
1065
1218
  );
1066
1219
  }
1067
1220
  ```
1221
+
1068
1222
  ### TableBody
1069
1223
 
1070
1224
  ##### Import
1225
+
1071
1226
  ```javascript
1072
1227
  import { TableBody } from '@hubspot/ui-extensions';
1073
1228
  ```
1074
1229
 
1075
1230
  ##### Props
1231
+
1076
1232
  ```typescript
1077
1233
  interface TableBodyProps {
1078
1234
  children: ReactNode;
1079
1235
  }
1080
1236
  ```
1237
+
1081
1238
  | Prop | Type | Default | Description |
1082
- | - | - | - | - |
1083
- | `children` | `ReactNode` | `N/A`| Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. These children should be [TableRow](#tablerow). |
1239
+ | --- | --- | --- | --- |
1240
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. These children should be [TableRow](#tablerow). |
1084
1241
 
1085
1242
  ##### Usage
1243
+
1086
1244
  ```javascript
1087
1245
  const Extension = () => {
1088
1246
  return (
@@ -1101,26 +1259,31 @@ const Extension = () => {
1101
1259
  </TableBody>
1102
1260
  </Table>
1103
1261
  );
1104
- }
1262
+ };
1105
1263
  ```
1264
+
1106
1265
  ### TableCell
1107
1266
 
1108
1267
  ##### Import
1268
+
1109
1269
  ```javascript
1110
1270
  import { TableCell } from '@hubspot/ui-extensions';
1111
1271
  ```
1112
1272
 
1113
1273
  ##### Props
1274
+
1114
1275
  ```typescript
1115
1276
  interface TableCellProps {
1116
1277
  children: ReactNode;
1117
1278
  }
1118
1279
  ```
1280
+
1119
1281
  | Prop | Type | Default | Description |
1120
- | - | - | - | - |
1121
- | `children` | `ReactNode` | `N/A`| Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components.|
1282
+ | --- | --- | --- | --- |
1283
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
1122
1284
 
1123
1285
  ##### Usage
1286
+
1124
1287
  ```javascript
1125
1288
  const Extension = () => {
1126
1289
  return (
@@ -1139,26 +1302,31 @@ const Extension = () => {
1139
1302
  </TableBody>
1140
1303
  </Table>
1141
1304
  );
1142
- }
1305
+ };
1143
1306
  ```
1307
+
1144
1308
  ### TableFooter
1145
1309
 
1146
1310
  ##### Import
1311
+
1147
1312
  ```javascript
1148
1313
  import { TableFooter } from '@hubspot/ui-extensions';
1149
1314
  ```
1150
1315
 
1151
1316
  ##### Props
1317
+
1152
1318
  ```typescript
1153
1319
  interface TableFooterProps {
1154
1320
  children: ReactNode;
1155
1321
  }
1156
1322
  ```
1323
+
1157
1324
  | Prop | Type | Default | Description |
1158
- | - | - | - | - |
1159
- | `children` | `ReactNode` | `N/A`| Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. These children should be [TableRow](#tablerow). |
1325
+ | --- | --- | --- | --- |
1326
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. These children should be [TableRow](#tablerow). |
1160
1327
 
1161
1328
  ##### Usage
1329
+
1162
1330
  ```javascript
1163
1331
  const Extension = () => {
1164
1332
  return (
@@ -1196,27 +1364,31 @@ const Extension = () => {
1196
1364
  </TableBody>
1197
1365
  </Table>
1198
1366
  );
1199
- }
1367
+ };
1200
1368
  ```
1201
1369
 
1202
1370
  ### TableHead
1203
1371
 
1204
1372
  ##### Import
1373
+
1205
1374
  ```javascript
1206
1375
  import { TableHead } from '@hubspot/ui-extensions';
1207
1376
  ```
1208
1377
 
1209
1378
  ##### Props
1379
+
1210
1380
  ```typescript
1211
1381
  interface TableHeadProps {
1212
1382
  children: ReactNode;
1213
1383
  }
1214
1384
  ```
1385
+
1215
1386
  | Prop | Type | Default | Description |
1216
- | - | - | - | - |
1217
- | `children` | `ReactNode` | `N/A`| Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. These children should be [TableHeader](#tableheader). |
1387
+ | --- | --- | --- | --- |
1388
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. These children should be [TableHeader](#tableheader). |
1218
1389
 
1219
1390
  ##### Usage
1391
+
1220
1392
  ```javascript
1221
1393
  const Extension = () => {
1222
1394
  return (
@@ -1235,26 +1407,31 @@ const Extension = () => {
1235
1407
  </TableBody>
1236
1408
  </Table>
1237
1409
  );
1238
- }
1410
+ };
1239
1411
  ```
1412
+
1240
1413
  ### TableHeader
1241
1414
 
1242
1415
  ##### Import
1416
+
1243
1417
  ```javascript
1244
1418
  import { TableHeader } from '@hubspot/ui-extensions';
1245
1419
  ```
1246
1420
 
1247
1421
  ##### Props
1422
+
1248
1423
  ```typescript
1249
1424
  interface TableHeaderProps {
1250
1425
  children: ReactNode;
1251
1426
  }
1252
1427
  ```
1428
+
1253
1429
  | Prop | Type | Default | Description |
1254
- | - | - | - | - |
1255
- | `children` | `ReactNode` | `N/A`| Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components.|
1430
+ | --- | --- | --- | --- |
1431
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
1256
1432
 
1257
1433
  ##### Usage
1434
+
1258
1435
  ```javascript
1259
1436
  const Extension = () => {
1260
1437
  return (
@@ -1273,26 +1450,31 @@ const Extension = () => {
1273
1450
  </TableBody>
1274
1451
  </Table>
1275
1452
  );
1276
- }
1453
+ };
1277
1454
  ```
1455
+
1278
1456
  ### TableRow
1279
1457
 
1280
1458
  ##### Import
1459
+
1281
1460
  ```javascript
1282
1461
  import { TableRow } from '@hubspot/ui-extensions';
1283
1462
  ```
1284
1463
 
1285
1464
  ##### Props
1465
+
1286
1466
  ```typescript
1287
1467
  interface TableRowProps {
1288
1468
  children: ReactNode;
1289
1469
  }
1290
1470
  ```
1471
+
1291
1472
  | Prop | Type | Default | Description |
1292
- | - | - | - | - |
1293
- | `children` | `ReactNode` | `N/A`| Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components.|
1473
+ | --- | --- | --- | --- |
1474
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
1294
1475
 
1295
1476
  ##### Usage
1477
+
1296
1478
  ```javascript
1297
1479
  const Extension = () => {
1298
1480
  return (
@@ -1311,100 +1493,128 @@ const Extension = () => {
1311
1493
  </TableBody>
1312
1494
  </Table>
1313
1495
  );
1314
- }
1496
+ };
1315
1497
  ```
1316
1498
 
1317
1499
  ### Tag
1318
1500
 
1319
1501
  ##### Import
1502
+
1320
1503
  ```javascript
1321
1504
  import { Tag } from '@hubspot/ui-extensions';
1322
1505
  ```
1323
1506
 
1324
1507
  ##### Props
1508
+
1325
1509
  ```typescript
1326
1510
  interface TagProps {
1327
- text: string;
1511
+ children: ReactNode;
1328
1512
  onClick?: () => void;
1329
1513
  variant?: 'default' | 'warning' | 'success' | 'error';
1330
1514
  }
1331
1515
  ```
1516
+
1332
1517
  | Prop | Type | Default | Description |
1333
- | - | - | - | - |
1334
- | `text` | `string` | `N/A`| Text to be displayed in the tag. |
1335
- | `onClick` | `() => void` `(optional)` | `N/A` | A function that will be invoked when the `Tag` is clicked. It receives no arguments and it's return value is ignored. |
1336
- | `variant` | `'default' \| 'warning' \| 'success' \| 'error'` `(optional)` | `'default'`| The color variation of the tag to display |
1518
+ | --- | --- | --- | --- |
1519
+ | `children` | `string` | `N/A` | Text to be displayed in the tag. |
1520
+ | `onClick` | `() => void` `(optional)` | `N/A` | A function that will be invoked when the `Tag` is clicked. It receives no arguments and it's return value is ignored. |
1521
+ | `variant` | `'default' \| 'warning' \| 'success' \| 'error'` `(optional)` | `'default'` | The color variation of the tag to display |
1337
1522
 
1338
1523
  ##### Usage
1524
+
1339
1525
  ```javascript
1340
1526
  const Extension = () => {
1341
1527
  return (
1342
1528
  <Tag
1343
- text="Success"
1344
- variant='success'
1529
+ variant="success"
1345
1530
  onClick={() => {
1346
1531
  console.log('Tag clicked!');
1347
1532
  }}
1348
- />
1533
+ >
1534
+ Success
1535
+ </Tag>
1349
1536
  );
1350
- }
1537
+ };
1351
1538
  ```
1352
1539
 
1353
1540
  ### Text
1354
1541
 
1355
1542
  ##### Import
1543
+
1356
1544
  ```javascript
1357
1545
  import { Text } from '@hubspot/ui-extensions';
1358
1546
  ```
1359
1547
 
1360
1548
  ##### Props
1549
+
1361
1550
  ```typescript
1362
- interface TextProps {
1363
- format?: 'plaintext' | 'markdown';
1364
- text: string;
1551
+ export interface TextFormatOptions {
1552
+ fontWeight?: 'regular' | 'bold' | 'demibold';
1553
+ italic?: boolean;
1554
+ lineDecoration?: 'none' | 'underline' | 'strikethrough';
1555
+ }
1556
+
1557
+ export type TextProps = {
1365
1558
  variant?: 'bodytext' | 'microcopy';
1559
+ inline?: boolean;
1366
1560
  children: ReactNode;
1367
- tagName?: 'p' | 'span' | 'small';
1368
- }
1561
+ format?: TextFormatOptions;
1562
+ };
1369
1563
  ```
1564
+
1370
1565
  | Prop | Type | Default | Description |
1371
- | - | - | - | - |
1372
- | `format` | `'plaintext' \| 'markdown'` `(optional)`| `'plaintext'`| Type of formatting for the display text. |
1373
- | `text` | `string` | `N/A`| Text to be displayed as body text iff format is `"markdown"`. Inline markdown elements (i.e. bold, italics, code, links) are supported |
1374
- | `children` | `string` | `N/A`| Text to be displayed as body text iff format is `"plaintext"`. |
1375
- | `variant` | `'bodytext' \| 'microcopy'` | `'bodytext`| Type of text to display |
1376
- | `tagName` | `'p' \| 'small' \| 'span'` | `'bodytext`| Type of text element(tag) to display. |
1566
+ | --- | --- | --- | --- |
1567
+ | `format` | `'TextFormatOptions'` `(optional)` | `N/A` | Type of formatting options for the text. |
1568
+ | `children` | `string` | `N/A` | Text to be displayed as body text. |
1569
+ | `variant` | `'bodytext' \| 'microcopy'` | `'bodytext'` | Type of text to display |
1570
+ | `inline` | `boolean(optional)` | `false` | If `false` the text component will not insert a line break. |
1377
1571
 
1378
- #### Markdown
1379
- Markdown syntax supported in the component:
1572
+ #### Format Options
1573
+
1574
+ - bold text: `{ fontWeight: 'bold' }`
1575
+ - semibold text: `{ fontWeight: 'demibold' }`
1576
+ - italicized text: `{ italic: true }`
1577
+ - strikethrough text: `{ lineDecoration: 'strikethrough' }`
1578
+ - underlined text: `{ lineDecoration: 'underline' }`
1579
+ - inline text: `<Text inline={true}/>`
1380
1580
 
1381
- - bold text: `**like this**` or `__like this__`
1382
- - italicized text: `*like this*` or `_like this_`
1383
- - inline code: `` `like this` ``
1384
- - links: `[visible anchor text](https://www.hubspot.com/)`
1385
1581
 
1386
1582
  ##### Usage
1583
+
1387
1584
  ```javascript
1388
1585
  const Extension = () => {
1389
1586
  return (
1390
1587
  <>
1391
- <Text text="**Bold**" format="markdown"/>
1392
- <Text text="*Italics*" format="markdown"/>
1393
- <Text text="**Not Bold because format isn't markdown**"/>
1394
- <Text text="This is going to be small" variant="microcopy"/>
1588
+ <Text>Plain text</Text>
1589
+ <Text format={{ fontWeight: 'bold' }}>Bold</Text>
1590
+ <Text format={{ italic: true }}>Italics</Text>
1591
+ <Text format={{ fontWeight: 'bold', italic: true }}>
1592
+ Bold and Italic text
1593
+ </Text>
1594
+ <Text format={{ lineDecoration: 'strikethrough' }}>
1595
+ Strikethrough Text
1596
+ </Text>
1597
+ <Text variant="microcopy">
1598
+ Microcopy text
1599
+ <Text inline={true} format={{ fontWeight: 'bold' }}>
1600
+ with inner bold
1601
+ </Text>
1602
+ </Text>
1395
1603
  </>
1396
1604
  );
1397
- }
1605
+ };
1398
1606
  ```
1399
1607
 
1400
1608
  ### Textarea
1401
1609
 
1402
1610
  ##### Import
1611
+
1403
1612
  ```javascript
1404
1613
  import { Textarea } from '@hubspot/ui-extensions';
1405
1614
  ```
1406
1615
 
1407
1616
  ##### Props
1617
+
1408
1618
  ```typescript
1409
1619
  interface TextareaProps {
1410
1620
  label: string;
@@ -1427,35 +1637,37 @@ interface TextareaProps {
1427
1637
  resize?: 'vertical' | 'horizontal' | 'both' | 'none';
1428
1638
  }
1429
1639
  ```
1640
+
1430
1641
  | Prop | Type | Default | Description |
1431
- | - | - | - | - |
1432
- | `label` | `string` | `N/A`| The label text to display for the textarea element |
1433
- | `name` | `string` | `N/A`| The unique identifier for the textarea element, this could be thought of as the HTML5 [Textarea element's name attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#name) |
1434
- | `value` | `string(optional)` | `''`| The value of the textarea |
1435
- | `required` | `boolean(optional)` | `false`| Determines if the required indicator should be displayed |
1436
- | `readOnly` | `boolean(optional)` | `false`| Determines if the field is editable or not. |
1437
- | `description` | `string(optional)` | `N/A`| Instructional message to display to the user to help understand the purpose of the textarea. |
1438
- | `tooltip` | `string(optional)` | `N/A`| Text that will appear in a tooltip next to the textarea label. |
1439
- | `placeholder` | `string(optional)` | `N/A`| Text that appears in the textarea when it has no value set. |
1440
- | `error` | `boolean(optional)` | `false`| If set to true, `validationMessage` is displayed as an error message, if it was provided. The textarea will also render it's error state to let the user know there is an error. If false, `validationMessage` is displayed as a success message. |
1441
- | `validationMessage` | `string(optional)` | `''`| The text to show if the textarea has an error. |
1442
- | `onChange` | `(value: string) => void(optional)` | `N/A` | A callback function that is invoked when the value is committed. Currently these times are `onBlur` of the textarea and when the user submits the form. |
1443
- | `onInput` | `(value: string) => void(optional)` | `N/A`| A function that is called and passed the value every time the field is edited by the user. It is recommended that you do not use this value to update state, that is what `onChange` should be used for. Instead this should be used for validation. |
1444
- | `onBlur` | `(value: string) => void(optional)` | `N/A`| A function that is called and passed the value every time the field loses focus. |
1445
- | `onFocus` | `(value: string) => void(optional)` | `N/A`| A function that is called and passed the value every time the field gets focused. |
1642
+ | --- | --- | --- | --- |
1643
+ | `label` | `string` | `N/A` | The label text to display for the textarea element |
1644
+ | `name` | `string` | `N/A` | The unique identifier for the textarea element, this could be thought of as the HTML5 [Textarea element's name attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#name) |
1645
+ | `value` | `string(optional)` | `''` | The value of the textarea |
1646
+ | `required` | `boolean(optional)` | `false` | Determines if the required indicator should be displayed |
1647
+ | `readOnly` | `boolean(optional)` | `false` | Determines if the field is editable or not. |
1648
+ | `description` | `string(optional)` | `N/A` | Instructional message to display to the user to help understand the purpose of the textarea. |
1649
+ | `tooltip` | `string(optional)` | `N/A` | Text that will appear in a tooltip next to the textarea label. |
1650
+ | `placeholder` | `string(optional)` | `N/A` | Text that appears in the textarea when it has no value set. |
1651
+ | `error` | `boolean(optional)` | `false` | If set to true, `validationMessage` is displayed as an error message, if it was provided. The textarea will also render it's error state to let the user know there is an error. If false, `validationMessage` is displayed as a success message. |
1652
+ | `validationMessage` | `string(optional)` | `''` | The text to show if the textarea has an error. |
1653
+ | `onChange` | `(value: string) => void(optional)` | `N/A` | A callback function that is invoked when the value is committed. Currently these times are `onBlur` of the textarea and when the user submits the form. |
1654
+ | `onInput` | `(value: string) => void(optional)` | `N/A` | A function that is called and passed the value every time the field is edited by the user. It is recommended that you do not use this value to update state, that is what `onChange` should be used for. Instead this should be used for validation. |
1655
+ | `onBlur` | `(value: string) => void(optional)` | `N/A` | A function that is called and passed the value every time the field loses focus. |
1656
+ | `onFocus` | `(value: string) => void(optional)` | `N/A` | A function that is called and passed the value every time the field gets focused. |
1446
1657
  | `cols` | `number(optional)` | `N/A` | The visible width of the text control, in average character widths. |
1447
1658
  | `rows` | `number(optional)` | `N/A` | The number of visible text lines for the control. |
1448
1659
  | `maxLength` | `number(optional)` | `N/A` | The maximum number of characters (UTF-16 code units) that the user can enter. If this value isn't specified, the user can enter an unlimited number of characters. |
1449
- | `resize` | `'vertical' \| 'horizontal' \| 'both' \| 'none'` `(optional)`| `'vertical'` | Sets whether an element is resizable, and if so, in which directions. |
1660
+ | `resize` | `'vertical' \| 'horizontal' \| 'both' \| 'none'` `(optional)` | `'vertical'` | Sets whether an element is resizable, and if so, in which directions. |
1450
1661
 
1451
1662
  ##### Usage
1663
+
1452
1664
  ```javascript
1453
1665
  import { useState } from 'react';
1454
1666
 
1455
1667
  const Extension = () => {
1456
- const [ desciptiption, setDescription ] = useState('');
1457
- const [ validationMessage, setValidationMessage ] = useState('');
1458
- const [ isValid, setIsValid ] = useState(true);
1668
+ const [desciptiption, setDescription] = useState('');
1669
+ const [validationMessage, setValidationMessage] = useState('');
1670
+ const [isValid, setIsValid] = useState(true);
1459
1671
 
1460
1672
  return (
1461
1673
  <Form>
@@ -1468,58 +1680,137 @@ const Extension = () => {
1468
1680
  required={true}
1469
1681
  error={!isValid}
1470
1682
  validationMessage={validationMessage}
1471
- onChange={(value) => {
1472
- setDescription(value)
1683
+ onChange={value => {
1684
+ setDescription(value);
1473
1685
  }}
1474
- onInput={(value) => {
1686
+ onInput={value => {
1475
1687
  if (!value.includes('http')) {
1476
1688
  setValidationMessage('A link must be included.');
1477
1689
  setIsValid(false);
1478
1690
  } else {
1479
- setValidationMessage('Valid description!')
1691
+ setValidationMessage('Valid description!');
1480
1692
  setIsValid(true);
1481
1693
  }
1482
1694
  }}
1483
1695
  />
1484
1696
  </Form>
1485
1697
  );
1486
- }
1698
+ };
1487
1699
  ```
1488
1700
 
1489
-
1490
1701
  ### Tile
1491
1702
 
1492
1703
  ##### Import
1704
+
1493
1705
  ```javascript
1494
1706
  import { Tile } from '@hubspot/ui-extensions';
1495
1707
  ```
1496
1708
 
1497
1709
  ##### Props
1710
+
1498
1711
  ```typescript
1499
1712
  interface TileProps {
1500
1713
  children: ReactNode;
1501
1714
  flush?: boolean;
1502
1715
  }
1503
1716
  ```
1717
+
1504
1718
  | Prop | Type | Default | Description |
1505
- | - | - | - | - |
1506
- | `children` | `ReactNode` | `N/A`| Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
1507
- | `flush` | `boolean(optional)` | `false`| If true the content of the Tile will have no left or right padding. |
1719
+ | --- | --- | --- | --- |
1720
+ | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
1721
+ | `flush` | `boolean(optional)` | `false` | If true the content of the Tile will have no left or right padding. |
1508
1722
 
1509
1723
  ##### Usage
1724
+
1510
1725
  ```javascript
1511
1726
  const Extension = () => {
1512
1727
  return (
1513
1728
  <>
1514
1729
  <Tile flush={true}>
1515
- <Text text="No left padding" />
1730
+ <Text>No left padding</Text>
1516
1731
  </Tile>
1517
1732
  <Tile>
1518
- <Text text="Small amount of left padding" />
1733
+ <Text>Small amount of left padding</Text>
1519
1734
  </Tile>
1520
1735
  </>
1521
1736
  );
1522
- }
1737
+ };
1738
+ ```
1739
+
1740
+ ### ToggleGroup
1741
+
1742
+ ##### Import
1743
+
1744
+ ```javascript
1745
+ import { ToggleGroup } from '@hubspot/ui-extensions';
1746
+ ```
1747
+
1748
+ ##### Props
1749
+
1750
+ ```typescript
1751
+ type ToggleGroupProps = {
1752
+ toggleType: 'checkboxList' | 'radioButtonList';
1753
+ name: string;
1754
+ label: string;
1755
+ value?: string | string[];
1756
+ onChange?: (value: string) => void | (value: string[]) => void;
1757
+ validationMessage?: string;
1758
+ required?: boolean;
1759
+ tooltip?: string;
1760
+ error?: boolean;
1761
+ options: {
1762
+ label: string;
1763
+ value: string;
1764
+ initialIsChecked?: boolean;
1765
+ readonly?: boolean;
1766
+ description?: string;
1767
+ }[];
1768
+ inline?: boolean;
1769
+ variant?: 'default' | 'small';
1770
+ };
1771
+
1772
+ ```
1523
1773
 
1774
+ | Prop | Type | Default | Description |
1775
+ | --- | --- | --- | --- | --- |
1776
+ | `toggleType` | `'radioButtonList' \| 'checkboxList'` | `N/A` | The type of toggles that will be shown. `'checkboxList'` is a multi-select and `'radioButtonList'` is a single select | ; |
1777
+ | `name` | `string` | `N/A` | The unique identifier for the toggle group element. |
1778
+ | `label` | `string` | `N/A` | The label text to display for the toggle group element. |
1779
+ | `options` | `Array<{ label: string; value: string; initialIsChecked?: boolean; readonly?: boolean; description?: string }>` | `N/A` | |
1780
+ | `value` | `string \| string[]` `(optional)` | `N/A` | The value of the toggle group. If `toggleType` is `'radioButtonList'`, this should be a `string`. If `toggleType` is `'checkboxList'` this should be an array of `string`s. |
1781
+ | `onChange` | `(value: string) => void \| (value: string[]) => void` `(optional)` | `N/A` | A function that is called with the new value or values when it is updated. If `toggleType` is `'radioButtonList'`, the function will be called with the `value` that is a `string`. If `toggleType` is `'checkboxList'` the function will be called with the `value` that is an array of `string`s. |
1782
+ | `required` | `boolean(optional)` | `false` | Determines if the required indicator should be displayed |
1783
+ | `tooltip` | `string` | `N/A` | Text that will appear in a tooltip next to the toggle group label. |
1784
+ | `error` | `boolean(optional)` | `false` | If set to true, `validationMessage` is displayed as an error message, if it was provided. The input will also render it's error state to let the user know there is an error. If false, `validationMessage` is displayed as a success message. |
1785
+ | `validationMessage` | `string(optional)` | `''` | The text to show if the input has an error. |
1786
+ | `inline` | `boolean(optional)` | `false` | Determines of the options are stacked vertically or share a line horizontally. |
1787
+ | `variant` | `'default' \| 'small'` `(optional)` | `default` | The size variation of the individual options. |
1788
+
1789
+ ##### Usage
1790
+
1791
+ ```javascript
1792
+ const options = [1, 2, 3, 4].map(n => ({
1793
+ label: `Option ${n}`,
1794
+ value: `${n}`,
1795
+ initialIsChecked: n === 2,
1796
+ readonly: false,
1797
+ description: `This is option ${n}`,
1798
+ }));
1524
1799
 
1800
+ const Extension = () => {
1801
+ return (
1802
+ <ToggleGroup
1803
+ name="toggle-checkboxes"
1804
+ label="Toggle these things"
1805
+ error={false}
1806
+ options={options}
1807
+ tooltip="Here's a secret tip."
1808
+ validationMessage="Make sure you do the thing correctly."
1809
+ required={false}
1810
+ inline={false}
1811
+ toggleType="checkboxList"
1812
+ variant="default"
1813
+ />
1814
+ );
1815
+ };
1525
1816
  ```