@0610studio/zs-ui 0.18.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/ZsUiModule.d.ts.map +1 -1
- package/build/ZsUiModule.js +0 -2
- package/build/ZsUiModule.js.map +1 -1
- package/build/assets/SvgExclamation.d.ts.map +1 -1
- package/build/assets/SvgExclamation.js.map +1 -1
- package/build/context/OverlayContext.d.ts.map +1 -1
- package/build/context/OverlayContext.js +11 -14
- package/build/context/OverlayContext.js.map +1 -1
- package/build/context/ThemeContext.d.ts +9 -0
- package/build/context/ThemeContext.d.ts.map +1 -1
- package/build/context/ThemeContext.js +8 -11
- package/build/context/ThemeContext.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -7
- package/build/index.js.map +1 -1
- package/build/model/globalOverlay.d.ts +0 -8
- package/build/model/globalOverlay.d.ts.map +1 -1
- package/build/model/globalOverlay.js +0 -9
- package/build/model/globalOverlay.js.map +1 -1
- package/build/model/types.d.ts +1 -1
- package/build/model/types.d.ts.map +1 -1
- package/build/model/types.js.map +1 -1
- package/build/model/useKeyboard.d.ts.map +1 -1
- package/build/model/useKeyboard.js +8 -4
- package/build/model/useKeyboard.js.map +1 -1
- package/build/model/utils.d.ts +1 -1
- package/build/model/utils.d.ts.map +1 -1
- package/build/model/utils.js +2 -1
- package/build/model/utils.js.map +1 -1
- package/build/overlay/AlertOverlay/index.d.ts.map +1 -1
- package/build/overlay/AlertOverlay/index.js +2 -2
- package/build/overlay/AlertOverlay/index.js.map +1 -1
- package/build/overlay/BottomSheetOverlay/index.d.ts.map +1 -1
- package/build/overlay/BottomSheetOverlay/index.js +18 -8
- package/build/overlay/BottomSheetOverlay/index.js.map +1 -1
- package/build/overlay/Modality/index.d.ts.map +1 -1
- package/build/overlay/Modality/index.js +3 -9
- package/build/overlay/Modality/index.js.map +1 -1
- package/build/overlay/PopOver/PopOverMenu.d.ts.map +1 -1
- package/build/overlay/PopOver/PopOverMenu.js +3 -6
- package/build/overlay/PopOver/PopOverMenu.js.map +1 -1
- package/build/overlay/SnackbarNotify/index.d.ts +3 -3
- package/build/overlay/SnackbarNotify/index.d.ts.map +1 -1
- package/build/overlay/SnackbarNotify/index.js +5 -4
- package/build/overlay/SnackbarNotify/index.js.map +1 -1
- package/build/overlay/SnackbarNotify/ui/SnackbarItem.d.ts +3 -3
- package/build/overlay/SnackbarNotify/ui/SnackbarItem.d.ts.map +1 -1
- package/build/overlay/SnackbarNotify/ui/SnackbarItem.js +5 -5
- package/build/overlay/SnackbarNotify/ui/SnackbarItem.js.map +1 -1
- package/build/overlay/ZSPortal/index.d.ts.map +1 -1
- package/build/overlay/ZSPortal/index.js +15 -4
- package/build/overlay/ZSPortal/index.js.map +1 -1
- package/build/overlay/ui/ModalBackground.js.map +1 -1
- package/build/theme/elevation.d.ts +94 -10
- package/build/theme/elevation.d.ts.map +1 -1
- package/build/theme/elevation.js +39 -35
- package/build/theme/elevation.js.map +1 -1
- package/build/theme/palette.d.ts +1 -5
- package/build/theme/palette.d.ts.map +1 -1
- package/build/theme/palette.js +3 -12
- package/build/theme/palette.js.map +1 -1
- package/build/theme/resolveColor.d.ts +4 -0
- package/build/theme/resolveColor.d.ts.map +1 -0
- package/build/theme/resolveColor.js +29 -0
- package/build/theme/resolveColor.js.map +1 -0
- package/build/ui/ZSBlockButton/index.d.ts +4 -2
- package/build/ui/ZSBlockButton/index.d.ts.map +1 -1
- package/build/ui/ZSBlockButton/index.js +31 -79
- package/build/ui/ZSBlockButton/index.js.map +1 -1
- package/build/ui/ZSContainer/index.d.ts +20 -0
- package/build/ui/ZSContainer/index.d.ts.map +1 -1
- package/build/ui/ZSContainer/index.js +28 -15
- package/build/ui/ZSContainer/index.js.map +1 -1
- package/build/ui/ZSPressable/index.d.ts.map +1 -1
- package/build/ui/ZSPressable/index.js +0 -2
- package/build/ui/ZSPressable/index.js.map +1 -1
- package/build/ui/ZSRadioGroup/index.d.ts +3 -2
- package/build/ui/ZSRadioGroup/index.d.ts.map +1 -1
- package/build/ui/ZSRadioGroup/index.js +64 -52
- package/build/ui/ZSRadioGroup/index.js.map +1 -1
- package/build/ui/ZSSkeleton/index.d.ts +2 -1
- package/build/ui/ZSSkeleton/index.d.ts.map +1 -1
- package/build/ui/ZSSkeleton/index.js +2 -2
- package/build/ui/ZSSkeleton/index.js.map +1 -1
- package/build/ui/ZSSkeletonBox/index.d.ts +2 -1
- package/build/ui/ZSSkeletonBox/index.d.ts.map +1 -1
- package/build/ui/ZSSkeletonBox/index.js +7 -5
- package/build/ui/ZSSkeletonBox/index.js.map +1 -1
- package/build/ui/ZSSwitch/index.d.ts +2 -1
- package/build/ui/ZSSwitch/index.d.ts.map +1 -1
- package/build/ui/ZSSwitch/index.js +2 -2
- package/build/ui/ZSSwitch/index.js.map +1 -1
- package/build/ui/ZSText/index.d.ts +3 -2
- package/build/ui/ZSText/index.d.ts.map +1 -1
- package/build/ui/ZSText/index.js +5 -16
- package/build/ui/ZSText/index.js.map +1 -1
- package/build/ui/ZSTextField/index.d.ts.map +1 -1
- package/build/ui/ZSTextField/index.js +41 -28
- package/build/ui/ZSTextField/index.js.map +1 -1
- package/build/ui/ZSView/index.d.ts +3 -2
- package/build/ui/ZSView/index.d.ts.map +1 -1
- package/build/ui/ZSView/index.js +7 -8
- package/build/ui/ZSView/index.js.map +1 -1
- package/build/ui/atoms/AnimatedWrapper.d.ts.map +1 -1
- package/build/ui/atoms/AnimatedWrapper.js +33 -40
- package/build/ui/atoms/AnimatedWrapper.js.map +1 -1
- package/build/ui/atoms/TextAtom.d.ts +1 -2
- package/build/ui/atoms/TextAtom.d.ts.map +1 -1
- package/build/ui/atoms/TextAtom.js.map +1 -1
- package/build/ui/atoms/ViewAtom.d.ts +1 -2
- package/build/ui/atoms/ViewAtom.d.ts.map +1 -1
- package/build/ui/atoms/ViewAtom.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
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AAK,EAAE,EAAE,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAChD,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,KAEtC,mBAAmB,YAEvB,KAAC,IAAI,IAAC,KAAK,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,cAAc,CAAC,YACxC,cAAc,GACV,GACI,CACd,GACI,CACR,IAEE,EACN,eAAe,IACX,GACF,EAEN,mBAAmB,IAAI,CACtB,KAAC,SAAS,IACR,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,cAAc,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,EAC1D,WAAW,EAAE,WAAW,GACxB,CACH,IACY,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 = 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
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSContainer/index.tsx"],"names":[],"mappings":";AAAA,OA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AAe,EAAE,WAAW,EAAE;IACpE,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE;CACtD,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC","sourcesContent":["import React, { ReactNode, useEffect, useImperativeHandle, forwardRef, useRef, useState, useCallback, useMemo } from 'react';\nimport { ViewProps, StatusBar, StyleSheet, ScrollView, NativeSyntheticEvent, NativeScrollEvent, View, useWindowDimensions } from 'react-native';\nimport { SafeAreaView } from 'react-native-safe-area-context';\nimport { useTheme } from '../../context/ThemeContext';\nimport useKeyboard from '../../model/useKeyboard';\nimport useFoldingState from '../../model/useFoldingState';\nimport { FoldingState } from '../../model/types';\n\nconst KEYBOARD_ANIMATION_DELAY = 50;\nconst SCROLL_VIEW_OPTIONS = {\n bounces: false,\n overScrollMode: \"never\" as const,\n keyboardShouldPersistTaps: \"handled\" as const,\n automaticallyAdjustKeyboardInsets: false\n}\n\nexport type ZSContainerProps = ViewProps & {\n backgroundColor?: string;\n statusBarColor?: string;\n barStyle?: 'light-content' | 'dark-content';\n edges?: Array<'top' | 'right' | 'bottom' | 'left'>;\n scrollViewDisabled?: boolean;\n topComponent?: ReactNode;\n bottomComponent?: ReactNode;\n rightComponent?: ReactNode;\n showsVerticalScrollIndicator?: boolean;\n keyboardScrollExtraOffset?: number;\n translucent?: boolean;\n onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;\n scrollEventThrottle?: number;\n scrollToFocusedInput?: boolean;\n foldableSingleScreen?: boolean;\n dividerLineComponent?: ReactNode;\n /**\n * 언폴딩 상태에서 rightComponent가 없을 때(단일 화면) 콘텐츠 최대 가로 길이(px).\n * 전폭으로 늘리려면 false. 미지정 시 ThemeProvider의 foldable 설정값을 따른다.\n */\n unfoldedSinglePaneMaxWidth?: number | false;\n};\n\nexport type ZSContainerRef = ScrollView;\n\nconst ZSContainer = forwardRef<ZSContainerRef, ZSContainerProps>(function ZSContainer(\n {\n backgroundColor,\n statusBarColor,\n barStyle,\n edges = ['bottom'],\n scrollViewDisabled = false,\n topComponent,\n bottomComponent,\n showsVerticalScrollIndicator = true,\n keyboardScrollExtraOffset = 30,\n translucent,\n scrollEventThrottle = 16,\n scrollToFocusedInput = true,\n foldableSingleScreen,\n dividerLineComponent,\n rightComponent,\n unfoldedSinglePaneMaxWidth,\n ...props\n },\n forwardedRef\n) {\n const { palette, foldable } = useTheme();\n const { height: windowHeight } = useWindowDimensions();\n const { foldingState, width } = useFoldingState();\n const positionRef = useRef<number | null>(0);\n const position2Ref = useRef<number | null>(0);\n const scrollViewRef = useRef<ScrollView>(null);\n const scrollView2Ref = useRef<ScrollView>(null);\n const touchPositionRef = useRef<number | null>(0);\n const lastTouchY = useRef<number | null>(0);\n const [keyboardHeight, setKeyboardHeight] = useState<number | null>(0);\n const scrollTimeoutRef = useRef<number | null>(null);\n\n useImperativeHandle(forwardedRef, () => scrollViewRef.current as ScrollView, [scrollViewDisabled]);\n\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 const currentScrollPosition = touchPositionRef.current === 1\n ? positionRef.current || 0\n : position2Ref.current || 0;\n\n const touchPosition = lastTouchY.current || 0;\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, windowHeight]);\n\n const handleKeyboardHide = useCallback(() => {\n setKeyboardHeight(0);\n }, []);\n\n useKeyboard({\n handleKeyboardShow,\n handleKeyboardHide,\n });\n\n useEffect(() => {\n return () => {\n positionRef.current = null;\n lastTouchY.current = null;\n if (scrollTimeoutRef.current) {\n clearTimeout(scrollTimeoutRef.current);\n scrollTimeoutRef.current = null;\n }\n };\n }, []);\n \n useEffect(() => {\n if (foldableSingleScreen && (rightComponent || dividerLineComponent)) {\n console.error('[ZSContainer] foldableSingleScreen일 때는 rightComponent/dividerLineComponent를 사용할 수 없습니다.');\n }\n }, [foldableSingleScreen, rightComponent, dividerLineComponent]);\n\n const handleScroll = useCallback((event: NativeSyntheticEvent<NativeScrollEvent>, position: 1 | 2) => {\n if (props.onScroll) props.onScroll(event);\n\n if (position === 1) {\n positionRef.current = event.nativeEvent.contentOffset.y;\n } else {\n position2Ref.current = event.nativeEvent.contentOffset.y;\n }\n }, [props.onScroll]);\n\n const handleTouch = useCallback((evt: any, position: 1 | 2) => {\n lastTouchY.current = evt.nativeEvent.pageY;\n touchPositionRef.current = position;\n }, []);\n\n const safeAreaStyle = useMemo(() => [\n { backgroundColor: backgroundColor || palette.background.base },\n styles.w100\n ], [backgroundColor, palette.background.base]);\n\n const scrollContentStyle = useMemo(() => [\n styles.scrollContainerStyle,\n {\n paddingBottom: keyboardHeight ? keyboardHeight : 0\n }\n ], [keyboardHeight]);\n\n const containerStyle = useMemo(() => [\n styles.w100,\n props.style\n ], [props.style]);\n\n // prop > ThemeProvider foldable 설정 순으로 적용. 기본값(폴백) 없음 — 미주입(undefined)이거나 false면 전폭으로 채움\n const effectiveUnfoldedMaxWidth = unfoldedSinglePaneMaxWidth ?? foldable?.unfoldedSinglePaneMaxWidth;\n const hasRightComponent = !!rightComponent;\n\n const innerMaxWidth = useMemo(() => {\n // foldableSingleScreen 이거나, 언폴딩 + rightComponent 미지원인 단일 화면일 때 폭 제한 대상\n const isSinglePane = foldableSingleScreen || (foldingState === FoldingState.UNFOLDED && !hasRightComponent);\n // 주입된 폭(number)이 있을 때만 제한, 없으면 전폭으로 채움\n if (isSinglePane && typeof effectiveUnfoldedMaxWidth === 'number') {\n return Math.min(width, effectiveUnfoldedMaxWidth);\n }\n return '100%' as const;\n }, [foldableSingleScreen, foldingState, hasRightComponent, effectiveUnfoldedMaxWidth, width]);\n\n const innerContainerStyle = useMemo(() => [\n styles.w100,\n {\n maxWidth: innerMaxWidth,\n alignSelf: 'center' as const,\n backgroundColor: palette.background.base,\n },\n ], [innerMaxWidth, palette.background.base]);\n\n const shouldShowStatusBar = useMemo(() =>\n Boolean(barStyle || statusBarColor || translucent),\n [barStyle, statusBarColor, translucent]\n );\n\n return (\n <SafeAreaView\n style={safeAreaStyle}\n edges={edges}\n >\n <View style={styles.outerLayer}>\n <View style={innerContainerStyle}>\n {topComponent}\n <View style={styles.row}>\n <View style={styles.flex1}>\n {scrollViewDisabled ? (\n <View style={[styles.flex1, containerStyle]}>\n {props.children}\n </View>\n ) : (\n <ScrollView\n ref={scrollViewRef}\n style={styles.w100}\n showsVerticalScrollIndicator={showsVerticalScrollIndicator}\n contentContainerStyle={scrollContentStyle}\n scrollEventThrottle={scrollEventThrottle}\n onScroll={(event) => { handleScroll(event, 1); }}\n onTouchStart={(evt) => handleTouch(evt, 1)}\n {...SCROLL_VIEW_OPTIONS}\n >\n <View style={[styles.flex1, containerStyle]}>\n {props.children}\n </View>\n </ScrollView>\n )}\n </View>\n {foldingState === FoldingState.UNFOLDED && !foldableSingleScreen && rightComponent && dividerLineComponent && dividerLineComponent}\n {\n foldingState === FoldingState.UNFOLDED && !foldableSingleScreen && rightComponent && (\n <View style={styles.flex1}>\n {scrollViewDisabled ? (\n <View style={[styles.flex1, containerStyle]}>\n {rightComponent}\n </View>\n ) : (\n <ScrollView\n ref={scrollView2Ref}\n style={styles.w100}\n showsVerticalScrollIndicator={showsVerticalScrollIndicator}\n contentContainerStyle={scrollContentStyle}\n scrollEventThrottle={scrollEventThrottle}\n onScroll={(event) => { handleScroll(event, 2); }}\n onTouchStart={(evt) => handleTouch(evt, 2)}\n {...SCROLL_VIEW_OPTIONS}\n >\n <View style={[styles.flex1, containerStyle]}>\n {rightComponent}\n </View>\n </ScrollView>\n )}\n </View>\n )\n }\n </View>\n {bottomComponent}\n </View>\n </View>\n\n {shouldShowStatusBar && (\n <StatusBar\n barStyle={barStyle}\n backgroundColor={statusBarColor || palette.background.base}\n translucent={translucent}\n />\n )}\n </SafeAreaView>\n );\n});\n\nexport const styles = StyleSheet.create({\n flex1: { flex: 1 },\n w100: { flex: 1, width: '100%' },\n scrollContainerStyle: { alignItems: 'center', width: '100%', flexGrow: 1 },\n outerLayer: { flex: 1, width: '100%', backgroundColor: '#00000009' },\n row: { flex: 1, width: '100%', flexDirection: 'row' },\n});\n\nexport default ZSContainer;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSPressable/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiB,MAAM,OAAO,CAAC;AACtC,OAAO,EAAmB,SAAS,EAAE,MAAM,cAAc,CAAC;AAG1D,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAMvE,UAAU,gBAAiB,SAAQ,SAAS;IAC1C,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAChC,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACpC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,SA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OUNCE_TIME = 300;
|
|
|
9
9
|
function ZSPressable({ onPress, onLongPress, isAnimation = true, pressedBackgroundColor = 'rgba(180, 180, 180, 0.1)', pressedBackgroundBorderRadius = 16, elevationLevel, fullWidth = false, color, isLoading = false, disabled = false, ...props }) {
|
|
10
10
|
const isButtonPress = useSharedValue(0);
|
|
11
11
|
const lastClickTime = useRef(0);
|
|
12
|
-
// ------------------------------------------------------------
|
|
13
12
|
const createPressHandler = (callback) => {
|
|
14
13
|
return () => {
|
|
15
14
|
const now = Date.now();
|
|
@@ -23,7 +22,6 @@ function ZSPressable({ onPress, onLongPress, isAnimation = true, pressedBackgrou
|
|
|
23
22
|
};
|
|
24
23
|
const handlePress = createPressHandler(onPress);
|
|
25
24
|
const handleLongPress = createPressHandler(onLongPress);
|
|
26
|
-
// ------------------------------------------------------------
|
|
27
25
|
const boxAnimation = useAnimatedStyle(() => {
|
|
28
26
|
const scale = interpolate(isButtonPress.value, [0, 1], SCALE_VALUES, 'clamp');
|
|
29
27
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSPressable/index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,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;AAGvD,MAAM,gBAAgB,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAW,CAAC;AACpD,MAAM,YAAY,GAAG,CAAC,CAAC,EAAE,IAAI,CAAU,CAAC;AACxC,MAAM,aAAa,GAAG,GAAG,CAAC;AAe1B,SAAS,WAAW,CAAC,EACnB,OAAO,EACP,WAAW,EACX,WAAW,GAAG,IAAI,E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,CAAC,CAAC,EAAE,KAAK,EAAE,MAAe,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,SAAS,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,YAChH,KAAC,SAAS,OACJ,KAAK,EACT,OAAO,EAAE,WAAW,EACpB,WAAW,EAAE,eAAe,EAC5B,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,cAAc,EAC1B,QAAQ,EAAE,SAAS,IAAI,QAAQ,EAC/B,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,YAEjD,KAAC,QAAQ,CAAC,IAAI,IAAC,KAAK,EAAE,YAAY,YAChC,KAAC,eAAe,IACd,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,KAAK,CAAC,KAAK,YAEjB,KAAK,CAAC,QAAQ,GACC,GACJ,GACN,GACP,CACR,CAAC;AACJ,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC","sourcesContent":["import React, { useRef } 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, ViewColorOptions } from \"../../theme/types\";\n\nconst DEFAULT_DURATION = { duration: 100 } as const;\nconst SCALE_VALUES = [1, 0.96] as const;\nconst DEBOUNCE_TIME = 300;\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 isLoading?: boolean;\n disabled?: boolean;\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 isLoading = false,\n disabled = false,\n ...props\n}: ZSPressableProps) {\n const isButtonPress = useSharedValue(0);\n const lastClickTime = useRef<number>(0);\n\n const createPressHandler = (callback?: () => void) => {\n return () => {\n const now = Date.now();\n if (now - lastClickTime.current < DEBOUNCE_TIME) return;\n if (isLoading || disabled) return;\n lastClickTime.current = now;\n\n callback?.();\n };\n };\n\n const handlePress = createPressHandler(onPress);\n const handleLongPress = createPressHandler(onLongPress);\n\n const boxAnimation = useAnimatedStyle(() => {\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 return (\n <View style={[fullWidth ? { width: '100%' as const } : undefined, { opacity: (isLoading || disabled) ? 0.55 : 1 }]}>\n <Pressable\n {...props}\n onPress={handlePress}\n onLongPress={handleLongPress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n disabled={isLoading || disabled}\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\nexport default React.memo(ZSPressable);\n"]}
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { ViewProps } from 'react-native';
|
|
3
3
|
import { RadioOption } from '../types';
|
|
4
4
|
import { ZSTextProps } from '../ZSText';
|
|
5
|
-
|
|
5
|
+
interface ZSRadioGroupProps extends ViewProps {
|
|
6
6
|
options: RadioOption[];
|
|
7
7
|
value?: RadioOption;
|
|
8
8
|
onSelect: (value: RadioOption) => void;
|
|
@@ -12,7 +12,8 @@ declare function ZSRadioGroup({ options, value, onSelect, containerStyle, valueS
|
|
|
12
12
|
selectLabel?: string;
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
rowCount?: 1 | 2 | 3;
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
|
+
declare function ZSRadioGroup({ options, value, onSelect, containerStyle, valueStyle, disabled, selectStyle, selectLabel, rowCount, ...props }: ZSRadioGroupProps): React.JSX.Element;
|
|
16
17
|
declare const _default: React.MemoExoticComponent<typeof ZSRadioGroup>;
|
|
17
18
|
export default _default;
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSRadioGroup/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSRadioGroup/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,EAAc,SAAS,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAe,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAsFhD,UAAU,iBAAkB,SAAQ,SAAS;IAC3C,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CACtB;AAED,iBAAS,YAAY,CAAC,EACpB,OAAO,EACP,KAAK,EACL,QAAQ,EACR,cAAc,EACd,UAAU,EACV,QAAgB,EAChB,WAAW,EACX,WAAkB,EAClB,QAAY,EACZ,GAAG,KAAK,EACT,EAAE,iBAAiB,qBAyCnB;;AA8CD,wBAAkC"}
|
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, memo } from 'react';
|
|
3
|
+
import { StyleSheet } from 'react-native';
|
|
3
4
|
import ViewAtom from '../atoms/ViewAtom';
|
|
4
5
|
import ZSText from '../ZSText';
|
|
5
6
|
import ZSPressable from '../ZSPressable';
|
|
6
7
|
import { useTheme } from '../../context/ThemeContext';
|
|
7
8
|
import { SvgCheck } from '../../assets/SvgCheck';
|
|
9
|
+
const ROW_WIDTH = {
|
|
10
|
+
1: '100%',
|
|
11
|
+
2: '50%',
|
|
12
|
+
3: '33.33%',
|
|
13
|
+
};
|
|
14
|
+
const RadioRow = memo(function RadioRow({ option, index, optionCount, rowCount, isSelected, isFullWidth, setColor, innerColor, selectColor, valueStyle, selectStyle, selectLabel, onSelect, }) {
|
|
15
|
+
const isLastCol = (index + 1) % rowCount === 0;
|
|
16
|
+
const isLastRow = Math.ceil((index + 1) / rowCount) === Math.ceil(optionCount / rowCount);
|
|
17
|
+
return (_jsx(ViewAtom, { style: [
|
|
18
|
+
styles.cell,
|
|
19
|
+
{
|
|
20
|
+
width: ROW_WIDTH[rowCount],
|
|
21
|
+
paddingRight: isFullWidth ? 0 : isLastCol ? 0 : 3,
|
|
22
|
+
paddingLeft: isFullWidth ? 0 : isLastCol ? 3 : 0,
|
|
23
|
+
paddingBottom: isLastRow ? 0 : 10,
|
|
24
|
+
},
|
|
25
|
+
], children: _jsx(ZSPressable, { onPress: () => onSelect(option), pressedBackgroundColor: "transparent", fullWidth: true, children: _jsxs(ViewAtom, { style: [styles.row, { borderColor: setColor, backgroundColor: innerColor }], children: [!isFullWidth && (_jsx(ViewAtom, { style: [styles.radioOuter, { borderColor: setColor }], children: _jsx(ViewAtom, { style: [styles.radioInner, { backgroundColor: setColor }] }) })), _jsx(ViewAtom, { style: styles.label, children: _jsx(ZSText, { ...valueStyle, children: option.value }) }), isFullWidth && (_jsx(ViewAtom, { style: [styles.selectButton, { backgroundColor: selectColor }], children: isSelected ? (_jsx(SvgCheck, { size: 18 })) : (_jsx(ZSText, { typo: "body.5", numberOfLines: 1, ...selectStyle, children: selectLabel })) }))] }) }) }));
|
|
26
|
+
});
|
|
8
27
|
function ZSRadioGroup({ options, value, onSelect, containerStyle, valueStyle, disabled = false, selectStyle, selectLabel = '선택', rowCount = 1, ...props }) {
|
|
9
28
|
const { palette } = useTheme();
|
|
10
29
|
const isFullWidth = rowCount === 1;
|
|
@@ -13,61 +32,54 @@ function ZSRadioGroup({ options, value, onSelect, containerStyle, valueStyle, di
|
|
|
13
32
|
onSelect(option);
|
|
14
33
|
}
|
|
15
34
|
}, [disabled, onSelect]);
|
|
16
|
-
return (_jsx(ViewAtom, { style: {
|
|
17
|
-
flexDirection: isFullWidth ? 'column' : 'row',
|
|
18
|
-
flexWrap: isFullWidth ? 'nowrap' : 'wrap',
|
|
19
|
-
width: '100%',
|
|
20
|
-
}, ...containerStyle, ...props, children: options.map((option, index) => {
|
|
35
|
+
return (_jsx(ViewAtom, { style: [styles.container, { flexDirection: isFullWidth ? 'column' : 'row', flexWrap: isFullWidth ? 'nowrap' : 'wrap' }], ...containerStyle, ...props, children: options.map((option, index) => {
|
|
21
36
|
const isSelected = value?.index === option.index;
|
|
22
37
|
const setColor = isSelected ? palette.primary.light : palette.background.neutral;
|
|
23
|
-
|
|
24
|
-
const isLastCol = (index + 1) % colCount === 0;
|
|
25
|
-
const isLastRow = Math.ceil((index + 1) / colCount) === Math.ceil(options.length / colCount);
|
|
26
|
-
return (_jsx(ViewAtom, { style: {
|
|
27
|
-
width: rowCount === 2
|
|
28
|
-
? '50%'
|
|
29
|
-
: rowCount === 3
|
|
30
|
-
? '33.33%'
|
|
31
|
-
: '100%',
|
|
32
|
-
paddingRight: isFullWidth ? 0 : isLastCol ? 0 : 3,
|
|
33
|
-
paddingLeft: isFullWidth ? 0 : isLastCol ? 3 : 0,
|
|
34
|
-
paddingBottom: isLastRow ? 0 : 10,
|
|
35
|
-
}, children: _jsx(ZSPressable, { onPress: () => handleSelect(option), pressedBackgroundColor: "transparent", fullWidth: true, children: _jsxs(ViewAtom, { style: {
|
|
36
|
-
flexDirection: 'row',
|
|
37
|
-
alignItems: 'center',
|
|
38
|
-
paddingVertical: 12,
|
|
39
|
-
borderWidth: 1,
|
|
40
|
-
paddingLeft: 10,
|
|
41
|
-
paddingRight: 15,
|
|
42
|
-
borderRadius: 100,
|
|
43
|
-
borderColor: setColor,
|
|
44
|
-
backgroundColor: isSelected ? palette.background.layer1 : 'transparent',
|
|
45
|
-
}, children: [!(isFullWidth) && (_jsx(ViewAtom, { style: {
|
|
46
|
-
width: 20,
|
|
47
|
-
height: 20,
|
|
48
|
-
borderWidth: 1,
|
|
49
|
-
borderRadius: 10,
|
|
50
|
-
borderColor: setColor,
|
|
51
|
-
justifyContent: 'center',
|
|
52
|
-
alignItems: 'center',
|
|
53
|
-
}, children: _jsx(ViewAtom, { style: {
|
|
54
|
-
width: 12,
|
|
55
|
-
height: 12,
|
|
56
|
-
borderRadius: 6,
|
|
57
|
-
backgroundColor: setColor,
|
|
58
|
-
} }) })), _jsx(ViewAtom, { style: { flex: 1, paddingLeft: 10, paddingRight: 12, minWidth: 0 }, children: _jsx(ZSText, { ...valueStyle, children: option.value }) }), isFullWidth && (_jsx(ViewAtom, { style: {
|
|
59
|
-
backgroundColor: isSelected
|
|
60
|
-
? palette.primary.main
|
|
61
|
-
: palette.background.layer2,
|
|
62
|
-
paddingHorizontal: 10,
|
|
63
|
-
borderRadius: 100,
|
|
64
|
-
minWidth: 42,
|
|
65
|
-
minHeight: 24,
|
|
66
|
-
justifyContent: 'center',
|
|
67
|
-
alignItems: 'center',
|
|
68
|
-
flexShrink: 0,
|
|
69
|
-
}, children: isSelected ? (_jsx(SvgCheck, { size: 18 })) : (_jsx(ZSText, { typo: "body.5", numberOfLines: 1, ...selectStyle, children: selectLabel })) }))] }) }) }, option.index));
|
|
38
|
+
return (_jsx(RadioRow, { option: option, index: index, optionCount: options.length, rowCount: rowCount, isSelected: isSelected, isFullWidth: isFullWidth, setColor: setColor, innerColor: isSelected ? palette.background.layer1 : 'transparent', selectColor: isSelected ? palette.primary.main : palette.background.layer2, valueStyle: valueStyle, selectStyle: selectStyle, selectLabel: selectLabel, onSelect: handleSelect }, option.index));
|
|
70
39
|
}) }));
|
|
71
40
|
}
|
|
41
|
+
const styles = StyleSheet.create({
|
|
42
|
+
container: {
|
|
43
|
+
width: '100%',
|
|
44
|
+
},
|
|
45
|
+
cell: {},
|
|
46
|
+
row: {
|
|
47
|
+
flexDirection: 'row',
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
paddingVertical: 12,
|
|
50
|
+
borderWidth: 1,
|
|
51
|
+
paddingLeft: 10,
|
|
52
|
+
paddingRight: 15,
|
|
53
|
+
borderRadius: 100,
|
|
54
|
+
},
|
|
55
|
+
radioOuter: {
|
|
56
|
+
width: 20,
|
|
57
|
+
height: 20,
|
|
58
|
+
borderWidth: 1,
|
|
59
|
+
borderRadius: 10,
|
|
60
|
+
justifyContent: 'center',
|
|
61
|
+
alignItems: 'center',
|
|
62
|
+
},
|
|
63
|
+
radioInner: {
|
|
64
|
+
width: 12,
|
|
65
|
+
height: 12,
|
|
66
|
+
borderRadius: 6,
|
|
67
|
+
},
|
|
68
|
+
label: {
|
|
69
|
+
flex: 1,
|
|
70
|
+
paddingLeft: 10,
|
|
71
|
+
paddingRight: 12,
|
|
72
|
+
minWidth: 0,
|
|
73
|
+
},
|
|
74
|
+
selectButton: {
|
|
75
|
+
paddingHorizontal: 10,
|
|
76
|
+
borderRadius: 100,
|
|
77
|
+
minWidth: 42,
|
|
78
|
+
minHeight: 24,
|
|
79
|
+
justifyContent: 'center',
|
|
80
|
+
alignItems: 'center',
|
|
81
|
+
flexShrink: 0,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
72
84
|
export default memo(ZSRadioGroup);
|
|
73
85
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSRadioGroup/index.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSRadioGroup/index.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,UAAU,EAAa,MAAM,cAAc,CAAC;AAErD,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,MAAuB,MAAM,WAAW,CAAC;AAChD,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,MAAM,SAAS,GAAiD;IAC9D,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,QAAQ;CACZ,CAAC;AAkBF,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,QAAQ,CAAC,EACtC,MAAM,EACN,KAAK,EACL,WA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,EAAE,CAAC;QACd,WAAW,EAAE,EAAE;QACf,YAAY,EAAE,EAAE;QAChB,YAAY,EAAE,GAAG;KAClB;IACD,UAAU,EAAE;QACV,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,WAAW,EAAE,CAAC;QACd,YAAY,EAAE,EAAE;QAChB,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;KACrB;IACD,UAAU,EAAE;QACV,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,CAAC;KAChB;IACD,KAAK,EAAE;QACL,IAAI,EAAE,CAAC;QACP,WAAW,EAAE,EAAE;QACf,YAAY,EAAE,EAAE;QAChB,QAAQ,EAAE,CAAC;KACZ;IACD,YAAY,EAAE;QACZ,iBAAiB,EAAE,EAAE;QACrB,YAAY,EAAE,GAAG;QACjB,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,EAAE;QACb,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;QACpB,UAAU,EAAE,CAAC;KACd;CACF,CAAC,CAAC;AAEH,eAAe,IAAI,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import React, { useCallback, memo } from 'react';\nimport { StyleSheet, ViewProps } from 'react-native';\nimport { RadioOption } from '../types';\nimport ViewAtom from '../atoms/ViewAtom';\nimport ZSText, { ZSTextProps } from '../ZSText';\nimport ZSPressable from '../ZSPressable';\nimport { useTheme } from '../../context/ThemeContext';\nimport { SvgCheck } from '../../assets/SvgCheck';\n\nconst ROW_WIDTH: Record<1 | 2 | 3, '100%' | '50%' | '33.33%'> = {\n 1: '100%',\n 2: '50%',\n 3: '33.33%',\n};\n\ninterface RadioRowProps {\n option: RadioOption;\n index: number;\n optionCount: number;\n rowCount: 1 | 2 | 3;\n isSelected: boolean;\n isFullWidth: boolean;\n setColor: string;\n innerColor: string;\n selectColor: string;\n valueStyle?: ZSTextProps;\n selectStyle?: ZSTextProps;\n selectLabel: string;\n onSelect: (option: RadioOption) => void;\n}\n\nconst RadioRow = memo(function RadioRow({\n option,\n index,\n optionCount,\n rowCount,\n isSelected,\n isFullWidth,\n setColor,\n innerColor,\n selectColor,\n valueStyle,\n selectStyle,\n selectLabel,\n onSelect,\n}: RadioRowProps) {\n const isLastCol = (index + 1) % rowCount === 0;\n const isLastRow = Math.ceil((index + 1) / rowCount) === Math.ceil(optionCount / rowCount);\n\n return (\n <ViewAtom\n style={[\n styles.cell,\n {\n width: ROW_WIDTH[rowCount],\n paddingRight: isFullWidth ? 0 : isLastCol ? 0 : 3,\n paddingLeft: isFullWidth ? 0 : isLastCol ? 3 : 0,\n paddingBottom: isLastRow ? 0 : 10,\n },\n ]}\n >\n <ZSPressable onPress={() => onSelect(option)} pressedBackgroundColor=\"transparent\" fullWidth>\n <ViewAtom style={[styles.row, { borderColor: setColor, backgroundColor: innerColor }]}>\n {!isFullWidth && (\n <ViewAtom style={[styles.radioOuter, { borderColor: setColor }]}>\n <ViewAtom style={[styles.radioInner, { backgroundColor: setColor }]} />\n </ViewAtom>\n )}\n\n <ViewAtom style={styles.label}>\n <ZSText {...valueStyle}>{option.value}</ZSText>\n </ViewAtom>\n\n {isFullWidth && (\n <ViewAtom style={[styles.selectButton, { backgroundColor: selectColor }]}>\n {isSelected ? (\n <SvgCheck size={18} />\n ) : (\n <ZSText typo=\"body.5\" numberOfLines={1} {...selectStyle}>\n {selectLabel}\n </ZSText>\n )}\n </ViewAtom>\n )}\n </ViewAtom>\n </ZSPressable>\n </ViewAtom>\n );\n});\n\ninterface ZSRadioGroupProps extends ViewProps {\n options: RadioOption[];\n value?: RadioOption;\n onSelect: (value: RadioOption) => void;\n containerStyle?: ViewProps;\n valueStyle?: ZSTextProps;\n selectStyle?: ZSTextProps;\n selectLabel?: string;\n disabled?: boolean;\n rowCount?: 1 | 2 | 3;\n}\n\nfunction ZSRadioGroup({\n options,\n value,\n onSelect,\n containerStyle,\n valueStyle,\n disabled = false,\n selectStyle,\n selectLabel = '선택',\n rowCount = 1,\n ...props\n}: ZSRadioGroupProps) {\n const { palette } = useTheme();\n const isFullWidth = rowCount === 1;\n\n const handleSelect = useCallback((option: RadioOption) => {\n if (!disabled) {\n onSelect(option);\n }\n }, [disabled, onSelect]);\n\n return (\n <ViewAtom\n style={[styles.container, { flexDirection: isFullWidth ? 'column' : 'row', flexWrap: isFullWidth ? 'nowrap' : 'wrap' }]}\n {...containerStyle}\n {...props}\n >\n {options.map((option, index) => {\n const isSelected = value?.index === option.index;\n const setColor = isSelected ? palette.primary.light : palette.background.neutral;\n\n return (\n <RadioRow\n key={option.index}\n option={option}\n index={index}\n optionCount={options.length}\n rowCount={rowCount}\n isSelected={isSelected}\n isFullWidth={isFullWidth}\n setColor={setColor}\n innerColor={isSelected ? palette.background.layer1 : 'transparent'}\n selectColor={isSelected ? palette.primary.main : palette.background.layer2}\n valueStyle={valueStyle}\n selectStyle={selectStyle}\n selectLabel={selectLabel}\n onSelect={handleSelect}\n />\n );\n })}\n </ViewAtom>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n width: '100%',\n },\n cell: {},\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingVertical: 12,\n borderWidth: 1,\n paddingLeft: 10,\n paddingRight: 15,\n borderRadius: 100,\n },\n radioOuter: {\n width: 20,\n height: 20,\n borderWidth: 1,\n borderRadius: 10,\n justifyContent: 'center',\n alignItems: 'center',\n },\n radioInner: {\n width: 12,\n height: 12,\n borderRadius: 6,\n },\n label: {\n flex: 1,\n paddingLeft: 10,\n paddingRight: 12,\n minWidth: 0,\n },\n selectButton: {\n paddingHorizontal: 10,\n borderRadius: 100,\n minWidth: 42,\n minHeight: 24,\n justifyContent: 'center',\n alignItems: 'center',\n flexShrink: 0,\n },\n});\n\nexport default memo(ZSRadioGroup);\n"]}
|
|
@@ -7,5 +7,6 @@ interface ZSSkeletonProps extends ViewProps {
|
|
|
7
7
|
overlayColor?: string;
|
|
8
8
|
}
|
|
9
9
|
declare function ZSSkeleton({ isFetching, style, children, overlayColor, ...props }: ZSSkeletonProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
|
10
|
-
|
|
10
|
+
declare const _default: React.MemoExoticComponent<typeof ZSSkeleton>;
|
|
11
|
+
export default _default;
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSSkeleton/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAc,KAAK,SAAS,EAAoB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAM5G,UAAU,eAAgB,SAAQ,SAAS;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSSkeleton/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAc,KAAK,SAAS,EAAoB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAM5G,UAAU,eAAgB,SAAQ,SAAS;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,iBAAS,UAAU,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,mSAuC3F;;AAED,wBAAsC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect } from "react";
|
|
2
|
+
import React, { useEffect } from "react";
|
|
3
3
|
import { Dimensions, StyleSheet, View } from "react-native";
|
|
4
4
|
import Animated, { useSharedValue, useAnimatedStyle, withRepeat, withTiming, cancelAnimation } from "react-native-reanimated";
|
|
5
5
|
import { useTheme } from "../../context/ThemeContext";
|
|
@@ -27,7 +27,7 @@ function ZSSkeleton({ isFetching, style, children, overlayColor, ...props }) {
|
|
|
27
27
|
});
|
|
28
28
|
return isFetching ? (_jsx(View, { style: [style, { overflow: "hidden" }], ...props, children: _jsxs(View, { style: styles.container, children: [children, _jsxs(Animated.View, { style: [styles.shimmer, animatedStyle], children: [_jsx(View, { style: [styles.shimmerSub, { backgroundColor: effectColor }] }), _jsx(View, { style: [styles.shimmerCenter, { backgroundColor: effectColor }] }), _jsx(View, { style: [styles.shimmerSub, { backgroundColor: effectColor }] })] })] }) })) : (children);
|
|
29
29
|
}
|
|
30
|
-
export default ZSSkeleton;
|
|
30
|
+
export default React.memo(ZSSkeleton);
|
|
31
31
|
const styles = StyleSheet.create({
|
|
32
32
|
container: {
|
|
33
33
|
overflow: "hidden",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSSkeleton/index.tsx"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSSkeleton/index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,UAAU,EAAkB,UAAU,EAAE,IAAI,EAAkC,MAAM,cAAc,CAAC;AAC5G,OAAO,QAAQ,EAAE,EAAE,cAAc,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC9H,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,MAAM,YAAY,GAAG,UAAU,CAA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I,IAAC,KAAK,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,aACnD,KAAC,IAAI,IAAC,KAAK,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC,GAAI,EACtE,KAAC,IAAI,IAAC,KAAK,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC,GAAI,EACzE,KAAC,IAAI,IAAC,KAAK,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC,GAAI,IACxD,IACX,GACF,CACR,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,CAAC;AACJ,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AAEtC,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,QAAQ,EAAE,QAAQ;QAClB,OAAO,EAAE,GAAG;QACZ,KAAK,EAAE,MAAM;KACd;IACD,OAAO,EAAE;QACP,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,UAAU;QACpB,aAAa,EAAE,KAAK;KACrB;IACD,UAAU,EAAE;QACV,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,GAAG;QACZ,KAAK,EAAE,YAAY,GAAG,GAAG;KAC1B;IACD,aAAa,EAAE;QACb,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,GAAG;QACZ,KAAK,EAAE,YAAY,GAAG,GAAG;KAC1B;CACF,CAAC,CAAC","sourcesContent":["import React, { useEffect } from \"react\";\nimport { Dimensions, type StyleProp, StyleSheet, View, type ViewStyle, type ViewProps } from \"react-native\";\nimport Animated, { useSharedValue, useAnimatedStyle, withRepeat, withTiming, cancelAnimation } from \"react-native-reanimated\";\nimport { useTheme } from \"../../context/ThemeContext\";\n\nconst DEVICE_WIDTH = Dimensions.get(\"window\").width;\n\ninterface ZSSkeletonProps extends ViewProps {\n isFetching?: boolean;\n style?: StyleProp<ViewStyle>;\n children?: React.ReactNode;\n overlayColor?: string;\n}\n\nfunction ZSSkeleton({ isFetching, style, children, overlayColor, ...props }: ZSSkeletonProps) {\n const translateX = useSharedValue(-DEVICE_WIDTH * 1.2);\n const { palette } = useTheme();\n const effectColor = overlayColor || palette.background.base;\n\n useEffect(() => {\n if (isFetching) {\n translateX.value = withRepeat(withTiming(DEVICE_WIDTH * 1.2, { duration: 800 }), -1, false);\n } else {\n cancelAnimation(translateX);\n translateX.value = -DEVICE_WIDTH * 1.2;\n }\n\n return () => {\n cancelAnimation(translateX);\n };\n }, [isFetching]);\n\n const animatedStyle = useAnimatedStyle(() => {\n return {\n transform: [{ translateX: translateX.value }],\n };\n });\n\n return isFetching ? (\n <View style={[style, { overflow: \"hidden\" }]} {...props}>\n <View style={styles.container}>\n {children}\n\n <Animated.View style={[styles.shimmer, animatedStyle]}>\n <View style={[styles.shimmerSub, { backgroundColor: effectColor }]} />\n <View style={[styles.shimmerCenter, { backgroundColor: effectColor }]} />\n <View style={[styles.shimmerSub, { backgroundColor: effectColor }]} />\n </Animated.View>\n </View>\n </View>\n ) : (\n children\n );\n}\n\nexport default React.memo(ZSSkeleton);\n\nconst styles = StyleSheet.create({\n container: {\n overflow: \"hidden\",\n opacity: 0.6,\n width: \"100%\",\n },\n shimmer: {\n width: \"100%\",\n height: \"100%\",\n position: \"absolute\",\n flexDirection: \"row\",\n },\n shimmerSub: {\n height: \"100%\",\n opacity: 0.3,\n width: DEVICE_WIDTH * 0.3,\n },\n shimmerCenter: {\n height: \"100%\",\n opacity: 0.6,\n width: DEVICE_WIDTH * 0.4,\n },\n});\n"]}
|
|
@@ -8,5 +8,6 @@ interface ZSSkeletonBoxProps extends ViewProps {
|
|
|
8
8
|
color?: ViewColorOptions;
|
|
9
9
|
}
|
|
10
10
|
declare function ZSSkeletonBox({ height, style, overlayColor, color, ...props }: ZSSkeletonBoxProps): React.JSX.Element;
|
|
11
|
-
|
|
11
|
+
declare const _default: React.MemoExoticComponent<typeof ZSSkeletonBox>;
|
|
12
|
+
export default _default;
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSSkeletonBox/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAc,KAAK,SAAS,EAAoB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSSkeletonBox/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAc,KAAK,SAAS,EAAoB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAG5G,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAKrD,UAAU,kBAAmB,SAAQ,SAAS;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B;AAED,iBAAS,aAAa,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,KAAiB,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,qBAuCtG;;AAED,wBAAyC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect } from "react";
|
|
2
|
+
import React, { useEffect } from "react";
|
|
3
3
|
import { Dimensions, StyleSheet, View } from "react-native";
|
|
4
4
|
import Animated, { useSharedValue, useAnimatedStyle, withRepeat, withTiming, cancelAnimation } from "react-native-reanimated";
|
|
5
|
-
import { useTheme } from "../../context/ThemeContext";
|
|
6
5
|
import ZSView from "../ZSView";
|
|
6
|
+
import { useTheme } from "../../context/ThemeContext";
|
|
7
7
|
const DEVICE_WIDTH = Dimensions.get("window").width;
|
|
8
8
|
function ZSSkeletonBox({ height, style, overlayColor, color = 'neutral', ...props }) {
|
|
9
9
|
const translateX = useSharedValue(-DEVICE_WIDTH * 1.2);
|
|
@@ -20,7 +20,7 @@ function ZSSkeletonBox({ height, style, overlayColor, color = 'neutral', ...prop
|
|
|
20
20
|
transform: [{ translateX: translateX.value }],
|
|
21
21
|
};
|
|
22
22
|
});
|
|
23
|
-
return (_jsx(View, { style: [
|
|
23
|
+
return (_jsx(View, { style: [styles.fullWidth, style, { height, overflow: "hidden" }], ...props, children: _jsx(ZSView, { style: [
|
|
24
24
|
styles.container,
|
|
25
25
|
{
|
|
26
26
|
width: DEVICE_WIDTH,
|
|
@@ -28,11 +28,13 @@ function ZSSkeletonBox({ height, style, overlayColor, color = 'neutral', ...prop
|
|
|
28
28
|
},
|
|
29
29
|
], color: color, children: _jsxs(Animated.View, { style: [styles.shimmer, animatedStyle], children: [_jsx(View, { style: [styles.shimmerSub, { backgroundColor: effectColor }] }), _jsx(View, { style: [styles.shimmerCenter, { backgroundColor: effectColor }] }), _jsx(View, { style: [styles.shimmerSub, { backgroundColor: effectColor }] })] }) }) }));
|
|
30
30
|
}
|
|
31
|
-
export default ZSSkeletonBox;
|
|
31
|
+
export default React.memo(ZSSkeletonBox);
|
|
32
32
|
const styles = StyleSheet.create({
|
|
33
|
+
fullWidth: {
|
|
34
|
+
width: '100%',
|
|
35
|
+
},
|
|
33
36
|
container: {
|
|
34
37
|
overflow: "hidden",
|
|
35
|
-
opacity: 0.4,
|
|
36
38
|
},
|
|
37
39
|
shimmer: {
|
|
38
40
|
width: "100%",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSSke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AO,EAAE,GAAG;QACZ,KAAK,EAAE,YAAY,GAAG,GAAG;KAC1B;IACD,aAAa,EAAE;QACb,MAAM,EAAE,MAAM;QACd,eAAe,EAAE,SAAS;QAC1B,OAAO,EAAE,GAAG;QACZ,KAAK,EAAE,YAAY,GAAG,GAAG;KAC1B;CACF,CAAC,CAAC","sourcesContent":["import React, { useEffect } from \"react\";\nimport { Dimensions, type StyleProp, StyleSheet, View, type ViewStyle, type ViewProps } from \"react-native\";\nimport Animated, { useSharedValue, useAnimatedStyle, withRepeat, withTiming, cancelAnimation } from \"react-native-reanimated\";\nimport ZSView from \"../ZSView\";\nimport { ViewColorOptions } from \"../../theme/types\";\nimport { useTheme } from \"../../context/ThemeContext\";\n\nconst DEVICE_WIDTH = Dimensions.get(\"window\").width;\n\ninterface ZSSkeletonBoxProps extends ViewProps {\n height: number;\n style?: StyleProp<ViewStyle>;\n overlayColor?: string;\n color?: ViewColorOptions;\n}\n\nfunction ZSSkeletonBox({ height, style, overlayColor, color = 'neutral', ...props }: ZSSkeletonBoxProps) {\n const translateX = useSharedValue(-DEVICE_WIDTH * 1.2);\n const { palette } = useTheme();\n const effectColor = overlayColor || palette.background.layer1;\n\n useEffect(() => {\n translateX.value = withRepeat(withTiming(DEVICE_WIDTH * 1.2, { duration: 800 }), -1, false);\n\n return () => {\n cancelAnimation(translateX);\n };\n }, []);\n\n const animatedStyle = useAnimatedStyle(() => {\n return {\n transform: [{ translateX: translateX.value }],\n };\n });\n\n return (\n <View style={[styles.fullWidth, style, { height, overflow: \"hidden\" }]} {...props}>\n <ZSView\n style={[\n styles.container,\n {\n width: DEVICE_WIDTH,\n height,\n },\n ]}\n color={color}\n >\n <Animated.View style={[styles.shimmer, animatedStyle]}>\n <View style={[styles.shimmerSub, { backgroundColor: effectColor }]} />\n <View style={[styles.shimmerCenter, { backgroundColor: effectColor }]} />\n <View style={[styles.shimmerSub, { backgroundColor: effectColor }]} />\n </Animated.View>\n </ZSView>\n </View>\n );\n}\n\nexport default React.memo(ZSSkeletonBox);\n\nconst styles = StyleSheet.create({\n fullWidth: {\n width: '100%',\n },\n container: {\n overflow: \"hidden\",\n },\n shimmer: {\n width: \"100%\",\n height: \"100%\",\n position: \"absolute\",\n flexDirection: \"row\",\n },\n shimmerSub: {\n height: \"100%\",\n backgroundColor: \"#ebebeb\",\n opacity: 0.3,\n width: DEVICE_WIDTH * 0.3,\n },\n shimmerCenter: {\n height: \"100%\",\n backgroundColor: \"#f5f5f5\",\n opacity: 0.7,\n width: DEVICE_WIDTH * 0.4,\n },\n});\n"]}
|
|
@@ -10,5 +10,6 @@ interface ZSSwitchProps extends ViewProps {
|
|
|
10
10
|
thumbColor?: string;
|
|
11
11
|
}
|
|
12
12
|
declare function ZSSwitch({ isActive, onToggle, style, width, trackColorInactive, trackColorActive, thumbColor, ...props }: ZSSwitchProps): React.JSX.Element;
|
|
13
|
-
|
|
13
|
+
declare const _default: React.MemoExoticComponent<typeof ZSSwitch>;
|
|
14
|
+
export default _default;
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSSwitch/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAa,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAUzF,UAAU,aAAc,SAAQ,SAAS;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,iBAAS,QAAQ,CAAC,EAChB,QAAgB,EAChB,QAAQ,EACR,KAAK,EACL,KAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,UAAsB,EACtB,GAAG,KAAK,EACT,EAAE,aAAa,qBAyCf
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSSwitch/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAa,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAUzF,UAAU,aAAc,SAAQ,SAAS;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,iBAAS,QAAQ,CAAC,EAChB,QAAgB,EAChB,QAAQ,EACR,KAAK,EACL,KAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,UAAsB,EACtB,GAAG,KAAK,EACT,EAAE,aAAa,qBAyCf;;AAED,wBAAoC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
2
3
|
import { Pressable } from "react-native";
|
|
3
4
|
import Animated from "react-native-reanimated";
|
|
4
5
|
import { useTheme } from "../../context/ThemeContext";
|
|
@@ -39,6 +40,5 @@ function ZSSwitch({ isActive = false, onToggle, style, width = 50, trackColorIna
|
|
|
39
40
|
};
|
|
40
41
|
return (_jsx(Pressable, { onPress: onToggle, style: style, ...props, children: _jsx(Animated.View, { style: toggleStyle, children: _jsx(Animated.View, { style: thumbStyle }) }) }));
|
|
41
42
|
}
|
|
42
|
-
;
|
|
43
|
-
export default ZSSwitch;
|
|
43
|
+
export default React.memo(ZSSwitch);
|
|
44
44
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSSwitch/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSSwitch/index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAkC,SAAS,EAAkB,MAAM,cAAc,CAAC;AACzF,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,MAAM,0BAA0B,GAAG,GAAG,CAAC;AACvC,MAAM,iBAAiB,GAAG;IACxB,kBAAkB,EAAE,0BAA0B;IAC9C,wBAAwB,EAAE,aAAa;CAC/B,CAAC;AAYX,SAAS,QAAQ,CAAC,EAChB,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,KAAK,EACL,KAAK,GAAG,EAAE,EACV,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,GAAG,SAAS,EACtB,GAAG,KAAK,EACM;IACd,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC/B,MAAM,MAAM,GAAG,KAAK,GAAG,GAAG,CAAC;IAC3B,MAAM,OAAO,GAAG,KAAK,GAAG,IAAI,CAAC;IAC7B,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,CAAC,CAAC;IACvC,MAAM,kBAAkB,GAAG,MAAM,GAAG,GAAG,CAAC;IACxC,MAAM,iBAAiB,GAAG,SAAS,GAAG,CAAC,CAAC;IAExC,MAAM,aAAa,GAAG,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7D,MAAM,WAAW,GAAG,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;IAC7D,MAAM,eAAe,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEvE,MAAM,WAAW,GAAG;QAClB,KAAK;QACL,MAAM;QACN,YAAY,EAAE,kBAAkB;QAChC,OAAO;QACP,cAAc,EAAE,QAAiB;QACjC,eAAe,EAAE,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa;QACvD,kBAAkB,EAAE,iBAA0B;QAC9C,GAAG,iBAAiB;KACrB,CAAC;IAEF,MAAM,UAAU,GAAG;QACjB,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,SAAS;QACjB,YAAY,EAAE,iBAAiB;QAC/B,cAAc,EAAE,QAAiB;QACjC,eAAe,EAAE,UAAU;QAC3B,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;QAC5C,kBAAkB,EAAE,WAAoB;QACxC,GAAG,iBAAiB;KACrB,CAAC;IAEF,OAAO,CACL,KAAC,SAAS,IAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,KAAM,KAAK,YACnD,KAAC,QAAQ,CAAC,IAAI,IAAC,KAAK,EAAE,WAAW,YAC/B,KAAC,QAAQ,CAAC,IAAI,IAAC,KAAK,EAAE,UAAU,GAAI,GACtB,GACN,CACb,CAAC;AACJ,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport { type StyleProp, type ViewStyle, Pressable, type ViewProps } from \"react-native\";\nimport Animated from \"react-native-reanimated\";\nimport { useTheme } from \"../../context/ThemeContext\";\n\nconst SWITCH_TRANSITION_DURATION = 200;\nconst SWITCH_TRANSITION = {\n transitionDuration: SWITCH_TRANSITION_DURATION,\n transitionTimingFunction: 'ease-in-out',\n} as const;\n\ninterface ZSSwitchProps extends ViewProps {\n isActive: boolean;\n onToggle: () => void;\n style?: StyleProp<ViewStyle>;\n width?: number;\n trackColorInactive?: string;\n trackColorActive?: string;\n thumbColor?: string;\n}\n\nfunction ZSSwitch({\n isActive = false,\n onToggle,\n style,\n width = 50,\n trackColorInactive,\n trackColorActive,\n thumbColor = '#ffffff',\n ...props\n}: ZSSwitchProps) {\n const { palette } = useTheme();\n const height = width * 0.6;\n const padding = width * 0.04;\n const thumbSize = height - padding * 2;\n const toggleBorderRadius = height * 1.2;\n const thumbBorderRadius = thumbSize / 2;\n\n const inactiveColor = trackColorInactive ?? palette.grey[30];\n const activeColor = trackColorActive ?? palette.primary.main;\n const thumbTranslateX = isActive ? width - thumbSize - padding * 2 : 0;\n\n const toggleStyle = {\n width,\n height,\n borderRadius: toggleBorderRadius,\n padding,\n justifyContent: \"center\" as const,\n backgroundColor: isActive ? activeColor : inactiveColor,\n transitionProperty: 'backgroundColor' as const,\n ...SWITCH_TRANSITION,\n };\n\n const thumbStyle = {\n width: thumbSize,\n height: thumbSize,\n borderRadius: thumbBorderRadius,\n justifyContent: \"center\" as const,\n backgroundColor: thumbColor,\n transform: [{ translateX: thumbTranslateX }],\n transitionProperty: 'transform' as const,\n ...SWITCH_TRANSITION,\n };\n\n return (\n <Pressable onPress={onToggle} style={style} {...props}>\n <Animated.View style={toggleStyle}>\n <Animated.View style={thumbStyle} />\n </Animated.View>\n </Pressable>\n );\n}\n\nexport default React.memo(ZSSwitch);\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TextProps } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { TypoColorOptions, TypoOptions } from "../../theme/types";
|
|
4
4
|
export interface ZSTextProps extends TextProps {
|
|
5
5
|
typo?: TypoOptions;
|
|
6
6
|
color?: TypoColorOptions;
|
|
7
7
|
}
|
|
8
8
|
declare function ZSText({ typo, color, ...props }: ZSTextProps): React.JSX.Element;
|
|
9
|
-
|
|
9
|
+
declare const _default: React.MemoExoticComponent<typeof ZSText>;
|
|
10
|
+
export default _default;
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|