@hero-design/rn 8.45.0-test.0 → 8.45.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 (37) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +12 -2
  3. package/es/index.js +731 -584
  4. package/lib/index.js +731 -584
  5. package/package.json +1 -1
  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 +102 -57
  15. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +34 -19
  16. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +34 -19
  17. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +34 -19
  18. package/src/components/RichTextEditor/RichTextEditor.tsx +76 -38
  19. package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +126 -102
  20. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +235 -146
  21. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +201 -127
  22. package/src/components/TextInput/StyledTextInput.tsx +8 -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 +1126 -833
  26. package/src/components/TextInput/__tests__/index.spec.tsx +2 -2
  27. package/src/components/TextInput/index.tsx +113 -57
  28. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +68 -38
  29. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +68 -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
@@ -59,6 +59,7 @@ exports[`DatePickerAndroid renders correctly 1`] = `
59
59
  }
60
60
  >
61
61
  <View
62
+ onLayout={[Function]}
62
63
  style={
63
64
  [
64
65
  {
@@ -98,24 +99,34 @@ exports[`DatePickerAndroid renders correctly 1`] = `
98
99
  themeState="filled"
99
100
  />
100
101
  <View
102
+ onLayout={[Function]}
103
+ />
104
+ <View
105
+ collapsable={false}
101
106
  pointerEvents="none"
102
107
  style={
103
- [
104
- {
105
- "backgroundColor": "#ffffff",
106
- "flexDirection": "row",
107
- "left": 16,
108
- "paddingHorizontal": 4,
109
- "position": "absolute",
110
- "top": -4,
111
- "zIndex": 1,
112
- },
113
- {
114
- "backgroundColor": "#ffffff",
115
- },
116
- ]
108
+ {
109
+ "alignItems": "center",
110
+ "flexDirection": "row",
111
+ "left": -32,
112
+ "position": "absolute",
113
+ "right": 0,
114
+ "top": -10.666666666666666,
115
+ "transform": [
116
+ {
117
+ "translateY": 0,
118
+ },
119
+ {
120
+ "translateX": 48,
121
+ },
122
+ {
123
+ "scale": 1,
124
+ },
125
+ ],
126
+ "zIndex": 1,
127
+ }
117
128
  }
118
- testID="label-container"
129
+ themeVariant="text"
119
130
  >
120
131
  <Text
121
132
  allowFontScaling={false}
@@ -124,14 +135,17 @@ exports[`DatePickerAndroid renders correctly 1`] = `
124
135
  {
125
136
  "color": "#001f23",
126
137
  "fontFamily": "BeVietnamPro-Regular",
127
- "fontSize": 12,
138
+ "fontSize": 16,
128
139
  "letterSpacing": 0.48,
129
- "lineHeight": 16,
140
+ "lineHeight": 24,
130
141
  },
131
142
  [
132
143
  {
144
+ "alignContent": "center",
145
+ "alignItems": "center",
133
146
  "color": "#001f23",
134
- "lineHeight": 12,
147
+ "marginTop": -2,
148
+ "textAlignVertical": "center",
135
149
  },
136
150
  {
137
151
  "backgroundColor": "#ffffff",
@@ -140,9 +154,10 @@ exports[`DatePickerAndroid renders correctly 1`] = `
140
154
  ]
141
155
  }
142
156
  testID="input-label"
143
- themeFontWeight="regular"
144
157
  themeIntent="body"
145
158
  themeState="filled"
159
+ themeTypeface="neutral"
160
+ themeVariant="regular"
146
161
  >
147
162
  Start date
148
163
  </Text>
@@ -59,6 +59,7 @@ exports[`DatePickerCalendar renders correctly 1`] = `
59
59
  }
60
60
  >
61
61
  <View
62
+ onLayout={[Function]}
62
63
  style={
63
64
  [
64
65
  {
@@ -98,24 +99,34 @@ exports[`DatePickerCalendar renders correctly 1`] = `
98
99
  themeState="filled"
99
100
  />
100
101
  <View
102
+ onLayout={[Function]}
103
+ />
104
+ <View
105
+ collapsable={false}
101
106
  pointerEvents="none"
