@utilitywarehouse/hearth-react-native 0.18.0 → 0.19.1

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 (147) hide show
  1. package/.storybook/preview.tsx +1 -0
  2. package/.turbo/turbo-build.log +1 -1
  3. package/.turbo/turbo-lint.log +24 -21
  4. package/CHANGELOG.md +128 -0
  5. package/build/components/Banner/Banner.d.ts +1 -1
  6. package/build/components/Banner/Banner.js +24 -4
  7. package/build/components/Banner/Banner.props.d.ts +1 -6
  8. package/build/components/Box/Box.props.d.ts +5 -2
  9. package/build/components/Button/Button.d.ts +2 -0
  10. package/build/components/Button/ButtonGroupRoot.d.ts +5 -1
  11. package/build/components/Button/ButtonGroupRoot.js +3 -3
  12. package/build/components/Card/Card.context.d.ts +1 -1
  13. package/build/components/Card/Card.props.d.ts +2 -0
  14. package/build/components/Card/CardContent.js +3 -3
  15. package/build/components/Card/CardRoot.d.ts +1 -1
  16. package/build/components/Card/CardRoot.js +14 -4
  17. package/build/components/Checkbox/CheckboxGroupTextContent.js +1 -1
  18. package/build/components/Checkbox/CheckboxTextContent.js +1 -1
  19. package/build/components/Container/Container.d.ts +1 -1
  20. package/build/components/Container/Container.js +3 -3
  21. package/build/components/Container/Container.props.d.ts +5 -0
  22. package/build/components/Divider/Divider.d.ts +1 -1
  23. package/build/components/Divider/Divider.js +19 -19
  24. package/build/components/Divider/Divider.props.d.ts +6 -0
  25. package/build/components/ExpandableCard/ExpandableCardExpandedContent.js +1 -1
  26. package/build/components/Flex/Flex.d.ts +1 -1
  27. package/build/components/Flex/Flex.js +3 -3
  28. package/build/components/Flex/Flex.props.d.ts +5 -0
  29. package/build/components/Grid/Grid.d.ts +1 -1
  30. package/build/components/Grid/Grid.js +4 -4
  31. package/build/components/Grid/Grid.props.d.ts +5 -0
  32. package/build/components/Menu/Menu.d.ts +1 -1
  33. package/build/components/Menu/Menu.js +2 -2
  34. package/build/components/Menu/Menu.props.d.ts +2 -6
  35. package/build/components/Modal/Modal.d.ts +1 -1
  36. package/build/components/Modal/Modal.js +16 -6
  37. package/build/components/Modal/Modal.props.d.ts +1 -0
  38. package/build/components/Modal/Modal.web.d.ts +1 -1
  39. package/build/components/Modal/Modal.web.js +2 -2
  40. package/build/components/Radio/RadioGroupTextContent.js +1 -1
  41. package/build/components/Radio/RadioTextContent.js +1 -1
  42. package/build/components/Toast/Toast.context.d.ts +2 -4
  43. package/build/components/Toast/Toast.context.js +14 -2
  44. package/build/components/Toast/Toast.props.d.ts +4 -0
  45. package/build/components/Toast/ToastItem.js +5 -2
  46. package/build/components/VerificationInput/VerificationInput.d.ts +2 -5
  47. package/build/components/VerificationInput/VerificationInput.js +20 -7
  48. package/build/components/VerificationInput/VerificationInput.props.d.ts +10 -0
  49. package/build/components/VerificationInput/index.d.ts +1 -1
  50. package/build/components/VerificationInput/useVerificationInput.d.ts +1 -0
  51. package/build/components/VerificationInput/useVerificationInput.js +24 -9
  52. package/build/core/themes.d.ts +4 -4
  53. package/build/core/themes.js +1 -1
  54. package/build/types/values.d.ts +1 -1
  55. package/docs/changelog.mdx +687 -0
  56. package/docs/components/AllComponents.web.tsx +9 -9
  57. package/docs/layout-components.docs.mdx +3 -3
  58. package/package.json +7 -7
  59. package/scripts/copyChangelog.js +50 -0
  60. package/src/components/Alert/Alert.stories.tsx +1 -1
  61. package/src/components/Avatar/Avatar.stories.tsx +4 -5
  62. package/src/components/Badge/Badge.stories.tsx +3 -3
  63. package/src/components/Banner/Banner.docs.mdx +1 -1
  64. package/src/components/Banner/Banner.props.ts +13 -20
  65. package/src/components/Banner/Banner.stories.tsx +83 -15
  66. package/src/components/Banner/Banner.tsx +27 -3
  67. package/src/components/Box/Box.props.ts +11 -4
  68. package/src/components/Button/Button.docs.mdx +2 -2
  69. package/src/components/Button/Button.stories.tsx +4 -4
  70. package/src/components/Button/ButtonGroupRoot.tsx +8 -3
  71. package/src/components/Card/Card.context.ts +1 -1
  72. package/src/components/Card/Card.docs.mdx +1 -1
  73. package/src/components/Card/Card.props.ts +2 -0
  74. package/src/components/Card/Card.stories.tsx +9 -9
  75. package/src/components/Card/CardAction/CardAction.stories.tsx +2 -2
  76. package/src/components/Card/CardContent.tsx +3 -3
  77. package/src/components/Card/CardRoot.tsx +15 -5
  78. package/src/components/Checkbox/CheckboxGroupTextContent.tsx +2 -2
  79. package/src/components/Checkbox/CheckboxTextContent.tsx +1 -1
  80. package/src/components/Container/Container.docs.mdx +2 -2
  81. package/src/components/Container/Container.props.ts +5 -0
  82. package/src/components/Container/Container.stories.tsx +2 -2
  83. package/src/components/Container/Container.tsx +3 -3
  84. package/src/components/CurrencyInput/CurrencyInput.docs.mdx +1 -1
  85. package/src/components/CurrencyInput/CurrencyInput.stories.tsx +2 -2
  86. package/src/components/DateInput/DateInput.stories.tsx +3 -3
  87. package/src/components/DatePickerInput/DatePickerInput.stories.tsx +1 -1
  88. package/src/components/DescriptionList/DescriptionList.stories.tsx +1 -1
  89. package/src/components/Divider/Divider.docs.mdx +6 -6
  90. package/src/components/Divider/Divider.props.ts +6 -0
  91. package/src/components/Divider/Divider.tsx +19 -18
  92. package/src/components/ExpandableCard/ExpandableCardExpandedContent.tsx +1 -1
  93. package/src/components/Flex/Flex.docs.mdx +3 -3
  94. package/src/components/Flex/Flex.props.ts +5 -0
  95. package/src/components/Flex/Flex.stories.tsx +2 -2
  96. package/src/components/Flex/Flex.tsx +4 -3
  97. package/src/components/FormField/FormField.docs.mdx +1 -1
  98. package/src/components/FormField/FormField.stories.tsx +1 -1
  99. package/src/components/Grid/Grid.docs.mdx +5 -5
  100. package/src/components/Grid/Grid.props.ts +6 -0
  101. package/src/components/Grid/Grid.stories.tsx +8 -8
  102. package/src/components/Grid/Grid.tsx +4 -3
  103. package/src/components/HighlightBanner/HighlightBanner.docs.mdx +1 -1
  104. package/src/components/HighlightBanner/HighlightBanner.stories.tsx +2 -2
  105. package/src/components/Icon/Icon.docs.mdx +3 -3
  106. package/src/components/IconButton/IconButton.stories.tsx +5 -5
  107. package/src/components/IconContainer/IconContainer.docs.mdx +1 -1
  108. package/src/components/IconContainer/IconContainer.stories.tsx +3 -3
  109. package/src/components/IndicatorIconButton/IndicatorIconButton.stories.tsx +17 -9
  110. package/src/components/InlineLink/InlineLink.stories.tsx +2 -2
  111. package/src/components/Input/Input.stories.tsx +4 -4
  112. package/src/components/List/List.stories.tsx +1 -1
  113. package/src/components/Menu/Menu.docs.mdx +8 -5
  114. package/src/components/Menu/Menu.figma.tsx +27 -27
  115. package/src/components/Menu/Menu.props.ts +2 -6
  116. package/src/components/Menu/Menu.tsx +3 -6
  117. package/src/components/Menu/MenuItem.figma.tsx +26 -18
  118. package/src/components/Modal/Modal.docs.mdx +22 -21
  119. package/src/components/Modal/Modal.figma.tsx +58 -47
  120. package/src/components/Modal/Modal.props.ts +1 -0
  121. package/src/components/Modal/Modal.stories.tsx +4 -0
  122. package/src/components/Modal/Modal.tsx +20 -5
  123. package/src/components/Modal/Modal.web.tsx +2 -1
  124. package/src/components/PillGroup/PillGroup.stories.tsx +7 -7
  125. package/src/components/ProgressStepper/ProgressStepper.stories.tsx +7 -8
  126. package/src/components/Radio/Radio.stories.tsx +1 -1
  127. package/src/components/Radio/RadioGroup.stories.tsx +1 -1
  128. package/src/components/Radio/RadioGroupTextContent.tsx +2 -2
  129. package/src/components/Radio/RadioTextContent.tsx +1 -1
  130. package/src/components/SectionHeader/SectionHeader.stories.tsx +1 -1
  131. package/src/components/Switch/Switch.docs.mdx +8 -8
  132. package/src/components/Switch/Switch.stories.tsx +2 -2
  133. package/src/components/Tabs/Tabs.stories.tsx +1 -1
  134. package/src/components/Textarea/Textarea.docs.mdx +3 -3
  135. package/src/components/Toast/Toast.context.tsx +24 -3
  136. package/src/components/Toast/Toast.props.ts +5 -0
  137. package/src/components/Toast/Toast.stories.tsx +29 -0
  138. package/src/components/Toast/ToastItem.tsx +7 -2
  139. package/src/components/UnstyledIconButton/UnstyledIconButton.stories.tsx +5 -5
  140. package/src/components/VerificationInput/VerificationInput.docs.mdx +31 -8
  141. package/src/components/VerificationInput/VerificationInput.props.ts +11 -0
  142. package/src/components/VerificationInput/VerificationInput.stories.tsx +79 -3
  143. package/src/components/VerificationInput/VerificationInput.tsx +94 -62
  144. package/src/components/VerificationInput/index.ts +4 -2
  145. package/src/components/VerificationInput/useVerificationInput.ts +26 -10
  146. package/src/core/themes.ts +1 -1
  147. 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)
