@utilitywarehouse/hearth-react-native 0.12.0 → 0.13.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 +6 -0
- package/build/components/Accordion/AccordionTrigger.js +1 -1
- package/build/components/Checkbox/CheckboxIndicator.js +3 -3
- package/build/components/DatePicker/DatePickerDay.js +3 -3
- package/build/components/PillGroup/Pill.js +2 -2
- package/build/components/Radio/RadioIndicator.js +3 -3
- 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 +11 -12
- 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/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.figma.tsx +20 -0
- package/src/components/Checkbox/CheckboxImage.figma.tsx +27 -0
- package/src/components/Checkbox/CheckboxIndicator.tsx +3 -3
- package/src/components/Checkbox/CheckboxTileRoot.figma.tsx +32 -0
- 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.figma.tsx +29 -108
- package/src/components/List/ListAction/ListAction.figma.tsx +29 -0
- package/src/components/List/ListItem/ListItem.figma.tsx +40 -220
- package/src/components/List/ListItem/ListItemLeadingContent.figma.tsx +29 -0
- package/src/components/List/ListItem/ListItemTrailingContent.figma.tsx +27 -0
- package/src/components/Menu/Menu.figma.tsx +30 -0
- package/src/components/Menu/MenuItem.figma.tsx +31 -0
- 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/RadioGroup.figma.tsx +54 -0
- package/src/components/Radio/RadioImage.figma.tsx +27 -0
- package/src/components/Radio/RadioIndicator.tsx +3 -3
- package/src/components/Radio/RadioTileRoot.figma.tsx +31 -0
- 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/src/components/Checkbox/CheckboxIndicator.figma.tsx +0 -19
- package/src/components/Radio/RadioIndicator.figma.tsx +0 -21
package/.turbo/turbo-build.log
CHANGED
package/.turbo/turbo-lint.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @utilitywarehouse/hearth-react-native@0.
|
|
2
|
+
> @utilitywarehouse/hearth-react-native@0.13.0 lint /home/runner/work/hearth/hearth/packages/react-native
|
|
3
3
|
> TIMING=1 eslint --max-warnings 0
|
|
4
4
|
|
|
5
5
|
Rule | Time (ms) | Relative
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @utilitywarehouse/hearth-react-native
|
|
2
2
|
|
|
3
|
+
## 0.13.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#682](https://github.com/utilitywarehouse/hearth/pull/682) [`57d6c71`](https://github.com/utilitywarehouse/hearth/commit/57d6c71baedeaa0bc914ff5163e73bbf4281aa79) Thanks [@Utakato](https://github.com/Utakato)! - Add Verification Input component
|
|
8
|
+
|
|
3
9
|
## 0.12.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -25,7 +25,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
25
25
|
_hover: {
|
|
26
26
|
backgroundColor: theme.color.interactive.neutral.surface.subtle.hover,
|
|
27
27
|
},
|
|
28
|
-
'_focus-visible': theme.helpers.focusVisible,
|
|
28
|
+
// '_focus-visible': theme.helpers.focusVisible,
|
|
29
29
|
_active: {
|
|
30
30
|
backgroundColor: theme.color.interactive.neutral.surface.subtle.active,
|
|
31
31
|
},
|
|
@@ -30,9 +30,9 @@ const styles = StyleSheet.create(theme => ({
|
|
|
30
30
|
_hover: {
|
|
31
31
|
outlineColor: theme.components.checkbox.outlineColorHover,
|
|
32
32
|
},
|
|
33
|
-
'_focus-within': {
|
|
34
|
-
|
|
35
|
-
},
|
|
33
|
+
// '_focus-within': {
|
|
34
|
+
// ...theme.helpers.focusVisible,
|
|
35
|
+
// },
|
|
36
36
|
_active: {
|
|
37
37
|
outlineColor: theme.components.checkbox.outlineColorActive,
|
|
38
38
|
},
|
|
@@ -133,9 +133,9 @@ const styles = StyleSheet.create(theme => ({
|
|
|
133
133
|
},
|
|
134
134
|
],
|
|
135
135
|
_web: {
|
|
136
|
-
'_focus-visible': {
|
|
137
|
-
|
|
138
|
-
},
|
|
136
|
+
// '_focus-visible': {
|
|
137
|
+
// ...theme.helpers.focusVisible,
|
|
138
|
+
// },
|
|
139
139
|
_active: {
|
|
140
140
|
backgroundColor: theme.color.interactive.functional.surface.subtle.active,
|
|
141
141
|
},
|
|
@@ -2,8 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { createPressable } from '@gluestack-ui/pressable';
|
|
3
3
|
import { Pressable } from 'react-native';
|
|
4
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
-
import { Icon } from '../Icon';
|
|
6
5
|
import { BodyText } from '../BodyText';
|
|
6
|
+
import { Icon } from '../Icon';
|
|
7
7
|
import { usePillGroupContext } from './PillGroup.context';
|
|
8
8
|
const PillRoot = ({ value, label, icon, states = {}, ...props }) => {
|
|
9
9
|
const { active } = states;
|
|
@@ -35,7 +35,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
35
35
|
_hover: {
|
|
36
36
|
backgroundColor: theme.color.interactive.neutral.surface.subtle.hover,
|
|
37
37
|
},
|
|
38
|
-
'_focus-visible': theme.helpers.focusVisible,
|
|
38
|
+
// '_focus-visible': theme.helpers.focusVisible,
|
|
39
39
|
},
|
|
40
40
|
variants: {
|
|
41
41
|
active: {
|
|
@@ -30,9 +30,9 @@ const styles = StyleSheet.create(theme => ({
|
|
|
30
30
|
_hover: {
|
|
31
31
|
outlineColor: theme.components.radio.outlineColorHover,
|
|
32
32
|
},
|
|
33
|
-
'_focus-within': {
|
|
34
|
-
|
|
35
|
-
},
|
|
33
|
+
// '_focus-within': {
|
|
34
|
+
// ...theme.helpers.focusVisible,
|
|
35
|
+
// },
|
|
36
36
|
_active: {
|
|
37
37
|
outlineColor: theme.components.radio.outlineColorActive,
|
|
38
38
|
},
|
|
@@ -30,9 +30,9 @@ const styles = StyleSheet.create(theme => ({
|
|
|
30
30
|
_hover: {
|
|
31
31
|
outlineColor: theme.components.radio.outlineColorHover,
|
|
32
32
|
},
|
|
33
|
-
'_focus-within': {
|
|
34
|
-
|
|
35
|
-
},
|
|
33
|
+
// '_focus-within': {
|
|
34
|
+
// ...theme.helpers.focusVisible,
|
|
35
|
+
// },
|
|
36
36
|
_active: {
|
|
37
37
|
outlineColor: theme.components.radio.outlineColorActive,
|
|
38
38
|
},
|
|
@@ -38,11 +38,11 @@ const styles = StyleSheet.create(theme => ({
|
|
|
38
38
|
_hover: {
|
|
39
39
|
backgroundColor: theme.color.interactive.neutral.surface.subtle.hover,
|
|
40
40
|
},
|
|
41
|
-
'_focus-visible': {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
},
|
|
41
|
+
// '_focus-visible': {
|
|
42
|
+
// ...theme.helpers.focusVisible,
|
|
43
|
+
// outlineOffset: -2,
|
|
44
|
+
// borderRadius: theme.borderRadius.sm,
|
|
45
|
+
// },
|
|
46
46
|
_active: {
|
|
47
47
|
backgroundColor: theme.color.interactive.neutral.surface.subtle.active,
|
|
48
48
|
},
|
|
@@ -7,7 +7,7 @@ const ButtonRoot = ({ children, onToggle, toggled, states, onPress, ...props })
|
|
|
7
7
|
const { pressed } = useCardPressHandlerContext();
|
|
8
8
|
styles.useVariants({
|
|
9
9
|
toggled,
|
|
10
|
-
active
|
|
10
|
+
active,
|
|
11
11
|
});
|
|
12
12
|
const handlePress = (e) => {
|
|
13
13
|
onPress?.(e);
|
|
@@ -34,7 +34,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
34
34
|
borderColor: theme.color.interactive.neutral.border.subtle,
|
|
35
35
|
height: theme.components.toggleButton.height,
|
|
36
36
|
_web: {
|
|
37
|
-
'_focus-visible': theme.helpers.focusVisible,
|
|
37
|
+
// '_focus-visible': theme.helpers.focusVisible,
|
|
38
38
|
_hover: {
|
|
39
39
|
backgroundColor: theme.color.interactive.neutral.surface.subtle.hover,
|
|
40
40
|
},
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import VerificationInputProps from './VerificationInput.props';
|
|
2
|
+
declare const VerificationInput: {
|
|
3
|
+
({ value, onChangeText, label, helperText, helperIcon, validationStatus, validText, invalidText, disabled, readonly, secureTextEntry, style, ...props }: VerificationInputProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
|
6
|
+
export default VerificationInput;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
import { FormField } from '../FormField';
|
|
5
|
+
import { useVerificationInput } from './useVerificationInput';
|
|
6
|
+
import { VerificationInputSlot } from './VerificationInputSlot';
|
|
7
|
+
const VerificationInput = ({ value = '', onChangeText, label, helperText, helperIcon, validationStatus = 'initial', validText, invalidText, disabled = false, readonly = false, secureTextEntry = false, style, ...props }) => {
|
|
8
|
+
const length = 6;
|
|
9
|
+
const { inputRefs, focusedIndex, handleFocus, handleBlur, handleChangeText, handleKeyPress } = useVerificationInput({
|
|
10
|
+
value,
|
|
11
|
+
onChangeText,
|
|
12
|
+
});
|
|
13
|
+
const slots = Array.from({ length }, (_, index) => index);
|
|
14
|
+
return (_jsx(FormField, { label: label, helperText: helperText, helperIcon: helperIcon, validationStatus: validationStatus, validText: validText, invalidText: invalidText, disabled: disabled, readonly: readonly, style: [styles.root, style], ...props, children: _jsx(View, { style: styles.slotsContainer, children: slots.map(index => {
|
|
15
|
+
const char = value[index] || '';
|
|
16
|
+
const isActive = focusedIndex === index;
|
|
17
|
+
return (_jsx(VerificationInputSlot, { ref: ref => {
|
|
18
|
+
inputRefs.current[index] = ref;
|
|
19
|
+
}, value: char, isActive: isActive, validationStatus: validationStatus, disabled: disabled, readonly: readonly, secureTextEntry: secureTextEntry, onChangeText: text => handleChangeText(text, index), onKeyPress: e => handleKeyPress(e, index), onFocus: () => handleFocus(index), onBlur: handleBlur }, index));
|
|
20
|
+
}) }) }));
|
|
21
|
+
};
|
|
22
|
+
const styles = StyleSheet.create(theme => ({
|
|
23
|
+
root: {
|
|
24
|
+
gap: theme.components.input.verification.gap,
|
|
25
|
+
width: '100%',
|
|
26
|
+
maxWidth: theme.components.input.maxWidth,
|
|
27
|
+
},
|
|
28
|
+
slotsContainer: {
|
|
29
|
+
flexDirection: 'row',
|
|
30
|
+
gap: theme.components.input.verification.gap,
|
|
31
|
+
width: '100%',
|
|
32
|
+
},
|
|
33
|
+
}));
|
|
34
|
+
VerificationInput.displayName = 'VerificationInput';
|
|
35
|
+
export default VerificationInput;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import { ViewProps } from 'react-native';
|
|
3
|
+
export interface VerificationInputProps extends ViewProps {
|
|
4
|
+
/**
|
|
5
|
+
* The value of the input.
|
|
6
|
+
*/
|
|
7
|
+
value?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Callback when the value changes.
|
|
10
|
+
*/
|
|
11
|
+
onChangeText?: (text: string) => void;
|
|
12
|
+
/**
|
|
13
|
+
* The label for the input.
|
|
14
|
+
*/
|
|
15
|
+
label?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Helper text to display below the input.
|
|
18
|
+
*/
|
|
19
|
+
helperText?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Icon to display alongside the helper text.
|
|
22
|
+
*/
|
|
23
|
+
helperIcon?: ComponentType;
|
|
24
|
+
/**
|
|
25
|
+
* The validation status of the input.
|
|
26
|
+
*/
|
|
27
|
+
validationStatus?: 'initial' | 'valid' | 'invalid';
|
|
28
|
+
/**
|
|
29
|
+
* Text to display when validation status is 'valid'.
|
|
30
|
+
*/
|
|
31
|
+
validText?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Text to display when validation status is 'invalid'.
|
|
34
|
+
*/
|
|
35
|
+
invalidText?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Whether the input is disabled.
|
|
38
|
+
*/
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the input is read-only.
|
|
42
|
+
*/
|
|
43
|
+
readonly?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether to obscure the text entry (e.g. for passwords/OTPs).
|
|
46
|
+
*/
|
|
47
|
+
secureTextEntry?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export default VerificationInputProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TextInput, TextInputProps } from 'react-native';
|
|
2
|
+
interface VerificationInputSlotProps extends TextInputProps {
|
|
3
|
+
isActive: boolean;
|
|
4
|
+
validationStatus: 'initial' | 'valid' | 'invalid';
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
readonly?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const VerificationInputSlot: import("react").ForwardRefExoticComponent<VerificationInputSlotProps & import("react").RefAttributes<TextInput>>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
import InputField from '../Input/InputField';
|
|
5
|
+
export const VerificationInputSlot = forwardRef(({ isActive, validationStatus, disabled, readonly, style, ...props }, ref) => {
|
|
6
|
+
styles.useVariants({
|
|
7
|
+
disabled,
|
|
8
|
+
readonly,
|
|
9
|
+
validationStatus,
|
|
10
|
+
active: isActive,
|
|
11
|
+
});
|
|
12
|
+
return (_jsx(InputField, { ref: ref, ...props, editable: !disabled && !readonly, selectTextOnFocus: true, keyboardType: "number-pad", style: [styles.slot, style] }));
|
|
13
|
+
});
|
|
14
|
+
VerificationInputSlot.displayName = 'VerificationInputSlot';
|
|
15
|
+
const styles = StyleSheet.create(theme => ({
|
|
16
|
+
slot: {
|
|
17
|
+
flex: 0,
|
|
18
|
+
width: theme.components.input.height,
|
|
19
|
+
height: theme.components.input.height,
|
|
20
|
+
borderWidth: theme.components.input.borderWidth,
|
|
21
|
+
borderColor: theme.color.border.strong,
|
|
22
|
+
borderRadius: theme.components.input.borderRadius,
|
|
23
|
+
backgroundColor: theme.color.surface.neutral.strong,
|
|
24
|
+
textAlign: 'center',
|
|
25
|
+
padding: 0,
|
|
26
|
+
variants: {
|
|
27
|
+
disabled: {
|
|
28
|
+
true: {
|
|
29
|
+
opacity: theme.opacity.disabled,
|
|
30
|
+
color: theme.color.text.secondary,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
readonly: {
|
|
34
|
+
true: {
|
|
35
|
+
borderColor: theme.color.border.subtle,
|
|
36
|
+
backgroundColor: theme.color.surface.neutral.subtle,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
validationStatus: {
|
|
40
|
+
initial: {},
|
|
41
|
+
valid: {
|
|
42
|
+
borderColor: theme.color.feedback.positive.border,
|
|
43
|
+
},
|
|
44
|
+
invalid: {
|
|
45
|
+
borderColor: theme.color.feedback.danger.border,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
active: {
|
|
49
|
+
true: {
|
|
50
|
+
borderColor: theme.color.border.strong,
|
|
51
|
+
borderWidth: theme.components.input.borderWidthFocused,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
compoundVariants: [
|
|
56
|
+
{
|
|
57
|
+
validationStatus: 'invalid',
|
|
58
|
+
active: true,
|
|
59
|
+
styles: {
|
|
60
|
+
borderColor: theme.color.feedback.danger.border,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
validationStatus: 'valid',
|
|
65
|
+
active: true,
|
|
66
|
+
styles: {
|
|
67
|
+
borderColor: theme.color.border.strong,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NativeSyntheticEvent, TextInput, TextInputKeyPressEventData } from 'react-native';
|
|
2
|
+
interface UseVerificationInputProps {
|
|
3
|
+
value: string;
|
|
4
|
+
onChangeText?: (text: string) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const useVerificationInput: ({ value, onChangeText }: UseVerificationInputProps) => {
|
|
7
|
+
inputRefs: import("react").RefObject<(TextInput | null)[]>;
|
|
8
|
+
focusedIndex: number | null;
|
|
9
|
+
handleFocus: (index: number) => void;
|
|
10
|
+
handleBlur: () => void;
|
|
11
|
+
handleChangeText: (text: string, index: number) => void;
|
|
12
|
+
handleKeyPress: (e: NativeSyntheticEvent<TextInputKeyPressEventData>, index: number) => void;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useRef, useState } from 'react';
|
|
2
|
+
export const useVerificationInput = ({ value, onChangeText }) => {
|
|
3
|
+
const length = 6;
|
|
4
|
+
const inputRefs = useRef([]);
|
|
5
|
+
const [focusedIndex, setFocusedIndex] = useState(null);
|
|
6
|
+
const handleFocus = (index) => {
|
|
7
|
+
setFocusedIndex(index);
|
|
8
|
+
};
|
|
9
|
+
const handleBlur = () => {
|
|
10
|
+
setFocusedIndex(null);
|
|
11
|
+
};
|
|
12
|
+
const handleChangeText = (text, index) => {
|
|
13
|
+
// Break down the text into an array of characters
|
|
14
|
+
const chars = Array(length).fill('');
|
|
15
|
+
for (let i = 0; i < value.length && i < length; i++) {
|
|
16
|
+
chars[i] = value[i];
|
|
17
|
+
}
|
|
18
|
+
if (text.length > 1) {
|
|
19
|
+
// Handle paste
|
|
20
|
+
const pastedChars = text.slice(0, length - index).split('');
|
|
21
|
+
for (let i = 0; i < pastedChars.length; i++) {
|
|
22
|
+
chars[index + i] = pastedChars[i];
|
|
23
|
+
}
|
|
24
|
+
const nextIndex = Math.min(index + pastedChars.length, length - 1);
|
|
25
|
+
inputRefs.current[nextIndex]?.focus();
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
// Handle single char input
|
|
29
|
+
chars[index] = text;
|
|
30
|
+
if (text.length === 1 && index < length - 1) {
|
|
31
|
+
inputRefs.current[index + 1]?.focus();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
onChangeText?.(chars.join(''));
|
|
35
|
+
};
|
|
36
|
+
const handleKeyPress = (e, index) => {
|
|
37
|
+
if (e.nativeEvent.key === 'Backspace') {
|
|
38
|
+
if (!value[index] && index > 0) {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
inputRefs.current[index - 1]?.focus();
|
|
41
|
+
const chars = Array(length).fill('');
|
|
42
|
+
for (let i = 0; i < value.length && i < length; i++) {
|
|
43
|
+
chars[i] = value[i];
|
|
44
|
+
}
|
|
45
|
+
chars[index - 1] = '';
|
|
46
|
+
onChangeText?.(chars.join(''));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
inputRefs,
|
|
52
|
+
focusedIndex,
|
|
53
|
+
handleFocus,
|
|
54
|
+
handleBlur,
|
|
55
|
+
handleChangeText,
|
|
56
|
+
handleKeyPress,
|
|
57
|
+
};
|
|
58
|
+
};
|
|
@@ -53,6 +53,7 @@ export * from './Textarea';
|
|
|
53
53
|
export * from './ThemedImage';
|
|
54
54
|
export * from './Toast';
|
|
55
55
|
export * from './ToggleButtonCard';
|
|
56
|
+
export * from './VerificationInput';
|
|
56
57
|
export { FlatList, Image, KeyboardAvoidingView, ScrollView, SectionList, View } from 'react-native';
|
|
57
58
|
export { Pressable } from 'react-native';
|
|
58
59
|
export { createIcon } from '@gluestack-ui/icon';
|
|
@@ -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
|
export { FlatList, Image, KeyboardAvoidingView, ScrollView, SectionList, View } from 'react-native';
|
|
58
59
|
export { Pressable } from 'react-native';
|
|
59
60
|
export { createIcon } from '@gluestack-ui/icon';
|
|
@@ -94,6 +94,7 @@ import {
|
|
|
94
94
|
ToggleButtonCardGroup,
|
|
95
95
|
UL,
|
|
96
96
|
useColorMode,
|
|
97
|
+
VerificationInput,
|
|
97
98
|
} from '../../src';
|
|
98
99
|
import { addReactNativePrefix } from '../heplers';
|
|
99
100
|
|
|
@@ -821,6 +822,14 @@ const AllComponents: React.FC = () => {
|
|
|
821
822
|
</UL>
|
|
822
823
|
</Center>
|
|
823
824
|
</ComponentWrapper>
|
|
825
|
+
<ComponentWrapper
|
|
826
|
+
name="Verification Input"
|
|
827
|
+
link="/?path=/docs/forms-verificationinput--docs"
|
|
828
|
+
>
|
|
829
|
+
<Center flex={1} padding="200">
|
|
830
|
+
<VerificationInput onChangeText={() => {}} />
|
|
831
|
+
</Center>
|
|
832
|
+
</ComponentWrapper>
|
|
824
833
|
</Flex>
|
|
825
834
|
</ScrollView>
|
|
826
835
|
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utilitywarehouse/hearth-react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Utility Warehouse React Native UI library",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -24,20 +24,19 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
|
|
27
|
-
"@chromatic-com/storybook": "^4.1.
|
|
28
|
-
"@figma/code-connect": "^1.3.
|
|
27
|
+
"@chromatic-com/storybook": "^4.1.3",
|
|
28
|
+
"@figma/code-connect": "^1.3.11",
|
|
29
29
|
"@gorhom/bottom-sheet": "5.2.6",
|
|
30
|
-
"@storybook/addon-a11y": "^10.
|
|
31
|
-
"@storybook/addon-docs": "^10.
|
|
32
|
-
"@storybook/addon-vitest": "^10.
|
|
33
|
-
"@storybook/react": "^10.
|
|
34
|
-
"@storybook/react-native-web-vite": "^10.0.5",
|
|
30
|
+
"@storybook/addon-a11y": "^10.1.4",
|
|
31
|
+
"@storybook/addon-docs": "^10.1.4",
|
|
32
|
+
"@storybook/addon-vitest": "^10.1.4",
|
|
33
|
+
"@storybook/react-native-web-vite": "^10.1.4",
|
|
35
34
|
"@types/prismjs": "^1.26.5",
|
|
36
35
|
"@types/react": "^19.1.10",
|
|
37
36
|
"@vitest/browser": "^3.2.4",
|
|
38
37
|
"@vitest/coverage-v8": "^3.2.4",
|
|
39
38
|
"chromatic": "^13.3.0",
|
|
40
|
-
"eslint-plugin-storybook": "10.
|
|
39
|
+
"eslint-plugin-storybook": "10.1.4",
|
|
41
40
|
"playwright": "^1.55.1",
|
|
42
41
|
"prismjs": "^1.30.0",
|
|
43
42
|
"react": "^19.1.0",
|
|
@@ -51,16 +50,16 @@
|
|
|
51
50
|
"react-native-web": "^0.20.0",
|
|
52
51
|
"react-native-worklets": "^0.6.1",
|
|
53
52
|
"remark-gfm": "^4.0.1",
|
|
54
|
-
"storybook": "^10.
|
|
53
|
+
"storybook": "^10.1.4",
|
|
55
54
|
"typescript": "^5.7.3",
|
|
56
55
|
"vite": "^7.1.3",
|
|
57
56
|
"vite-plugin-svgr": "^4.5.0",
|
|
58
57
|
"vitest": "^3.2.4",
|
|
59
58
|
"@utilitywarehouse/hearth-fonts": "^0.0.4",
|
|
60
|
-
"@utilitywarehouse/hearth-react-icons": "^0.7.4",
|
|
61
59
|
"@utilitywarehouse/hearth-react-native-icons": "^0.7.4",
|
|
60
|
+
"@utilitywarehouse/hearth-react-icons": "^0.7.4",
|
|
62
61
|
"@utilitywarehouse/hearth-svg-assets": "^0.2.0",
|
|
63
|
-
"@utilitywarehouse/hearth-tokens": "^0.2.
|
|
62
|
+
"@utilitywarehouse/hearth-tokens": "^0.2.2"
|
|
64
63
|
},
|
|
65
64
|
"peerDependencies": {
|
|
66
65
|
"@gorhom/bottom-sheet": "^5.0.0",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import Accordion from "./Accordion"
|
|
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
|
+
*/
|
|
12
|
+
|
|
13
|
+
figma.connect(
|
|
14
|
+
Accordion,
|
|
15
|
+
"https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=3385%3A7751",
|
|
16
|
+
{
|
|
17
|
+
props: {
|
|
18
|
+
// No matching props could be found for these Figma properties:
|
|
19
|
+
// "sectionHeader": figma.boolean('Section header?')
|
|
20
|
+
},
|
|
21
|
+
example: (props) => <Accordion />,
|
|
22
|
+
},
|
|
23
|
+
)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import AccordionItemRoot from "./AccordionItemRoot"
|
|
3
|
+
import figma from "@figma/code-connect"
|
|
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
|
+
*/
|
|
11
|
+
|
|
12
|
+
figma.connect(
|
|
13
|
+
AccordionItemRoot,
|
|
14
|
+
"https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=3390%3A6160",
|
|
15
|
+
{
|
|
16
|
+
props: {
|
|
17
|
+
// These props were automatically mapped based on your linked code:
|
|
18
|
+
disabled: figma.enum("State", {
|
|
19
|
+
Active: true,
|
|
20
|
+
}),
|
|
21
|
+
title: figma.string("Title"),
|
|
22
|
+
expanded: figma.boolean("Expand?"),
|
|
23
|
+
triggerContent: figma.instance("Trigger custom content"),
|
|
24
|
+
collapsable: figma.boolean("Expand?"),
|
|
25
|
+
focusable: figma.enum("State", {
|
|
26
|
+
Focus: true,
|
|
27
|
+
}),
|
|
28
|
+
// No matching props could be found for these Figma properties:
|
|
29
|
+
// "customContent": figma.boolean('Custom content?'),
|
|
30
|
+
// "title": figma.string('Title'),
|
|
31
|
+
// "description": figma.string('Description'),
|
|
32
|
+
// "customContent": figma.instance('Custom content'),
|
|
33
|
+
// "triggerCustomContent": figma.instance('Trigger custom content'),
|
|
34
|
+
// "triggerCustomContent": figma.boolean('Trigger custom content?')
|
|
35
|
+
},
|
|
36
|
+
example: (props) => (
|
|
37
|
+
<AccordionItemRoot
|
|
38
|
+
disabled={props.disabled}
|
|
39
|
+
title={props.title}
|
|
40
|
+
expanded={props.expanded}
|
|
41
|
+
triggerContent={props.triggerContent}
|
|
42
|
+
collapsable={props.collapsable}
|
|
43
|
+
focusable={props.focusable}
|
|
44
|
+
/>
|
|
45
|
+
),
|
|
46
|
+
},
|
|
47
|
+
)
|
|
@@ -31,7 +31,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
31
31
|
_hover: {
|
|
32
32
|
backgroundColor: theme.color.interactive.neutral.surface.subtle.hover,
|
|
33
33
|
},
|
|
34
|
-
'_focus-visible': theme.helpers.focusVisible,
|
|
34
|
+
// '_focus-visible': theme.helpers.focusVisible,
|
|
35
35
|
_active: {
|
|
36
36
|
backgroundColor: theme.color.interactive.neutral.surface.subtle.active,
|
|
37
37
|
},
|