@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
@@ -4,8 +4,8 @@ import { View } from 'react-native';
4
4
  import { StyleSheet } from 'react-native-unistyles';
5
5
  import { useTheme } from '../../hooks';
6
6
  import { getFlattenedColorValue } from '../../utils';
7
- const Divider = ({ orientation = 'horizontal', color, space, height, width, flexItem, ...props }) => {
8
- styles.useVariants({ orientation, space, flexItem });
7
+ const Divider = ({ orientation = 'horizontal', color, spacing, space, height, width, flexItem, ...props }) => {
8
+ styles.useVariants({ orientation, spacing: space ?? spacing, flexItem });
9
9
  const { color: themeColor, colorMode } = useTheme();
10
10
  // eslint-disable-next-line react-hooks/exhaustive-deps
11
11
  const colorValue = useMemo(() => getFlattenedColorValue(color, themeColor), [color, colorMode]);
@@ -26,7 +26,7 @@ const styles = StyleSheet.create(theme => ({
26
26
  width: theme.components.divider.borderWidth,
27
27
  },
28
28
  },
29
- space: {
29
+ spacing: {
30
30
  none: {},
31
31
  '2xs': {},
32
32
  xs: {},
@@ -45,14 +45,14 @@ const styles = StyleSheet.create(theme => ({
45
45
  compoundVariants: [
46
46
  {
47
47
  orientation: 'horizontal',
48
- space: 'none',
48
+ spacing: 'none',
49
49
  styles: {
50
50
  marginVertical: 0,
51
51
  },
52
52
  },
53
53
  {
54
54
  orientation: 'horizontal',
55
- space: '2xs',
55
+ spacing: '2xs',
56
56
  styles: {
57
57
  marginVertical: {
58
58
  base: theme.layout.mobile.spacing['2xs'],
@@ -63,7 +63,7 @@ const styles = StyleSheet.create(theme => ({
63
63
  },
64
64
  {
65
65
  orientation: 'horizontal',
66
- space: 'xs',
66
+ spacing: 'xs',
67
67
  styles: {
68
68
  marginVertical: {
69
69
  base: theme.layout.mobile.spacing.xs,
@@ -74,7 +74,7 @@ const styles = StyleSheet.create(theme => ({
74
74
  },
75
75
  {
76
76
  orientation: 'horizontal',
77
- space: 'sm',
77
+ spacing: 'sm',
78
78
  styles: {
79
79
  marginVertical: {
80
80
  base: theme.layout.mobile.spacing.sm,
@@ -85,7 +85,7 @@ const styles = StyleSheet.create(theme => ({
85
85
  },
86
86
  {
87
87
  orientation: 'horizontal',
88
- space: 'md',
88
+ spacing: 'md',
89
89
  styles: {
90
90
  marginVertical: {
91
91
  base: theme.layout.mobile.spacing.md,
@@ -96,7 +96,7 @@ const styles = StyleSheet.create(theme => ({
96
96
  },
97
97
  {
98
98
  orientation: 'horizontal',
99
- space: 'lg',
99
+ spacing: 'lg',
100
100
  styles: {
101
101
  marginVertical: {
102
102
  base: theme.layout.mobile.spacing.lg,
@@ -107,7 +107,7 @@ const styles = StyleSheet.create(theme => ({
107
107
  },
108
108
  {
109
109
  orientation: 'horizontal',
110
- space: 'xl',
110
+ spacing: 'xl',
111
111
  styles: {
112
112
  marginVertical: {
113
113
  base: theme.layout.mobile.spacing.xl,
@@ -118,7 +118,7 @@ const styles = StyleSheet.create(theme => ({
118
118
  },
119
119
  {
120
120
  orientation: 'horizontal',
121
- space: '2xl',
121
+ spacing: '2xl',
122
122
  styles: {
123
123
  marginVertical: {
124
124
  base: theme.layout.mobile.spacing['2xl'],
@@ -129,14 +129,14 @@ const styles = StyleSheet.create(theme => ({
129
129
  },
130
130
  {
131
131
  orientation: 'vertical',
132
- space: 'none',
132
+ spacing: 'none',
133
133
  styles: {
134
134
  marginHorizontal: 0,
135
135
  },
136
136
  },
137
137
  {
138
138
  orientation: 'vertical',
139
- space: '2xs',
139
+ spacing: '2xs',
140
140
  styles: {
141
141
  marginHorizontal: {
142
142
  base: theme.layout.mobile.spacing['2xs'],
@@ -147,7 +147,7 @@ const styles = StyleSheet.create(theme => ({
147
147
  },
148
148
  {
149
149
  orientation: 'vertical',
150
- space: 'xs',
150
+ spacing: 'xs',
151
151
  styles: {
152
152
  marginHorizontal: {
153
153
  base: theme.layout.mobile.spacing.xs,
@@ -158,7 +158,7 @@ const styles = StyleSheet.create(theme => ({
158
158
  },
159
159
  {
160
160
  orientation: 'vertical',
161
- space: 'sm',
161
+ spacing: 'sm',
162
162
  styles: {
163
163
  marginHorizontal: {
164
164
  base: theme.layout.mobile.spacing.sm,
@@ -169,7 +169,7 @@ const styles = StyleSheet.create(theme => ({
169
169
  },
170
170
  {
171
171
  orientation: 'vertical',
172
- space: 'md',
172
+ spacing: 'md',
173
173
  styles: {
174
174
  marginHorizontal: {
175
175
  base: theme.layout.mobile.spacing.md,
@@ -180,7 +180,7 @@ const styles = StyleSheet.create(theme => ({
180
180
  },
181
181
  {
182
182
  orientation: 'vertical',
183
- space: 'lg',
183
+ spacing: 'lg',
184
184
  styles: {
185
185
  marginHorizontal: {
186
186
  base: theme.layout.mobile.spacing.lg,
@@ -191,7 +191,7 @@ const styles = StyleSheet.create(theme => ({
191
191
  },
192
192
  {
193
193
  orientation: 'vertical',
194
- space: 'xl',
194
+ spacing: 'xl',
195
195
  styles: {
196
196
  marginHorizontal: {
197
197
  base: theme.layout.mobile.spacing.xl,
@@ -202,7 +202,7 @@ const styles = StyleSheet.create(theme => ({
202
202
  },
203
203
  {
204
204
  orientation: 'vertical',
205
- space: '2xl',
205
+ spacing: '2xl',
206
206
  styles: {
207
207
  marginHorizontal: {
208
208
  base: theme.layout.mobile.spacing['2xl'],
@@ -2,6 +2,12 @@ import type { DimensionValue, ViewProps } from 'react-native';
2
2
  import type { ColorValue, SpacingValues } from '../../types';
3
3
  interface DividerProps extends Omit<ViewProps, 'children'> {
4
4
  color?: ColorValue;
5
+ backgroundColor?: ColorValue;
6
+ spacing?: SpacingValues;
7
+ /**
8
+ * The space between child elements (gap).
9
+ * @deprecated Use `spacing` instead. The `space` prop will be removed in a future release.
10
+ */
5
11
  space?: SpacingValues;
6
12
  orientation?: 'horizontal' | 'vertical';
7
13
  height?: DimensionValue;
@@ -4,7 +4,7 @@ import { StyleSheet } from 'react-native-unistyles';
4
4
  import { Divider } from '../Divider';
5
5
  import { Expandable } from '../Expandable';
6
6
  const ExpandableCardExpandedContent = ({ children, isExpanded, duration = 200, animateOpacity = true, }) => {
7
- return (_jsx(View, { style: styles.container, children: _jsx(Expandable, { expanded: isExpanded, duration: duration, animateOpacity: animateOpacity, children: _jsxs(View, { children: [_jsx(Divider, { space: "none" }), _jsx(View, { style: styles.content, children: children })] }) }) }));
7
+ return (_jsx(View, { style: styles.container, children: _jsx(Expandable, { expanded: isExpanded, duration: duration, animateOpacity: animateOpacity, children: _jsxs(View, { children: [_jsx(Divider, { spacing: "none" }), _jsx(View, { style: styles.content, children: children })] }) }) }));
8
8
  };
9
9
  ExpandableCardExpandedContent.displayName = 'ExpandableCardExpandedContent';
10
10
  const styles = StyleSheet.create(theme => ({
@@ -1,6 +1,6 @@
1
1
  import FlexProps from './Flex.props';
2
2
  declare const Flex: {
3
- ({ style, children, direction, align, justify, wrap, space, ...rest }: FlexProps): import("react/jsx-runtime").JSX.Element;
3
+ ({ style, children, direction, align, justify, wrap, spacing, space, ...rest }: FlexProps): import("react/jsx-runtime").JSX.Element;
4
4
  displayName: string;
5
5
  };
6
6
  export default Flex;
@@ -1,14 +1,14 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { View } from 'react-native';
3
3
  import { StyleSheet } from 'react-native-unistyles';
4
- const Flex = ({ style, children, direction = 'column', align = 'flex-start', justify = 'flex-start', wrap = 'nowrap', space = 'md', ...rest }) => {
4
+ const Flex = ({ style, children, direction = 'column', align = 'flex-start', justify = 'flex-start', wrap = 'nowrap', spacing = 'md', space, ...rest }) => {
5
5
  const propStyle = {
6
6
  flexDirection: direction,
7
7
  alignItems: align,
8
8
  justifyContent: justify,
9
9
  flexWrap: wrap,
10
10
  };
11
- styles.useVariants({ space });
11
+ styles.useVariants({ spacing: space ?? spacing });
12
12
  return (_jsx(View, { style: [propStyle, styles.flex, style], ...rest, children: children }));
13
13
  };
14
14
  Flex.displayName = 'Flex';
@@ -16,7 +16,7 @@ const styles = StyleSheet.create(theme => ({
16
16
  flex: {
17
17
  display: 'flex',
18
18
  variants: {
19
- space: theme.globalStyle.variants.space,
19
+ spacing: theme.globalStyle.variants.spacing,
20
20
  },
21
21
  },
22
22
  }));
@@ -5,6 +5,11 @@ interface FlexProps extends ViewProps {
5
5
  align?: FlexAlignType;
6
6
  justify?: ViewStyle['justifyContent'];
7
7
  wrap?: ViewStyle['flexWrap'];
8
+ spacing?: SpacingValues;
9
+ /**
10
+ * The space between child elements (gap).
11
+ * @deprecated Use `spacing` instead. The `space` prop will be removed in a future release.
12
+ */
8
13
  space?: SpacingValues;
9
14
  }
10
15
  export default FlexProps;
@@ -1,6 +1,6 @@
1
1
  import type { GridProps } from './Grid.props';
2
2
  declare const Grid: {
3
- ({ columns, containerStyle, itemStyle, rowStyle, space, children, ...props }: GridProps): import("react/jsx-runtime").JSX.Element;
3
+ ({ columns, containerStyle, itemStyle, rowStyle, spacing, space, children, ...props }: GridProps): import("react/jsx-runtime").JSX.Element;
4
4
  displayName: string;
5
5
  };
6
6
  export default Grid;
@@ -3,13 +3,13 @@ import React, { useMemo } from 'react';
3
3
  import { useWindowDimensions, View } from 'react-native';
4
4
  import { StyleSheet, UnistylesRuntime } from 'react-native-unistyles';
5
5
  import { useStyleProps, useTheme } from '../../hooks';
6
- const Grid = ({ columns = 2, containerStyle, itemStyle, rowStyle, space, children, ...props }) => {
6
+ const Grid = ({ columns = 2, containerStyle, itemStyle, rowStyle, spacing, space, children, ...props }) => {
7
7
  const { breakpoints } = useTheme();
8
8
  const { computedStyles, remainingProps } = useStyleProps(props);
9
9
  const childrenArray = React.Children.toArray(children).filter(Boolean);
10
10
  const { width } = useWindowDimensions();
11
11
  const { gap, columnGap, rowGap } = { ...remainingProps, ...computedStyles };
12
- styles.useVariants({ space });
12
+ styles.useVariants({ spacing: space ?? spacing });
13
13
  const getColumnsForWidth = useMemo(() => {
14
14
  // If columns is a number, use that number
15
15
  if (typeof columns === 'number') {
@@ -78,14 +78,14 @@ const styles = StyleSheet.create(theme => ({
78
78
  rowsContainer: {
79
79
  width: '100%',
80
80
  variants: {
81
- space: theme.globalStyle.variants.space,
81
+ spacing: theme.globalStyle.variants.spacing,
82
82
  },
83
83
  },
84
84
  row: {
85
85
  flexDirection: 'row',
86
86
  width: '100%',
87
87
  variants: {
88
- space: theme.globalStyle.variants.space,
88
+ spacing: theme.globalStyle.variants.spacing,
89
89
  },
90
90
  },
91
91
  item: {
@@ -13,6 +13,11 @@ export interface GridProps extends ViewProps {
13
13
  /**
14
14
  * Spacing between grid items (applies to both rows and columns)
15
15
  */
16
+ spacing?: SpacingValues;
17
+ /**
18
+ * Spacing between grid items (applies to both rows and columns)
19
+ * @deprecated Use `spacing` instead. The `space` prop will be removed in a future release.
20
+ */
16
21
  space?: SpacingValues;
17
22
  /**
18
23
  * Gap between items (overrides spacing if provided)
@@ -138,21 +138,31 @@ const styles = StyleSheet.create((theme, rt) => ({
138
138
  variants: {
139
139
  bothButtons: {
140
140
  true: {
141
- paddingBottom: 166 + rt.insets.bottom - theme.components.modal.padding,
141
+ paddingBottom: 166 +
142
+ rt.insets.bottom -
143
+ theme.components.modal.padding +
144
+ theme.components.bottomSheet.padding,
142
145
  },
143
146
  false: {
144
- paddingBottom: 102 + rt.insets.bottom - theme.components.modal.padding,
147
+ paddingBottom: 102 +
148
+ rt.insets.bottom -
149
+ theme.components.modal.padding +
150
+ theme.components.bottomSheet.padding,
145
151
  },
146
152
  },
147
153
  noButtons: {
148
154
  true: {
149
- paddingBottom: rt.insets.bottom + theme.components.modal.padding,
155
+ paddingBottom: rt.insets.bottom +
156
+ theme.components.modal.padding +
157
+ theme.components.bottomSheet.padding,
150
158
  },
151
159
  },
152
160
  stickyFooter: {
153
161
  true: {},
154
162
  false: {
155
- paddingBottom: rt.insets.bottom + theme.components.modal.padding,
163
+ paddingBottom: rt.insets.bottom +
164
+ theme.components.modal.padding +
165
+ theme.components.bottomSheet.padding,
156
166
  },
157
167
  },
158
168
  },
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Flex } from '../Flex';
3
3
  const RadioGroupTextContent = ({ children, ...props }) => {
4
- return (_jsx(Flex, { direction: "column", space: "none", ...props, children: children }));
4
+ return (_jsx(Flex, { direction: "column", spacing: "none", ...props, children: children }));
5
5
  };
6
6
  RadioGroupTextContent.displayName = 'RadioGroupTextContent';
7
7
  export default RadioGroupTextContent;
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { StyleSheet } from 'react-native-unistyles';
3
3
  import { Flex } from '../Flex';
4
4
  const RadioTextContent = ({ children, style, ...props }) => {
5
- return (_jsx(Flex, { direction: "column", space: "none", style: [styles.content, style], ...props, children: children }));
5
+ return (_jsx(Flex, { direction: "column", spacing: "none", style: [styles.content, style], ...props, children: children }));
6
6
  };
7
7
  const styles = StyleSheet.create({
8
8
  content: {
@@ -1,9 +1,7 @@
1
1
  import React from 'react';
2
- import type { ToastContextValue } from './Toast.props';
2
+ import type { ToastContextValue, ToastProviderProps } from './Toast.props';
3
3
  declare const ToastContext: React.Context<ToastContextValue | undefined>;
4
4
  export declare const useToastContext: () => ToastContextValue;
5
- export declare const ToastProvider: React.FC<{
6
- children: React.ReactNode;
7
- }>;
5
+ export declare const ToastProvider: React.FC<ToastProviderProps>;
8
6
  export declare const useToast: () => ToastContextValue;
9
7
  export default ToastContext;
@@ -10,7 +10,7 @@ export const useToastContext = () => {
10
10
  throw new Error('useToastContext must be used within ToastProvider');
11
11
  return ctx;
12
12
  };
13
- export const ToastProvider = ({ children }) => {
13
+ export const ToastProvider = ({ children, safeAreaPadding = true, }) => {
14
14
  const [toasts, setToasts] = useState([]);
15
15
  const timers = useRef({});
16
16
  const toastRefs = useRef({});
@@ -53,6 +53,9 @@ export const ToastProvider = ({ children }) => {
53
53
  }
54
54
  return id;
55
55
  }, [removeToast]);
56
+ styles.useVariants({
57
+ safeAreaPadding,
58
+ });
56
59
  useEffect(() => {
57
60
  return () => {
58
61
  // cleanup timers on unmount
@@ -71,7 +74,7 @@ export const useToast = () => {
71
74
  return ctx;
72
75
  };
73
76
  export default ToastContext;
74
- const styles = StyleSheet.create(theme => ({
77
+ const styles = StyleSheet.create((theme, rt) => ({
75
78
  container: {
76
79
  position: 'absolute',
77
80
  left: 0,
@@ -80,6 +83,15 @@ const styles = StyleSheet.create(theme => ({
80
83
  alignItems: 'stretch',
81
84
  paddingBottom: theme.space['200'],
82
85
  pointerEvents: 'box-none',
86
+ variants: {
87
+ safeAreaPadding: {
88
+ true: {
89
+ paddingBottom: theme.space['200'] + rt.insets.bottom,
90
+ paddingTop: rt.insets.top,
91
+ },
92
+ false: {},
93
+ },
94
+ },
83
95
  },
84
96
  stack: {
85
97
  width: '100%',
@@ -22,6 +22,10 @@ export interface ToastInstance extends ToastOptions {
22
22
  /** resolved duration */
23
23
  duration: number;
24
24
  }
25
+ export interface ToastProviderProps {
26
+ children: ReactNode;
27
+ safeAreaPadding?: boolean;
28
+ }
25
29
  export interface ToastContextValue {
26
30
  addToast: (opts: ToastOptions) => string;
27
31
  removeToast: (id: string) => void;
@@ -81,7 +81,7 @@ const ToastItem = forwardRef(({ toast, onClose }, ref) => {
81
81
  }
82
82
  }
83
83
  };
84
- const toastContent = (_jsxs(View, { style: styles.inner, children: [_jsxs(View, { style: styles.content, children: [IconComp ? (_jsx(View, { style: styles.iconWrap, children: _jsx(Icon, { as: IconComp, style: styles.icon }) })) : null, _jsx(BodyText, { inverted: true, children: toast.text })] }), toast.actionText ? (_jsx(Link, { onPress: handlePress, showIcon: false, inverted: true, children: toast.actionText })) : null, showDismissIcon ? (_jsx(View, { style: styles.actions, children: _jsx(UnstyledIconButton, { icon: CloseSmallIcon, accessibilityLabel: "Dismiss", inverted: true, onPress: () => handleDismiss(false) }) })) : null] }));
84
+ const toastContent = (_jsxs(View, { style: styles.inner, children: [_jsxs(View, { style: styles.content, children: [IconComp ? (_jsx(View, { style: styles.iconWrap, children: _jsx(Icon, { as: IconComp, style: styles.icon }) })) : null, _jsx(BodyText, { inverted: true, style: styles.text, children: toast.text })] }), toast.actionText ? (_jsx(Link, { onPress: handlePress, showIcon: false, inverted: true, children: toast.actionText })) : null, showDismissIcon ? (_jsx(View, { style: styles.actions, children: _jsx(UnstyledIconButton, { icon: CloseSmallIcon, accessibilityLabel: "Dismiss", inverted: true, onPress: () => handleDismiss(false) }) })) : null] }));
85
85
  return (_jsx(GestureDetector, { gesture: panGesture, children: _jsx(AnimatedView, { style: [styles.toast, animatedStyle], ...(Platform.OS === 'ios' && {
86
86
  accessible: true,
87
87
  accessibilityRole: 'alert',
@@ -122,6 +122,7 @@ const styles = StyleSheet.create(theme => ({
122
122
  alignItems: 'center',
123
123
  minWidth: 0,
124
124
  },
125
+ text: { flexShrink: 1 },
125
126
  actions: {
126
127
  flexShrink: 0,
127
128
  },
@@ -1,6 +1,3 @@
1
- import VerificationInputProps from './VerificationInput.props';
2
- declare const VerificationInput: {
3
- ({ value, onChangeText, label, labelVariant, helperText, helperIcon, validationStatus, validText, invalidText, disabled, readonly, secureTextEntry, style, ...props }: VerificationInputProps): import("react/jsx-runtime").JSX.Element;
4
- displayName: string;
5
- };
1
+ import type { VerificationInputHandle, VerificationInputProps } from './VerificationInput.props';
2
+ declare const VerificationInput: import("react").ForwardRefExoticComponent<VerificationInputProps & import("react").RefAttributes<VerificationInputHandle>>;
6
3
  export default VerificationInput;
@@ -1,24 +1,37 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useImperativeHandle } from 'react';
2
3
  import { View } from 'react-native';
3
4
  import { StyleSheet } from 'react-native-unistyles';
4
5
  import { FormField } from '../FormField';
5
6
  import { useVerificationInput } from './useVerificationInput';
6
7
  import { VerificationInputSlot } from './VerificationInputSlot';
7
- const VerificationInput = ({ value = '', onChangeText, label, labelVariant = 'body', helperText, helperIcon, validationStatus = 'initial', validText, invalidText, disabled = false, readonly = false, secureTextEntry = false, style, ...props }) => {
8
+ const VerificationInput = forwardRef(({ value = '', onChangeText, label, labelVariant = 'body', helperText, helperIcon, validationStatus = 'initial', validText, invalidText, disabled = false, readonly = false, secureTextEntry = false, autoFocus = false, style, ...props }, ref) => {
8
9
  const length = 6;
9
- const { inputRefs, focusedIndex, handleFocus, handleBlur, handleChangeText, handleKeyPress } = useVerificationInput({
10
+ const { inputRefs, displayValue, focusedIndex, handleFocus, handleBlur, handleChangeText, handleKeyPress, } = useVerificationInput({
10
11
  value,
11
12
  onChangeText,
12
13
  });
14
+ useImperativeHandle(ref, () => ({
15
+ focus: () => inputRefs.current[0]?.focus(),
16
+ blur: () => {
17
+ inputRefs.current.forEach(input => input?.blur());
18
+ },
19
+ clear: () => onChangeText?.(''),
20
+ focusIndex: (index) => {
21
+ if (index >= 0 && index < length) {
22
+ inputRefs.current[index]?.focus();
23
+ }
24
+ },
25
+ }), [length, onChangeText]);
13
26
  const slots = Array.from({ length }, (_, index) => index);
14
27
  return (_jsx(FormField, { label: label, labelVariant: labelVariant, 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] || '';
28
+ const char = displayValue[index] || '';
16
29
  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));
30
+ return (_jsx(VerificationInputSlot, { ref: inputRef => {
31
+ inputRefs.current[index] = inputRef;
32
+ }, autoFocus: index === 0 && autoFocus, 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
33
  }) }) }));
21
- };
34
+ });
22
35
  const styles = StyleSheet.create(theme => ({
23
36
  root: {
24
37
  gap: theme.components.input.verification.gap,
@@ -1,5 +1,11 @@
1
1
  import type { ComponentType } from 'react';
2
2
  import { ViewProps } from 'react-native';
3
+ export interface VerificationInputHandle {
4
+ focus: () => void;
5
+ blur: () => void;
6
+ clear: () => void;
7
+ focusIndex: (index: number) => void;
8
+ }
3
9
  export interface VerificationInputProps extends ViewProps {
4
10
  /**
5
11
  * The value of the input.
@@ -49,5 +55,9 @@ export interface VerificationInputProps extends ViewProps {
49
55
  * Whether to obscure the text entry (e.g. for passwords/OTPs).
50
56
  */
51
57
  secureTextEntry?: boolean;
58
+ /**
59
+ * Whether the input should auto-focus when mounted.
60
+ */
61
+ autoFocus?: boolean;
52
62
  }
53
63
  export default VerificationInputProps;
@@ -1,4 +1,4 @@
1
1
  import VerificationInput from './VerificationInput';
2
2
  export { default as VerificationInput } from './VerificationInput';
3
- export type { default as VerificationInputProps } from './VerificationInput.props';
3
+ export type { VerificationInputHandle, default as VerificationInputProps, } from './VerificationInput.props';
4
4
  export default VerificationInput;
@@ -5,6 +5,7 @@ interface UseVerificationInputProps {
5
5
  }
6
6
  export declare const useVerificationInput: ({ value, onChangeText }: UseVerificationInputProps) => {
7
7
  inputRefs: import("react").RefObject<(TextInput | null)[]>;
8
+ displayValue: string;
8
9
  focusedIndex: number | null;
9
10
  handleFocus: (index: number) => void;
10
11
  handleBlur: () => void;
@@ -1,19 +1,32 @@
1
- import { useRef, useState } from 'react';
1
+ import { useEffect, useRef, useState } from 'react';
2
2
  export const useVerificationInput = ({ value, onChangeText }) => {
3
3
  const length = 6;
4
4
  const inputRefs = useRef([]);
5
+ const latestValueRef = useRef(value);
6
+ const [displayValue, setDisplayValue] = useState(value);
5
7
  const [focusedIndex, setFocusedIndex] = useState(null);
8
+ useEffect(() => {
9
+ if (value !== latestValueRef.current) {
10
+ latestValueRef.current = value;
11
+ setDisplayValue(value);
12
+ }
13
+ }, [value]);
6
14
  const handleFocus = (index) => {
7
15
  setFocusedIndex(index);
8
16
  };
9
17
  const handleBlur = () => {
10
18
  setFocusedIndex(null);
11
19
  };
20
+ const updateValue = (nextValue) => {
21
+ latestValueRef.current = nextValue;
22
+ setDisplayValue(nextValue);
23
+ onChangeText?.(nextValue);
24
+ };
12
25
  const handleChangeText = (text, index) => {
13
- // Break down the text into an array of characters
26
+ const currentValue = latestValueRef.current;
14
27
  const chars = Array(length).fill('');
15
- for (let i = 0; i < value.length && i < length; i++) {
16
- chars[i] = value[i];
28
+ for (let i = 0; i < currentValue.length && i < length; i++) {
29
+ chars[i] = currentValue[i];
17
30
  }
18
31
  if (text.length > 1) {
19
32
  // Handle paste
@@ -31,24 +44,26 @@ export const useVerificationInput = ({ value, onChangeText }) => {
31
44
  inputRefs.current[index + 1]?.focus();
32
45
  }
33
46
  }
34
- onChangeText?.(chars.join(''));
47
+ updateValue(chars.join(''));
35
48
  };
36
49
  const handleKeyPress = (e, index) => {
37
50
  if (e.nativeEvent.key === 'Backspace') {
38
- if (!value[index] && index > 0) {
51
+ const currentValue = latestValueRef.current;
52
+ if (!currentValue[index] && index > 0) {
39
53
  e.preventDefault();
40
54
  inputRefs.current[index - 1]?.focus();
41
55
  const chars = Array(length).fill('');
42
- for (let i = 0; i < value.length && i < length; i++) {
43
- chars[i] = value[i];
56
+ for (let i = 0; i < currentValue.length && i < length; i++) {
57
+ chars[i] = currentValue[i];
44
58
  }
45
59
  chars[index - 1] = '';
46
- onChangeText?.(chars.join(''));
60
+ updateValue(chars.join(''));
47
61
  }
48
62
  }
49
63
  };
50
64
  return {
51
65
  inputRefs,
66
+ displayValue,
52
67
  focusedIndex,
53
68
  handleFocus,
54
69
  handleBlur,
@@ -718,7 +718,7 @@ export declare const lightTheme: {
718
718
  };
719
719
  };
720
720
  };
721
- readonly space: {
721
+ readonly spacing: {
722
722
  readonly none: {
723
723
  readonly gap: {
724
724
  readonly base: 0;
@@ -2078,7 +2078,7 @@ export declare const darkTheme: {
2078
2078
  };
2079
2079
  };
2080
2080
  };
2081
- readonly space: {
2081
+ readonly spacing: {
2082
2082
  readonly none: {
2083
2083
  readonly gap: {
2084
2084
  readonly base: 0;
@@ -3450,7 +3450,7 @@ export declare const themes: {
3450
3450
  };
3451
3451
  };
3452
3452
  };
3453
- readonly space: {
3453
+ readonly spacing: {
3454
3454
  readonly none: {
3455
3455
  readonly gap: {
3456
3456
  readonly base: 0;
@@ -4810,7 +4810,7 @@ export declare const themes: {
4810
4810
  };
4811
4811
  };
4812
4812
  };
4813
- readonly space: {
4813
+ readonly spacing: {
4814
4814
  readonly none: {
4815
4815
  readonly gap: {
4816
4816
  readonly base: 0;
@@ -191,7 +191,7 @@ const shared = {
191
191
  },
192
192
  },
193
193
  },
194
- space: {
194
+ spacing: {
195
195
  none: {
196
196
  gap: {
197
197
  base: layout.mobile.spacing.none,
@@ -26,5 +26,5 @@ export type ColorValue = 'currentColor' | 'transparent' | FlattenColorKeys<Omit<
26
26
  export type BorderRadiusValue = `${keyof (typeof lightTheme)['borderRadius'] & (string | number)}` | AnimatableNumericValue | undefined;
27
27
  export type BordeWidthValue = `${keyof (typeof lightTheme)['borderWidth'] & (string | number)}` | number | undefined;
28
28
  export type OpacityValue = AnimatableNumericValue | undefined;
29
- export type SpacingValues = keyof (typeof themes)['light']['globalStyle']['variants']['space'];
29
+ export type SpacingValues = keyof (typeof themes)['light']['globalStyle']['variants']['spacing'];
30
30
  export {};