@hero-design/rn 8.45.0-test.0 → 8.45.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 (37) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/CHANGELOG.md +23 -2
  3. package/es/index.js +764 -578
  4. package/lib/index.js +764 -578
  5. package/package.json +6 -6
  6. package/src/components/Accordion/index.tsx +1 -1
  7. package/src/components/Avatar/AvatarStack/StyledAvatarStack.tsx +63 -9
  8. package/src/components/Avatar/AvatarStack/__tests__/StyledAvatarStack.spec.tsx +71 -9
  9. package/src/components/Avatar/AvatarStack/__tests__/__snapshots__/StyledAvatarStack.spec.tsx.snap +271 -2
  10. package/src/components/Avatar/AvatarStack/__tests__/__snapshots__/index.spec.tsx.snap +2156 -7
  11. package/src/components/Avatar/AvatarStack/__tests__/index.spec.tsx +140 -6
  12. package/src/components/Avatar/AvatarStack/index.tsx +94 -9
  13. package/src/components/Carousel/index.tsx +18 -11
  14. package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +108 -57
  15. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +36 -19
  16. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +36 -19
  17. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +36 -19
  18. package/src/components/RichTextEditor/RichTextEditor.tsx +89 -38
  19. package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +130 -102
  20. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +247 -146
  21. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +211 -127
  22. package/src/components/TextInput/StyledTextInput.tsx +9 -31
  23. package/src/components/TextInput/__tests__/StyledTextInput.spec.tsx +0 -44
  24. package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +21 -638
  25. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +1159 -833
  26. package/src/components/TextInput/__tests__/index.spec.tsx +2 -2
  27. package/src/components/TextInput/index.tsx +128 -57
  28. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +72 -38
  29. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +72 -38
  30. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +2 -2
  31. package/src/theme/components/textInput.ts +2 -2
  32. package/types/components/Accordion/index.d.ts +1 -1
  33. package/types/components/Avatar/AvatarStack/StyledAvatarStack.d.ts +13 -0
  34. package/types/components/Avatar/AvatarStack/index.d.ts +14 -2
  35. package/types/components/Avatar/index.d.ts +1 -1
  36. package/types/components/TextInput/StyledTextInput.d.ts +4 -24
  37. package/types/components/TextInput/index.d.ts +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.45.0-test.0",
3
+ "version": "8.45.1",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -28,11 +28,11 @@
28
28
  "nanoid": "^4.0.2"
29
29
  },
