@0610studio/zs-ui 0.18.0 → 0.19.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.
- package/build/ZsUiModule.d.ts.map +1 -1
- package/build/ZsUiModule.js +0 -2
- package/build/ZsUiModule.js.map +1 -1
- package/build/assets/SvgExclamation.d.ts.map +1 -1
- package/build/assets/SvgExclamation.js.map +1 -1
- package/build/assets/SvgTooltipTail.d.ts +7 -0
- package/build/assets/SvgTooltipTail.d.ts.map +1 -0
- package/build/assets/SvgTooltipTail.js +7 -0
- package/build/assets/SvgTooltipTail.js.map +1 -0
- package/build/context/OverlayContext.d.ts.map +1 -1
- package/build/context/OverlayContext.js +11 -14
- package/build/context/OverlayContext.js.map +1 -1
- package/build/context/ThemeContext.d.ts +9 -0
- package/build/context/ThemeContext.d.ts.map +1 -1
- package/build/context/ThemeContext.js +24 -15
- package/build/context/ThemeContext.js.map +1 -1
- package/build/index.d.ts +16 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +7 -7
- package/build/index.js.map +1 -1
- package/build/model/globalOverlay.d.ts +0 -8
- package/build/model/globalOverlay.d.ts.map +1 -1
- package/build/model/globalOverlay.js +0 -9
- package/build/model/globalOverlay.js.map +1 -1
- package/build/model/types.d.ts +2 -1
- package/build/model/types.d.ts.map +1 -1
- package/build/model/types.js.map +1 -1
- package/build/model/useFoldingState.d.ts.map +1 -1
- package/build/model/useFoldingState.js +51 -32
- package/build/model/useFoldingState.js.map +1 -1
- package/build/model/useKeyboard.d.ts.map +1 -1
- package/build/model/useKeyboard.js +8 -4
- package/build/model/useKeyboard.js.map +1 -1
- package/build/model/utils.d.ts +1 -1
- package/build/model/utils.d.ts.map +1 -1
- package/build/model/utils.js +2 -1
- package/build/model/utils.js.map +1 -1
- package/build/overlay/AlertOverlay/index.d.ts +1 -2
- package/build/overlay/AlertOverlay/index.d.ts.map +1 -1
- package/build/overlay/AlertOverlay/index.js +13 -11
- package/build/overlay/AlertOverlay/index.js.map +1 -1
- package/build/overlay/BottomSheetOverlay/index.d.ts.map +1 -1
- package/build/overlay/BottomSheetOverlay/index.js +22 -11
- package/build/overlay/BottomSheetOverlay/index.js.map +1 -1
- package/build/overlay/LoadingNotify/index.d.ts +2 -2
- package/build/overlay/LoadingNotify/index.d.ts.map +1 -1
- package/build/overlay/LoadingNotify/index.js +2 -2
- package/build/overlay/LoadingNotify/index.js.map +1 -1
- package/build/overlay/Modality/index.d.ts.map +1 -1
- package/build/overlay/Modality/index.js +6 -12
- package/build/overlay/Modality/index.js.map +1 -1
- package/build/overlay/PopOver/PopOverMenu.d.ts.map +1 -1
- package/build/overlay/PopOver/PopOverMenu.js +7 -8
- package/build/overlay/PopOver/PopOverMenu.js.map +1 -1
- package/build/overlay/SnackbarNotify/index.d.ts +3 -3
- package/build/overlay/SnackbarNotify/index.d.ts.map +1 -1
- package/build/overlay/SnackbarNotify/index.js +5 -4
- package/build/overlay/SnackbarNotify/index.js.map +1 -1
- package/build/overlay/SnackbarNotify/ui/SnackbarItem.d.ts +4 -4
- package/build/overlay/SnackbarNotify/ui/SnackbarItem.d.ts.map +1 -1
- package/build/overlay/SnackbarNotify/ui/SnackbarItem.js +9 -9
- package/build/overlay/SnackbarNotify/ui/SnackbarItem.js.map +1 -1
- package/build/overlay/ZSPortal/index.d.ts.map +1 -1
- package/build/overlay/ZSPortal/index.js +15 -4
- package/build/overlay/ZSPortal/index.js.map +1 -1
- package/build/overlay/ui/ModalBackground.js.map +1 -1
- package/build/theme/elevation.d.ts +94 -10
- package/build/theme/elevation.d.ts.map +1 -1
- package/build/theme/elevation.js +39 -35
- package/build/theme/elevation.js.map +1 -1
- package/build/theme/intentColors.d.ts +9 -0
- package/build/theme/intentColors.d.ts.map +1 -0
- package/build/theme/intentColors.js +30 -0
- package/build/theme/intentColors.js.map +1 -0
- package/build/theme/palette.d.ts +1 -5
- package/build/theme/palette.d.ts.map +1 -1
- package/build/theme/palette.js +3 -12
- package/build/theme/palette.js.map +1 -1
- package/build/theme/resolveColor.d.ts +4 -0
- package/build/theme/resolveColor.d.ts.map +1 -0
- package/build/theme/resolveColor.js +29 -0
- package/build/theme/resolveColor.js.map +1 -0
- package/build/theme/tokens.d.ts +35 -0
- package/build/theme/tokens.d.ts.map +1 -0
- package/build/theme/tokens.js +35 -0
- package/build/theme/tokens.js.map +1 -0
- package/build/theme/typography.d.ts.map +1 -1
- package/build/theme/typography.js +36 -72
- package/build/theme/typography.js.map +1 -1
- package/build/ui/ZSBlockButton/index.d.ts +4 -2
- package/build/ui/ZSBlockButton/index.d.ts.map +1 -1
- package/build/ui/ZSBlockButton/index.js +17 -80
- package/build/ui/ZSBlockButton/index.js.map +1 -1
- package/build/ui/ZSBorderBeam/index.d.ts +48 -0
- package/build/ui/ZSBorderBeam/index.d.ts.map +1 -0
- package/build/ui/ZSBorderBeam/index.js +135 -0
- package/build/ui/ZSBorderBeam/index.js.map +1 -0
- package/build/ui/ZSCheckBox/index.d.ts +18 -0
- package/build/ui/ZSCheckBox/index.d.ts.map +1 -0
- package/build/ui/ZSCheckBox/index.js +60 -0
- package/build/ui/ZSCheckBox/index.js.map +1 -0
- package/build/ui/ZSChip/index.d.ts +28 -0
- package/build/ui/ZSChip/index.d.ts.map +1 -0
- package/build/ui/ZSChip/index.js +76 -0
- package/build/ui/ZSChip/index.js.map +1 -0
- package/build/ui/ZSContainer/index.d.ts +19 -0
- package/build/ui/ZSContainer/index.d.ts.map +1 -1
- package/build/ui/ZSContainer/index.js +29 -15
- package/build/ui/ZSContainer/index.js.map +1 -1
- package/build/ui/ZSPressable/index.d.ts.map +1 -1
- package/build/ui/ZSPressable/index.js +9 -6
- package/build/ui/ZSPressable/index.js.map +1 -1
- package/build/ui/ZSRadioGroup/index.d.ts +4 -4
- package/build/ui/ZSRadioGroup/index.d.ts.map +1 -1
- package/build/ui/ZSRadioGroup/index.js +72 -52
- package/build/ui/ZSRadioGroup/index.js.map +1 -1
- package/build/ui/ZSSegmented/index.d.ts +26 -0
- package/build/ui/ZSSegmented/index.d.ts.map +1 -0
- package/build/ui/ZSSegmented/index.js +124 -0
- package/build/ui/ZSSegmented/index.js.map +1 -0
- package/build/ui/ZSSkeleton/SkiaShimmer.d.ts +18 -0
- package/build/ui/ZSSkeleton/SkiaShimmer.d.ts.map +1 -0
- package/build/ui/ZSSkeleton/SkiaShimmer.js +73 -0
- package/build/ui/ZSSkeleton/SkiaShimmer.js.map +1 -0
- package/build/ui/ZSSkeleton/index.d.ts +9 -3
- package/build/ui/ZSSkeleton/index.d.ts.map +1 -1
- package/build/ui/ZSSkeleton/index.js +13 -44
- package/build/ui/ZSSkeleton/index.js.map +1 -1
- package/build/ui/ZSSkeletonBox/index.d.ts +10 -3
- package/build/ui/ZSSkeletonBox/index.d.ts.map +1 -1
- package/build/ui/ZSSkeletonBox/index.js +9 -47
- package/build/ui/ZSSkeletonBox/index.js.map +1 -1
- package/build/ui/ZSSwitch/index.d.ts +4 -2
- package/build/ui/ZSSwitch/index.d.ts.map +1 -1
- package/build/ui/ZSSwitch/index.js +8 -6
- package/build/ui/ZSSwitch/index.js.map +1 -1
- package/build/ui/ZSText/index.d.ts +3 -2
- package/build/ui/ZSText/index.d.ts.map +1 -1
- package/build/ui/ZSText/index.js +5 -16
- package/build/ui/ZSText/index.js.map +1 -1
- package/build/ui/ZSTextField/index.d.ts.map +1 -1
- package/build/ui/ZSTextField/index.js +57 -40
- package/build/ui/ZSTextField/index.js.map +1 -1
- package/build/ui/ZSTextField/ui/ButtonClose.d.ts.map +1 -1
- package/build/ui/ZSTextField/ui/ButtonClose.js +4 -1
- package/build/ui/ZSTextField/ui/ButtonClose.js.map +1 -1
- package/build/ui/ZSTooltip/index.d.ts +38 -0
- package/build/ui/ZSTooltip/index.d.ts.map +1 -0
- package/build/ui/ZSTooltip/index.js +99 -0
- package/build/ui/ZSTooltip/index.js.map +1 -0
- package/build/ui/ZSView/index.d.ts +3 -2
- package/build/ui/ZSView/index.d.ts.map +1 -1
- package/build/ui/ZSView/index.js +7 -8
- package/build/ui/ZSView/index.js.map +1 -1
- package/build/ui/atoms/AnimatedWrapper.d.ts.map +1 -1
- package/build/ui/atoms/AnimatedWrapper.js +33 -40
- package/build/ui/atoms/AnimatedWrapper.js.map +1 -1
- package/build/ui/atoms/TextAtom.d.ts +1 -2
- package/build/ui/atoms/TextAtom.d.ts.map +1 -1
- package/build/ui/atoms/TextAtom.js.map +1 -1
- package/build/ui/atoms/ViewAtom.d.ts +1 -2
- package/build/ui/atoms/ViewAtom.d.ts.map +1 -1
- package/build/ui/atoms/ViewAtom.js.map +1 -1
- package/package.json +6 -1
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, useCallback, useState, forwardRef, useEffect, useRef } from 'react';
|
|
3
3
|
import { Platform, TextInput } from 'react-native';
|
|
4
|
-
import Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming, ReduceMotion } from 'react-native-reanimated';
|
|
4
|
+
import Animated, { interpolate, interpolateColor, useAnimatedStyle, useSharedValue, withTiming, ReduceMotion } from 'react-native-reanimated';
|
|
5
5
|
import ButtonClose from './ui/ButtonClose';
|
|
6
6
|
import ErrorComponent from './ui/ErrorComponent';
|
|
7
7
|
import { extractStyle } from '../../model/utils';
|
|
8
8
|
import { useTheme } from '../../context/ThemeContext';
|
|
9
|
+
import { DISABLED_OPACITY, DURATION, RADIUS } from '../../theme/tokens';
|
|
9
10
|
import ViewAtom from '../atoms/ViewAtom';
|
|
10
11
|
const iosOffset = Platform.OS === 'ios' ? 8 : 4;
|
|
11
|
-
const ANIM_DURATION =
|
|
12
|
+
const ANIM_DURATION = DURATION.fast;
|
|
12
13
|
const TIMING_CONFIG = { duration: ANIM_DURATION, reduceMotion: ReduceMotion.System };
|
|
13
|
-
const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, onChangeText, label = 'Placeholder', labelColor, placeHolderColor, inputBgColor, labelBgColor, borderWidth = 1.2, borderColor, focusColor, errorColor, borderRadius =
|
|
14
|
+
const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, onChangeText, label = 'Placeholder', labelColor, placeHolderColor, inputBgColor, labelBgColor, borderWidth = 1.2, borderColor, focusColor, errorColor, borderRadius = RADIUS.lg, paddingHorizontal = 15, errorMessage, textInputProps, boxStyle = 'outline', innerBoxStyle, disabled = false, allowFontScaling = true, isTextArea = false, }, ref) => {
|
|
14
15
|
const { typography, palette } = useTheme();
|
|
15
16
|
const [primaryStyle, subStyle] = typo.split('.');
|
|
16
17
|
const fErrorColor = errorColor || palette.danger.main;
|
|
17
18
|
const fontSize = extractStyle(typography[primaryStyle][subStyle], 'fontSize') || 17;
|
|
18
19
|
const fontFamily = extractStyle(typography[primaryStyle][subStyle], 'fontFamily') || '';
|
|
19
|
-
const floatProgress = useSharedValue(value !== '' ? 1 : 0);
|
|
20
|
-
const [isFocusedForUI, setIsFocusedForUI] = useState(false);
|
|
21
|
-
const boxHeightValue = useSharedValue(0);
|
|
22
20
|
const isError = status === 'error';
|
|
23
21
|
const hasValue = value !== '';
|
|
22
|
+
const floatProgress = useSharedValue(hasValue ? 1 : 0);
|
|
23
|
+
const focusProgress = useSharedValue(0);
|
|
24
|
+
const errorProgress = useSharedValue(isError ? 1 : 0);
|
|
25
|
+
const boxHeightValue = useSharedValue(0);
|
|
26
|
+
const [isFocusedForUI, setIsFocusedForUI] = useState(false);
|
|
24
27
|
const isFocusedRef = useRef(false);
|
|
25
28
|
const hasValueRef = useRef(hasValue);
|
|
26
29
|
hasValueRef.current = hasValue;
|
|
@@ -30,12 +33,26 @@ const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, on
|
|
|
30
33
|
floatProgress.value = withTiming(target, TIMING_CONFIG);
|
|
31
34
|
}
|
|
32
35
|
}, [hasValue]);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
const target = isError ? 1 : 0;
|
|
38
|
+
if (errorProgress.value !== target) {
|
|
39
|
+
errorProgress.value = withTiming(target, TIMING_CONFIG);
|
|
40
|
+
}
|
|
41
|
+
}, [isError]);
|
|
33
42
|
const animationConstants = useMemo(() => ({
|
|
34
43
|
baseFontSize: fontSize + (boxStyle === 'inbox' ? 1 : 0),
|
|
35
44
|
targetFontSize: boxStyle === 'inbox' ? 10 : 11,
|
|
36
45
|
baseTop: isTextArea ? 12 : 0,
|
|
37
46
|
targetTopOffset: boxStyle === 'inbox' ? 17 : 2,
|
|
38
47
|
}), [fontSize, boxStyle, isTextArea]);
|
|
48
|
+
const colorConfig = useMemo(() => ({
|
|
49
|
+
primaryColor: focusColor || palette.primary.main,
|
|
50
|
+
defaultBorderColor: borderColor || palette.grey[30],
|
|
51
|
+
defaultLabelColor: labelColor || palette.text.secondary,
|
|
52
|
+
placeholderColor: placeHolderColor || palette.grey[40],
|
|
53
|
+
errorColor: fErrorColor,
|
|
54
|
+
}), [focusColor, palette.primary.main, borderColor, palette.grey, labelColor, palette.text.secondary, placeHolderColor, fErrorColor]);
|
|
55
|
+
const nonFocusLabelColor = useMemo(() => (hasValue ? colorConfig.defaultLabelColor : colorConfig.placeholderColor), [hasValue, colorConfig.defaultLabelColor, colorConfig.placeholderColor]);
|
|
39
56
|
const animatedLabelStyle = useAnimatedStyle(() => {
|
|
40
57
|
const progress = floatProgress.value;
|
|
41
58
|
const labelTranslateY = interpolate(progress, [0, 1], [
|
|
@@ -43,51 +60,50 @@ const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, on
|
|
|
43
60
|
isTextArea ? -24 : -(boxHeightValue.value / 2) - 1 + animationConstants.targetTopOffset - animationConstants.baseTop,
|
|
44
61
|
], 'clamp');
|
|
45
62
|
const labelScale = interpolate(progress, [0, 1], [1, animationConstants.targetFontSize / animationConstants.baseFontSize], 'clamp');
|
|
63
|
+
const focusedColor = interpolateColor(focusProgress.value, [0, 1], [nonFocusLabelColor, colorConfig.primaryColor]);
|
|
64
|
+
const color = interpolateColor(errorProgress.value, [0, 1], [focusedColor, colorConfig.errorColor]);
|
|
46
65
|
return {
|
|
66
|
+
color,
|
|
47
67
|
transform: [
|
|
48
68
|
{ translateY: labelTranslateY },
|
|
49
69
|
{ scale: labelScale },
|
|
50
70
|
],
|
|
51
71
|
};
|
|
52
|
-
}, [animationConstants, isTextArea]);
|
|
72
|
+
}, [animationConstants, isTextArea, nonFocusLabelColor, colorConfig.primaryColor, colorConfig.errorColor]);
|
|
73
|
+
const animatedBorderStyle = useAnimatedStyle(() => {
|
|
74
|
+
const focusedColor = interpolateColor(focusProgress.value, [0, 1], [colorConfig.defaultBorderColor, colorConfig.primaryColor]);
|
|
75
|
+
const borderColor = interpolateColor(errorProgress.value, [0, 1], [focusedColor, colorConfig.errorColor]);
|
|
76
|
+
return { borderColor };
|
|
77
|
+
}, [colorConfig.defaultBorderColor, colorConfig.primaryColor, colorConfig.errorColor]);
|
|
53
78
|
const handleLayout = useCallback((event) => {
|
|
54
79
|
const { height } = event.nativeEvent.layout;
|
|
55
|
-
boxHeightValue.value
|
|
80
|
+
if (boxHeightValue.value !== height) {
|
|
81
|
+
boxHeightValue.value = height;
|
|
82
|
+
}
|
|
56
83
|
}, []);
|
|
57
|
-
const handleFocus = useCallback(() => {
|
|
84
|
+
const handleFocus = useCallback((event) => {
|
|
58
85
|
isFocusedRef.current = true;
|
|
59
86
|
if (floatProgress.value !== 1) {
|
|
60
87
|
floatProgress.value = withTiming(1, TIMING_CONFIG);
|
|
61
88
|
}
|
|
89
|
+
if (focusProgress.value !== 1) {
|
|
90
|
+
focusProgress.value = withTiming(1, TIMING_CONFIG);
|
|
91
|
+
}
|
|
62
92
|
setIsFocusedForUI(true);
|
|
63
|
-
|
|
64
|
-
|
|
93
|
+
textInputProps?.onFocus?.(event);
|
|
94
|
+
}, [textInputProps?.onFocus]);
|
|
95
|
+
const handleBlur = useCallback((event) => {
|
|
65
96
|
isFocusedRef.current = false;
|
|
66
97
|
const target = hasValueRef.current ? 1 : 0;
|
|
67
98
|
if (floatProgress.value !== target) {
|
|
68
99
|
floatProgress.value = withTiming(target, TIMING_CONFIG);
|
|
69
100
|
}
|
|
101
|
+
if (focusProgress.value !== 0) {
|
|
102
|
+
focusProgress.value = withTiming(0, TIMING_CONFIG);
|
|
103
|
+
}
|
|
70
104
|
setIsFocusedForUI(false);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
primaryColor: focusColor || palette.primary.main,
|
|
74
|
-
defaultBorderColor: borderColor || palette.grey[30],
|
|
75
|
-
defaultLabelColor: labelColor || palette.text.secondary,
|
|
76
|
-
placeholderColor: placeHolderColor || palette.grey[40],
|
|
77
|
-
errorColor: fErrorColor,
|
|
78
|
-
}), [focusColor, palette.primary.main, borderColor, palette.grey, labelColor, palette.text.secondary, placeHolderColor, fErrorColor]);
|
|
79
|
-
const currentBorderColor = isError
|
|
80
|
-
? colorConfig.errorColor
|
|
81
|
-
: isFocusedForUI
|
|
82
|
-
? colorConfig.primaryColor
|
|
83
|
-
: colorConfig.defaultBorderColor;
|
|
84
|
-
const currentLabelColor = isError
|
|
85
|
-
? colorConfig.errorColor
|
|
86
|
-
: isFocusedForUI
|
|
87
|
-
? colorConfig.primaryColor
|
|
88
|
-
: hasValue
|
|
89
|
-
? colorConfig.defaultLabelColor
|
|
90
|
-
: colorConfig.placeholderColor;
|
|
105
|
+
textInputProps?.onBlur?.(event);
|
|
106
|
+
}, [textInputProps?.onBlur]);
|
|
91
107
|
const styleConfig = useMemo(() => {
|
|
92
108
|
const baseStyle = {
|
|
93
109
|
width: '100%',
|
|
@@ -97,7 +113,6 @@ const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, on
|
|
|
97
113
|
backgroundColor: inputBgColor || palette.background.base,
|
|
98
114
|
paddingTop: boxStyle === 'inbox' ? 13 : 0,
|
|
99
115
|
};
|
|
100
|
-
// 박스 스타일에 따른 테두리 설정
|
|
101
116
|
let borderStyle = {};
|
|
102
117
|
if (boxStyle === 'outline' || boxStyle === 'inbox') {
|
|
103
118
|
borderStyle = { borderWidth };
|
|
@@ -105,7 +120,6 @@ const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, on
|
|
|
105
120
|
else if (boxStyle === 'underline') {
|
|
106
121
|
borderStyle = { borderBottomWidth: borderWidth };
|
|
107
122
|
}
|
|
108
|
-
// innerBoxStyle에 따른 스타일 설정
|
|
109
123
|
let innerStyle = {};
|
|
110
124
|
if (innerBoxStyle === 'top') {
|
|
111
125
|
innerStyle = {
|
|
@@ -143,10 +157,12 @@ const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, on
|
|
|
143
157
|
borderRadius: boxStyle === 'outline' ? 5 : 0,
|
|
144
158
|
...(Platform.OS === 'android' ? { overflow: 'hidden' } : {}),
|
|
145
159
|
}), [fontSize, animationConstants.baseTop, paddingHorizontal, labelBgColor, palette.background.base, boxStyle, fontFamily]);
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
160
|
+
const boxStyleArray = useMemo(() => [styleConfig, animatedBorderStyle], [styleConfig, animatedBorderStyle]);
|
|
161
|
+
const labelStyleArray = useMemo(() => [labelTextStyle, animatedLabelStyle], [labelTextStyle, animatedLabelStyle]);
|
|
162
|
+
const handleTextChange = useCallback((text) => {
|
|
163
|
+
onChangeText?.(text);
|
|
164
|
+
textInputProps?.onChangeText?.(text);
|
|
165
|
+
}, [onChangeText, textInputProps?.onChangeText]);
|
|
150
166
|
const textInputStyle = useMemo(() => [
|
|
151
167
|
{
|
|
152
168
|
paddingTop: 7 + iosOffset,
|
|
@@ -160,9 +176,10 @@ const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, on
|
|
|
160
176
|
},
|
|
161
177
|
textInputProps?.style,
|
|
162
178
|
], [palette.text.base, fontSize, fontFamily, textInputProps?.style]);
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
|
|
179
|
+
// 빈 문자열이 View 자식으로 렌더되지 않도록 boolean 으로 강제 (web 'Unexpected text node' 경고 방지)
|
|
180
|
+
const shouldShowCloseButton = Boolean(value) && isFocusedForUI;
|
|
181
|
+
const shouldShowError = status === 'error' && errorMessage !== undefined && errorMessage !== '';
|
|
182
|
+
return (_jsxs(ViewAtom, { style: { alignSelf: 'stretch', width: '100%', opacity: disabled ? DISABLED_OPACITY : 1 }, children: [_jsxs(Animated.View, { style: boxStyleArray, onLayout: handleLayout, pointerEvents: disabled ? 'none' : 'auto', children: [_jsx(TextInput, { ...textInputProps, ref: ref, style: textInputStyle, value: value, onFocus: handleFocus, onBlur: handleBlur, onChangeText: handleTextChange, allowFontScaling: allowFontScaling, selectionColor: palette.grey[50], autoCorrect: false, spellCheck: false }), _jsx(ViewAtom, { pointerEvents: "none", style: { position: 'absolute' }, children: _jsx(Animated.Text, { allowFontScaling: allowFontScaling, style: labelStyleArray, children: label }) }), shouldShowCloseButton && (_jsx(ButtonClose, { marginTop: isTextArea ? 13 : undefined, onChangeText: onChangeText }))] }), shouldShowError && (_jsx(ErrorComponent, { errorMessage: errorMessage, errorColor: fErrorColor }))] }));
|
|
166
183
|
});
|
|
167
184
|
ZSTextField.displayName = 'ZSTextField';
|
|
168
185
|
export default ZSTextField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSTextField/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtF,OAAO,EAAqB,QAAQ,EAAa,SAAS,EAA6B,MAAM,cAAc,CAAC;AAC5G,OAAO,QAAQ,EAAE,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5H,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD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Z,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,UAAU,EAClB,YAAY,EAAE,gBAAgB,EAC9B,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAChC,WAAW,EAAE,KAAK,EAClB,UAAU,EAAE,KAAK,GACjB,EAEF,KAAC,QAAQ,IAAC,aAAa,EAAC,MAAM,EAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,YAC5D,KAAC,QAAQ,CAAC,IAAI,IAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,EAAE,kBAAkB,CAAC,YACzH,KAAK,GACQ,GACP,EAEV,qBAAqB,IAAI,CACxB,KAAC,WAAW,IAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,EAAE,YAAY,GAAI,CACpF,IACQ,EAEV,eAAe,IAAI,CAClB,KAAC,cAAc,IAAC,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,GAAI,CACxE,IACQ,CACZ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,WAAW,CAAC,WAAW,GAAG,aAAa,CAAC;AAExC,eAAe,WAAW,CAAC","sourcesContent":["import { useMemo, useCallback, useState, forwardRef, useEffect, useRef } from 'react';\nimport { LayoutChangeEvent, Platform, StyleProp, TextInput, TextInputProps, TextStyle } from 'react-native';\nimport Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming, ReduceMotion } from 'react-native-reanimated';\nimport ButtonClose from './ui/ButtonClose';\nimport ErrorComponent from './ui/ErrorComponent';\nimport { TypoOptions, TypoStyle, TypoSubStyle } from '../../theme/types';\nimport { extractStyle } from '../../model/utils';\nimport { useTheme } from '../../context/ThemeContext';\nimport ViewAtom from '../atoms/ViewAtom';\n\nexport type BoxStyle = 'outline' | 'underline' | 'inbox';\n\nconst iosOffset = Platform.OS === 'ios' ? 8 : 4;\nconst ANIM_DURATION = 150;\nconst TIMING_CONFIG = { duration: ANIM_DURATION, reduceMotion: ReduceMotion.System };\n\ninterface TextFieldProps {\n typo?: TypoOptions;\n status?: 'default' | 'error';\n value: string;\n onChangeText?: (text: string) => void;\n inputBgColor?: string;\n labelBgColor?: string;\n label?: string;\n labelColor?: string;\n placeHolderColor?: string;\n fontSize?: number;\n borderColor?: string;\n borderRadius?: number;\n focusColor?: string;\n errorColor?: string;\n paddingHorizontal?: number;\n borderWidth?: number;\n errorMessage?: string;\n textInputProps?: TextInputProps;\n boxStyle?: BoxStyle;\n innerBoxStyle?: 'top' | 'middle' | 'bottom';\n disabled?: boolean;\n allowFontScaling?: boolean;\n isTextArea?: boolean;\n}\n\nexport type ZSTextFieldRef = TextInput;\n\nconst ZSTextField = forwardRef<ZSTextFieldRef, TextFieldProps>(({\n typo = 'body.2',\n status = 'default',\n value,\n onChangeText,\n label = 'Placeholder',\n labelColor,\n placeHolderColor,\n inputBgColor,\n labelBgColor,\n borderWidth = 1.2,\n borderColor,\n focusColor,\n errorColor,\n borderRadius = 14,\n paddingHorizontal = 15,\n errorMessage,\n textInputProps,\n boxStyle = 'outline',\n innerBoxStyle,\n disabled = false,\n allowFontScaling = true,\n isTextArea = false,\n}, ref) => {\n const { typography, palette } = useTheme();\n const [primaryStyle, subStyle] = typo.split('.') as [TypoStyle, TypoSubStyle];\n const fErrorColor = errorColor || palette.danger.main;\n\n const fontSize = extractStyle(typography[primaryStyle][subStyle], 'fontSize') as number || 17;\n const fontFamily = extractStyle(typography[primaryStyle][subStyle], 'fontFamily') as string || '';\n const floatProgress = useSharedValue(value !== '' ? 1 : 0);\n const [isFocusedForUI, setIsFocusedForUI] = useState<boolean>(false);\n const boxHeightValue = useSharedValue(0);\n\n const isError = status === 'error';\n const hasValue = value !== '';\n\n const isFocusedRef = useRef(false);\n const hasValueRef = useRef(hasValue);\n hasValueRef.current = hasValue;\n\n useEffect(() => {\n const target = hasValue ? 1 : 0;\n if (!isFocusedRef.current && floatProgress.value !== target) {\n floatProgress.value = withTiming(target, TIMING_CONFIG);\n }\n }, [hasValue]);\n\n const animationConstants = useMemo(() => ({\n baseFontSize: fontSize + (boxStyle === 'inbox' ? 1 : 0),\n targetFontSize: boxStyle === 'inbox' ? 10 : 11,\n baseTop: isTextArea ? 12 : 0,\n targetTopOffset: boxStyle === 'inbox' ? 17 : 2,\n }), [fontSize, boxStyle, isTextArea]);\n\n const animatedLabelStyle = useAnimatedStyle(() => {\n const progress = floatProgress.value;\n\n const labelTranslateY = interpolate(\n progress,\n [0, 1],\n [\n 0,\n isTextArea ? -24 : -(boxHeightValue.value / 2) - 1 + animationConstants.targetTopOffset - animationConstants.baseTop,\n ],\n 'clamp'\n );\n\n const labelScale = interpolate(\n progress,\n [0, 1],\n [1, animationConstants.targetFontSize / animationConstants.baseFontSize],\n 'clamp'\n );\n\n return {\n transform: [\n { translateY: labelTranslateY },\n { scale: labelScale },\n ],\n };\n }, [animationConstants, isTextArea]);\n\n const handleLayout = useCallback((event: LayoutChangeEvent) => {\n const { height } = event.nativeEvent.layout;\n boxHeightValue.value = height;\n }, []);\n\n const handleFocus = useCallback(() => {\n isFocusedRef.current = true;\n if (floatProgress.value !== 1) {\n floatProgress.value = withTiming(1, TIMING_CONFIG);\n }\n setIsFocusedForUI(true);\n }, []);\n\n const handleBlur = useCallback(() => {\n isFocusedRef.current = false;\n const target = hasValueRef.current ? 1 : 0;\n if (floatProgress.value !== target) {\n floatProgress.value = withTiming(target, TIMING_CONFIG);\n }\n setIsFocusedForUI(false);\n }, []);\n\n const colorConfig = useMemo(() => ({\n primaryColor: focusColor || palette.primary.main,\n defaultBorderColor: borderColor || palette.grey[30],\n defaultLabelColor: labelColor || palette.text.secondary,\n placeholderColor: placeHolderColor || palette.grey[40],\n errorColor: fErrorColor,\n }), [focusColor, palette.primary.main, borderColor, palette.grey, labelColor, palette.text.secondary, placeHolderColor, fErrorColor]);\n\n const currentBorderColor = isError\n ? colorConfig.errorColor\n : isFocusedForUI\n ? colorConfig.primaryColor\n : colorConfig.defaultBorderColor;\n\n const currentLabelColor = isError\n ? colorConfig.errorColor\n : isFocusedForUI\n ? colorConfig.primaryColor\n : hasValue\n ? colorConfig.defaultLabelColor\n : colorConfig.placeholderColor;\n\n const styleConfig = useMemo(() => {\n const baseStyle = {\n width: '100%' as const,\n justifyContent: isTextArea ? 'flex-start' as const : 'center' as const,\n borderRadius,\n paddingHorizontal,\n backgroundColor: inputBgColor || palette.background.base,\n paddingTop: boxStyle === 'inbox' ? 13 : 0,\n };\n\n // 박스 스타일에 따른 테두리 설정\n let borderStyle = {};\n if (boxStyle === 'outline' || boxStyle === 'inbox') {\n borderStyle = { borderWidth };\n } else if (boxStyle === 'underline') {\n borderStyle = { borderBottomWidth: borderWidth };\n }\n\n // innerBoxStyle에 따른 스타일 설정\n let innerStyle = {};\n if (innerBoxStyle === 'top') {\n innerStyle = {\n borderBottomLeftRadius: 0,\n borderBottomRightRadius: 0,\n borderBottomWidth: borderWidth / 2\n };\n } else if (innerBoxStyle === 'middle') {\n innerStyle = {\n borderRadius: 0,\n borderTopWidth: borderWidth / 2,\n borderBottomWidth: borderWidth / 2\n };\n } else if (innerBoxStyle === 'bottom') {\n innerStyle = {\n borderTopLeftRadius: 0,\n borderTopRightRadius: 0,\n borderTopWidth: borderWidth / 2\n };\n }\n\n return { ...baseStyle, ...borderStyle, ...innerStyle };\n }, [isTextArea, borderRadius, paddingHorizontal, inputBgColor, borderWidth, boxStyle, innerBoxStyle, palette.background.base]);\n\n const labelTextStyle: StyleProp<TextStyle> = useMemo(() => ({\n fontSize,\n top: animationConstants.baseTop,\n left: paddingHorizontal,\n transformOrigin: 'left center',\n backgroundColor: labelBgColor || palette.background.base,\n paddingHorizontal: boxStyle === 'outline' ? 5 : 0,\n paddingVertical: 2,\n textAlignVertical: 'center' as const,\n fontFamily,\n borderRadius: boxStyle === 'outline' ? 5 : 0,\n ...(Platform.OS === 'android' ? { overflow: 'hidden' as const } : {}),\n }), [fontSize, animationConstants.baseTop, paddingHorizontal, labelBgColor, palette.background.base, boxStyle, fontFamily]);\n\n const handleTextChange = (text: string) => {\n if (onChangeText) onChangeText(text);\n };\n\n const textInputStyle = useMemo(() => [\n {\n paddingTop: 7 + iosOffset,\n paddingBottom: 5 + iosOffset,\n color: palette.text.base,\n fontSize,\n width: '100%' as const,\n paddingRight: 25,\n fontFamily,\n ...(Platform.OS === 'web' ? { outline: 'none' } : {}),\n },\n textInputProps?.style,\n ], [palette.text.base, fontSize, fontFamily, textInputProps?.style]);\n\n const shouldShowCloseButton = value && isFocusedForUI;\n const shouldShowError = status === 'error' && errorMessage;\n\n return (\n <ViewAtom style={{ alignSelf: 'stretch', width: '100%' }}>\n <ViewAtom\n style={[styleConfig, { borderColor: currentBorderColor }]}\n onLayout={handleLayout}\n pointerEvents={disabled ? 'none' : 'auto'}\n >\n <TextInput\n {...textInputProps}\n ref={ref}\n style={textInputStyle}\n value={value}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onChangeText={handleTextChange}\n allowFontScaling={allowFontScaling}\n selectionColor={palette.grey[50]}\n autoCorrect={false}\n spellCheck={false}\n />\n\n <ViewAtom pointerEvents=\"none\" style={{ position: 'absolute' }}>\n <Animated.Text allowFontScaling={allowFontScaling} style={[labelTextStyle, { color: currentLabelColor }, animatedLabelStyle]}>\n {label}\n </Animated.Text>\n </ViewAtom>\n\n {shouldShowCloseButton && (\n <ButtonClose marginTop={isTextArea ? 13 : undefined} onChangeText={onChangeText} />\n )}\n </ViewAtom>\n\n {shouldShowError && (\n <ErrorComponent errorMessage={errorMessage} errorColor={fErrorColor} />\n )}\n </ViewAtom>\n );\n});\n\nZSTextField.displayName = 'ZSTextField';\n\nexport default ZSTextField;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSTextField/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE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,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,YAAY,EACtB,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,aAEzC,KAAC,SAAS,OACJ,cAAc,EAClB,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,UAAU,EAClB,YAAY,EAAE,gBAAgB,EAC9B,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAChC,WAAW,EAAE,KAAK,EAClB,UAAU,EAAE,KAAK,GACjB,EAEF,KAAC,QAAQ,IAAC,aAAa,EAAC,MAAM,EAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,YAC5D,KAAC,QAAQ,CAAC,IAAI,IAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,eAAe,YACtE,KAAK,GACQ,GACP,EAEV,qBAAqB,IAAI,CACxB,KAAC,WAAW,IAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,EAAE,YAAY,GAAI,CACpF,IACa,EAEf,eAAe,IAAI,CAClB,KAAC,cAAc,IAAC,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,GAAI,CACxE,IACQ,CACZ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,WAAW,CAAC,WAAW,GAAG,aAAa,CAAC;AAExC,eAAe,WAAW,CAAC","sourcesContent":["import { useMemo, useCallback, useState, forwardRef, useEffect, useRef } from 'react';\nimport { LayoutChangeEvent, Platform, StyleProp, TextInput, TextInputProps, TextStyle } from 'react-native';\nimport Animated, { interpolate, interpolateColor, useAnimatedStyle, useSharedValue, withTiming, ReduceMotion } from 'react-native-reanimated';\nimport ButtonClose from './ui/ButtonClose';\nimport ErrorComponent from './ui/ErrorComponent';\nimport { TypoOptions, TypoStyle, TypoSubStyle } from '../../theme/types';\nimport { extractStyle } from '../../model/utils';\nimport { useTheme } from '../../context/ThemeContext';\nimport { DISABLED_OPACITY, DURATION, RADIUS } from '../../theme/tokens';\nimport ViewAtom from '../atoms/ViewAtom';\n\nexport type BoxStyle = 'outline' | 'underline' | 'inbox';\n\nconst iosOffset = Platform.OS === 'ios' ? 8 : 4;\nconst ANIM_DURATION = DURATION.fast;\nconst TIMING_CONFIG = { duration: ANIM_DURATION, reduceMotion: ReduceMotion.System };\n\ninterface TextFieldProps {\n typo?: TypoOptions;\n status?: 'default' | 'error';\n value: string;\n onChangeText?: (text: string) => void;\n inputBgColor?: string;\n labelBgColor?: string;\n label?: string;\n labelColor?: string;\n placeHolderColor?: string;\n fontSize?: number;\n borderColor?: string;\n borderRadius?: number;\n focusColor?: string;\n errorColor?: string;\n paddingHorizontal?: number;\n borderWidth?: number;\n errorMessage?: string;\n textInputProps?: TextInputProps;\n boxStyle?: BoxStyle;\n innerBoxStyle?: 'top' | 'middle' | 'bottom';\n disabled?: boolean;\n allowFontScaling?: boolean;\n isTextArea?: boolean;\n}\n\nexport type ZSTextFieldRef = TextInput;\n\nconst ZSTextField = forwardRef<ZSTextFieldRef, TextFieldProps>(({\n typo = 'body.2',\n status = 'default',\n value,\n onChangeText,\n label = 'Placeholder',\n labelColor,\n placeHolderColor,\n inputBgColor,\n labelBgColor,\n borderWidth = 1.2,\n borderColor,\n focusColor,\n errorColor,\n borderRadius = RADIUS.lg,\n paddingHorizontal = 15,\n errorMessage,\n textInputProps,\n boxStyle = 'outline',\n innerBoxStyle,\n disabled = false,\n allowFontScaling = true,\n isTextArea = false,\n}, ref) => {\n const { typography, palette } = useTheme();\n const [primaryStyle, subStyle] = typo.split('.') as [TypoStyle, TypoSubStyle];\n const fErrorColor = errorColor || palette.danger.main;\n\n const fontSize = extractStyle(typography[primaryStyle][subStyle], 'fontSize') as number || 17;\n const fontFamily = extractStyle(typography[primaryStyle][subStyle], 'fontFamily') as string || '';\n\n const isError = status === 'error';\n const hasValue = value !== '';\n\n const floatProgress = useSharedValue(hasValue ? 1 : 0);\n const focusProgress = useSharedValue(0);\n const errorProgress = useSharedValue(isError ? 1 : 0);\n const boxHeightValue = useSharedValue(0);\n\n const [isFocusedForUI, setIsFocusedForUI] = useState<boolean>(false);\n\n const isFocusedRef = useRef(false);\n const hasValueRef = useRef(hasValue);\n hasValueRef.current = hasValue;\n\n useEffect(() => {\n const target = hasValue ? 1 : 0;\n if (!isFocusedRef.current && floatProgress.value !== target) {\n floatProgress.value = withTiming(target, TIMING_CONFIG);\n }\n }, [hasValue]);\n\n useEffect(() => {\n const target = isError ? 1 : 0;\n if (errorProgress.value !== target) {\n errorProgress.value = withTiming(target, TIMING_CONFIG);\n }\n }, [isError]);\n\n const animationConstants = useMemo(() => ({\n baseFontSize: fontSize + (boxStyle === 'inbox' ? 1 : 0),\n targetFontSize: boxStyle === 'inbox' ? 10 : 11,\n baseTop: isTextArea ? 12 : 0,\n targetTopOffset: boxStyle === 'inbox' ? 17 : 2,\n }), [fontSize, boxStyle, isTextArea]);\n\n const colorConfig = useMemo(() => ({\n primaryColor: focusColor || palette.primary.main,\n defaultBorderColor: borderColor || palette.grey[30],\n defaultLabelColor: labelColor || palette.text.secondary,\n placeholderColor: placeHolderColor || palette.grey[40],\n errorColor: fErrorColor,\n }), [focusColor, palette.primary.main, borderColor, palette.grey, labelColor, palette.text.secondary, placeHolderColor, fErrorColor]);\n\n const nonFocusLabelColor = useMemo(\n () => (hasValue ? colorConfig.defaultLabelColor : colorConfig.placeholderColor),\n [hasValue, colorConfig.defaultLabelColor, colorConfig.placeholderColor]\n );\n\n const animatedLabelStyle = useAnimatedStyle(() => {\n const progress = floatProgress.value;\n\n const labelTranslateY = interpolate(\n progress,\n [0, 1],\n [\n 0,\n isTextArea ? -24 : -(boxHeightValue.value / 2) - 1 + animationConstants.targetTopOffset - animationConstants.baseTop,\n ],\n 'clamp'\n );\n\n const labelScale = interpolate(\n progress,\n [0, 1],\n [1, animationConstants.targetFontSize / animationConstants.baseFontSize],\n 'clamp'\n );\n\n const focusedColor = interpolateColor(focusProgress.value, [0, 1], [nonFocusLabelColor, colorConfig.primaryColor]);\n const color = interpolateColor(errorProgress.value, [0, 1], [focusedColor, colorConfig.errorColor]);\n\n return {\n color,\n transform: [\n { translateY: labelTranslateY },\n { scale: labelScale },\n ],\n };\n }, [animationConstants, isTextArea, nonFocusLabelColor, colorConfig.primaryColor, colorConfig.errorColor]);\n\n const animatedBorderStyle = useAnimatedStyle(() => {\n const focusedColor = interpolateColor(focusProgress.value, [0, 1], [colorConfig.defaultBorderColor, colorConfig.primaryColor]);\n const borderColor = interpolateColor(errorProgress.value, [0, 1], [focusedColor, colorConfig.errorColor]);\n return { borderColor };\n }, [colorConfig.defaultBorderColor, colorConfig.primaryColor, colorConfig.errorColor]);\n\n const handleLayout = useCallback((event: LayoutChangeEvent) => {\n const { height } = event.nativeEvent.layout;\n if (boxHeightValue.value !== height) {\n boxHeightValue.value = height;\n }\n }, []);\n\n const handleFocus = useCallback<NonNullable<TextInputProps['onFocus']>>((event) => {\n isFocusedRef.current = true;\n if (floatProgress.value !== 1) {\n floatProgress.value = withTiming(1, TIMING_CONFIG);\n }\n if (focusProgress.value !== 1) {\n focusProgress.value = withTiming(1, TIMING_CONFIG);\n }\n setIsFocusedForUI(true);\n textInputProps?.onFocus?.(event);\n }, [textInputProps?.onFocus]);\n\n const handleBlur = useCallback<NonNullable<TextInputProps['onBlur']>>((event) => {\n isFocusedRef.current = false;\n const target = hasValueRef.current ? 1 : 0;\n if (floatProgress.value !== target) {\n floatProgress.value = withTiming(target, TIMING_CONFIG);\n }\n if (focusProgress.value !== 0) {\n focusProgress.value = withTiming(0, TIMING_CONFIG);\n }\n setIsFocusedForUI(false);\n textInputProps?.onBlur?.(event);\n }, [textInputProps?.onBlur]);\n\n const styleConfig = useMemo(() => {\n const baseStyle = {\n width: '100%' as const,\n justifyContent: isTextArea ? 'flex-start' as const : 'center' as const,\n borderRadius,\n paddingHorizontal,\n backgroundColor: inputBgColor || palette.background.base,\n paddingTop: boxStyle === 'inbox' ? 13 : 0,\n };\n\n let borderStyle = {};\n if (boxStyle === 'outline' || boxStyle === 'inbox') {\n borderStyle = { borderWidth };\n } else if (boxStyle === 'underline') {\n borderStyle = { borderBottomWidth: borderWidth };\n }\n\n let innerStyle = {};\n if (innerBoxStyle === 'top') {\n innerStyle = {\n borderBottomLeftRadius: 0,\n borderBottomRightRadius: 0,\n borderBottomWidth: borderWidth / 2\n };\n } else if (innerBoxStyle === 'middle') {\n innerStyle = {\n borderRadius: 0,\n borderTopWidth: borderWidth / 2,\n borderBottomWidth: borderWidth / 2\n };\n } else if (innerBoxStyle === 'bottom') {\n innerStyle = {\n borderTopLeftRadius: 0,\n borderTopRightRadius: 0,\n borderTopWidth: borderWidth / 2\n };\n }\n\n return { ...baseStyle, ...borderStyle, ...innerStyle };\n }, [isTextArea, borderRadius, paddingHorizontal, inputBgColor, borderWidth, boxStyle, innerBoxStyle, palette.background.base]);\n\n const labelTextStyle: StyleProp<TextStyle> = useMemo(() => ({\n fontSize,\n top: animationConstants.baseTop,\n left: paddingHorizontal,\n transformOrigin: 'left center',\n backgroundColor: labelBgColor || palette.background.base,\n paddingHorizontal: boxStyle === 'outline' ? 5 : 0,\n paddingVertical: 2,\n textAlignVertical: 'center' as const,\n fontFamily,\n borderRadius: boxStyle === 'outline' ? 5 : 0,\n ...(Platform.OS === 'android' ? { overflow: 'hidden' as const } : {}),\n }), [fontSize, animationConstants.baseTop, paddingHorizontal, labelBgColor, palette.background.base, boxStyle, fontFamily]);\n\n const boxStyleArray = useMemo(\n () => [styleConfig, animatedBorderStyle],\n [styleConfig, animatedBorderStyle]\n );\n\n const labelStyleArray = useMemo(\n () => [labelTextStyle, animatedLabelStyle],\n [labelTextStyle, animatedLabelStyle]\n );\n\n const handleTextChange = useCallback((text: string) => {\n onChangeText?.(text);\n textInputProps?.onChangeText?.(text);\n }, [onChangeText, textInputProps?.onChangeText]);\n\n const textInputStyle = useMemo(() => [\n {\n paddingTop: 7 + iosOffset,\n paddingBottom: 5 + iosOffset,\n color: palette.text.base,\n fontSize,\n width: '100%' as const,\n paddingRight: 25,\n fontFamily,\n ...(Platform.OS === 'web' ? { outline: 'none' } : {}),\n },\n textInputProps?.style,\n ], [palette.text.base, fontSize, fontFamily, textInputProps?.style]);\n\n // 빈 문자열이 View 자식으로 렌더되지 않도록 boolean 으로 강제 (web 'Unexpected text node' 경고 방지)\n const shouldShowCloseButton = Boolean(value) && isFocusedForUI;\n const shouldShowError = status === 'error' && errorMessage !== undefined && errorMessage !== '';\n\n return (\n <ViewAtom style={{ alignSelf: 'stretch', width: '100%', opacity: disabled ? DISABLED_OPACITY : 1 }}>\n <Animated.View\n style={boxStyleArray}\n onLayout={handleLayout}\n pointerEvents={disabled ? 'none' : 'auto'}\n >\n <TextInput\n {...textInputProps}\n ref={ref}\n style={textInputStyle}\n value={value}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onChangeText={handleTextChange}\n allowFontScaling={allowFontScaling}\n selectionColor={palette.grey[50]}\n autoCorrect={false}\n spellCheck={false}\n />\n\n <ViewAtom pointerEvents=\"none\" style={{ position: 'absolute' }}>\n <Animated.Text allowFontScaling={allowFontScaling} style={labelStyleArray}>\n {label}\n </Animated.Text>\n </ViewAtom>\n\n {shouldShowCloseButton && (\n <ButtonClose marginTop={isTextArea ? 13 : undefined} onChangeText={onChangeText} />\n )}\n </Animated.View>\n\n {shouldShowError && (\n <ErrorComponent errorMessage={errorMessage} errorColor={fErrorColor} />\n )}\n </ViewAtom>\n );\n});\n\nZSTextField.displayName = 'ZSTextField';\n\nexport default ZSTextField;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonClose.d.ts","sourceRoot":"","sources":["../../../../src/ui/ZSTextField/ui/ButtonClose.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"ButtonClose.d.ts","sourceRoot":"","sources":["../../../../src/ui/ZSTextField/ui/ButtonClose.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAK5E,QAAA,MAAM,WAAW,GAAI,uCAIlB;IACC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,qBAAqB,gCAYxB,CAAA;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { TouchableOpacity } from "react-native";
|
|
3
3
|
import { SvgX } from "../../../assets/SvgX";
|
|
4
|
+
import { useTheme } from "../../../context/ThemeContext";
|
|
5
|
+
import { RADIUS } from "../../../theme/tokens";
|
|
4
6
|
const ButtonClose = ({ onChangeText, marginTop, ...props }) => {
|
|
5
|
-
|
|
7
|
+
const { palette } = useTheme();
|
|
8
|
+
return (_jsx(TouchableOpacity, { style: { position: 'absolute', padding: 3, right: 15, borderRadius: RADIUS.pill, backgroundColor: palette.grey[30], justifyContent: 'center', alignItems: 'center', ...marginTop && { top: marginTop } }, hitSlop: { top: 10, right: 10, bottom: 10, left: 10 }, onPress: () => { onChangeText?.(''); }, ...props, children: _jsx(SvgX, { color: palette.grey[60] }) }));
|
|
6
9
|
};
|
|
7
10
|
export default ButtonClose;
|
|
8
11
|
//# sourceMappingURL=ButtonClose.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonClose.js","sourceRoot":"","sources":["../../../../src/ui/ZSTextField/ui/ButtonClose.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAA8B,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ButtonClose.js","sourceRoot":"","sources":["../../../../src/ui/ZSTextField/ui/ButtonClose.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAA8B,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,MAAM,WAAW,GAAG,CAAC,EACjB,YAAY,EACZ,SAAS,EACT,GAAG,KAAK,EAIa,EAAE,EAAE;IACzB,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAC;IAE/B,OAAO,CACH,KAAC,gBAAgB,IACb,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,SAAS,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EACxM,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EACrD,OAAO,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAClC,KAAK,YACT,KAAC,IAAI,IAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,GAAI,GAClB,CACtB,CAAA;AACL,CAAC,CAAA;AAED,eAAe,WAAW,CAAC","sourcesContent":["import { TouchableOpacity, type TouchableOpacityProps } from \"react-native\";\nimport { SvgX } from \"../../../assets/SvgX\";\nimport { useTheme } from \"../../../context/ThemeContext\";\nimport { RADIUS } from \"../../../theme/tokens\";\n\nconst ButtonClose = ({\n onChangeText,\n marginTop,\n ...props\n}: {\n onChangeText?: (text: string) => void;\n marginTop?: number;\n} & TouchableOpacityProps) => {\n const { palette } = useTheme();\n\n return (\n <TouchableOpacity\n style={{ position: 'absolute', padding: 3, right: 15, borderRadius: RADIUS.pill, backgroundColor: palette.grey[30], justifyContent: 'center', alignItems: 'center', ...marginTop && { top: marginTop } }}\n hitSlop={{ top: 10, right: 10, bottom: 10, left: 10 }}\n onPress={() => { onChangeText?.(''); }}\n {...props}>\n <SvgX color={palette.grey[60]} />\n </TouchableOpacity>\n )\n}\n\nexport default ButtonClose;\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type StyleProp, type ViewProps, type ViewStyle } from "react-native";
|
|
3
|
+
import type { TypoOptions } from "../../theme/types";
|
|
4
|
+
export type ZSTooltipPlacement = 'top' | 'bottom';
|
|
5
|
+
export type ZSTooltipTailAlign = 'start' | 'center' | 'end';
|
|
6
|
+
export interface ZSTooltipProps extends ViewProps {
|
|
7
|
+
/** 말풍선 메시지 (children 지정 시 children 우선) */
|
|
8
|
+
message?: string;
|
|
9
|
+
/** 커스텀 콘텐츠 */
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
/** 표시 여부를 외부에서 제어할 때 사용 (미지정 시 내부 상태로 동작) */
|
|
12
|
+
visible?: boolean;
|
|
13
|
+
/** 비제어 모드의 초기 표시 상태 */
|
|
14
|
+
initialVisible?: boolean;
|
|
15
|
+
/** 닫기 버튼 탭 시 호출 */
|
|
16
|
+
onClose?: () => void;
|
|
17
|
+
/** 앵커 기준 말풍선 위치 — top 이면 꼬리가 아래를 향함 (기본: top) */
|
|
18
|
+
placement?: ZSTooltipPlacement;
|
|
19
|
+
/** true면 닫기(X) 버튼 표시 */
|
|
20
|
+
showClose?: boolean;
|
|
21
|
+
/** true면 위아래로 살짝 떠다니는 애니메이션 */
|
|
22
|
+
floating?: boolean;
|
|
23
|
+
/** 말풍선 배경색 (기본: 테마 반전 색 — light 는 어두운 배경, dark 는 밝은 배경) */
|
|
24
|
+
backgroundColor?: string;
|
|
25
|
+
/** 메시지·닫기 아이콘 색 (기본: palette.background.base) */
|
|
26
|
+
textColor?: string;
|
|
27
|
+
typo?: TypoOptions;
|
|
28
|
+
/** 꼬리 정렬 (기본: start) */
|
|
29
|
+
tailAlign?: ZSTooltipTailAlign;
|
|
30
|
+
/** start/end 정렬 시 가장자리에서 꼬리까지의 간격 */
|
|
31
|
+
tailOffset?: number;
|
|
32
|
+
closeAccessibilityLabel?: string;
|
|
33
|
+
style?: StyleProp<ViewStyle>;
|
|
34
|
+
}
|
|
35
|
+
declare function ZSTooltip({ message, children, visible, initialVisible, onClose, placement, showClose, floating, backgroundColor, textColor, typo, tailAlign, tailOffset, closeAccessibilityLabel, style, ...props }: ZSTooltipProps): React.JSX.Element | null;
|
|
36
|
+
declare const _default: React.MemoExoticComponent<typeof ZSTooltip>;
|
|
37
|
+
export default _default;
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSTooltip/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAA+B,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAmB3G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AASrD,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,QAAQ,CAAC;AAClD,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE5D,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,6CAA6C;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uBAAuB;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,iDAAiD;IACjD,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B,wBAAwB;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,wBAAwB;IACxB,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,iBAAS,SAAS,CAAC,EACjB,OAAO,EACP,QAAQ,EACR,OAAO,EACP,cAAqB,EACrB,OAAO,EACP,SAAiB,EACjB,SAAiB,EACjB,QAAgB,EAChB,eAAe,EACf,SAAS,EACT,IAAe,EACf,SAAmB,EACnB,UAAe,EACf,uBAAiC,EACjC,KAAK,EACL,GAAG,KAAK,EACT,EAAE,cAAc,4BAgGhB;;AAED,wBAAqC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
import { Pressable, StyleSheet, View } from "react-native";
|
|
4
|
+
import Animated, { cancelAnimation, Easing, FadeInDown, FadeInUp, FadeOutDown, FadeOutUp, useAnimatedStyle, useSharedValue, withDelay, withRepeat, withTiming, } from "react-native-reanimated";
|
|
5
|
+
import ZSText from "../ZSText";
|
|
6
|
+
import { useTheme } from "../../context/ThemeContext";
|
|
7
|
+
import { DURATION, RADIUS } from "../../theme/tokens";
|
|
8
|
+
import { SvgX } from "../../assets/SvgX";
|
|
9
|
+
import { SvgTooltipTail } from "../../assets/SvgTooltipTail";
|
|
10
|
+
const FLOATING_START_DELAY = 220;
|
|
11
|
+
const FLOATING_ANIMATION_DURATION = 1100;
|
|
12
|
+
const FLOATING_OFFSET = 2;
|
|
13
|
+
const TAIL_WIDTH = 12;
|
|
14
|
+
const TAIL_HEIGHT = 7;
|
|
15
|
+
const CLOSE_HIT_SLOP = { top: 8, bottom: 8, left: 8, right: 8 };
|
|
16
|
+
function ZSTooltip({ message, children, visible, initialVisible = true, onClose, placement = 'top', showClose = false, floating = false, backgroundColor, textColor, typo = 'body.4', tailAlign = 'start', tailOffset = 16, closeAccessibilityLabel = '툴팁 닫기', style, ...props }) {
|
|
17
|
+
const { palette } = useTheme();
|
|
18
|
+
const [internalVisible, setInternalVisible] = useState(initialVisible);
|
|
19
|
+
const isVisible = visible ?? internalVisible;
|
|
20
|
+
const floatingTranslateY = useSharedValue(0);
|
|
21
|
+
// 테마 반전 표면: light 는 어두운 말풍선 + 밝은 텍스트, dark 는 그 반대
|
|
22
|
+
const bubbleColor = backgroundColor ?? palette.grey[90];
|
|
23
|
+
const contentColor = textColor ?? palette.background.base;
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!floating || !isVisible)
|
|
26
|
+
return;
|
|
27
|
+
floatingTranslateY.value = 0;
|
|
28
|
+
floatingTranslateY.value = withDelay(FLOATING_START_DELAY, withRepeat(withTiming(-FLOATING_OFFSET, {
|
|
29
|
+
duration: FLOATING_ANIMATION_DURATION,
|
|
30
|
+
easing: Easing.inOut(Easing.ease),
|
|
31
|
+
}), -1, true));
|
|
32
|
+
return () => {
|
|
33
|
+
cancelAnimation(floatingTranslateY);
|
|
34
|
+
};
|
|
35
|
+
}, [floating, isVisible, floatingTranslateY]);
|
|
36
|
+
const floatingStyle = useAnimatedStyle(() => ({
|
|
37
|
+
transform: [{ translateY: floatingTranslateY.value }],
|
|
38
|
+
}));
|
|
39
|
+
const handleClose = () => {
|
|
40
|
+
if (visible === undefined)
|
|
41
|
+
setInternalVisible(false);
|
|
42
|
+
onClose?.();
|
|
43
|
+
};
|
|
44
|
+
if (!isVisible)
|
|
45
|
+
return null;
|
|
46
|
+
const isTop = placement === 'top';
|
|
47
|
+
const tail = (_jsx(View, { pointerEvents: 'none', style: [
|
|
48
|
+
tailAlign === 'center'
|
|
49
|
+
? styles.tailCenter
|
|
50
|
+
: tailAlign === 'end'
|
|
51
|
+
? { alignSelf: 'flex-end', marginRight: tailOffset }
|
|
52
|
+
: { alignSelf: 'flex-start', marginLeft: tailOffset },
|
|
53
|
+
// 말풍선과 꼬리 사이 헤어라인 틈 방지 오버랩 · bottom 은 180도 회전
|
|
54
|
+
isTop ? styles.tailTop : styles.tailBottom,
|
|
55
|
+
], children: _jsx(SvgTooltipTail, { width: TAIL_WIDTH, height: TAIL_HEIGHT, color: bubbleColor }) }));
|
|
56
|
+
return (_jsx(Animated.View, { entering: (isTop ? FadeInUp : FadeInDown).duration(DURATION.fast).easing(Easing.out(Easing.quad)), exiting: (isTop ? FadeOutDown : FadeOutUp).duration(DURATION.fast).easing(Easing.in(Easing.quad)), pointerEvents: 'box-none', style: [styles.container, { shadowColor: palette.grey[100] }, style], ...props, children: _jsxs(Animated.View, { style: floatingStyle, children: [!isTop && tail, _jsx(View, { style: [styles.bubble, { backgroundColor: bubbleColor }], children: _jsxs(View, { style: styles.contentRow, children: [children ?? (_jsx(ZSText, { typo: typo, style: [styles.message, { color: contentColor }], children: message })), showClose && (_jsx(Pressable, { accessibilityLabel: closeAccessibilityLabel, accessibilityRole: 'button', hitSlop: CLOSE_HIT_SLOP, onPress: handleClose, style: styles.closeButton, testID: 'zs-tooltip-close', children: _jsx(SvgX, { size: 10, color: contentColor }) }))] }) }), isTop && tail] }) }));
|
|
57
|
+
}
|
|
58
|
+
export default React.memo(ZSTooltip);
|
|
59
|
+
const styles = StyleSheet.create({
|
|
60
|
+
container: {
|
|
61
|
+
alignSelf: 'flex-start',
|
|
62
|
+
maxWidth: '100%',
|
|
63
|
+
shadowOffset: { width: 0, height: 4 },
|
|
64
|
+
shadowOpacity: 0.16,
|
|
65
|
+
shadowRadius: 8,
|
|
66
|
+
elevation: 6,
|
|
67
|
+
},
|
|
68
|
+
bubble: {
|
|
69
|
+
borderRadius: RADIUS.lg,
|
|
70
|
+
maxWidth: '100%',
|
|
71
|
+
paddingHorizontal: 12,
|
|
72
|
+
paddingVertical: 8,
|
|
73
|
+
},
|
|
74
|
+
contentRow: {
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
flexDirection: 'row',
|
|
77
|
+
gap: 6,
|
|
78
|
+
},
|
|
79
|
+
message: {
|
|
80
|
+
flexShrink: 1,
|
|
81
|
+
},
|
|
82
|
+
closeButton: {
|
|
83
|
+
alignItems: 'center',
|
|
84
|
+
justifyContent: 'center',
|
|
85
|
+
width: 20,
|
|
86
|
+
height: 20,
|
|
87
|
+
},
|
|
88
|
+
tailCenter: {
|
|
89
|
+
alignSelf: 'center',
|
|
90
|
+
},
|
|
91
|
+
tailTop: {
|
|
92
|
+
marginTop: -0.5,
|
|
93
|
+
},
|
|
94
|
+
tailBottom: {
|
|
95
|
+
marginBottom: -0.5,
|
|
96
|
+
transform: [{ rotate: '180deg' }],
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSTooltip/index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAkD,MAAM,cAAc,CAAC;AAC3G,OAAO,Q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AAW,EAAE;QACX,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;QACxB,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;KACX;IACD,UAAU,EAAE;QACV,SAAS,EAAE,QAAQ;KACpB;IACD,OAAO,EAAE;QACP,SAAS,EAAE,CAAC,GAAG;KAChB;IACD,UAAU,EAAE;QACV,YAAY,EAAE,CAAC,GAAG;QAClB,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;KAClC;CACF,CAAC,CAAC","sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport { Pressable, StyleSheet, View, type StyleProp, type ViewProps, type ViewStyle } from \"react-native\";\nimport Animated, {\n cancelAnimation,\n Easing,\n FadeInDown,\n FadeInUp,\n FadeOutDown,\n FadeOutUp,\n useAnimatedStyle,\n useSharedValue,\n withDelay,\n withRepeat,\n withTiming,\n} from \"react-native-reanimated\";\nimport ZSText from \"../ZSText\";\nimport { useTheme } from \"../../context/ThemeContext\";\nimport { DURATION, RADIUS } from \"../../theme/tokens\";\nimport { SvgX } from \"../../assets/SvgX\";\nimport { SvgTooltipTail } from \"../../assets/SvgTooltipTail\";\nimport type { TypoOptions } from \"../../theme/types\";\n\nconst FLOATING_START_DELAY = 220;\nconst FLOATING_ANIMATION_DURATION = 1100;\nconst FLOATING_OFFSET = 2;\nconst TAIL_WIDTH = 12;\nconst TAIL_HEIGHT = 7;\nconst CLOSE_HIT_SLOP = { top: 8, bottom: 8, left: 8, right: 8 };\n\nexport type ZSTooltipPlacement = 'top' | 'bottom';\nexport type ZSTooltipTailAlign = 'start' | 'center' | 'end';\n\nexport interface ZSTooltipProps extends ViewProps {\n /** 말풍선 메시지 (children 지정 시 children 우선) */\n message?: string;\n /** 커스텀 콘텐츠 */\n children?: React.ReactNode;\n /** 표시 여부를 외부에서 제어할 때 사용 (미지정 시 내부 상태로 동작) */\n visible?: boolean;\n /** 비제어 모드의 초기 표시 상태 */\n initialVisible?: boolean;\n /** 닫기 버튼 탭 시 호출 */\n onClose?: () => void;\n /** 앵커 기준 말풍선 위치 — top 이면 꼬리가 아래를 향함 (기본: top) */\n placement?: ZSTooltipPlacement;\n /** true면 닫기(X) 버튼 표시 */\n showClose?: boolean;\n /** true면 위아래로 살짝 떠다니는 애니메이션 */\n floating?: boolean;\n /** 말풍선 배경색 (기본: 테마 반전 색 — light 는 어두운 배경, dark 는 밝은 배경) */\n backgroundColor?: string;\n /** 메시지·닫기 아이콘 색 (기본: palette.background.base) */\n textColor?: string;\n typo?: TypoOptions;\n /** 꼬리 정렬 (기본: start) */\n tailAlign?: ZSTooltipTailAlign;\n /** start/end 정렬 시 가장자리에서 꼬리까지의 간격 */\n tailOffset?: number;\n closeAccessibilityLabel?: string;\n style?: StyleProp<ViewStyle>;\n}\n\nfunction ZSTooltip({\n message,\n children,\n visible,\n initialVisible = true,\n onClose,\n placement = 'top',\n showClose = false,\n floating = false,\n backgroundColor,\n textColor,\n typo = 'body.4',\n tailAlign = 'start',\n tailOffset = 16,\n closeAccessibilityLabel = '툴팁 닫기',\n style,\n ...props\n}: ZSTooltipProps) {\n const { palette } = useTheme();\n const [internalVisible, setInternalVisible] = useState(initialVisible);\n const isVisible = visible ?? internalVisible;\n const floatingTranslateY = useSharedValue(0);\n\n // 테마 반전 표면: light 는 어두운 말풍선 + 밝은 텍스트, dark 는 그 반대\n const bubbleColor = backgroundColor ?? palette.grey[90];\n const contentColor = textColor ?? palette.background.base;\n\n useEffect(() => {\n if (!floating || !isVisible) return;\n\n floatingTranslateY.value = 0;\n floatingTranslateY.value = withDelay(\n FLOATING_START_DELAY,\n withRepeat(\n withTiming(-FLOATING_OFFSET, {\n duration: FLOATING_ANIMATION_DURATION,\n easing: Easing.inOut(Easing.ease),\n }),\n -1,\n true,\n ),\n );\n\n return () => {\n cancelAnimation(floatingTranslateY);\n };\n }, [floating, isVisible, floatingTranslateY]);\n\n const floatingStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: floatingTranslateY.value }],\n }));\n\n const handleClose = () => {\n if (visible === undefined) setInternalVisible(false);\n onClose?.();\n };\n\n if (!isVisible) return null;\n\n const isTop = placement === 'top';\n\n const tail = (\n <View\n pointerEvents='none'\n style={[\n tailAlign === 'center'\n ? styles.tailCenter\n : tailAlign === 'end'\n ? { alignSelf: 'flex-end', marginRight: tailOffset }\n : { alignSelf: 'flex-start', marginLeft: tailOffset },\n // 말풍선과 꼬리 사이 헤어라인 틈 방지 오버랩 · bottom 은 180도 회전\n isTop ? styles.tailTop : styles.tailBottom,\n ]}\n >\n <SvgTooltipTail width={TAIL_WIDTH} height={TAIL_HEIGHT} color={bubbleColor} />\n </View>\n );\n\n return (\n <Animated.View\n entering={(isTop ? FadeInUp : FadeInDown).duration(DURATION.fast).easing(Easing.out(Easing.quad))}\n exiting={(isTop ? FadeOutDown : FadeOutUp).duration(DURATION.fast).easing(Easing.in(Easing.quad))}\n pointerEvents='box-none'\n style={[styles.container, { shadowColor: palette.grey[100] }, style]}\n {...props}\n >\n <Animated.View style={floatingStyle}>\n {!isTop && tail}\n <View style={[styles.bubble, { backgroundColor: bubbleColor }]}>\n <View style={styles.contentRow}>\n {children ?? (\n <ZSText typo={typo} style={[styles.message, { color: contentColor }]}>\n {message}\n </ZSText>\n )}\n {showClose && (\n <Pressable\n accessibilityLabel={closeAccessibilityLabel}\n accessibilityRole='button'\n hitSlop={CLOSE_HIT_SLOP}\n onPress={handleClose}\n style={styles.closeButton}\n testID='zs-tooltip-close'\n >\n <SvgX size={10} color={contentColor} />\n </Pressable>\n )}\n </View>\n </View>\n {isTop && tail}\n </Animated.View>\n </Animated.View>\n );\n}\n\nexport default React.memo(ZSTooltip);\n\nconst styles = StyleSheet.create({\n container: {\n alignSelf: 'flex-start',\n maxWidth: '100%',\n shadowOffset: { width: 0, height: 4 },\n shadowOpacity: 0.16,\n shadowRadius: 8,\n elevation: 6,\n },\n bubble: {\n borderRadius: RADIUS.lg,\n maxWidth: '100%',\n paddingHorizontal: 12,\n paddingVertical: 8,\n },\n contentRow: {\n alignItems: 'center',\n flexDirection: 'row',\n gap: 6,\n },\n message: {\n flexShrink: 1,\n },\n closeButton: {\n alignItems: 'center',\n justifyContent: 'center',\n width: 20,\n height: 20,\n },\n tailCenter: {\n alignSelf: 'center',\n },\n tailTop: {\n marginTop: -0.5,\n },\n tailBottom: {\n marginBottom: -0.5,\n transform: [{ rotate: '180deg' }],\n },\n});\n"]}
|
|
@@ -6,6 +6,7 @@ type Props = ViewProps & {
|
|
|
6
6
|
elevationLevel?: ShadowLevel;
|
|
7
7
|
color?: ViewColorOptions;
|
|
8
8
|
};
|
|
9
|
-
declare
|
|
10
|
-
|
|
9
|
+
declare function ZSView({ isAnimation, elevationLevel, style, children, color, ...rest }: Props): React.JSX.Element;
|
|
10
|
+
declare const _default: React.MemoExoticComponent<typeof ZSView>;
|
|
11
|
+
export default _default;
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSView/index.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSView/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAc,SAAS,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAElE,KAAK,KAAK,GAAG,SAAS,GAAG;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEF,iBAAS,MAAM,CAAC,EAAE,WAAmB,EAAE,cAAkB,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,KAAK,qBAclG;;AAED,wBAAkC"}
|
package/build/ui/ZSView/index.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import { StyleSheet } from 'react-native';
|
|
4
|
-
import {
|
|
4
|
+
import { useStyleSheetCreate } from '../../model/useStyleSheetCreate';
|
|
5
5
|
import AnimatedWrapper from '../atoms/AnimatedWrapper';
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const styles = useMemo(() => StyleSheet.create({
|
|
6
|
+
function ZSView({ isAnimation = false, elevationLevel = 0, style, children, color, ...rest }) {
|
|
7
|
+
const styles = useStyleSheetCreate((palette) => StyleSheet.create({
|
|
9
8
|
container: {
|
|
10
9
|
backgroundColor: palette.background.base,
|
|
11
10
|
},
|
|
12
|
-
})
|
|
11
|
+
}));
|
|
13
12
|
return (_jsx(AnimatedWrapper, { color: color, isAnimation: isAnimation, elevationLevel: elevationLevel, style: [styles.container, style], ...rest, children: children }));
|
|
14
|
-
}
|
|
15
|
-
export default ZSView;
|
|
13
|
+
}
|
|
14
|
+
export default React.memo(ZSView);
|
|
16
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSView/index.tsx"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSView/index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAa,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,eAAe,MAAM,0BAA0B,CAAC;AASvD,SAAS,MAAM,CAAC,EAAE,WAAW,GAAG,KAAK,EAAE,cAAc,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,EAAS;IACjG,MAAM,MAAM,GAAG,mBAAmB,CAAC,CAAC,OAAO,EAAE,EAAE,CAC7C,UAAU,CAAC,MAAM,CAAC;QAChB,SAAS,EAAE;YACT,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI;SACzC;KACF,CAAC,CACH,CAAC;IAEF,OAAO,CACL,KAAC,eAAe,IAAC,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,KAAM,IAAI,YAChI,QAAQ,GACO,CACnB,CAAC;AACJ,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { StyleSheet, ViewProps } from 'react-native';\nimport { useStyleSheetCreate } from '../../model/useStyleSheetCreate';\nimport AnimatedWrapper from '../atoms/AnimatedWrapper';\nimport { ViewColorOptions, ShadowLevel } from '../../theme/types';\n\ntype Props = ViewProps & {\n isAnimation?: boolean;\n elevationLevel?: ShadowLevel;\n color?: ViewColorOptions;\n};\n\nfunction ZSView({ isAnimation = false, elevationLevel = 0, style, children, color, ...rest }: Props) {\n const styles = useStyleSheetCreate((palette) =>\n StyleSheet.create({\n container: {\n backgroundColor: palette.background.base,\n },\n }),\n );\n\n return (\n <AnimatedWrapper color={color} isAnimation={isAnimation} elevationLevel={elevationLevel} style={[styles.container, style]} {...rest}>\n {children}\n </AnimatedWrapper>\n );\n}\n\nexport default React.memo(ZSView);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnimatedWrapper.d.ts","sourceRoot":"","sources":["../../../src/ui/atoms/AnimatedWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,EAAQ,SAAS,
|
|
1
|
+
{"version":3,"file":"AnimatedWrapper.d.ts","sourceRoot":"","sources":["../../../src/ui/atoms/AnimatedWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,EAAQ,SAAS,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAOlE,UAAU,oBAAqB,SAAQ,SAAS;IAC9C,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B;AAED,iBAAS,eAAe,CAAC,EACvB,WAAkB,EAClB,cAAkB,EAClB,QAA2B,EAC3B,KAAK,EACL,QAAQ,EACR,KAAK,EACL,GAAG,KAAK,EACT,EAAE,oBAAoB,qBAyFtB;;AAED,wBAA2C"}
|