@fountain-ui/core 3.0.0-alpha.44 → 3.0.0-alpha.46

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 (51) hide show
  1. package/build/commonjs/BottomSheetTitle/BottomSheetTitle.js +1 -1
  2. package/build/commonjs/BottomSheetTitle/BottomSheetTitle.js.map +1 -1
  3. package/build/commonjs/BottomSheetTitle/BottomSheetTitleProps.js.map +1 -1
  4. package/build/commonjs/Image/Image.js +5 -0
  5. package/build/commonjs/Image/Image.js.map +1 -1
  6. package/build/commonjs/Image/ImageProps.js.map +1 -1
  7. package/build/commonjs/Image/preload.js +10 -0
  8. package/build/commonjs/Image/preload.js.map +1 -0
  9. package/build/commonjs/Image/preload.native.js +22 -0
  10. package/build/commonjs/Image/preload.native.js.map +1 -0
  11. package/build/commonjs/ImageCore/ImageCoreNative.js +10 -7
  12. package/build/commonjs/ImageCore/ImageCoreNative.js.map +1 -1
  13. package/build/commonjs/ImageCore/ImageCoreProps.js.map +1 -1
  14. package/build/commonjs/TextField/TextField.js +33 -3
  15. package/build/commonjs/TextField/TextField.js.map +1 -1
  16. package/build/commonjs/Tooltip/Tooltip.js +5 -1
  17. package/build/commonjs/Tooltip/Tooltip.js.map +1 -1
  18. package/build/module/BottomSheetTitle/BottomSheetTitle.js +1 -1
  19. package/build/module/BottomSheetTitle/BottomSheetTitle.js.map +1 -1
  20. package/build/module/BottomSheetTitle/BottomSheetTitleProps.js.map +1 -1
  21. package/build/module/Image/Image.js +4 -0
  22. package/build/module/Image/Image.js.map +1 -1
  23. package/build/module/Image/ImageProps.js.map +1 -1
  24. package/build/module/Image/preload.js +3 -0
  25. package/build/module/Image/preload.js.map +1 -0
  26. package/build/module/Image/preload.native.js +12 -0
  27. package/build/module/Image/preload.native.js.map +1 -0
  28. package/build/module/ImageCore/ImageCoreNative.js +11 -7
  29. package/build/module/ImageCore/ImageCoreNative.js.map +1 -1
  30. package/build/module/ImageCore/ImageCoreProps.js.map +1 -1
  31. package/build/module/TextField/TextField.js +33 -4
  32. package/build/module/TextField/TextField.js.map +1 -1
  33. package/build/module/Tooltip/Tooltip.js +6 -2
  34. package/build/module/Tooltip/Tooltip.js.map +1 -1
  35. package/build/typescript/BottomSheetTitle/BottomSheetTitleProps.d.ts +3 -4
  36. package/build/typescript/Image/Image.d.ts +1 -0
  37. package/build/typescript/Image/ImageProps.d.ts +6 -0
  38. package/build/typescript/Image/preload.d.ts +2 -0
  39. package/build/typescript/Image/preload.native.d.ts +2 -0
  40. package/build/typescript/ImageCore/ImageCoreProps.d.ts +1 -0
  41. package/package.json +2 -2
  42. package/src/BottomSheetTitle/BottomSheetTitle.tsx +1 -1
  43. package/src/BottomSheetTitle/BottomSheetTitleProps.ts +3 -4
  44. package/src/Image/Image.tsx +4 -0
  45. package/src/Image/ImageProps.ts +7 -0
  46. package/src/Image/preload.native.ts +6 -0
  47. package/src/Image/preload.ts +5 -0
  48. package/src/ImageCore/ImageCoreNative.tsx +10 -7
  49. package/src/ImageCore/ImageCoreProps.ts +1 -0
  50. package/src/TextField/TextField.tsx +33 -3
  51. package/src/Tooltip/Tooltip.tsx +6 -1
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useCallback, useLayoutEffect, useRef, useState } from 'react';
2
2
  import type { NativeSyntheticEvent, TextInputFocusEventData } from 'react-native';
3
3
  import { Platform, StyleSheet, Text, TextInput, View } from 'react-native';
4
4
  import type { FountainUiStyle } from '@fountain-ui/styles';
@@ -11,6 +11,8 @@ import type TextFieldProps from './TextFieldProps';
11
11
  import type { TextFieldStatus, TextFieldVariant } from './TextFieldProps';
12
12
  import useVariantStyleMap from './useVariantStyleMap';
