@utilitywarehouse/hearth-react-native 0.12.0 → 0.14.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 +1 -1
- package/CHANGELOG.md +22 -0
- package/build/components/Accordion/AccordionTrigger.js +1 -1
- package/build/components/BodyText/index.d.ts +1 -0
- package/build/components/Checkbox/CheckboxGroup.context.d.ts +2 -0
- package/build/components/Checkbox/CheckboxGroup.js +5 -5
- package/build/components/Checkbox/CheckboxIndicator.js +3 -3
- package/build/components/Checkbox/CheckboxTextContent.js +0 -1
- package/build/components/Checkbox/CheckboxTileRoot.js +9 -1
- package/build/components/DatePicker/DatePickerDay.js +3 -3
- package/build/components/FormField/FormField.d.ts +5 -5
- package/build/components/List/List.context.d.ts +2 -0
- package/build/components/List/List.context.js +2 -0
- package/build/components/List/List.js +19 -15
- package/build/components/List/ListAction/ListAction.js +3 -2
- package/build/components/List/ListAction/ListAction.props.d.ts +0 -1
- package/build/components/List/ListItem/ListItem.props.d.ts +4 -1
- package/build/components/List/ListItem/ListItemHeading.d.ts +13 -0
- package/build/components/List/ListItem/ListItemHeading.js +12 -0
- package/build/components/List/ListItem/ListItemHelperText.d.ts +2 -2
- package/build/components/List/ListItem/ListItemRoot.d.ts +1 -1
- package/build/components/List/ListItem/ListItemRoot.js +7 -6
- package/build/components/List/ListItem/index.d.ts +1 -1
- package/build/components/List/ListItem/index.js +1 -1
- package/build/components/PillGroup/Pill.js +2 -2
- package/build/components/Radio/RadioGroup.context.d.ts +2 -0
- package/build/components/Radio/RadioGroup.js +1 -1
- package/build/components/Radio/RadioIndicator.js +3 -3
- package/build/components/Radio/RadioTextContent.js +0 -1
- package/build/components/Radio/RadioTileRoot.js +9 -1
- package/build/components/RadioCard/RadioCardIndicator.js +3 -3
- package/build/components/RadioCard/RadioCardRoot.js +3 -3
- package/build/components/Tabs/Tab.js +5 -5
- package/build/components/ToggleButton/ToggleButtonRoot.js +2 -2
- package/build/components/ToggleButtonCard/ToggleButtonCardRoot.js +3 -3
- package/build/components/UnstyledIconButton/UnstyledIconButtonRoot.js +1 -1
- package/build/components/VerificationInput/VerificationInput.d.ts +6 -0
- package/build/components/VerificationInput/VerificationInput.js +35 -0
- package/build/components/VerificationInput/VerificationInput.props.d.ts +49 -0
- package/build/components/VerificationInput/VerificationInput.props.js +1 -0
- package/build/components/VerificationInput/VerificationInputSlot.d.ts +9 -0
- package/build/components/VerificationInput/VerificationInputSlot.js +72 -0
- package/build/components/VerificationInput/index.d.ts +4 -0
- package/build/components/VerificationInput/index.js +3 -0
- package/build/components/VerificationInput/useVerificationInput.d.ts +14 -0
- package/build/components/VerificationInput/useVerificationInput.js +58 -0
- package/build/components/index.d.ts +1 -0
- package/build/components/index.js +1 -0
- package/docs/components/AllComponents.web.tsx +9 -0
- package/package.json +10 -11
- package/src/components/Accordion/Accordion.figma.tsx +23 -0
- package/src/components/Accordion/AccordionItemRoot.figma.tsx +47 -0
- package/src/components/Accordion/AccordionTrigger.tsx +1 -1
- package/src/components/Alert/Alert.figma.tsx +47 -0
- package/src/components/Avatar/Avatar.figma.tsx +33 -0
- package/src/components/Badge/Badge.figma.tsx +48 -24
- package/src/components/Banner/Banner.figma.tsx +15 -0
- package/src/components/Banner/BannerIllustration.figma.tsx +30 -0
- package/src/components/BodyText/index.ts +1 -0
- package/src/components/BottomSheet/BottomSheetModal.figma.tsx +20 -0
- package/src/components/Button/Button.figma.tsx +60 -229
- package/src/components/Card/Card.figma.tsx +43 -71
- package/src/components/Card/CardAction/CardAction.figma.tsx +44 -0
- package/src/components/Card/CardAction/CardAction.stories.tsx +1 -1
- package/src/components/Carousel/Carousel.figma.tsx +19 -0
- package/src/components/Checkbox/Checkbox.figma.tsx +26 -41
- package/src/components/Checkbox/CheckboxGroup.context.ts +1 -0
- package/src/components/Checkbox/CheckboxGroup.figma.tsx +20 -0
- package/src/components/Checkbox/CheckboxGroup.tsx +7 -8
- package/src/components/Checkbox/CheckboxImage.figma.tsx +27 -0
- package/src/components/Checkbox/CheckboxIndicator.tsx +3 -3
- package/src/components/Checkbox/CheckboxTextContent.tsx +0 -1
- package/src/components/Checkbox/CheckboxTileRoot.figma.tsx +32 -0
- package/src/components/Checkbox/CheckboxTileRoot.tsx +9 -1
- package/src/components/CurrencyInput/CurrencyInput.figma.tsx +56 -0
- package/src/components/DateInput/DateInput.figma.tsx +75 -0
- package/src/components/DatePicker/DatePickerCalendar.figma.tsx +34 -0
- package/src/components/DatePicker/DatePickerDay.tsx +3 -3
- package/src/components/DatePickerInput/DatePickerInput.figma.tsx +62 -0
- package/src/components/DescriptionList/DescriptionList.figma.tsx +23 -0
- package/src/components/Divider/Divider.figma.tsx +23 -18
- package/src/components/ExpandableCard/ExpandableCard.figma.tsx +54 -0
- package/src/components/ExpandableCard/ExpandableCardGroup.figma.tsx +23 -0
- package/src/components/FormField/FormField.figma.tsx +23 -0
- package/src/components/Helper/HelperText.figma.tsx +23 -0
- package/src/components/IconButton/IconButton.figma.tsx +55 -161
- package/src/components/IconContainer/IconContainer.figma.tsx +50 -0
- package/src/components/InlineLink/InlineLink.figma.tsx +33 -0
- package/src/components/Input/Input.figma.tsx +52 -110
- package/src/components/Label/Label.figma.tsx +24 -0
- package/src/components/Link/Link.figma.tsx +42 -0
- package/src/components/List/List.context.ts +4 -0
- package/src/components/List/List.docs.mdx +30 -24
- package/src/components/List/List.figma.tsx +29 -108
- package/src/components/List/List.stories.tsx +26 -1
- package/src/components/List/List.tsx +26 -19
- package/src/components/List/ListAction/ListAction.figma.tsx +29 -0
- package/src/components/List/ListAction/ListAction.props.ts +0 -1
- package/src/components/List/ListAction/ListAction.tsx +3 -2
- package/src/components/List/ListItem/ListItem.figma.tsx +40 -220
- package/src/components/List/ListItem/ListItem.props.ts +4 -1
- package/src/components/List/ListItem/ListItemHeading.tsx +20 -0
- package/src/components/List/ListItem/ListItemHelperText.tsx +2 -3
- package/src/components/List/ListItem/ListItemLeadingContent.figma.tsx +29 -0
- package/src/components/List/ListItem/ListItemRoot.tsx +11 -6
- package/src/components/List/ListItem/ListItemTrailingContent.figma.tsx +27 -0
- package/src/components/List/ListItem/index.ts +1 -1
- package/src/components/Menu/Menu.figma.tsx +30 -0
- package/src/components/Menu/MenuItem.figma.tsx +31 -0
- package/src/components/Modal/Modal.docs.mdx +23 -20
- package/src/components/Modal/Modal.figma.tsx +56 -0
- package/src/components/PillGroup/Pill.figma.tsx +25 -0
- package/src/components/PillGroup/Pill.tsx +3 -3
- package/src/components/PillGroup/PillGroup.figma.tsx +21 -0
- package/src/components/ProgressStepper/ProgressStep.figma.tsx +30 -0
- package/src/components/ProgressStepper/ProgressStepper.figma.tsx +20 -0
- package/src/components/Radio/Radio.figma.tsx +22 -42
- package/src/components/Radio/Radio.stories.tsx +24 -0
- package/src/components/Radio/RadioGroup.context.ts +1 -0
- package/src/components/Radio/RadioGroup.figma.tsx +54 -0
- package/src/components/Radio/RadioGroup.tsx +2 -2
- package/src/components/Radio/RadioImage.figma.tsx +27 -0
- package/src/components/Radio/RadioIndicator.tsx +3 -3
- package/src/components/Radio/RadioTextContent.tsx +0 -1
- package/src/components/Radio/RadioTileRoot.figma.tsx +31 -0
- package/src/components/Radio/RadioTileRoot.tsx +9 -1
- package/src/components/RadioCard/RadioCardIndicator.tsx +3 -3
- package/src/components/RadioCard/RadioCardRoot.tsx +3 -3
- package/src/components/SectionHeader/SectionHeader.figma.tsx +30 -16
- package/src/components/Select/Select.figma.tsx +55 -0
- package/src/components/Select/SelectOption.figma.tsx +36 -0
- package/src/components/Spinner/Spinner.figma.tsx +20 -12
- package/src/components/Switch/Switch.figma.tsx +31 -23
- package/src/components/Tabs/Tab.tsx +5 -5
- package/src/components/Tabs/Tabs.figma.tsx +29 -0
- package/src/components/ThemedImage/ThemedImage.stories.tsx +1 -1
- package/src/components/Toast/ToastItem.figma.tsx +22 -0
- package/src/components/ToggleButton/ToggleButtonRoot.tsx +2 -2
- package/src/components/ToggleButtonCard/ToggleButtonCardRoot.tsx +3 -3
- package/src/components/UnstyledIconButton/UnstyledIconButton.figma.tsx +49 -0
- package/src/components/UnstyledIconButton/UnstyledIconButtonRoot.tsx +1 -1
- package/src/components/VerificationInput/VerificationInput.docs.mdx +68 -0
- package/src/components/VerificationInput/VerificationInput.props.ts +52 -0
- package/src/components/VerificationInput/VerificationInput.stories.tsx +140 -0
- package/src/components/VerificationInput/VerificationInput.tsx +89 -0
- package/src/components/VerificationInput/VerificationInputSlot.tsx +94 -0
- package/src/components/VerificationInput/index.ts +5 -0
- package/src/components/VerificationInput/useVerificationInput.ts +72 -0
- package/src/components/index.ts +1 -0
- package/build/components/List/ListItem/ListItemText.d.ts +0 -6
- package/build/components/List/ListItem/ListItemText.js +0 -7
- package/src/components/Checkbox/CheckboxIndicator.figma.tsx +0 -19
- package/src/components/List/ListItem/ListItemText.tsx +0 -14
- package/src/components/Radio/RadioIndicator.figma.tsx +0 -21
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useRef, useState } from 'react';
|
|
2
|
+
import { NativeSyntheticEvent, TextInput, TextInputKeyPressEventData } from 'react-native';
|
|
3
|
+
|
|
4
|
+
interface UseVerificationInputProps {
|
|
5
|
+
value: string;
|
|
6
|
+
onChangeText?: (text: string) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const useVerificationInput = ({ value, onChangeText }: UseVerificationInputProps) => {
|
|
10
|
+
const length = 6;
|
|
11
|
+
const inputRefs = useRef<(TextInput | null)[]>([]);
|
|
12
|
+
const [focusedIndex, setFocusedIndex] = useState<number | null>(null);
|
|
13
|
+
|
|
14
|
+
const handleFocus = (index: number) => {
|
|
15
|
+
setFocusedIndex(index);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const handleBlur = () => {
|
|
19
|
+
setFocusedIndex(null);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const handleChangeText = (text: string, index: number) => {
|
|
23
|
+
// Break down the text into an array of characters
|
|
24
|
+
const chars = Array(length).fill('');
|
|
25
|
+
for (let i = 0; i < value.length && i < length; i++) {
|
|
26
|
+
chars[i] = value[i];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (text.length > 1) {
|
|
30
|
+
// Handle paste
|
|
31
|
+
const pastedChars = text.slice(0, length - index).split('');
|
|
32
|
+
for (let i = 0; i < pastedChars.length; i++) {
|
|
33
|
+
chars[index + i] = pastedChars[i];
|
|
34
|
+
}
|
|
35
|
+
const nextIndex = Math.min(index + pastedChars.length, length - 1);
|
|
36
|
+
inputRefs.current[nextIndex]?.focus();
|
|
37
|
+
} else {
|
|
38
|
+
// Handle single char input
|
|
39
|
+
chars[index] = text;
|
|
40
|
+
if (text.length === 1 && index < length - 1) {
|
|
41
|
+
inputRefs.current[index + 1]?.focus();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
onChangeText?.(chars.join(''));
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const handleKeyPress = (e: NativeSyntheticEvent<TextInputKeyPressEventData>, index: number) => {
|
|
49
|
+
if (e.nativeEvent.key === 'Backspace') {
|
|
50
|
+
if (!value[index] && index > 0) {
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
inputRefs.current[index - 1]?.focus();
|
|
53
|
+
|
|
54
|
+
const chars = Array(length).fill('');
|
|
55
|
+
for (let i = 0; i < value.length && i < length; i++) {
|
|
56
|
+
chars[i] = value[i];
|
|
57
|
+
}
|
|
58
|
+
chars[index - 1] = '';
|
|
59
|
+
onChangeText?.(chars.join(''));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
inputRefs,
|
|
66
|
+
focusedIndex,
|
|
67
|
+
handleFocus,
|
|
68
|
+
handleBlur,
|
|
69
|
+
handleChangeText,
|
|
70
|
+
handleKeyPress,
|
|
71
|
+
};
|
|
72
|
+
};
|
package/src/components/index.ts
CHANGED
|
@@ -54,6 +54,7 @@ export * from './Textarea';
|
|
|
54
54
|
export * from './ThemedImage';
|
|
55
55
|
export * from './Toast';
|
|
56
56
|
export * from './ToggleButtonCard';
|
|
57
|
+
export * from './VerificationInput';
|
|
57
58
|
|
|
58
59
|
export { FlatList, Image, KeyboardAvoidingView, ScrollView, SectionList, View } from 'react-native';
|
|
59
60
|
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { BodyText } from '../../BodyText';
|
|
3
|
-
const ListItemText = ({ children, ...props }) => {
|
|
4
|
-
return (_jsx(BodyText, { size: "lg", ...props, children: children }));
|
|
5
|
-
};
|
|
6
|
-
ListItemText.displayName = 'ListItemText';
|
|
7
|
-
export default ListItemText;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Checkbox } from './';
|
|
2
|
-
import figma from '@figma/code-connect';
|
|
3
|
-
|
|
4
|
-
const value = 'some-value';
|
|
5
|
-
const setValue = (isChecked: boolean) => console.log(isChecked);
|
|
6
|
-
|
|
7
|
-
figma.connect(
|
|
8
|
-
Checkbox,
|
|
9
|
-
'https://www.figma.com/design/3RY3OvLA88yZksRjOfjQJm/UW-App-UI?node-id=4454-3759&m=dev',
|
|
10
|
-
{
|
|
11
|
-
props: {
|
|
12
|
-
checked: figma.boolean('checked'),
|
|
13
|
-
disabled: figma.boolean('disabled'),
|
|
14
|
-
},
|
|
15
|
-
example: ({ disabled, checked }) => (
|
|
16
|
-
<Checkbox value={value} onChange={setValue} disabled={disabled} checked={checked} />
|
|
17
|
-
),
|
|
18
|
-
}
|
|
19
|
-
);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TextProps } from 'react-native';
|
|
2
|
-
import { BodyText } from '../../BodyText';
|
|
3
|
-
|
|
4
|
-
const ListItemText = ({ children, ...props }: TextProps) => {
|
|
5
|
-
return (
|
|
6
|
-
<BodyText size="lg" {...props}>
|
|
7
|
-
{children}
|
|
8
|
-
</BodyText>
|
|
9
|
-
);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
ListItemText.displayName = 'ListItemText';
|
|
13
|
-
|
|
14
|
-
export default ListItemText;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Radio, RadioGroup } from './';
|
|
2
|
-
import figma from '@figma/code-connect';
|
|
3
|
-
|
|
4
|
-
const value = 'some-value';
|
|
5
|
-
const setValue = (value: string) => console.log(value);
|
|
6
|
-
|
|
7
|
-
figma.connect(
|
|
8
|
-
Radio,
|
|
9
|
-
'https://www.figma.com/design/3RY3OvLA88yZksRjOfjQJm/UW-App-UI?node-id=4461-7535&m=dev',
|
|
10
|
-
{
|
|
11
|
-
props: {
|
|
12
|
-
checked: figma.boolean('checked', { true: 'some-value', false: undefined }),
|
|
13
|
-
disabled: figma.boolean('disabled'),
|
|
14
|
-
},
|
|
15
|
-
example: ({ disabled, checked }) => (
|
|
16
|
-
<RadioGroup value={checked} onChange={setValue}>
|
|
17
|
-
<Radio value={value} disabled={disabled} />
|
|
18
|
-
</RadioGroup>
|
|
19
|
-
),
|
|
20
|
-
}
|
|
21
|
-
);
|