@utilitywarehouse/hearth-react-native 0.19.0 → 0.20.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/.storybook/preview.tsx +1 -0
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +16 -16
- package/CHANGELOG.md +74 -2
- package/build/components/Menu/Menu.d.ts +1 -1
- package/build/components/Menu/Menu.js +2 -2
- package/build/components/Menu/Menu.props.d.ts +2 -6
- package/build/components/Modal/Modal.d.ts +1 -1
- package/build/components/Modal/Modal.js +2 -2
- package/build/components/Modal/Modal.props.d.ts +1 -0
- package/build/components/Modal/Modal.web.d.ts +1 -1
- package/build/components/Modal/Modal.web.js +2 -2
- package/build/components/Select/Select.d.ts +1 -1
- package/build/components/Select/Select.js +9 -10
- package/build/components/Select/Select.props.d.ts +16 -0
- package/build/components/Toast/ToastItem.js +3 -1
- package/docs/changelog.mdx +687 -0
- package/package.json +6 -6
- package/scripts/copyChangelog.js +50 -0
- package/src/components/Checkbox/CheckboxGroup.figma.tsx +21 -1
- package/src/components/Menu/Menu.docs.mdx +8 -5
- package/src/components/Menu/Menu.figma.tsx +27 -27
- package/src/components/Menu/Menu.props.ts +2 -6
- package/src/components/Menu/Menu.tsx +3 -6
- package/src/components/Menu/MenuItem.figma.tsx +26 -18
- package/src/components/Modal/Modal.docs.mdx +22 -21
- package/src/components/Modal/Modal.figma.tsx +58 -47
- package/src/components/Modal/Modal.props.ts +1 -0
- package/src/components/Modal/Modal.stories.tsx +4 -0
- package/src/components/Modal/Modal.tsx +2 -1
- package/src/components/Modal/Modal.web.tsx +2 -1
- package/src/components/PillGroup/Pill.figma.tsx +4 -17
- package/src/components/PillGroup/PillGroup.figma.tsx +8 -9
- package/src/components/ProgressStepper/ProgressStep.figma.tsx +4 -15
- package/src/components/ProgressStepper/ProgressStepper.figma.tsx +9 -16
- package/src/components/Radio/Radio.figma.tsx +35 -22
- package/src/components/Radio/RadioGroup.figma.tsx +69 -41
- package/src/components/Radio/RadioTile.figma.tsx +34 -0
- package/src/components/RadioCard/RadioCard.figma.tsx +24 -0
- package/src/components/SectionHeader/SectionHeader.figma.tsx +31 -25
- package/src/components/Select/Select.docs.mdx +76 -28
- package/src/components/Select/Select.figma.tsx +44 -43
- package/src/components/Select/Select.props.ts +16 -0
- package/src/components/Select/Select.tsx +42 -35
- package/src/components/Select/SelectOption.figma.tsx +3 -21
- package/src/components/Spinner/Spinner.figma.tsx +12 -25
- package/src/components/Switch/Switch.figma.tsx +2 -23
- package/src/components/Tabs/Tab.figma.tsx +21 -0
- package/src/components/Tabs/Tabs.figma.tsx +18 -27
- package/src/components/Textarea/Textarea.figma.tsx +64 -0
- package/src/components/Toast/ToastItem.tsx +3 -1
- package/src/components/ToggleButtonCard/ToggleButtonCard.figma.tsx +24 -0
- package/src/components/VerificationInput/VerificationInput.figma.tsx +53 -0
- package/src/components/Radio/RadioTileRoot.figma.tsx +0 -31
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
import figma from '@figma/code-connect';
|
|
2
|
-
import ProgressStep from '
|
|
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
|
-
*/
|
|
2
|
+
import { ProgressStep } from '../';
|
|
10
3
|
|
|
11
4
|
figma.connect(
|
|
12
5
|
ProgressStep,
|
|
13
6
|
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=6056%3A1987',
|
|
14
7
|
{
|
|
15
8
|
props: {
|
|
16
|
-
// These props were automatically mapped based on your linked code:
|
|
17
9
|
status: figma.enum('State', {
|
|
18
10
|
Complete: 'complete',
|
|
19
11
|
Active: 'active',
|
|
20
12
|
Incomplete: 'incomplete',
|
|
21
13
|
}),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// "label": figma.boolean('Label?'),
|
|
25
|
-
// "stepNumber": figma.string('Step number'),
|
|
26
|
-
// "interactive": figma.boolean('Interactive?')
|
|
14
|
+
label: figma.string('Label'),
|
|
15
|
+
id: figma.string('Step number'),
|
|
27
16
|
},
|
|
28
|
-
example: props => <ProgressStep id={
|
|
17
|
+
example: props => <ProgressStep id={props.id} status={props.status} />,
|
|
29
18
|
}
|
|
30
19
|
);
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import ProgressStepper from
|
|
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 { ProgressStepper } from '../';
|
|
12
3
|
|
|
13
4
|
figma.connect(
|
|
14
5
|
ProgressStepper,
|
|
15
|
-
|
|
6
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=6056%3A2000',
|
|
16
7
|
{
|
|
17
|
-
props: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
props: {
|
|
9
|
+
steps: figma.children('Step'),
|
|
10
|
+
},
|
|
11
|
+
example: props => <ProgressStepper>{props.steps}</ProgressStepper>,
|
|
12
|
+
}
|
|
13
|
+
);
|
|
@@ -1,25 +1,38 @@
|
|
|
1
1
|
import figma from '@figma/code-connect';
|
|
2
2
|
import Radio from './Radio';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
figma.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
4
|
+
figma.connect(
|
|
5
|
+
Radio,
|
|
6
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=7428-12685&m=dev',
|
|
7
|
+
{
|
|
8
|
+
props: {
|
|
9
|
+
helperText: figma.boolean('Helper text?', {
|
|
10
|
+
true: figma.string('Helper text'),
|
|
11
|
+
}),
|
|
12
|
+
label: figma.string('Label'),
|
|
13
|
+
image: figma.boolean('Image?', {
|
|
14
|
+
true: figma.instance('Radio Image'),
|
|
15
|
+
}),
|
|
16
|
+
state: figma.enum('State', {
|
|
17
|
+
Default: 'default',
|
|
18
|
+
}),
|
|
19
|
+
checked: figma.boolean('Checked?'),
|
|
20
|
+
indicator: figma.nestedProps('Radio Item', {
|
|
21
|
+
disabled: figma.enum('State', {
|
|
22
|
+
Disabled: true,
|
|
23
|
+
}),
|
|
24
|
+
}),
|
|
25
|
+
},
|
|
26
|
+
example: props => (
|
|
27
|
+
<Radio
|
|
28
|
+
label={props.label}
|
|
29
|
+
helperText={props.helperText}
|
|
30
|
+
image={props.image}
|
|
31
|
+
state={props.state}
|
|
32
|
+
checked={props.checked}
|
|
33
|
+
disabled={props.indicator.disabled}
|
|
34
|
+
value="someValue"
|
|
35
|
+
/>
|
|
36
|
+
),
|
|
37
|
+
}
|
|
38
|
+
);
|
|
@@ -1,54 +1,82 @@
|
|
|
1
|
-
import
|
|
2
|
-
import RadioGroup from
|
|
3
|
-
import figma from "@figma/code-connect"
|
|
1
|
+
import figma from '@figma/code-connect';
|
|
2
|
+
import { RadioGroup } from '../';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const props = {
|
|
5
|
+
validationStatus: figma.enum('State', {
|
|
6
|
+
Invalid: 'invalid',
|
|
7
|
+
}),
|
|
8
|
+
labelVariant: figma.enum('Label variant', {
|
|
9
|
+
Body: 'body',
|
|
10
|
+
Heading: 'heading',
|
|
11
|
+
}),
|
|
12
|
+
direction: figma.enum('Direction', {
|
|
13
|
+
Row: 'row',
|
|
14
|
+
}),
|
|
15
|
+
label: figma.string('Group label'),
|
|
16
|
+
helperText: figma.boolean('Helper text?', {
|
|
17
|
+
true: figma.string('Helper text'),
|
|
18
|
+
}),
|
|
19
|
+
invalidText: figma.enum('State', {
|
|
20
|
+
Invalid: figma.string('Validation text'),
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const value = '';
|
|
25
|
+
const setValue = (value: string) => {};
|
|
11
26
|
|
|
12
27
|
figma.connect(
|
|
13
28
|
RadioGroup,
|
|
14
|
-
|
|
29
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=3138-13254&t=Uq6QfQcygdNGv5lM-4',
|
|
15
30
|
{
|
|
31
|
+
variant: {
|
|
32
|
+
Content: 'Radio',
|
|
33
|
+
},
|
|
16
34
|
props: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
helperText: figma.string("Helper text"),
|
|
20
|
-
invalidText: figma.string("Helper text"),
|
|
21
|
-
validText: figma.string("Validation text"),
|
|
22
|
-
direction: figma.enum("Direction", {
|
|
23
|
-
Row: "row",
|
|
24
|
-
Column: "column",
|
|
25
|
-
}),
|
|
26
|
-
// No matching props could be found for these Figma properties:
|
|
27
|
-
// "groupLabel": figma.string('Group label'),
|
|
28
|
-
// "helperText": figma.boolean('Helper text?'),
|
|
29
|
-
// "helperText": figma.string('Helper text'),
|
|
30
|
-
// "validationText": figma.string('Validation text'),
|
|
31
|
-
// "state": figma.enum('State', {
|
|
32
|
-
// "Default": "default",
|
|
33
|
-
// "Invalid": "invalid"
|
|
34
|
-
// }),
|
|
35
|
-
// "labelVariant": figma.enum('Label variant', {
|
|
36
|
-
// "Body": "body",
|
|
37
|
-
// "Heading": "heading"
|
|
38
|
-
// }),
|
|
39
|
-
// "content": figma.enum('Content', {
|
|
40
|
-
// "Radio": "radio",
|
|
41
|
-
// "Radio Tile": "radio-tile"
|
|
42
|
-
// })
|
|
35
|
+
...props,
|
|
36
|
+
items: figma.children('Radio'),
|
|
43
37
|
},
|
|
44
|
-
example:
|
|
38
|
+
example: props => (
|
|
45
39
|
<RadioGroup
|
|
46
40
|
label={props.label}
|
|
47
41
|
helperText={props.helperText}
|
|
42
|
+
validationStatus={props.validationStatus}
|
|
43
|
+
labelVariant={props.labelVariant}
|
|
44
|
+
direction={props.direction}
|
|
48
45
|
invalidText={props.invalidText}
|
|
49
|
-
|
|
46
|
+
value={value}
|
|
47
|
+
onChange={value => setValue(value)}
|
|
48
|
+
>
|
|
49
|
+
{props.items}
|
|
50
|
+
</RadioGroup>
|
|
51
|
+
),
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
figma.connect(
|
|
56
|
+
RadioGroup,
|
|
57
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=3138-13254&t=Uq6QfQcygdNGv5lM-4',
|
|
58
|
+
{
|
|
59
|
+
variant: {
|
|
60
|
+
Content: 'Radio Tile',
|
|
61
|
+
},
|
|
62
|
+
props: {
|
|
63
|
+
...props,
|
|
64
|
+
items: figma.children('Radio Tile'),
|
|
65
|
+
},
|
|
66
|
+
example: props => (
|
|
67
|
+
<RadioGroup
|
|
68
|
+
label={props.label}
|
|
69
|
+
helperText={props.helperText}
|
|
70
|
+
validationStatus={props.validationStatus}
|
|
71
|
+
labelVariant={props.labelVariant}
|
|
50
72
|
direction={props.direction}
|
|
51
|
-
|
|
73
|
+
invalidText={props.invalidText}
|
|
74
|
+
type="tile"
|
|
75
|
+
value={value}
|
|
76
|
+
onChange={value => setValue(value)}
|
|
77
|
+
>
|
|
78
|
+
{props.items}
|
|
79
|
+
</RadioGroup>
|
|
52
80
|
),
|
|
53
|
-
}
|
|
54
|
-
)
|
|
81
|
+
}
|
|
82
|
+
);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import figma from '@figma/code-connect';
|
|
2
|
+
import { RadioTile } from '../';
|
|
3
|
+
|
|
4
|
+
figma.connect(
|
|
5
|
+
RadioTile,
|
|
6
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=3138-13222&t=Uq6QfQcygdNGv5lM-4',
|
|
7
|
+
{
|
|
8
|
+
props: {
|
|
9
|
+
helperText: figma.boolean('Helper text?', {
|
|
10
|
+
true: figma.string('Helper text'),
|
|
11
|
+
}),
|
|
12
|
+
label: figma.string('Label'),
|
|
13
|
+
image: figma.boolean('Image?', {
|
|
14
|
+
true: figma.instance('Radio Image'),
|
|
15
|
+
}),
|
|
16
|
+
checked: figma.boolean('Checked?'),
|
|
17
|
+
indicator: figma.nestedProps('Radio Item', {
|
|
18
|
+
disabled: figma.enum('State', {
|
|
19
|
+
Disabled: true,
|
|
20
|
+
}),
|
|
21
|
+
}),
|
|
22
|
+
},
|
|
23
|
+
example: props => (
|
|
24
|
+
<RadioTile
|
|
25
|
+
label={props.label}
|
|
26
|
+
helperText={props.helperText}
|
|
27
|
+
image={props.image}
|
|
28
|
+
checked={props.checked}
|
|
29
|
+
disabled={props.indicator.disabled}
|
|
30
|
+
value="someValue"
|
|
31
|
+
/>
|
|
32
|
+
),
|
|
33
|
+
}
|
|
34
|
+
);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import figma from '@figma/code-connect';
|
|
2
|
+
import { RadioCard } from '../';
|
|
3
|
+
|
|
4
|
+
figma.connect(
|
|
5
|
+
RadioCard,
|
|
6
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=2164-727&t=Uq6QfQcygdNGv5lM-4',
|
|
7
|
+
{
|
|
8
|
+
variant: {
|
|
9
|
+
Variant: 'Radio',
|
|
10
|
+
},
|
|
11
|
+
props: {
|
|
12
|
+
radio: figma.nestedProps('Radio', {
|
|
13
|
+
label: figma.string('Label'),
|
|
14
|
+
}),
|
|
15
|
+
content: figma.instance('Content'),
|
|
16
|
+
},
|
|
17
|
+
example: props => (
|
|
18
|
+
// This should be wrapped in a RadioCardGroup, see docs
|
|
19
|
+
<RadioCard label={props.radio.label} value="someValue">
|
|
20
|
+
{props.content}
|
|
21
|
+
</RadioCard>
|
|
22
|
+
),
|
|
23
|
+
}
|
|
24
|
+
);
|
|
@@ -1,31 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
import SectionHeader from
|
|
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 { SectionHeader } from '../';
|
|
12
3
|
|
|
13
4
|
figma.connect(
|
|
14
5
|
SectionHeader,
|
|
15
|
-
|
|
6
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=9092%3A3352',
|
|
16
7
|
{
|
|
17
8
|
props: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
9
|
+
trailingContent: figma.boolean('Trailing content?', {
|
|
10
|
+
true: figma.nestedProps('Trailing content', {
|
|
11
|
+
content: figma.children('Link'),
|
|
12
|
+
}),
|
|
13
|
+
}),
|
|
14
|
+
helperText: figma.boolean('Helper text?', {
|
|
15
|
+
true: figma.string('Helper text'),
|
|
16
|
+
}),
|
|
17
|
+
heading: figma.string('Heading'),
|
|
18
|
+
badge: figma.boolean('Badge?', {
|
|
19
|
+
true: figma.children('Badge'),
|
|
20
|
+
}),
|
|
21
|
+
invalidText: figma.enum('State', {
|
|
22
|
+
Invalid: figma.nestedProps('Validation Text', {
|
|
23
|
+
text: figma.string('Text'),
|
|
24
|
+
}),
|
|
25
|
+
}),
|
|
28
26
|
},
|
|
29
|
-
example:
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
example: props => (
|
|
28
|
+
<SectionHeader
|
|
29
|
+
heading={props.heading}
|
|
30
|
+
helperText={props.helperText}
|
|
31
|
+
badge={props.badge}
|
|
32
|
+
trailingContent={props.trailingContent?.content}
|
|
33
|
+
invalidText={props.invalidText?.text}
|
|
34
|
+
/>
|
|
35
|
+
),
|
|
36
|
+
}
|
|
37
|
+
);
|
|
@@ -20,6 +20,7 @@ The `Select` component creates a dropdown menu that allows users to choose from
|
|
|
20
20
|
- [`Select`](#select)
|
|
21
21
|
- [`SelectOption`](#selectoption)
|
|
22
22
|
- [Examples](#examples)
|
|
23
|
+
- [With label and helper text](#with-label-and-helper-text)
|
|
23
24
|
- [With `FormField`](#with-formfield)
|
|
24
25
|
- [Searchable `Select`](#searchable-select)
|
|
25
26
|
- [Inline `SelectOption`](#inline-selectoption)
|
|
@@ -77,42 +78,89 @@ const MyComponent = () => {
|
|
|
77
78
|
|
|
78
79
|
The `Select` component inherits all of the React Native [`View` props](https://reactnative.dev/docs/view).
|
|
79
80
|
|
|
80
|
-
| Prop | Type | Default | Description
|
|
81
|
-
| ----------------- | ----------------------------------- | ------------------------ |
|
|
82
|
-
| options | SelectOptionProps[]
|
|
83
|
-
| value | string \| null
|
|
84
|
-
| onValueChange | (value: string) => void
|
|
85
|
-
| label | string
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
|
92
|
-
|
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
|
|
|
81
|
+
| Prop | Type | Default | Description |
|
|
82
|
+
| ----------------- | ----------------------------------- | ------------------------ | -------------------------------------------------------------------------- |
|
|
83
|
+
| options | `SelectOptionProps[]` | `[]` | Array of options to display in the select. |
|
|
84
|
+
| value | `string \| null` | `-` | Currently selected value. |
|
|
85
|
+
| onValueChange | `(value: string) => void` | `-` | Callback when value changes. |
|
|
86
|
+
| label | `string` | `-` | Label for the select. |
|
|
87
|
+
| labelVariant | `'body' \| 'heading'` | `'body'` | Variant for the label. 'inline' will display the label next to the select. |
|
|
88
|
+
| helperText | `string` | `-` | Helper text to display below the select. |
|
|
89
|
+
| helperIcon | `React.ComponentType` | `-` | Optional icon to display next to the helper text. |
|
|
90
|
+
| placeholder | `string` | `'Select an option'` | Placeholder text to show when no value is selected. |
|
|
91
|
+
| disabled | `boolean` | `false` | Whether the select is disabled. |
|
|
92
|
+
| readonly | `boolean` | `false` | Whether the select is readonly. |
|
|
93
|
+
| leadingIcon | `React.ComponentType` | `-` | Icon to display before the select text. |
|
|
94
|
+
| validationStatus | `'initial' \| 'valid' \| 'invalid'` | `'initial'` | The validation status of the select. |
|
|
95
|
+
| invalidText | `string` | `-` | Text to display when validationStatus is 'invalid'. |
|
|
96
|
+
| validText | `string` | `-` | Text to display when validationStatus is 'valid'. |
|
|
97
|
+
| required | `boolean` | `true` | Indicates that the select is required. |
|
|
98
|
+
| menuHeading | `string` | `-` | Heading to display at the top of the menu. |
|
|
99
|
+
| children | `ReactNode` | `-` | Children to render inside the select (for custom options). |
|
|
100
|
+
| bottomSheetProps | `BottomSheetProps` | `-` | Props passed to the BottomSheetModal. |
|
|
101
|
+
| emptyText | `string` | `'No options available'` | Text to display when no options are available. |
|
|
102
|
+
| listProps | `object` | `-` | Props to be passed to the bottom sheet flat list. |
|
|
103
|
+
| searchable | `boolean` | `false` | Optional search functionality for the select. |
|
|
104
|
+
| searchPlaceholder | `string` | `'Search'` | Search placeholder. |
|
|
99
105
|
|
|
100
106
|
### `SelectOption`
|
|
101
107
|
|
|
102
108
|
The `SelectOption` component is used to create individual options within the `Select` component. It can be used inline or as part of the `options` prop.
|
|
103
109
|
|
|
104
|
-
| Prop | Type
|
|
105
|
-
| ------------ |
|
|
106
|
-
| label | string | `-` | Label to display for this option. |
|
|
107
|
-
| value | string | `-` | Value for this option. |
|
|
108
|
-
| leadingIcon | React.ComponentType | `-` | Optional left icon for this option. |
|
|
109
|
-
| trailingIcon | React.ComponentType | `-` | Optional right icon for this option. |
|
|
110
|
-
| selected | boolean | `-` | Whether this option is selected. |
|
|
111
|
-
| disabled | boolean | `false` | Whether this option is disabled. |
|
|
112
|
-
| onPress | (value: string) => void | `-` | Callback when this option is selected. |
|
|
110
|
+
| Prop | Type | Default | Description |
|
|
111
|
+
| ------------ | ------------------------- | ------- | -------------------------------------- |
|
|
112
|
+
| label | `string` | `-` | Label to display for this option. |
|
|
113
|
+
| value | `string` | `-` | Value for this option. |
|
|
114
|
+
| leadingIcon | `React.ComponentType` | `-` | Optional left icon for this option. |
|
|
115
|
+
| trailingIcon | `React.ComponentType` | `-` | Optional right icon for this option. |
|
|
116
|
+
| selected | `boolean` | `-` | Whether this option is selected. |
|
|
117
|
+
| disabled | `boolean` | `false` | Whether this option is disabled. |
|
|
118
|
+
| onPress | `(value: string) => void` | `-` | Callback when this option is selected. |
|
|
113
119
|
|
|
114
120
|
## Examples
|
|
115
121
|
|
|
122
|
+
## With label and helper text
|
|
123
|
+
|
|
124
|
+
<UsageWrap>
|
|
125
|
+
<Center>
|
|
126
|
+
<Select
|
|
127
|
+
label="Select an option"
|
|
128
|
+
helperText="This is some helper text for the select component."
|
|
129
|
+
placeholder="Select an option"
|
|
130
|
+
options={[
|
|
131
|
+
{ label: 'Option 1', value: '1' },
|
|
132
|
+
{ label: 'Option 2', value: '2' },
|
|
133
|
+
{ label: 'Option 3', value: '3' },
|
|
134
|
+
]}
|
|
135
|
+
value="1"
|
|
136
|
+
onValueChange={value => console.log('Selected:', value)}
|
|
137
|
+
/>
|
|
138
|
+
</Center>
|
|
139
|
+
</UsageWrap>
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
import { Select } from '@utilitywarehouse/hearth-react-native';
|
|
143
|
+
|
|
144
|
+
const MyComponent = () => {
|
|
145
|
+
const [value, setValue] = useState(null);
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<Select
|
|
149
|
+
label="Select an option"
|
|
150
|
+
helperText="This is some helper text for the select component."
|
|
151
|
+
placeholder="Select an option"
|
|
152
|
+
options={[
|
|
153
|
+
{ label: 'Option 1', value: '1' },
|
|
154
|
+
{ label: 'Option 2', value: '2' },
|
|
155
|
+
{ label: 'Option 3', value: '3' },
|
|
156
|
+
]}
|
|
157
|
+
value={value}
|
|
158
|
+
onValueChange={setValue}
|
|
159
|
+
/>
|
|
160
|
+
);
|
|
161
|
+
};
|
|
162
|
+
```
|
|
163
|
+
|
|
116
164
|
### With `FormField`
|
|
117
165
|
|
|
118
166
|
The `Select` component can be used with the `FormField` component for additional functionality like validation messages and helper text.
|
|
@@ -1,55 +1,56 @@
|
|
|
1
1
|
import figma from '@figma/code-connect';
|
|
2
|
-
import
|
|
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
|
-
*/
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Select } from '../';
|
|
10
4
|
|
|
11
5
|
figma.connect(Select, 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=3224%3A995', {
|
|
12
6
|
props: {
|
|
13
|
-
// These props were automatically mapped based on your linked code:
|
|
14
7
|
label: figma.string('Label'),
|
|
15
|
-
placeholder: figma.
|
|
8
|
+
placeholder: figma.enum('Value type', {
|
|
9
|
+
Placeholder: figma.string('Value'),
|
|
10
|
+
}),
|
|
16
11
|
disabled: figma.enum('Variant', {
|
|
17
12
|
Disabled: true,
|
|
18
13
|
}),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
'
|
|
14
|
+
validationStatus: figma.enum('Variant', {
|
|
15
|
+
Invalid: 'invalid',
|
|
16
|
+
Valid: 'valid',
|
|
22
17
|
}),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
invalidText: figma.enum('Variant', {
|
|
19
|
+
Invalid: figma.string('Validation'),
|
|
20
|
+
}),
|
|
21
|
+
validText: figma.enum('Variant', {
|
|
22
|
+
Valid: figma.string('Validation'),
|
|
28
23
|
}),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
24
|
+
helperText: figma.boolean('Helper text?', {
|
|
25
|
+
true: figma.string('Helper text'),
|
|
26
|
+
}),
|
|
27
|
+
required: figma.boolean('Optional?', {
|
|
28
|
+
true: false,
|
|
29
|
+
}),
|
|
30
|
+
value: figma.enum('Value type', {
|
|
31
|
+
Selected: figma.string('Value'),
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
example: props => {
|
|
35
|
+
const [value, setValue] = useState(null);
|
|
36
|
+
return (
|
|
37
|
+
<Select
|
|
38
|
+
label={props.label}
|
|
39
|
+
placeholder={props.placeholder}
|
|
40
|
+
disabled={props.disabled}
|
|
41
|
+
validationStatus={props.validationStatus}
|
|
42
|
+
invalidText={props.invalidText}
|
|
43
|
+
validText={props.validText}
|
|
44
|
+
helperText={props.helperText}
|
|
45
|
+
required={props.required}
|
|
46
|
+
options={[
|
|
47
|
+
{ label: 'Option 1', value: '1' },
|
|
48
|
+
{ label: 'Option 2', value: '2' },
|
|
49
|
+
{ label: 'Option 3', value: '3' },
|
|
50
|
+
]}
|
|
51
|
+
value={value}
|
|
52
|
+
onValueChange={value => setValue(value)}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
42
55
|
},
|
|
43
|
-
example: props => (
|
|
44
|
-
<Select
|
|
45
|
-
label={props.label}
|
|
46
|
-
placeholder={props.placeholder}
|
|
47
|
-
disabled={props.disabled}
|
|
48
|
-
emptyText={props.emptyText}
|
|
49
|
-
readonly={props.readonly}
|
|
50
|
-
collapsable={props.collapsable}
|
|
51
|
-
focusable={props.focusable}
|
|
52
|
-
hasTVPreferredFocus={props.hasTVPreferredFocus}
|
|
53
|
-
/>
|
|
54
|
-
),
|
|
55
56
|
});
|
|
@@ -53,6 +53,22 @@ interface SelectProps extends ViewProps {
|
|
|
53
53
|
* @default 'body'.
|
|
54
54
|
*/
|
|
55
55
|
labelVariant?: 'heading' | 'body';
|
|
56
|
+
/**
|
|
57
|
+
* Helper text to show below the select
|
|
58
|
+
*/
|
|
59
|
+
helperText?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Optional icon to display alongside the helper text
|
|
62
|
+
*/
|
|
63
|
+
helperIcon?: React.ComponentType;
|
|
64
|
+
/**
|
|
65
|
+
* Text to display when validationStatus is 'invalid'
|
|
66
|
+
*/
|
|
67
|
+
invalidText?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Text to display when validationStatus is 'valid'
|
|
70
|
+
*/
|
|
71
|
+
validText?: string;
|
|
56
72
|
/**
|
|
57
73
|
* Placeholder text to show when no value is selected
|
|
58
74
|
*/
|