@0610studio/zs-ui 0.13.9 → 0.13.11
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/ui/ZSBlockButton/index.d.ts.map +1 -1
- package/build/ui/ZSBlockButton/index.js +4 -2
- package/build/ui/ZSBlockButton/index.js.map +1 -1
- package/build/ui/ZSContainer/index.js +4 -4
- package/build/ui/ZSContainer/index.js.map +1 -1
- package/build/ui/ZSTextField/index.d.ts +2 -2
- package/build/ui/ZSTextField/index.d.ts.map +1 -1
- package/build/ui/ZSTextField/index.js +32 -23
- package/build/ui/ZSTextField/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSBlockButton/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAS,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/F,OAAO,EAAoB,WAAW,EAAoB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAMnG,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACxC,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,iBAAS,aAAa,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAkB,EAAE,IAAI,EAAE,UAAU,EAAE,OAAiB,EAAE,SAAiB,EAAE,QAAgB,EAAE,EAAE,KAAK,+
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSBlockButton/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAS,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/F,OAAO,EAAoB,WAAW,EAAoB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAMnG,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACxC,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,iBAAS,aAAa,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAkB,EAAE,IAAI,EAAE,UAAU,EAAE,OAAiB,EAAE,SAAiB,EAAE,QAAgB,EAAE,EAAE,KAAK,+BAgHpJ;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -59,13 +59,15 @@ function ZSBlockButton({ onPress, style, title, intent = 'primary', typo, prefix
|
|
|
59
59
|
: size === '3' ? 10
|
|
60
60
|
: size === '4' ? 8
|
|
61
61
|
: size === '5' ? 7
|
|
62
|
-
:
|
|
62
|
+
: size === '6' ? 5
|
|
63
|
+
: 10;
|
|
63
64
|
const paddingVertical = size === '1' ? 9
|
|
64
65
|
: size === '2' ? 9
|
|
65
66
|
: size === '3' ? 8
|
|
66
67
|
: size === '4' ? 6
|
|
67
68
|
: size === '5' ? 5
|
|
68
|
-
:
|
|
69
|
+
: size === '6' ? 4
|
|
70
|
+
: 8;
|
|
69
71
|
const getTextColorValue = () => {
|
|
70
72
|
const [c01, c02] = colors.textColor.split('.');
|
|
71
73
|
if (c02) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSBlockButton/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAA4D,MAAM,cAAc,CAAC;AAE/F,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,MAAM,MAAM,WAAW,CAAC;AAc/B,SAAS,aAAa,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,GAAG,OAAO,EAAE,SAAS,GAAG,KAAK,EAAE,QAAQ,GAAG,KAAK,EAAS;IACnJ,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhC,MAAM,SAAS,GAAG,GAKhB,EAAE;QACF,MAAM,SAAS,GAAG,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ;YAC9C,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS;gBAChC,CAAC,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC,CAAC,aAAa;oBACxC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS;wBAChC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS;4BAChC,CAAC,CAAC,MAAM,CAAC;QAEnB,IAAI,OAAO,KAAK,OAAO,EAAE;YACvB,OAAO;gBACL,eAAe,EAAE,GAAG,SAAS,KAAyB;gBACtD,SAAS,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AQ;YACpB,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;YACN,eAAe,EAAE,MAAM,CAAC,eAAe,KAAK,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;YACrF,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC,CAAC,CACF,KAAK,CAAC,CAAC,MAAM,CAAC,eAAe,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,CAErF;QAAA,CAAC,UAAU,IAAI,CACb,CAAC,KAAK,CACJ,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAC/C,SAAS,CAAC,CAAC,cAAc,CAAC,CAC1B,MAAM,CAAC,CAAC,UAAU,CAAC,EACnB,CACH,CACD;QAAA,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,CAC9D;MAAA,EAAE,MAAM,CACV;IAAA,EAAE,WAAW,CAAC,CACf,CAAC;AACJ,CAAC;AAED,eAAe,aAAa,CAAC","sourcesContent":["import { Image, type ImageSourcePropType, type StyleProp, type ViewStyle } from 'react-native';\nimport { TypoColorOptions, TypoOptions, ViewColorOptions, IntentOptions } from '../../theme/types';\nimport { useTheme } from '../../context/ThemeContext';\nimport ZSPressable from '../ZSPressable';\nimport ZSView from '../ZSView';\nimport ZSText from '../ZSText';\n\ntype Props = {\n onPress: () => void;\n style?: StyleProp<ViewStyle>;\n title: string;\n intent?: IntentOptions;\n variant?: 'solid' | 'pastel' | 'stroke';\n typo: TypoOptions;\n prefixIcon?: ImageSourcePropType;\n isLoading?: boolean;\n disabled?: boolean;\n};\n\nfunction ZSBlockButton({ onPress, style, title, intent = 'primary', typo, prefixIcon, variant = 'solid', isLoading = false, disabled = false }: Props) {\n const { palette } = useTheme();\n const size = typo.split('.')[1];\n\n const getColors = (): {\n backgroundColor: ViewColorOptions | 'transparent';\n textColor: TypoColorOptions;\n borderColor?: string;\n borderWidth: number;\n } => {\n const baseColor = intent === 'danger' ? 'danger'\n : intent === 'primary' ? 'primary'\n : intent === 'information' ? 'information'\n : intent === 'success' ? 'success'\n : intent === 'warning' ? 'warning'\n : 'grey';\n\n if (variant === 'solid') {\n return {\n backgroundColor: `${baseColor}.50` as ViewColorOptions,\n textColor: 'white' as TypoColorOptions,\n borderColor: undefined,\n borderWidth: 0,\n };\n } else if (variant === 'pastel') {\n return {\n backgroundColor: `${baseColor}.10` as ViewColorOptions,\n textColor: (intent === 'danger' ? 'danger.60'\n : intent === 'primary' ? 'primary.60'\n : intent === 'information' ? 'information.60'\n : intent === 'success' ? 'success.60'\n : intent === 'warning' ? 'warning.60'\n : 'grey.70') as TypoColorOptions,\n borderColor: undefined,\n borderWidth: 0,\n };\n } else { // stroke\n return {\n backgroundColor: 'transparent',\n textColor: (intent === 'danger' ? 'danger.50'\n : intent === 'primary' ? 'primary.50'\n : intent === 'information' ? 'information.50'\n : intent === 'success' ? 'success.50'\n : intent === 'warning' ? 'warning.60'\n : 'grey.60') as TypoColorOptions,\n borderColor: intent === 'danger' ? palette.danger[50]\n : intent === 'primary' ? palette.primary[50]\n : intent === 'information' ? palette.information[50]\n : intent === 'success' ? palette.success[50]\n : intent === 'warning' ? palette.warning[50]\n : palette.grey[50],\n borderWidth: 1,\n };\n }\n };\n\n const colors = getColors();\n\n const paddingHorizontal = size === '1' ? 11\n : size === '2' ? 11\n : size === '3' ? 10\n : size === '4' ? 8\n : size === '5' ? 7\n : size === '6' ? 5\n : 10;\n\n const paddingVertical = size === '1' ? 9\n : size === '2' ? 9\n : size === '3' ? 8\n : size === '4' ? 6\n : size === '5' ? 5\n : size === '6' ? 4\n : 8;\n\n const getTextColorValue = () => {\n const [c01, c02] = colors.textColor.split('.');\n if (c02) {\n return palette[c01][c02];\n }\n return palette.text[c01];\n };\n\n const textColorValue = getTextColorValue();\n\n return (\n <ZSPressable onPress={onPress} style={style} isLoading={isLoading} disabled={disabled}>\n <ZSView\n style={{\n paddingHorizontal,\n paddingVertical,\n borderRadius: 6,\n justifyContent: 'center',\n alignItems: 'center',\n flexDirection: 'row',\n gap: 4,\n backgroundColor: colors.backgroundColor === 'transparent' ? 'transparent' : undefined,\n borderColor: colors.borderColor,\n borderWidth: colors.borderWidth,\n }}\n color={colors.backgroundColor !== 'transparent' ? colors.backgroundColor : undefined}\n >\n {prefixIcon && (\n <Image\n style={{ width: 12, height: 12, marginTop: 1 }}\n tintColor={textColorValue}\n source={prefixIcon}\n />\n )}\n <ZSText color={colors.textColor} typo={typo}>{title}</ZSText>\n </ZSView>\n </ZSPressable>\n );\n}\n\nexport default ZSBlockButton;\n"]}
|
|
@@ -30,7 +30,7 @@ foldableSingleScreen, dividerLineComponent, rightComponent,
|
|
|
30
30
|
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
31
31
|
const scrollTimeoutRef = useRef(null);
|
|
32
32
|
useImperativeHandle(forwardedRef, () => scrollViewRef.current, [scrollViewDisabled]);
|
|
33
|
-
const handleKeyboardShow = (e) => {
|
|
33
|
+
const handleKeyboardShow = useCallback((e) => {
|
|
34
34
|
setKeyboardHeight(e.endCoordinates.height);
|
|
35
35
|
if ((scrollViewRef.current || scrollView2Ref.current) && scrollToFocusedInput) {
|
|
36
36
|
const keyboardHeight = e.endCoordinates.height;
|
|
@@ -61,10 +61,10 @@ foldableSingleScreen, dividerLineComponent, rightComponent,
|
|
|
61
61
|
scrollTimeoutRef.current = null;
|
|
62
62
|
}, KEYBOARD_ANIMATION_DELAY);
|
|
63
63
|
}
|
|
64
|
-
};
|
|
65
|
-
const handleKeyboardHide = () => {
|
|
64
|
+
}, [scrollToFocusedInput, keyboardScrollExtraOffset]);
|
|
65
|
+
const handleKeyboardHide = useCallback(() => {
|
|
66
66
|
setKeyboardHeight(0);
|
|
67
|
-
};
|
|
67
|
+
}, []);
|
|
68
68
|
useKeyboard({
|
|
69
69
|
handleKeyboardShow,
|
|
70
70
|
handleKeyboardHide,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSContainer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAa,SAAS,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7H,OAAO,EAAa,SAAS,EAAE,UAAU,EAAE,UAAU,EAA2C,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACvI,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAO,eAAe,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,YAAY,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;AACrD,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,MAAM,mBAAmB,GAAG;IAC1B,OAAO,EAAE,KAAK;IACd,cAAc,EAAE,OAAgB;IAChC,yBAAyB,EAAE,SAAkB;IAC7C,iCAAiC,EAAE,KAAK;CACzC,CAAA;AAuBD,MAAM,WAAW,GAAG,UAAU,CAAmC,SAAS,WAAW,CACnF,EACE,eAAe,EACf,cAAc,EACd,QAAQ,EACR,KAAK,GAAG,CAAC,QAAQ,CAAC,EAClB,kBAAkB,GAAG,KAAK,EAC1B,YAAY,EACZ,eAAe,EACf,4BAA4B,GAAG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AAC,IAAI,CAAC,CAC3D,WAAW,CAAC,CAAC,WAAW,CAAC,EACzB,CACH,CACH;IAAA,EAAE,YAAY,CAAC,CAChB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IACtC,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;IAClB,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE;IAChC,oBAAoB,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE;CAC3E,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC","sourcesContent":["import React, { ReactNode, useEffect, useImperativeHandle, forwardRef, useRef, useState, useCallback, useMemo } from 'react';\r\nimport { ViewProps, StatusBar, StyleSheet, ScrollView, NativeSyntheticEvent, NativeScrollEvent, View, Dimensions } from 'react-native';\r\nimport { SafeAreaView } from 'react-native-safe-area-context';\r\nimport { useTheme } from '../../context/ThemeContext';\r\nimport useKeyboard from '../../model/useKeyboard';\r\nimport useFoldingState from '../../model/useFoldingState';\r\nimport { FoldingState } from '../../model/types';\r\nimport { MAX_FOLDABLE_SINGLE_WIDTH } from '../../model/utils';\r\n\r\nconst windowHeight = Dimensions.get('window').height;\r\nconst KEYBOARD_ANIMATION_DELAY = 50;\r\nconst SCROLL_VIEW_OPTIONS = {\r\n bounces: false,\r\n overScrollMode: \"never\" as const,\r\n keyboardShouldPersistTaps: \"handled\" as const,\r\n automaticallyAdjustKeyboardInsets: false\r\n}\r\n\r\nexport type ZSContainerProps = ViewProps & {\r\n backgroundColor?: string;\r\n statusBarColor?: string;\r\n barStyle?: 'light-content' | 'dark-content';\r\n edges?: Array<'top' | 'right' | 'bottom' | 'left'>;\r\n scrollViewDisabled?: boolean;\r\n topComponent?: ReactNode;\r\n bottomComponent?: ReactNode;\r\n rightComponent?: ReactNode;\r\n showsVerticalScrollIndicator?: boolean;\r\n keyboardScrollExtraOffset?: number;\r\n translucent?: boolean;\r\n onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;\r\n scrollEventThrottle?: number;\r\n scrollToFocusedInput?: boolean;\r\n foldableSingleScreen?: boolean;\r\n dividerLineComponent?: ReactNode;\r\n};\r\n\r\nexport type ZSContainerRef = ScrollView;\r\n\r\nconst ZSContainer = forwardRef<ZSContainerRef, ZSContainerProps>(function ZSContainer(\r\n {\r\n backgroundColor,\r\n statusBarColor,\r\n barStyle,\r\n edges = ['bottom'],\r\n scrollViewDisabled = false,\r\n topComponent,\r\n bottomComponent,\r\n showsVerticalScrollIndicator = true,\r\n keyboardScrollExtraOffset = 30,\r\n translucent,\r\n scrollEventThrottle = 16,\r\n scrollToFocusedInput = true,\r\n // foldable device\r\n foldableSingleScreen,\r\n dividerLineComponent,\r\n rightComponent,\r\n // ---\r\n ...props\r\n },\r\n forwardedRef\r\n) {\r\n const { palette } = useTheme();\r\n const { foldingState, width } = useFoldingState();\r\n const positionRef = useRef<number | null>(0);\r\n const position2Ref = useRef<number | null>(0);\r\n const scrollViewRef = useRef<ScrollView>(null);\r\n const scrollView2Ref = useRef<ScrollView>(null);\r\n const touchPositionRef = useRef<number | null>(0);\r\n const lastTouchY = useRef<number | null>(0);\r\n const [keyboardHeight, setKeyboardHeight] = useState<number | null>(0);\r\n const scrollTimeoutRef = useRef<number | null>(null);\r\n\r\n useImperativeHandle(forwardedRef, () => scrollViewRef.current as ScrollView, [scrollViewDisabled]);\r\n\r\n const handleKeyboardShow = (e: any) => {\r\n setKeyboardHeight(e.endCoordinates.height);\r\n\r\n if ((scrollViewRef.current || scrollView2Ref.current) && scrollToFocusedInput) {\r\n const keyboardHeight = e.endCoordinates.height;\r\n const safeAreaBottom = 0;\r\n const availableScreenHeight = windowHeight - keyboardHeight - safeAreaBottom;\r\n\r\n // 현재 스크롤 위치 참조\r\n const currentScrollPosition = touchPositionRef.current === 1\r\n ? positionRef.current || 0\r\n : position2Ref.current || 0;\r\n\r\n const touchPosition = lastTouchY.current || 0;\r\n\r\n // 현재 터치 위치와 스크롤 위치를 기반으로 새로운 스크롤 위치 계산\r\n const scrollOffset = touchPosition - availableScreenHeight + keyboardScrollExtraOffset;\r\n\r\n if (scrollTimeoutRef.current) clearTimeout(scrollTimeoutRef.current);\r\n scrollTimeoutRef.current = setTimeout(() => {\r\n if (touchPositionRef.current === 1) {\r\n scrollViewRef.current?.scrollTo({\r\n y: currentScrollPosition + scrollOffset,\r\n animated: true,\r\n });\r\n } else {\r\n scrollView2Ref.current?.scrollTo({\r\n y: currentScrollPosition + scrollOffset,\r\n animated: true,\r\n });\r\n }\r\n scrollTimeoutRef.current = null;\r\n }, KEYBOARD_ANIMATION_DELAY);\r\n }\r\n };\r\n\r\n const handleKeyboardHide = () => {\r\n setKeyboardHeight(0);\r\n };\r\n\r\n useKeyboard({\r\n handleKeyboardShow,\r\n handleKeyboardHide,\r\n });\r\n\r\n // 클린업\r\n useEffect(() => {\r\n return () => {\r\n positionRef.current = null;\r\n lastTouchY.current = null;\r\n if (scrollTimeoutRef.current) {\r\n clearTimeout(scrollTimeoutRef.current);\r\n scrollTimeoutRef.current = null;\r\n }\r\n };\r\n }, []);\r\n \r\n // 에러 로그 출력\r\n useEffect(() => {\r\n if (foldableSingleScreen && (rightComponent || dividerLineComponent)) {\r\n console.error('[ZSContainer] foldableSingleScreen일 때는 rightComponent/dividerLineComponent를 사용할 수 없습니다.');\r\n }\r\n }, [foldableSingleScreen, rightComponent, dividerLineComponent]);\r\n\r\n const handleScroll = useCallback((event: NativeSyntheticEvent<NativeScrollEvent>, position: 1 | 2) => {\r\n if (props.onScroll) props.onScroll(event);\r\n\r\n if (position === 1) {\r\n positionRef.current = event.nativeEvent.contentOffset.y;\r\n } else {\r\n position2Ref.current = event.nativeEvent.contentOffset.y;\r\n }\r\n }, [props.onScroll]);\r\n\r\n const handleTouch = useCallback((evt: any, position: 1 | 2) => {\r\n lastTouchY.current = evt.nativeEvent.pageY;\r\n touchPositionRef.current = position;\r\n }, []);\r\n\r\n const safeAreaStyle = useMemo(() => [\r\n { backgroundColor: backgroundColor || palette.background.base },\r\n styles.w100\r\n ], [backgroundColor, palette.background.base]);\r\n\r\n const scrollContentStyle = useMemo(() => [\r\n styles.scrollContainerStyle,\r\n {\r\n paddingBottom: keyboardHeight ? keyboardHeight : 0\r\n }\r\n ], [keyboardHeight]);\r\n\r\n const containerStyle = useMemo(() => [\r\n styles.w100,\r\n props.style\r\n ], [props.style]);\r\n\r\n const shouldShowStatusBar = useMemo(() =>\r\n Boolean(barStyle || statusBarColor || translucent),\r\n [barStyle, statusBarColor, translucent]\r\n );\r\n\r\n return (\r\n <SafeAreaView\r\n style={safeAreaStyle}\r\n edges={edges}\r\n >\r\n <View style={[styles.w100, { backgroundColor: \"#00000009\" }]}>\r\n <View style={[styles.w100, { maxWidth: foldableSingleScreen ? Math.min(width, MAX_FOLDABLE_SINGLE_WIDTH) : '100%', alignSelf: 'center', backgroundColor: palette.background.base }]}>\r\n {topComponent}\r\n <View style={[styles.w100, { flexDirection: 'row' }]}>\r\n <View style={styles.flex1}>\r\n {scrollViewDisabled ? (\r\n <View style={[styles.flex1, containerStyle]}>\r\n {props.children}\r\n </View>\r\n ) : (\r\n <ScrollView\r\n ref={scrollViewRef}\r\n style={styles.w100}\r\n showsVerticalScrollIndicator={showsVerticalScrollIndicator}\r\n contentContainerStyle={scrollContentStyle}\r\n scrollEventThrottle={scrollEventThrottle}\r\n onScroll={(event) => { handleScroll(event, 1); }}\r\n onTouchStart={(evt) => handleTouch(evt, 1)}\r\n // ---\r\n {...SCROLL_VIEW_OPTIONS}\r\n >\r\n <View style={[styles.flex1, containerStyle]}>\r\n {props.children}\r\n </View>\r\n </ScrollView>\r\n )}\r\n </View>\r\n {foldingState === FoldingState.UNFOLDED && !foldableSingleScreen && rightComponent && dividerLineComponent && dividerLineComponent}\r\n {\r\n foldingState === FoldingState.UNFOLDED && !foldableSingleScreen && rightComponent && (\r\n <View style={styles.flex1}>\r\n {scrollViewDisabled ? (\r\n <View style={[styles.flex1, containerStyle]}>\r\n {rightComponent}\r\n </View>\r\n ) : (\r\n <ScrollView\r\n ref={scrollView2Ref}\r\n style={styles.w100}\r\n showsVerticalScrollIndicator={showsVerticalScrollIndicator}\r\n contentContainerStyle={scrollContentStyle}\r\n scrollEventThrottle={scrollEventThrottle}\r\n onScroll={(event) => { handleScroll(event, 2); }}\r\n onTouchStart={(evt) => handleTouch(evt, 2)}\r\n // ---\r\n {...SCROLL_VIEW_OPTIONS}\r\n >\r\n <View style={[styles.flex1, containerStyle]}>\r\n {rightComponent}\r\n </View>\r\n </ScrollView>\r\n )}\r\n </View>\r\n )\r\n }\r\n </View>\r\n {bottomComponent}\r\n </View>\r\n </View>\r\n\r\n {shouldShowStatusBar && (\r\n <StatusBar\r\n barStyle={barStyle}\r\n backgroundColor={statusBarColor || palette.background.base}\r\n translucent={translucent}\r\n />\r\n )}\r\n </SafeAreaView>\r\n );\r\n});\r\n\r\nexport const styles = StyleSheet.create({\r\n flex1: { flex: 1 },\r\n w100: { flex: 1, width: '100%' },\r\n scrollContainerStyle: { alignItems: 'center', width: '100%', flexGrow: 1 },\r\n});\r\n\r\nexport default ZSContainer;\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSContainer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAa,SAAS,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7H,OAAO,EAAa,SAAS,EAAE,UAAU,EAAE,UAAU,EAA2C,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACvI,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,WA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Memo } from 'react';\r\nimport { ViewProps, StatusBar, StyleSheet, ScrollView, NativeSyntheticEvent, NativeScrollEvent, View, Dimensions } from 'react-native';\r\nimport { SafeAreaView } from 'react-native-safe-area-context';\r\nimport { useTheme } from '../../context/ThemeContext';\r\nimport useKeyboard from '../../model/useKeyboard';\r\nimport useFoldingState from '../../model/useFoldingState';\r\nimport { FoldingState } from '../../model/types';\r\nimport { MAX_FOLDABLE_SINGLE_WIDTH } from '../../model/utils';\r\n\r\nconst windowHeight = Dimensions.get('window').height;\r\nconst KEYBOARD_ANIMATION_DELAY = 50;\r\nconst SCROLL_VIEW_OPTIONS = {\r\n bounces: false,\r\n overScrollMode: \"never\" as const,\r\n keyboardShouldPersistTaps: \"handled\" as const,\r\n automaticallyAdjustKeyboardInsets: false\r\n}\r\n\r\nexport type ZSContainerProps = ViewProps & {\r\n backgroundColor?: string;\r\n statusBarColor?: string;\r\n barStyle?: 'light-content' | 'dark-content';\r\n edges?: Array<'top' | 'right' | 'bottom' | 'left'>;\r\n scrollViewDisabled?: boolean;\r\n topComponent?: ReactNode;\r\n bottomComponent?: ReactNode;\r\n rightComponent?: ReactNode;\r\n showsVerticalScrollIndicator?: boolean;\r\n keyboardScrollExtraOffset?: number;\r\n translucent?: boolean;\r\n onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;\r\n scrollEventThrottle?: number;\r\n scrollToFocusedInput?: boolean;\r\n foldableSingleScreen?: boolean;\r\n dividerLineComponent?: ReactNode;\r\n};\r\n\r\nexport type ZSContainerRef = ScrollView;\r\n\r\nconst ZSContainer = forwardRef<ZSContainerRef, ZSContainerProps>(function ZSContainer(\r\n {\r\n backgroundColor,\r\n statusBarColor,\r\n barStyle,\r\n edges = ['bottom'],\r\n scrollViewDisabled = false,\r\n topComponent,\r\n bottomComponent,\r\n showsVerticalScrollIndicator = true,\r\n keyboardScrollExtraOffset = 30,\r\n translucent,\r\n scrollEventThrottle = 16,\r\n scrollToFocusedInput = true,\r\n // foldable device\r\n foldableSingleScreen,\r\n dividerLineComponent,\r\n rightComponent,\r\n // ---\r\n ...props\r\n },\r\n forwardedRef\r\n) {\r\n const { palette } = useTheme();\r\n const { foldingState, width } = useFoldingState();\r\n const positionRef = useRef<number | null>(0);\r\n const position2Ref = useRef<number | null>(0);\r\n const scrollViewRef = useRef<ScrollView>(null);\r\n const scrollView2Ref = useRef<ScrollView>(null);\r\n const touchPositionRef = useRef<number | null>(0);\r\n const lastTouchY = useRef<number | null>(0);\r\n const [keyboardHeight, setKeyboardHeight] = useState<number | null>(0);\r\n const scrollTimeoutRef = useRef<number | null>(null);\r\n\r\n useImperativeHandle(forwardedRef, () => scrollViewRef.current as ScrollView, [scrollViewDisabled]);\r\n\r\n const handleKeyboardShow = useCallback((e: any) => {\n setKeyboardHeight(e.endCoordinates.height);\n\n if ((scrollViewRef.current || scrollView2Ref.current) && scrollToFocusedInput) {\n const keyboardHeight = e.endCoordinates.height;\n const safeAreaBottom = 0;\n const availableScreenHeight = windowHeight - keyboardHeight - safeAreaBottom;\n\n // 현재 스크롤 위치 참조\n const currentScrollPosition = touchPositionRef.current === 1\n ? positionRef.current || 0\n : position2Ref.current || 0;\n\n const touchPosition = lastTouchY.current || 0;\n\n // 현재 터치 위치와 스크롤 위치를 기반으로 새로운 스크롤 위치 계산\n const scrollOffset = touchPosition - availableScreenHeight + keyboardScrollExtraOffset;\n\n if (scrollTimeoutRef.current) clearTimeout(scrollTimeoutRef.current);\n scrollTimeoutRef.current = setTimeout(() => {\n if (touchPositionRef.current === 1) {\n scrollViewRef.current?.scrollTo({\n y: currentScrollPosition + scrollOffset,\n animated: true,\n });\n } else {\n scrollView2Ref.current?.scrollTo({\n y: currentScrollPosition + scrollOffset,\n animated: true,\n });\n }\n scrollTimeoutRef.current = null;\n }, KEYBOARD_ANIMATION_DELAY);\n }\n }, [scrollToFocusedInput, keyboardScrollExtraOffset]);\n\n const handleKeyboardHide = useCallback(() => {\n setKeyboardHeight(0);\n }, []);\n\r\n useKeyboard({\r\n handleKeyboardShow,\r\n handleKeyboardHide,\r\n });\r\n\r\n // 클린업\r\n useEffect(() => {\r\n return () => {\r\n positionRef.current = null;\r\n lastTouchY.current = null;\r\n if (scrollTimeoutRef.current) {\r\n clearTimeout(scrollTimeoutRef.current);\r\n scrollTimeoutRef.current = null;\r\n }\r\n };\r\n }, []);\r\n \r\n // 에러 로그 출력\r\n useEffect(() => {\r\n if (foldableSingleScreen && (rightComponent || dividerLineComponent)) {\r\n console.error('[ZSContainer] foldableSingleScreen일 때는 rightComponent/dividerLineComponent를 사용할 수 없습니다.');\r\n }\r\n }, [foldableSingleScreen, rightComponent, dividerLineComponent]);\r\n\r\n const handleScroll = useCallback((event: NativeSyntheticEvent<NativeScrollEvent>, position: 1 | 2) => {\r\n if (props.onScroll) props.onScroll(event);\r\n\r\n if (position === 1) {\r\n positionRef.current = event.nativeEvent.contentOffset.y;\r\n } else {\r\n position2Ref.current = event.nativeEvent.contentOffset.y;\r\n }\r\n }, [props.onScroll]);\r\n\r\n const handleTouch = useCallback((evt: any, position: 1 | 2) => {\r\n lastTouchY.current = evt.nativeEvent.pageY;\r\n touchPositionRef.current = position;\r\n }, []);\r\n\r\n const safeAreaStyle = useMemo(() => [\r\n { backgroundColor: backgroundColor || palette.background.base },\r\n styles.w100\r\n ], [backgroundColor, palette.background.base]);\r\n\r\n const scrollContentStyle = useMemo(() => [\r\n styles.scrollContainerStyle,\r\n {\r\n paddingBottom: keyboardHeight ? keyboardHeight : 0\r\n }\r\n ], [keyboardHeight]);\r\n\r\n const containerStyle = useMemo(() => [\r\n styles.w100,\r\n props.style\r\n ], [props.style]);\r\n\r\n const shouldShowStatusBar = useMemo(() =>\r\n Boolean(barStyle || statusBarColor || translucent),\r\n [barStyle, statusBarColor, translucent]\r\n );\r\n\r\n return (\r\n <SafeAreaView\r\n style={safeAreaStyle}\r\n edges={edges}\r\n >\r\n <View style={[styles.w100, { backgroundColor: \"#00000009\" }]}>\r\n <View style={[styles.w100, { maxWidth: foldableSingleScreen ? Math.min(width, MAX_FOLDABLE_SINGLE_WIDTH) : '100%', alignSelf: 'center', backgroundColor: palette.background.base }]}>\r\n {topComponent}\r\n <View style={[styles.w100, { flexDirection: 'row' }]}>\r\n <View style={styles.flex1}>\r\n {scrollViewDisabled ? (\r\n <View style={[styles.flex1, containerStyle]}>\r\n {props.children}\r\n </View>\r\n ) : (\r\n <ScrollView\r\n ref={scrollViewRef}\r\n style={styles.w100}\r\n showsVerticalScrollIndicator={showsVerticalScrollIndicator}\r\n contentContainerStyle={scrollContentStyle}\r\n scrollEventThrottle={scrollEventThrottle}\r\n onScroll={(event) => { handleScroll(event, 1); }}\r\n onTouchStart={(evt) => handleTouch(evt, 1)}\r\n // ---\r\n {...SCROLL_VIEW_OPTIONS}\r\n >\r\n <View style={[styles.flex1, containerStyle]}>\r\n {props.children}\r\n </View>\r\n </ScrollView>\r\n )}\r\n </View>\r\n {foldingState === FoldingState.UNFOLDED && !foldableSingleScreen && rightComponent && dividerLineComponent && dividerLineComponent}\r\n {\r\n foldingState === FoldingState.UNFOLDED && !foldableSingleScreen && rightComponent && (\r\n <View style={styles.flex1}>\r\n {scrollViewDisabled ? (\r\n <View style={[styles.flex1, containerStyle]}>\r\n {rightComponent}\r\n </View>\r\n ) : (\r\n <ScrollView\r\n ref={scrollView2Ref}\r\n style={styles.w100}\r\n showsVerticalScrollIndicator={showsVerticalScrollIndicator}\r\n contentContainerStyle={scrollContentStyle}\r\n scrollEventThrottle={scrollEventThrottle}\r\n onScroll={(event) => { handleScroll(event, 2); }}\r\n onTouchStart={(evt) => handleTouch(evt, 2)}\r\n // ---\r\n {...SCROLL_VIEW_OPTIONS}\r\n >\r\n <View style={[styles.flex1, containerStyle]}>\r\n {rightComponent}\r\n </View>\r\n </ScrollView>\r\n )}\r\n </View>\r\n )\r\n }\r\n </View>\r\n {bottomComponent}\r\n </View>\r\n </View>\r\n\r\n {shouldShowStatusBar && (\r\n <StatusBar\r\n barStyle={barStyle}\r\n backgroundColor={statusBarColor || palette.background.base}\r\n translucent={translucent}\r\n />\r\n )}\r\n </SafeAreaView>\r\n );\r\n});\r\n\r\nexport const styles = StyleSheet.create({\r\n flex1: { flex: 1 },\r\n w100: { flex: 1, width: '100%' },\r\n scrollContainerStyle: { alignItems: 'center', width: '100%', flexGrow: 1 },\r\n});\r\n\r\nexport default ZSContainer;\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { TextInput, TextInputProps } from 'react-native';
|
|
3
3
|
import { TypoOptions } from '../../theme/types';
|
|
4
4
|
export type BoxStyle = 'outline' | 'underline' | 'inbox';
|
|
@@ -28,6 +28,6 @@ interface TextFieldProps {
|
|
|
28
28
|
isTextArea?: boolean;
|
|
29
29
|
}
|
|
30
30
|
export type ZSTextFieldRef = TextInput;
|
|
31
|
-
declare const ZSTextField:
|
|
31
|
+
declare const ZSTextField: import("react").ForwardRefExoticComponent<TextFieldProps & import("react").RefAttributes<TextInput>>;
|
|
32
32
|
export default ZSTextField;
|
|
33
33
|
//# 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,EAA0C,SAAS,EAAE,cAAc,EAAa,MAAM,cAAc,CAAC;AAI5G,OAAO,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAC;AAKzE,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;AAMzD,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,MAAM,MAAM,cAAc,GAAG,SAAS,CAAC;AAEvC,QAAA,MAAM,WAAW,sGA2Pf,CAAC;AAIH,eAAe,WAAW,CAAC"}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo, useCallback, useState, forwardRef, 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, withDelay, ReduceMotion } 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';
|
|
7
7
|
import { useTheme } from '../../context/ThemeContext';
|
|
8
8
|
import ViewAtom from '../atoms/ViewAtom';
|
|
9
9
|
const iosOffset = Platform.OS === 'ios' ? 8 : 4;
|
|
10
|
+
const ANIM_DURATION = 150;
|
|
11
|
+
const KEYBOARD_SETTLE_DELAY = Platform.OS === 'ios' ? 50 : 0;
|
|
10
12
|
const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, onChangeText, label = 'Placeholder', labelColor, placeHolderColor, inputBgColor, labelBgColor, borderWidth = 1.2, borderColor, focusColor, errorColor, borderRadius = 14, paddingHorizontal = 15, errorMessage, textInputProps, boxStyle = 'outline', innerBoxStyle, disabled = false, allowFontScaling = true, isTextArea = false, }, ref) => {
|
|
11
13
|
const { typography, palette } = useTheme();
|
|
12
14
|
const [primaryStyle, subStyle] = typo.split('.');
|
|
13
15
|
const fErrorColor = errorColor || palette.danger.main;
|
|
14
16
|
const fontSize = extractStyle(typography[primaryStyle][subStyle], 'fontSize') || 17;
|
|
15
17
|
const fontFamily = extractStyle(typography[primaryStyle][subStyle], 'fontFamily') || '';
|
|
16
|
-
const
|
|
18
|
+
const labelProgress = useSharedValue(value !== '' ? 1 : 0);
|
|
19
|
+
const focusProgress = useSharedValue(0);
|
|
20
|
+
const errorProgress = useSharedValue(0);
|
|
21
|
+
const [isFocusedForUI, setIsFocusedForUI] = useState(false);
|
|
17
22
|
const boxHeightValue = useSharedValue(0);
|
|
18
|
-
const hasValue = value !== '';
|
|
19
23
|
const isError = status === 'error';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return withTiming(isFocused ? 1 : 0, { duration: 200 });
|
|
26
|
-
}, [isFocused]);
|
|
27
|
-
const errorAnimationValue = useDerivedValue(() => {
|
|
28
|
-
return withTiming(isError ? 1 : 0, { duration: 200 });
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
labelProgress.value = withTiming(value !== '' ? 1 : 0, { duration: ANIM_DURATION, reduceMotion: ReduceMotion.System });
|
|
26
|
+
}, [value]);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
errorProgress.value = withTiming(isError ? 1 : 0, { duration: ANIM_DURATION, reduceMotion: ReduceMotion.System });
|
|
29
29
|
}, [isError]);
|
|
30
30
|
const animationConstants = useMemo(() => ({
|
|
31
31
|
baseFontSize: fontSize + (boxStyle === 'inbox' ? 1 : 0),
|
|
@@ -35,8 +35,9 @@ const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, on
|
|
|
35
35
|
}), [fontSize, boxStyle, isTextArea]);
|
|
36
36
|
const animatedLabelStyle = useAnimatedStyle(() => {
|
|
37
37
|
'worklet';
|
|
38
|
-
const
|
|
39
|
-
const
|
|
38
|
+
const progress = Math.max(labelProgress.value, focusProgress.value);
|
|
39
|
+
const labelFontSize = interpolate(progress, [0, 1], [animationConstants.baseFontSize, animationConstants.targetFontSize], 'clamp');
|
|
40
|
+
const labelTop = interpolate(progress, [0, 1], [
|
|
40
41
|
animationConstants.baseTop,
|
|
41
42
|
isTextArea ? -12 : -(boxHeightValue.value / 2) - 1 + animationConstants.targetTopOffset,
|
|
42
43
|
], 'clamp');
|
|
@@ -49,8 +50,15 @@ const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, on
|
|
|
49
50
|
const { height } = event.nativeEvent.layout;
|
|
50
51
|
boxHeightValue.value = height;
|
|
51
52
|
}, []);
|
|
52
|
-
const handleFocus = () =>
|
|
53
|
-
|
|
53
|
+
const handleFocus = useCallback(() => {
|
|
54
|
+
const timing = withTiming(1, { duration: ANIM_DURATION, reduceMotion: ReduceMotion.System });
|
|
55
|
+
focusProgress.value = KEYBOARD_SETTLE_DELAY > 0 ? withDelay(KEYBOARD_SETTLE_DELAY, timing) : timing;
|
|
56
|
+
setIsFocusedForUI(true);
|
|
57
|
+
}, []);
|
|
58
|
+
const handleBlur = useCallback(() => {
|
|
59
|
+
focusProgress.value = withTiming(0, { duration: ANIM_DURATION, reduceMotion: ReduceMotion.System });
|
|
60
|
+
setIsFocusedForUI(false);
|
|
61
|
+
}, []);
|
|
54
62
|
const colorConfig = useMemo(() => ({
|
|
55
63
|
primaryColor: focusColor || palette.primary.main,
|
|
56
64
|
defaultBorderColor: borderColor || palette.grey[30],
|
|
@@ -60,9 +68,9 @@ const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, on
|
|
|
60
68
|
}), [focusColor, palette.primary.main, borderColor, palette.grey, labelColor, palette.text.secondary, placeHolderColor, fErrorColor]);
|
|
61
69
|
const animatedColorStyle = useAnimatedStyle(() => {
|
|
62
70
|
'worklet';
|
|
63
|
-
const borderColor =
|
|
71
|
+
const borderColor = errorProgress.value > 0
|
|
64
72
|
? colorConfig.errorColor
|
|
65
|
-
:
|
|
73
|
+
: focusProgress.value > 0
|
|
66
74
|
? colorConfig.primaryColor
|
|
67
75
|
: colorConfig.defaultBorderColor;
|
|
68
76
|
return {
|
|
@@ -71,11 +79,12 @@ const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, on
|
|
|
71
79
|
}, [colorConfig]);
|
|
72
80
|
const animatedLabelColorStyle = useAnimatedStyle(() => {
|
|
73
81
|
'worklet';
|
|
74
|
-
const
|
|
82
|
+
const floatProgress = Math.max(labelProgress.value, focusProgress.value);
|
|
83
|
+
const labelColor = errorProgress.value > 0
|
|
75
84
|
? colorConfig.errorColor
|
|
76
|
-
:
|
|
85
|
+
: focusProgress.value > 0
|
|
77
86
|
? colorConfig.primaryColor
|
|
78
|
-
:
|
|
87
|
+
: floatProgress > 0
|
|
79
88
|
? colorConfig.defaultLabelColor
|
|
80
89
|
: colorConfig.placeholderColor;
|
|
81
90
|
return {
|
|
@@ -152,7 +161,7 @@ const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, on
|
|
|
152
161
|
},
|
|
153
162
|
textInputProps?.style,
|
|
154
163
|
];
|
|
155
|
-
const shouldShowCloseButton = value &&
|
|
164
|
+
const shouldShowCloseButton = value && isFocusedForUI;
|
|
156
165
|
const shouldShowError = status === 'error' && errorMessage;
|
|
157
166
|
return (<ViewAtom style={{ alignSelf: 'stretch', width: '100%' }}>
|
|
158
167
|
<Animated.View style={[styleConfig, animatedColorStyle]} onLayout={handleLayout} pointerEvents={disabled ? 'none' : 'auto'}>
|
|
@@ -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,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAqB,QAAQ,EAAa,SAAS,EAA6B,MAAM,cAAc,CAAC;AAC5G,OAAO,QAAQ,EAAE,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/H,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAIzC,MAAM,SAAS,GAAG,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AA8BhD,MAAM,WAAW,GAAG,UAAU,CAAiC,CAAC,EAC9D,IAAI,GAAG,QAAQ,EACf,MAAM,GAAG,SAAS,EAClB,KAAK,EACL,YAAY,EACZ,KAAK,GAAG,aAAa,EACrB,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,WAAW,GAAG,GAAG,EACjB,WAAW,EACX,UAAU,EACV,UAAU,EACV,YAAY,GAAG,EAAE,EACjB,iBAAiB,GAAG,EAAE,EACtB,YAAY,EACZ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, useCallback, useState, forwardRef } from 'react';\nimport { LayoutChangeEvent, Platform, StyleProp, TextInput, TextInputProps, TextStyle } from 'react-native';\nimport Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming, useDerivedValue } 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;\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\n const [isFocused, setIsFocused] = useState<boolean>(false);\n const boxHeightValue = useSharedValue(0);\n \n const hasValue = value !== '';\n const isError = status === 'error';\n \n // useDerivedValue: 애니메이션을 UI 스레드에서 직접 처리하여 JS Thread 블로킹 방지\n const labelAnimationValue = useDerivedValue(() => {\n return withTiming(hasValue || isFocused ? 1 : 0, { duration: 200 });\n }, [hasValue, isFocused]);\n\n const focusAnimationValue = useDerivedValue(() => {\n return withTiming(isFocused ? 1 : 0, { duration: 200 });\n }, [isFocused]);\n\n const errorAnimationValue = useDerivedValue(() => {\n return withTiming(isError ? 1 : 0, { duration: 200 });\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 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 }, []);\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 ...(Platform.OS === 'web' ? { outline: 'none' } : {}),\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 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={[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\nZSTextField.displayName = 'ZS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C,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,CAAC,CAAC;AAEH,WAAW,CAAC,WAAW,GAAG,aAAa,CAAC;AAExC,eAAe,WAAW,CAAC","sourcesContent":["import { useMemo, useCallback, useState, forwardRef, useEffect } from 'react';\nimport { LayoutChangeEvent, Platform, StyleProp, TextInput, TextInputProps, TextStyle } from 'react-native';\nimport Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming, withDelay, 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 KEYBOARD_SETTLE_DELAY = Platform.OS === 'ios' ? 50 : 0;\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\n const labelProgress = useSharedValue(value !== '' ? 1 : 0);\n const focusProgress = useSharedValue(0);\n const errorProgress = useSharedValue(0);\n const [isFocusedForUI, setIsFocusedForUI] = useState<boolean>(false);\n const boxHeightValue = useSharedValue(0);\n \n const isError = status === 'error';\n\n useEffect(() => {\n labelProgress.value = withTiming(value !== '' ? 1 : 0, { duration: ANIM_DURATION, reduceMotion: ReduceMotion.System });\n }, [value]);\n\n useEffect(() => {\n errorProgress.value = withTiming(isError ? 1 : 0, { duration: ANIM_DURATION, reduceMotion: ReduceMotion.System });\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 animatedLabelStyle = useAnimatedStyle(() => {\n 'worklet';\n \n const progress = Math.max(labelProgress.value, focusProgress.value);\n \n const labelFontSize = interpolate(\n progress,\n [0, 1],\n [animationConstants.baseFontSize, animationConstants.targetFontSize],\n 'clamp'\n );\n\n const labelTop = interpolate(\n progress,\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 }, []);\n\n const handleFocus = useCallback(() => {\n const timing = withTiming(1, { duration: ANIM_DURATION, reduceMotion: ReduceMotion.System });\n focusProgress.value = KEYBOARD_SETTLE_DELAY > 0 ? withDelay(KEYBOARD_SETTLE_DELAY, timing) : timing;\n setIsFocusedForUI(true);\n }, []);\n\n const handleBlur = useCallback(() => {\n focusProgress.value = withTiming(0, { duration: ANIM_DURATION, reduceMotion: ReduceMotion.System });\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 animatedColorStyle = useAnimatedStyle(() => {\n 'worklet';\n \n const borderColor = errorProgress.value > 0 \n ? colorConfig.errorColor\n : focusProgress.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 floatProgress = Math.max(labelProgress.value, focusProgress.value);\n \n const labelColor = errorProgress.value > 0\n ? colorConfig.errorColor\n : focusProgress.value > 0\n ? colorConfig.primaryColor\n : floatProgress > 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 ...(Platform.OS === 'web' ? { outline: 'none' } : {}),\n },\n textInputProps?.style,\n ];\n\n const shouldShowCloseButton = value && isFocusedForUI;\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 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={[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\nZSTextField.displayName = 'ZSTextField';\n\nexport default ZSTextField;\n"]}
|