@utilitywarehouse/hearth-react-native 0.18.0 → 0.19.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 +21 -18
- package/CHANGELOG.md +102 -0
- package/build/components/Banner/Banner.d.ts +1 -1
- package/build/components/Banner/Banner.js +24 -4
- package/build/components/Banner/Banner.props.d.ts +1 -6
- package/build/components/Box/Box.props.d.ts +5 -2
- package/build/components/Button/Button.d.ts +2 -0
- package/build/components/Button/ButtonGroupRoot.d.ts +5 -1
- package/build/components/Button/ButtonGroupRoot.js +3 -3
- package/build/components/Card/Card.context.d.ts +1 -1
- package/build/components/Card/Card.props.d.ts +2 -0
- package/build/components/Card/CardContent.js +3 -3
- package/build/components/Card/CardRoot.d.ts +1 -1
- package/build/components/Card/CardRoot.js +14 -4
- package/build/components/Checkbox/CheckboxGroupTextContent.js +1 -1
- package/build/components/Checkbox/CheckboxTextContent.js +1 -1
- package/build/components/Container/Container.d.ts +1 -1
- package/build/components/Container/Container.js +3 -3
- package/build/components/Container/Container.props.d.ts +5 -0
- package/build/components/Divider/Divider.d.ts +1 -1
- package/build/components/Divider/Divider.js +19 -19
- package/build/components/Divider/Divider.props.d.ts +6 -0
- package/build/components/ExpandableCard/ExpandableCardExpandedContent.js +1 -1
- package/build/components/Flex/Flex.d.ts +1 -1
- package/build/components/Flex/Flex.js +3 -3
- package/build/components/Flex/Flex.props.d.ts +5 -0
- package/build/components/Grid/Grid.d.ts +1 -1
- package/build/components/Grid/Grid.js +4 -4
- package/build/components/Grid/Grid.props.d.ts +5 -0
- package/build/components/Modal/Modal.js +14 -4
- package/build/components/Radio/RadioGroupTextContent.js +1 -1
- package/build/components/Radio/RadioTextContent.js +1 -1
- package/build/components/Toast/Toast.context.d.ts +2 -4
- package/build/components/Toast/Toast.context.js +14 -2
- package/build/components/Toast/Toast.props.d.ts +4 -0
- package/build/components/Toast/ToastItem.js +2 -1
- package/build/components/VerificationInput/VerificationInput.d.ts +2 -5
- package/build/components/VerificationInput/VerificationInput.js +20 -7
- package/build/components/VerificationInput/VerificationInput.props.d.ts +10 -0
- package/build/components/VerificationInput/index.d.ts +1 -1
- package/build/components/VerificationInput/useVerificationInput.d.ts +1 -0
- package/build/components/VerificationInput/useVerificationInput.js +24 -9
- package/build/core/themes.d.ts +4 -4
- package/build/core/themes.js +1 -1
- package/build/types/values.d.ts +1 -1
- package/docs/components/AllComponents.web.tsx +9 -9
- package/docs/layout-components.docs.mdx +3 -3
- package/package.json +4 -4
- package/src/components/Alert/Alert.stories.tsx +1 -1
- package/src/components/Avatar/Avatar.stories.tsx +4 -5
- package/src/components/Badge/Badge.stories.tsx +3 -3
- package/src/components/Banner/Banner.docs.mdx +1 -1
- package/src/components/Banner/Banner.props.ts +13 -20
- package/src/components/Banner/Banner.stories.tsx +83 -15
- package/src/components/Banner/Banner.tsx +27 -3
- package/src/components/Box/Box.props.ts +11 -4
- package/src/components/Button/Button.docs.mdx +2 -2
- package/src/components/Button/Button.stories.tsx +4 -4
- package/src/components/Button/ButtonGroupRoot.tsx +8 -3
- package/src/components/Card/Card.context.ts +1 -1
- package/src/components/Card/Card.docs.mdx +1 -1
- package/src/components/Card/Card.props.ts +2 -0
- package/src/components/Card/Card.stories.tsx +9 -9
- package/src/components/Card/CardAction/CardAction.stories.tsx +2 -2
- package/src/components/Card/CardContent.tsx +3 -3
- package/src/components/Card/CardRoot.tsx +15 -5
- package/src/components/Checkbox/CheckboxGroupTextContent.tsx +2 -2
- package/src/components/Checkbox/CheckboxTextContent.tsx +1 -1
- package/src/components/Container/Container.docs.mdx +2 -2
- package/src/components/Container/Container.props.ts +5 -0
- package/src/components/Container/Container.stories.tsx +2 -2
- package/src/components/Container/Container.tsx +3 -3
- package/src/components/CurrencyInput/CurrencyInput.docs.mdx +1 -1
- package/src/components/CurrencyInput/CurrencyInput.stories.tsx +2 -2
- package/src/components/DateInput/DateInput.stories.tsx +3 -3
- package/src/components/DatePickerInput/DatePickerInput.stories.tsx +1 -1
- package/src/components/DescriptionList/DescriptionList.stories.tsx +1 -1
- package/src/components/Divider/Divider.docs.mdx +6 -6
- package/src/components/Divider/Divider.props.ts +6 -0
- package/src/components/Divider/Divider.tsx +19 -18
- package/src/components/ExpandableCard/ExpandableCardExpandedContent.tsx +1 -1
- package/src/components/Flex/Flex.docs.mdx +3 -3
- package/src/components/Flex/Flex.props.ts +5 -0
- package/src/components/Flex/Flex.stories.tsx +2 -2
- package/src/components/Flex/Flex.tsx +4 -3
- package/src/components/FormField/FormField.docs.mdx +1 -1
- package/src/components/FormField/FormField.stories.tsx +1 -1
- package/src/components/Grid/Grid.docs.mdx +5 -5
- package/src/components/Grid/Grid.props.ts +6 -0
- package/src/components/Grid/Grid.stories.tsx +8 -8
- package/src/components/Grid/Grid.tsx +4 -3
- package/src/components/HighlightBanner/HighlightBanner.docs.mdx +1 -1
- package/src/components/HighlightBanner/HighlightBanner.stories.tsx +2 -2
- package/src/components/Icon/Icon.docs.mdx +3 -3
- package/src/components/IconButton/IconButton.stories.tsx +5 -5
- package/src/components/IconContainer/IconContainer.docs.mdx +1 -1
- package/src/components/IconContainer/IconContainer.stories.tsx +3 -3
- package/src/components/IndicatorIconButton/IndicatorIconButton.stories.tsx +17 -9
- package/src/components/InlineLink/InlineLink.stories.tsx +2 -2
- package/src/components/Input/Input.stories.tsx +4 -4
- package/src/components/List/List.stories.tsx +1 -1
- package/src/components/Modal/Modal.tsx +18 -4
- package/src/components/PillGroup/PillGroup.stories.tsx +7 -7
- package/src/components/ProgressStepper/ProgressStepper.stories.tsx +7 -8
- package/src/components/Radio/Radio.stories.tsx +1 -1
- package/src/components/Radio/RadioGroup.stories.tsx +1 -1
- package/src/components/Radio/RadioGroupTextContent.tsx +2 -2
- package/src/components/Radio/RadioTextContent.tsx +1 -1
- package/src/components/SectionHeader/SectionHeader.stories.tsx +1 -1
- package/src/components/Switch/Switch.docs.mdx +8 -8
- package/src/components/Switch/Switch.stories.tsx +2 -2
- package/src/components/Tabs/Tabs.stories.tsx +1 -1
- package/src/components/Textarea/Textarea.docs.mdx +3 -3
- package/src/components/Toast/Toast.context.tsx +24 -3
- package/src/components/Toast/Toast.props.ts +5 -0
- package/src/components/Toast/Toast.stories.tsx +29 -0
- package/src/components/Toast/ToastItem.tsx +4 -1
- package/src/components/UnstyledIconButton/UnstyledIconButton.stories.tsx +5 -5
- package/src/components/VerificationInput/VerificationInput.docs.mdx +31 -8
- package/src/components/VerificationInput/VerificationInput.props.ts +11 -0
- package/src/components/VerificationInput/VerificationInput.stories.tsx +79 -3
- package/src/components/VerificationInput/VerificationInput.tsx +94 -62
- package/src/components/VerificationInput/index.ts +4 -2
- package/src/components/VerificationInput/useVerificationInput.ts +26 -10
- package/src/core/themes.ts +1 -1
- package/src/types/values.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useRef, useState } from 'react';
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { NativeSyntheticEvent, TextInput, TextInputKeyPressEventData } from 'react-native';
|
|
3
3
|
|
|
4
4
|
interface UseVerificationInputProps {
|
|
@@ -9,8 +9,17 @@ interface UseVerificationInputProps {
|
|
|
9
9
|
export const useVerificationInput = ({ value, onChangeText }: UseVerificationInputProps) => {
|
|
10
10
|
const length = 6;
|
|
11
11
|
const inputRefs = useRef<(TextInput | null)[]>([]);
|
|
12
|
+
const latestValueRef = useRef(value);
|
|
13
|
+
const [displayValue, setDisplayValue] = useState(value);
|
|
12
14
|
const [focusedIndex, setFocusedIndex] = useState<number | null>(null);
|
|
13
15
|
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (value !== latestValueRef.current) {
|
|
18
|
+
latestValueRef.current = value;
|
|
19
|
+
setDisplayValue(value);
|
|
20
|
+
}
|
|
21
|
+
}, [value]);
|
|
22
|
+
|
|
14
23
|
const handleFocus = (index: number) => {
|
|
15
24
|
setFocusedIndex(index);
|
|
16
25
|
};
|
|
@@ -19,11 +28,17 @@ export const useVerificationInput = ({ value, onChangeText }: UseVerificationInp
|
|
|
19
28
|
setFocusedIndex(null);
|
|
20
29
|
};
|
|
21
30
|
|
|
31
|
+
const updateValue = (nextValue: string) => {
|
|
32
|
+
latestValueRef.current = nextValue;
|
|
33
|
+
setDisplayValue(nextValue);
|
|
34
|
+
onChangeText?.(nextValue);
|
|
35
|
+
};
|
|
36
|
+
|
|
22
37
|
const handleChangeText = (text: string, index: number) => {
|
|
23
|
-
|
|
38
|
+
const currentValue = latestValueRef.current;
|
|
24
39
|
const chars = Array(length).fill('');
|
|
25
|
-
for (let i = 0; i <
|
|
26
|
-
chars[i] =
|
|
40
|
+
for (let i = 0; i < currentValue.length && i < length; i++) {
|
|
41
|
+
chars[i] = currentValue[i];
|
|
27
42
|
}
|
|
28
43
|
|
|
29
44
|
if (text.length > 1) {
|
|
@@ -41,28 +56,29 @@ export const useVerificationInput = ({ value, onChangeText }: UseVerificationInp
|
|
|
41
56
|
inputRefs.current[index + 1]?.focus();
|
|
42
57
|
}
|
|
43
58
|
}
|
|
44
|
-
|
|
45
|
-
onChangeText?.(chars.join(''));
|
|
59
|
+
updateValue(chars.join(''));
|
|
46
60
|
};
|
|
47
61
|
|
|
48
62
|
const handleKeyPress = (e: NativeSyntheticEvent<TextInputKeyPressEventData>, index: number) => {
|
|
49
63
|
if (e.nativeEvent.key === 'Backspace') {
|
|
50
|
-
|
|
64
|
+
const currentValue = latestValueRef.current;
|
|
65
|
+
if (!currentValue[index] && index > 0) {
|
|
51
66
|
e.preventDefault();
|
|
52
67
|
inputRefs.current[index - 1]?.focus();
|
|
53
68
|
|
|
54
69
|
const chars = Array(length).fill('');
|
|
55
|
-
for (let i = 0; i <
|
|
56
|
-
chars[i] =
|
|
70
|
+
for (let i = 0; i < currentValue.length && i < length; i++) {
|
|
71
|
+
chars[i] = currentValue[i];
|
|
57
72
|
}
|
|
58
73
|
chars[index - 1] = '';
|
|
59
|
-
|
|
74
|
+
updateValue(chars.join(''));
|
|
60
75
|
}
|
|
61
76
|
}
|
|
62
77
|
};
|
|
63
78
|
|
|
64
79
|
return {
|
|
65
80
|
inputRefs,
|
|
81
|
+
displayValue,
|
|
66
82
|
focusedIndex,
|
|
67
83
|
handleFocus,
|
|
68
84
|
handleBlur,
|
package/src/core/themes.ts
CHANGED
package/src/types/values.ts
CHANGED
|
@@ -81,4 +81,4 @@ export type BordeWidthValue =
|
|
|
81
81
|
|
|
82
82
|
export type OpacityValue = AnimatableNumericValue | undefined;
|
|
83
83
|
|
|
84
|
-
export type SpacingValues = keyof (typeof themes)['light']['globalStyle']['variants']['
|
|
84
|
+
export type SpacingValues = keyof (typeof themes)['light']['globalStyle']['variants']['spacing'];
|