@hero-design/rn 8.20.0 → 8.21.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 (44) hide show
  1. package/.turbo/turbo-build.log +9 -9
  2. package/es/index.js +190 -60
  3. package/lib/index.js +190 -60
  4. package/package.json +5 -5
  5. package/src/components/Button/Button.tsx +1 -1
  6. package/src/components/Button/StyledButton.tsx +0 -3
  7. package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +0 -10
  8. package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +0 -16
  9. package/src/components/Calendar/index.tsx +7 -2
  10. package/src/components/Carousel/StyledCarousel.tsx +11 -3
  11. package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +791 -6
  12. package/src/components/Carousel/__tests__/index.spec.tsx +41 -31
  13. package/src/components/Carousel/index.tsx +39 -7
  14. package/src/components/DatePicker/DatePickerAndroid.tsx +1 -1
  15. package/src/components/DatePicker/DatePickerCalendar.tsx +110 -0
  16. package/src/components/DatePicker/DatePickerIOS.tsx +1 -1
  17. package/src/components/DatePicker/__tests__/DatePicker.spec.tsx +27 -8
  18. package/src/components/DatePicker/__tests__/DatePickerCalendar.spec.tsx +61 -0
  19. package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +670 -0
  20. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +220 -0
  21. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +0 -1
  22. package/src/components/DatePicker/index.tsx +5 -1
  23. package/src/components/DatePicker/types.ts +7 -1
  24. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +0 -3
  25. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +0 -1
  26. package/src/components/TimePicker/types.ts +1 -1
  27. package/src/components/Toast/Toast.tsx +3 -1
  28. package/src/components/Toast/types.ts +4 -0
  29. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +2 -3
  30. package/src/theme/components/button.ts +0 -5
  31. package/src/theme/components/carousel.ts +3 -0
  32. package/types/components/Calendar/index.d.ts +6 -2
  33. package/types/components/Carousel/StyledCarousel.d.ts +7 -1
  34. package/types/components/Carousel/index.d.ts +7 -1
  35. package/types/components/DatePicker/DatePickerAndroid.d.ts +1 -1
  36. package/types/components/DatePicker/DatePickerCalendar.d.ts +3 -0
  37. package/types/components/DatePicker/DatePickerIOS.d.ts +1 -1
  38. package/types/components/DatePicker/index.d.ts +1 -1
  39. package/types/components/DatePicker/types.d.ts +7 -1
  40. package/types/components/TimePicker/types.d.ts +1 -1
  41. package/types/components/Toast/Toast.d.ts +1 -1
  42. package/types/components/Toast/types.d.ts +4 -0
  43. package/types/theme/components/button.d.ts +0 -3
  44. package/types/theme/components/carousel.d.ts +2 -0
