@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createInput } from '@gluestack-ui/input';
|
|
2
|
-
import { ComponentType, forwardRef, useImperativeHandle, useRef, useState } from 'react';
|
|
2
|
+
import { ComponentType, forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
3
3
|
import { TextInput } from 'react-native';
|
|
4
4
|
import type InputProps from './Input.props';
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
SearchMediumIcon,
|
|
11
11
|
} from '@utilitywarehouse/hearth-react-native-icons';
|
|
12
12
|
import { useTheme } from '../../hooks';
|
|
13
|
-
import { useFormFieldContext } from '../FormField';
|
|
13
|
+
import { FormField, useFormFieldContext } from '../FormField';
|
|
14
14
|
import { Spinner } from '../Spinner';
|
|
15
15
|
import { UnstyledIconButton } from '../UnstyledIconButton';
|
|
16
16
|
import { InputWithoutChildrenProps } from './Input.props';
|
|
@@ -43,20 +43,37 @@ const Input = forwardRef<TextInput, InputProps>(
|
|
|
43
43
|
type,
|
|
44
44
|
showPasswordToggle = true,
|
|
45
45
|
onClear,
|
|
46
|
-
format,
|
|
47
46
|
loading,
|
|
48
47
|
clearable = false,
|
|
49
|
-
required,
|
|
48
|
+
required = true,
|
|
50
49
|
inBottomSheet = false,
|
|
51
50
|
style,
|
|
51
|
+
label,
|
|
52
|
+
labelVariant,
|
|
53
|
+
helperText,
|
|
54
|
+
helperIcon,
|
|
55
|
+
validText,
|
|
56
|
+
invalidText,
|
|
52
57
|
...props
|
|
53
58
|
},
|
|
54
59
|
ref
|
|
55
60
|
) => {
|
|
56
61
|
const formFieldContext = useFormFieldContext();
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
62
|
+
const inputLabel = label ?? formFieldContext?.label;
|
|
63
|
+
const inputHelperText = helperText ?? formFieldContext?.helperText;
|
|
64
|
+
const inputValidText = validText ?? formFieldContext?.validText;
|
|
65
|
+
const inputInvalidText = invalidText ?? formFieldContext?.invalidText;
|
|
66
|
+
const inputRequired = required ?? formFieldContext?.required;
|
|
67
|
+
const inputDisabled = disabled ?? formFieldContext?.disabled;
|
|
68
|
+
const inputReadonly = readonly ?? formFieldContext?.readonly;
|
|
69
|
+
const inputValidationStatus = formFieldContext?.validationStatus ?? validationStatus;
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (formFieldContext?.setShouldHandleAccessibility) {
|
|
73
|
+
formFieldContext.setShouldHandleAccessibility(true);
|
|
74
|
+
}
|
|
75
|
+
}, []);
|
|
76
|
+
|
|
60
77
|
const [fieldType, setFieldType] = useState<'password' | 'text'>(
|
|
61
78
|
type === 'password' ? 'password' : 'text'
|
|
62
79
|
);
|
|
@@ -87,61 +104,108 @@ const Input = forwardRef<TextInput, InputProps>(
|
|
|
87
104
|
return undefined;
|
|
88
105
|
})();
|
|
89
106
|
|
|
107
|
+
const getAccessibilityLabel = () => {
|
|
108
|
+
let accessibilityLabel = '';
|
|
109
|
+
if (inputLabel) {
|
|
110
|
+
accessibilityLabel = accessibilityLabel + inputLabel;
|
|
111
|
+
}
|
|
112
|
+
if (inputRequired) {
|
|
113
|
+
accessibilityLabel = accessibilityLabel + ', required';
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return accessibilityLabel || props.accessibilityLabel;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const getAccessibilityHint = () => {
|
|
120
|
+
let accessibilityHint = '';
|
|
121
|
+
if (inputHelperText) {
|
|
122
|
+
accessibilityHint = accessibilityHint + inputHelperText;
|
|
123
|
+
}
|
|
124
|
+
if (inputValidationStatus !== 'initial') {
|
|
125
|
+
if (accessibilityHint.length > 0) {
|
|
126
|
+
accessibilityHint = accessibilityHint + ', ';
|
|
127
|
+
}
|
|
128
|
+
if (inputValidationStatus === 'invalid' && inputInvalidText) {
|
|
129
|
+
accessibilityHint = accessibilityHint + inputInvalidText;
|
|
130
|
+
}
|
|
131
|
+
if (inputValidationStatus === 'valid' && inputValidText) {
|
|
132
|
+
accessibilityHint = accessibilityHint + inputValidText;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return accessibilityHint || props.accessibilityHint;
|
|
136
|
+
};
|
|
137
|
+
|
|
90
138
|
return (
|
|
91
|
-
<
|
|
92
|
-
{
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
139
|
+
<FormField
|
|
140
|
+
label={label}
|
|
141
|
+
labelVariant={labelVariant}
|
|
142
|
+
helperText={helperText}
|
|
143
|
+
helperIcon={helperIcon}
|
|
144
|
+
validText={validText}
|
|
145
|
+
invalidText={invalidText}
|
|
146
|
+
required={required}
|
|
147
|
+
validationStatus={validationStatus}
|
|
148
|
+
disabled={disabled}
|
|
149
|
+
readonly={readonly}
|
|
150
|
+
accessibilityHandledByChildren
|
|
101
151
|
>
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
152
|
+
<InputComponent
|
|
153
|
+
{...(children ? props : {})}
|
|
154
|
+
validationStatus={inputValidationStatus}
|
|
155
|
+
isInvalid={inputValidationStatus === 'invalid'}
|
|
156
|
+
isReadOnly={inputReadonly}
|
|
157
|
+
isDisabled={inputDisabled}
|
|
158
|
+
isFocused={focused}
|
|
159
|
+
type={type as undefined}
|
|
160
|
+
isRequired={inputRequired}
|
|
161
|
+
style={style}
|
|
162
|
+
>
|
|
163
|
+
{children ? (
|
|
164
|
+
<>{children}</>
|
|
165
|
+
) : (
|
|
166
|
+
<>
|
|
167
|
+
{!!leadingIconComponent && (
|
|
168
|
+
<InputSlot>
|
|
169
|
+
<InputIcon as={leadingIconComponent} />
|
|
170
|
+
</InputSlot>
|
|
171
|
+
)}
|
|
172
|
+
<InputField
|
|
173
|
+
// @ts-expect-error - ref forwarding issue
|
|
174
|
+
ref={inputRef}
|
|
175
|
+
type={fieldType}
|
|
176
|
+
inputMode={getInputMode}
|
|
177
|
+
inBottomSheet={inBottomSheet}
|
|
178
|
+
{...props}
|
|
179
|
+
aria-label={getAccessibilityLabel()}
|
|
180
|
+
accessibilityHint={getAccessibilityHint()}
|
|
181
|
+
/>
|
|
182
|
+
{shouldShowClear && (
|
|
183
|
+
<InputSlot>
|
|
184
|
+
<UnstyledIconButton onPress={onClear} icon={CloseSmallIcon} />
|
|
185
|
+
</InputSlot>
|
|
186
|
+
)}
|
|
187
|
+
{loading && (
|
|
188
|
+
<InputSlot>
|
|
189
|
+
<Spinner size="xs" color={color.icon.primary} />
|
|
190
|
+
</InputSlot>
|
|
191
|
+
)}
|
|
192
|
+
{shouldShowPasswordToggle && (
|
|
193
|
+
<InputSlot>
|
|
194
|
+
<UnstyledIconButton
|
|
195
|
+
onPress={toggleFieldType}
|
|
196
|
+
icon={fieldType === 'password' ? EyeSmallIcon : EyeOffSmallIcon}
|
|
197
|
+
/>
|
|
198
|
+
</InputSlot>
|
|
199
|
+
)}
|
|
200
|
+
{!!trailingIcon && (
|
|
201
|
+
<InputSlot>
|
|
202
|
+
<InputIcon as={trailingIcon} />
|
|
203
|
+
</InputSlot>
|
|
204
|
+
)}
|
|
205
|
+
</>
|
|
206
|
+
)}
|
|
207
|
+
</InputComponent>
|
|
208
|
+
</FormField>
|
|
145
209
|
);
|
|
146
210
|
}
|
|
147
211
|
);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BodyTextProps } from '../BodyText';
|
|
2
2
|
|
|
3
|
-
interface LabelProps extends
|
|
3
|
+
interface LabelProps extends Omit<BodyTextProps, 'size' | 'weight'> {
|
|
4
4
|
nested?: boolean;
|
|
5
5
|
disabled?: boolean;
|
|
6
|
+
variant?: 'heading' | 'body';
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
export default LabelProps;
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
2
|
import { BodyText } from '../BodyText';
|
|
3
|
+
import { Heading } from '../Heading';
|
|
3
4
|
import LabelProps from './Label.props';
|
|
4
5
|
|
|
5
|
-
const Label = ({ children, nested, disabled, style, ...props }: LabelProps) => {
|
|
6
|
+
const Label = ({ children, nested, disabled, style, variant = 'body', ...props }: LabelProps) => {
|
|
6
7
|
styles.useVariants({ disabled });
|
|
8
|
+
|
|
9
|
+
if (variant === 'heading') {
|
|
10
|
+
return (
|
|
11
|
+
<Heading size="md" style={[styles.text, style]} {...props}>
|
|
12
|
+
{children}
|
|
13
|
+
</Heading>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
7
17
|
return (
|
|
8
18
|
<BodyText
|
|
9
19
|
size="md"
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
SettingsMediumIcon,
|
|
10
10
|
UserMediumIcon,
|
|
11
11
|
} from '@utilitywarehouse/hearth-react-native-icons';
|
|
12
|
-
import {
|
|
12
|
+
import { useState } from 'react';
|
|
13
13
|
import { List, ListAction, ListItem, ListItemIcon, ListItemTrailingIcon } from '.';
|
|
14
14
|
import { VariantTitle } from '../../../docs/components';
|
|
15
15
|
import { Badge } from '../Badge';
|
|
@@ -18,9 +18,6 @@ import { Flex } from '../Flex';
|
|
|
18
18
|
import { IconContainer } from '../IconContainer';
|
|
19
19
|
import { Link } from '../Link';
|
|
20
20
|
import { Switch } from '../Switch';
|
|
21
|
-
// import { Card } from '../Card';
|
|
22
|
-
|
|
23
|
-
const Card: FC<PropsWithChildren> = ({ children }) => <div>{children}</div>;
|
|
24
21
|
|
|
25
22
|
const meta = {
|
|
26
23
|
title: 'Stories / List',
|
|
@@ -90,21 +90,21 @@ const MyComponent = () => {
|
|
|
90
90
|
|
|
91
91
|
## Props
|
|
92
92
|
|
|
93
|
-
| Property | Type | Default
|
|
94
|
-
| -------------------- | ----------------------------------- |
|
|
95
|
-
| `value` | string | -
|
|
96
|
-
| `onChange` | function | -
|
|
97
|
-
| `disabled` | bool | false
|
|
98
|
-
| `validationStatus` | `'valid' \| 'invalid' \| 'initial'` | -
|
|
99
|
-
| `disabled` | `bool` | `false`
|
|
100
|
-
| `label` | `string` | -
|
|
101
|
-
| `helperText` | `string` | -
|
|
102
|
-
| `helperIcon` | `React.ComponentType` | -
|
|
103
|
-
| `invalidText` | `string` | -
|
|
104
|
-
| `validText` | `string` | -
|
|
105
|
-
| `showValidationIcon` | `boolean` | `true`
|
|
106
|
-
| `type` | `'default' \| 'tile'` | `default` | The type of the radio. |
|
|
107
|
-
| `image` | `ReactNode` | -
|
|
93
|
+
| Property | Type | Default | Description |
|
|
94
|
+
| -------------------- | ----------------------------------- | ----------- | ---------------------------------------------------------------------------------------------------- |
|
|
95
|
+
| `value` | string | - | The value to be used in the radio input. This is the value that will be returned on form submission. |
|
|
96
|
+
| `onChange` | function | - | Function called when the state of the radio changes. |
|
|
97
|
+
| `disabled` | bool | false | To manually set disable to the radio. |
|
|
98
|
+
| `validationStatus` | `'valid' \| 'invalid' \| 'initial'` | - | The validation status of the radio. |
|
|
99
|
+
| `disabled` | `bool` | `false` | To manually set disable to the radio. |
|
|
100
|
+
| `label` | `string` | - | The label to be displayed next to the radio. |
|
|
101
|
+
| `helperText` | `string` | - | The helper text to be displayed below the radio. |
|
|
102
|
+
| `helperIcon` | `React.ComponentType` | - | The icon to be displayed next to the helper text. |
|
|
103
|
+
| `invalidText` | `string` | - | The invalid text to be displayed below the radio. |
|
|
104
|
+
| `validText` | `string` | - | The valid text to be displayed below the radio. |
|
|
105
|
+
| `showValidationIcon` | `boolean` | `true` | Whether to show the validation icon. |
|
|
106
|
+
| `type` | `'default' \| 'tile'` | `'default'` | The type of the radio. |
|
|
107
|
+
| `image` | `ReactNode` | - | The image to be displayed next to the label. |
|
|
108
108
|
|
|
109
109
|
## Components
|
|
110
110
|
|
|
@@ -132,21 +132,22 @@ Contains all Label related layout style props and actions. It inherits all the p
|
|
|
132
132
|
|
|
133
133
|
Contains all Group related layout style props and actions. It inherits all the properties of React Native's [View component](https://reactnative.dev/docs/view).
|
|
134
134
|
|
|
135
|
-
| Property | Type | Default
|
|
136
|
-
| -------------------- | ----------------------------------- |
|
|
137
|
-
| `value` | string | -
|
|
138
|
-
| `onChange` | function | -
|
|
139
|
-
| `disabled` | bool | -
|
|
140
|
-
| `validationStatus` | `'valid' \| 'invalid' \| 'initial'` | -
|
|
141
|
-
| `label` | `string` | -
|
|
142
|
-
| `
|
|
143
|
-
| `
|
|
144
|
-
| `
|
|
145
|
-
| `
|
|
146
|
-
| `
|
|
147
|
-
| `
|
|
148
|
-
| `
|
|
149
|
-
| `
|
|
135
|
+
| Property | Type | Default | Description |
|
|
136
|
+
| -------------------- | ----------------------------------- | ----------- | ------------------------------------------------------------------- |
|
|
137
|
+
| `value` | string | - | The value of the radio group. |
|
|
138
|
+
| `onChange` | function | - | The callback fired when any children Radio is checked or unchecked. |
|
|
139
|
+
| `disabled` | bool | - | To manually set disable to the radio group. |
|
|
140
|
+
| `validationStatus` | `'valid' \| 'invalid' \| 'initial'` | - | The validation status of the radio group. |
|
|
141
|
+
| `label` | `string` | - | The label to be displayed above the radio group. |
|
|
142
|
+
| `labelVariant` | `'heading' \| 'body'` | `'body'` | The variant of the label text. |
|
|
143
|
+
| `helperText` | `string` | - | The helper text to be displayed below the radio group. |
|
|
144
|
+
| `helperIcon` | `React.ComponentType` | - | The icon to be displayed next to the helper text. |
|
|
145
|
+
| `invalidText` | `string` | - | The invalid text to be displayed below the radio group. |
|
|
146
|
+
| `validText` | `string` | - | The valid text to be displayed below the radio group. |
|
|
147
|
+
| `showValidationIcon` | `boolean` | `true` | Whether to show the validation icon. |
|
|
148
|
+
| `type` | `'default' \| 'tile'` | `'default'` | The type of the radio group. |
|
|
149
|
+
| `direction` | `'row' \| 'column'` | `'column'` | The direction of the radio group. |
|
|
150
|
+
| `gap` | `string` | - | The gap between the radio group items. |
|
|
150
151
|
|
|
151
152
|
### `RadioImage`
|
|
152
153
|
|
|
@@ -19,6 +19,11 @@ const meta = {
|
|
|
19
19
|
control: 'text',
|
|
20
20
|
description: 'The label component for the radio group.',
|
|
21
21
|
},
|
|
22
|
+
labelVariant: {
|
|
23
|
+
control: 'radio',
|
|
24
|
+
options: ['heading', 'body'],
|
|
25
|
+
description: 'The variant of the label text.',
|
|
26
|
+
},
|
|
22
27
|
helperText: {
|
|
23
28
|
type: 'string',
|
|
24
29
|
control: 'text',
|
|
@@ -51,6 +56,7 @@ const meta = {
|
|
|
51
56
|
args: {
|
|
52
57
|
disabled: false,
|
|
53
58
|
label: 'Group label',
|
|
59
|
+
labelVariant: 'body',
|
|
54
60
|
helperText: 'Supporting text',
|
|
55
61
|
validationStatus: 'initial',
|
|
56
62
|
showValidationIcon: true,
|
|
@@ -14,6 +14,7 @@ const RadioGroup = ({
|
|
|
14
14
|
readonly,
|
|
15
15
|
validationStatus,
|
|
16
16
|
label,
|
|
17
|
+
labelVariant = 'body',
|
|
17
18
|
helperText,
|
|
18
19
|
invalidText,
|
|
19
20
|
validText,
|
|
@@ -49,7 +50,11 @@ const RadioGroup = ({
|
|
|
49
50
|
>
|
|
50
51
|
{showHeader && (
|
|
51
52
|
<RadioGroupTextContent>
|
|
52
|
-
{!!label &&
|
|
53
|
+
{!!label && (
|
|
54
|
+
<Label disabled={disabled} variant={labelVariant}>
|
|
55
|
+
{label}
|
|
56
|
+
</Label>
|
|
57
|
+
)}
|
|
53
58
|
{!!helperText && <Helper disabled={disabled} icon={helperIcon} text={helperText} />}
|
|
54
59
|
{validationStatus === 'invalid' && !!invalidText && (
|
|
55
60
|
<Helper
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Canvas, Controls, Meta, Story } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import { TickSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
3
3
|
import {
|
|
4
|
-
RadioCard,
|
|
5
|
-
RadioCardGroup,
|
|
6
|
-
Center,
|
|
7
|
-
Box,
|
|
8
|
-
Heading,
|
|
9
4
|
BodyText,
|
|
5
|
+
Box,
|
|
6
|
+
Center,
|
|
10
7
|
DetailText,
|
|
11
|
-
|
|
8
|
+
Heading,
|
|
12
9
|
LI,
|
|
10
|
+
RadioCard,
|
|
11
|
+
RadioCardGroup,
|
|
12
|
+
UL,
|
|
13
13
|
} from '../..';
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
14
|
+
import { BackToTopButton, UsageWrap, ViewFigmaButton } from '../../../docs/components';
|
|
15
|
+
import * as Stories from './RadioCardGroup.stories';
|
|
16
16
|
|
|
17
17
|
<Meta title="Components / Radio Card" />
|
|
18
18
|
|
|
@@ -92,16 +92,17 @@ const MyComponent = () => {
|
|
|
92
92
|
|
|
93
93
|
The `RadioCard` component accepts the following props:
|
|
94
94
|
|
|
95
|
-
| Property | Type | Default
|
|
96
|
-
| ---------------- | ------------------------------------------------------------------------------------------------------- |
|
|
97
|
-
| `value` | string | -
|
|
98
|
-
| `onChange` | `(isSelected: boolean) => void` | -
|
|
99
|
-
| `children` | `React.ReactNode` | -
|
|
100
|
-
| `label` | `string` | -
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
95
|
+
| Property | Type | Default | Description |
|
|
96
|
+
| ---------------- | ------------------------------------------------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------- |
|
|
97
|
+
| `value` | string | - | The value to be used in the radio card input. This is the value that will be returned on form submission. |
|
|
98
|
+
| `onChange` | `(isSelected: boolean) => void` | - | Function called when the state of the radio card changes. |
|
|
99
|
+
| `children` | `React.ReactNode` | - | The content to be displayed inside the radio card. |
|
|
100
|
+
| `label` | `string` | - | The label to be displayed next to the radio card. |
|
|
101
|
+
| `labelVariant` | `'heading' \| 'body'` | `'body'` | The variant of the label text. |
|
|
102
|
+
| `flexDirection` | `'row' \| 'column' \| 'row-reverse' \| 'column-reverse'` | - | Sets the direction of the flex items. |
|
|
103
|
+
| `flexWrap` | `'wrap' \| 'nowrap' \| 'wrap-reverse'` | - | Sets whether flex items are forced onto one line or can wrap. |
|
|
104
|
+
| `alignItems` | `'flex-start' \| 'flex-end' \| 'center' \|`<br />` 'stretch' \| 'baseline'` | - | Sets the alignment of flex items on the cross axis. |
|
|
105
|
+
| `justifyContent` | `'flex-start' \| 'flex-end' \| 'center' \|`<br />` 'space-between' \| 'space-around' \| 'space-evenly'` | - | Sets the alignment of flex items on the main axis. |
|
|
105
106
|
|
|
106
107
|
## Components
|
|
107
108
|
|
|
@@ -113,13 +114,13 @@ Contains all RadioCard related layout style props and actions. It inherits all t
|
|
|
113
114
|
|
|
114
115
|
Contains all Group related layout style props and actions. It inherits all the properties of React Native's [View component](https://reactnative.dev/docs/view).
|
|
115
116
|
|
|
116
|
-
| Property | Type | Default
|
|
117
|
-
| ---------------- | -------------------------------------------------------------------------------------------------------- |
|
|
118
|
-
| `value` | `string` | -
|
|
119
|
-
| `onChange` | `(value: string) => void` | -
|
|
120
|
-
| `gap` | `keyof typeof space` | -
|
|
121
|
-
| `columns` | `GridProps['columns']` | -
|
|
122
|
-
| `flexDirection` | `'row' \| 'column' \| 'row-reverse' \| 'column-reverse'` | `row`
|
|
123
|
-
| `flexWrap` | `'wrap' \| 'nowrap' \| 'wrap-reverse'` | `wrap`
|
|
124
|
-
| `alignItems` | `'flex-start' \| 'flex-end' \| 'center' \| `<br />`'stretch' \| 'baseline'` | -
|
|
125
|
-
| `justifyContent` | `'flex-start' \| 'flex-end' \| 'center' \| `<br /> `'space-between' \| 'space-around' \| 'space-evenly'` | -
|
|
117
|
+
| Property | Type | Default | Description |
|
|
118
|
+
| ---------------- | -------------------------------------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------- |
|
|
119
|
+
| `value` | `string` | - | The value of the currently selected `RadioCard`. |
|
|
120
|
+
| `onChange` | `(value: string) => void` | - | Callback fired when the selected `RadioCard` changes. |
|
|
121
|
+
| `gap` | `keyof typeof space` | - | The gap between the `RadioCard` items. |
|
|
122
|
+
| `columns` | `GridProps['columns']` | - | If set, the group will use a grid layout with the specified number of columns. Otherwise, it uses flexbox. |
|
|
123
|
+
| `flexDirection` | `'row' \| 'column' \| 'row-reverse' \| 'column-reverse'` | `'row'` | (Flexbox only) Sets the direction of the flex items. |
|
|
124
|
+
| `flexWrap` | `'wrap' \| 'nowrap' \| 'wrap-reverse'` | `'wrap'` | (Flexbox only) Sets whether flex items are forced onto one line or can wrap. |
|
|
125
|
+
| `alignItems` | `'flex-start' \| 'flex-end' \| 'center' \| `<br />`'stretch' \| 'baseline'` | - | (Flexbox only) Sets the alignment of flex items on the cross axis. |
|
|
126
|
+
| `justifyContent` | `'flex-start' \| 'flex-end' \| 'center' \| `<br /> `'space-between' \| 'space-around' \| 'space-evenly'` | - | (Flexbox only) Sets the alignment of flex items on the main axis. |
|
|
@@ -7,6 +7,7 @@ interface RadioCardProps extends Omit<PressableProps, 'children'> {
|
|
|
7
7
|
onChange?: (isSelected: boolean) => void;
|
|
8
8
|
children?: ViewProps['children'];
|
|
9
9
|
label?: string;
|
|
10
|
+
labelVariant?: 'heading' | 'body';
|
|
10
11
|
flexDirection?: ViewStyle['flexDirection'];
|
|
11
12
|
flexWrap?: ViewStyle['flexWrap'];
|
|
12
13
|
alignItems?: ViewStyle['alignItems'];
|
|
@@ -27,7 +27,13 @@ RadioCardIndicator.displayName = 'RadioCardIndicator';
|
|
|
27
27
|
RadioCardIcon.displayName = 'RadioCardIcon';
|
|
28
28
|
RadioCardLabel.displayName = 'RadioCardLabel';
|
|
29
29
|
|
|
30
|
-
const RadioCard = ({
|
|
30
|
+
const RadioCard = ({
|
|
31
|
+
children,
|
|
32
|
+
label,
|
|
33
|
+
labelVariant = 'body',
|
|
34
|
+
contentStyle,
|
|
35
|
+
...props
|
|
36
|
+
}: RadioCardProps) => {
|
|
31
37
|
const { computedStyles } = useStyleProps(props);
|
|
32
38
|
return (
|
|
33
39
|
<RadioCardComponent {...props}>
|
|
@@ -35,7 +41,7 @@ const RadioCard = ({ children, label, contentStyle, ...props }: RadioCardProps)
|
|
|
35
41
|
<RadioCardIndicator>
|
|
36
42
|
<RadioCardIcon />
|
|
37
43
|
</RadioCardIndicator>
|
|
38
|
-
{!!label && <RadioCardLabel>{label}</RadioCardLabel>}
|
|
44
|
+
{!!label && <RadioCardLabel variant={labelVariant}>{label}</RadioCardLabel>}
|
|
39
45
|
</View>
|
|
40
46
|
{!!children && <View style={[computedStyles, contentStyle]}>{children}</View>}
|
|
41
47
|
</RadioCardComponent>
|
|
@@ -43,6 +43,16 @@ interface SelectProps extends ViewProps {
|
|
|
43
43
|
* Label for the select
|
|
44
44
|
*/
|
|
45
45
|
label?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The variant of the label text.
|
|
48
|
+
*
|
|
49
|
+
* Supported values are:
|
|
50
|
+
* - `'heading'` – use heading text styling for the label.
|
|
51
|
+
* - `'body'` – use body text styling for the label.
|
|
52
|
+
*
|
|
53
|
+
* @default 'body'.
|
|
54
|
+
*/
|
|
55
|
+
labelVariant?: 'heading' | 'body';
|
|
46
56
|
/**
|
|
47
57
|
* Placeholder text to show when no value is selected
|
|
48
58
|
*/
|
|
@@ -23,6 +23,7 @@ const Select = ({
|
|
|
23
23
|
value,
|
|
24
24
|
onValueChange,
|
|
25
25
|
label,
|
|
26
|
+
labelVariant = 'body',
|
|
26
27
|
placeholder = 'Select an option',
|
|
27
28
|
disabled = false,
|
|
28
29
|
leadingIcon: LeadingIcon,
|
|
@@ -123,9 +124,9 @@ const Select = ({
|
|
|
123
124
|
<View {...rest} style={[styles.container, rest.style]}>
|
|
124
125
|
{!!label && (
|
|
125
126
|
<View>
|
|
126
|
-
<Label>
|
|
127
|
+
<Label variant={labelVariant}>
|
|
127
128
|
{label}
|
|
128
|
-
{!isRequired && <Label> (Optional)</Label>}
|
|
129
|
+
{!isRequired && <Label variant={labelVariant}> (Optional)</Label>}
|
|
129
130
|
</Label>
|
|
130
131
|
</View>
|
|
131
132
|
)}
|
|
@@ -23,7 +23,7 @@ const CustomSwitch = ({
|
|
|
23
23
|
size = 'medium',
|
|
24
24
|
...accessibilityProps
|
|
25
25
|
}: SwitchProps) => {
|
|
26
|
-
const { components
|
|
26
|
+
const { components } = useTheme();
|
|
27
27
|
const theme = useAnimatedTheme();
|
|
28
28
|
const SWITCH_WIDTH = size === 'medium' ? components.switch.md.width : components.switch.sm.width;
|
|
29
29
|
const THUMB_SIZE =
|