@hero-design/rn 8.44.0 → 8.44.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 (25) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/CHANGELOG.md +6 -0
  3. package/es/index.js +154 -96
  4. package/lib/index.js +154 -96
  5. package/package.json +1 -1
  6. package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +102 -57
  7. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +34 -19
  8. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +34 -19
  9. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +34 -19
  10. package/src/components/RichTextEditor/RichTextEditor.tsx +76 -38
  11. package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +126 -102
  12. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +235 -146
  13. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +201 -127
  14. package/src/components/TextInput/StyledTextInput.tsx +8 -31
  15. package/src/components/TextInput/__tests__/StyledTextInput.spec.tsx +0 -44
  16. package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +21 -638
  17. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +1126 -833
  18. package/src/components/TextInput/__tests__/index.spec.tsx +2 -2
  19. package/src/components/TextInput/index.tsx +113 -57
  20. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +68 -38
  21. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +68 -38
  22. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +2 -2
  23. package/src/theme/components/textInput.ts +2 -2
  24. package/types/components/TextInput/StyledTextInput.d.ts +4 -24
  25. package/types/components/TextInput/index.d.ts +1 -0
@@ -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
  {