@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.
- package/build/commonjs/BottomSheetTitle/BottomSheetTitle.js +1 -1
- package/build/commonjs/BottomSheetTitle/BottomSheetTitle.js.map +1 -1
- package/build/commonjs/BottomSheetTitle/BottomSheetTitleProps.js.map +1 -1
- package/build/commonjs/Image/Image.js +5 -0
- package/build/commonjs/Image/Image.js.map +1 -1
- package/build/commonjs/Image/ImageProps.js.map +1 -1
- package/build/commonjs/Image/preload.js +10 -0
- package/build/commonjs/Image/preload.js.map +1 -0
- package/build/commonjs/Image/preload.native.js +22 -0
- package/build/commonjs/Image/preload.native.js.map +1 -0
- package/build/commonjs/ImageCore/ImageCoreNative.js +10 -7
- package/build/commonjs/ImageCore/ImageCoreNative.js.map +1 -1
- package/build/commonjs/ImageCore/ImageCoreProps.js.map +1 -1
- package/build/commonjs/TextField/TextField.js +33 -3
- package/build/commonjs/TextField/TextField.js.map +1 -1
- package/build/commonjs/Tooltip/Tooltip.js +5 -1
- package/build/commonjs/Tooltip/Tooltip.js.map +1 -1
- package/build/module/BottomSheetTitle/BottomSheetTitle.js +1 -1
- package/build/module/BottomSheetTitle/BottomSheetTitle.js.map +1 -1
- package/build/module/BottomSheetTitle/BottomSheetTitleProps.js.map +1 -1
- package/build/module/Image/Image.js +4 -0
- package/build/module/Image/Image.js.map +1 -1
- package/build/module/Image/ImageProps.js.map +1 -1
- package/build/module/Image/preload.js +3 -0
- package/build/module/Image/preload.js.map +1 -0
- package/build/module/Image/preload.native.js +12 -0
- package/build/module/Image/preload.native.js.map +1 -0
- package/build/module/ImageCore/ImageCoreNative.js +11 -7
- package/build/module/ImageCore/ImageCoreNative.js.map +1 -1
- package/build/module/ImageCore/ImageCoreProps.js.map +1 -1
- package/build/module/TextField/TextField.js +33 -4
- package/build/module/TextField/TextField.js.map +1 -1
- package/build/module/Tooltip/Tooltip.js +6 -2
- package/build/module/Tooltip/Tooltip.js.map +1 -1
- package/build/typescript/BottomSheetTitle/BottomSheetTitleProps.d.ts +3 -4
- package/build/typescript/Image/Image.d.ts +1 -0
- package/build/typescript/Image/ImageProps.d.ts +6 -0
- package/build/typescript/Image/preload.d.ts +2 -0
- package/build/typescript/Image/preload.native.d.ts +2 -0
- package/build/typescript/ImageCore/ImageCoreProps.d.ts +1 -0
- package/package.json +2 -2
- package/src/BottomSheetTitle/BottomSheetTitle.tsx +1 -1
- package/src/BottomSheetTitle/BottomSheetTitleProps.ts +3 -4
- package/src/Image/Image.tsx +4 -0
- package/src/Image/ImageProps.ts +7 -0
- package/src/Image/preload.native.ts +6 -0
- package/src/Image/preload.ts +5 -0
- package/src/ImageCore/ImageCoreNative.tsx +10 -7
- package/src/ImageCore/ImageCoreProps.ts +1 -0
- package/src/TextField/TextField.tsx +33 -3
- 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
|
-
|
|
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={
|
|
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>
|
package/src/Tooltip/Tooltip.tsx
CHANGED
|
@@ -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 = (
|