@0610studio/zs-ui 0.17.1 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +3 -3
- package/build/ZsUiView.js +2 -2
- package/build/ZsUiView.js.map +1 -1
- package/build/ZsUiView.web.js +2 -4
- package/build/ZsUiView.web.js.map +1 -1
- package/build/assets/SvgCheck.js +2 -4
- package/build/assets/SvgCheck.js.map +1 -1
- package/build/assets/SvgExclamation.js +2 -9
- package/build/assets/SvgExclamation.js.map +1 -1
- package/build/assets/SvgX.js +3 -5
- package/build/assets/SvgX.js.map +1 -1
- package/build/context/OverlayContext.js +2 -29
- package/build/context/OverlayContext.js.map +1 -1
- package/build/context/ThemeContext.d.ts.map +1 -1
- package/build/context/ThemeContext.js +5 -8
- package/build/context/ThemeContext.js.map +1 -1
- package/build/overlay/AlertOverlay/index.js +8 -25
- package/build/overlay/AlertOverlay/index.js.map +1 -1
- package/build/overlay/BottomSheetOverlay/index.js +3 -17
- package/build/overlay/BottomSheetOverlay/index.js.map +1 -1
- package/build/overlay/LoadingNotify/index.js +4 -5
- package/build/overlay/LoadingNotify/index.js.map +1 -1
- package/build/overlay/Modality/index.js +20 -29
- package/build/overlay/Modality/index.js.map +1 -1
- package/build/overlay/PopOver/PopOverButton.js +3 -6
- package/build/overlay/PopOver/PopOverButton.js.map +1 -1
- package/build/overlay/PopOver/PopOverMenu.js +7 -12
- package/build/overlay/PopOver/PopOverMenu.js.map +1 -1
- package/build/overlay/SnackbarNotify/index.js +4 -6
- package/build/overlay/SnackbarNotify/index.js.map +1 -1
- package/build/overlay/SnackbarNotify/ui/SnackbarItem.js +6 -13
- package/build/overlay/SnackbarNotify/ui/SnackbarItem.js.map +1 -1
- package/build/overlay/ZSPortal/index.js +3 -7
- package/build/overlay/ZSPortal/index.js.map +1 -1
- package/build/overlay/ui/ModalBackground.js +5 -9
- package/build/overlay/ui/ModalBackground.js.map +1 -1
- package/build/ui/ZSAboveKeyboard/index.js +2 -5
- package/build/ui/ZSAboveKeyboard/index.js.map +1 -1
- package/build/ui/ZSBlockButton/index.js +13 -17
- package/build/ui/ZSBlockButton/index.js.map +1 -1
- package/build/ui/ZSContainer/index.js +3 -36
- package/build/ui/ZSContainer/index.js.map +1 -1
- package/build/ui/ZSPressable/index.js +2 -9
- package/build/ui/ZSPressable/index.js.map +1 -1
- package/build/ui/ZSRadioGroup/index.js +41 -64
- package/build/ui/ZSRadioGroup/index.js.map +1 -1
- package/build/ui/ZSSkeleton/index.js +3 -12
- package/build/ui/ZSSkeleton/index.js.map +1 -1
- package/build/ui/ZSSkeletonBox/index.js +9 -16
- package/build/ui/ZSSkeletonBox/index.js.map +1 -1
- package/build/ui/ZSSwitch/index.js +2 -6
- package/build/ui/ZSSwitch/index.js.map +1 -1
- package/build/ui/ZSText/index.js +2 -2
- package/build/ui/ZSText/index.js.map +1 -1
- package/build/ui/ZSTextField/index.js +2 -15
- package/build/ui/ZSTextField/index.js.map +1 -1
- package/build/ui/ZSTextField/ui/ButtonClose.js +2 -3
- package/build/ui/ZSTextField/ui/ButtonClose.js.map +1 -1
- package/build/ui/ZSTextField/ui/ErrorComponent.js +2 -7
- package/build/ui/ZSTextField/ui/ErrorComponent.js.map +1 -1
- package/build/ui/ZSView/index.js +3 -4
- package/build/ui/ZSView/index.js.map +1 -1
- package/build/ui/atoms/AnimatedWrapper.js +4 -5
- package/build/ui/atoms/AnimatedWrapper.js.map +1 -1
- package/build/ui/atoms/TextAtom.js +2 -4
- package/build/ui/atoms/TextAtom.js.map +1 -1
- package/build/ui/atoms/ViewAtom.js +2 -4
- package/build/ui/atoms/ViewAtom.js.map +1 -1
- package/ios/ZsUi.podspec +1 -1
- package/package.json +30 -28
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import { useRef } from "react";
|
|
2
3
|
import { Platform, StyleSheet, View } from "react-native";
|
|
3
4
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
@@ -21,11 +22,7 @@ function ZSAboveKeyboard({ keyboardShowOffset = 0, keyboardHideOffset = 0, child
|
|
|
21
22
|
handleLayoutHeight?.(height);
|
|
22
23
|
};
|
|
23
24
|
const isVisible = showOnlyKeyboardVisible ? isKeyboardVisible : true;
|
|
24
|
-
return (
|
|
25
|
-
<View style={{ width: "100%", backgroundColor, paddingBottom: keyboardVisiblePadding }}>
|
|
26
|
-
{children}
|
|
27
|
-
</View>
|
|
28
|
-
</View>);
|
|
25
|
+
return (_jsx(View, { style: [styles.container, { bottom: !isVisible ? HIDDEN_BOTTOM_OFFSET : 0 }], onLayout: handleLayout, ...props, children: _jsx(View, { style: { width: "100%", backgroundColor, paddingBottom: keyboardVisiblePadding }, children: children }) }));
|
|
29
26
|
}
|
|
30
27
|
export default ZSAboveKeyboard;
|
|
31
28
|
const styles = StyleSheet.create({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSAboveKeyboard/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAqB,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,wBAAwB;AACxB,6DAA6D;AAC7D,8CAA8C;AAC9C,MAAM,+BAA+B,GAAG,CAAC,QAAQ,CAAC,EAAE,KAAK,SAAS,IAAI,QAAQ,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;AAE7F,MAAM,oBAAoB,GAAG,CAAC,GAAG,CAAC;AAWlC,SAAS,eAAe,CAAC,EACvB,kBAAkB,GAAG,CAAC,EACtB,kBAAkB,GAAG,CAAC,EACtB,QAA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K,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,YAAY,KAAM,KAAK,YACnH,KAAC,IAAI,IAAC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,sBAAsB,EAAE,YACnF,QAAQ,GACJ,GACD,CACT,CAAC;AACJ,CAAC;AAED,eAAe,eAAe,CAAC;AAE/B,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;QACpB,MAAM,EAAE,aAAa,CAAC,cAAc;QACpC,KAAK,EAAE,MAAM;KACd;CACF,CAAC,CAAC","sourcesContent":["import { useRef } from \"react\";\nimport { LayoutChangeEvent, Platform, StyleSheet, View, type ViewProps } from \"react-native\";\nimport { useSafeAreaInsets } from \"react-native-safe-area-context\";\nimport useKeyboard from \"../../model/useKeyboard\";\nimport { Z_INDEX_VALUE } from \"../../model/utils\";\n\n// Edge-to-edge 디스플레이 정책\n// Android 11 (API 30) 이전: adjustResize가 시스템 레벨에서 자동으로 패딩을 추가\n// Android 11 (API 30) 이후: 일부 기기에서 패딩이 적용되지 않음\nconst isLegacyAndroidKeyboardBehavior = (Platform.OS === 'android' && Platform.Version < 30);\n\nconst HIDDEN_BOTTOM_OFFSET = -300;\n\ninterface Props extends ViewProps {\n children: React.ReactNode;\n keyboardShowOffset?: number;\n keyboardHideOffset?: number;\n handleLayoutHeight?: (height: number) => void;\n showOnlyKeyboardVisible?: boolean;\n backgroundColor?: string;\n}\n\nfunction ZSAboveKeyboard({\n keyboardShowOffset = 0,\n keyboardHideOffset = 0,\n children,\n handleLayoutHeight,\n showOnlyKeyboardVisible = false,\n backgroundColor,\n ...props\n}: Props) {\n const { bottom } = useSafeAreaInsets();\n const componentHeightRef = useRef(0);\n const { isKeyboardVisible, keyboardHeight } = useKeyboard();\n const keyboardVisiblePadding =\n !isKeyboardVisible ? (0 + keyboardHideOffset)\n : isLegacyAndroidKeyboardBehavior ? 0\n : (keyboardHeight - (Platform.OS === 'ios' ? bottom : 0) + keyboardShowOffset);\n\n const handleLayout = (event: LayoutChangeEvent) => {\n const { height } = event.nativeEvent.layout;\n componentHeightRef.current = height;\n handleLayoutHeight?.(height);\n };\n\n const isVisible = showOnlyKeyboardVisible ? isKeyboardVisible : true;\n\n return (\n <View style={[styles.container, { bottom: !isVisible ? HIDDEN_BOTTOM_OFFSET : 0 }]} onLayout={handleLayout} {...props}>\n <View style={{ width: \"100%\", backgroundColor, paddingBottom: keyboardVisiblePadding }}>\n {children}\n </View>\n </View >\n );\n}\n\nexport default ZSAboveKeyboard;\n\nconst styles = StyleSheet.create({\n container: {\n position: 'absolute',\n justifyContent: 'center',\n alignItems: 'center',\n zIndex: Z_INDEX_VALUE.ABOVE_KEYBOARD,\n width: '100%',\n },\n});\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
2
|
import { Image } from 'react-native';
|
|
2
3
|
import { useTheme } from '../../context/ThemeContext';
|
|
3
4
|
import ZSPressable from '../ZSPressable';
|
|
@@ -84,23 +85,18 @@ function ZSBlockButton({ onPress, style, title, intent = 'primary', typo, prefix
|
|
|
84
85
|
return palette.text[c01];
|
|
85
86
|
};
|
|
86
87
|
const textColorValue = getTextColorValue();
|
|
87
|
-
return (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}} color={colors.backgroundColor !== 'transparent' ? colors.backgroundColor : undefined}>
|
|
100
|
-
{prefixIcon && (<Image style={{ width: 12, height: 12, marginTop: 1 }} tintColor={textColorValue} source={prefixIcon}/>)}
|
|
101
|
-
<ZSText color={colors.textColor} typo={typo}>{title}</ZSText>
|
|
102
|
-
</ZSView>
|
|
103
|
-
</ZSPressable>);
|
|
88
|
+
return (_jsx(ZSPressable, { onPress: onPress, style: style, isLoading: isLoading, disabled: disabled, ...props, children: _jsxs(ZSView, { style: {
|
|
89
|
+
paddingHorizontal,
|
|
90
|
+
paddingVertical,
|
|
91
|
+
borderRadius: 6,
|
|
92
|
+
justifyContent: 'center',
|
|
93
|
+
alignItems: 'center',
|
|
94
|
+
flexDirection: 'row',
|
|
95
|
+
gap: 4,
|
|
96
|
+
backgroundColor: colors.backgroundColor === 'transparent' ? 'transparent' : undefined,
|
|
97
|
+
borderColor: colors.borderColor,
|
|
98
|
+
borderWidth: colors.borderWidth,
|
|
99
|
+
}, color: colors.backgroundColor !== 'transparent' ? colors.backgroundColor : undefined, children: [prefixIcon && (_jsx(Image, { style: { width: 12, height: 12, marginTop: 1 }, tintColor: textColorValue, source: prefixIcon })), _jsx(ZSText, { color: colors.textColor, typo: typo, children: title })] }) }));
|
|
104
100
|
}
|
|
105
101
|
export default ZSBlockButton;
|
|
106
102
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSBlockButton/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAA4E,MAAM,cAAc,CAAC;AAE/G,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;AAK/B,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAcD,SAAS,aAAa,CAAC,EAAE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C,eAAe,KAAK,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;gBACrF,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,WAAW,EAAE,MAAM,CAAC,WAAW;aAChC,EACD,KAAK,EAAE,MAAM,CAAC,eAAe,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,aAEnF,UAAU,IAAI,CACb,KAAC,KAAK,IACJ,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,EAC9C,SAAS,EAAE,cAAc,EACzB,MAAM,EAAE,UAAU,GAClB,CACH,EACD,KAAC,MAAM,IAAC,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,YAAG,KAAK,GAAU,IACtD,GACG,CACf,CAAC;AACJ,CAAC;AAED,eAAe,aAAa,CAAC","sourcesContent":["import { Image, type ImageSourcePropType, type StyleProp, type ViewStyle, type ViewProps } from 'react-native';\nimport { ColorPalette, ThemeTextType, TypoColorOptions, TypoOptions, ViewColorOptions, IntentOptions, ThemeBackground } from '../../theme/types';\nimport { useTheme } from '../../context/ThemeContext';\nimport ZSPressable from '../ZSPressable';\nimport ZSView from '../ZSView';\nimport ZSText from '../ZSText';\n\ntype SemanticPaletteKey = 'primary' | 'secondary' | 'danger' | 'warning' | 'success' | 'information' | 'grey';\ntype PaletteShade = keyof ColorPalette;\n\nfunction isColorMap(value: unknown): value is Record<string, string> {\n return typeof value === 'object' && value !== null;\n}\n\ntype Props = ViewProps & {\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 }: 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('.') as [string, string | undefined];\n if (c02) {\n if (c01 === 'text') return palette.text[c02 as keyof ThemeTextType];\n if (c01 === 'background') return palette.background[c02 as keyof ThemeBackground];\n\n const semanticPalette = palette[c01 as SemanticPaletteKey];\n return isColorMap(semanticPalette) ? semanticPalette[c02 as PaletteShade] : undefined;\n }\n return palette.text[c01 as keyof ThemeTextType];\n };\n\n const textColorValue = getTextColorValue();\n\n return (\n <ZSPressable onPress={onPress} style={style} isLoading={isLoading} disabled={disabled} {...props}>\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"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useImperativeHandle, forwardRef, useRef, useState, useCallback, useMemo } from 'react';
|
|
2
3
|
import { StatusBar, StyleSheet, ScrollView, View, Dimensions } from 'react-native';
|
|
3
4
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
4
5
|
import { useTheme } from '../../context/ThemeContext';
|
|
@@ -115,41 +116,7 @@ foldableSingleScreen, dividerLineComponent, rightComponent,
|
|
|
115
116
|
props.style
|
|
116
117
|
], [props.style]);
|
|
117
118
|
const shouldShowStatusBar = useMemo(() => Boolean(barStyle || statusBarColor || translucent), [barStyle, statusBarColor, translucent]);
|
|
118
|
-
return (
|
|
119
|
-
<View style={[styles.w100, { backgroundColor: "#00000009" }]}>
|
|
120
|
-
<View style={[styles.w100, { maxWidth: foldableSingleScreen ? Math.min(width, MAX_FOLDABLE_SINGLE_WIDTH) : '100%', alignSelf: 'center', backgroundColor: palette.background.base }]}>
|
|
121
|
-
{topComponent}
|
|
122
|
-
<View style={[styles.w100, { flexDirection: 'row' }]}>
|
|
123
|
-
<View style={styles.flex1}>
|
|
124
|
-
{scrollViewDisabled ? (<View style={[styles.flex1, containerStyle]}>
|
|
125
|
-
{props.children}
|
|
126
|
-
</View>) : (<ScrollView ref={scrollViewRef} style={styles.w100} showsVerticalScrollIndicator={showsVerticalScrollIndicator} contentContainerStyle={scrollContentStyle} scrollEventThrottle={scrollEventThrottle} onScroll={(event) => { handleScroll(event, 1); }} onTouchStart={(evt) => handleTouch(evt, 1)}
|
|
127
|
-
// ---
|
|
128
|
-
{...SCROLL_VIEW_OPTIONS}>
|
|
129
|
-
<View style={[styles.flex1, containerStyle]}>
|
|
130
|
-
{props.children}
|
|
131
|
-
</View>
|
|
132
|
-
</ScrollView>)}
|
|
133
|
-
</View>
|
|
134
|
-
{foldingState === FoldingState.UNFOLDED && !foldableSingleScreen && rightComponent && dividerLineComponent && dividerLineComponent}
|
|
135
|
-
{foldingState === FoldingState.UNFOLDED && !foldableSingleScreen && rightComponent && (<View style={styles.flex1}>
|
|
136
|
-
{scrollViewDisabled ? (<View style={[styles.flex1, containerStyle]}>
|
|
137
|
-
{rightComponent}
|
|
138
|
-
</View>) : (<ScrollView ref={scrollView2Ref} style={styles.w100} showsVerticalScrollIndicator={showsVerticalScrollIndicator} contentContainerStyle={scrollContentStyle} scrollEventThrottle={scrollEventThrottle} onScroll={(event) => { handleScroll(event, 2); }} onTouchStart={(evt) => handleTouch(evt, 2)}
|
|
139
|
-
// ---
|
|
140
|
-
{...SCROLL_VIEW_OPTIONS}>
|
|
141
|
-
<View style={[styles.flex1, containerStyle]}>
|
|
142
|
-
{rightComponent}
|
|
143
|
-
</View>
|
|
144
|
-
</ScrollView>)}
|
|
145
|
-
</View>)}
|
|
146
|
-
</View>
|
|
147
|
-
{bottomComponent}
|
|
148
|
-
</View>
|
|
149
|
-
</View>
|
|
150
|
-
|
|
151
|
-
{shouldShowStatusBar && (<StatusBar barStyle={barStyle} backgroundColor={statusBarColor || palette.background.base} translucent={translucent}/>)}
|
|
152
|
-
</SafeAreaView>);
|
|
119
|
+
return (_jsxs(SafeAreaView, { style: safeAreaStyle, edges: edges, children: [_jsx(View, { style: [styles.w100, { backgroundColor: "#00000009" }], children: _jsxs(View, { style: [styles.w100, { maxWidth: foldableSingleScreen ? Math.min(width, MAX_FOLDABLE_SINGLE_WIDTH) : '100%', alignSelf: 'center', backgroundColor: palette.background.base }], children: [topComponent, _jsxs(View, { style: [styles.w100, { flexDirection: 'row' }], children: [_jsx(View, { style: styles.flex1, children: scrollViewDisabled ? (_jsx(View, { style: [styles.flex1, containerStyle], children: props.children })) : (_jsx(ScrollView, { ref: scrollViewRef, style: styles.w100, showsVerticalScrollIndicator: showsVerticalScrollIndicator, contentContainerStyle: scrollContentStyle, scrollEventThrottle: scrollEventThrottle, onScroll: (event) => { handleScroll(event, 1); }, onTouchStart: (evt) => handleTouch(evt, 1), ...SCROLL_VIEW_OPTIONS, children: _jsx(View, { style: [styles.flex1, containerStyle], children: props.children }) })) }), foldingState === FoldingState.UNFOLDED && !foldableSingleScreen && rightComponent && dividerLineComponent && dividerLineComponent, foldingState === FoldingState.UNFOLDED && !foldableSingleScreen && rightComponent && (_jsx(View, { style: styles.flex1, children: scrollViewDisabled ? (_jsx(View, { style: [styles.flex1, containerStyle], children: rightComponent })) : (_jsx(ScrollView, { ref: scrollView2Ref, style: styles.w100, showsVerticalScrollIndicator: showsVerticalScrollIndicator, contentContainerStyle: scrollContentStyle, scrollEventThrottle: scrollEventThrottle, onScroll: (event) => { handleScroll(event, 2); }, onTouchStart: (evt) => handleTouch(evt, 2), ...SCROLL_VIEW_OPTIONS, children: _jsx(View, { style: [styles.flex1, containerStyle], children: rightComponent }) })) }))] }), bottomComponent] }) }), shouldShowStatusBar && (_jsx(StatusBar, { barStyle: barStyle, backgroundColor: statusBarColor || palette.background.base, translucent: translucent }))] }));
|
|
153
120
|
});
|
|
154
121
|
export const styles = StyleSheet.create({
|
|
155
122
|
flex1: { flex: 1 },
|
|
@@ -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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AI,CACN;UAAA,CAAC,eAAe,CAClB;QAAA,EAAE,IAAI,CACR;MAAA,EAAE,IAAI,CAEN;;MAAA,CAAC,mBAAmB,IAAI,CACtB,CAAC,SAAS,CACR,QAAQ,CAAC,CAAC,QAAQ,CAAC,CACnB,eAAe,CAAC,CAAC,cAAc,IAAI,OAAO,CAAC,UAAU,CAAC,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 = 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,OAAc,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,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C,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,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import React, { useRef } from "react";
|
|
2
3
|
import { Pressable, View } from "react-native";
|
|
3
4
|
import Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
@@ -46,15 +47,7 @@ function ZSPressable({ onPress, onLongPress, isAnimation = true, pressedBackgrou
|
|
|
46
47
|
borderRadius: pressedBackgroundBorderRadius,
|
|
47
48
|
};
|
|
48
49
|
};
|
|
49
|
-
return (
|
|
50
|
-
<Pressable {...props} onPress={handlePress} onLongPress={handleLongPress} onPressIn={handlePressIn} onPressOut={handlePressOut} disabled={isLoading || disabled} style={({ pressed }) => handlePressStyle(pressed)}>
|
|
51
|
-
<Animated.View style={boxAnimation}>
|
|
52
|
-
<AnimatedWrapper color={color} isAnimation={isAnimation} elevationLevel={elevationLevel} style={props.style}>
|
|
53
|
-
{props.children}
|
|
54
|
-
</AnimatedWrapper>
|
|
55
|
-
</Animated.View>
|
|
56
|
-
</Pressable>
|
|
57
|
-
</View>);
|
|
50
|
+
return (_jsx(View, { style: [fullWidth ? { width: '100%' } : undefined, { opacity: (isLoading || disabled) ? 0.55 : 1 }], children: _jsx(Pressable, { ...props, onPress: handlePress, onLongPress: handleLongPress, onPressIn: handlePressIn, onPressOut: handlePressOut, disabled: isLoading || disabled, style: ({ pressed }) => handlePressStyle(pressed), children: _jsx(Animated.View, { style: boxAnimation, children: _jsx(AnimatedWrapper, { color: color, isAnimation: isAnimation, elevationLevel: elevationLevel, style: props.style, children: props.children }) }) }) }));
|
|
58
51
|
}
|
|
59
52
|
export default React.memo(ZSPressable);
|
|
60
53
|
//# sourceMappingURL=index.js.map
|
|
@@ -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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,EAAE,6BAA6B;aAC5C;YACD,CAAC,CAAC;gBACA,eAAe,EAAE,aAAa;gBAC9B,YAAY,EAAE,6BAA6B;aAC5C,CAAC;IACN,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,IAAI,IAAC,KAAK,EAAE,CAAC,SAAS,CAAC,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 // ------------------------------------------------------------\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 // ------------------------------------------------------------\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"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, memo } from 'react';
|
|
2
3
|
import ViewAtom from '../atoms/ViewAtom';
|
|
3
4
|
import ZSText from '../ZSText';
|
|
4
5
|
import ZSPressable from '../ZSPressable';
|
|
@@ -12,18 +13,17 @@ function ZSRadioGroup({ options, value, onSelect, containerStyle, valueStyle, di
|
|
|
12
13
|
onSelect(option);
|
|
13
14
|
}
|
|
14
15
|
}, [disabled, onSelect]);
|
|
15
|
-
return (
|
|
16
|
+
return (_jsx(ViewAtom, { style: {
|
|
16
17
|
flexDirection: isFullWidth ? 'column' : 'row',
|
|
17
18
|
flexWrap: isFullWidth ? 'nowrap' : 'wrap',
|
|
18
19
|
width: '100%',
|
|
19
|
-
}
|
|
20
|
-
{options.map((option, index) => {
|
|
20
|
+
}, ...containerStyle, ...props, children: options.map((option, index) => {
|
|
21
21
|
const isSelected = value?.index === option.index;
|
|
22
22
|
const setColor = isSelected ? palette.primary.light : palette.background.neutral;
|
|
23
23
|
const colCount = rowCount;
|
|
24
24
|
const isLastCol = (index + 1) % colCount === 0;
|
|
25
25
|
const isLastRow = Math.ceil((index + 1) / colCount) === Math.ceil(options.length / colCount);
|
|
26
|
-
return (
|
|
26
|
+
return (_jsx(ViewAtom, { style: {
|
|
27
27
|
width: rowCount === 2
|
|
28
28
|
? '50%'
|
|
29
29
|
: rowCount === 3
|
|
@@ -32,65 +32,42 @@ function ZSRadioGroup({ options, value, onSelect, containerStyle, valueStyle, di
|
|
|
32
32
|
paddingRight: isFullWidth ? 0 : isLastCol ? 0 : 3,
|
|
33
33
|
paddingLeft: isFullWidth ? 0 : isLastCol ? 3 : 0,
|
|
34
34
|
paddingBottom: isLastRow ? 0 : 10,
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{/* fullWidth가 true일 때 우측에 선택 버튼 표시 */}
|
|
73
|
-
{isFullWidth && (<ViewAtom style={{
|
|
74
|
-
backgroundColor: isSelected
|
|
75
|
-
? palette.primary.main
|
|
76
|
-
: palette.background.layer2,
|
|
77
|
-
paddingHorizontal: 10,
|
|
78
|
-
borderRadius: 100,
|
|
79
|
-
minWidth: 42,
|
|
80
|
-
minHeight: 24,
|
|
81
|
-
justifyContent: 'center',
|
|
82
|
-
alignItems: 'center',
|
|
83
|
-
flexShrink: 0,
|
|
84
|
-
}}>
|
|
85
|
-
{isSelected ? (<SvgCheck size={18}/>) : (<ZSText typo="body.5" numberOfLines={1} {...selectStyle}>
|
|
86
|
-
{selectLabel}
|
|
87
|
-
</ZSText>)}
|
|
88
|
-
</ViewAtom>)}
|
|
89
|
-
</ViewAtom>
|
|
90
|
-
</ZSPressable>
|
|
91
|
-
</ViewAtom>);
|
|
92
|
-
})}
|
|
93
|
-
</ViewAtom>);
|
|
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));
|
|
70
|
+
}) }));
|
|
94
71
|
}
|
|
95
72
|
export default memo(ZSRadioGroup);
|
|
96
73
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSRadioGroup/index.tsx"],"names":[],"mappings":"AAAA,
|
|
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;AAGjD,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,SAAS,YAAY,CAAC,EACpB,OAAO,EACP,KAAK,EACL,QAAQ,EACR,cAAc,EACd,UAAU,EACV,QAAQ,GAAG,KAAK,EAChB,WAAW,EACX,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,CAAC,EACZ,GAAG,KAAK,EAWG;IACX,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC/B,MAAM,WAAW,GAAG,QAAQ,KAAK,CAAC,CAAC;IAEnC,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,MAAmB,EAAE,EAAE;QACvD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,QAAQ,CAAC,MAAM,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEzB,OAAO,CACL,KAAC,QAAQ,IACP,KAAK,EAAE;YACL,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK;YAC7C,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM;YACzC,KAAK,EAAE,MAAM;SACd,KACG,cAAc,KACd,KAAK,YA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QAAQ;oCACxB,UAAU,EAAE,QAAQ;oCACpB,UAAU,EAAE,CAAC;iCACd,YAEA,UAAU,CAAC,CAAC,CAAC,CACZ,KAAC,QAAQ,IAAC,IAAI,EAAE,EAAE,GAAI,CACvB,CAAC,CAAC,CAAC,CACF,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,aAAa,EAAE,CAAC,KAAM,WAAW,YACpD,WAAW,GACL,CACV,GACQ,CACZ,IACQ,GACC,IApFD,MAAM,CAAC,KAAK,CAqFhB,CACZ,CAAC;QACJ,CAAC,CAAC,GACO,CACZ,CAAC;AACJ,CAAC;AAED,eAAe,IAAI,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import React, { useCallback, memo } from 'react';\nimport { 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\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}: {\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} & ViewProps) {\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={{\n flexDirection: isFullWidth ? 'column' : 'row',\n flexWrap: isFullWidth ? 'nowrap' : 'wrap',\n width: '100%',\n }}\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 const colCount = rowCount;\n const isLastCol = (index + 1) % colCount === 0;\n const isLastRow = Math.ceil((index + 1) / colCount) === Math.ceil(options.length / colCount);\n\n return (\n <ViewAtom key={option.index} style={{\n width: rowCount === 2\n ? '50%'\n : rowCount === 3\n ? '33.33%'\n : '100%',\n paddingRight: isFullWidth ? 0 : isLastCol ? 0 : 3,\n paddingLeft: isFullWidth ? 0 : isLastCol ? 3 : 0,\n paddingBottom: isLastRow ? 0 : 10,\n }}>\n <ZSPressable\n onPress={() => handleSelect(option)}\n pressedBackgroundColor=\"transparent\"\n fullWidth\n >\n <ViewAtom\n style={{\n flexDirection: 'row',\n alignItems: 'center',\n paddingVertical: 12,\n borderWidth: 1,\n paddingLeft: 10,\n paddingRight: 15,\n borderRadius: 100,\n borderColor: setColor,\n backgroundColor: isSelected ? palette.background.layer1 : 'transparent',\n }}\n >\n {/* fullWidth가 false일 때 동그라미 체크박스 표시 */}\n {!(isFullWidth) && (\n <ViewAtom\n style={{\n width: 20,\n height: 20,\n borderWidth: 1,\n borderRadius: 10,\n borderColor: setColor,\n justifyContent: 'center',\n alignItems: 'center',\n }}\n >\n <ViewAtom\n style={{\n width: 12,\n height: 12,\n borderRadius: 6,\n backgroundColor: setColor,\n }}\n />\n </ViewAtom>\n )}\n {/* 옵션 텍스트 표시 */}\n <ViewAtom style={{ flex: 1, paddingLeft: 10, paddingRight: 12, minWidth: 0 }}>\n <ZSText {...valueStyle}>\n {option.value}\n </ZSText>\n </ViewAtom>\n\n {/* fullWidth가 true일 때 우측에 선택 버튼 표시 */}\n {isFullWidth && (\n <ViewAtom\n style={{\n backgroundColor: isSelected\n ? palette.primary.main\n : palette.background.layer2,\n paddingHorizontal: 10,\n borderRadius: 100,\n minWidth: 42,\n minHeight: 24,\n justifyContent: 'center',\n alignItems: 'center',\n flexShrink: 0,\n }}\n >\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 </ViewAtom>\n );\n}\n\nexport default memo(ZSRadioGroup);\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from "react";
|
|
2
3
|
import { Dimensions, StyleSheet, View } from "react-native";
|
|
3
4
|
import Animated, { useSharedValue, useAnimatedStyle, withRepeat, withTiming, cancelAnimation } from "react-native-reanimated";
|
|
4
5
|
import { useTheme } from "../../context/ThemeContext";
|
|
@@ -24,17 +25,7 @@ function ZSSkeleton({ isFetching, style, children, overlayColor, ...props }) {
|
|
|
24
25
|
transform: [{ translateX: translateX.value }],
|
|
25
26
|
};
|
|
26
27
|
});
|
|
27
|
-
return isFetching ? (
|
|
28
|
-
<View style={styles.container}>
|
|
29
|
-
{children}
|
|
30
|
-
|
|
31
|
-
<Animated.View style={[styles.shimmer, animatedStyle]}>
|
|
32
|
-
<View style={[styles.shimmerSub, { backgroundColor: effectColor }]}/>
|
|
33
|
-
<View style={[styles.shimmerCenter, { backgroundColor: effectColor }]}/>
|
|
34
|
-
<View style={[styles.shimmerSub, { backgroundColor: effectColor }]}/>
|
|
35
|
-
</Animated.View>
|
|
36
|
-
</View>
|
|
37
|
-
</View>) : (children);
|
|
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);
|
|
38
29
|
}
|
|
39
30
|
export default ZSSkeleton;
|
|
40
31
|
const styles = StyleSheet.create({
|
|
@@ -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,OAAc,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,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;AASpD,SAAS,UAAU,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,KAAK,EAAmB;IACxF,MAAM,UAAU,GAAG,cAAc,CAAC,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC;IACvD,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC/B,MAAM,WAAW,GAAG,YAAY,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;IAE5D,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,UAAU,EAAE,CAAC;YACb,UAAU,CAAC,KAAK,GAAG,UAAU,CAAC,UAAU,CAAC,YAAY,GAAG,GAAG,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QAChG,CAAC;aAAM,CAAC;YACJ,eAAe,CAAC,UAAU,CAAC,CAAC;YAC5B,UAAU,CAAC,KAAK,GAAG,CAAC,YAAY,GAAG,GAAG,CAAC;QAC3C,CAAC;QAED,OAAO,GAAG,EAAE;Y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Aa,EAAE,KAAK;KACvB;IACD,UAAU,EAAE;QACR,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,GAAG;QACZ,KAAK,EAAE,YAAY,GAAG,GAAG;KAC5B;IACD,aAAa,EAAE;QACX,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,GAAG;QACZ,KAAK,EAAE,YAAY,GAAG,GAAG;KAC5B;CACJ,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 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"]}
|