@@ -0,0 +1,220 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`DatePickerCalendar renders correctly 1`] = `
4
+ <View
5
+ accessibilityState={
6
+ Object {
7
+ "disabled": false,
8
+ }
9
+ }
10
+ accessible={true}
11
+ collapsable={false}
12
+ focusable={true}
13
+ onClick={[Function]}
14
+ onResponderGrant={[Function]}
15
+ onResponderMove={[Function]}
16
+ onResponderRelease={[Function]}
17
+ onResponderTerminate={[Function]}
18
+ onResponderTerminationRequest={[Function]}
19
+ onStartShouldSetResponder={[Function]}
20
+ style={
21
+ Object {
22
+ "opacity": 1,
23
+ }
24
+ }
25
+ >
26
+ <View
27
+ pointerEvents="none"
28
+ testID="datePickerCalendar"
29
+ >
30
+ <View
31
+ pointerEvents="auto"
32
+ style={
33
+ Array [
34
+ Object {
35
+ "marginTop": 8,
36
+ "width": "100%",
37
+ },
38
+ undefined,
39
+ ]
40
+ }
41
+ >
42
+ <View
43
+ style={
44
+ Array [
45
+ Object {
46
+ "alignItems": "center",
47
+ "backgroundColor": "#ffffff",
48
+ "borderRadius": 8,
49
+ "flexDirection": "row",
50
+ "padding": 16,
51
+ },
52
+ undefined,
53
+ ]
54
+ }
55
+ >
56
+ <View
57
+ style={
58
+ Array [
59
+ Object {
60
+ "borderColor": "#001f23",
61
+ "borderRadius": 8,
62
+ "borderWidth": 1,
63
+ "bottom": 0,
64
+ "left": 0,
65
+ "position": "absolute",
66
+ "right": 0,
67
+ "top": 0,
68
+ },
69
+ Array [
70
+ Object {
71
+ "backgroundColor": "#ffffff",
72
+ },
73
+ undefined,
74
+ ],
75
+ ]
76
+ }
77
+ testID="text-input-border"
78
+ themeFocused={false}
79
+ themeVariant="filled"
80
+ />
81
+ <View
82
+ pointerEvents="none"
83
+ style={
84
+ Array [
85
+ Object {
86
+ "backgroundColor": "#ffffff",
87
+ "flexDirection": "row",
88
+ "left": 16,
89
+ "paddingHorizontal": 4,
90
+ "position": "absolute",
91
+ "top": -10,
92
+ "zIndex": 1,
93
+ },
94
+ Object {
95
+ "backgroundColor": "#ffffff",
96
+ },
97
+ ]
98
+ }
99
+ testID="label-container"
100
+ >
101
+ <Text
102
+ allowFontScaling={false}
103
+ style={
104
+ Array [
105
+ Object {
106
+ "color": "#001f23",
107
+ "fontFamily": "BeVietnamPro-Regular",
108
+ "fontSize": 12,
109
+ "letterSpacing": 0.36,
110
+ "lineHeight": 20,
111
+ },
112
+ Array [
113
+ Object {
114
+ "color": "#001f23",
115
+ },
116
+ Object {
117
+ "backgroundColor": "#ffffff",
118
+ },
119
+ ],
120
+ ]
121
+ }
122
+ testID="input-label"
123
+ themeFontSize="small"
124
+ themeFontWeight="regular"
125
+ themeIntent="body"
126
+ themeTypeface="neutral"
127
+ themeVariant="filled"
128
+ >
129
+ Start date
130
+ </Text>
131
+ </View>
132
+ <View
133
+ style={
134
+ Array [
135
+ Object {
136
+ "alignItems": "center",
137
+ "alignSelf": "stretch",
138
+ "flexDirection": "row",
139
+ "flexGrow": 2,
140
+ "flexShrink": 1,
141
+ },
142
+ undefined,
143
+ ]
144
+ }
145
+ >
146
+ <TextInput
147
+ accessibilityState={
148
+ Object {
149
+ "disabled": false,
150
+ }
151
+ }
152
+ allowFontScaling={false}
153
+ editable={true}
154
+ onBlur={[Function]}
155
+ onChangeText={[Function]}
156
+ onFocus={[Function]}
157
+ placeholder=" "
158
+ style={
159
+ Array [
160
+ Object {
161
+ "alignSelf": "stretch",
162
+ "flexGrow": 2,
163
+ "fontSize": 14,
164
+ "marginHorizontal": 8,
165
+ "paddingVertical": 0,
166
+ "textAlignVertical": "center",
167
+ },
168
+ Object {
169
+ "backgroundColor": "#ffffff",
170
+ "color": "#001f23",
171
+ },
172
+ ]
173
+ }
174
+ testID="text-input"
175
+ value="21/12/1995"
176
+ />
177
+ </View>
178
+ <HeroIcon
179
+ name="calendar-dates-outlined"
180
+ style={
181
+ Array [
182
+ Object {
183
+ "color": "#001f23",
184
+ "fontSize": 16,
185
+ },
186
+ undefined,
187
+ ]
188
+ }
189
+ testID="input-suffix"
190
+ themeIntent="text"
191
+ themeSize="xsmall"
192
+ />
193
+ </View>
194
+ <View
195
+ style={
196
+ Array [
197
+ Object {
198
+ "minHeight": 16,
199
+ "paddingLeft": 16,
200
+ },
201
+ undefined,
202
+ ]
203
+ }
204
+ >
205
+ <View
206
+ style={
207
+ Array [
208
+ Object {
209
+ "flexDirection": "row",
210
+ "justifyContent": "space-between",
211
+ },
212
+ undefined,
213
+ ]
214
+ }
215
+ />
216
+ </View>
217
+ </View>
218
+ </View>
219
+ </View>
220
+ `;
@@ -534,7 +534,6 @@ exports[`DatePickerIOS renders correctly 1`] = `
534
534
  "flexShrink": 1,
535
535
  "fontFamily": "BeVietnamPro-SemiBold",
536
536
  "fontSize": 16,
537
- "lineHeight": 24,
538
537
  "textAlign": "center",
539
538
  },
540
539
  undefined,
@@ -1,10 +1,14 @@
1
1
  import React from 'react';
2
2
  import { Platform } from 'react-native';
3
3
  import DatePickerAndroid from './DatePickerAndroid';
4
+ import DatePickerCalendar from './DatePickerCalendar';
4
5
  import DatePickerIOS from './DatePickerIOS';
5
6
  import type { DatePickerProps } from './types';
6
7
 
7
- const DatePicker = (props: DatePickerProps) => {
8
+ const DatePicker = ({ variant = 'default', ...props }: DatePickerProps) => {
9
+ if (variant === 'calendar') {
10
+ return <DatePickerCalendar {...props} />;
11
+ }
8
12
  if (Platform.OS === 'ios') {
9
13
  return <DatePickerIOS {...props} />;
10
14
  }
@@ -9,6 +9,12 @@ export interface DatePickerProps {
9
9
  * Current date value. Must be in correct default format or format provided via format prop.
10
10
  */
11
11
  value?: Date;
12
+ /**
13
+ * Datepicker variants.
14
+ * - default: is default UI of Android or iOS
15
+ * - calendar: calendar UI
16
+ */
17
+ variant?: 'default' | 'calendar';
12
18
  /**
13
19
  * Mininum date. Restrict the range of possible date values.
14
20
  */
@@ -55,7 +61,7 @@ export interface DatePickerProps {
55
61
  */
56
62
  style?: StyleProp<ViewStyle>;
57
63
  /**
58
- * Testing id of the component..
64
+ * Testing id of the component.
59
65
  */
60
66
  testID?: string;
61
67
  }
@@ -1371,7 +1371,6 @@ Array [
1371
1371
  "flexShrink": 1,
1372
1372
  "fontFamily": "BeVietnamPro-SemiBold",
1373
1373
  "fontSize": 16,
1374
- "lineHeight": 24,
1375
1374
  "textAlign": "center",
1376
1375
  },
1377
1376
  undefined,
@@ -3173,7 +3172,6 @@ Array [
3173
3172
  "flexShrink": 1,
3174
3173
  "fontFamily": "BeVietnamPro-SemiBold",
3175
3174
  "fontSize": 16,
3176
- "lineHeight": 24,
3177
3175
  "textAlign": "center",
3178
3176
  },
3179
3177
  undefined,
@@ -4596,7 +4594,6 @@ Array [
4596
4594
  "flexShrink": 1,
4597
4595
  "fontFamily": "BeVietnamPro-SemiBold",
4598
4596
  "fontSize": 16,
4599
- "lineHeight": 24,
4600
4597
  "textAlign": "center",
4601
4598
  },
4602
4599
  undefined,
@@ -765,7 +765,6 @@ exports[`TimePickerIOS renders correctly 1`] = `
765
765
  "flexShrink": 1,
