@utilitywarehouse/hearth-react-native 0.15.3 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +67 -6
- package/CHANGELOG.md +73 -6
- package/build/components/Avatar/Avatar.js +0 -2
- package/build/components/Banner/Banner.d.ts +1 -1
- package/build/components/Banner/Banner.js +3 -1
- package/build/components/Carousel/Carousel.js +1 -1
- package/build/components/Checkbox/CheckboxGroup.d.ts +1 -1
- package/build/components/Checkbox/CheckboxGroup.js +2 -2
- package/build/components/Checkbox/CheckboxGroup.props.d.ts +2 -1
- package/build/components/CurrencyInput/CurrencyInput.d.ts +1 -1
- package/build/components/CurrencyInput/CurrencyInput.js +2 -6
- package/build/components/CurrencyInput/CurrencyInput.props.d.ts +6 -0
- package/build/components/DateInput/DateInput.js +1 -0
- package/build/components/DateInput/DateInputSegment.js +2 -3
- package/build/components/DatePicker/DatePicker.js +8 -4
- package/build/components/DatePicker/DatePickerHeader/DatePickerHeader.props.d.ts +0 -1
- package/build/components/DatePicker/DatePickerHeader/index.js +1 -1
- package/build/components/DatePicker/index.d.ts +1 -0
- package/build/components/DatePicker/polyfill.js +3 -3
- package/build/components/DatePicker/time-picker/wheel-web.js +1 -3
- package/build/components/DatePickerInput/DatePickerInput.d.ts +1 -1
- package/build/components/DatePickerInput/DatePickerInput.js +3 -4
- package/build/components/DatePickerInput/DatePickerInput.props.d.ts +6 -0
- package/build/components/DescriptionList/DescriptionList.d.ts +1 -1
- package/build/components/DescriptionList/DescriptionList.js +2 -2
- package/build/components/DescriptionList/DescriptionList.props.d.ts +1 -0
- package/build/components/DescriptionList/DescriptionListItem.d.ts +1 -1
- package/build/components/DescriptionList/DescriptionListItem.js +3 -2
- package/build/components/DescriptionList/DescriptionListItem.props.d.ts +1 -0
- package/build/components/FormField/FormField.context.d.ts +8 -2
- package/build/components/FormField/FormField.d.ts +1 -1
- package/build/components/FormField/FormField.js +24 -4
- package/build/components/FormField/FormField.props.d.ts +2 -0
- package/build/components/FormField/FormFieldLabel.d.ts +1 -1
- package/build/components/FormField/FormFieldLabel.js +3 -3
- package/build/components/FormField/FormFieldValid.js +2 -2
- package/build/components/Input/Input.js +48 -10
- package/build/components/Input/Input.props.d.ts +7 -1
- package/build/components/Label/Label.d.ts +1 -1
- package/build/components/Label/Label.js +5 -1
- package/build/components/Label/Label.props.d.ts +3 -2
- package/build/components/Radio/RadioGroup.d.ts +1 -1
- package/build/components/Radio/RadioGroup.js +2 -2
- package/build/components/Radio/RadioGroup.props.d.ts +1 -0
- package/build/components/RadioCard/RadioCard.d.ts +1 -1
- package/build/components/RadioCard/RadioCard.js +2 -2
- package/build/components/RadioCard/RadioCard.props.d.ts +1 -0
- package/build/components/Select/Select.d.ts +1 -1
- package/build/components/Select/Select.js +2 -2
- package/build/components/Select/Select.props.d.ts +10 -0
- package/build/components/Switch/Switch.js +1 -1
- package/build/components/Tabs/Tabs.d.ts +1 -1
- package/build/components/Tabs/Tabs.js +1 -1
- package/build/components/Textarea/Textarea.d.ts +1 -1
- package/build/components/Textarea/Textarea.js +46 -6
- package/build/components/Textarea/Textarea.props.d.ts +8 -0
- package/build/components/Toast/ToastItem.js +1 -1
- package/build/components/ToggleButton/ToggleButtonIcon.js +1 -1
- package/build/components/ToggleButton/ToggleButtonRoot.js +0 -2
- package/build/components/UnstyledIconButton/UnstyledIconButtonIcon.js +1 -1
- package/build/components/VerificationInput/VerificationInput.d.ts +1 -1
- package/build/components/VerificationInput/VerificationInput.js +2 -2
- package/build/components/VerificationInput/VerificationInput.props.d.ts +4 -0
- package/build/utils/coloursAsArray.js +1 -1
- package/docs/components/AllComponents.web.tsx +19 -20
- package/docs/components/UsageWrap.tsx +17 -20
- package/docs/theme-tokens.mdx +390 -2
- package/eslint.config.js +5 -1
- package/package.json +12 -12
- package/src/components/Accordion/Accordion.figma.tsx +15 -17
- package/src/components/Accordion/AccordionItem.figma.tsx +27 -0
- package/src/components/Avatar/Avatar.figma.tsx +11 -21
- package/src/components/Avatar/Avatar.tsx +0 -2
- package/src/components/Badge/Badge.figma.tsx +45 -54
- package/src/components/Banner/Banner.figma.tsx +21 -13
- package/src/components/Banner/Banner.stories.tsx +4 -4
- package/src/components/Banner/Banner.tsx +2 -1
- package/src/components/Button/Button.figma.tsx +118 -46
- package/src/components/Card/Card.figma.tsx +27 -43
- package/src/components/Card/Card.stories.tsx +1 -1
- package/src/components/Carousel/Carousel.figma.tsx +20 -17
- package/src/components/Carousel/Carousel.tsx +1 -1
- package/src/components/Checkbox/Checkbox.docs.mdx +32 -31
- package/src/components/Checkbox/Checkbox.figma.tsx +15 -18
- package/src/components/Checkbox/Checkbox.stories.tsx +2 -2
- package/src/components/Checkbox/CheckboxGroup.figma.tsx +48 -15
- package/src/components/Checkbox/CheckboxGroup.props.ts +2 -1
- package/src/components/Checkbox/CheckboxGroup.tsx +6 -1
- package/src/components/Checkbox/CheckboxTileRoot.figma.tsx +24 -27
- package/src/components/CurrencyInput/CurrencyInput.docs.mdx +52 -9
- package/src/components/CurrencyInput/CurrencyInput.figma.tsx +65 -49
- package/src/components/CurrencyInput/CurrencyInput.props.ts +6 -0
- package/src/components/CurrencyInput/CurrencyInput.stories.tsx +30 -1
- package/src/components/CurrencyInput/CurrencyInput.tsx +16 -8
- package/src/components/DateInput/DateInput.figma.tsx +58 -45
- package/src/components/DateInput/DateInput.tsx +1 -0
- package/src/components/DateInput/DateInputSegment.tsx +2 -3
- package/src/components/DatePicker/DatePicker.figma.tsx +47 -0
- package/src/components/DatePicker/DatePicker.tsx +8 -4
- package/src/components/DatePicker/DatePickerHeader/DatePickerHeader.props.ts +0 -2
- package/src/components/DatePicker/DatePickerHeader/index.tsx +2 -2
- package/src/components/DatePicker/index.ts +2 -0
- package/src/components/DatePicker/polyfill.ts +3 -3
- package/src/components/DatePicker/time-picker/wheel-web.tsx +0 -1
- package/src/components/DatePickerInput/DatePickerInput.docs.mdx +22 -0
- package/src/components/DatePickerInput/DatePickerInput.figma.tsx +18 -46
- package/src/components/DatePickerInput/DatePickerInput.props.ts +6 -0
- package/src/components/DatePickerInput/DatePickerInput.tsx +17 -5
- package/src/components/DescriptionList/DescriptionList.docs.mdx +16 -14
- package/src/components/DescriptionList/DescriptionList.figma.tsx +41 -17
- package/src/components/DescriptionList/DescriptionList.props.ts +1 -0
- package/src/components/DescriptionList/DescriptionList.stories.tsx +24 -0
- package/src/components/DescriptionList/DescriptionList.tsx +2 -0
- package/src/components/DescriptionList/DescriptionListItem.figma.tsx +42 -0
- package/src/components/DescriptionList/DescriptionListItem.props.ts +1 -0
- package/src/components/DescriptionList/DescriptionListItem.tsx +7 -0
- package/src/components/Divider/Divider.figma.tsx +10 -23
- package/src/components/FormField/FormField.context.ts +6 -1
- package/src/components/FormField/FormField.docs.mdx +30 -30
- package/src/components/FormField/FormField.props.ts +2 -0
- package/src/components/FormField/FormField.stories.tsx +8 -2
- package/src/components/FormField/FormField.tsx +38 -4
- package/src/components/FormField/FormFieldLabel.tsx +7 -3
- package/src/components/FormField/FormFieldValid.tsx +2 -2
- package/src/components/Input/Input.docs.mdx +67 -22
- package/src/components/Input/Input.props.ts +7 -1
- package/src/components/Input/Input.stories.tsx +9 -1
- package/src/components/Input/Input.tsx +124 -60
- package/src/components/Label/Label.props.ts +3 -2
- package/src/components/Label/Label.tsx +11 -1
- package/src/components/List/List.stories.tsx +1 -4
- package/src/components/Radio/Radio.docs.mdx +31 -30
- package/src/components/Radio/Radio.stories.tsx +1 -1
- package/src/components/Radio/RadioGroup.props.ts +1 -0
- package/src/components/Radio/RadioGroup.stories.tsx +6 -0
- package/src/components/Radio/RadioGroup.tsx +6 -1
- package/src/components/RadioCard/RadioCard.docs.mdx +31 -30
- package/src/components/RadioCard/RadioCard.props.ts +1 -0
- package/src/components/RadioCard/RadioCard.tsx +8 -2
- package/src/components/Select/Select.props.ts +10 -0
- package/src/components/Select/Select.tsx +3 -2
- package/src/components/Switch/Switch.tsx +1 -1
- package/src/components/Tabs/Tabs.tsx +0 -1
- package/src/components/Textarea/Textarea.docs.mdx +65 -17
- package/src/components/Textarea/Textarea.props.ts +8 -0
- package/src/components/Textarea/Textarea.stories.tsx +23 -2
- package/src/components/Textarea/Textarea.tsx +87 -19
- package/src/components/ThemedImage/ThemedImage.stories.tsx +14 -14
- package/src/components/Toast/ToastItem.tsx +1 -1
- package/src/components/ToggleButton/ToggleButtonIcon.tsx +1 -1
- package/src/components/ToggleButton/ToggleButtonRoot.tsx +0 -2
- package/src/components/UnstyledIconButton/UnstyledIconButtonIcon.tsx +1 -1
- package/src/components/VerificationInput/VerificationInput.docs.mdx +1 -0
- package/src/components/VerificationInput/VerificationInput.props.ts +4 -1
- package/src/components/VerificationInput/VerificationInput.tsx +2 -0
- package/src/utils/coloursAsArray.ts +1 -1
- package/tsconfig.eslint.json +13 -0
- package/src/components/Accordion/AccordionItemRoot.figma.tsx +0 -47
- package/src/components/DatePicker/DatePickerCalendar.figma.tsx +0 -34
|
@@ -76,22 +76,22 @@ const MyComponent = () => {
|
|
|
76
76
|
|
|
77
77
|
## Props
|
|
78
78
|
|
|
79
|
-
| Property | Type | Default
|
|
80
|
-
| -------------------- | ----------------------------------- |
|
|
81
|
-
| `value` | `string` | -
|
|
82
|
-
| `onChange` | `(value: boolean) => void` | -
|
|
83
|
-
| `defaultchecked` | `bool` | `false`
|
|
84
|
-
| `checked` | `bool` | `false`
|
|
85
|
-
| `validationStatus` | `'valid' \| 'invalid' \| 'initial'` | -
|
|
86
|
-
| `disabled` | `bool` | `false`
|
|
87
|
-
| `label` | `string` | -
|
|
88
|
-
| `helperText` | `string` | -
|
|
89
|
-
| `helperIcon` | `React.ComponentType` | -
|
|
90
|
-
| `invalidText` | `string` | -
|
|
91
|
-
| `validText` | `string` | -
|
|
92
|
-
| `showValidationIcon` | `boolean` | `true`
|
|
93
|
-
| `type` | `'default' \| 'tile'` | `default` | The type of the checkbox. |
|
|
94
|
-
| `image` | `ReactNode` | -
|
|
79
|
+
| Property | Type | Default | Description |
|
|
80
|
+
| -------------------- | ----------------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
81
|
+
| `value` | `string` | - | The value to be used in the checkbox input. This is the value that will be returned on form submission. |
|
|
82
|
+
| `onChange` | `(value: boolean) => void` | - | Function called when the state of the checkbox changes. |
|
|
83
|
+
| `defaultchecked` | `bool` | `false` | If true, the checkbox will be initially checked. |
|
|
84
|
+
| `checked` | `bool` | `false` | When true, the checkbox will be checked. You'll need to pass onChange update it's value (since it's now controlled). |
|
|
85
|
+
| `validationStatus` | `'valid' \| 'invalid' \| 'initial'` | - | The validation status of the checkbox. |
|
|
86
|
+
| `disabled` | `bool` | `false` | To manually set disable to the checkbox. |
|
|
87
|
+
| `label` | `string` | - | The label to be displayed next to the checkbox. |
|
|
88
|
+
| `helperText` | `string` | - | The helper text to be displayed below the checkbox. |
|
|
89
|
+
| `helperIcon` | `React.ComponentType` | - | The icon to be displayed next to the helper text. |
|
|
90
|
+
| `invalidText` | `string` | - | The invalid text to be displayed below the checkbox. |
|
|
91
|
+
| `validText` | `string` | - | The valid text to be displayed below the checkbox. |
|
|
92
|
+
| `showValidationIcon` | `boolean` | `true` | Whether to show the validation icon. |
|
|
93
|
+
| `type` | `'default' \| 'tile'` | `'default'` | The type of the checkbox. |
|
|
94
|
+
| `image` | `ReactNode` | - | The image to be displayed next to the label. |
|
|
95
95
|
|
|
96
96
|
## Components
|
|
97
97
|
|
|
@@ -123,21 +123,22 @@ The `CheckboxLabel` component is used to create the label for the checkbox input
|
|
|
123
123
|
|
|
124
124
|
The `CheckboxGroup` component is used to group multiple checkbox inputs together. It inherits all the properties of React Native's `View` component.
|
|
125
125
|
|
|
126
|
-
| Property | Type | Default
|
|
127
|
-
| -------------------- | ----------------------------------- |
|
|
128
|
-
| `value` | string | -
|
|
129
|
-
| `onChange` | function | -
|
|
130
|
-
| `disabled` | bool | -
|
|
131
|
-
| `validationStatus` | `'valid' \| 'invalid' \| 'initial'` | -
|
|
132
|
-
| `label` | `string` | -
|
|
133
|
-
| `
|
|
134
|
-
| `
|
|
135
|
-
| `
|
|
136
|
-
| `
|
|
137
|
-
| `
|
|
138
|
-
| `
|
|
139
|
-
| `
|
|
140
|
-
| `
|
|
126
|
+
| Property | Type | Default | Description |
|
|
127
|
+
| -------------------- | ----------------------------------- | ----------- | ---------------------------------------------------------------------- |
|
|
128
|
+
| `value` | string | - | The value of the checkbox group. |
|
|
129
|
+
| `onChange` | function | - | The callback fired when any children Checkbox is checked or unchecked. |
|
|
130
|
+
| `disabled` | bool | - | To manually set disable to the checkbox group. |
|
|
131
|
+
| `validationStatus` | `'valid' \| 'invalid' \| 'initial'` | - | The validation status of the checkbox group. |
|
|
132
|
+
| `label` | `string` | - | The label to be displayed above the checkbox group. |
|
|
133
|
+
| `labelVariant` | `'heading' \| 'body'` | `'body'` | The variant of the label text. |
|
|
134
|
+
| `helperText` | `string` | - | The helper text to be displayed below the checkbox group. |
|
|
135
|
+
| `helperIcon` | `React.ComponentType` | - | The icon to be displayed next to the helper text. |
|
|
136
|
+
| `invalidText` | `string` | - | The invalid text to be displayed below the checkbox group. |
|
|
137
|
+
| `validText` | `string` | - | The valid text to be displayed below the checkbox group. |
|
|
138
|
+
| `showValidationIcon` | `boolean` | `true` | Whether to show the validation icon. |
|
|
139
|
+
| `type` | `'default' \| 'tile'` | `'default'` | The type of the checkbox group. |
|
|
140
|
+
| `direction` | `'row' \| 'column'` | `'column'` | The direction of the checkbox group. |
|
|
141
|
+
| `gap` | `string` | - | The gap between the checkbox group items. |
|
|
141
142
|
|
|
142
143
|
<UsageWrap>
|
|
143
144
|
<Center>
|
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
import figma from '@figma/code-connect';
|
|
2
2
|
import { Checkbox } from './Checkbox';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
* -- This file was auto-generated by Code Connect --
|
|
6
|
-
* `props` includes a mapping from your code props to Figma properties.
|
|
7
|
-
* You should check this is correct, and update the `example` function
|
|
8
|
-
* to return the code example you'd like to see in Figma
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
figma.connect(Checkbox, 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=3087%3A7316', {
|
|
4
|
+
figma.connect(Checkbox, 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=3087-7316', {
|
|
12
5
|
props: {
|
|
13
|
-
// These props were automatically mapped based on your linked code:
|
|
14
6
|
disabled: figma.enum('State', {
|
|
15
7
|
Disabled: true,
|
|
16
8
|
}),
|
|
17
9
|
checked: figma.boolean('Checked?'),
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
label: figma.string('Label'),
|
|
11
|
+
helperText: figma.boolean('Helper text?', {
|
|
12
|
+
true: figma.string('Helper text'),
|
|
13
|
+
false: undefined,
|
|
20
14
|
}),
|
|
21
|
-
|
|
22
|
-
// "label": figma.string('Label'),
|
|
23
|
-
// "helperText": figma.string('Helper text'),
|
|
24
|
-
// "helperText": figma.boolean('Helper text?'),
|
|
25
|
-
// "validationText": figma.string('Validation text'),
|
|
26
|
-
// "image": figma.boolean('Image?')
|
|
15
|
+
validationText: figma.string('Validation text'),
|
|
27
16
|
},
|
|
28
|
-
example: props =>
|
|
17
|
+
example: props => (
|
|
18
|
+
<Checkbox
|
|
19
|
+
disabled={props.disabled}
|
|
20
|
+
checked={props.checked}
|
|
21
|
+
label={props.label}
|
|
22
|
+
helperText={props.helperText}
|
|
23
|
+
invalidText={props.validationText}
|
|
24
|
+
/>
|
|
25
|
+
),
|
|
29
26
|
});
|
|
@@ -76,7 +76,7 @@ type Story = StoryObj<typeof meta>;
|
|
|
76
76
|
|
|
77
77
|
export const Playground: Story = {
|
|
78
78
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
79
|
-
render: ({ checked: checkedArg = false, value,
|
|
79
|
+
render: ({ checked: checkedArg = false, value, onChange, ...args }) => {
|
|
80
80
|
const [checked, setChecked] = React.useState(checkedArg);
|
|
81
81
|
useEffect(() => {
|
|
82
82
|
setChecked(checkedArg);
|
|
@@ -95,7 +95,7 @@ export const Playground: Story = {
|
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
export const WithImage: Story = {
|
|
98
|
-
render: ({
|
|
98
|
+
render: ({ ...args }) => (
|
|
99
99
|
<CheckboxGroup aria-label="Checkbox Group" nativeID="checkbox-group">
|
|
100
100
|
<Checkbox
|
|
101
101
|
aria-label="Visa"
|
|
@@ -1,20 +1,53 @@
|
|
|
1
|
-
import
|
|
2
|
-
import CheckboxGroup from
|
|
3
|
-
import figma from "@figma/code-connect"
|
|
1
|
+
import figma from '@figma/code-connect';
|
|
2
|
+
import { CheckboxGroup } from '../';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
const props = {
|
|
5
|
+
label: figma.string('Group label'),
|
|
6
|
+
helperText: figma.boolean('Helper text?', {
|
|
7
|
+
true: figma.string('Helper text'),
|
|
8
|
+
false: undefined,
|
|
9
|
+
}),
|
|
10
|
+
direction: figma.enum('Direction', {
|
|
11
|
+
Column: undefined,
|
|
12
|
+
Row: 'row',
|
|
13
|
+
}),
|
|
14
|
+
tiles: figma.children('Checkbox Tile'),
|
|
15
|
+
checkboxes: figma.children('Checkbox'),
|
|
16
|
+
};
|
|
12
17
|
|
|
13
18
|
figma.connect(
|
|
14
19
|
CheckboxGroup,
|
|
15
|
-
|
|
20
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=3141-4275&m=dev',
|
|
16
21
|
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
variant: {
|
|
23
|
+
Content: 'Checkbox Tile',
|
|
24
|
+
},
|
|
25
|
+
props,
|
|
26
|
+
example: props => (
|
|
27
|
+
<CheckboxGroup
|
|
28
|
+
type="tile"
|
|
29
|
+
label={props.label}
|
|
30
|
+
helperText={props.helperText}
|
|
31
|
+
direction={props.direction}
|
|
32
|
+
>
|
|
33
|
+
{props.tiles}
|
|
34
|
+
</CheckboxGroup>
|
|
35
|
+
),
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
figma.connect(
|
|
40
|
+
CheckboxGroup,
|
|
41
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=3141-4275&m=dev',
|
|
42
|
+
{
|
|
43
|
+
variant: {
|
|
44
|
+
Content: 'Checkbox',
|
|
45
|
+
},
|
|
46
|
+
props,
|
|
47
|
+
example: props => (
|
|
48
|
+
<CheckboxGroup label={props.label} helperText={props.helperText} direction={props.direction}>
|
|
49
|
+
{props.checkboxes}
|
|
50
|
+
</CheckboxGroup>
|
|
51
|
+
),
|
|
52
|
+
}
|
|
53
|
+
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
|
-
import { space } from '../../tokens';
|
|
3
2
|
import { ViewProps } from 'react-native';
|
|
3
|
+
import { space } from '../../tokens';
|
|
4
4
|
|
|
5
5
|
interface CheckboxGroupProps extends ViewProps {
|
|
6
6
|
disabled?: boolean;
|
|
@@ -9,6 +9,7 @@ interface CheckboxGroupProps extends ViewProps {
|
|
|
9
9
|
readonly?: boolean;
|
|
10
10
|
validationStatus?: 'valid' | 'invalid' | 'initial';
|
|
11
11
|
label?: string;
|
|
12
|
+
labelVariant?: 'heading' | 'body';
|
|
12
13
|
helperText?: string;
|
|
13
14
|
showValidationIcon?: boolean;
|
|
14
15
|
invalidText?: string;
|
|
@@ -14,6 +14,7 @@ const CheckboxGroup = ({
|
|
|
14
14
|
readonly,
|
|
15
15
|
validationStatus,
|
|
16
16
|
label,
|
|
17
|
+
labelVariant = 'body',
|
|
17
18
|
helperText,
|
|
18
19
|
invalidText,
|
|
19
20
|
validText,
|
|
@@ -50,7 +51,11 @@ const CheckboxGroup = ({
|
|
|
50
51
|
>
|
|
51
52
|
{showHeader && (
|
|
52
53
|
<CheckboxGroupTextContent>
|
|
53
|
-
{!!label &&
|
|
54
|
+
{!!label && (
|
|
55
|
+
<Label disabled={disabled} variant={labelVariant}>
|
|
56
|
+
{label}
|
|
57
|
+
</Label>
|
|
58
|
+
)}
|
|
54
59
|
{!!helperText && <Helper disabled={disabled} icon={helperIcon} text={helperText} />}
|
|
55
60
|
{validationStatus === 'invalid' && !!invalidText && (
|
|
56
61
|
<Helper
|
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import figma from "@figma/code-connect"
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* -- This file was auto-generated by Code Connect --
|
|
7
|
-
* None of your props could be automatically mapped to Figma properties.
|
|
8
|
-
* You should update the `props` object to include a mapping from your
|
|
9
|
-
* code props to Figma properties, and update the `example` function to
|
|
10
|
-
* return the code example you'd like to see in Figma
|
|
11
|
-
*/
|
|
1
|
+
import figma from '@figma/code-connect';
|
|
2
|
+
import { Checkbox } from './Checkbox';
|
|
12
3
|
|
|
13
4
|
figma.connect(
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
Checkbox,
|
|
6
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=4961-23797&m=dev',
|
|
16
7
|
{
|
|
17
8
|
props: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// }),
|
|
28
|
-
// "checked": figma.boolean('Checked?')
|
|
9
|
+
disabled: figma.enum('State', {
|
|
10
|
+
Disabled: true,
|
|
11
|
+
}),
|
|
12
|
+
checked: figma.boolean('Checked?'),
|
|
13
|
+
label: figma.string('Label'),
|
|
14
|
+
helperText: figma.boolean('Helper text?', {
|
|
15
|
+
true: figma.string('Helper text'),
|
|
16
|
+
false: undefined,
|
|
17
|
+
}),
|
|
29
18
|
},
|
|
30
|
-
example:
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
example: props => (
|
|
20
|
+
<Checkbox
|
|
21
|
+
type="tile"
|
|
22
|
+
disabled={props.disabled}
|
|
23
|
+
checked={props.checked}
|
|
24
|
+
label={props.label}
|
|
25
|
+
helperText={props.helperText}
|
|
26
|
+
/>
|
|
27
|
+
),
|
|
28
|
+
}
|
|
29
|
+
);
|
|
@@ -16,6 +16,7 @@ An input specialised for monetary amounts. It shows a currency symbol prefix and
|
|
|
16
16
|
- [Playground](#playground)
|
|
17
17
|
- [Usage](#usage)
|
|
18
18
|
- [Props](#props)
|
|
19
|
+
- [Examples](#examples)
|
|
19
20
|
- [States](#states)
|
|
20
21
|
- [Formatting](#formatting)
|
|
21
22
|
- [Accessibility](#accessibility)
|
|
@@ -48,20 +49,62 @@ const MyComponent = () => {
|
|
|
48
49
|
|
|
49
50
|
When using `CurrencyInput`, the component inherits React Native TextInput props (except `children`). In addition, it supports:
|
|
50
51
|
|
|
51
|
-
| Prop
|
|
52
|
-
|
|
|
53
|
-
| validationStatus
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
|
52
|
+
| Prop | Type | Default | Description |
|
|
53
|
+
| --------------------- | ------------------------------------------------ | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
54
|
+
| validationStatus | `'initial' \| 'valid' \| 'invalid'` | `'initial'` | Validation styling state |
|
|
55
|
+
| onChangeText | `(e: { nativeEvent: { text: string } }) => void` | - | Callback when the text changes |
|
|
56
|
+
| value | `string` | - | The value of the input |
|
|
57
|
+
| label | `string` | - | The label for the input |
|
|
58
|
+
| labelVariant | `'heading' \| 'body'` | `'body'` | The variant of the label text |
|
|
59
|
+
| helperText | `string` | - | Helper text to display below the input |
|
|
60
|
+
| helperIcon | `ComponentType` | - | Icon to display alongside the helper text |
|
|
61
|
+
| required | `boolean` |
|
|
62
|
+
| disabled | `boolean` | `false` | Disables the input |
|
|
63
|
+
| readonly | `boolean` | `false` | Makes the input read-only |
|
|
64
|
+
| focused | `boolean` | `false` | Forces the focused visual state |
|
|
65
|
+
| inBottomSheet | `boolean` | `false` | Use BottomSheetTextInput when true |
|
|
66
|
+
| placeholder | `string` | `'0.00'` | Placeholder text |
|
|
67
|
+
| disableGroupSeparator | `boolean` | `false` | Disables automatic inserting of thousand separators while the user types _(Formatting only works with controlled components via onTextChange)_ |
|
|
60
68
|
|
|
61
69
|
Note: When used inside `FormField`, `validationStatus` and `disabled` are read from the context unless explicitly overridden.
|
|
62
70
|
|
|
63
71
|
## Examples
|
|
64
72
|
|
|
73
|
+
## With Label and Helper Text
|
|
74
|
+
|
|
75
|
+
The `CurrencyInput` component can display a label and helper text by passing the appropriate props.
|
|
76
|
+
|
|
77
|
+
<UsageWrap>
|
|
78
|
+
<Center>
|
|
79
|
+
<CurrencyInput
|
|
80
|
+
label="Amount"
|
|
81
|
+
helperText="Enter the amount in GBP"
|
|
82
|
+
placeholder="0.00"
|
|
83
|
+
onChange={() => console.log('###')}
|
|
84
|
+
/>
|
|
85
|
+
</Center>
|
|
86
|
+
</UsageWrap>
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { CurrencyInput } from '@utilitywarehouse/hearth-react-native';
|
|
90
|
+
|
|
91
|
+
const MyComponent = () => {
|
|
92
|
+
const [value, setValue] = useState('');
|
|
93
|
+
const handleChange = e => {
|
|
94
|
+
setValue(e.target.value);
|
|
95
|
+
};
|
|
96
|
+
return (
|
|
97
|
+
<CurrencyInput
|
|
98
|
+
label="Amount"
|
|
99
|
+
helperText="Enter the amount in GBP"
|
|
100
|
+
placeholder="0.00"
|
|
101
|
+
value={value}
|
|
102
|
+
onChange={handleChange}
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
```
|
|
107
|
+
|
|
65
108
|
### With `FormField`
|
|
66
109
|
|
|
67
110
|
The `CurrencyInput` component can be used with the `FormField` component to create a custom input field.
|
|
@@ -1,56 +1,72 @@
|
|
|
1
|
-
import
|
|
2
|
-
import CurrencyInput from
|
|
3
|
-
import figma from "@figma/code-connect"
|
|
1
|
+
import figma from '@figma/code-connect';
|
|
2
|
+
import { CurrencyInput, FormField } from '../';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const props = {
|
|
5
|
+
placeholder: figma.string('Value'),
|
|
6
|
+
value: figma.string('Value'),
|
|
7
|
+
label: figma.string('Label'),
|
|
8
|
+
helperText: figma.boolean('Helper text?', {
|
|
9
|
+
true: figma.string('Helper text'),
|
|
10
|
+
false: undefined,
|
|
11
|
+
}),
|
|
12
|
+
invalidText: figma.enum('State', {
|
|
13
|
+
Default: undefined,
|
|
14
|
+
Invalid: figma.string('Validation'),
|
|
15
|
+
}),
|
|
16
|
+
validationStatus: figma.enum('State', {
|
|
17
|
+
Default: undefined,
|
|
18
|
+
Invalid: 'invalid',
|
|
19
|
+
}),
|
|
20
|
+
// "labelVariant": figma.enum('Label variant', {
|
|
21
|
+
// "Body": "body",
|
|
22
|
+
// "Heading": "heading"
|
|
23
|
+
// })
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const onChangeHandler = () => {
|
|
27
|
+
// Placeholder for onChange handler
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const value = 'some value';
|
|
31
|
+
|
|
32
|
+
figma.connect(
|
|
33
|
+
CurrencyInput,
|
|
34
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=2161%3A1336',
|
|
35
|
+
{
|
|
36
|
+
props,
|
|
37
|
+
variant: {
|
|
38
|
+
'Value type': 'Filled',
|
|
39
|
+
},
|
|
40
|
+
example: props => (
|
|
41
|
+
<FormField
|
|
42
|
+
label={props.label}
|
|
43
|
+
helperText={props.helperText}
|
|
44
|
+
invalidText={props.invalidText}
|
|
45
|
+
validationStatus={props.validationStatus}
|
|
46
|
+
>
|
|
47
|
+
<CurrencyInput value={props.value} onChange={onChangeHandler} />
|
|
48
|
+
</FormField>
|
|
49
|
+
),
|
|
50
|
+
}
|
|
51
|
+
);
|
|
11
52
|
|
|
12
53
|
figma.connect(
|
|
13
54
|
CurrencyInput,
|
|
14
|
-
|
|
55
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=2161%3A1336',
|
|
15
56
|
{
|
|
16
|
-
props
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
placeholder: figma.string("Label"),
|
|
20
|
-
autoFocus: figma.boolean("Focus?"),
|
|
21
|
-
defaultValue: figma.string("Value"),
|
|
22
|
-
value: figma.string("Value"),
|
|
23
|
-
focusable: figma.boolean("Focus?"),
|
|
24
|
-
hasTVPreferredFocus: figma.boolean("Focus?"),
|
|
25
|
-
// No matching props could be found for these Figma properties:
|
|
26
|
-
// "validation": figma.string('Validation'),
|
|
27
|
-
// "helperText": figma.string('Helper text'),
|
|
28
|
-
// "label": figma.string('Label'),
|
|
29
|
-
// "value": figma.string('Value'),
|
|
30
|
-
// "helperText": figma.boolean('Helper text?'),
|
|
31
|
-
// "state": figma.enum('State', {
|
|
32
|
-
// "Default": "default",
|
|
33
|
-
// "Invalid": "invalid"
|
|
34
|
-
// }),
|
|
35
|
-
// "valueType": figma.enum('Value type', {
|
|
36
|
-
// "Placeholder": "placeholder",
|
|
37
|
-
// "Filled": "filled"
|
|
38
|
-
// }),
|
|
39
|
-
// "labelVariant": figma.enum('Label variant', {
|
|
40
|
-
// "Body": "body",
|
|
41
|
-
// "Heading": "heading"
|
|
42
|
-
// })
|
|
57
|
+
props,
|
|
58
|
+
variant: {
|
|
59
|
+
'Value type': 'Placeholder',
|
|
43
60
|
},
|
|
44
|
-
example:
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/>
|
|
61
|
+
example: props => (
|
|
62
|
+
<FormField
|
|
63
|
+
label={props.label}
|
|
64
|
+
helperText={props.helperText}
|
|
65
|
+
invalidText={props.invalidText}
|
|
66
|
+
validationStatus={props.validationStatus}
|
|
67
|
+
>
|
|
68
|
+
<CurrencyInput placeholder={props.placeholder} value={value} onChange={onChangeHandler} />
|
|
69
|
+
</FormField>
|
|
54
70
|
),
|
|
55
|
-
}
|
|
56
|
-
)
|
|
71
|
+
}
|
|
72
|
+
);
|
|
@@ -12,6 +12,12 @@ export interface CurrencyInputBaseProps {
|
|
|
12
12
|
required?: boolean;
|
|
13
13
|
/** When not specifically disabled, the numeric value is automatically formatted with thousand separators (e.g. 1234 -> 1,234). */
|
|
14
14
|
disableGroupSeparator?: boolean;
|
|
15
|
+
label?: string;
|
|
16
|
+
labelVariant?: 'heading' | 'body';
|
|
17
|
+
helperText?: string;
|
|
18
|
+
helperIcon?: React.ComponentType;
|
|
19
|
+
validText?: string;
|
|
20
|
+
invalidText?: string;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
export type CurrencyInputProps = CurrencyInputBaseProps &
|
|
@@ -22,6 +22,35 @@ const meta = {
|
|
|
22
22
|
description: 'The validation status',
|
|
23
23
|
defaultValue: 'initial',
|
|
24
24
|
},
|
|
25
|
+
label: {
|
|
26
|
+
control: 'text',
|
|
27
|
+
description: 'The label for the CurrencyInput',
|
|
28
|
+
defaultValue: 'Currency Input Label',
|
|
29
|
+
},
|
|
30
|
+
helperText: {
|
|
31
|
+
control: 'text',
|
|
32
|
+
description: 'The helper text for the CurrencyInput',
|
|
33
|
+
defaultValue: 'Supporting text',
|
|
34
|
+
},
|
|
35
|
+
labelVariant: {
|
|
36
|
+
control: 'radio',
|
|
37
|
+
options: ['heading', 'body'],
|
|
38
|
+
description: 'The label text variant',
|
|
39
|
+
},
|
|
40
|
+
helperIcon: {
|
|
41
|
+
control: 'object',
|
|
42
|
+
description: 'The helper icon component',
|
|
43
|
+
},
|
|
44
|
+
validText: {
|
|
45
|
+
control: 'text',
|
|
46
|
+
description: 'The valid text for the CurrencyInput',
|
|
47
|
+
defaultValue: 'Valid text',
|
|
48
|
+
},
|
|
49
|
+
invalidText: {
|
|
50
|
+
control: 'text',
|
|
51
|
+
description: 'The invalid text for the CurrencyInput',
|
|
52
|
+
defaultValue: 'Invalid text',
|
|
53
|
+
},
|
|
25
54
|
disabled: {
|
|
26
55
|
control: 'boolean',
|
|
27
56
|
description: 'Disable the input',
|
|
@@ -107,7 +136,7 @@ export const States: Story = {
|
|
|
107
136
|
<CurrencyInput disabled />
|
|
108
137
|
</VariantTitle>
|
|
109
138
|
<VariantTitle title="Readonly">
|
|
110
|
-
<CurrencyInput readonly value="11666"/>
|
|
139
|
+
<CurrencyInput readonly value="11666" />
|
|
111
140
|
</VariantTitle>
|
|
112
141
|
<VariantTitle title="Disable auto format thousands">
|
|
113
142
|
<CurrencyInput disableGroupSeparator value="1234.56" />
|
|
@@ -2,7 +2,6 @@ import { Platform } from 'react-native';
|
|
|
2
2
|
import { StyleSheet } from 'react-native-unistyles';
|
|
3
3
|
import { formatThousands } from '../../utils';
|
|
4
4
|
import { DetailText } from '../DetailText';
|
|
5
|
-
import { useFormFieldContext } from '../FormField';
|
|
6
5
|
import { Input, InputField, InputSlot } from '../Input';
|
|
7
6
|
import type CurrencyInputProps from './CurrencyInput.props';
|
|
8
7
|
|
|
@@ -13,17 +12,19 @@ const CurrencyInput = ({
|
|
|
13
12
|
readonly,
|
|
14
13
|
placeholder,
|
|
15
14
|
inBottomSheet = false,
|
|
16
|
-
required,
|
|
15
|
+
required = true,
|
|
17
16
|
disableGroupSeparator = false,
|
|
18
17
|
value,
|
|
19
18
|
onChangeText,
|
|
19
|
+
label,
|
|
20
|
+
labelVariant = 'body',
|
|
21
|
+
helperText,
|
|
22
|
+
helperIcon,
|
|
23
|
+
validText,
|
|
24
|
+
invalidText,
|
|
20
25
|
ref,
|
|
21
26
|
...rest
|
|
22
27
|
}: CurrencyInputProps) => {
|
|
23
|
-
const formFieldContext = useFormFieldContext();
|
|
24
|
-
const { disabled: formFieldDisabled } = formFieldContext;
|
|
25
|
-
const validationStatusFromContext = formFieldContext?.validationStatus ?? validationStatus;
|
|
26
|
-
|
|
27
28
|
const defaultFormat = '0.00';
|
|
28
29
|
const getPlaceholder = placeholder ?? defaultFormat;
|
|
29
30
|
|
|
@@ -41,11 +42,18 @@ const CurrencyInput = ({
|
|
|
41
42
|
|
|
42
43
|
return (
|
|
43
44
|
<Input
|
|
44
|
-
validationStatus={
|
|
45
|
-
disabled={
|
|
45
|
+
validationStatus={validationStatus}
|
|
46
|
+
disabled={disabled}
|
|
46
47
|
readonly={readonly}
|
|
47
48
|
focused={focused}
|
|
49
|
+
required={required}
|
|
48
50
|
style={styles.wrap}
|
|
51
|
+
label={label}
|
|
52
|
+
labelVariant={labelVariant}
|
|
53
|
+
helperText={helperText}
|
|
54
|
+
helperIcon={helperIcon}
|
|
55
|
+
validText={validText}
|
|
56
|
+
invalidText={invalidText}
|
|
49
57
|
>
|
|
50
58
|
<InputSlot>
|
|
51
59
|
<DetailText size="4xl" style={styles.text} accessible={false}>
|