30
30
  "peerDependencies": {
31
- "@hero-design/react-native-month-year-picker": "^8.42.5",
31
+ "@hero-design/react-native-month-year-picker": "^8.42.6",
32
32
  "@react-native-community/datetimepicker": "^3.5.2",
33
33
  "@react-native-community/slider": "4.4.3",
34
34
  "react": "18.2.0",
35
- "react-native": "0.71.13",
35
+ "react-native": "^0.71.0",
36
36
  "react-native-gesture-handler": "^1.10.3 | ~2.5.0",
37
37
  "react-native-linear-gradient": "^2.6.2",
38
38
  "react-native-pager-view": "^5.4.25",
@@ -48,8 +48,8 @@
48
48
  "@babel/runtime": "^7.20.0",
49
49
  "@emotion/jest": "^11.11.0",
50
50
  "@hero-design/eslint-plugin": "8.42.5",
51
- "@hero-design/react-native-month-year-picker": "^8.42.5",
52
- "@react-native-community/datetimepicker": "^3.5.2",
51
+ "@hero-design/react-native-month-year-picker": "^8.42.6",
52
+ "@react-native-community/datetimepicker": "3.5.2",
53
53
  "@react-native-community/slider": "4.4.3",
54
54
  "@rollup/plugin-babel": "^5.3.1",
55
55
  "@rollup/plugin-commonjs": "^21.0.1",
@@ -71,7 +71,7 @@
71
71
  "jest-junit": "^16.0.0",
72
72
  "prettier-config-hd": "8.42.4",
73
73
  "react": "18.2.0",
74
- "react-native": "0.71.13",
74
+ "react-native": "0.71.14",
75
75
  "react-native-gesture-handler": "~2.5.0",
76
76
  "react-native-linear-gradient": "^2.6.2",
77
77
  "react-native-pager-view": "^5.4.25",
@@ -45,8 +45,8 @@ const Accordion = <K extends Key>({
45
45
  activeItemKey,
46
46
  onItemPress,
47
47
  variant = 'default',
48
- testID,
49
48
  style,
49
+ testID,
50
50
  }: AccordionProps<K>) => {
51
51
  const defaultValue = useMemo(
52
52
  () => (typeof activeItemKey === 'number' ? NaN : '') as K,
@@ -1,29 +1,83 @@
1
1
  import styled from '@emotion/native';
2
2
  import { View } from 'react-native';
3
3
  import Avatar, { AvatarProps } from '../Avatar';
4
+ import Box from '../../Box';
4
5
 
5
6
  const VISIBLE_RATIO = 0.7;
6
7
 
8
+ type ThemeVariant = 'horizontal' | 'vertical';
9
+
7
10
  export const StyledWrapper = styled(View)<{
8
11
  themeSize: Required<AvatarProps>['size'];
9
12
  themeAvatarCount: number;
10
- }>(({ theme, themeSize, themeAvatarCount }) => {
11
- const avatarSize = theme.__hd__.avatar.sizes[themeSize];
13
+ themeVariant: ThemeVariant;
14
+ themeHasSurplus: boolean;
15
+ }>(
16
+ ({
17
+ theme,
18
+ themeSize,
19
+ themeAvatarCount,
20
+ themeVariant = 'horizontal',
21
+ themeHasSurplus = false,
22
+ }) => {
23
+ const avatarSize = theme.__hd__.avatar.sizes[themeSize];
24
+
25
+ const widthAndHeightByVariant = {
26
+ horizontal: {
27
+ width:
28
+ avatarSize *
29
+ (1 +
30
+ VISIBLE_RATIO *
31
+ (themeHasSurplus ? themeAvatarCount : themeAvatarCount - 1)),
32
+ height: avatarSize,
33
+ },
34
+ vertical: {
35
+ width: avatarSize,
36
+ height:
37
+ avatarSize *
38
+ (1 +
39
+ VISIBLE_RATIO *
40
+ (themeHasSurplus ? themeAvatarCount : themeAvatarCount - 1)),
41
+ },
42
+ };
43
+
44
+ return {
45
+ flexDirection: themeVariant === 'horizontal' ? 'row' : 'column',
46
+ height: widthAndHeightByVariant[themeVariant].height,
47
+ width: widthAndHeightByVariant[themeVariant].width,
48
+ };
49
+ }
50
+ );
51
+
52
+ export const StyledAvatar = styled(Avatar)<{
53
+ themeIndex: number;
54
+ themeVariant: ThemeVariant;
55
+ }>(({ theme, themeIndex, size = 'small', themeVariant = 'horizontal' }) => {
56
+ const avatarSize = theme.__hd__.avatar.sizes[size];
57
+ const offset = avatarSize * VISIBLE_RATIO * themeIndex;
12
58
 
13
59
  return {
14
- flexDirection: 'row',
15
- height: avatarSize,
16
- width: avatarSize * (1 + VISIBLE_RATIO * (themeAvatarCount - 1)),
60
+ position: 'absolute',
61
+ left: themeVariant === 'horizontal' ? offset : undefined,
62
+ top: themeVariant === 'vertical' ? offset : undefined,
17
63
  };
18
64
  });
19
65
 
20
- export const StyledAvatar = styled(Avatar)<{
66
+ export const StyledSurplusContainer = styled(Box)<{
21
67
  themeIndex: number;
22
- }>(({ theme, themeIndex, size = 'small' }) => {
23
- const avatarSize = theme.__hd__.avatar.sizes[size];
68
+ themeSize: AvatarProps['size'];
69
+ themeVariant: ThemeVariant;
70
+ }>(({ theme, themeIndex, themeVariant, themeSize = 'small' }) => {
71
+ const avatarSize = theme.__hd__.avatar.sizes[themeSize];
72
+ const offset = avatarSize * VISIBLE_RATIO * themeIndex;
24
73
 
25
74
  return {
26
75
  position: 'absolute',
27
- left: avatarSize * VISIBLE_RATIO * themeIndex,
76
+ left: themeVariant === 'horizontal' ? offset : undefined,
77
+ top: themeVariant === 'vertical' ? offset : undefined,
78
+ borderRadius: theme.__hd__.avatar.radii.rounded,
79
+ width: theme.__hd__.avatar.sizes[themeSize],
80
+ height: theme.__hd__.avatar.sizes[themeSize],
81
+ overflow: 'hidden',
28
82
  };
29
83
  });
@@ -11,26 +11,88 @@ afterEach(() => {
11
11
  });
12
12
 
13
13
  describe('StyledWrapper', () => {
14
- it('renders correctly', () => {
14
+ it.each`
15
+ themeVariant
16
+ ${'horizontal'}
17
+ ${'vertical'}
18
+ `('renders correctly with $variant', ({ themeVariant }) => {
15
19
  const wrapper = renderWithTheme(
16
- <StyledWrapper themeSize="large" themeAvatarCount={4} testID="wrapper" />
20
+ <StyledWrapper
21
+ themeHasSurplus={false}
22
+ themeVariant={themeVariant}
23
+ themeSize="large"
24
+ themeAvatarCount={4}
25
+ testID="wrapper"
26
+ />
27
+ );
28
+
29
+ expect(wrapper.getByTestId('wrapper')).toHaveStyle(
30
+ themeVariant === 'horizontal'
31
+ ? {
32
+ height: 48,
33
+ width: 48 * (1 + 0.7 * 3),
34
+ }
35
+ : {
36
+ height: 48 * (1 + 0.7 * 3),
37
+ width: 48,
38
+ }
17
39
  );
18
40
 
19
- expect(wrapper.getByTestId('wrapper')).toHaveStyle({
20
- height: 48,
21
- width: 48 * (1 + 0.7 * 3),
22
- });
23
41
  expect(wrapper.toJSON()).toMatchSnapshot();
24
42
  });
43
+
44
+ it.each`
45
+ themeHasSurplus
46
+ ${true}
47
+ ${false}
48
+ `(
49
+ 'render with correct width and height when themeHasSurplus is $themeHasSurplus',
50
+ ({ themeHasSurplus }) => {
51
+ const { toJSON, getByTestId } = renderWithTheme(
52
+ <StyledWrapper
53
+ themeHasSurplus={themeHasSurplus}
54
+ themeVariant="horizontal"
55
+ themeSize="large"
56
+ themeAvatarCount={4}
57
+ testID="wrapper"
58
+ />
59
+ );
60
+
61
+ expect(getByTestId('wrapper')).toHaveStyle(
62
+ themeHasSurplus
63
+ ? {
64
+ height: 48,
65
+ width: 48 * (1 + 0.7 * 4),
66
+ }
67
+ : {
68
+ height: 48,
69
+ width: 48 * (1 + 0.7 * 3),
70
+ }
71
+ );
72
+ expect(toJSON()).toMatchSnapshot();
73
+ }
74
+ );
25
75
  });
26
76
 
27
77
  describe('StyledAvatar', () => {
28
- it('renders correctly', () => {
78
+ it.each`
79
+ themeVariant
80
+ ${'horizontal'}
81
+ ${'vertical'}
82
+ `('renders correctly with $variant', ({ themeVariant }) => {
29
83
  const wrapper = renderWithTheme(
30
- <StyledAvatar themeIndex={2} size="medium" title="AA" testID="avatar" />
84
+ <StyledAvatar
85
+ themeVariant={themeVariant}
86
+ themeIndex={2}
87
+ size="medium"
88
+ title="AA"
89
+ testID="avatar"
90
+ />
31
91
  );
32
92
 
33
- expect(wrapper.getByTestId('avatar')).toHaveStyle({ left: 56 });
93
+ expect(wrapper.getByTestId('avatar')).toHaveStyle(
94
+ themeVariant === 'horizontal' ? { left: 56 } : { top: 56 }
95
+ );
34
96
  expect(wrapper.toJSON()).toMatchSnapshot();
35
97
  });
36
98
  });
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`StyledAvatar renders correctly 1`] = `
3
+ exports[`StyledAvatar renders correctly with $variant 1`] = `
4
4
  <View
5
5
  style={
6
6
  {
@@ -45,6 +45,7 @@ exports[`StyledAvatar renders correctly 1`] = `
45
45
  "opacity": 1,
46
46
  "overflow": "hidden",
47
47
  "position": "absolute",
48
+ "top": undefined,
48
49
  "width": 40,
49
50
  }
50
51
  }
@@ -121,7 +122,225 @@ exports[`StyledAvatar renders correctly 1`] = `
121
122
  </View>
122
123
  `;
123
124
 
124
- exports[`StyledWrapper renders correctly 1`] = `
125
+ exports[`StyledAvatar renders correctly with $variant 2`] = `
126
+ <View
127
+ style={
128
+ {
129
+ "flex": 1,
130
+ }
131
+ }
132
+ >
133
+ <View
134
+ accessibilityState={
135
+ {
136
+ "busy": undefined,
137
+ "checked": undefined,
138
+ "disabled": true,
139
+ "expanded": undefined,
140
+ "selected": undefined,
141
+ }
142
+ }
143
+ accessibilityValue={
144
+ {
145
+ "max": undefined,
146
+ "min": undefined,
147
+ "now": undefined,
148
+ "text": undefined,
149
+ }
150
+ }
151
+ accessible={true}
152
+ collapsable={false}
153
+ focusable={false}
154
+ onClick={[Function]}
155
+ onResponderGrant={[Function]}
156
+ onResponderMove={[Function]}
157
+ onResponderRelease={[Function]}
158
+ onResponderTerminate={[Function]}
159
+ onResponderTerminationRequest={[Function]}
160
+ onStartShouldSetResponder={[Function]}
161
+ style={
162
+ {
163
+ "backgroundColor": "#401960",
164
+ "borderRadius": 999,
165
+ "height": 40,
166
+ "left": undefined,
167
+ "opacity": 1,
168
+ "overflow": "hidden",
169
+ "position": "absolute",
170
+ "top": 56,
171
+ "width": 40,
172
+ }
173
+ }
174
+ testID="avatar"
175
+ >
176
+ <View
177
+ style={
178
+ [
179
+ {
180
+ "alignItems": "center",
181
+ "height": "100%",
182
+ "justifyContent": "center",
183
+ "width": "100%",
184
+ },
185
+ undefined,
186
+ ]
187
+ }
188
+ >
189
+ <Text
190
+ allowFontScaling={false}
191
+ style={
192
+ [
193
+ {
194
+ "color": "#001f23",
195
+ "fontFamily": "BeVietnamPro-Regular",
196
+ "fontSize": 14,
197
+ "letterSpacing": 0.42,
198
+ "lineHeight": 22,
199
+ },
200
+ [
201
+ {
202
+ "color": "#ffffff",
203
+ "fontFamily": "BeVietnamPro-Regular",
204
+ "fontSize": 18,
205
+ "lineHeight": 0,
206
+ "overflow": "hidden",
207
+ "textAlign": "center",
208
+ "textAlignVertical": "center",
209
+ },
210
+ undefined,
211
+ ],
212
+ ]
213
+ }
214
+ themeFontSize="medium"
215
+ themeFontWeight="regular"
216
+ themeIntent="body"
217
+ themeSize="medium"
218
+ themeTypeface="neutral"
219
+ >
220
+ AA
221
+ </Text>
222
+ </View>
223
+ </View>
224
+ <View
225
+ pointerEvents="box-none"
226
+ position="bottom"
227
+ style={
228
+ [
229
+ {
230
+ "bottom": 0,
231
+ "elevation": 9999,
232
+ "flexDirection": "column-reverse",
233
+ "left": 0,
234
+ "paddingHorizontal": 24,
235
+ "paddingVertical": 16,
236
+ "position": "absolute",
237
+ "right": 0,
238
+ "top": 0,
239
+ },
240
+ undefined,
241
+ ]
242
+ }
243
+ />
244
+ </View>
245
+ `;
246
+
247
+ exports[`StyledWrapper render with correct width and height when themeHasSurplus is false 1`] = `
248
+ <View
249
+ style={
250
+ {
251
+ "flex": 1,
252
+ }
253
+ }
254
+ >
255
+ <View
256
+ style={
257
+ [
258
+ {
259
+ "flexDirection": "row",
260
+ "height": 48,
261
+ "width": 148.79999999999998,
262
+ },
263
+ undefined,
264
+ ]
265
+ }
266
+ testID="wrapper"
267
+ themeAvatarCount={4}
268
+ themeHasSurplus={false}
269
+ themeSize="large"
270
+ themeVariant="horizontal"
271
+ />
272
+ <View
273
+ pointerEvents="box-none"
274
+ position="bottom"
275
+ style={
276
+ [
277
+ {
278
+ "bottom": 0,
279
+ "elevation": 9999,
280
+ "flexDirection": "column-reverse",
281
+ "left": 0,
282
+ "paddingHorizontal": 24,
283
+ "paddingVertical": 16,
284
+ "position": "absolute",
285
+ "right": 0,
286
+ "top": 0,
287
+ },
288
+ undefined,
289
+ ]
290
+ }
291
+ />
292
+ </View>
293
+ `;
294
+
295
+ exports[`StyledWrapper render with correct width and height when themeHasSurplus is true 1`] = `
296
+ <View
297
+ style={
298
+ {
299
+ "flex": 1,
300
+ }
301
+ }
302
+ >
303
+ <View
304
+ style={
305
+ [
306
+ {
307
+ "flexDirection": "row",
308
+ "height": 48,
309
+ "width": 182.39999999999998,
310
+ },
311
+ undefined,
312
+ ]
313
+ }
314
+ testID="wrapper"
315
+ themeAvatarCount={4}
316
+ themeHasSurplus={true}
317
+ themeSize="large"
318
+ themeVariant="horizontal"
319
+ />
320
+ <View
321
+ pointerEvents="box-none"
322
+ position="bottom"
323
+ style={
324
+ [
325
+ {
326
+ "bottom": 0,
327
+ "elevation": 9999,
328
+ "flexDirection": "column-reverse",
329
+ "left": 0,
330
+ "paddingHorizontal": 24,
331
+ "paddingVertical": 16,
332
+ "position": "absolute",
333
+ "right": 0,
334
+ "top": 0,
335
+ },
336
+ undefined,
337
+ ]
338
+ }
339
+ />
340
+ </View>
341
+ `;
342
+
343
+ exports[`StyledWrapper renders correctly with $variant 1`] = `
125
344
  <View
126
345
  style={
127
346
  {
@@ -142,7 +361,57 @@ exports[`StyledWrapper renders correctly 1`] = `
142
361
  }
143
362
  testID="wrapper"
144
363
  themeAvatarCount={4}
364
+ themeHasSurplus={false}
365
+ themeSize="large"
366
+ themeVariant="horizontal"
367
+ />
368
+ <View
369
+ pointerEvents="box-none"
370
+ position="bottom"
371
+ style={
372
+ [
373
+ {
374
+ "bottom": 0,
375
+ "elevation": 9999,
376
+ "flexDirection": "column-reverse",
377
+ "left": 0,
378
+ "paddingHorizontal": 24,
379
+ "paddingVertical": 16,
380
+ "position": "absolute",
381
+ "right": 0,
382
+ "top": 0,
383
+ },
384
+ undefined,
385
+ ]
386
+ }
387
+ />
388
+ </View>
389
+ `;
390
+
391
+ exports[`StyledWrapper renders correctly with $variant 2`] = `
392
+ <View
393
+ style={
394
+ {
395
+ "flex": 1,
396
+ }
397
+ }
398
+ >
399
+ <View
400
+ style={
401
+ [
402
+ {
403
+ "flexDirection": "column",
404
+ "height": 148.79999999999998,
405
+ "width": 48,
406
+ },
407
+ undefined,
408
+ ]
409
+ }
410
+ testID="wrapper"
411
+ themeAvatarCount={4}
412
+ themeHasSurplus={false}
145
413
  themeSize="large"
414
+ themeVariant="vertical"
146
415
  />
147
416
  <View
148
417
  pointerEvents="box-none"