@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.
Files changed (127) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-lint.log +21 -18
  3. package/CHANGELOG.md +102 -0
  4. package/build/components/Banner/Banner.d.ts +1 -1
  5. package/build/components/Banner/Banner.js +24 -4
  6. package/build/components/Banner/Banner.props.d.ts +1 -6
  7. package/build/components/Box/Box.props.d.ts +5 -2
  8. package/build/components/Button/Button.d.ts +2 -0
  9. package/build/components/Button/ButtonGroupRoot.d.ts +5 -1
  10. package/build/components/Button/ButtonGroupRoot.js +3 -3
  11. package/build/components/Card/Card.context.d.ts +1 -1
  12. package/build/components/Card/Card.props.d.ts +2 -0
  13. package/build/components/Card/CardContent.js +3 -3
  14. package/build/components/Card/CardRoot.d.ts +1 -1
  15. package/build/components/Card/CardRoot.js +14 -4
  16. package/build/components/Checkbox/CheckboxGroupTextContent.js +1 -1
  17. package/build/components/Checkbox/CheckboxTextContent.js +1 -1
  18. package/build/components/Container/Container.d.ts +1 -1
  19. package/build/components/Container/Container.js +3 -3
  20. package/build/components/Container/Container.props.d.ts +5 -0
  21. package/build/components/Divider/Divider.d.ts +1 -1
  22. package/build/components/Divider/Divider.js +19 -19
  23. package/build/components/Divider/Divider.props.d.ts +6 -0
  24. package/build/components/ExpandableCard/ExpandableCardExpandedContent.js +1 -1
  25. package/build/components/Flex/Flex.d.ts +1 -1
  26. package/build/components/Flex/Flex.js +3 -3
  27. package/build/components/Flex/Flex.props.d.ts +5 -0
  28. package/build/components/Grid/Grid.d.ts +1 -1
  29. package/build/components/Grid/Grid.js +4 -4
  30. package/build/components/Grid/Grid.props.d.ts +5 -0
  31. package/build/components/Modal/Modal.js +14 -4
  32. package/build/components/Radio/RadioGroupTextContent.js +1 -1
  33. package/build/components/Radio/RadioTextContent.js +1 -1
  34. package/build/components/Toast/Toast.context.d.ts +2 -4
  35. package/build/components/Toast/Toast.context.js +14 -2
  36. package/build/components/Toast/Toast.props.d.ts +4 -0
  37. package/build/components/Toast/ToastItem.js +2 -1
  38. package/build/components/VerificationInput/VerificationInput.d.ts +2 -5
  39. package/build/components/VerificationInput/VerificationInput.js +20 -7
  40. package/build/components/VerificationInput/VerificationInput.props.d.ts +10 -0
  41. package/build/components/VerificationInput/index.d.ts +1 -1
  42. package/build/components/VerificationInput/useVerificationInput.d.ts +1 -0
  43. package/build/components/VerificationInput/useVerificationInput.js +24 -9
  44. package/build/core/themes.d.ts +4 -4
  45. package/build/core/themes.js +1 -1
  46. package/build/types/values.d.ts +1 -1
  47. package/docs/components/AllComponents.web.tsx +9 -9
  48. package/docs/layout-components.docs.mdx +3 -3
  49. package/package.json +4 -4
  50. package/src/components/Alert/Alert.stories.tsx +1 -1
  51. package/src/components/Avatar/Avatar.stories.tsx +4 -5
  52. package/src/components/Badge/Badge.stories.tsx +3 -3
  53. package/src/components/Banner/Banner.docs.mdx +1 -1
  54. package/src/components/Banner/Banner.props.ts +13 -20
  55. package/src/components/Banner/Banner.stories.tsx +83 -15
  56. package/src/components/Banner/Banner.tsx +27 -3
  57. package/src/components/Box/Box.props.ts +11 -4
  58. package/src/components/Button/Button.docs.mdx +2 -2
  59. package/src/components/Button/Button.stories.tsx +4 -4
  60. package/src/components/Button/ButtonGroupRoot.tsx +8 -3
  61. package/src/components/Card/Card.context.ts +1 -1
  62. package/src/components/Card/Card.docs.mdx +1 -1
  63. package/src/components/Card/Card.props.ts +2 -0
  64. package/src/components/Card/Card.stories.tsx +9 -9
  65. package/src/components/Card/CardAction/CardAction.stories.tsx +2 -2
  66. package/src/components/Card/CardContent.tsx +3 -3
  67. package/src/components/Card/CardRoot.tsx +15 -5
  68. package/src/components/Checkbox/CheckboxGroupTextContent.tsx +2 -2
  69. package/src/components/Checkbox/CheckboxTextContent.tsx +1 -1
  70. package/src/components/Container/Container.docs.mdx +2 -2
  71. package/src/components/Container/Container.props.ts +5 -0
  72. package/src/components/Container/Container.stories.tsx +2 -2
  73. package/src/components/Container/Container.tsx +3 -3
  74. package/src/components/CurrencyInput/CurrencyInput.docs.mdx +1 -1
  75. package/src/components/CurrencyInput/CurrencyInput.stories.tsx +2 -2
  76. package/src/components/DateInput/DateInput.stories.tsx +3 -3
  77. package/src/components/DatePickerInput/DatePickerInput.stories.tsx +1 -1
  78. package/src/components/DescriptionList/DescriptionList.stories.tsx +1 -1
  79. package/src/components/Divider/Divider.docs.mdx +6 -6
  80. package/src/components/Divider/Divider.props.ts +6 -0
  81. package/src/components/Divider/Divider.tsx +19 -18
  82. package/src/components/ExpandableCard/ExpandableCardExpandedContent.tsx +1 -1
  83. package/src/components/Flex/Flex.docs.mdx +3 -3
  84. package/src/components/Flex/Flex.props.ts +5 -0
  85. package/src/components/Flex/Flex.stories.tsx +2 -2
  86. package/src/components/Flex/Flex.tsx +4 -3
  87. package/src/components/FormField/FormField.docs.mdx +1 -1
  88. package/src/components/FormField/FormField.stories.tsx +1 -1
  89. package/src/components/Grid/Grid.docs.mdx +5 -5
  90. package/src/components/Grid/Grid.props.ts +6 -0
  91. package/src/components/Grid/Grid.stories.tsx +8 -8
  92. package/src/components/Grid/Grid.tsx +4 -3
  93. package/src/components/HighlightBanner/HighlightBanner.docs.mdx +1 -1
  94. package/src/components/HighlightBanner/HighlightBanner.stories.tsx +2 -2
  95. package/src/components/Icon/Icon.docs.mdx +3 -3
  96. package/src/components/IconButton/IconButton.stories.tsx +5 -5
  97. package/src/components/IconContainer/IconContainer.docs.mdx +1 -1
  98. package/src/components/IconContainer/IconContainer.stories.tsx +3 -3
  99. package/src/components/IndicatorIconButton/IndicatorIconButton.stories.tsx +17 -9
  100. package/src/components/InlineLink/InlineLink.stories.tsx +2 -2
  101. package/src/components/Input/Input.stories.tsx +4 -4
  102. package/src/components/List/List.stories.tsx +1 -1
  103. package/src/components/Modal/Modal.tsx +18 -4
  104. package/src/components/PillGroup/PillGroup.stories.tsx +7 -7
  105. package/src/components/ProgressStepper/ProgressStepper.stories.tsx +7 -8
  106. package/src/components/Radio/Radio.stories.tsx +1 -1
  107. package/src/components/Radio/RadioGroup.stories.tsx +1 -1
  108. package/src/components/Radio/RadioGroupTextContent.tsx +2 -2
  109. package/src/components/Radio/RadioTextContent.tsx +1 -1
  110. package/src/components/SectionHeader/SectionHeader.stories.tsx +1 -1
  111. package/src/components/Switch/Switch.docs.mdx +8 -8
  112. package/src/components/Switch/Switch.stories.tsx +2 -2
  113. package/src/components/Tabs/Tabs.stories.tsx +1 -1
  114. package/src/components/Textarea/Textarea.docs.mdx +3 -3
  115. package/src/components/Toast/Toast.context.tsx +24 -3
  116. package/src/components/Toast/Toast.props.ts +5 -0
  117. package/src/components/Toast/Toast.stories.tsx +29 -0
  118. package/src/components/Toast/ToastItem.tsx +4 -1
  119. package/src/components/UnstyledIconButton/UnstyledIconButton.stories.tsx +5 -5
  120. package/src/components/VerificationInput/VerificationInput.docs.mdx +31 -8
  121. package/src/components/VerificationInput/VerificationInput.props.ts +11 -0
  122. package/src/components/VerificationInput/VerificationInput.stories.tsx +79 -3
  123. package/src/components/VerificationInput/VerificationInput.tsx +94 -62
  124. package/src/components/VerificationInput/index.ts +4 -2
  125. package/src/components/VerificationInput/useVerificationInput.ts +26 -10
  126. package/src/core/themes.ts +1 -1
  127. 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
- // Break down the text into an array of characters
38
+ const currentValue = latestValueRef.current;
24
39
  const chars = Array(length).fill('');
25
- for (let i = 0; i < value.length && i < length; i++) {
26
- chars[i] = value[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
- if (!value[index] && index > 0) {
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 < value.length && i < length; i++) {
56
- chars[i] = value[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
- onChangeText?.(chars.join(''));
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,
@@ -205,7 +205,7 @@ const shared = {
205
205
  },
206
206
  },
207
207
  },
208
- space: {
208
+ spacing: {
209
209
  none: {
210
210
  gap: {
211
211
  base: layout.mobile.spacing.none,
@@ -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']['space'];
84
+ export type SpacingValues = keyof (typeof themes)['light']['globalStyle']['variants']['spacing'];