@0610studio/zs-ui 0.8.4 → 0.8.6
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/overlay/BottomSheetOverlay/index.d.ts.map +1 -1
- package/build/overlay/BottomSheetOverlay/index.js +3 -8
- package/build/overlay/BottomSheetOverlay/index.js.map +1 -1
- package/build/ui/ZSPressable/index.d.ts.map +1 -1
- package/build/ui/ZSPressable/index.js +0 -2
- package/build/ui/ZSPressable/index.js.map +1 -1
- package/build/ui/ZSText/index.d.ts +2 -4
- package/build/ui/ZSText/index.d.ts.map +1 -1
- package/build/ui/ZSText/index.js +1 -2
- package/build/ui/ZSText/index.js.map +1 -1
- package/build/ui/ZSTextField/index.d.ts +1 -3
- package/build/ui/ZSTextField/index.d.ts.map +1 -1
- package/build/ui/ZSTextField/index.js +30 -75
- package/build/ui/ZSTextField/index.js.map +1 -1
- package/build/ui/ZSView/index.d.ts +2 -2
- package/build/ui/ZSView/index.d.ts.map +1 -1
- package/build/ui/ZSView/index.js +2 -2
- 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 +12 -21
- package/build/ui/atoms/AnimatedWrapper.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/overlay/BottomSheetOverlay/index.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/overlay/BottomSheetOverlay/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAOzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAwCzD,iBAAS,kBAAkB,CAAC,EAC1B,eAAe,EACf,SAAS,EACT,OAAY,GACb,EAAE,oBAAoB,4BAgMtB;;AAyCD,wBAA6D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useState, useCallback, useMemo } from 'react';
|
|
2
2
|
import { StyleSheet, View, PanResponder, Keyboard, Platform } from 'react-native';
|
|
3
3
|
import { useBottomSheet } from '../../model/useOverlay';
|
|
4
|
-
import Animated, { useAnimatedStyle, useSharedValue, withSpring, withTiming
|
|
4
|
+
import Animated, { useAnimatedStyle, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
|
|
5
5
|
import ModalBackground from '../ui/ModalBackground';
|
|
6
6
|
import { useTheme } from '../../model';
|
|
7
7
|
import { useSafeAreaInsets, initialWindowMetrics } from 'react-native-safe-area-context';
|
|
@@ -54,14 +54,12 @@ function BottomSheetOverlay({ headerComponent, component, options = {}, }) {
|
|
|
54
54
|
const isGesturing = useSharedValue(false);
|
|
55
55
|
const [localVisible, setLocalVisible] = useState(false);
|
|
56
56
|
const handleKeyboardShow = useCallback((event) => {
|
|
57
|
-
'worklet';
|
|
58
57
|
if (!isGesturing.value) {
|
|
59
58
|
const targetY = IS_IOS ? (-event.endCoordinates.height + bottom) : 0;
|
|
60
59
|
translateY.value = withTiming(targetY, ANIMATION_CONFIG.keyboard.show);
|
|
61
60
|
}
|
|
62
61
|
}, [translateY, bottom, isGesturing]);
|
|
63
62
|
const handleKeyboardHide = useCallback(() => {
|
|
64
|
-
'worklet';
|
|
65
63
|
if (!isGesturing.value) {
|
|
66
64
|
translateY.value = withTiming(0, ANIMATION_CONFIG.keyboard.hide);
|
|
67
65
|
}
|
|
@@ -105,15 +103,13 @@ function BottomSheetOverlay({ headerComponent, component, options = {}, }) {
|
|
|
105
103
|
setBottomSheetVisible(false);
|
|
106
104
|
}, [setBottomSheetVisible]);
|
|
107
105
|
const handlePanResponderGrant = useCallback(() => {
|
|
108
|
-
|
|
109
|
-
runOnJS(dismissKeyboard)();
|
|
106
|
+
dismissKeyboard();
|
|
110
107
|
isGesturing.value = true;
|
|
111
108
|
startX.value = translateX.value;
|
|
112
109
|
startY.value = translateY.value;
|
|
113
110
|
scale.value = withTiming(GESTURE_CONSTANTS.scaleAmount, ANIMATION_CONFIG.scale);
|
|
114
111
|
}, [translateX, translateY, scale, startX, startY, isGesturing, dismissKeyboard]);
|
|
115
112
|
const handlePanResponderMove = useCallback((_, gestureState) => {
|
|
116
|
-
'worklet';
|
|
117
113
|
const newTranslateX = (startX.value + gestureState.dx) / GESTURE_CONSTANTS.horizontalDamping;
|
|
118
114
|
translateX.value = newTranslateX;
|
|
119
115
|
const newTranslateY = startY.value + gestureState.dy;
|
|
@@ -125,7 +121,6 @@ function BottomSheetOverlay({ headerComponent, component, options = {}, }) {
|
|
|
125
121
|
}
|
|
126
122
|
}, [translateX, translateY, startX, startY]);
|
|
127
123
|
const handlePanResponderRelease = useCallback((_, gestureState) => {
|
|
128
|
-
'worklet';
|
|
129
124
|
isGesturing.value = false;
|
|
130
125
|
translateX.value = withTiming(0, { duration: 100 });
|
|
131
126
|
// 빠른 플리킹 제스처를 했을 때, 혹은 화면의 1/3 이상 내렸을 때, 닫기
|
|
@@ -133,7 +128,7 @@ function BottomSheetOverlay({ headerComponent, component, options = {}, }) {
|
|
|
133
128
|
translateY.value > maxHeight * GESTURE_CONSTANTS.closeDistanceRatio;
|
|
134
129
|
if (shouldClose) {
|
|
135
130
|
translateY.value = withTiming(maxHeight + 100, ANIMATION_CONFIG.close);
|
|
136
|
-
|
|
131
|
+
closeBottomSheet();
|
|
137
132
|
}
|
|
138
133
|
else {
|
|
139
134
|
translateY.value = withTiming(0, ANIMATION_CONFIG.close);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/overlay/BottomSheetOverlay/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAU,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ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SAAS,CAAC,OAAO,EAAE,YAAY,KAAK,SAAS,CAAC,OAAO,EAAE,YAAY;QACnE,SAAS,CAAC,OAAO,EAAE,OAAO,KAAK,SAAS,CAAC,OAAO,EAAE,OAAO,CAC1D,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC,IAAI,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import React, { useEffect, useState, useRef, useCallback, useMemo } from 'react';\nimport { StyleSheet, View, PanResponder, Keyboard, Platform } from 'react-native';\nimport { useBottomSheet } from '../../model/useOverlay';\nimport Animated, { useAnimatedStyle, useSharedValue, withSpring, withTiming, runOnJS } from 'react-native-reanimated';\nimport ModalBackground from '../ui/ModalBackground';\nimport { useTheme } from '../../model';\nimport { useSafeAreaInsets, initialWindowMetrics } from 'react-native-safe-area-context';\nimport { ShowBottomSheetProps } from '../../model/types';\nimport { MAX_OVERLAY_WIDTH, Z_INDEX_VALUE } from '../../model/utils';\n\nconst IS_IOS = Platform.OS === 'ios';\n\nconst keyboardEvents = ({\n showEvent: IS_IOS ? 'keyboardWillShow' as const : 'keyboardDidShow' as const,\n hideEvent: IS_IOS ? 'keyboardWillHide' as const : 'keyboardDidHide' as const,\n});\n\nconst ANIMATION_CONFIG = {\n keyboard: {\n show: { duration: IS_IOS ? 250 : 300 },\n hide: { duration: IS_IOS ? 150 : 200 },\n },\n spring: {\n damping: 50,\n stiffness: 300,\n mass: 0.7,\n velocity: 100,\n restDisplacementThreshold: 0.2,\n },\n close: { duration: 150 },\n scale: { duration: 200 },\n scaleRestore: {\n damping: 15,\n stiffness: 300,\n },\n} as const;\n\nconst GESTURE_CONSTANTS = {\n scaleAmount: 0.985,\n horizontalDamping: 18,\n verticalUpDamping: 18,\n verticalDownDamping: 1.5,\n closeVelocityThreshold: 0.5,\n closeDistanceRatio: 1 / 3,\n hideDelay: 200,\n} as const;\n\nfunction BottomSheetOverlay({\n headerComponent,\n component,\n options = {},\n}: ShowBottomSheetProps) {\n const {\n isBackgroundTouchClose = true,\n marginHorizontal = 10,\n marginBottom = 10,\n padding = 14,\n } = options;\n const { palette, dimensions: { width: windowWidth, height: windowHeight } } = useTheme();\n const { bottomSheetVisible, setBottomSheetVisible, height } = useBottomSheet();\n const { bottom } = useSafeAreaInsets();\n \n // 화면의 크기보다 높이가 높으면 화면의 크기로 제한 \n const maxHeight = useMemo(() => \n Math.min(\n windowHeight - 30 - (initialWindowMetrics?.insets.bottom || 0) - (initialWindowMetrics?.insets.top || 0),\n height\n ),\n [windowHeight, height]\n );\n \n const translateY = useSharedValue(0);\n const translateX = useSharedValue(0);\n const scale = useSharedValue(1);\n const startX = useSharedValue(0);\n const startY = useSharedValue(0);\n const isGesturing = useSharedValue(false);\n \n const [localVisible, setLocalVisible] = useState(false);\n\n const handleKeyboardShow = useCallback((event: any) => {\n 'worklet';\n if (!isGesturing.value) {\n const targetY = IS_IOS ? (-event.endCoordinates.height + bottom) : 0;\n translateY.value = withTiming(targetY, ANIMATION_CONFIG.keyboard.show);\n }\n }, [translateY, bottom, isGesturing]);\n\n const handleKeyboardHide = useCallback(() => {\n 'worklet';\n if (!isGesturing.value) {\n translateY.value = withTiming(0, ANIMATION_CONFIG.keyboard.hide);\n }\n }, [translateY, isGesturing]);\n\n useEffect(() => {\n const keyboardShowSubscription = Keyboard.addListener(keyboardEvents.showEvent, handleKeyboardShow);\n const keyboardHideSubscription = Keyboard.addListener(keyboardEvents.hideEvent, handleKeyboardHide);\n\n return () => {\n keyboardShowSubscription.remove();\n keyboardHideSubscription.remove();\n };\n }, [keyboardEvents.showEvent, keyboardEvents.hideEvent, handleKeyboardShow, handleKeyboardHide]);\n\n // BottomSheet 표시/숨김 애니메이션 처리\n useEffect(() => {\n if (bottomSheetVisible) {\n Keyboard.dismiss();\n setLocalVisible(true);\n translateY.value = withSpring(0, ANIMATION_CONFIG.spring);\n } else {\n translateY.value = withTiming(maxHeight + 100, ANIMATION_CONFIG.close);\n setTimeout(() => {\n setLocalVisible(false);\n }, GESTURE_CONSTANTS.hideDelay);\n }\n }, [bottomSheetVisible, translateY, maxHeight]);\n\n const animatedStyles = useAnimatedStyle(() => {\n 'worklet';\n return {\n transform: [\n { translateY: translateY.value },\n { translateX: translateX.value },\n { scale: scale.value }\n ],\n };\n }, [translateY, translateX, scale]);\n\n const dismissKeyboard = useCallback(() => {\n Keyboard.dismiss();\n }, []);\n\n const closeBottomSheet = useCallback(() => {\n setBottomSheetVisible(false);\n }, [setBottomSheetVisible]);\n\n const handlePanResponderGrant = useCallback(() => {\n 'worklet';\n runOnJS(dismissKeyboard)();\n isGesturing.value = true;\n startX.value = translateX.value;\n startY.value = translateY.value;\n scale.value = withTiming(GESTURE_CONSTANTS.scaleAmount, ANIMATION_CONFIG.scale);\n }, [translateX, translateY, scale, startX, startY, isGesturing, dismissKeyboard]);\n\n const handlePanResponderMove = useCallback((_, gestureState) => {\n 'worklet';\n const newTranslateX = (startX.value + gestureState.dx) / GESTURE_CONSTANTS.horizontalDamping;\n translateX.value = newTranslateX;\n\n const newTranslateY = startY.value + gestureState.dy;\n if (newTranslateY < 0) {\n translateY.value = newTranslateY / GESTURE_CONSTANTS.verticalUpDamping;\n } else {\n translateY.value = newTranslateY / GESTURE_CONSTANTS.verticalDownDamping;\n }\n }, [translateX, translateY, startX, startY]);\n\n const handlePanResponderRelease = useCallback((_, gestureState) => {\n 'worklet';\n isGesturing.value = false;\n translateX.value = withTiming(0, { duration: 100 });\n\n // 빠른 플리킹 제스처를 했을 때, 혹은 화면의 1/3 이상 내렸을 때, 닫기\n const shouldClose = gestureState.vy > GESTURE_CONSTANTS.closeVelocityThreshold || \n translateY.value > maxHeight * GESTURE_CONSTANTS.closeDistanceRatio;\n \n if (shouldClose) {\n translateY.value = withTiming(maxHeight + 100, ANIMATION_CONFIG.close);\n runOnJS(closeBottomSheet)();\n } else {\n translateY.value = withTiming(0, ANIMATION_CONFIG.close);\n }\n\n // 사이즈 원래대로 복귀\n scale.value = withSpring(1, ANIMATION_CONFIG.scaleRestore);\n }, [translateX, translateY, scale, maxHeight, isGesturing, closeBottomSheet]);\n\n const panResponder = useMemo(\n () => PanResponder.create({\n onStartShouldSetPanResponder: () => true,\n onMoveShouldSetPanResponder: () => true,\n onPanResponderGrant: handlePanResponderGrant,\n onPanResponderMove: handlePanResponderMove,\n onPanResponderRelease: handlePanResponderRelease,\n }),\n [handlePanResponderGrant, handlePanResponderMove, handlePanResponderRelease]\n );\n\n // 배경 터치 핸들러\n const handleBackgroundPress = useCallback(() => {\n if (isBackgroundTouchClose) setBottomSheetVisible(false);\n }, [isBackgroundTouchClose, setBottomSheetVisible]);\n\n const containerStyle = [\n styles.container,\n {\n width: windowWidth - marginHorizontal * 2,\n height: maxHeight,\n marginHorizontal,\n bottom: marginBottom + bottom,\n backgroundColor: palette.background.base,\n },\n animatedStyles,\n ];\n\n const pressableViewStyle = [\n styles.pressableView,\n { paddingHorizontal: padding, paddingBottom: padding },\n ];\n\n const gestureBarContainerStyle = [\n styles.gestureBarContainer,\n { paddingBottom: padding }\n ];\n\n const gestureBarStyle = [\n styles.gestureBar,\n { backgroundColor: palette.divider }\n ];\n\n if (!localVisible) {\n return null;\n }\n\n return (\n <ModalBackground\n zIndex={Z_INDEX_VALUE.BOTTOM_SHEET1}\n key={localVisible ? 'visiblebs' : 'hiddenbs'}\n modalBgColor={palette.modalBgColor}\n onPress={handleBackgroundPress}\n >\n <Animated.View style={containerStyle}>\n <View style={pressableViewStyle}>\n <View {...panResponder.panHandlers}>\n <View style={gestureBarContainerStyle}>\n <View style={gestureBarStyle} />\n </View>\n {headerComponent}\n </View>\n\n {component}\n </View>\n </Animated.View>\n </ModalBackground>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n position: 'absolute',\n borderRadius: 26,\n overflow: 'hidden',\n zIndex: Z_INDEX_VALUE.BOTTOM_SHEET2,\n maxWidth: MAX_OVERLAY_WIDTH,\n },\n pressableView: {\n width: '100%',\n height: '100%',\n },\n gestureBarContainer: {\n width: '100%',\n paddingTop: 10,\n justifyContent: 'center',\n alignItems: 'center',\n },\n gestureBar: {\n width: 45,\n height: 3,\n borderRadius: 2,\n },\n});\n\nconst arePropsEqual = (\n prevProps: ShowBottomSheetProps, \n nextProps: ShowBottomSheetProps\n): boolean => {\n return (\n prevProps.headerComponent === nextProps.headerComponent &&\n prevProps.component === nextProps.component &&\n prevProps.options?.isBackgroundTouchClose === nextProps.options?.isBackgroundTouchClose &&\n prevProps.options?.marginHorizontal === nextProps.options?.marginHorizontal &&\n prevProps.options?.marginBottom === nextProps.options?.marginBottom &&\n prevProps.options?.padding === nextProps.options?.padding\n );\n};\n\nexport default React.memo(BottomSheetOverlay, arePropsEqual);"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/overlay/BottomSheetOverlay/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,QAAQ,EAAE,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC7G,OAAO,eAAe,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAEzF,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAErE,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC;AAErC,MAAM,cAAc,GAAG,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,kBAA2B,CA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B,KAAK,EAAE,MAAM;QACb,UAAU,EAAE,EAAE;QACd,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;KACrB;IACD,UAAU,EAAE;QACV,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,CAAC;QACT,YAAY,EAAE,CAAC;KAChB;CACF,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,CACpB,SAA+B,EAC/B,SAA+B,EACtB,EAAE;IACX,OAAO,CACL,SAAS,CAAC,eAAe,KAAK,SAAS,CAAC,eAAe;QACvD,SAAS,CAAC,SAAS,KAAK,SAAS,CAAC,SAAS;QAC3C,SAAS,CAAC,OAAO,EAAE,sBAAsB,KAAK,SAAS,CAAC,OAAO,EAAE,sBAAsB;QACvF,SAAS,CAAC,OAAO,EAAE,gBAAgB,KAAK,SAAS,CAAC,OAAO,EAAE,gBAAgB;QAC3E,SAAS,CAAC,OAAO,EAAE,YAAY,KAAK,SAAS,CAAC,OAAO,EAAE,YAAY;QACnE,SAAS,CAAC,OAAO,EAAE,OAAO,KAAK,SAAS,CAAC,OAAO,EAAE,OAAO,CAC1D,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC,IAAI,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import React, { useEffect, useState, useCallback, useMemo } from 'react';\nimport { StyleSheet, View, PanResponder, Keyboard, Platform } from 'react-native';\nimport { useBottomSheet } from '../../model/useOverlay';\nimport Animated, { useAnimatedStyle, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';\nimport ModalBackground from '../ui/ModalBackground';\nimport { useTheme } from '../../model';\nimport { useSafeAreaInsets, initialWindowMetrics } from 'react-native-safe-area-context';\nimport { ShowBottomSheetProps } from '../../model/types';\nimport { MAX_OVERLAY_WIDTH, Z_INDEX_VALUE } from '../../model/utils';\n\nconst IS_IOS = Platform.OS === 'ios';\n\nconst keyboardEvents = ({\n showEvent: IS_IOS ? 'keyboardWillShow' as const : 'keyboardDidShow' as const,\n hideEvent: IS_IOS ? 'keyboardWillHide' as const : 'keyboardDidHide' as const,\n});\n\nconst ANIMATION_CONFIG = {\n keyboard: {\n show: { duration: IS_IOS ? 250 : 300 },\n hide: { duration: IS_IOS ? 150 : 200 },\n },\n spring: {\n damping: 50,\n stiffness: 300,\n mass: 0.7,\n velocity: 100,\n restDisplacementThreshold: 0.2,\n },\n close: { duration: 150 },\n scale: { duration: 200 },\n scaleRestore: {\n damping: 15,\n stiffness: 300,\n },\n} as const;\n\nconst GESTURE_CONSTANTS = {\n scaleAmount: 0.985,\n horizontalDamping: 18,\n verticalUpDamping: 18,\n verticalDownDamping: 1.5,\n closeVelocityThreshold: 0.5,\n closeDistanceRatio: 1 / 3,\n hideDelay: 200,\n} as const;\n\nfunction BottomSheetOverlay({\n headerComponent,\n component,\n options = {},\n}: ShowBottomSheetProps) {\n const {\n isBackgroundTouchClose = true,\n marginHorizontal = 10,\n marginBottom = 10,\n padding = 14,\n } = options;\n const { palette, dimensions: { width: windowWidth, height: windowHeight } } = useTheme();\n const { bottomSheetVisible, setBottomSheetVisible, height } = useBottomSheet();\n const { bottom } = useSafeAreaInsets();\n \n // 화면의 크기보다 높이가 높으면 화면의 크기로 제한 \n const maxHeight = useMemo(() => \n Math.min(\n windowHeight - 30 - (initialWindowMetrics?.insets.bottom || 0) - (initialWindowMetrics?.insets.top || 0),\n height\n ),\n [windowHeight, height]\n );\n \n const translateY = useSharedValue(0);\n const translateX = useSharedValue(0);\n const scale = useSharedValue(1);\n const startX = useSharedValue(0);\n const startY = useSharedValue(0);\n const isGesturing = useSharedValue(false);\n \n const [localVisible, setLocalVisible] = useState(false);\n\n const handleKeyboardShow = useCallback((event: any) => {\n if (!isGesturing.value) {\n const targetY = IS_IOS ? (-event.endCoordinates.height + bottom) : 0;\n translateY.value = withTiming(targetY, ANIMATION_CONFIG.keyboard.show);\n }\n }, [translateY, bottom, isGesturing]);\n\n const handleKeyboardHide = useCallback(() => {\n if (!isGesturing.value) {\n translateY.value = withTiming(0, ANIMATION_CONFIG.keyboard.hide);\n }\n }, [translateY, isGesturing]);\n\n useEffect(() => {\n const keyboardShowSubscription = Keyboard.addListener(keyboardEvents.showEvent, handleKeyboardShow);\n const keyboardHideSubscription = Keyboard.addListener(keyboardEvents.hideEvent, handleKeyboardHide);\n\n return () => {\n keyboardShowSubscription.remove();\n keyboardHideSubscription.remove();\n };\n }, [keyboardEvents.showEvent, keyboardEvents.hideEvent, handleKeyboardShow, handleKeyboardHide]);\n\n // BottomSheet 표시/숨김 애니메이션 처리\n useEffect(() => {\n if (bottomSheetVisible) {\n Keyboard.dismiss();\n setLocalVisible(true);\n translateY.value = withSpring(0, ANIMATION_CONFIG.spring);\n } else {\n translateY.value = withTiming(maxHeight + 100, ANIMATION_CONFIG.close);\n setTimeout(() => {\n setLocalVisible(false);\n }, GESTURE_CONSTANTS.hideDelay);\n }\n }, [bottomSheetVisible, translateY, maxHeight]);\n\n const animatedStyles = useAnimatedStyle(() => {\n 'worklet';\n return {\n transform: [\n { translateY: translateY.value },\n { translateX: translateX.value },\n { scale: scale.value }\n ],\n };\n }, [translateY, translateX, scale]);\n\n const dismissKeyboard = useCallback(() => {\n Keyboard.dismiss();\n }, []);\n\n const closeBottomSheet = useCallback(() => {\n setBottomSheetVisible(false);\n }, [setBottomSheetVisible]);\n\n const handlePanResponderGrant = useCallback(() => {\n dismissKeyboard();\n isGesturing.value = true;\n startX.value = translateX.value;\n startY.value = translateY.value;\n scale.value = withTiming(GESTURE_CONSTANTS.scaleAmount, ANIMATION_CONFIG.scale);\n }, [translateX, translateY, scale, startX, startY, isGesturing, dismissKeyboard]);\n\n const handlePanResponderMove = useCallback((_, gestureState) => {\n const newTranslateX = (startX.value + gestureState.dx) / GESTURE_CONSTANTS.horizontalDamping;\n translateX.value = newTranslateX;\n\n const newTranslateY = startY.value + gestureState.dy;\n if (newTranslateY < 0) {\n translateY.value = newTranslateY / GESTURE_CONSTANTS.verticalUpDamping;\n } else {\n translateY.value = newTranslateY / GESTURE_CONSTANTS.verticalDownDamping;\n }\n }, [translateX, translateY, startX, startY]);\n\n const handlePanResponderRelease = useCallback((_, gestureState) => {\n isGesturing.value = false;\n translateX.value = withTiming(0, { duration: 100 });\n\n // 빠른 플리킹 제스처를 했을 때, 혹은 화면의 1/3 이상 내렸을 때, 닫기\n const shouldClose = gestureState.vy > GESTURE_CONSTANTS.closeVelocityThreshold || \n translateY.value > maxHeight * GESTURE_CONSTANTS.closeDistanceRatio;\n \n if (shouldClose) {\n translateY.value = withTiming(maxHeight + 100, ANIMATION_CONFIG.close);\n closeBottomSheet();\n } else {\n translateY.value = withTiming(0, ANIMATION_CONFIG.close);\n }\n\n // 사이즈 원래대로 복귀\n scale.value = withSpring(1, ANIMATION_CONFIG.scaleRestore);\n }, [translateX, translateY, scale, maxHeight, isGesturing, closeBottomSheet]);\n\n const panResponder = useMemo(\n () => PanResponder.create({\n onStartShouldSetPanResponder: () => true,\n onMoveShouldSetPanResponder: () => true,\n onPanResponderGrant: handlePanResponderGrant,\n onPanResponderMove: handlePanResponderMove,\n onPanResponderRelease: handlePanResponderRelease,\n }),\n [handlePanResponderGrant, handlePanResponderMove, handlePanResponderRelease]\n );\n\n // 배경 터치 핸들러\n const handleBackgroundPress = useCallback(() => {\n if (isBackgroundTouchClose) setBottomSheetVisible(false);\n }, [isBackgroundTouchClose, setBottomSheetVisible]);\n\n const containerStyle = [\n styles.container,\n {\n width: windowWidth - marginHorizontal * 2,\n height: maxHeight,\n marginHorizontal,\n bottom: marginBottom + bottom,\n backgroundColor: palette.background.base,\n },\n animatedStyles,\n ];\n\n const pressableViewStyle = [\n styles.pressableView,\n { paddingHorizontal: padding, paddingBottom: padding },\n ];\n\n const gestureBarContainerStyle = [\n styles.gestureBarContainer,\n { paddingBottom: padding }\n ];\n\n const gestureBarStyle = [\n styles.gestureBar,\n { backgroundColor: palette.divider }\n ];\n\n if (!localVisible) {\n return null;\n }\n\n return (\n <ModalBackground\n zIndex={Z_INDEX_VALUE.BOTTOM_SHEET1}\n key={localVisible ? 'visiblebs' : 'hiddenbs'}\n modalBgColor={palette.modalBgColor}\n onPress={handleBackgroundPress}\n >\n <Animated.View style={containerStyle}>\n <View style={pressableViewStyle}>\n <View {...panResponder.panHandlers}>\n <View style={gestureBarContainerStyle}>\n <View style={gestureBarStyle} />\n </View>\n {headerComponent}\n </View>\n\n {component}\n </View>\n </Animated.View>\n </ModalBackground>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n position: 'absolute',\n borderRadius: 26,\n overflow: 'hidden',\n zIndex: Z_INDEX_VALUE.BOTTOM_SHEET2,\n maxWidth: MAX_OVERLAY_WIDTH,\n },\n pressableView: {\n width: '100%',\n height: '100%',\n },\n gestureBarContainer: {\n width: '100%',\n paddingTop: 10,\n justifyContent: 'center',\n alignItems: 'center',\n },\n gestureBar: {\n width: 45,\n height: 3,\n borderRadius: 2,\n },\n});\n\nconst arePropsEqual = (\n prevProps: ShowBottomSheetProps, \n nextProps: ShowBottomSheetProps\n): boolean => {\n return (\n prevProps.headerComponent === nextProps.headerComponent &&\n prevProps.component === nextProps.component &&\n prevProps.options?.isBackgroundTouchClose === nextProps.options?.isBackgroundTouchClose &&\n prevProps.options?.marginHorizontal === nextProps.options?.marginHorizontal &&\n prevProps.options?.marginBottom === nextProps.options?.marginBottom &&\n prevProps.options?.padding === nextProps.options?.padding\n );\n};\n\nexport default React.memo(BottomSheetOverlay, arePropsEqual);"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSPressable/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAmB,SAAS,EAAE,MAAM,cAAc,CAAC;AAG1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAKrD,UAAU,gBAAiB,SAAQ,SAAS;IAC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AAED,iBAAS,WAAW,CAAC,EACnB,OAAO,EACP,WAAW,EACX,WAAkB,EAClB,sBAAmD,EACnD,6BAAkC,EAClC,cAAc,EACd,SAAiB,EACjB,KAAK,EACL,GAAG,KAAK,EACT,EAAE,gBAAgB,qBA4DlB;;AAoBD,wBAAsD"}
|
|
@@ -14,11 +14,9 @@ function ZSPressable({ onPress, onLongPress, isAnimation = true, pressedBackgrou
|
|
|
14
14
|
};
|
|
15
15
|
}, []);
|
|
16
16
|
const handlePressIn = () => {
|
|
17
|
-
'worklet';
|
|
18
17
|
isButtonPress.value = withTiming(1, DEFAULT_DURATION);
|
|
19
18
|
};
|
|
20
19
|
const handlePressOut = () => {
|
|
21
|
-
'worklet';
|
|
22
20
|
isButtonPress.value = withTiming(0, DEFAULT_DURATION);
|
|
23
21
|
};
|
|
24
22
|
const handlePressStyle = (pressed) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSPressable/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,IAAI,EAAa,MAAM,cAAc,CAAC;AAC1D,OAAO,QAAQ,EAAE,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC9G,OAAO,eAAe,MAAM,0BAA0B,CAAC;AAIvD,MAAM,gBAAgB,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAW,CAAC;AACpD,MAAM,YAAY,GAAG,CAAC,CAAC,EAAE,IAAI,CAAU,CAAC;AAaxC,SAAS,WAAW,CAAC,EACnB,OAAO,EACP,WAAW,EACX,WAAW,GAAG,IAAI,EAClB,sBAAsB,GAAG,0BAA0B,EACnD,6BAA6B,GAAG,EAAE,EAClC,cAAc,EACd,SAAS,GAAG,KAAK,EACjB,KAAK,EACL,GAAG,KAAK,EACS;IACjB,MAAM,aAAa,GAAG,cAA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CAAC,WAAW,CAAC,CACzB,cAAc,CAAC,CAAC,cAAc,CAAC,CAC/B,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAEnB;YAAA,CAAC,KAAK,CAAC,QAAQ,CACjB;UAAA,EAAE,eAAe,CACnB;QAAA,EAAE,QAAQ,CAAC,IAAI,CACjB;MAAA,EAAE,SAAS,CACb;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC;AAED,MAAM,aAAa,GAAG,CACpB,SAA2B,EAC3B,SAA2B,EAClB,EAAE;IACX,OAAO,CACL,SAAS,CAAC,OAAO,KAAK,SAAS,CAAC,OAAO;QACvC,SAAS,CAAC,WAAW,KAAK,SAAS,CAAC,WAAW;QAC/C,SAAS,CAAC,WAAW,KAAK,SAAS,CAAC,WAAW;QAC/C,SAAS,CAAC,sBAAsB,KAAK,SAAS,CAAC,sBAAsB;QACrE,SAAS,CAAC,6BAA6B,KAAK,SAAS,CAAC,6BAA6B;QACnF,SAAS,CAAC,cAAc,KAAK,SAAS,CAAC,cAAc;QACrD,SAAS,CAAC,SAAS,KAAK,SAAS,CAAC,SAAS;QAC3C,SAAS,CAAC,KAAK,KAAK,SAAS,CAAC,KAAK;QACnC,SAAS,CAAC,KAAK,KAAK,SAAS,CAAC,KAAK;QACnC,SAAS,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ,CAC1C,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport { Pressable, View, ViewProps } from \"react-native\";\nimport Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming } from \"react-native-reanimated\";\nimport AnimatedWrapper from \"../atoms/AnimatedWrapper\";\nimport type { ShadowLevel } from \"../types\";\nimport { ViewColorOptions } from \"../../theme/types\";\n\nconst DEFAULT_DURATION = { duration: 100 } as const;\nconst SCALE_VALUES = [1, 0.96] as const;\n\ninterface ZSPressableProps extends ViewProps {\n onPress?: (value?: any) => void;\n onLongPress?: (value?: any) => void;\n pressedBackgroundColor?: string;\n pressedBackgroundBorderRadius?: number;\n isAnimation?: boolean;\n elevationLevel?: ShadowLevel;\n fullWidth?: boolean;\n color?: ViewColorOptions;\n}\n\nfunction ZSPressable({\n onPress,\n onLongPress,\n isAnimation = true,\n pressedBackgroundColor = 'rgba(180, 180, 180, 0.1)',\n pressedBackgroundBorderRadius = 16,\n elevationLevel,\n fullWidth = false,\n color,\n ...props\n}: ZSPressableProps) {\n const isButtonPress = useSharedValue(0);\n\n const boxAnimation = useAnimatedStyle(() => {\n 'worklet';\n const scale = interpolate(\n isButtonPress.value,\n [0, 1],\n SCALE_VALUES,\n 'clamp'\n );\n return {\n transform: [{ scale }],\n };\n }, []);\n \n const handlePressIn = () => {\n isButtonPress.value = withTiming(1, DEFAULT_DURATION);\n };\n \n const handlePressOut = () => {\n isButtonPress.value = withTiming(0, DEFAULT_DURATION);\n };\n\n const handlePressStyle = (pressed: boolean) => {\n return pressed \n ? {\n backgroundColor: pressedBackgroundColor,\n borderRadius: pressedBackgroundBorderRadius,\n }\n : {\n backgroundColor: 'transparent',\n borderRadius: pressedBackgroundBorderRadius,\n };\n };\n\n const containerStyle = fullWidth ? { width: '100%' as const } : undefined;\n\n return (\n <View style={containerStyle}>\n <Pressable\n onPress={onPress}\n onLongPress={onLongPress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n style={({ pressed }) => handlePressStyle(pressed)}\n >\n <Animated.View style={boxAnimation}>\n <AnimatedWrapper\n color={color}\n isAnimation={isAnimation}\n elevationLevel={elevationLevel}\n style={props.style}\n >\n {props.children}\n </AnimatedWrapper>\n </Animated.View>\n </Pressable>\n </View>\n );\n}\n\nconst arePropsEqual = (\n prevProps: ZSPressableProps, \n nextProps: ZSPressableProps\n): boolean => {\n return (\n prevProps.onPress === nextProps.onPress &&\n prevProps.onLongPress === nextProps.onLongPress &&\n prevProps.isAnimation === nextProps.isAnimation &&\n prevProps.pressedBackgroundColor === nextProps.pressedBackgroundColor &&\n prevProps.pressedBackgroundBorderRadius === nextProps.pressedBackgroundBorderRadius &&\n prevProps.elevationLevel === nextProps.elevationLevel &&\n prevProps.fullWidth === nextProps.fullWidth &&\n prevProps.color === nextProps.color &&\n prevProps.style === nextProps.style &&\n prevProps.children === nextProps.children\n );\n};\n\nexport default React.memo(ZSPressable, arePropsEqual);\n"]}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { TextProps } from "react-native/types";
|
|
3
2
|
import { TypoOptions, TypoColorOptions } from "../../theme/types";
|
|
4
3
|
export interface ZSTextProps extends TextProps {
|
|
5
4
|
typo?: TypoOptions;
|
|
6
5
|
color?: TypoColorOptions;
|
|
7
6
|
}
|
|
8
|
-
declare function ZSText({ typo, color, ...props }: ZSTextProps):
|
|
9
|
-
|
|
10
|
-
export default _default;
|
|
7
|
+
declare function ZSText({ typo, color, ...props }: ZSTextProps): import("react").JSX.Element;
|
|
8
|
+
export default ZSText;
|
|
11
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSText/index.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSText/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAa,gBAAgB,EAA4C,MAAM,mBAAmB,CAAC;AAGvH,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC1C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC5B;AAED,iBAAS,MAAM,CAAC,EACd,IAAe,EACf,KAAc,EACd,GAAG,KAAK,EACT,EAAE,WAAW,+BAKb;AAED,eAAe,MAAM,CAAC"}
|
package/build/ui/ZSText/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React, { memo } from 'react';
|
|
2
1
|
import { useTheme } from "../../model/useThemeProvider";
|
|
3
2
|
import TextAtom from "../atoms/TextAtom";
|
|
4
3
|
function ZSText({ typo = 'body.2', color = 'base', ...props }) {
|
|
@@ -7,5 +6,5 @@ function ZSText({ typo = 'body.2', color = 'base', ...props }) {
|
|
|
7
6
|
const [c01, c02] = color.split('.');
|
|
8
7
|
return <TextAtom {...props} style={[typography[s01][s02], { color: c02 ? palette[c01][c02] : palette.text[c01] }, props.style]}>{props.children}</TextAtom>;
|
|
9
8
|
}
|
|
10
|
-
export default
|
|
9
|
+
export default ZSText;
|
|
11
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSText/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSText/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAExD,OAAO,QAAQ,MAAM,mBAAmB,CAAA;AAOxC,SAAS,MAAM,CAAC,EACd,IAAI,GAAG,QAAQ,EACf,KAAK,GAAG,MAAM,EACd,GAAG,KAAK,EACI;IACV,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC3C,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAA8B,CAAC;IAChE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAiC,CAAC;IACpE,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAA;AAC/J,CAAC;AAED,eAAe,MAAM,CAAC","sourcesContent":["import { TextProps } from \"react-native/types\";\nimport { useTheme } from \"../../model/useThemeProvider\";\nimport { TypoOptions, TypoStyle, TypoColorOptions, TypoSubStyle, TypoColor, SubColorOptions } from \"../../theme/types\";\nimport TextAtom from \"../atoms/TextAtom\"\n\nexport interface ZSTextProps extends TextProps {\n typo?: TypoOptions;\n color?: TypoColorOptions;\n}\n\nfunction ZSText({\n typo = 'body.2',\n color = 'base',\n ...props\n}: ZSTextProps) {\n const { palette, typography } = useTheme();\n const [s01, s02] = typo.split('.') as [TypoStyle, TypoSubStyle];\n const [c01, c02] = color.split('.') as [TypoColor, SubColorOptions];\n return <TextAtom {...props} style={[typography[s01][s02], { color: c02 ? palette[c01][c02] : palette.text[c01] }, props.style]}>{props.children}</TextAtom>\n}\n\nexport default ZSText;\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { TextInputProps } from 'react-native';
|
|
3
2
|
import { TypoOptions } from '../../theme';
|
|
4
3
|
export type BoxStyle = 'outline' | 'underline' | 'inbox';
|
|
@@ -28,6 +27,5 @@ interface TextFieldProps {
|
|
|
28
27
|
isTextArea?: boolean;
|
|
29
28
|
}
|
|
30
29
|
declare function ZSTextField({ typo, status, value, onChangeText, label, labelColor, placeHolderColor, inputBgColor, labelBgColor, borderWidth, borderColor, focusColor, errorColor, borderRadius, paddingHorizontal, errorMessage, textInputProps, boxStyle, innerBoxStyle, disabled, allowFontScaling, isTextArea, }: TextFieldProps): JSX.Element;
|
|
31
|
-
|
|
32
|
-
export default _default;
|
|
30
|
+
export default ZSTextField;
|
|
33
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSTextField/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSTextField/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAqD,cAAc,EAAa,MAAM,cAAc,CAAC;AAI5G,OAAO,EAAE,WAAW,EAA2B,MAAM,aAAa,CAAC;AAKnE,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;AAIzD,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,aAAa,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,iBAAS,WAAW,CAAC,EACnB,IAAe,EACf,MAAkB,EAClB,KAAK,EACL,YAAY,EACZ,KAAqB,EACrB,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,WAAiB,EACjB,WAAW,EACX,UAAU,EACV,UAAU,EACV,YAAiB,EACjB,iBAAsB,EACtB,YAAY,EACZ,cAAc,EACd,QAAoB,EACpB,aAAa,EACb,QAAgB,EAChB,gBAAuB,EACvB,UAAkB,GACnB,EAAE,cAAc,GAAG,GAAG,CAAC,OAAO,CAwN9B;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useMemo, useCallback, useState, useEffect } from 'react';
|
|
2
2
|
import { Platform, TextInput } from 'react-native';
|
|
3
|
-
import Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming
|
|
3
|
+
import Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
4
4
|
import ButtonClose from './ui/ButtonClose';
|
|
5
5
|
import ErrorComponent from './ui/ErrorComponent';
|
|
6
6
|
import { extractStyle } from '../../model/utils';
|
|
@@ -11,46 +11,27 @@ function ZSTextField({ typo = 'body.2', status = 'default', value, onChangeText,
|
|
|
11
11
|
const { typography, palette } = useTheme();
|
|
12
12
|
const [primaryStyle, subStyle] = typo.split('.');
|
|
13
13
|
const fErrorColor = errorColor || palette.danger.main;
|
|
14
|
-
const fontSize =
|
|
15
|
-
|
|
16
|
-
}, [typography, primaryStyle, subStyle]);
|
|
17
|
-
const fontFamily = useMemo(() => {
|
|
18
|
-
return extractStyle(typography[primaryStyle][subStyle], 'fontFamily') || '';
|
|
19
|
-
}, [typography, primaryStyle, subStyle]);
|
|
14
|
+
const fontSize = extractStyle(typography[primaryStyle][subStyle], 'fontSize') || 17;
|
|
15
|
+
const fontFamily = extractStyle(typography[primaryStyle][subStyle], 'fontFamily') || '';
|
|
20
16
|
const [isFocused, setIsFocused] = useState(false);
|
|
21
17
|
const boxHeightValue = useSharedValue(0);
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const shouldShow = hasValueState.value || isFocusedValue.value;
|
|
28
|
-
return withTiming(shouldShow ? 1 : 0, { duration: 100 });
|
|
29
|
-
}, []);
|
|
30
|
-
const focusAnimationValue = useDerivedValue(() => {
|
|
31
|
-
'worklet';
|
|
32
|
-
return withTiming(isFocusedValue.value ? 1 : 0, { duration: 150 });
|
|
33
|
-
}, []);
|
|
34
|
-
const errorAnimationValue = useDerivedValue(() => {
|
|
35
|
-
'worklet';
|
|
36
|
-
return withTiming(errorState.value ? 1 : 0, { duration: 150 });
|
|
37
|
-
}, []);
|
|
38
|
-
// 상태 동기화를 위한 useEffect
|
|
18
|
+
const hasValue = value !== '';
|
|
19
|
+
const isError = status === 'error';
|
|
20
|
+
const labelAnimationValue = useSharedValue(0);
|
|
21
|
+
const focusAnimationValue = useSharedValue(0);
|
|
22
|
+
const errorAnimationValue = useSharedValue(0);
|
|
39
23
|
useEffect(() => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}, [value, isFocused, status, isFocusedValue, hasValueState, errorState]);
|
|
47
|
-
const animationConstants = {
|
|
24
|
+
const animationOptions = { duration: 200 };
|
|
25
|
+
labelAnimationValue.value = withTiming(hasValue || isFocused ? 1 : 0, animationOptions);
|
|
26
|
+
focusAnimationValue.value = withTiming(isFocused ? 1 : 0, animationOptions);
|
|
27
|
+
errorAnimationValue.value = withTiming(isError ? 1 : 0, animationOptions);
|
|
28
|
+
}, [hasValue, isFocused, isError, labelAnimationValue, focusAnimationValue, errorAnimationValue]);
|
|
29
|
+
const animationConstants = useMemo(() => ({
|
|
48
30
|
baseFontSize: fontSize + (boxStyle === 'inbox' ? 1 : 0),
|
|
49
31
|
targetFontSize: boxStyle === 'inbox' ? 10 : 11,
|
|
50
32
|
baseTop: isTextArea ? 12 : 0,
|
|
51
33
|
targetTopOffset: boxStyle === 'inbox' ? 17 : 2,
|
|
52
|
-
};
|
|
53
|
-
// 라벨 애니메이션 스타일
|
|
34
|
+
}), [fontSize, boxStyle, isTextArea]);
|
|
54
35
|
const animatedLabelStyle = useAnimatedStyle(() => {
|
|
55
36
|
'worklet';
|
|
56
37
|
const labelFontSize = interpolate(labelAnimationValue.value, [0, 1], [animationConstants.baseFontSize, animationConstants.targetFontSize], 'clamp');
|
|
@@ -62,17 +43,13 @@ function ZSTextField({ typo = 'body.2', status = 'default', value, onChangeText,
|
|
|
62
43
|
top: labelTop,
|
|
63
44
|
fontSize: labelFontSize,
|
|
64
45
|
};
|
|
65
|
-
}, [animationConstants
|
|
66
|
-
// 레이아웃 핸들러
|
|
46
|
+
}, [animationConstants, isTextArea]);
|
|
67
47
|
const handleLayout = useCallback((event) => {
|
|
68
|
-
'worklet';
|
|
69
48
|
const { height } = event.nativeEvent.layout;
|
|
70
|
-
|
|
71
|
-
boxHeightValue.value = height;
|
|
49
|
+
boxHeightValue.value = height;
|
|
72
50
|
}, [boxHeightValue]);
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
const handleBlur = useCallback(() => setIsFocused(false), []);
|
|
51
|
+
const handleFocus = () => setIsFocused(true);
|
|
52
|
+
const handleBlur = () => setIsFocused(false);
|
|
76
53
|
const colorConfig = useMemo(() => ({
|
|
77
54
|
primaryColor: focusColor || palette.primary.main,
|
|
78
55
|
defaultBorderColor: borderColor || palette.grey[30],
|
|
@@ -80,7 +57,6 @@ function ZSTextField({ typo = 'body.2', status = 'default', value, onChangeText,
|
|
|
80
57
|
placeholderColor: placeHolderColor || palette.grey[40],
|
|
81
58
|
errorColor: fErrorColor,
|
|
82
59
|
}), [focusColor, palette.primary.main, borderColor, palette.grey, labelColor, palette.text.secondary, placeHolderColor, fErrorColor]);
|
|
83
|
-
// 애니메이션된 색상 스타일
|
|
84
60
|
const animatedColorStyle = useAnimatedStyle(() => {
|
|
85
61
|
'worklet';
|
|
86
62
|
const borderColor = errorAnimationValue.value > 0
|
|
@@ -91,22 +67,20 @@ function ZSTextField({ typo = 'body.2', status = 'default', value, onChangeText,
|
|
|
91
67
|
return {
|
|
92
68
|
borderColor,
|
|
93
69
|
};
|
|
94
|
-
}, [colorConfig
|
|
95
|
-
// 애니메이션된 라벨 색상 스타일
|
|
70
|
+
}, [colorConfig]);
|
|
96
71
|
const animatedLabelColorStyle = useAnimatedStyle(() => {
|
|
97
72
|
'worklet';
|
|
98
|
-
const hasValueAnimation = hasValueState.value ? 1 : 0;
|
|
99
73
|
const labelColor = errorAnimationValue.value > 0
|
|
100
74
|
? colorConfig.errorColor
|
|
101
75
|
: focusAnimationValue.value > 0
|
|
102
76
|
? colorConfig.primaryColor
|
|
103
|
-
:
|
|
77
|
+
: labelAnimationValue.value > 0
|
|
104
78
|
? colorConfig.defaultLabelColor
|
|
105
79
|
: colorConfig.placeholderColor;
|
|
106
80
|
return {
|
|
107
81
|
color: labelColor,
|
|
108
82
|
};
|
|
109
|
-
}, [colorConfig
|
|
83
|
+
}, [colorConfig]);
|
|
110
84
|
const styleConfig = useMemo(() => {
|
|
111
85
|
const baseStyle = {
|
|
112
86
|
width: '100%',
|
|
@@ -149,10 +123,7 @@ function ZSTextField({ typo = 'body.2', status = 'default', value, onChangeText,
|
|
|
149
123
|
}
|
|
150
124
|
return { ...baseStyle, ...borderStyle, ...innerStyle };
|
|
151
125
|
}, [isTextArea, borderRadius, paddingHorizontal, inputBgColor, borderWidth, boxStyle, innerBoxStyle, palette.background.base]);
|
|
152
|
-
|
|
153
|
-
const containerStyle = styleConfig;
|
|
154
|
-
// 라벨 스타일 정의
|
|
155
|
-
const labelTextStyle = useMemo(() => ({
|
|
126
|
+
const labelTextStyle = {
|
|
156
127
|
fontSize,
|
|
157
128
|
left: paddingHorizontal,
|
|
158
129
|
backgroundColor: labelBgColor || palette.background.base,
|
|
@@ -162,13 +133,12 @@ function ZSTextField({ typo = 'body.2', status = 'default', value, onChangeText,
|
|
|
162
133
|
fontFamily,
|
|
163
134
|
borderRadius: boxStyle === 'outline' ? 5 : 0,
|
|
164
135
|
overflow: 'hidden',
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const handleTextChange = useCallback((text) => {
|
|
136
|
+
};
|
|
137
|
+
const handleTextChange = (text) => {
|
|
168
138
|
if (onChangeText)
|
|
169
139
|
onChangeText(text);
|
|
170
|
-
}
|
|
171
|
-
const textInputStyle =
|
|
140
|
+
};
|
|
141
|
+
const textInputStyle = [
|
|
172
142
|
{
|
|
173
143
|
paddingTop: 7 + iosOffset,
|
|
174
144
|
paddingBottom: 5 + iosOffset,
|
|
@@ -179,11 +149,11 @@ function ZSTextField({ typo = 'body.2', status = 'default', value, onChangeText,
|
|
|
179
149
|
fontFamily
|
|
180
150
|
},
|
|
181
151
|
textInputProps?.style,
|
|
182
|
-
]
|
|
152
|
+
];
|
|
183
153
|
const shouldShowCloseButton = value && isFocused;
|
|
184
154
|
const shouldShowError = status === 'error' && errorMessage;
|
|
185
155
|
return (<ViewAtom style={{ alignSelf: 'stretch', width: '100%' }}>
|
|
186
|
-
<Animated.View style={[
|
|
156
|
+
<Animated.View style={[styleConfig, animatedColorStyle]} onLayout={handleLayout} pointerEvents={disabled ? 'none' : 'auto'}>
|
|
187
157
|
<TextInput {...textInputProps} style={textInputStyle} value={value} onFocus={handleFocus} onBlur={handleBlur} onChangeText={handleTextChange} allowFontScaling={allowFontScaling} selectionColor={palette.grey[50]} autoCorrect={false} spellCheck={false}/>
|
|
188
158
|
|
|
189
159
|
<ViewAtom pointerEvents="none" style={{ position: 'absolute' }}>
|
|
@@ -198,20 +168,5 @@ function ZSTextField({ typo = 'body.2', status = 'default', value, onChangeText,
|
|
|
198
168
|
{shouldShowError && (<ErrorComponent errorMessage={errorMessage} errorColor={fErrorColor}/>)}
|
|
199
169
|
</ViewAtom>);
|
|
200
170
|
}
|
|
201
|
-
|
|
202
|
-
return (prevProps.value === nextProps.value &&
|
|
203
|
-
prevProps.status === nextProps.status &&
|
|
204
|
-
prevProps.disabled === nextProps.disabled &&
|
|
205
|
-
prevProps.errorMessage === nextProps.errorMessage &&
|
|
206
|
-
prevProps.typo === nextProps.typo &&
|
|
207
|
-
prevProps.boxStyle === nextProps.boxStyle &&
|
|
208
|
-
prevProps.innerBoxStyle === nextProps.innerBoxStyle &&
|
|
209
|
-
prevProps.isTextArea === nextProps.isTextArea &&
|
|
210
|
-
prevProps.label === nextProps.label &&
|
|
211
|
-
prevProps.focusColor === nextProps.focusColor &&
|
|
212
|
-
prevProps.borderColor === nextProps.borderColor &&
|
|
213
|
-
prevProps.labelColor === nextProps.labelColor &&
|
|
214
|
-
prevProps.onChangeText === nextProps.onChangeText);
|
|
215
|
-
};
|
|
216
|
-
export default React.memo(ZSTextField, arePropsEqual);
|
|
171
|
+
export default ZSTextField;
|
|
217
172
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSTextField/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,EAAqB,QAAQ,EAAa,SAAS,EAAwC,MAAM,cAAc,CAAC;AACvH,OAAO,QAAQ,EAAE,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACxI,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,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CAClD,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import React, { useMemo, useCallback, useState, useEffect } from 'react';\nimport { LayoutChangeEvent, Platform, StyleProp, TextInput, TextInputProps, TextStyle, ViewStyle } from 'react-native';\nimport Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming, runOnUI, useDerivedValue } from 'react-native-reanimated';\nimport ButtonClose from './ui/ButtonClose';\nimport ErrorComponent from './ui/ErrorComponent';\nimport { TypoOptions, TypoStyle, TypoSubStyle } from '../../theme';\nimport { extractStyle } from '../../model/utils';\nimport { useTheme } from '../../model/useThemeProvider';\nimport ViewAtom from '../atoms/ViewAtom';\n\nexport type BoxStyle = 'outline' | 'underline' | 'inbox';\n\nconst iosOffset = Platform.OS === 'ios' ? 8 : 4;\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\nfunction ZSTextField({\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}: TextFieldProps): JSX.Element {\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 = useMemo(() => {\n return extractStyle(typography[primaryStyle][subStyle], 'fontSize') as number || 17;\n }, [typography, primaryStyle, subStyle]);\n \n const fontFamily = useMemo(() => {\n return extractStyle(typography[primaryStyle][subStyle], 'fontFamily') as string || '';\n }, [typography, primaryStyle, subStyle]);\n\n const [isFocused, setIsFocused] = useState<boolean>(false);\n const boxHeightValue = useSharedValue(0);\n const isFocusedValue = useSharedValue(false);\n const hasValueState = useSharedValue(false);\n const errorState = useSharedValue(false);\n\n const labelAnimationValue = useDerivedValue(() => {\n 'worklet';\n const shouldShow = hasValueState.value || isFocusedValue.value;\n return withTiming(shouldShow ? 1 : 0, { duration: 100 });\n }, []);\n\n const focusAnimationValue = useDerivedValue(() => {\n 'worklet';\n return withTiming(isFocusedValue.value ? 1 : 0, { duration: 150 });\n }, []);\n\n const errorAnimationValue = useDerivedValue(() => {\n 'worklet';\n return withTiming(errorState.value ? 1 : 0, { duration: 150 });\n }, []);\n\n // 상태 동기화를 위한 useEffect\n useEffect(() => {\n runOnUI(() => {\n 'worklet';\n isFocusedValue.value = isFocused;\n hasValueState.value = value !== '';\n errorState.value = status === 'error';\n })();\n }, [value, isFocused, status, isFocusedValue, hasValueState, errorState]);\n\n const animationConstants = {\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 };\n\n // 라벨 애니메이션 스타일\n const animatedLabelStyle = useAnimatedStyle(() => {\n 'worklet';\n\n const labelFontSize = interpolate(\n labelAnimationValue.value,\n [0, 1],\n [animationConstants.baseFontSize, animationConstants.targetFontSize],\n 'clamp'\n );\n\n const labelTop = interpolate(\n labelAnimationValue.value,\n [0, 1],\n [\n animationConstants.baseTop,\n isTextArea ? -12 : -(boxHeightValue.value / 2) - 1 + animationConstants.targetTopOffset,\n ],\n 'clamp'\n );\n\n return {\n top: labelTop,\n fontSize: labelFontSize,\n };\n }, [animationConstants.baseFontSize, animationConstants.targetFontSize, animationConstants.baseTop, animationConstants.targetTopOffset, isTextArea]);\n\n // 레이아웃 핸들러\n const handleLayout = useCallback((event: LayoutChangeEvent) => {\n 'worklet';\n \n const { height } = event.nativeEvent.layout;\n if (boxHeightValue.value !== height) boxHeightValue.value = height;\n }, [boxHeightValue]);\n\n // 포커스 및 블러 핸들러\n const handleFocus = useCallback(() => setIsFocused(true), []);\n const handleBlur = useCallback(() => setIsFocused(false), []);\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 // 애니메이션된 색상 스타일\n const animatedColorStyle = useAnimatedStyle(() => {\n 'worklet';\n \n const borderColor = errorAnimationValue.value > 0 \n ? colorConfig.errorColor\n : focusAnimationValue.value > 0\n ? colorConfig.primaryColor\n : colorConfig.defaultBorderColor;\n \n return {\n borderColor,\n };\n }, [colorConfig, errorAnimationValue, focusAnimationValue]);\n\n // 애니메이션된 라벨 색상 스타일\n const animatedLabelColorStyle = useAnimatedStyle(() => {\n 'worklet';\n \n const hasValueAnimation = hasValueState.value ? 1 : 0;\n const labelColor = errorAnimationValue.value > 0\n ? colorConfig.errorColor\n : focusAnimationValue.value > 0\n ? colorConfig.primaryColor\n : hasValueAnimation > 0\n ? colorConfig.defaultLabelColor\n : colorConfig.placeholderColor;\n \n return {\n color: labelColor,\n };\n }, [colorConfig, errorAnimationValue, focusAnimationValue]);\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 // 컨테이너 스타일 정의\n const containerStyle: StyleProp<ViewStyle> = styleConfig;\n\n // 라벨 스타일 정의\n const labelTextStyle: StyleProp<TextStyle> = useMemo(() => ({\n fontSize,\n left: paddingHorizontal,\n backgroundColor: labelBgColor || palette.background.base,\n paddingHorizontal: boxStyle === 'outline' ? 5 : 0,\n paddingVertical: 2,\n textAlignVertical: 'center',\n fontFamily,\n borderRadius: boxStyle === 'outline' ? 5 : 0,\n overflow: 'hidden',\n }), [fontSize, paddingHorizontal, labelBgColor, boxStyle, fontFamily, palette.background.base]);\n\n // 텍스트 변경 핸들러\n const handleTextChange = useCallback((text: string) => {\n if (onChangeText) onChangeText(text);\n }, [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 },\n textInputProps?.style,\n ], [palette.text.base, fontSize, fontFamily, textInputProps?.style]);\n\n const shouldShowCloseButton = value && isFocused;\n const shouldShowError = status === 'error' && errorMessage;\n\n return (\n <ViewAtom style={{ alignSelf: 'stretch', width: '100%' }}>\n <Animated.View\n style={[containerStyle, animatedColorStyle]}\n onLayout={handleLayout}\n pointerEvents={disabled ? 'none' : 'auto'}\n >\n <TextInput\n {...textInputProps}\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={[animatedLabelStyle, labelTextStyle, animatedLabelColorStyle]}>\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\nconst arePropsEqual = (prevProps: TextFieldProps, nextProps: TextFieldProps): boolean => {\n return (\n prevProps.value === nextProps.value &&\n prevProps.status === nextProps.status &&\n prevProps.disabled === nextProps.disabled &&\n prevProps.errorMessage === nextProps.errorMessage &&\n prevProps.typo === nextProps.typo &&\n prevProps.boxStyle === nextProps.boxStyle &&\n prevProps.innerBoxStyle === nextProps.innerBoxStyle &&\n prevProps.isTextArea === nextProps.isTextArea &&\n prevProps.label === nextProps.label &&\n prevProps.focusColor === nextProps.focusColor &&\n prevProps.borderColor === nextProps.borderColor &&\n prevProps.labelColor === nextProps.labelColor &&\n prevProps.onChangeText === nextProps.onChangeText\n );\n};\n\nexport default React.memo(ZSTextField, arePropsEqual);\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","s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K,CAAC,EAGpB;;QAAA,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAC7D;UAAA,CAAC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,kBAAkB,EAAE,cAAc,EAAE,uBAAuB,CAAC,CAAC,CACtH;YAAA,CAAC,KAAK,CACR;UAAA,EAAE,QAAQ,CAAC,IAAI,CACjB;QAAA,EAAE,QAAQ,CAEV;;QAAA,CAAC,qBAAqB,IAAI,CACxB,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,EAAG,CACpF,CACH;MAAA,EAAE,QAAQ,CAAC,IAAI,CAEf;;MAAA,CAAC,eAAe,IAAI,CAClB,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,EAAG,CACxE,CACH;IAAA,EAAE,QAAQ,CAAC,CACZ,CAAC;AACJ,CAAC;AAED,eAAe,WAAW,CAAC","sourcesContent":["import React, { useMemo, useCallback, useState, useEffect } from 'react';\nimport { LayoutChangeEvent, Platform, StyleProp, TextInput, TextInputProps, TextStyle } from 'react-native';\nimport Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';\nimport ButtonClose from './ui/ButtonClose';\nimport ErrorComponent from './ui/ErrorComponent';\nimport { TypoOptions, TypoStyle, TypoSubStyle } from '../../theme';\nimport { extractStyle } from '../../model/utils';\nimport { useTheme } from '../../model/useThemeProvider';\nimport ViewAtom from '../atoms/ViewAtom';\n\nexport type BoxStyle = 'outline' | 'underline' | 'inbox';\n\nconst iosOffset = Platform.OS === 'ios' ? 8 : 4;\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\nfunction ZSTextField({\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}: TextFieldProps): JSX.Element {\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 [isFocused, setIsFocused] = useState<boolean>(false);\n const boxHeightValue = useSharedValue(0);\n \n const hasValue = value !== '';\n const isError = status === 'error';\n \n const labelAnimationValue = useSharedValue(0);\n const focusAnimationValue = useSharedValue(0);\n const errorAnimationValue = useSharedValue(0);\n\n useEffect(() => {\n const animationOptions = { duration: 200 };\n \n labelAnimationValue.value = withTiming(hasValue || isFocused ? 1 : 0, animationOptions);\n focusAnimationValue.value = withTiming(isFocused ? 1 : 0, animationOptions);\n errorAnimationValue.value = withTiming(isError ? 1 : 0, animationOptions);\n }, [hasValue, isFocused, isError, labelAnimationValue, focusAnimationValue, errorAnimationValue]);\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 'worklet';\n \n const labelFontSize = interpolate(\n labelAnimationValue.value,\n [0, 1],\n [animationConstants.baseFontSize, animationConstants.targetFontSize],\n 'clamp'\n );\n\n const labelTop = interpolate(\n labelAnimationValue.value,\n [0, 1],\n [\n animationConstants.baseTop,\n isTextArea ? -12 : -(boxHeightValue.value / 2) - 1 + animationConstants.targetTopOffset,\n ],\n 'clamp'\n );\n\n return {\n top: labelTop,\n fontSize: labelFontSize,\n };\n }, [animationConstants, isTextArea]);\n\n const handleLayout = useCallback((event: LayoutChangeEvent) => {\n const { height } = event.nativeEvent.layout;\n boxHeightValue.value = height;\n }, [boxHeightValue]);\n\n const handleFocus = () => setIsFocused(true);\n const handleBlur = () => setIsFocused(false);\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 animatedColorStyle = useAnimatedStyle(() => {\n 'worklet';\n \n const borderColor = errorAnimationValue.value > 0 \n ? colorConfig.errorColor\n : focusAnimationValue.value > 0\n ? colorConfig.primaryColor\n : colorConfig.defaultBorderColor;\n \n return {\n borderColor,\n };\n }, [colorConfig]);\n\n const animatedLabelColorStyle = useAnimatedStyle(() => {\n 'worklet';\n \n const labelColor = errorAnimationValue.value > 0\n ? colorConfig.errorColor\n : focusAnimationValue.value > 0\n ? colorConfig.primaryColor\n : labelAnimationValue.value > 0\n ? colorConfig.defaultLabelColor\n : colorConfig.placeholderColor;\n \n return {\n color: labelColor,\n };\n }, [colorConfig]);\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> = {\n fontSize,\n left: paddingHorizontal,\n backgroundColor: labelBgColor || palette.background.base,\n paddingHorizontal: boxStyle === 'outline' ? 5 : 0,\n paddingVertical: 2,\n textAlignVertical: 'center',\n fontFamily,\n borderRadius: boxStyle === 'outline' ? 5 : 0,\n overflow: 'hidden',\n };\n\n const handleTextChange = (text: string) => {\n if (onChangeText) onChangeText(text);\n };\n\n const textInputStyle = [\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 },\n textInputProps?.style,\n ];\n\n const shouldShowCloseButton = value && isFocused;\n const shouldShowError = status === 'error' && errorMessage;\n\n return (\n <ViewAtom style={{ alignSelf: 'stretch', width: '100%' }}>\n <Animated.View\n style={[styleConfig, animatedColorStyle]}\n onLayout={handleLayout}\n pointerEvents={disabled ? 'none' : 'auto'}\n >\n <TextInput\n {...textInputProps}\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={[animatedLabelStyle, labelTextStyle, animatedLabelColorStyle]}>\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\nexport default ZSTextField;\n"]}
|
|
@@ -7,6 +7,6 @@ type Props = ViewProps & {
|
|
|
7
7
|
elevationLevel?: ShadowLevel;
|
|
8
8
|
color?: ViewColorOptions;
|
|
9
9
|
};
|
|
10
|
-
declare const
|
|
11
|
-
export default
|
|
10
|
+
declare const ZSView: React.FC<Props>;
|
|
11
|
+
export default ZSView;
|
|
12
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,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,SAAS,EAAc,MAAM,cAAc,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,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,QAAA,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAkB3B,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/build/ui/ZSView/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import { StyleSheet } from 'react-native';
|
|
3
3
|
import { useTheme } from '../../model/useThemeProvider';
|
|
4
4
|
import AnimatedWrapper from '../atoms/AnimatedWrapper';
|
|
@@ -13,5 +13,5 @@ const ZSView = ({ isAnimation = false, elevationLevel = 0, style, children, colo
|
|
|
13
13
|
{children}
|
|
14
14
|
</AnimatedWrapper>);
|
|
15
15
|
};
|
|
16
|
-
export default
|
|
16
|
+
export default ZSView;
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSView/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSView/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAa,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,eAAe,MAAM,0BAA0B,CAAC;AAUvD,MAAM,MAAM,GAAoB,CAAC,EAAE,WAAW,GAAG,KAAK,EAAE,cAAc,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE;IAC/G,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAC;IAE/B,MAAM,MAAM,GAAG,OAAO,CACpB,GAAG,EAAE,CACH,UAAU,CAAC,MAAM,CAAC;QAChB,SAAS,EAAE;YACT,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI;SACzC;KACF,CAAC,EACJ,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAC1B,CAAC;IAEF,OAAO,CACL,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAClI;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,eAAe,CAAC,CACnB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import React, { useMemo } from 'react';\nimport { ViewProps, StyleSheet } from 'react-native';\nimport { useTheme } from '../../model/useThemeProvider';\nimport AnimatedWrapper from '../atoms/AnimatedWrapper';\nimport { ShadowLevel } from '../types';\nimport { ViewColorOptions } from '../../theme';\n\ntype Props = ViewProps & {\n isAnimation?: boolean;\n elevationLevel?: ShadowLevel;\n color?: ViewColorOptions;\n};\n\nconst ZSView: React.FC<Props> = ({ isAnimation = false, elevationLevel = 0, style, children, color, ...rest }) => {\n const { palette } = useTheme();\n\n const styles = useMemo(\n () =>\n StyleSheet.create({\n container: {\n backgroundColor: palette.background.base,\n },\n }),\n [palette.background.base],\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 ZSView;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnimatedWrapper.d.ts","sourceRoot":"","sources":["../../../src/ui/atoms/AnimatedWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,EAAY,MAAM,cAAc,CAAC;AAGzD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAA8B,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAMjF,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,qBA4EtB;;AAgBD,wBAA0D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import { View, Platform } from 'react-native';
|
|
3
3
|
import Animated, { FadeInDown, FadeOut, useAnimatedStyle, withTiming, useSharedValue, useDerivedValue } from 'react-native-reanimated';
|
|
4
4
|
import { useTheme } from '../../model/useThemeProvider';
|
|
@@ -9,19 +9,11 @@ const IS_IOS = Platform.OS === 'ios';
|
|
|
9
9
|
function AnimatedWrapper({ isAnimation = true, elevationLevel = 0, duration = DEFAULT_DURATION, style, children, color, ...props }) {
|
|
10
10
|
const { elevation, palette } = useTheme();
|
|
11
11
|
const animationFinished = useSharedValue(false);
|
|
12
|
-
const
|
|
12
|
+
const staticConfig = useMemo(() => ({
|
|
13
13
|
isIOS: IS_IOS,
|
|
14
14
|
maxShadowOpacity: IS_IOS ? IOS_SHADOW[elevationLevel].shadowOpacity : 0,
|
|
15
15
|
maxElevation: IS_IOS ? 0 : elevationLevel,
|
|
16
|
-
});
|
|
17
|
-
if (staticConfigRef.current.maxShadowOpacity !== (IS_IOS ? IOS_SHADOW[elevationLevel].shadowOpacity : 0) ||
|
|
18
|
-
staticConfigRef.current.maxElevation !== (IS_IOS ? 0 : elevationLevel)) {
|
|
19
|
-
staticConfigRef.current = {
|
|
20
|
-
isIOS: IS_IOS,
|
|
21
|
-
maxShadowOpacity: IS_IOS ? IOS_SHADOW[elevationLevel].shadowOpacity : 0,
|
|
22
|
-
maxElevation: IS_IOS ? 0 : elevationLevel,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
16
|
+
}), [elevationLevel]);
|
|
25
17
|
const backgroundColor = useMemo(() => {
|
|
26
18
|
if (!color) {
|
|
27
19
|
return elevationLevel ? palette.background.base : undefined;
|
|
@@ -45,13 +37,12 @@ function AnimatedWrapper({ isAnimation = true, elevationLevel = 0, duration = DE
|
|
|
45
37
|
}, []);
|
|
46
38
|
const animatedStyle = useAnimatedStyle(() => {
|
|
47
39
|
'worklet';
|
|
48
|
-
const config = staticConfigRef.current;
|
|
49
40
|
const shadowValue = shadowProgress.value;
|
|
50
|
-
if (
|
|
51
|
-
return { shadowOpacity: shadowValue *
|
|
41
|
+
if (staticConfig.isIOS) {
|
|
42
|
+
return { shadowOpacity: shadowValue * staticConfig.maxShadowOpacity };
|
|
52
43
|
}
|
|
53
|
-
return { elevation: shadowValue *
|
|
54
|
-
}, []);
|
|
44
|
+
return { elevation: shadowValue * staticConfig.maxElevation };
|
|
45
|
+
}, [staticConfig]);
|
|
55
46
|
const animationProps = useMemo(() => ({
|
|
56
47
|
entering: FadeInDown.duration(duration).withCallback((finished) => {
|
|
57
48
|
'worklet';
|
|
@@ -60,16 +51,16 @@ function AnimatedWrapper({ isAnimation = true, elevationLevel = 0, duration = DE
|
|
|
60
51
|
}
|
|
61
52
|
}),
|
|
62
53
|
exiting: FadeOut.duration(50),
|
|
63
|
-
}), [duration
|
|
64
|
-
const baseStyle =
|
|
54
|
+
}), [duration]);
|
|
55
|
+
const baseStyle = [
|
|
65
56
|
style,
|
|
66
57
|
backgroundColor && { backgroundColor },
|
|
67
58
|
staticStyle
|
|
68
|
-
]
|
|
69
|
-
const animatedStyleArray =
|
|
59
|
+
];
|
|
60
|
+
const animatedStyleArray = [
|
|
70
61
|
...baseStyle,
|
|
71
62
|
animatedStyle
|
|
72
|
-
]
|
|
63
|
+
];
|
|
73
64
|
if (!isAnimation) {
|
|
74
65
|
return <View style={baseStyle} {...props}>{children}</View>;
|
|
75
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnimatedWrapper.js","sourceRoot":"","sources":["../../../src/ui/atoms/AnimatedWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"AnimatedWrapper.js","sourceRoot":"","sources":["../../../src/ui/atoms/AnimatedWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,IAAI,EAAa,QAAQ,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,QAAQ,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACvI,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,MAAM,gBAAgB,GAAG,GAAY,CAAC;AACtC,MAAM,eAAe,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ACzB,GAAG,SAAS;QACZ,aAAa;KACd,CAAC;IAEF,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,CACL,CAAC,QAAQ,CAAC,IAAI,CACZ,KAAK,CAAC,CAAC,kBAAkB,CAAC,CAC1B,IAAI,cAAc,CAAC,CACnB,IAAI,KAAK,CAAC,CAEV;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,QAAQ,CAAC,IAAI,CAAC,CACjB,CAAC;AACJ,CAAC;AAED,MAAM,aAAa,GAAG,CACpB,SAA+B,EAC/B,SAA+B,EACtB,EAAE;IACX,IAAI,SAAS,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5D,IAAI,SAAS,CAAC,KAAK,KAAK,SAAS,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACtD,IAAI,SAAS,CAAC,WAAW,KAAK,SAAS,CAAC,WAAW;QAAE,OAAO,KAAK,CAAC;IAClE,IAAI,SAAS,CAAC,cAAc,KAAK,SAAS,CAAC,cAAc;QAAE,OAAO,KAAK,CAAC;IACxE,IAAI,SAAS,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5D,IAAI,SAAS,CAAC,KAAK,KAAK,SAAS,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAEtD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC,IAAI,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import React, { useMemo } from 'react';\nimport { View, ViewProps, Platform } from 'react-native';\nimport Animated, { FadeInDown, FadeOut, useAnimatedStyle, withTiming, useSharedValue, useDerivedValue } from 'react-native-reanimated';\nimport { useTheme } from '../../model/useThemeProvider';\nimport { ShadowLevel } from '../types';\nimport { IOS_SHADOW } from '../../theme/elevation';\nimport { SubColorOptions, ViewColor, ViewColorOptions } from '../../theme/types';\n\nconst DEFAULT_DURATION = 200 as const;\nconst SHADOW_DURATION = 50 as const;\nconst IS_IOS = Platform.OS === 'ios';\n\ninterface AnimatedWrapperProps extends ViewProps {\n isAnimation: boolean;\n elevationLevel?: ShadowLevel;\n duration?: number;\n color?: ViewColorOptions;\n}\n\nfunction AnimatedWrapper({\n isAnimation = true,\n elevationLevel = 0,\n duration = DEFAULT_DURATION,\n style,\n children,\n color,\n ...props\n}: AnimatedWrapperProps) {\n const { elevation, palette } = useTheme();\n const animationFinished = useSharedValue(false);\n \n const staticConfig = useMemo(() => ({\n isIOS: IS_IOS,\n maxShadowOpacity: IS_IOS ? IOS_SHADOW[elevationLevel].shadowOpacity : 0,\n maxElevation: IS_IOS ? 0 : elevationLevel,\n }), [elevationLevel]);\n \n const backgroundColor = useMemo(() => {\n if (!color) {\n return elevationLevel ? palette.background.base : undefined;\n }\n \n const [c01, c02] = color.split('.') as [ViewColor, SubColorOptions];\n if (c02) return palette[c01][c02];\n if (c01) return palette.background[c01];\n if (elevationLevel) return palette.background.base;\n return undefined;\n }, [color, palette, elevationLevel]);\n\n const staticStyle = elevation[elevationLevel];\n\n const shadowProgress = useDerivedValue(() => {\n 'worklet';\n if (animationFinished.value) {\n return withTiming(1, { duration: SHADOW_DURATION });\n }\n return 0;\n }, []);\n\n const animatedStyle = useAnimatedStyle(() => {\n 'worklet';\n const shadowValue = shadowProgress.value;\n \n if (staticConfig.isIOS) {\n return { shadowOpacity: shadowValue * staticConfig.maxShadowOpacity };\n }\n return { elevation: shadowValue * staticConfig.maxElevation };\n }, [staticConfig]);\n\n const animationProps = useMemo(() => ({\n entering: FadeInDown.duration(duration).withCallback((finished) => {\n 'worklet';\n if (finished) {\n animationFinished.value = true;\n }\n }),\n exiting: FadeOut.duration(50),\n }), [duration]);\n\n const baseStyle = [\n style,\n backgroundColor && { backgroundColor },\n staticStyle\n ];\n\n const animatedStyleArray = [\n ...baseStyle,\n animatedStyle\n ];\n\n if (!isAnimation) {\n return <View style={baseStyle} {...props}>{children}</View>;\n }\n\n return (\n <Animated.View\n style={animatedStyleArray}\n {...animationProps}\n {...props}\n >\n {children}\n </Animated.View>\n );\n}\n\nconst arePropsEqual = (\n prevProps: AnimatedWrapperProps, \n nextProps: AnimatedWrapperProps\n): boolean => {\n if (prevProps.children !== nextProps.children) return false;\n if (prevProps.style !== nextProps.style) return false;\n if (prevProps.isAnimation !== nextProps.isAnimation) return false;\n if (prevProps.elevationLevel !== nextProps.elevationLevel) return false;\n if (prevProps.duration !== nextProps.duration) return false;\n if (prevProps.color !== nextProps.color) return false;\n \n return true;\n};\n\nexport default React.memo(AnimatedWrapper, arePropsEqual);\n"]}
|