@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.
- package/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +23 -2
- package/es/index.js +764 -578
- package/lib/index.js +764 -578
- package/package.json +6 -6
- package/src/components/Accordion/index.tsx +1 -1
- package/src/components/Avatar/AvatarStack/StyledAvatarStack.tsx +63 -9
- package/src/components/Avatar/AvatarStack/__tests__/StyledAvatarStack.spec.tsx +71 -9
- package/src/components/Avatar/AvatarStack/__tests__/__snapshots__/StyledAvatarStack.spec.tsx.snap +271 -2
- package/src/components/Avatar/AvatarStack/__tests__/__snapshots__/index.spec.tsx.snap +2156 -7
- package/src/components/Avatar/AvatarStack/__tests__/index.spec.tsx +140 -6
- package/src/components/Avatar/AvatarStack/index.tsx +94 -9
- package/src/components/Carousel/index.tsx +18 -11
- package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +108 -57
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +36 -19
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +36 -19
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +36 -19
- package/src/components/RichTextEditor/RichTextEditor.tsx +89 -38
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +130 -102
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +247 -146
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +211 -127
- package/src/components/TextInput/StyledTextInput.tsx +9 -31
- package/src/components/TextInput/__tests__/StyledTextInput.spec.tsx +0 -44
- package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +21 -638
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +1159 -833
- package/src/components/TextInput/__tests__/index.spec.tsx +2 -2
- package/src/components/TextInput/index.tsx +128 -57
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +72 -38
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +72 -38
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +2 -2
- package/src/theme/components/textInput.ts +2 -2
- package/types/components/Accordion/index.d.ts +1 -1
- package/types/components/Avatar/AvatarStack/StyledAvatarStack.d.ts +13 -0
- package/types/components/Avatar/AvatarStack/index.d.ts +14 -2
- package/types/components/Avatar/index.d.ts +1 -1
- package/types/components/TextInput/StyledTextInput.d.ts +4 -24
- 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,40 +99,55 @@ 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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
108
|
+
{
|
|
109
|
+
"alignItems": "center",
|
|
110
|
+
"flexDirection": "row",
|
|
111
|
+
"justifyContent": "center",
|
|
112
|
+
"left": 0,
|
|
113
|
+
"position": "absolute",
|
|
114
|
+
"right": 0,
|
|
115
|
+
"top": -10.666666666666666,
|
|
116
|
+
"transform": [
|
|
117
|
+
{
|
|
118
|
+
"translateY": 0,
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"translateX": 24,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"scale": 1,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
"zIndex": 1,
|
|
128
|
+
}
|
|
117
129
|
}
|
|
118
|
-
|
|
130
|
+
themeVariant="text"
|
|
119
131
|
>
|
|
120
132
|
<Text
|
|
121
133
|
allowFontScaling={false}
|
|
134
|
+
onLayout={[Function]}
|
|
122
135
|
style={
|
|
123
136
|
[
|
|
124
137
|
{
|
|
125
138
|
"color": "#001f23",
|
|
126
139
|
"fontFamily": "BeVietnamPro-Regular",
|
|
127
|
-
"fontSize":
|
|
140
|
+
"fontSize": 16,
|
|
128
141
|
"letterSpacing": 0.48,
|
|
129
|
-
"lineHeight":
|
|
142
|
+
"lineHeight": 24,
|
|
130
143
|
},
|
|
131
144
|
[
|
|
132
145
|
{
|
|
146
|
+
"alignContent": "center",
|
|
147
|
+
"alignItems": "center",
|
|
133
148
|
"color": "#001f23",
|
|
134
|
-
"
|
|
149
|
+
"marginTop": -2,
|
|
150
|
+
"textAlignVertical": "center",
|
|
135
151
|
},
|
|
136
152
|
{
|
|
137
153
|
"backgroundColor": "#ffffff",
|
|
@@ -140,9 +156,10 @@ exports[`DatePickerAndroid renders correctly 1`] = `
|
|
|
140
156
|
]
|
|
141
157
|
}
|
|
142
158
|
testID="input-label"
|
|
143
|
-
themeFontWeight="regular"
|
|
144
159
|
themeIntent="body"
|
|
145
160
|
themeState="filled"
|
|
161
|
+
themeTypeface="neutral"
|
|
162
|
+
themeVariant="regular"
|
|
146
163
|
>
|
|
147
164
|
Start date
|
|
148
165
|
</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,40 +99,55 @@ 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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
108
|
+
{
|
|
109
|
+
"alignItems": "center",
|
|
110
|
+
"flexDirection": "row",
|
|
111
|
+
"justifyContent": "center",
|
|
112
|
+
"left": 0,
|
|
113
|
+
"position": "absolute",
|
|
114
|
+
"right": 0,
|
|
115
|
+
"top": -10.666666666666666,
|
|
116
|
+
"transform": [
|
|
117
|
+
{
|
|
118
|
+
"translateY": 0,
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"translateX": 24,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"scale": 1,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
"zIndex": 1,
|
|
128
|
+
}
|
|
117
129
|
}
|
|
118
|
-
|
|
130
|
+
themeVariant="text"
|
|
119
131
|
>
|
|
120
132
|
<Text
|
|
121
133
|
allowFontScaling={false}
|
|
134
|
+
onLayout={[Function]}
|
|
122
135
|
style={
|
|
123
136
|
[
|
|
124
137
|
{
|
|
125
138
|
"color": "#001f23",
|
|
126
139
|
"fontFamily": "BeVietnamPro-Regular",
|
|
127
|
-
"fontSize":
|
|
140
|
+
"fontSize": 16,
|
|
128
141
|
"letterSpacing": 0.48,
|
|
129
|
-
"lineHeight":
|
|
142
|
+
"lineHeight": 24,
|
|
130
143
|
},
|
|
131
144
|
[
|
|
132
145
|
{
|
|
146
|
+
"alignContent": "center",
|
|
147
|
+
"alignItems": "center",
|
|
133
148
|
"color": "#001f23",
|
|
134
|
-
"
|
|
149
|
+
"marginTop": -2,
|
|
150
|
+
"textAlignVertical": "center",
|
|
135
151
|
},
|
|
136
152
|
{
|
|
137
153
|
"backgroundColor": "#ffffff",
|
|
@@ -140,9 +156,10 @@ exports[`DatePickerCalendar renders correctly 1`] = `
|
|
|
140
156
|
]
|
|
141
157
|
}
|
|
142
158
|
testID="input-label"
|
|
143
|
-
themeFontWeight="regular"
|
|
144
159
|
themeIntent="body"
|
|
145
160
|
themeState="filled"
|
|
161
|
+
themeTypeface="neutral"
|
|
162
|
+
themeVariant="regular"
|
|
146
163
|
>
|
|
147
164
|
Start date
|
|
148
165
|
</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,40 +99,55 @@ 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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
108
|
+
{
|
|
109
|
+
"alignItems": "center",
|
|
110
|
+
"flexDirection": "row",
|
|
111
|
+
"justifyContent": "center",
|
|
112
|
+
"left": 0,
|
|
113
|
+
"position": "absolute",
|
|
114
|
+
"right": 0,
|
|
115
|
+
"top": -10.666666666666666,
|
|
116
|
+
"transform": [
|
|
117
|
+
{
|
|
118
|
+
"translateY": 0,
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"translateX": 24,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"scale": 1,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
"zIndex": 1,
|
|
128
|
+
}
|
|
117
129
|
}
|
|
118
|
-
|
|
130
|
+
themeVariant="text"
|
|
119
131
|
>
|
|
120
132
|
<Text
|
|
121
133
|
allowFontScaling={false}
|
|
134
|
+
onLayout={[Function]}
|
|
122
135
|
style={
|
|
123
136
|
[
|
|
124
137
|
{
|
|
125
138
|
"color": "#001f23",
|
|
126
139
|
"fontFamily": "BeVietnamPro-Regular",
|
|
127
|
-
"fontSize":
|
|
140
|
+
"fontSize": 16,
|
|
128
141
|
"letterSpacing": 0.48,
|
|
129
|
-
"lineHeight":
|
|
142
|
+
"lineHeight": 24,
|
|
130
143
|
},
|
|
131
144
|
[
|
|
132
145
|
{
|
|
146
|
+
"alignContent": "center",
|
|
147
|
+
"alignItems": "center",
|
|
133
148
|
"color": "#001f23",
|
|
134
|
-
"
|
|
149
|
+
"marginTop": -2,
|
|
150
|
+
"textAlignVertical": "center",
|
|
135
151
|
},
|
|
136
152
|
{
|
|
137
153
|
"backgroundColor": "#ffffff",
|
|
@@ -140,9 +156,10 @@ exports[`DatePickerIOS renders correctly 1`] = `
|
|
|
140
156
|
]
|
|
141
157
|
}
|
|
142
158
|
testID="input-label"
|
|
143
|
-
themeFontWeight="regular"
|
|
144
159
|
themeIntent="body"
|
|
145
160
|
themeState="filled"
|
|
161
|
+
themeTypeface="neutral"
|
|
162
|
+
themeVariant="regular"
|
|
146
163
|
>
|
|
147
164
|
Start date
|
|
148
165
|
</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,32 @@ const RichTextEditor: ComponentType<RichTextEditorProps> = ({
|
|
|
150
148
|
postMessage(webview.current, message);
|
|
151
149
|
}
|
|
152
150
|
};
|
|
151
|
+
const [inputSize, setInputSize] = React.useState<{
|
|
152
|
+
height: number;
|
|
153
|
+
width: number;
|
|
154
|
+
}>({ height: 0, width: 0 });
|
|
155
|
+
const [labelWidth, setLabelWidth] = React.useState<number>(0);
|
|
156
|
+
|
|
157
|
+
const focusAnimation = useRef(new Animated.Value(0)).current;
|
|
158
|
+
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
Animated.timing(focusAnimation, {
|
|
161
|
+
toValue: isFocused || !isEmptyValue ? 1 : 0,
|
|
162
|
+
duration: LABEL_ANIMATION_DURATION,
|
|
163
|
+
easing: Easing.bezier(0.4, 0, 0.2, 1),
|
|
164
|
+
useNativeDriver: true,
|
|
165
|
+
}).start();
|
|
166
|
+
}, [focusAnimation, isEmptyValue, isFocused]);
|
|
167
|
+
|
|
168
|
+
const onLayout = useCallback((event: LayoutChangeEvent) => {
|
|
169
|
+
const { height, width } = event.nativeEvent.layout;
|
|
170
|
+
setInputSize((prev) => ({ ...prev, height, width }));
|
|
171
|
+
}, []);
|
|
172
|
+
|
|
173
|
+
const onLabelLayout = useCallback((event: LayoutChangeEvent) => {
|
|
174
|
+
const { width } = event.nativeEvent.layout;
|
|
175
|
+
setLabelWidth(width);
|
|
176
|
+
}, []);
|
|
153
177
|
|
|
154
178
|
useEffect(() => {
|
|
155
179
|
const removeFocusListener = Events.on(
|
|
@@ -307,41 +331,68 @@ const RichTextEditor: ComponentType<RichTextEditorProps> = ({
|
|
|
307
331
|
|
|
308
332
|
return (
|
|
309
333
|
<StyledContainer testID={testID}>
|
|
310
|
-
<
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
334
|
+
<StyledLabelContainerInsideTextInput
|
|
335
|
+
themeVariant="text"
|
|
336
|
+
pointerEvents="none"
|
|
337
|
+
testID="input-label-container"
|
|
338
|
+
style={[
|
|
339
|
+
{
|
|
340
|
+
position: 'absolute',
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
transform: [
|
|
344
|
+
{
|
|
345
|
+
translateY: focusAnimation.interpolate({
|
|
346
|
+
inputRange: [0, 1],
|
|
347
|
+
outputRange: [inputSize.height / 2, 0],
|
|
348
|
+
}),
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
translateX: focusAnimation.interpolate({
|
|
352
|
+
inputRange: [0, 1],
|
|
353
|
+
outputRange: [
|
|
354
|
+
-inputSize.width / 2 + labelWidth / 2 + theme.space.large,
|
|
355
|
+
-inputSize.width / 2 + labelWidth / 2 + theme.space.small,
|
|
356
|
+
],
|
|
357
|
+
}),
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
scale: focusAnimation.interpolate({
|
|
361
|
+
inputRange: [0, 1],
|
|
362
|
+
outputRange: [1, 0.75],
|
|
363
|
+
}),
|
|
364
|
+
},
|
|
365
|
+
],
|
|
366
|
+
},
|
|
367
|
+
]}
|
|
368
|
+
>
|
|
369
|
+
{required && (
|
|
370
|
+
<StyledAsteriskLabelInsideTextInput
|
|
371
|
+
style={{
|
|
372
|
+
backgroundColor: theme.__hd__.textInput.colors.labelBackground,
|
|
373
|
+
}}
|
|
374
|
+
themeState={state}
|
|
375
|
+
>
|
|
376
|
+
*
|
|
377
|
+
</StyledAsteriskLabelInsideTextInput>
|
|
378
|
+
)}
|
|
379
|
+
{!!label && (
|
|
380
|
+
<StyledLabelInsideTextInput
|
|
381
|
+
style={{
|
|
382
|
+
backgroundColor: theme.__hd__.textInput.colors.labelBackground,
|
|
383
|
+
}}
|
|
384
|
+
testID="input-label"
|
|
385
|
+
themeState={state}
|
|
386
|
+
onLayout={onLabelLayout}
|
|
387
|
+
>
|
|
388
|
+
{label}
|
|
389
|
+
</StyledLabelInsideTextInput>
|
|
323
390
|
)}
|
|
391
|
+
</StyledLabelContainerInsideTextInput>
|
|
392
|
+
<StyledTextInputContainer onLayout={onLayout}>
|
|
393
|
+
<StyledBorderBackDrop themeState={state} themeFocused={isFocused} />
|
|
394
|
+
|
|
324
395
|
<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
396
|
<TouchableWithoutFeedback onPress={(e) => e.stopPropagation()}>
|
|
346
397
|
<StyledWebView
|
|
347
398
|
ref={webview}
|