13
13
 
14
+ const isWeb = Platform.OS === 'web';
15
+
14
16
  const styles = StyleSheet.create({
15
17
  root: {
16
18
  alignItems: 'center',
@@ -57,6 +59,7 @@ const TextField = React.forwardRef<TextInput, TextFieldProps>(function TextField
57
59
  const {
58
60
  autoFocus,
59
61
  containerStyle: containerStyleProp,
62
+ multiline,
60
63
  editable = true,
61
64
  hint,
62
65
  isLoading,
@@ -84,6 +87,17 @@ const TextField = React.forwardRef<TextInput, TextFieldProps>(function TextField
84
87
  const [isFocused, setIsFocused] = useState<boolean>(autoFocus ?? false);
85
88
  const [secureTextEntry, setSecureTextEntry] = useState<boolean>(secureTextEntryProp ?? false);
86
89
 
90
+ const internalRef = useRef<TextInput>(null);
91
+
92
+ const mergedRef = useCallback((node: TextInput | null) => {
93
+ (internalRef as React.MutableRefObject<TextInput | null>).current = node;
94
+ if (typeof ref === 'function') {
95
+ ref(node);
96
+ } else if (ref) {
97
+ (ref as React.MutableRefObject<TextInput | null>).current = node;
98
+ }
99
+ }, [ref]);
100
+
87
101
  const variantStyles = useVariantStyleMap(variant, status, isFocused);
88
102
 
89
103
  const handleBlur = (event: NativeSyntheticEvent<TextInputFocusEventData>) => {
@@ -100,6 +114,21 @@ const TextField = React.forwardRef<TextInput, TextFieldProps>(function TextField
100
114
  setSecureTextEntry((current) => !current);
101
115
  };
102
116
 
117
+ const resizeHeight = useCallback(() => {
118
+ const el = internalRef.current as unknown as HTMLTextAreaElement | null;
119
+ if (el) {
120
+ el.style.height = 'auto';
121
+ el.style.height = `${el.scrollHeight}px`;
122
+ }
123
+ }, []);
124
+
125
+ useLayoutEffect(() => {
126
+ const shouldResizeHeight = multiline && isWeb;
127
+ if (shouldResizeHeight) {
128
+ resizeHeight();
129
+ }
130
+ }, [resizeHeight, multiline, value]);
131
+
103
132
  const handleChangeText = (text: string) => {
104
133
  onChangeTextProp?.(text);
105
134
  };
@@ -119,7 +148,7 @@ const TextField = React.forwardRef<TextInput, TextFieldProps>(function TextField
119
148
  styles.input,
120
149
  variantStyles.inputStyle,
121
150
  variantStyles.inputFontStyle,
122
- Platform.OS === 'web' ? { outlineWidth: 0 } as FountainUiStyle : {},
151
+ isWeb ? { outlineWidth: 0 } as FountainUiStyle : {},
123
152
  styleProp,
124
153
  ]);
125
154
 
@@ -180,10 +209,11 @@ const TextField = React.forwardRef<TextInput, TextFieldProps>(function TextField
180
209
  onBlur={handleBlur}
181
210
  onChangeText={handleChangeText}
182
211
  onFocus={handleFocus}
183
- ref={ref}
212
+ ref={mergedRef}
184
213
  secureTextEntry={secureTextEntry}
185
214
  style={inputStyle}
186
215
  value={value}
216
+ multiline={multiline}
187
217
  {...otherProps}
188
218
  />
189
219
  </View>
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { Platform, Text, View, ViewProps } from 'react-native';
2
+ import { Platform, StyleSheet, Text, View, ViewProps } from 'react-native';
3
3
  import type { WithTimingConfig } from 'react-native-reanimated';
4
4
  import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
5
5
  import type { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';
@@ -150,8 +150,13 @@ export default function Tooltip(props: TooltipProps) {
150
150
  { flexShrink: 1 },
151
151
  ]);
152
152
 
153
+ const beakOverlapStyle = {
154
+ [placement === 'top' ? 'marginTop' : placement === 'bottom' ? 'marginBottom' : placement === 'left' ? 'marginLeft' : 'marginRight']: -StyleSheet.hairlineWidth,
155
+ };
156
+
153
157
  const beakStyle = css({
154
158
  transform: [isVerticalPlacement ? { translateX: beakOffset } : { translateY: beakOffset }],
159
+ ...beakOverlapStyle,
155
160
  });
156
161
 
157
162
  const buttonElem = (