102
107
  style={
103
- [
104
- {
105
- "backgroundColor": "#ffffff",
106
- "flexDirection": "row",
107
- "left": 16,
108
- "paddingHorizontal": 4,
109
- "position": "absolute",
110
- "top": -4,
111
- "zIndex": 1,
112
- },
113
- {
114
- "backgroundColor": "#ffffff",
115
- },
116
- ]
108
+ {
109
+ "alignItems": "center",
110
+ "flexDirection": "row",
111
+ "left": -32,
112
+ "position": "absolute",
113
+ "right": 0,
114
+ "top": -10.666666666666666,
115
+ "transform": [
116
+ {
117
+ "translateY": 0,
118
+ },
119
+ {
120
+ "translateX": 48,
121
+ },
122
+ {
123
+ "scale": 1,
124
+ },
125
+ ],
126
+ "zIndex": 1,
127
+ }
117
128
  }
118
- testID="label-container"
129
+ themeVariant="text"
119
130
  >
120
131
  <Text
121
132
  allowFontScaling={false}
@@ -124,14 +135,17 @@ exports[`DatePickerCalendar renders correctly 1`] = `
124
135
  {
125
136
  "color": "#001f23",
126
137
  "fontFamily": "BeVietnamPro-Regular",
127
- "fontSize": 12,
138
+ "fontSize": 16,
128
139
  "letterSpacing": 0.48,
129
- "lineHeight": 16,
140
+ "lineHeight": 24,
130
141
  },
131
142
  [
132
143
  {
144
+ "alignContent": "center",
145
+ "alignItems": "center",
133
146
  "color": "#001f23",
134
- "lineHeight": 12,
147
+ "marginTop": -2,
148
+ "textAlignVertical": "center",
135
149
  },
136
150
  {
137
151
  "backgroundColor": "#ffffff",
@@ -140,9 +154,10 @@ exports[`DatePickerCalendar renders correctly 1`] = `
140
154
  ]
141
155
  }
142
156
  testID="input-label"
143
- themeFontWeight="regular"
144
157
  themeIntent="body"
145
158
  themeState="filled"
159
+ themeTypeface="neutral"
160
+ themeVariant="regular"
146
161
  >
147
162
  Start date
148
163
  </Text>
@@ -59,6 +59,7 @@ exports[`DatePickerIOS renders correctly 1`] = `
59
59
  }
60
60
  >
61
61
  <View
62
+ onLayout={[Function]}
62
63
  style={
63
64
  [
64
65
  {
@@ -98,24 +99,34 @@ exports[`DatePickerIOS renders correctly 1`] = `
98
99
  themeState="filled"
99
100
  />
100
101
  <View
102
+ onLayout={[Function]}
103
+ />
104
+ <View
105
+ collapsable={false}
101
106
  pointerEvents="none"
102
107
  style={
103
- [
104
- {
105
- "backgroundColor": "#ffffff",
106
- "flexDirection": "row",
107
- "left": 16,
108
- "paddingHorizontal": 4,
109
- "position": "absolute",
110
- "top": -4,
111
- "zIndex": 1,
112
- },
113
- {
114
- "backgroundColor": "#ffffff",
115
- },
116
- ]
108
+ {
109
+ "alignItems": "center",
110
+ "flexDirection": "row",
111
+ "left": -32,
112
+ "position": "absolute",
113
+ "right": 0,
114
+ "top": -10.666666666666666,
115
+ "transform": [
116
+ {
117
+ "translateY": 0,
118
+ },
119
+ {
120
+ "translateX": 48,
121
+ },
122
+ {
123
+ "scale": 1,
124
+ },
125
+ ],
126
+ "zIndex": 1,
127
+ }
117
128
  }
118
- testID="label-container"
129
+ themeVariant="text"
119
130
  >
120
131
  <Text
121
132
  allowFontScaling={false}
@@ -124,14 +135,17 @@ exports[`DatePickerIOS renders correctly 1`] = `
124
135
  {
125
136
  "color": "#001f23",
126
137
  "fontFamily": "BeVietnamPro-Regular",
127
- "fontSize": 12,
138
+ "fontSize": 16,
128
139
  "letterSpacing": 0.48,
129
- "lineHeight": 16,
140
+ "lineHeight": 24,
130
141
  },
131
142
  [
132
143
  {
144
+ "alignContent": "center",
145
+ "alignItems": "center",
133
146
  "color": "#001f23",
134
- "lineHeight": 12,
147
+ "marginTop": -2,
148
+ "textAlignVertical": "center",
135
149
  },
136
150
  {
137
151
  "backgroundColor": "#ffffff",
@@ -140,9 +154,10 @@ exports[`DatePickerIOS renders correctly 1`] = `
140
154
  ]
141
155
  }
142
156
  testID="input-label"