@@ -1,4 +1,4 @@
1
1
  import type MenuProps from './Menu.props';
2
2
  import type { MenuMethods } from './Menu.props';
3
- declare const Menu: import("react").ForwardRefExoticComponent<MenuProps & import("react").RefAttributes<MenuMethods>>;
3
+ declare const Menu: import("react").ForwardRefExoticComponent<Omit<MenuProps, "ref"> & import("react").RefAttributes<MenuMethods>>;
4
4
  export default Menu;
@@ -4,7 +4,7 @@ import { StyleSheet } from 'react-native-unistyles';
4
4
  import { BodyText } from '../BodyText';
5
5
  import { BottomSheetModal, BottomSheetScrollView } from '../BottomSheet';
6
6
  import { MenuContext } from './Menu.context';
7
- const Menu = forwardRef(({ heading, children, bottomSheetProps }, ref) => {
7
+ const Menu = forwardRef(({ heading, children, ...props }, ref) => {
8
8
  const bottomSheetModalRef = useRef(null);
9
9
  useImperativeHandle(ref, () => ({
10
10
  present: () => bottomSheetModalRef.current?.present(),
@@ -14,7 +14,7 @@ const Menu = forwardRef(({ heading, children, bottomSheetProps }, ref) => {
14
14
  bottomSheetModalRef.current?.dismiss();
15
15
  }, []);
16
16
  const contextValue = useMemo(() => ({ close: handleClose }), [handleClose]);
17
- return (_jsx(BottomSheetModal, { ref: bottomSheetModalRef, ...bottomSheetProps, children: _jsx(BottomSheetScrollView, { contentContainerStyle: styles.container, children: _jsxs(MenuContext.Provider, { value: contextValue, children: [heading && (_jsx(BodyText, { size: "md", weight: "semibold", children: heading })), children] }) }) }));
17
+ return (_jsx(BottomSheetModal, { ref: bottomSheetModalRef, ...props, children: _jsx(BottomSheetScrollView, { contentContainerStyle: styles.container, children: _jsxs(MenuContext.Provider, { value: contextValue, children: [heading && (_jsx(BodyText, { size: "md", weight: "semibold", children: heading })), children] }) }) }));
18
18
  });
19
19
  Menu.displayName = 'Menu';
20
20
  const styles = StyleSheet.create(theme => ({
@@ -1,10 +1,10 @@
1
- import type { BottomSheetModalProps } from '@gorhom/bottom-sheet';
2
1
  import type { ReactNode } from 'react';
2
+ import { BottomSheetProps } from '../BottomSheet';
3
3
  export interface MenuMethods {
4
4
  present: () => void;
5
5
  dismiss: () => void;
6
6
  }
7
- export interface MenuProps {
7
+ export interface MenuProps extends BottomSheetProps {
8
8
  /**
9
9
  * Heading text displayed at the top of the menu
10
10
  */
@@ -13,9 +13,5 @@ export interface MenuProps {
13
13
  * Menu items to display
14
14
  */
15
15
  children: ReactNode;
16
- /**
17
- * Optional bottom sheet modal props to customise the menu behavior
18
- */
19
- bottomSheetProps?: Partial<BottomSheetModalProps>;
20
16
  }
21
17
  export default MenuProps;
@@ -3,5 +3,5 @@ import ModalProps from './Modal.props';
3
3
  type Modal<T = any> = BottomSheetModalMethods<T> & {
4
4
  triggerCloseAnimation?: () => void;
5
5
  };
6
- declare const Modal: ({ ref, children, heading, description, showCloseButton, primaryButtonText, secondaryButtonText, onPressPrimaryButton, onPressCloseButton, onPressSecondaryButton, closeOnPrimaryButtonPress, closeOnSecondaryButtonPress, loading, fullscreen, image, primaryButtonProps, secondaryButtonProps, closeButtonProps, inNavModal, stickyFooter, ...props }: ModalProps) => import("react/jsx-runtime").JSX.Element;
6
+ declare const Modal: ({ ref, children, heading, description, showCloseButton, primaryButtonText, secondaryButtonText, onPressPrimaryButton, onPressCloseButton, onPressSecondaryButton, closeOnPrimaryButtonPress, closeOnSecondaryButtonPress, loading, loadingHeading, fullscreen, image, primaryButtonProps, secondaryButtonProps, closeButtonProps, inNavModal, stickyFooter, ...props }: ModalProps) => import("react/jsx-runtime").JSX.Element;
7
7
  export default Modal;
@@ -13,7 +13,7 @@ import { Button } from '../Button';
13
13
  import { Heading } from '../Heading';
14
14
  import { Spinner } from '../Spinner';
15
15
  import { UnstyledIconButton } from '../UnstyledIconButton';
16
- const Modal = ({ ref, children, heading, description, showCloseButton = true, primaryButtonText, secondaryButtonText, onPressPrimaryButton, onPressCloseButton, onPressSecondaryButton, closeOnPrimaryButtonPress = true, closeOnSecondaryButtonPress = true, loading, fullscreen = false, image, primaryButtonProps, secondaryButtonProps, closeButtonProps, inNavModal = false, stickyFooter = true, ...props }) => {
16
+ const Modal = ({ ref, children, heading, description, showCloseButton = true, primaryButtonText, secondaryButtonText, onPressPrimaryButton, onPressCloseButton, onPressSecondaryButton, closeOnPrimaryButtonPress = true, closeOnSecondaryButtonPress = true, loading, loadingHeading = 'Loading...', fullscreen = false, image, primaryButtonProps, secondaryButtonProps, closeButtonProps, inNavModal = false, stickyFooter = true, ...props }) => {
17
17
  const bottomSheetModalRef = useRef(null);
18
18
  const viewRef = useRef(null);
19
19
  const scrollViewRef = useRef(null);
@@ -107,7 +107,7 @@ const Modal = ({ ref, children, heading, description, showCloseButton = true, pr
107
107
  showHandle: props.showHandle,
108
108
  });
109
109
  const footer = (_jsxs(View, { style: styles.footer, children: [onPressPrimaryButton && primaryButtonText ? (_jsx(Button, { onPress: handlePrimaryButtonPress, text: primaryButtonText, ...primaryButtonProps, variant: primaryButtonProps?.variant ?? 'solid', colorScheme: primaryButtonProps?.colorScheme ?? 'highlight' })) : null, onPressSecondaryButton && secondaryButtonText ? (_jsx(Button, { onPress: handleSecondaryButtonPress, text: secondaryButtonText, ...secondaryButtonProps, variant: secondaryButtonProps?.variant ?? 'outline', colorScheme: secondaryButtonProps?.colorScheme ?? 'functional' })) : null] }));
110
- const content = (_jsx(_Fragment, { children: loading ? (_jsxs(View, { style: styles.loadingContainer, accessible: Platform.OS === 'android' ? true : undefined, accessibilityLabel: Platform.OS === 'android' ? 'Loading' : undefined, screenReaderFocusable: true, ref: viewRef, children: [_jsx(Spinner, { size: "lg" }), _jsx(Heading, { size: "lg", textAlign: "center", children: "Loading..." })] })) : (_jsxs(View, { style: styles.container, accessible: Platform.OS === 'android' ? true : undefined, accessibilityLabel: Platform.OS === 'android' ? 'Modal content' : undefined, screenReaderFocusable: true, ref: viewRef, children: [_jsxs(View, { style: styles.header, children: [_jsxs(View, { style: styles.headerTextContent, children: [heading && !image ? (_jsx(Heading, { size: "lg", accessible: true, children: heading })) : null, description && !image ? _jsx(BodyText, { accessible: true, children: description }) : null] }), showCloseButton ? (_jsx(UnstyledIconButton, { icon: CloseMediumIcon, onPress: handleCloseButtonPress, accessibilityLabel: "Close modal", ...closeButtonProps })) : null] }), image ? (_jsxs(View, { style: styles.imageContainer, children: [image, _jsxs(View, { style: styles.textContent, children: [heading ? (_jsx(Heading, { size: "lg", textAlign: "center", accessible: true, children: heading })) : null, description ? (_jsx(BodyText, { textAlign: "center", accessible: true, children: description })) : null] })] })) : null, children, !stickyFooter && !noButtons ? footer : null] })) }));
110
+ const content = (_jsx(_Fragment, { children: loading ? (_jsxs(View, { style: styles.loadingContainer, accessible: Platform.OS === 'android' ? true : undefined, accessibilityLabel: Platform.OS === 'android' ? 'Loading' : undefined, screenReaderFocusable: true, ref: viewRef, children: [_jsx(Spinner, { size: "lg" }), _jsx(Heading, { size: "lg", textAlign: "center", children: loadingHeading })] })) : (_jsxs(View, { style: styles.container, accessible: Platform.OS === 'android' ? true : undefined, accessibilityLabel: Platform.OS === 'android' ? 'Modal content' : undefined, screenReaderFocusable: true, ref: viewRef, children: [_jsxs(View, { style: styles.header, children: [_jsxs(View, { style: styles.headerTextContent, children: [heading && !image ? (_jsx(Heading, { size: "lg", accessible: true, children: heading })) : null, description && !image ? _jsx(BodyText, { accessible: true, children: description }) : null] }), showCloseButton ? (_jsx(UnstyledIconButton, { icon: CloseMediumIcon, onPress: handleCloseButtonPress, accessibilityLabel: "Close modal", ...closeButtonProps })) : null] }), image ? (_jsxs(View, { style: styles.imageContainer, children: [image, _jsxs(View, { style: styles.textContent, children: [heading ? (_jsx(Heading, { size: "lg", textAlign: "center", accessible: true, children: heading })) : null, description ? (_jsx(BodyText, { textAlign: "center", accessible: true, children: description })) : null] })] })) : null, children, !stickyFooter && !noButtons ? footer : null] })) }));
111
111
  const renderFooter = useCallback((props) => (_jsx(BottomSheetFooter, { ...props, children: _jsx(View, { style: styles.footerWrap, children: footer }) })), [
112
112
  onPressPrimaryButton,
113
113
  primaryButtonText,
@@ -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
  },
@@ -8,6 +8,7 @@ interface ModalProps extends Omit<BottomSheetProps, 'children'> {
8
8
  image?: ReactNode;
9
9
  showCloseButton?: boolean;
10
10
  heading?: string;
11
+ loadingHeading?: string;
11
12
  description?: string;
12
13
  inNavModal?: boolean;
13
14
  fullscreen?: boolean;
@@ -3,5 +3,5 @@ import ModalProps from './Modal.props';
3
3
  type Modal<T = any> = BottomSheetModalMethods<T> & {
4
4
  triggerCloseAnimation?: () => void;
5
5
  };
6
- declare const Modal: ({ ref, children, heading, description, showCloseButton, primaryButtonText, secondaryButtonText, onPressPrimaryButton, onPressCloseButton, onPressSecondaryButton, closeOnPrimaryButtonPress, closeOnSecondaryButtonPress, loading, image, primaryButtonProps, secondaryButtonProps, closeButtonProps, inNavModal, ...props }: ModalProps) => import("react/jsx-runtime").JSX.Element;
6
+ declare const Modal: ({ ref, children, heading, description, showCloseButton, primaryButtonText, secondaryButtonText, onPressPrimaryButton, onPressCloseButton, onPressSecondaryButton, closeOnPrimaryButtonPress, closeOnSecondaryButtonPress, loading, loadingHeading, image, primaryButtonProps, secondaryButtonProps, closeButtonProps, inNavModal, ...props }: ModalProps) => import("react/jsx-runtime").JSX.Element;
7
7
  export default Modal;
@@ -12,7 +12,7 @@ import { Button } from '../Button';
12
12
  import { Heading } from '../Heading';
13
13
  import { Spinner } from '../Spinner';
14
14
  import { UnstyledIconButton } from '../UnstyledIconButton';
15
- const Modal = ({ ref, children, heading, description, showCloseButton = true, primaryButtonText, secondaryButtonText, onPressPrimaryButton, onPressCloseButton, onPressSecondaryButton, closeOnPrimaryButtonPress = true, closeOnSecondaryButtonPress = true, loading, image, primaryButtonProps, secondaryButtonProps, closeButtonProps, inNavModal = false, ...props }) => {
15
+ const Modal = ({ ref, children, heading, description, showCloseButton = true, primaryButtonText, secondaryButtonText, onPressPrimaryButton, onPressCloseButton, onPressSecondaryButton, closeOnPrimaryButtonPress = true, closeOnSecondaryButtonPress = true, loading, loadingHeading = 'Loading...', image, primaryButtonProps, secondaryButtonProps, closeButtonProps, inNavModal = false, ...props }) => {
16
16
  const bottomSheetModalRef = useRef(null);
17
17
  const viewRef = useRef(null);
18
18
  const scrollViewRef = useRef(null);
@@ -97,7 +97,7 @@ const Modal = ({ ref, children, heading, description, showCloseButton = true, pr
97
97
  bottomSheetModalRef.current?.dismiss();
98
98
  }
99
99
  };
100
- const content = (_jsx(_Fragment, { children: loading ? (_jsxs(View, { style: styles.loadingContainer, accessible: Platform.OS === 'android' ? true : undefined, accessibilityLabel: Platform.OS === 'android' ? 'Loading' : undefined, screenReaderFocusable: true, ref: viewRef, children: [_jsx(Spinner, { size: "lg" }), _jsx(Heading, { size: "lg", textAlign: "center", children: "Loading..." })] })) : (_jsxs(View, { style: styles.container, accessible: Platform.OS === 'android' ? true : undefined, accessibilityLabel: Platform.OS === 'android' ? 'Modal content' : undefined, screenReaderFocusable: true, ref: viewRef, children: [_jsxs(View, { style: styles.header, children: [_jsxs(View, { style: styles.headerTextContent, children: [heading && !image ? (_jsx(Heading, { size: "lg", accessible: true, children: heading })) : null, description && !image ? _jsx(BodyText, { accessible: true, children: description }) : null] }), showCloseButton ? (_jsx(UnstyledIconButton, { icon: CloseMediumIcon, onPress: handleCloseButtonPress, accessibilityLabel: "Close modal", ...closeButtonProps })) : null] }), image ? (_jsxs(View, { style: styles.imageContainer, children: [image, _jsxs(View, { style: styles.textContent, children: [heading ? (_jsx(Heading, { size: "lg", textAlign: "center", accessible: true, children: heading })) : null, description ? (_jsx(BodyText, { textAlign: "center", accessible: true, children: description })) : null] })] })) : null, children, _jsxs(View, { style: styles.footer, children: [onPressPrimaryButton && primaryButtonText ? (_jsx(Button, { onPress: handlePrimaryButtonPress, text: primaryButtonText, ...primaryButtonProps, variant: primaryButtonProps?.variant ?? 'solid', colorScheme: primaryButtonProps?.colorScheme ?? 'highlight' })) : null, onPressSecondaryButton && secondaryButtonText ? (_jsx(Button, { onPress: handleSecondaryButtonPress, text: secondaryButtonText, ...secondaryButtonProps, variant: secondaryButtonProps?.variant ?? 'outline', colorScheme: secondaryButtonProps?.colorScheme ?? 'functional' })) : null] })] })) }));
100
+ const content = (_jsx(_Fragment, { children: loading ? (_jsxs(View, { style: styles.loadingContainer, accessible: Platform.OS === 'android' ? true : undefined, accessibilityLabel: Platform.OS === 'android' ? 'Loading' : undefined, screenReaderFocusable: true, ref: viewRef, children: [_jsx(Spinner, { size: "lg" }), _jsx(Heading, { size: "lg", textAlign: "center", children: loadingHeading })] })) : (_jsxs(View, { style: styles.container, accessible: Platform.OS === 'android' ? true : undefined, accessibilityLabel: Platform.OS === 'android' ? 'Modal content' : undefined, screenReaderFocusable: true, ref: viewRef, children: [_jsxs(View, { style: styles.header, children: [_jsxs(View, { style: styles.headerTextContent, children: [heading && !image ? (_jsx(Heading, { size: "lg", accessible: true, children: heading })) : null, description && !image ? _jsx(BodyText, { accessible: true, children: description }) : null] }), showCloseButton ? (_jsx(UnstyledIconButton, { icon: CloseMediumIcon, onPress: handleCloseButtonPress, accessibilityLabel: "Close modal", ...closeButtonProps })) : null] }), image ? (_jsxs(View, { style: styles.imageContainer, children: [image, _jsxs(View, { style: styles.textContent, children: [heading ? (_jsx(Heading, { size: "lg", textAlign: "center", accessible: true, children: heading })) : null, description ? (_jsx(BodyText, { textAlign: "center", accessible: true, children: description })) : null] })] })) : null, children, _jsxs(View, { style: styles.footer, children: [onPressPrimaryButton && primaryButtonText ? (_jsx(Button, { onPress: handlePrimaryButtonPress, text: primaryButtonText, ...primaryButtonProps, variant: primaryButtonProps?.variant ?? 'solid', colorScheme: primaryButtonProps?.colorScheme ?? 'highlight' })) : null, onPressSecondaryButton && secondaryButtonText ? (_jsx(Button, { onPress: handleSecondaryButtonPress, text: secondaryButtonText, ...secondaryButtonProps, variant: secondaryButtonProps?.variant ?? 'outline', colorScheme: secondaryButtonProps?.colorScheme ?? 'functional' })) : null] })] })) }));
101
101
  return inNavModal ? (_jsxs(View, { style: { flex: 1, backgroundColor: theme.color.background.primary }, children: [Platform.OS === 'android' ? (_jsx(Animated.View, { style: [styles.androidContainer, animatedBackgroundStyle], children: _jsx(Animated.View, { style: [styles.pretendContent, animatedPretendContentStyle] }) })) : null, _jsx(Animated.View, { style: [styles.inNavModalContainer, Platform.OS === 'android' && animatedInNavModalStyle], children: _jsx(View, { style: styles.inNavModalContent, children: content }) })] })) : (_jsx(BottomSheetModal, { ref: bottomSheetModalRef, enableDynamicSizing: true, snapPoints: image ? ['90%'] : props.snapPoints, showHandle: typeof loading !== 'undefined' && loading ? false : props.showHandle, accessible: false, ...props, onChange: handleChange, children: _jsx(BottomSheetScrollView, { contentContainerStyle: styles.container, ref: scrollViewRef, children: content }) }));
102
102
  };
103
103
  const styles = StyleSheet.create((theme, rt) => ({
@@ -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',
@@ -109,7 +109,8 @@ const styles = StyleSheet.create(theme => ({
109
109
  width: 24,
110
110
  height: 24,
111
111
  justifyContent: 'center',
112
- alignItems: 'center',
112
+ alignSelf: 'flex-start',
113
+ alignItems: 'flex-start',
113
114
  flexShrink: 0,
114
115
  },
115
116
  icon: {
@@ -122,8 +123,10 @@ const styles = StyleSheet.create(theme => ({
122
123
  alignItems: 'center',
123
124
  minWidth: 0,
124
125
  },
126
+ text: { flexShrink: 1 },
125
127
  actions: {
126
128
  flexShrink: 0,
129
+ alignSelf: 'flex-start',
127
130
  },
128
131
  }));
129
132
  export default ToastItem;
@@ -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,