766
766
  "fontFamily": "BeVietnamPro-SemiBold",
767
767
  "fontSize": 16,
768
- "lineHeight": 24,
769
768
  "textAlign": "center",
770
769
  },
771
770
  undefined,
@@ -53,7 +53,7 @@ export interface TimePickerProps {
53
53
  */
54
54
  style?: StyleProp<ViewStyle>;
55
55
  /**
56
- * Testing id of the component..
56
+ * Testing id of the component.
57
57
  */
58
58
  testID?: string;
59
59
  }
@@ -56,6 +56,7 @@ const Toast = ({
56
56
  onAction,
57
57
  actionLabel,
58
58
  onDismiss,
59
+ distance = 0,
59
60
  }: ToastProps): JSX.Element => {
60
61
  const animatedValue = useRef(new Animated.Value(0)).current;
61
62
  const toastConfig = useToastConfig();
@@ -85,7 +86,8 @@ const Toast = ({
85
86
 
86
87
  const interpolateY = animatedValue.interpolate({
87
88
  inputRange: [0, 1],
88
- outputRange: [toastConfig.position === 'top' ? -20 : 20, 0],
89
+ outputRange:
90
+ toastConfig.position === 'top' ? [-20, distance] : [20, -distance],
89
91
  });
90
92
 
91
93
  return (
@@ -61,6 +61,10 @@ export interface ToastProps {
61
61
  * Addtitional style.
62
62
  */
63
63
  style?: StyleProp<ViewStyle>;
64
+ /**
65
+ * Toast distance from bottom.
66
+ */
67
+ distance?: number;
64
68
  }
65
69
 
66
70
  export interface ToastContainerProps {
@@ -223,9 +223,6 @@ Object {
223
223
  "default": "BeVietnamPro-SemiBold",
224
224
  "utility": "BeVietnamPro-Regular",
225
225
  },
226
- "lineHeight": Object {
227
- "default": 24,
228
- },
229
226
  "radii": Object {
230
227
  "default": 32,
231
228
  "text": 4,
@@ -321,6 +318,8 @@ Object {
321
318
  "footerPaddingVertical": 16,
322
319
  "headingMarginBottom": 16,
323
320
  "headingMarginTop": 8,
321
+ "pageControlPaddingVertical": 8,
322
+ "pageControlWrapperHeight": 48,
324
323
  },
325
324
  },
326
325
  "checkbox": Object {
@@ -12,10 +12,6 @@ const getButtonTheme = (theme: GlobalTheme) => {
12
12
  textVariant: theme.fontSizes.large,
13
13
  };
14
14
 
15
- const lineHeight = {
16
- default: theme.lineHeights.large,
17
- };
18
-
19
15
  const borderWidth = {
20
16
  default: theme.space.xxsmall,
21
17
  };
@@ -68,7 +64,6 @@ const getButtonTheme = (theme: GlobalTheme) => {
68
64
  sizes,
69
65
  radii,
70
66
  colors,
71
- lineHeight,
72
67
  space,
73
68
  };
74
69
  };
@@ -1,3 +1,4 @@
1
+ import { scale } from '../../utils/scale';
1
2
  import type { GlobalTheme } from '../global';
2
3
 
3
4
  const getCarouselTheme = (theme: GlobalTheme) => {
@@ -7,6 +8,8 @@ const getCarouselTheme = (theme: GlobalTheme) => {
7
8
  footerPaddingHorizontal: theme.space.large,
8
9
  footerPaddingVertical: theme.space.medium,
9
10
  footerMarginBottom: theme.space.large,
11
+ pageControlPaddingVertical: theme.space.small,
12
+ pageControlWrapperHeight: scale(48),
10
13
  };
11
14
 
12
15
  const fontSizes = {
@@ -32,9 +32,13 @@ export interface CalendarProps {
32
32
  */
33
33
  onTitlePress?: () => void;
34
34
  /**
35
- * Mark dates to display on calendar..
35
+ * Mark dates to display on calendar.
36
36
  */
37
37
  markedDates?: Date[];
38
+ /**
39
+ * Testing id of the component.
40
+ */
41
+ testID?: string;
38
42
  }
39
- declare const Calendar: ({ value, visibleDate, onChange, onPreviousPress, onNextPress, onTitlePress, minDate, maxDate, markedDates, }: CalendarProps) => JSX.Element;
43
+ declare const Calendar: ({ value, visibleDate, onChange, onPreviousPress, onNextPress, onTitlePress, minDate, maxDate, markedDates, testID, }: CalendarProps) => JSX.Element;
40
44
  export default Calendar;
@@ -46,4 +46,10 @@ declare const StyledPageControl: import("@emotion/native").StyledComponent<impor
46
46
  theme?: import("@emotion/react").Theme | undefined;
47
47
  as?: import("react").ElementType<any> | undefined;
48
48
  }, {}, {}>;
49
- export { StyledBackDrop, StyledCarouselView, StyledCarouselHeading, StyledCarouselImage, StyledCarouselContentWrapper, StyledCarouselFooterWrapper, StyledCustomSizeCarouselImage, StyledPageControl, };
49
+ declare const StyledPageControlWrapper: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
50
+ theme?: import("@emotion/react").Theme | undefined;
51
+ as?: import("react").ElementType<any> | undefined;
52
+ }, {}, {
53
+ ref?: import("react").Ref<View> | undefined;
54
+ }>;
55
+ export { StyledBackDrop, StyledCarouselView, StyledCarouselHeading, StyledCarouselImage, StyledCarouselContentWrapper, StyledCarouselFooterWrapper, StyledCustomSizeCarouselImage, StyledPageControl, StyledPageControlWrapper, };
@@ -23,6 +23,8 @@ interface CarouselProps extends ViewProps {
23
23
  */
24
24
  renderActions?: (pageIndex: number) => JSX.Element;
25
25
  /**
26
+ * @deprecated will be removed in 9.0.0
27
+ *
26
28
  * Should show paginations
27
29
  */
28
30
  shouldShowPagination?: (pageIndex: number) => boolean;
@@ -30,9 +32,13 @@ interface CarouselProps extends ViewProps {
30
32
  * Current selected item index.
31
33
  */
32
34
  selectedItemIndex?: number;
35
+ /**
36
+ * position of the page control
37
+ */
38
+ pageControlPosition?: 'top' | 'bottom';
33
39
  }
34
40
  export declare function useStateFromProp<T>(initialValue: T): [T, Dispatch<SetStateAction<T>>];
35
- declare const _default: (({ items, onItemIndexChange, renderActions, selectedItemIndex, style, shouldShowPagination, ...nativeProps }: CarouselProps) => JSX.Element) & {
41
+ declare const _default: (({ items, onItemIndexChange, renderActions, selectedItemIndex, style, shouldShowPagination, pageControlPosition, ...nativeProps }: CarouselProps) => JSX.Element) & {
36
42
  Card: React.ForwardRefExoticComponent<Pick<import("./CardCarousel").CardCarouselProps, "style" | "onLayout" | "testID" | "items" | "onItemIndexChange" | "hidePageControl" | "autoPlay" | "autoPlayInterval"> & React.RefAttributes<import("./CardCarousel").CardCarouselHandles>>;
37
43
  };
38
44
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import type { DatePickerProps } from './types';
2
- declare const DatePickerAndroid: ({ value, minDate, maxDate, label, placeholder, onChange, displayFormat, disabled, required, error, helpText, style, testID, }: DatePickerProps) => JSX.Element;
2
+ declare const DatePickerAndroid: ({ value, minDate, maxDate, label, placeholder, onChange, displayFormat, disabled, required, error, helpText, style, testID, }: Omit<DatePickerProps, 'variant'>) => JSX.Element;
3
3
  export default DatePickerAndroid;
@@ -0,0 +1,3 @@
1
+ import type { DatePickerProps } from './types';
2
+ declare const DatePickerCalendar: ({ value, minDate, maxDate, label, placeholder, onChange, confirmLabel, displayFormat, disabled, required, error, helpText, style, testID, }: Omit<DatePickerProps, 'variant'>) => JSX.Element;
3
+ export default DatePickerCalendar;
@@ -1,3 +1,3 @@
1
1
  import type { DatePickerProps } from './types';
2
- declare const DatePickerIOS: ({ value, minDate, maxDate, label, placeholder, onChange, confirmLabel, displayFormat, disabled, required, error, helpText, style, testID, }: DatePickerProps) => JSX.Element;
2
+ declare const DatePickerIOS: ({ value, minDate, maxDate, label, placeholder, onChange, confirmLabel, displayFormat, disabled, required, error, helpText, style, testID, }: Omit<DatePickerProps, 'variant'>) => JSX.Element;
3
3
  export default DatePickerIOS;
@@ -1,3 +1,3 @@
1
1
  import type { DatePickerProps } from './types';
2
- declare const DatePicker: (props: DatePickerProps) => JSX.Element;
2
+ declare const DatePicker: ({ variant, ...props }: DatePickerProps) => JSX.Element;
3
3
  export default DatePicker;
@@ -8,6 +8,12 @@ export interface DatePickerProps {
8
8
  * Current date value. Must be in correct default format or format provided via format prop.
9
9
  */
10
10
  value?: Date;
11
+ /**
12
+ * Datepicker variants.
13
+ * - default: is default UI of Android or iOS
14
+ * - calendar: calendar UI
15
+ */
16
+ variant?: 'default' | 'calendar';
11
17
  /**
12
18
  * Mininum date. Restrict the range of possible date values.
13
19
  */
@@ -54,7 +60,7 @@ export interface DatePickerProps {
54
60
  */
55
61
  style?: StyleProp<ViewStyle>;
56
62
  /**
57
- * Testing id of the component..
63
+ * Testing id of the component.
58
64
  */
59
65
  testID?: string;
60
66
  }
@@ -51,7 +51,7 @@ export interface TimePickerProps {
51
51
  */
52
52
  style?: StyleProp<ViewStyle>;
53
53
  /**
54
- * Testing id of the component..
54
+ * Testing id of the component.
55
55
  */
56
56
  testID?: string;
57
57
  }
@@ -1,3 +1,3 @@
1
1
  import type { ToastProps } from './types';
2
- declare const Toast: ({ content, icon, variant, intent, style, duration, autoDismiss, onAction, actionLabel, onDismiss, }: ToastProps) => JSX.Element;
2
+ declare const Toast: ({ content, icon, variant, intent, style, duration, autoDismiss, onAction, actionLabel, onDismiss, distance, }: ToastProps) => JSX.Element;
3
3
  export default Toast;
@@ -47,6 +47,10 @@ export interface ToastProps {
47
47
  * Addtitional style.
48
48
  */
49
49
  style?: StyleProp<ViewStyle>;
50
+ /**
51
+ * Toast distance from bottom.
52
+ */
53
+ distance?: number;
50
54
  }
51
55
  export interface ToastContainerProps {
52
56
  /**
@@ -43,9 +43,6 @@ declare const getButtonTheme: (theme: GlobalTheme) => {
43
43
  textDanger: string;
44
44
  };
45
45
  };
46
- lineHeight: {
47
- default: number;
48
- };
49
46
  space: {
50
47
  buttonPadding: number;
51
48
  textButtonPadding: number;
@@ -6,6 +6,8 @@ declare const getCarouselTheme: (theme: GlobalTheme) => {
6
6
  footerPaddingHorizontal: number;
7
7
  footerPaddingVertical: number;
8
8
  footerMarginBottom: number;
9
+ pageControlPaddingVertical: number;
10
+ pageControlWrapperHeight: number;
9
11
  };
10
12
  fonts: {
11
13
  heading: string;