@utilitywarehouse/hearth-react-native 0.16.1 → 0.17.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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +14 -14
- package/CHANGELOG.md +156 -0
- package/build/components/Card/CardAction/CardActionRoot.js +12 -2
- package/build/components/Card/CardActions.context.d.ts +6 -0
- package/build/components/Card/CardActions.context.js +5 -0
- package/build/components/Card/CardActions.d.ts +7 -0
- package/build/components/Card/CardActions.js +29 -0
- package/build/components/Card/CardRoot.js +16 -104
- package/build/components/Card/helpers.d.ts +8 -0
- package/build/components/Card/helpers.js +146 -0
- package/build/components/Card/index.d.ts +2 -0
- package/build/components/Card/index.js +2 -0
- package/build/components/DateInput/DateInput.d.ts +1 -1
- package/build/components/DateInput/DateInput.js +2 -3
- package/build/components/DateInput/DateInput.props.d.ts +22 -1
- package/build/components/DateInput/DateInputSegment.d.ts +2 -16
- package/build/components/DateInput/DateInputSegment.js +3 -6
- package/build/components/ExpandableCard/ExpandableCardGroup.d.ts +1 -1
- package/build/components/ExpandableCard/ExpandableCardGroup.js +2 -2
- package/build/components/ExpandableCard/ExpandableCardGroup.props.d.ts +4 -0
- package/build/components/Input/Input.js +4 -3
- package/build/components/Input/Input.props.d.ts +9 -0
- package/build/components/List/List.context.d.ts +4 -2
- package/build/components/List/List.context.js +0 -2
- package/build/components/List/List.d.ts +1 -1
- package/build/components/List/List.js +25 -38
- package/build/components/List/List.props.d.ts +1 -0
- package/build/components/List/ListAction/ListAction.js +24 -7
- package/build/components/List/ListAction/ListAction.props.d.ts +1 -0
- package/build/components/List/ListItem/ListItemRoot.js +12 -4
- package/build/utils/isThemedImageProps.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/Card/Card.docs.mdx +224 -66
- package/src/components/Card/Card.stories.tsx +29 -25
- package/src/components/Card/CardAction/CardAction.stories.tsx +239 -93
- package/src/components/Card/CardAction/CardActionRoot.tsx +15 -2
- package/src/components/Card/CardActions.context.ts +12 -0
- package/src/components/Card/CardActions.tsx +40 -0
- package/src/components/Card/CardRoot.tsx +27 -132
- package/src/components/Card/helpers.tsx +195 -0
- package/src/components/Card/index.ts +2 -0
- package/src/components/DateInput/DateInput.docs.mdx +47 -29
- package/src/components/DateInput/DateInput.props.ts +32 -1
- package/src/components/DateInput/DateInput.stories.tsx +10 -0
- package/src/components/DateInput/DateInput.tsx +12 -1
- package/src/components/DateInput/DateInputSegment.tsx +8 -23
- package/src/components/ExpandableCard/ExpandableCard.figma.tsx +33 -38
- package/src/components/ExpandableCard/ExpandableCardGroup.figma.tsx +34 -17
- package/src/components/ExpandableCard/ExpandableCardGroup.props.ts +5 -0
- package/src/components/ExpandableCard/ExpandableCardGroup.tsx +2 -0
- package/src/components/HighlightBanner/HighlightBanner.figma.tsx +46 -0
- package/src/components/IconButton/IconButton.figma.tsx +20 -30
- package/src/components/IconContainer/IconContainer.figma.tsx +7 -13
- package/src/components/IndicatorIconButton/IndicatorIconButton.figma.tsx +16 -0
- package/src/components/Input/Input.docs.mdx +55 -15
- package/src/components/Input/Input.figma.tsx +106 -40
- package/src/components/Input/Input.props.ts +9 -0
- package/src/components/Input/Input.tsx +21 -0
- package/src/components/Link/Link.figma.tsx +31 -38
- package/src/components/List/List.context.ts +2 -4
- package/src/components/List/List.docs.mdx +10 -5
- package/src/components/List/List.figma.tsx +42 -28
- package/src/components/List/List.props.ts +1 -0
- package/src/components/List/List.stories.tsx +43 -0
- package/src/components/List/List.tsx +38 -51
- package/src/components/List/ListAction/ListAction.figma.tsx +5 -13
- package/src/components/List/ListAction/ListAction.props.ts +1 -0
- package/src/components/List/ListAction/ListAction.tsx +40 -10
- package/src/components/List/ListItem/ListItem.figma.tsx +43 -27
- package/src/components/List/ListItem/ListItemRoot.tsx +15 -4
- package/src/utils/isThemedImageProps.ts +1 -1
- package/src/components/InlineLink/InlineLink.figma.tsx +0 -33
|
@@ -1,54 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
import ExpandableCard from
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* -- This file was auto-generated by Code Connect --
|
|
7
|
-
* `props` includes a mapping from your code props to Figma properties.
|
|
8
|
-
* You should check this is correct, and update the `example` function
|
|
9
|
-
* to return the code example you'd like to see in Figma
|
|
10
|
-
*/
|
|
1
|
+
import figma from '@figma/code-connect';
|
|
2
|
+
import { ExpandableCard } from '../';
|
|
3
|
+
import { IconContainer } from '../IconContainer';
|
|
11
4
|
|
|
12
5
|
figma.connect(
|
|
13
6
|
ExpandableCard,
|
|
14
|
-
|
|
7
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=7222%3A5935',
|
|
15
8
|
{
|
|
16
9
|
props: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
expanded: figma.boolean('Expand?'),
|
|
11
|
+
heading: figma.string('Heading'),
|
|
12
|
+
helperText: figma.string('Helper text'),
|
|
13
|
+
leadingContent: figma.boolean('Leading content?', {
|
|
14
|
+
true: figma.nestedProps('Leading content', {
|
|
15
|
+
variant: figma.enum('Variant', {
|
|
16
|
+
Icon: figma.instance('Icon-24'),
|
|
17
|
+
'Icon Container': <IconContainer icon={figma.instance('Icon-24')} />,
|
|
18
|
+
}),
|
|
19
|
+
}),
|
|
24
20
|
}),
|
|
25
|
-
disabled: figma.enum(
|
|
21
|
+
disabled: figma.enum('State', {
|
|
26
22
|
Active: true,
|
|
27
23
|
}),
|
|
28
|
-
collapsable: figma.boolean(
|
|
29
|
-
focusable: figma.enum(
|
|
24
|
+
collapsable: figma.boolean('Expand?'),
|
|
25
|
+
focusable: figma.enum('State', {
|
|
30
26
|
Focus: true,
|
|
31
27
|
}),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// "leadingContent": figma.boolean('Leading content?'),
|
|
40
|
-
// "badge": figma.boolean('Badge?')
|
|
28
|
+
content: figma.instance('Custom content'),
|
|
29
|
+
numericalValue: figma.boolean('Numerical value?', {
|
|
30
|
+
true: figma.string('Numerical value'),
|
|
31
|
+
}),
|
|
32
|
+
badge: figma.boolean('Badge?', {
|
|
33
|
+
true: figma.instance('Badge'),
|
|
34
|
+
}),
|
|
41
35
|
},
|
|
42
|
-
example:
|
|
36
|
+
example: props => (
|
|
43
37
|
<ExpandableCard
|
|
44
38
|
expanded={props.expanded}
|
|
45
39
|
heading={props.heading}
|
|
46
40
|
helperText={props.helperText}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
leadingContent={props.leadingContent?.variant}
|
|
42
|
+
numericValue={props.numericalValue}
|
|
43
|
+
badge={props.badge}
|
|
44
|
+
>
|
|
45
|
+
{props.content}
|
|
46
|
+
</ExpandableCard>
|
|
52
47
|
),
|
|
53
|
-
}
|
|
54
|
-
)
|
|
48
|
+
}
|
|
49
|
+
);
|
|
@@ -1,23 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import ExpandableCardGroup 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 { ExpandableCardGroup } from '../';
|
|
12
3
|
|
|
13
4
|
figma.connect(
|
|
14
5
|
ExpandableCardGroup,
|
|
15
|
-
|
|
6
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=7222-7221&m=dev',
|
|
16
7
|
{
|
|
17
8
|
props: {
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
sectionHeader: figma.boolean('Section header?', {
|
|
10
|
+
true: figma.nestedProps('Section Header', {
|
|
11
|
+
heading: figma.string('Heading'),
|
|
12
|
+
helperText: figma.boolean('Helper text?', {
|
|
13
|
+
true: figma.string('Helper text'),
|
|
14
|
+
}),
|
|
15
|
+
trailingContent: figma.boolean('Trailing content?', {
|
|
16
|
+
true: figma.nestedProps('Trailing content', {
|
|
17
|
+
headerTrailingContent: figma.instance('Variant'),
|
|
18
|
+
}),
|
|
19
|
+
}),
|
|
20
|
+
invalidText: figma.enum('State', {
|
|
21
|
+
Invalid: figma.nestedProps('Validation Text', {
|
|
22
|
+
invalidText: figma.string('Text'),
|
|
23
|
+
}),
|
|
24
|
+
}),
|
|
25
|
+
}),
|
|
26
|
+
}),
|
|
27
|
+
cards: figma.children('Expandable Card'),
|
|
20
28
|
},
|
|
21
|
-
example:
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
example: props => (
|
|
30
|
+
<ExpandableCardGroup
|
|
31
|
+
heading={props.sectionHeader?.heading}
|
|
32
|
+
helperText={props.sectionHeader?.helperText}
|
|
33
|
+
headerTrailingContent={props.sectionHeader?.trailingContent?.headerTrailingContent}
|
|
34
|
+
invalidText={props.sectionHeader?.invalidText?.invalidText}
|
|
35
|
+
>
|
|
36
|
+
{props.cards}
|
|
37
|
+
</ExpandableCardGroup>
|
|
38
|
+
),
|
|
39
|
+
}
|
|
40
|
+
);
|
|
@@ -26,6 +26,11 @@ export interface ExpandableCardGroupProps extends ViewProps {
|
|
|
26
26
|
* Test ID for testing
|
|
27
27
|
*/
|
|
28
28
|
testID?: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Validation text displayed below the helper text when in an invalid state
|
|
32
|
+
*/
|
|
33
|
+
invalidText?: string;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
export default ExpandableCardGroupProps;
|
|
@@ -10,6 +10,7 @@ const ExpandableCardGroup = ({
|
|
|
10
10
|
children,
|
|
11
11
|
style,
|
|
12
12
|
testID = 'expandable-card-group',
|
|
13
|
+
invalidText,
|
|
13
14
|
...props
|
|
14
15
|
}: ExpandableCardGroupProps) => {
|
|
15
16
|
return (
|
|
@@ -19,6 +20,7 @@ const ExpandableCardGroup = ({
|
|
|
19
20
|
heading={heading}
|
|
20
21
|
helperText={helperText}
|
|
21
22
|
trailingContent={headerTrailingContent}
|
|
23
|
+
invalidText={invalidText}
|
|
22
24
|
/>
|
|
23
25
|
) : null}
|
|
24
26
|
<View style={styles.cardsContainer}>{children}</View>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import figma from '@figma/code-connect';
|
|
2
|
+
import { HighlightBanner, Image } from '..';
|
|
3
|
+
|
|
4
|
+
figma.connect(
|
|
5
|
+
HighlightBanner,
|
|
6
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=8306-4665&t=3uUSBVdxldgG5uz3-4',
|
|
7
|
+
{
|
|
8
|
+
props: {
|
|
9
|
+
heading: figma.string('Heading'),
|
|
10
|
+
description: figma.string('Description'),
|
|
11
|
+
image: figma.boolean('Image?', {
|
|
12
|
+
true: <Image source={{ uri: '' }} />,
|
|
13
|
+
}),
|
|
14
|
+
headingColor: figma.enum('Heading color', {
|
|
15
|
+
Highlight: 'highlight',
|
|
16
|
+
Pig: 'pig',
|
|
17
|
+
Energy: 'energy',
|
|
18
|
+
Broadband: 'broadband',
|
|
19
|
+
Insurance: 'insurance',
|
|
20
|
+
Cashback: 'cashback',
|
|
21
|
+
Mobile: 'mobile',
|
|
22
|
+
}),
|
|
23
|
+
link: figma.boolean('Link?', {
|
|
24
|
+
true: figma.children('Link'),
|
|
25
|
+
}),
|
|
26
|
+
button: figma.boolean('Button?', {
|
|
27
|
+
true: figma.children('Button'),
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
example: props => {
|
|
31
|
+
return (
|
|
32
|
+
// HighlightBanner doesn't need to be wrapped in a Card
|
|
33
|
+
// it's a standalone component in code please see the HighlightBanner docs
|
|
34
|
+
// https://hearth.prod.uw.systems/react-native/?path=/docs/components-highlightbanner--docs
|
|
35
|
+
<HighlightBanner
|
|
36
|
+
heading={props.heading}
|
|
37
|
+
description={props.description}
|
|
38
|
+
image={props.image}
|
|
39
|
+
headingColor={props.headingColor}
|
|
40
|
+
link={props.link}
|
|
41
|
+
button={props.button}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
);
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import figma from '@figma/code-connect';
|
|
2
|
-
import IconButton 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 { IconButton } from '../';
|
|
10
3
|
|
|
11
4
|
figma.connect(IconButton, 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=90%3A1455', {
|
|
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
|
}),
|
|
@@ -18,38 +10,36 @@ figma.connect(IconButton, 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?n
|
|
|
18
10
|
'SM-32': 'sm',
|
|
19
11
|
'MD-48': 'md',
|
|
20
12
|
}),
|
|
13
|
+
colorScheme: figma.enum('Color Scheme', {
|
|
14
|
+
Affirmative: 'affirmative',
|
|
15
|
+
Destructive: 'destructive',
|
|
16
|
+
Functional: 'functional',
|
|
17
|
+
Highlight: 'highlight',
|
|
18
|
+
}),
|
|
21
19
|
loading: figma.enum('State', {
|
|
22
20
|
Loading: true,
|
|
23
21
|
}),
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
'aria-disabled': figma.enum('State', {
|
|
28
|
-
Disabled: true,
|
|
22
|
+
icon: figma.enum('Size', {
|
|
23
|
+
'SM-32': figma.instance('Icon-20'),
|
|
24
|
+
'MD-48': figma.instance('Icon-24'),
|
|
29
25
|
}),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
variant: figma.enum('Variant', {
|
|
27
|
+
Emphasis: 'emphasis',
|
|
28
|
+
Solid: 'solid',
|
|
29
|
+
Outline: 'outline',
|
|
30
|
+
Ghost: 'ghost',
|
|
33
31
|
}),
|
|
34
|
-
|
|
35
|
-
// "icon24": figma.instance('Icon-24'),
|
|
36
|
-
// "icon20": figma.instance('Icon-20'),
|
|
37
|
-
// "variant": figma.enum('Variant', {
|
|
38
|
-
// "Emphasis": "emphasis",
|
|
39
|
-
// "Solid": "solid",
|
|
40
|
-
// "Outline": "outline",
|
|
41
|
-
// "Ghost": "ghost"
|
|
42
|
-
// }),
|
|
43
|
-
// "inverted": figma.boolean('Inverted?')
|
|
32
|
+
inverted: figma.boolean('Inverted?'),
|
|
44
33
|
},
|
|
45
34
|
example: props => (
|
|
46
35
|
<IconButton
|
|
47
36
|
disabled={props.disabled}
|
|
48
37
|
size={props.size}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
focusable={props.focusable}
|
|
38
|
+
variant={props.variant}
|
|
39
|
+
inverted={props.inverted}
|
|
52
40
|
colorScheme={props.colorScheme}
|
|
41
|
+
loading={props.loading}
|
|
42
|
+
icon={props.icon}
|
|
53
43
|
/>
|
|
54
44
|
),
|
|
55
45
|
});
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import figma from '@figma/code-connect';
|
|
2
|
-
import IconContainer 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 { IconContainer } from '../';
|
|
10
3
|
|
|
11
4
|
figma.connect(
|
|
12
5
|
IconContainer,
|
|
13
6
|
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=5462%3A9728',
|
|
14
7
|
{
|
|
15
8
|
props: {
|
|
16
|
-
// These props were automatically mapped based on your linked code:
|
|
17
9
|
size: figma.enum('Size', {
|
|
18
10
|
'SM-32': 'sm',
|
|
19
11
|
'MD-48': 'md',
|
|
@@ -33,13 +25,15 @@ figma.connect(
|
|
|
33
25
|
Cashback: 'cashback',
|
|
34
26
|
Highlight: 'highlight',
|
|
35
27
|
}),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
icon: figma.enum('Size', {
|
|
29
|
+
'SM-32': figma.instance('Icon-20'),
|
|
30
|
+
'MD-48': figma.instance('Icon-24'),
|
|
31
|
+
'LG-64': figma.instance('Icon-24'),
|
|
32
|
+
}),
|
|
39
33
|
},
|
|
40
34
|
example: props => (
|
|
41
35
|
<IconContainer
|
|
42
|
-
icon={
|
|
36
|
+
icon={props.icon}
|
|
43
37
|
size={props.size}
|
|
44
38
|
radiusNone={props.radiusNone}
|
|
45
39
|
variant={props.variant}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import figma from '@figma/code-connect';
|
|
2
|
+
import { IndicatorIconButton } from '..';
|
|
3
|
+
|
|
4
|
+
figma.connect(
|
|
5
|
+
IndicatorIconButton,
|
|
6
|
+
'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=6778-10672&t=3uUSBVdxldgG5uz3-4',
|
|
7
|
+
{
|
|
8
|
+
props: {
|
|
9
|
+
indicator: figma.boolean('Indicator?'),
|
|
10
|
+
icon: figma.nestedProps('Icon Button/Unstyled', {
|
|
11
|
+
icon: figma.instance('Icon-24'),
|
|
12
|
+
}),
|
|
13
|
+
},
|
|
14
|
+
example: props => <IndicatorIconButton icon={props.icon.icon} indicator={props.indicator} />,
|
|
15
|
+
}
|
|
16
|
+
);
|
|
@@ -29,6 +29,8 @@ The input component is a text field that allows users to enter text, numbers, or
|
|
|
29
29
|
- [Advanced Usage](#advanced-usage)
|
|
30
30
|
- [Variants](#variants)
|
|
31
31
|
- [Examples](#examples)
|
|
32
|
+
- [With Label and Helper Text](#with-label-and-helper-text)
|
|
33
|
+
- [With `prefix` and `suffix`](#with-prefix-and-suffix)
|
|
32
34
|
- [With `FormField`](#with-formfield)
|
|
33
35
|
- [Accessibility](#accessibility)
|
|
34
36
|
|
|
@@ -46,7 +48,7 @@ The input component is a text field that allows users to enter text, numbers, or
|
|
|
46
48
|
<InputSlot>
|
|
47
49
|
<InputIcon as={EmailMediumIcon} />
|
|
48
50
|
</InputSlot>
|
|
49
|
-
<InputField placeholder="Placeholder"
|
|
51
|
+
<InputField placeholder="Placeholder" onChangeText={() => console.log('###')} />
|
|
50
52
|
</Input>
|
|
51
53
|
</Center>
|
|
52
54
|
</UsageWrap>
|
|
@@ -95,8 +97,10 @@ all of the React Native [`View` props](https://reactnative.dev/docs/view).
|
|
|
95
97
|
| required | `boolean` | `true` | Indicates that the input is required. **(Only to be used if the input has no children)** |
|
|
96
98
|
| leadingIcon | `React.ComponentType` | `-` | The leading icon of the input. **(Only to be used if the input has no children)** |
|
|
97
99
|
| trailingIcon | `React.ComponentType` | `-` | The trailing icon of the input. **(Only to be used if the input has no children)** |
|
|
100
|
+
| prefix | `string \| React.ReactNode` | `-` | Content to display before the input field. **(Only to be used if the input has no children)** |
|
|
101
|
+
| suffix | `string \| React.ReactNode` | `-` | Content to display after the input field. **(Only to be used if the input has no children)** |
|
|
98
102
|
| value | `string` | `-` | The value of the input. **(Only to be used if the input has no children)** |
|
|
99
|
-
|
|
|
103
|
+
| onChangeText | `function` | `-` | Callback function that is triggered when the input value changes. **(Only to be used if the input has no children)** **(Only to be used if the input has no children)** |
|
|
100
104
|
| onBlur | `function` | `-` | Callback function that is triggered when the input loses focus. **(Only to be used if the input has no children)** |
|
|
101
105
|
| onFocus | `function` | `-` | Callback function that is triggered when the input gains focus. **(Only to be used if the input has no children)** |
|
|
102
106
|
| placeholder | `string` | `-` | The placeholder text for the input. **(Only to be used if the input has no children)** |
|
|
@@ -113,7 +117,7 @@ The `InputField` inherits all of the React Native [`TextInput` props](https://re
|
|
|
113
117
|
| ------------- | ---------------------- | -------- | ----------------------------------------------------------------- |
|
|
114
118
|
| type | `'text' \| 'password'` | `'text'` | The type of the input. |
|
|
115
119
|
| value | `string` | `-` | The value of the input. |
|
|
116
|
-
|
|
|
120
|
+
| onChangeText | `function` | `-` | Callback function that is triggered when the input value changes. |
|
|
117
121
|
| onBlur | `function` | `-` | Callback function that is triggered when the input loses focus. |
|
|
118
122
|
| onFocus | `function` | `-` | Callback function that is triggered when the input gains focus. |
|
|
119
123
|
| placeholder | `string` | `-` | The placeholder text for the input. |
|
|
@@ -156,13 +160,12 @@ import {
|
|
|
156
160
|
EyeOffMediumIcon,
|
|
157
161
|
} from '@utilitywarehouse/hearth-react-native-icons';
|
|
158
162
|
import { useState } from 'react';
|
|
159
|
-
import { NativeSyntheticEvent, TextInputChangeEventData } from 'react-native';
|
|
160
163
|
|
|
161
164
|
const AdvancedExample = () => {
|
|
162
165
|
const [value, setValue] = useState<string>('');
|
|
163
166
|
const [fieldType, setFieldType] = useState<'password' | 'text'>('password');
|
|
164
|
-
const handleChange = (
|
|
165
|
-
setValue(
|
|
167
|
+
const handleChange = (text: string) => {
|
|
168
|
+
setValue(text);
|
|
166
169
|
};
|
|
167
170
|
const handleToggleFieldType = () => {
|
|
168
171
|
setFieldType(fieldType === 'password' ? 'text' : 'password');
|
|
@@ -173,7 +176,7 @@ const AdvancedExample = () => {
|
|
|
173
176
|
<InputIcon as={EmailMediumIcon} />
|
|
174
177
|
</InputSlot>
|
|
175
178
|
<InputField
|
|
176
|
-
|
|
179
|
+
onChangeText={handleChange}
|
|
177
180
|
type={fieldType}
|
|
178
181
|
value={value}
|
|
179
182
|
placeholder="Secret email address"
|
|
@@ -207,7 +210,7 @@ The `Input` component can be used with a label and helper text by passing the `l
|
|
|
207
210
|
<Input
|
|
208
211
|
label="Label"
|
|
209
212
|
helperText="Helper text"
|
|
210
|
-
|
|
213
|
+
onChangeText={() => console.log('###')}
|
|
211
214
|
placeholder="Placeholder"
|
|
212
215
|
/>
|
|
213
216
|
</Center>
|
|
@@ -218,14 +221,14 @@ import { Input } from '@utilitywarehouse/hearth-react-native';
|
|
|
218
221
|
|
|
219
222
|
const MyComponent = () => {
|
|
220
223
|
const [value, setValue] = useState('');
|
|
221
|
-
const handleChange =
|
|
222
|
-
setValue(
|
|
224
|
+
const handleChange = text => {
|
|
225
|
+
setValue(text);
|
|
223
226
|
};
|
|
224
227
|
return (
|
|
225
228
|
<Input
|
|
226
229
|
label="Label"
|
|
227
230
|
helperText="Helper text"
|
|
228
|
-
|
|
231
|
+
onChangeText={handleChange}
|
|
229
232
|
value={value}
|
|
230
233
|
placeholder="Placeholder"
|
|
231
234
|
/>
|
|
@@ -233,6 +236,43 @@ const MyComponent = () => {
|
|
|
233
236
|
};
|
|
234
237
|
```
|
|
235
238
|
|
|
239
|
+
## With `prefix` and `suffix`
|
|
240
|
+
|
|
241
|
+
The `Input` component can be customised with `prefix` and `suffix` props to add content before or after the input field.
|
|
242
|
+
|
|
243
|
+
<UsageWrap>
|
|
244
|
+
<Center>
|
|
245
|
+
<Input
|
|
246
|
+
label="Amount"
|
|
247
|
+
prefix="£"
|
|
248
|
+
suffix="GBP"
|
|
249
|
+
onChangeText={() => console.log('###')}
|
|
250
|
+
placeholder="0.00"
|
|
251
|
+
/>
|
|
252
|
+
</Center>
|
|
253
|
+
</UsageWrap>
|
|
254
|
+
|
|
255
|
+
```tsx
|
|
256
|
+
import { Input } from '@utilitywarehouse/hearth-react-native';
|
|
257
|
+
|
|
258
|
+
const MyComponent = () => {
|
|
259
|
+
const [value, setValue] = useState('');
|
|
260
|
+
const handleChange = text => {
|
|
261
|
+
setValue(text);
|
|
262
|
+
};
|
|
263
|
+
return (
|
|
264
|
+
<Input
|
|
265
|
+
label="Amount"
|
|
266
|
+
prefix="£"
|
|
267
|
+
suffix="GBP"
|
|
268
|
+
onChangeText={handleChange}
|
|
269
|
+
value={value}
|
|
270
|
+
placeholder="0.00"
|
|
271
|
+
/>
|
|
272
|
+
);
|
|
273
|
+
};
|
|
274
|
+
```
|
|
275
|
+
|
|
236
276
|
### With `FormField`
|
|
237
277
|
|
|
238
278
|
The `Input` component can be used with the `FormField` component to create a custom input field.
|
|
@@ -241,7 +281,7 @@ For more information on the `FormField` componment view the [docs here](/docs/co
|
|
|
241
281
|
<UsageWrap>
|
|
242
282
|
<Center>
|
|
243
283
|
<FormField label="Label" helperText="Helper text" helperPosition="bottom">
|
|
244
|
-
<Input
|
|
284
|
+
<Input onChangeText={() => console.log('###')} placeholder="Placeholder" />
|
|
245
285
|
</FormField>
|
|
246
286
|
</Center>
|
|
247
287
|
</UsageWrap>
|
|
@@ -251,12 +291,12 @@ import { FormField, Input } from '@utilitywarehouse/hearth-react-native';
|
|
|
251
291
|
|
|
252
292
|
const MyComponent = () => {
|
|
253
293
|
const [value, setValue] = useState('');
|
|
254
|
-
const handleChange =
|
|
255
|
-
setValue(
|
|
294
|
+
const handleChange = text => {
|
|
295
|
+
setValue(text);
|
|
256
296
|
};
|
|
257
297
|
return (
|
|
258
298
|
<FormField label="Label" helperText="Helper text" helperPosition="bottom">
|
|
259
|
-
<Input
|
|
299
|
+
<Input onChangeText={handleChange} value={value} placeholder="Placeholder" />
|
|
260
300
|
</FormField>
|
|
261
301
|
);
|
|
262
302
|
};
|