@hubspot/ui-extensions 0.6.0 → 0.7.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
@@ -10,6 +10,7 @@ React components and utilities for extending HubSpot's UI.
10
10
  - [Button](#button)
11
11
  - [ButtonRow](#buttonrow)
12
12
  - [Card](#card)
13
+ - [DateInput](#dateinput)
13
14
  - [DescriptionList](#descriptionlist)
14
15
  - [DescriptionListItem](#descriptionlistitem)
15
16
  - [Divider](#divider)
@@ -346,6 +347,107 @@ const Extension = () => {
346
347
  };
347
348
  ```
348
349
 
350
+ ### DateInput
351
+
352
+ ##### Import
353
+
354
+ ```javascript
355
+ import { DateInput } from '@hubspot/ui-extensions';
356
+ ```
357
+
358
+ ##### Props
359
+
360
+ ```typescript
361
+ interface DateInputProps {
362
+ label: string;
363
+ name: string;
364
+ value?: { year: number; month: number; date: number };
365
+ required?: boolean;
366
+ readOnly?: boolean;
367
+ description?: string;
368
+ tooltip?: string;
369
+ error?: boolean;
370
+ defaultValue?: { year: number; month: number; date: number };
371
+ validationMessage?: string;
372
+ onChange?: (value: {
373
+ year: number;
374
+ month: number;
375
+ date: number;
376
+ formattedDate?: string;
377
+ }) => void;
378
+ onBlur?: (value: {
379
+ year: number;
380
+ month: number;
381
+ date: number;
382
+ formattedDate?: string;
383
+ }) => void;
384
+ onFocus?: (value: {
385
+ year: number;
386
+ month: number;
387
+ date: number;
388
+ formattedDate?: string;
389
+ }) => void;
390
+ min?: { year: number; month: number; date: number };
391
+ max?: { year: number; month: number; date: number };
392
+ minValidationMessage?: string;
393
+ maxValidationMessage?: string;
394
+ format?: 'YYYY-MM-DD' | 'L' | 'LL' | 'll';
395
+ timezone?: 'userTz' | 'portalTz';
396
+ clearButtonLabel?: string;
397
+ todayButtonLabel?: string;
398
+ }
399
+ ```
400
+
401
+ | Prop | Type | Default | Description |
402
+ | --- | --- | --- | --- |
403
+ | `label` | `string` | `N/A` | The label text to display for the form input element. |
404
+ | `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) |
405
+ | `value` | `{ year: number; month: number; date: number }(optional)` | `N/A` | The value of the input |
406
+ | `required` | `boolean(optional)` | `false` | Determines if the required indicator should be displayed |
407
+ | `readOnly` | `boolean(optional)` | `false` | Determines if the field is editable or not. |
408
+ | `description` | `string(optional)` | `N/A` | Instructional message to display to the user to help understand the purpose of the input. |
409
+ | `tooltip` | `string(optional)` | `N/A` | Text that will appear in a tooltip next to the input label. |
410
+ | `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. |
411
+ | `validationMessage` | `string(optional)` | `''` | The text to show if the input has an error. |
412
+ | `onChange` | `(value: {year: number; month: number; date: number; formattedDate?: string;}) => void(optional)` | `N/A` | A callback function that is invoked when the user selects or types a valid date. It won't get called on invalid inputs. |
413
+ | `onBlur` | `(value: {year: number; month: number; date: number; formattedDate?: string;}) => void(optional)` | `N/A` | A function that is called and passed the value every time the field loses focus. |
414
+ | `onFocus` | `(value: {year: number; month: number; date: number; formattedDate?: string;}) => void(optional)` | `N/A` | A function that is called and passed the value every time the field gets focused. |
415
+ | `min` | `{ year: number; month: number; date: number }(optional)` | `N/A` | Sets the earliest date that will be valid. |
416
+ | `max` | `{ year: number; month: number; date: number }(optional)` | `N/A` | Sets the latest date that will be valid|
417
+ | `minValidationMessage` | `string` | `"You must choose an older date"` | Sets the message that users will see when the hover over dates that are older than the min date. |
418
+ | `maxValidationMessage` | `string` | `"You must choose a newer date"` | Sets the message that users will see when the hover over dates that are newer than the max date. |
419
+ | `format` | `'short' \| 'long' \| 'medium' \| 'standard' \| 'YYYY-MM-DD' \| 'L' \| 'LL' \| 'll'` | `short` | Sets the date format that input will display to users. |
420
+ | `timezone` | `'userTz' \| 'portalTz'` | `userTz` | Sets the timezone that the component will user to calculate valid dates. |
421
+ | `clearButtonLabel` | `string` | `Clear` | Sets the label of the clear button. |
422
+ | `todayButtonLabel` | `string` | `Today` | Sets the label of the today button.|
423
+
424
+
425
+ #### Format Options
426
+
427
+ - short: `09/04/1986`
428
+ - long: `September 4, 1986`
429
+ - medium : `Sep 4, 1986`
430
+ - standard: `1986-09-04`
431
+ - L: `09/04/1986`
432
+ - LL: `September 4, 1986`
433
+ - l: `9/4/1986`
434
+ - ll : `Sep 4, 1986`
435
+ - YYYY-MM-DD: `1986-09-04`
436
+
437
+ ##### Usage
438
+
439
+ ```javascript
440
+ const Extension = () => {
441
+ return (
442
+ <DateInput
443
+ label="Appointment Date"
444
+ name="appointment-date"
445
+ format="LL"
446
+ />
447
+ );
448
+ };
449
+ ```
450
+
349
451
  ### DescriptionList
350
452
 
351
453
  ##### Import
@@ -475,7 +577,7 @@ export interface FlexProps {
475
577
  justify?: 'center' | 'end' | 'start' | 'around' | 'between';
476
578
  align?: 'start' | 'center' | 'baseline' | 'end' | 'stretch';
477
579
  alignSelf?: 'start' | 'center' | 'baseline' | 'end' | 'stretch';
478
- wrap?: boolean;
580
+ wrap?: 'wrap' | 'nowrap';
479
581
  gap?:
480
582
  | 'flush'
481
583
  | 'small'
@@ -497,7 +599,7 @@ export interface FlexProps {
497
599
  | `justify` | `'start' \| 'center' \|'end' \|'around' \| 'between'` | `'start'` | Defines how to distribute space between and around children on main axis. |
498
600
  | `align` | `'start' \| 'center' \|'baseline' \| 'end' \| 'stretch' \|'between'` | `'start'` | Controls the aligment of children in the cross axis. |
499
601
  | `alignSelf` | `'start' \| 'center' \| 'baseline' \| 'end' \| 'stretch' \| 'auto'` `(optional)` | `'auto'` | Overrides flex's align item value for this element. Useful when `Flex` is the child of another `Flex` component. |
500
- | `wrap` | `boolean(optional)` | `false` | If set to `false`, children are forced onto one line. If set to `true`, they can wrap into multiple lines. |
602
+ | `wrap` | `'wrap' \| 'nowrap'` | `'nowrap'` | If set to `nowrap`, children are forced onto one line. If set to `wrap`, they can wrap into multiple lines. |
501
603
  | `children` | `ReactNode` | `N/A` | Sets the content that will render inside the component. This prop is passed implicitly by providing sub-components. |
502
604
  | `gap` | `'flush' \| 'extra-small' \| 'small' \| 'medium' \| 'large' \| 'extra-large' \| 'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | `'small'` | Amount of space between each child component passed as children. |
503
605
 
@@ -985,7 +1087,6 @@ export interface NumberInputProps {
985
1087
  defaultValue?: number;
986
1088
  validationMessage?: string;
987
1089
  onChange?: (value: number) => void;
988
- onInput?: (value: number) => void;
989
1090
  onBlur?: (value: number) => void;
990
1091
  onFocus?: (value: number) => void;
991
1092
  min?: number;
@@ -1007,8 +1108,7 @@ export interface NumberInputProps {
1007
1108
  | `placeholder` | `string(optional)` | `N/A` | Text that appears in the input when it has no value set. |
1008
1109
  | `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. |
1009
1110
  | `validationMessage` | `string(optional)` | `''` | The text to show if the input has an error. |
1010
- | `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. |
1011
- | `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. |
1111
+ | `onChange` | `(value: number) => void(optional)` | `N/A` | A callback function that is invoked when the user types a valid number. It won't get called on invalid inputs. |
1012
1112
  | `onBlur` | `(value: number) => void(optional)` | `N/A` | A function that is called and passed the value every time the field loses focus. |
1013
1113
  | `onFocus` | `(value: number) => void(optional)` | `N/A` | A function that is called and passed the value every time the field gets focused. |
1014
1114
  | `min` | `number(optional)` | `N/A` | Sets the lower bound of your input. |
@@ -1094,9 +1194,10 @@ import { Select } from '@hubspot/ui-extensions';
1094
1194
 
1095
1195
  ```typescript
1096
1196
  interface SelectProps {
1097
- label: string;
1098
- name: string;
1197
+ label?: string;
1198
+ name?: string;
1099
1199
  value?: string | number | boolean;
1200
+ variant?: 'transparent' | 'input'
1100
1201
  required?: boolean;
1101
1202
  readOnly?: boolean;
1102
1203
  description?: string;
@@ -1114,8 +1215,8 @@ interface SelectProps {
1114
1215
 
1115
1216
  | Prop | Type | Default | Description |
1116
1217
  | --- | --- | --- | --- |
1117
- | `label` | `string` | `N/A` | The label text to display for the select element |
1118
- | `name` | `string` | `N/A` | The unique identifier for the select element. |
1218
+ | `label` | `string(optional)` | `N/A` | The label text to display for the select element. |
1219
+ | `name` | `string(optional)` | `N/A` | The unique identifier for the select element. |
1119
1220
  | `value` | `string \| number \| boolean` | `''` | The value of the select input. |
1120
1221
  | `required` | `boolean` | `false` | Determines if the required indicator should be displayed |
1121
1222
  | `readOnly` | `boolean` | `false` | Determines if the field is editable or not. |
@@ -1126,6 +1227,7 @@ interface SelectProps {
1126
1227
  | `validationMessage` | `string(optional)` | `''` | The text to show if the input has an error. |
1127
1228
  | `onChange` | `(value: string) => void` | `N/A` | Function that is called with the new value when it is updated. |
1128
1229
  | `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. |
1230
+ | `variant` | `'transparent' \| 'input' `| `input` | Sets the visual styles of the button used for the anchor of the component. |
1129
1231
 
1130
1232
  ##### Usage
1131
1233
 
@@ -61,9 +61,9 @@ export declare const Image: "Image" & {
61
61
  } & import("@remote-ui/react").ReactComponentTypeFromRemoteComponentType<import("@remote-ui/types").RemoteComponentType<"Image", types.ImageProps, true>>;
62
62
  export declare const Input: "Input" & {
63
63
  readonly type?: "Input" | undefined;
64
- readonly props?: types.InputProps<string> | undefined;
64
+ readonly props?: types.InputProps | undefined;
65
65
  readonly children?: true | undefined;
66
- } & import("@remote-ui/react").ReactComponentTypeFromRemoteComponentType<import("@remote-ui/types").RemoteComponentType<"Input", types.InputProps<string>, true>>;
66
+ } & import("@remote-ui/react").ReactComponentTypeFromRemoteComponentType<import("@remote-ui/types").RemoteComponentType<"Input", types.InputProps, true>>;
67
67
  export declare const Link: "Link" & {
68
68
  readonly type?: "Link" | undefined;
69
69
  readonly props?: types.LinkProps | undefined;
@@ -110,6 +110,7 @@ export declare const Tile: "Tile" & {
110
110
  readonly props?: types.TileProps | undefined;
111
111
  readonly children?: true | undefined;
112
112
  } & import("@remote-ui/react").ReactComponentTypeFromRemoteComponentType<import("@remote-ui/types").RemoteComponentType<"Tile", types.TileProps, true>>;
113
+ /** @deprecated use Flex instead. It will be removed in the next release. */
113
114
  export declare const Stack: "Stack" & {
114
115
  readonly type?: "Stack" | undefined;
115
116
  readonly props?: types.StackProps | undefined;
@@ -200,3 +201,8 @@ export declare const Flex: "Flex" & {
200
201
  readonly props?: types.FlexProps | undefined;
201
202
  readonly children?: true | undefined;
202
203
  } & import("@remote-ui/react").ReactComponentTypeFromRemoteComponentType<import("@remote-ui/types").RemoteComponentType<"Flex", types.FlexProps, true>>;
204
+ export declare const DateInput: "DateInput" & {
205
+ readonly type?: "DateInput" | undefined;
206
+ readonly props?: types.DateInputProps | undefined;
207
+ readonly children?: true | undefined;
208
+ } & import("@remote-ui/react").ReactComponentTypeFromRemoteComponentType<import("@remote-ui/types").RemoteComponentType<"DateInput", types.DateInputProps, true>>;
@@ -24,6 +24,7 @@ export const Select = createRemoteReactComponent('Select');
24
24
  export const Tag = createRemoteReactComponent('Tag');
25
25
  export const Text = createRemoteReactComponent('Text');
26
26
  export const Tile = createRemoteReactComponent('Tile');
27
+ /** @deprecated use Flex instead. It will be removed in the next release. */
27
28
  export const Stack = createRemoteReactComponent('Stack');
28
29
  export const ToggleGroup = createRemoteReactComponent('ToggleGroup');
29
30
  export const StatisticsItem = createRemoteReactComponent('StatisticsItem');
@@ -42,3 +43,4 @@ export const StepIndicator = createRemoteReactComponent('StepIndicator');
42
43
  export const Accordion = createRemoteReactComponent('Accordion');
43
44
  export const MultiSelect = createRemoteReactComponent('MultiSelect');
44
45
  export const Flex = createRemoteReactComponent('Flex');
46
+ export const DateInput = createRemoteReactComponent('DateInput');
package/dist/types.d.ts CHANGED
@@ -61,7 +61,7 @@ export interface ImageProps {
61
61
  width?: number;
62
62
  height?: number;
63
63
  }
64
- export interface InputProps<T = string> {
64
+ interface BaseInputProps<T = string, V = string> {
65
65
  label: string;
66
66
  name: string;
67
67
  value?: T;
@@ -73,23 +73,44 @@ export interface InputProps<T = string> {
73
73
  error?: boolean;
74
74
  defaultValue?: T;
75
75
  validationMessage?: string;
76
- onChange?: (value: T) => void;
77
- onInput?: (value: T) => void;
78
- onBlur?: (value: T) => void;
79
- onFocus?: (value: T) => void;
76
+ onChange?: (value: V) => void;
77
+ onInput?: (value: V) => void;
78
+ onBlur?: (value: V) => void;
79
+ onFocus?: (value: V) => void;
80
80
  }
81
- export interface TextAreaProps extends InputProps {
81
+ export type InputProps = BaseInputProps;
82
+ export interface TextAreaProps extends BaseInputProps {
82
83
  cols?: number;
83
84
  maxLength?: number;
84
85
  rows?: number;
85
86
  resize?: 'vertical' | 'horizontal' | 'both' | 'none';
86
87
  }
87
88
  export type TextareaProps = TextAreaProps;
88
- export interface NumberInputProps extends InputProps<number> {
89
+ export interface NumberInputProps extends Omit<BaseInputProps<number, number>, 'onInput'> {
89
90
  min?: number;
90
91
  max?: number;
91
92
  precision?: number;
92
93
  formatStyle?: 'decimal' | 'percentage';
94
+ /** @deprecated use onChange instead. It doesn't guarantee valid format */
95
+ onInput?: (value: number) => void;
96
+ }
97
+ export interface BaseDate {
98
+ year: number;
99
+ month: number;
100
+ date: number;
101
+ }
102
+ export interface DateInputEventsPayload extends BaseDate {
103
+ formattedDate?: string;
104
+ }
105
+ export interface DateInputProps extends Omit<BaseInputProps<BaseDate | null, DateInputEventsPayload>, 'onInput' | 'placeholder'> {
106
+ min?: BaseDate;
107
+ max?: BaseDate;
108
+ minValidationMessage?: string;
109
+ maxValidationMessage?: string;
110
+ format?: 'YYYY-MM-DD' | 'L' | 'LL' | 'll' | 'short' | 'long' | 'medium' | 'standard';
111
+ timezone?: 'userTz' | 'portalTz';
112
+ clearButtonLabel?: string;
113
+ todayButtonLabel?: string;
93
114
  }
94
115
  export interface ProgressBarProps {
95
116
  title?: string;
@@ -103,8 +124,8 @@ export interface ProgressBarProps {
103
124
  variant?: 'success' | 'danger' | 'warning';
104
125
  }
105
126
  export interface BaseSelectProps {
106
- label: string;
107
- name: string;
127
+ label?: string;
128
+ name?: string;
108
129
  required?: boolean;
109
130
  readOnly?: boolean;
110
131
  description?: string;
@@ -119,11 +140,12 @@ export interface BaseSelectProps {
119
140
  }
120
141
  export interface SelectProps extends BaseSelectProps {
121
142
  value?: string | number;
122
- onChange?: (value: SelectProps['value']) => void;
143
+ onChange?: (value: NonNullable<SelectProps['value']>) => void;
144
+ variant?: 'transparent' | 'input';
123
145
  }
124
146
  export interface MultiSelectProps extends BaseSelectProps {
125
147
  value?: (string | number)[];
126
- onChange?: (value: MultiSelectProps['value']) => void;
148
+ onChange?: (value: NonNullable<MultiSelectProps['value']>) => void;
127
149
  }
128
150
  export interface TagProps {
129
151
  children: ReactNode;
@@ -225,7 +247,7 @@ export interface FlexProps {
225
247
  justify?: 'center' | 'end' | 'start' | 'around' | 'between';
226
248
  align?: 'start' | 'center' | 'baseline' | 'end' | 'stretch';
227
249
  alignSelf?: 'start' | 'center' | 'baseline' | 'end' | 'stretch';
228
- wrap?: boolean;
250
+ wrap?: boolean | 'wrap' | 'nowrap';
229
251
  }
230
252
  export interface StatisticsTrendProps {
231
253
  value: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/ui-extensions",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -48,5 +48,5 @@
48
48
  "devDependencies": {
49
49
  "typescript": "5.0.4"
50
50
  },
51
- "gitHead": "1979c2dce0a920c10e4f8b5ec3bc16a1080120cb"
51
+ "gitHead": "60f780b26b92ab097b24f162bf485fde5fd26528"
52
52
  }