143
- themeFontWeight="regular"
144
157
  themeIntent="body"
145
158
  themeState="filled"
159
+ themeTypeface="neutral"
160
+ themeVariant="regular"
146
161
  >
147
162
  Start date
148
163
  </Text>
@@ -10,15 +10,14 @@ import React, {
10
10
  useState,
11
11
  } from 'react';
12
12
 
13
- import { TouchableWithoutFeedback } from 'react-native';
13
+ import { Animated, TouchableWithoutFeedback, Easing } from 'react-native';
14
14
  import { WebView } from 'react-native-webview';
15
15
  import type { ComponentType, ReactElement, Ref } from 'react';
16
- import type { StyleProp, ViewStyle } from 'react-native';
16
+ import type { StyleProp, ViewStyle, LayoutChangeEvent } from 'react-native';
17
17
  import heroEditorApp from './heroEditorApp';
18
18
  import { isAndroid } from '../../utils/helpers';
19
19
  import Icon from '../Icon';
20
20
  import {
21
- StyledAsteriskLabel,
22
21
  StyledAsteriskLabelInsideTextInput,
23
22
  StyledBorderBackDrop,
24
23
  StyledContainer,
@@ -27,8 +26,6 @@ import {
27
26
  StyledErrorAndMaxLengthContainer,
28
27
  StyledErrorContainer,
29
28
  StyledHelperText,
30
- StyledLabel,
31
- StyledLabelContainer,
32
29
  StyledLabelContainerInsideTextInput,
33
30
  StyledLabelInsideTextInput,
34
31
  StyledTextInputAndLabelContainer,
@@ -40,6 +37,7 @@ import { StyledWebView } from './StyledRichTextEditor';
40
37
  import * as Events from './utils/events';
41
38
  import { postMessage, requestBlurEditor } from './utils/rnWebView';
42
39
  import type { WebViewEventMessage } from './utils/rnWebView';
40
+ import { LABEL_ANIMATION_DURATION } from '../TextInput';
43
41
 
44
42
  export interface RichTextEditorRef {
45
43
  requestBlur: VoidFunction;
@@ -150,6 +148,23 @@ const RichTextEditor: ComponentType<RichTextEditorProps> = ({
150
148
  postMessage(webview.current, message);
151
149
  }
152
150
  };
151
+ const [inputHeight, setInputHeight] = React.useState<number>(0);
152
+
153
+ const focusAnimation = useRef(new Animated.Value(0)).current;
154
+
155
+ useEffect(() => {
156
+ Animated.timing(focusAnimation, {
157
+ toValue: isFocused || !isEmptyValue ? 1 : 0,
158
+ duration: LABEL_ANIMATION_DURATION,
159
+ easing: Easing.bezier(0.4, 0, 0.2, 1),
160
+ useNativeDriver: true,
161
+ }).start();
162
+ }, [focusAnimation, isEmptyValue, isFocused]);
163
+
164
+ const onLayout = useCallback((event: LayoutChangeEvent) => {
165
+ const { height } = event.nativeEvent.layout;
166
+ setInputHeight(height);
167
+ }, []);
153
168
 
154
169
  useEffect(() => {
155
170
  const removeFocusListener = Events.on(
@@ -307,41 +322,64 @@ const RichTextEditor: ComponentType<RichTextEditorProps> = ({
307
322
 
308
323
  return (
309
324
  <StyledContainer testID={testID}>
310
- <StyledTextInputContainer>
311
- <StyledBorderBackDrop themeState={state} themeFocused={isFocused} />
312
- {(isFocused || (label && !isEmptyValue)) && (
313
- <StyledLabelContainer pointerEvents="none">
314
- {required && (
315
- <StyledAsteriskLabel themeState={state}>*</StyledAsteriskLabel>
316
- )}
317
- {!!label && (
318
- <StyledLabel testID="input-label" themeState={state}>
319
- {label}
320
- </StyledLabel>
321
- )}
322
- </StyledLabelContainer>
325
+ <StyledLabelContainerInsideTextInput
326
+ themeVariant="text"
327
+ pointerEvents="none"
328
+ testID="input-label-container"
329
+ style={[
330
+ {
331
+ position: 'absolute',
332
+ },
333
+ {
334
+ transform: [
335
+ {
336
+ translateY: focusAnimation.interpolate({
337
+ inputRange: [0, 1],
338
+ outputRange: [inputHeight / 2, 0],
339
+ }),
340
+ },
341
+ {
342
+ translateX: focusAnimation.interpolate({
343
+ inputRange: [0, 1],
344
+ outputRange: [theme.space.xxxlarge, 0],
345
+ }),
346
+ },
347
+ {
348
+ scale: focusAnimation.interpolate({
349
+ inputRange: [0, 1],
350
+ outputRange: [1, 0.75],
351
+ }),
352
+ },
353
+ ],
354
+ },
355
+ ]}
356
+ >
357
+ {required && (
358
+ <StyledAsteriskLabelInsideTextInput
359
+ style={{
360
+ backgroundColor: theme.__hd__.textInput.colors.labelBackground,
361
+ }}
362
+ themeState={state}
363
+ >
364
+ *
365
+ </StyledAsteriskLabelInsideTextInput>
323
366
  )}
367
+ {!!label && (
368
+ <StyledLabelInsideTextInput
369
+ style={{
370
+ backgroundColor: theme.__hd__.textInput.colors.labelBackground,
371
+ }}
372
+ testID="input-label"
373
+ themeState={state}
374
+ >
375
+ {label}
376
+ </StyledLabelInsideTextInput>
377
+ )}
378
+ </StyledLabelContainerInsideTextInput>
379
+ <StyledTextInputContainer onLayout={onLayout}>
380
+ <StyledBorderBackDrop themeState={state} themeFocused={isFocused} />
381
+
324
382
  <StyledTextInputAndLabelContainer>
325
- {!isFocused && isEmptyValue && (
326
- <StyledLabelContainerInsideTextInput
327
- themeVariant="text"
328
- pointerEvents="none"
329
- >
330
- {required && (
331
- <StyledAsteriskLabelInsideTextInput themeState={state}>
332
- *
333
- </StyledAsteriskLabelInsideTextInput>
334
- )}
335
- {!!label && (
336
- <StyledLabelInsideTextInput
337
- testID="input-label"
338
- themeState={state}
339
- >
340
- {label}
341
- </StyledLabelInsideTextInput>
342
- )}
343
- </StyledLabelContainerInsideTextInput>
344
- )}
345
383
  <TouchableWithoutFeedback onPress={(e) => e.stopPropagation()}>
346
384
  <StyledWebView
347
385
  ref={webview}
@@ -20,6 +20,69 @@ exports[`RichTextEditor onMessage recevied event editor-layout should update hei
20
20
  }
21
21
  >
22
22
  <View
23
+ collapsable={false}
24
+ pointerEvents="none"
25
+ style={
26
+ {
27
+ "alignItems": "center",
28
+ "flexDirection": "row",
29
+ "left": -32,
30
+ "position": "absolute",
31
+ "right": 0,
32
+ "top": -10.666666666666666,
33
+ "transform": [
34
+ {
35
+ "translateY": 0,
36
+ },
37
+ {
38
+ "translateX": 48,
39
+ },
40
+ {
41
+ "scale": 1,
42
+ },
43
+ ],
44
+ "zIndex": 1,
45
+ }
46
+ }
47
+ testID="input-label-container"
48
+ themeVariant="text"
49
+ >
50
+ <Text
51
+ allowFontScaling={false}
52
+ style={
53
+ [
54
+ {
55
+ "color": "#001f23",
56
+ "fontFamily": "BeVietnamPro-Regular",
57
+ "fontSize": 16,
58
+ "letterSpacing": 0.48,
59
+ "lineHeight": 24,
60
+ },
61
+ [
62
+ {
63
+ "alignContent": "center",
64
+ "alignItems": "center",
65
+ "color": "#001f23",
66
+ "marginTop": -2,
67
+ "textAlignVertical": "center",
68
+ },
69
+ {
70
+ "backgroundColor": "#ffffff",
71
+ },
72
+ ],
73
+ ]
74
+ }
75
+ testID="input-label"
76
+ themeIntent="body"
77
+ themeState="error"
78
+ themeTypeface="neutral"
79
+ themeVariant="regular"
80
+ >
81
+ Rich Text Editor
82
+ </Text>
83
+ </View>
84
+ <View
85
+ onLayout={[Function]}
23
86
  style={
24
87
  [
25
88
  {
@@ -66,57 +129,6 @@ exports[`RichTextEditor onMessage recevied event editor-layout should update hei
66
129
  ]
67
130
  }
68
131
  >
69
- <View
70
- pointerEvents="none"
71
- style={
72
- [
73
- {
74
- "alignItems": "center",
75
- "bottom": 0,
76
- "flexDirection": "row",
77
- "left": 0,
78
- "position": "absolute",
79
- "right": 0,
80
- "top": 0,
81
- "zIndex": 9999,
82
- },
83
- undefined,
84
- ]
85
- }
86
- themeVariant="text"
87
- >
88
- <Text
89
- allowFontScaling={false}
90
- style={
91
- [
92
- {
93
- "color": "#001f23",
94
- "fontFamily": "BeVietnamPro-Regular",
95
- "fontSize": 16,
96
- "letterSpacing": 0.48,
97
- "lineHeight": 24,
98
- },
99
- [
100
- {
101
- "alignContent": "center",
102
- "alignItems": "center",
103
- "color": "#001f23",
104
- "marginTop": -2,
105
- "textAlignVertical": "center",
106
- },
107
- undefined,
108
- ],
109
- ]
110
- }
111
- testID="input-label"
112
- themeIntent="body"
113
- themeState="error"
114
- themeTypeface="neutral"
115
- themeVariant="regular"
116
- >
117
- Rich Text Editor
118
- </Text>
119
- </View>
120
132
  <WebView
121
133
  accessibilityState={
122
134
  {
@@ -324,6 +336,69 @@ exports[`RichTextEditor should render correctly 1`] = `
324
336
  }
325
337
  >
326
338
  <View
339
+ collapsable={false}
340
+ pointerEvents="none"
341
+ style={
342
+ {
343
+ "alignItems": "center",
344
+ "flexDirection": "row",
345
+ "left": -32,
346
+ "position": "absolute",
347
+ "right": 0,
348
+ "top": -10.666666666666666,
349
+ "transform": [
350
+ {
351
+ "translateY": 0,
352
+ },
353
+ {
354
+ "translateX": 48,
355
+ },
356
+ {
357
+ "scale": 1,
358
+ },
359
+ ],
360
+ "zIndex": 1,
361
+ }
362
+ }
363
+ testID="input-label-container"
364
+ themeVariant="text"
365
+ >
366
+ <Text
367
+ allowFontScaling={false}
368
+ style={
369
+ [
370
+ {
371
+ "color": "#001f23",
372
+ "fontFamily": "BeVietnamPro-Regular",
373
+ "fontSize": 16,
374
+ "letterSpacing": 0.48,
375
+ "lineHeight": 24,
376
+ },
377
+ [
378
+ {
379
+ "alignContent": "center",
380
+ "alignItems": "center",
381
+ "color": "#001f23",
382
+ "marginTop": -2,
383
+ "textAlignVertical": "center",
384
+ },
385
+ {
386
+ "backgroundColor": "#ffffff",
387
+ },
388
+ ],
389
+ ]
390
+ }
391
+ testID="input-label"
392
+ themeIntent="body"
393
+ themeState="error"
394
+ themeTypeface="neutral"
395
+ themeVariant="regular"
396
+ >
397
+ Rich Text Editor
398
+ </Text>
399
+ </View>
400
+ <View
401
+ onLayout={[Function]}
327
402
  style={
328
403
  [
329
404
  {
@@ -370,57 +445,6 @@ exports[`RichTextEditor should render correctly 1`] = `
370
445
  ]
371
446
  }
372
447
  >
373
- <View
374
- pointerEvents="none"
375
- style={
376
- [
377
- {
378
- "alignItems": "center",
379
- "bottom": 0,
380
- "flexDirection": "row",
381
- "left": 0,
382
- "position": "absolute",
383
- "right": 0,
384
- "top": 0,
385
- "zIndex": 9999,
386
- },
387
- undefined,
388
- ]
389
- }
390
- themeVariant="text"
391
- >
392
- <Text
393
- allowFontScaling={false}
394
- style={
395
- [
396
- {
397
- "color": "#001f23",
398
- "fontFamily": "BeVietnamPro-Regular",
399
- "fontSize": 16,
400
- "letterSpacing": 0.48,
401
- "lineHeight": 24,
402
- },
403
- [
404
- {
405
- "alignContent": "center",
406
- "alignItems": "center",
407
- "color": "#001f23",
408
- "marginTop": -2,
409
- "textAlignVertical": "center",
410
- },
411
- undefined,
412
- ],
413
- ]
414
- }
415
- testID="input-label"
416
- themeIntent="body"
417
- themeState="error"
418
- themeTypeface="neutral"
419
- themeVariant="regular"
420
- >
421
- Rich Text Editor
422
- </Text>
423
- </View>
424
448
  <WebView
425
449
  accessibilityState={
426
450
  {