@0610studio/zs-ui 0.18.1 → 0.19.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/assets/SvgTooltipTail.d.ts +7 -0
- package/build/assets/SvgTooltipTail.d.ts.map +1 -0
- package/build/assets/SvgTooltipTail.js +7 -0
- package/build/assets/SvgTooltipTail.js.map +1 -0
- package/build/context/ThemeContext.d.ts.map +1 -1
- package/build/context/ThemeContext.js +17 -5
- package/build/context/ThemeContext.js.map +1 -1
- package/build/index.d.ts +15 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +7 -1
- package/build/index.js.map +1 -1
- package/build/model/types.d.ts +1 -0
- package/build/model/types.d.ts.map +1 -1
- package/build/model/types.js.map +1 -1
- package/build/model/useFoldingState.d.ts.map +1 -1
- package/build/model/useFoldingState.js +51 -32
- package/build/model/useFoldingState.js.map +1 -1
- package/build/overlay/AlertOverlay/index.d.ts +1 -2
- package/build/overlay/AlertOverlay/index.d.ts.map +1 -1
- package/build/overlay/AlertOverlay/index.js +11 -9
- 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 +4 -3
- package/build/overlay/BottomSheetOverlay/index.js.map +1 -1
- package/build/overlay/LoadingNotify/index.d.ts +2 -2
- package/build/overlay/LoadingNotify/index.d.ts.map +1 -1
- package/build/overlay/LoadingNotify/index.js +2 -2
- package/build/overlay/LoadingNotify/index.js.map +1 -1
- package/build/overlay/Modality/index.d.ts.map +1 -1
- package/build/overlay/Modality/index.js +3 -3
- 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 +5 -3
- package/build/overlay/PopOver/PopOverMenu.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/theme/intentColors.d.ts +9 -0
- package/build/theme/intentColors.d.ts.map +1 -0
- package/build/theme/intentColors.js +30 -0
- package/build/theme/intentColors.js.map +1 -0
- package/build/theme/tokens.d.ts +35 -0
- package/build/theme/tokens.d.ts.map +1 -0
- package/build/theme/tokens.js +35 -0
- package/build/theme/tokens.js.map +1 -0
- package/build/theme/typography.d.ts.map +1 -1
- package/build/theme/typography.js +36 -72
- package/build/theme/typography.js.map +1 -1
- package/build/ui/ZSBlockButton/index.d.ts.map +1 -1
- package/build/ui/ZSBlockButton/index.js +4 -19
- package/build/ui/ZSBlockButton/index.js.map +1 -1
- package/build/ui/ZSBorderBeam/index.d.ts +48 -0
- package/build/ui/ZSBorderBeam/index.d.ts.map +1 -0
- package/build/ui/ZSBorderBeam/index.js +136 -0
- package/build/ui/ZSBorderBeam/index.js.map +1 -0
- package/build/ui/ZSCheckBox/index.d.ts +18 -0
- package/build/ui/ZSCheckBox/index.d.ts.map +1 -0
- package/build/ui/ZSCheckBox/index.js +60 -0
- package/build/ui/ZSCheckBox/index.js.map +1 -0
- package/build/ui/ZSChip/index.d.ts +28 -0
- package/build/ui/ZSChip/index.d.ts.map +1 -0
- package/build/ui/ZSChip/index.js +76 -0
- package/build/ui/ZSChip/index.js.map +1 -0
- package/build/ui/ZSContainer/index.d.ts +0 -1
- package/build/ui/ZSContainer/index.d.ts.map +1 -1
- package/build/ui/ZSContainer/index.js +3 -2
- package/build/ui/ZSContainer/index.js.map +1 -1
- package/build/ui/ZSPressable/index.d.ts.map +1 -1
- package/build/ui/ZSPressable/index.js +9 -4
- package/build/ui/ZSPressable/index.js.map +1 -1
- package/build/ui/ZSRadioGroup/index.d.ts +2 -3
- package/build/ui/ZSRadioGroup/index.d.ts.map +1 -1
- package/build/ui/ZSRadioGroup/index.js +12 -4
- package/build/ui/ZSRadioGroup/index.js.map +1 -1
- package/build/ui/ZSSegmented/index.d.ts +26 -0
- package/build/ui/ZSSegmented/index.d.ts.map +1 -0
- package/build/ui/ZSSegmented/index.js +124 -0
- package/build/ui/ZSSegmented/index.js.map +1 -0
- package/build/ui/ZSSkeleton/SkiaShimmer.d.ts +18 -0
- package/build/ui/ZSSkeleton/SkiaShimmer.d.ts.map +1 -0
- package/build/ui/ZSSkeleton/SkiaShimmer.js +73 -0
- package/build/ui/ZSSkeleton/SkiaShimmer.js.map +1 -0
- package/build/ui/ZSSkeleton/index.d.ts +7 -2
- package/build/ui/ZSSkeleton/index.d.ts.map +1 -1
- package/build/ui/ZSSkeleton/index.js +12 -43
- package/build/ui/ZSSkeleton/index.js.map +1 -1
- package/build/ui/ZSSkeletonBox/index.d.ts +8 -2
- package/build/ui/ZSSkeletonBox/index.d.ts.map +1 -1
- package/build/ui/ZSSkeletonBox/index.js +6 -46
- 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 +6 -4
- package/build/ui/ZSSwitch/index.js.map +1 -1
- package/build/ui/ZSTextField/index.d.ts.map +1 -1
- package/build/ui/ZSTextField/index.js +17 -13
- package/build/ui/ZSTextField/index.js.map +1 -1
- package/build/ui/ZSTextField/ui/ButtonClose.d.ts.map +1 -1
- package/build/ui/ZSTextField/ui/ButtonClose.js +4 -1
- package/build/ui/ZSTextField/ui/ButtonClose.js.map +1 -1
- package/build/ui/ZSTooltip/index.d.ts +38 -0
- package/build/ui/ZSTooltip/index.d.ts.map +1 -0
- package/build/ui/ZSTooltip/index.js +99 -0
- package/build/ui/ZSTooltip/index.js.map +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
import { Pressable, StyleSheet } from 'react-native';
|
|
4
|
+
import ViewAtom from '../atoms/ViewAtom';
|
|
5
|
+
import ZSText from '../ZSText';
|
|
6
|
+
import { useTheme } from '../../context/ThemeContext';
|
|
7
|
+
import { DISABLED_OPACITY, RADIUS } from '../../theme/tokens';
|
|
8
|
+
import { SvgCheck } from '../../assets/SvgCheck';
|
|
9
|
+
// size 기본값(18) 기준 곡률·보더 비율 유지용
|
|
10
|
+
const BASE_SIZE = 18;
|
|
11
|
+
const BASE_BORDER_WIDTH = 1.6;
|
|
12
|
+
function ZSCheckBox({ value, onChange, size = 18, activeColor, label, labelStyle, labelComponent, moreComponent, disabled = false, style, ...props }) {
|
|
13
|
+
const { palette } = useTheme();
|
|
14
|
+
const checkedColor = activeColor ?? palette.primary.main;
|
|
15
|
+
const handlePress = useCallback(() => {
|
|
16
|
+
if (!disabled) {
|
|
17
|
+
onChange(!value);
|
|
18
|
+
}
|
|
19
|
+
}, [disabled, onChange, value]);
|
|
20
|
+
return (_jsxs(ViewAtom, { style: [styles.container, disabled && styles.disabled, style], ...props, children: [_jsxs(Pressable, { onPress: handlePress, disabled: disabled, style: styles.checkContainer, accessibilityRole: 'checkbox', accessibilityState: { checked: value, disabled }, children: [_jsx(ViewAtom, { style: [
|
|
21
|
+
styles.box,
|
|
22
|
+
{
|
|
23
|
+
width: size,
|
|
24
|
+
height: size,
|
|
25
|
+
borderRadius: RADIUS.xs * (size / BASE_SIZE),
|
|
26
|
+
borderWidth: BASE_BORDER_WIDTH * (size / BASE_SIZE),
|
|
27
|
+
backgroundColor: value ? checkedColor : 'transparent',
|
|
28
|
+
borderColor: value ? checkedColor : palette.grey[30],
|
|
29
|
+
},
|
|
30
|
+
], children: value && (_jsx(ViewAtom, { style: styles.checkmark, children: _jsx(SvgCheck, { size: size - 4, strokeWidth: "3.5" }) })) }), labelComponent ?? (label !== undefined && _jsx(ZSText, { ...labelStyle, children: label }))] }), moreComponent] }));
|
|
31
|
+
}
|
|
32
|
+
const styles = StyleSheet.create({
|
|
33
|
+
container: {
|
|
34
|
+
width: '100%',
|
|
35
|
+
flexDirection: 'row',
|
|
36
|
+
alignItems: 'center',
|
|
37
|
+
justifyContent: 'space-between',
|
|
38
|
+
},
|
|
39
|
+
disabled: {
|
|
40
|
+
opacity: DISABLED_OPACITY,
|
|
41
|
+
},
|
|
42
|
+
checkContainer: {
|
|
43
|
+
flex: 1,
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
flexDirection: 'row',
|
|
46
|
+
paddingVertical: 2,
|
|
47
|
+
gap: 12,
|
|
48
|
+
},
|
|
49
|
+
box: {
|
|
50
|
+
justifyContent: 'center',
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
},
|
|
53
|
+
checkmark: {
|
|
54
|
+
position: 'absolute',
|
|
55
|
+
justifyContent: 'center',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
export default React.memo(ZSCheckBox);
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSCheckBox/index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAa,MAAM,cAAc,CAAC;AAChE,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,MAAuB,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,+BAA+B;AAC/B,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAc9B,SAAS,UAAU,CAAC,EAClB,K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O,CAAC,IAAI,CAAC,EAAE,CAAC;6BACrD;yBACF,YAEA,KAAK,IAAI,CACR,KAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,CAAC,SAAS,YAC/B,KAAC,QAAQ,IAAC,IAAI,EAAE,IAAI,GAAG,CAAC,EAAE,WAAW,EAAC,KAAK,GAAG,GACrC,CACZ,GACQ,EACV,cAAc,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,KAAC,MAAM,OAAK,UAAU,YAAG,KAAK,GAAU,CAAC,IAC1E,EACX,aAAa,IACL,CACZ,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,KAAK,EAAE,MAAM;QACb,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,eAAe;KAChC;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,gBAAgB;KAC1B;IACD,cAAc,EAAE;QACd,IAAI,EAAE,CAAC;QACP,UAAU,EAAE,QAAQ;QACpB,aAAa,EAAE,KAAK;QACpB,eAAe,EAAE,CAAC;QAClB,GAAG,EAAE,EAAE;KACR;IACD,GAAG,EAAE;QACH,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;KACrB;IACD,SAAS,EAAE;QACT,QAAQ,EAAE,UAAU;QACpB,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;KACrB;CACF,CAAC,CAAC;AAEH,eAAe,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import React, { useCallback } from 'react';\nimport { Pressable, StyleSheet, ViewProps } from 'react-native';\nimport ViewAtom from '../atoms/ViewAtom';\nimport ZSText, { ZSTextProps } from '../ZSText';\nimport { useTheme } from '../../context/ThemeContext';\nimport { DISABLED_OPACITY, RADIUS } from '../../theme/tokens';\nimport { SvgCheck } from '../../assets/SvgCheck';\n\n// size 기본값(18) 기준 곡률·보더 비율 유지용\nconst BASE_SIZE = 18;\nconst BASE_BORDER_WIDTH = 1.6;\n\nexport interface ZSCheckBoxProps extends ViewProps {\n value: boolean;\n onChange: (value: boolean) => void;\n size?: number;\n activeColor?: string;\n label?: string;\n labelStyle?: ZSTextProps;\n labelComponent?: React.ReactNode;\n moreComponent?: React.ReactNode;\n disabled?: boolean;\n}\n\nfunction ZSCheckBox({\n value,\n onChange,\n size = 18,\n activeColor,\n label,\n labelStyle,\n labelComponent,\n moreComponent,\n disabled = false,\n style,\n ...props\n}: ZSCheckBoxProps) {\n const { palette } = useTheme();\n const checkedColor = activeColor ?? palette.primary.main;\n\n const handlePress = useCallback(() => {\n if (!disabled) {\n onChange(!value);\n }\n }, [disabled, onChange, value]);\n\n return (\n <ViewAtom style={[styles.container, disabled && styles.disabled, style]} {...props}>\n <Pressable\n onPress={handlePress}\n disabled={disabled}\n style={styles.checkContainer}\n accessibilityRole='checkbox'\n accessibilityState={{ checked: value, disabled }}\n >\n <ViewAtom\n style={[\n styles.box,\n {\n width: size,\n height: size,\n borderRadius: RADIUS.xs * (size / BASE_SIZE),\n borderWidth: BASE_BORDER_WIDTH * (size / BASE_SIZE),\n backgroundColor: value ? checkedColor : 'transparent',\n borderColor: value ? checkedColor : palette.grey[30],\n },\n ]}\n >\n {value && (\n <ViewAtom style={styles.checkmark}>\n <SvgCheck size={size - 4} strokeWidth=\"3.5\" />\n </ViewAtom>\n )}\n </ViewAtom>\n {labelComponent ?? (label !== undefined && <ZSText {...labelStyle}>{label}</ZSText>)}\n </Pressable>\n {moreComponent}\n </ViewAtom>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n width: '100%',\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-between',\n },\n disabled: {\n opacity: DISABLED_OPACITY,\n },\n checkContainer: {\n flex: 1,\n alignItems: 'center',\n flexDirection: 'row',\n paddingVertical: 2,\n gap: 12,\n },\n box: {\n justifyContent: 'center',\n alignItems: 'center',\n },\n checkmark: {\n position: 'absolute',\n justifyContent: 'center',\n alignItems: 'center',\n },\n});\n\nexport default React.memo(ZSCheckBox);\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type StyleProp, type ViewProps, type ViewStyle } from "react-native";
|
|
3
|
+
import type { IntentOptions, TypoSubStyle } from "../../theme/types";
|
|
4
|
+
export type ZSChipVariant = 'pastel' | 'solid' | 'stroke';
|
|
5
|
+
export interface ZSChipProps extends ViewProps {
|
|
6
|
+
/** 칩 라벨 */
|
|
7
|
+
label: string;
|
|
8
|
+
/** 선택 상태를 외부에서 제어할 때 사용 (미지정 시 내부 상태로 토글) */
|
|
9
|
+
selected?: boolean;
|
|
10
|
+
/** 비제어 모드의 초기 선택 상태 */
|
|
11
|
+
initialSelected?: boolean;
|
|
12
|
+
/** 토글 시 다음 선택 상태를 전달 */
|
|
13
|
+
onChange?: (selected: boolean) => void;
|
|
14
|
+
intent?: IntentOptions;
|
|
15
|
+
/** 선택 상태 스타일 (기본: pastel) */
|
|
16
|
+
variant?: ZSChipVariant;
|
|
17
|
+
textSize?: TypoSubStyle;
|
|
18
|
+
/** true면 선택 시 체크 아이콘 표시 */
|
|
19
|
+
checkIcon?: boolean;
|
|
20
|
+
/** 라벨 왼쪽 커스텀 요소 */
|
|
21
|
+
leftIcon?: React.ReactNode;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
style?: StyleProp<ViewStyle>;
|
|
24
|
+
}
|
|
25
|
+
declare function ZSChip({ label, selected, initialSelected, onChange, intent, variant, textSize, checkIcon, leftIcon, disabled, style, ...props }: ZSChipProps): React.JSX.Element;
|
|
26
|
+
declare const _default: React.MemoExoticComponent<typeof ZSChip>;
|
|
27
|
+
export default _default;
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSChip/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAAyB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAMrG,OAAO,KAAK,EAAE,aAAa,EAAoB,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAQvF,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;AAO1D,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,WAAW;IACX,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uBAAuB;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,wBAAwB;IACxB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mBAAmB;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,iBAAS,MAAM,CAAC,EACd,KAAK,EACL,QAAQ,EACR,eAAuB,EACvB,QAAQ,EACR,MAAkB,EAClB,OAAkB,EAClB,QAAc,EACd,SAAiB,EACjB,QAAQ,EACR,QAAgB,EAChB,KAAK,EACL,GAAG,KAAK,EACT,EAAE,WAAW,qBAiFb;;AAED,wBAAkC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
import { Pressable, StyleSheet } from "react-native";
|
|
4
|
+
import Animated, { Easing, interpolateColor, useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
5
|
+
import ZSText from "../ZSText";
|
|
6
|
+
import { useTheme } from "../../context/ThemeContext";
|
|
7
|
+
import { resolveTextColor } from "../../theme/resolveColor";
|
|
8
|
+
import { SvgCheck } from "../../assets/SvgCheck";
|
|
9
|
+
import { PASTEL_TEXT_COLOR, SOLID_TEXT_COLOR, STROKE_TEXT_COLOR } from "../../theme/intentColors";
|
|
10
|
+
import { DISABLED_OPACITY, DURATION, RADIUS } from "../../theme/tokens";
|
|
11
|
+
const ANIMATION_DURATION = DURATION.base;
|
|
12
|
+
const PRESS_DURATION = DURATION.press;
|
|
13
|
+
const PRESS_SCALE = 0.04;
|
|
14
|
+
// typo 크기(subStyle)별 패딩 · 체크 아이콘 크기
|
|
15
|
+
const PADDING_HORIZONTAL = { '1': 18, '2': 16, '3': 14, '4': 12, '5': 10, '6': 9 };
|
|
16
|
+
const PADDING_VERTICAL = { '1': 10, '2': 9, '3': 8, '4': 7, '5': 5, '6': 4 };
|
|
17
|
+
const CHECK_ICON_SIZE = { '1': 18, '2': 17, '3': 15, '4': 14, '5': 12, '6': 11 };
|
|
18
|
+
function ZSChip({ label, selected, initialSelected = false, onChange, intent = 'primary', variant = 'pastel', textSize = '3', checkIcon = false, leftIcon, disabled = false, style, ...props }) {
|
|
19
|
+
const { palette } = useTheme();
|
|
20
|
+
const [internalSelected, setInternalSelected] = useState(initialSelected);
|
|
21
|
+
const isSelected = selected ?? internalSelected;
|
|
22
|
+
const progress = useSharedValue(isSelected ? 1 : 0);
|
|
23
|
+
const pressProgress = useSharedValue(0);
|
|
24
|
+
const unselectedBackground = palette.background.base;
|
|
25
|
+
const unselectedBorder = palette.grey[30];
|
|
26
|
+
const selectedColors = variant === 'solid'
|
|
27
|
+
? { background: palette[intent][50], border: palette[intent][50], text: SOLID_TEXT_COLOR[intent] }
|
|
28
|
+
: variant === 'pastel'
|
|
29
|
+
? { background: palette[intent][10], border: palette[intent][30], text: PASTEL_TEXT_COLOR[intent] }
|
|
30
|
+
: { background: unselectedBackground, border: palette[intent][50], text: STROKE_TEXT_COLOR[intent] };
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
progress.value = withTiming(isSelected ? 1 : 0, {
|
|
33
|
+
duration: ANIMATION_DURATION,
|
|
34
|
+
easing: Easing.out(Easing.quad),
|
|
35
|
+
});
|
|
36
|
+
}, [isSelected, progress]);
|
|
37
|
+
const chipAnimatedStyle = useAnimatedStyle(() => ({
|
|
38
|
+
backgroundColor: interpolateColor(progress.value, [0, 1], [unselectedBackground, selectedColors.background]),
|
|
39
|
+
borderColor: interpolateColor(progress.value, [0, 1], [unselectedBorder, selectedColors.border]),
|
|
40
|
+
transform: [{ scale: 1 - pressProgress.value * PRESS_SCALE }],
|
|
41
|
+
}));
|
|
42
|
+
const handlePress = () => {
|
|
43
|
+
if (disabled)
|
|
44
|
+
return;
|
|
45
|
+
const next = !isSelected;
|
|
46
|
+
if (selected === undefined)
|
|
47
|
+
setInternalSelected(next);
|
|
48
|
+
onChange?.(next);
|
|
49
|
+
};
|
|
50
|
+
const textColor = isSelected ? selectedColors.text : 'secondary';
|
|
51
|
+
return (_jsx(Pressable, { onPress: handlePress, onPressIn: () => { pressProgress.value = withTiming(1, { duration: PRESS_DURATION }); }, onPressOut: () => { pressProgress.value = withTiming(0, { duration: PRESS_DURATION }); }, disabled: disabled, accessibilityRole: 'button', accessibilityState: { selected: isSelected, disabled }, style: styles.pressable, ...props, children: _jsxs(Animated.View, { style: [
|
|
52
|
+
styles.chip,
|
|
53
|
+
{
|
|
54
|
+
paddingHorizontal: PADDING_HORIZONTAL[textSize],
|
|
55
|
+
paddingVertical: PADDING_VERTICAL[textSize],
|
|
56
|
+
opacity: disabled ? DISABLED_OPACITY : 1,
|
|
57
|
+
},
|
|
58
|
+
chipAnimatedStyle,
|
|
59
|
+
style,
|
|
60
|
+
], children: [leftIcon, checkIcon && isSelected && (_jsx(Animated.View, { testID: 'zs-chip-check', children: _jsx(SvgCheck, { size: CHECK_ICON_SIZE[textSize], color: resolveTextColor(palette, textColor), strokeWidth: '2.4' }) })), _jsx(ZSText, { typo: `body.${textSize}`, color: textColor, allowFontScaling: false, numberOfLines: 1, children: label })] }) }));
|
|
61
|
+
}
|
|
62
|
+
export default React.memo(ZSChip);
|
|
63
|
+
const styles = StyleSheet.create({
|
|
64
|
+
// flexWrap 부모에서 콘텐츠 폭으로 렌더링되도록 hug
|
|
65
|
+
pressable: {
|
|
66
|
+
alignSelf: 'flex-start',
|
|
67
|
+
},
|
|
68
|
+
chip: {
|
|
69
|
+
flexDirection: 'row',
|
|
70
|
+
alignItems: 'center',
|
|
71
|
+
gap: 5,
|
|
72
|
+
borderWidth: 1,
|
|
73
|
+
borderRadius: RADIUS.pill,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSChip/index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAkD,MAAM,cAAc,CAAC;AACrG,OAAO,QAAQ,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC3H,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,QAA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,MAAM,CAAC,SAAS,KACnB,KAAK,YAET,MAAC,QAAQ,CAAC,IAAI,IACZ,KAAK,EAAE;gBACL,MAAM,CAAC,IAAI;gBACX;oBACE,iBAAiB,EAAE,kBAAkB,CAAC,QAAQ,CAAC;oBAC/C,eAAe,EAAE,gBAAgB,CAAC,QAAQ,CAAC;oBAC3C,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;iBACzC;gBACD,iBAAiB;gBACjB,KAAK;aACN,aAEA,QAAQ,EACR,SAAS,IAAI,UAAU,IAAI,CAC1B,KAAC,QAAQ,CAAC,IAAI,IAAC,MAAM,EAAC,eAAe,YACnC,KAAC,QAAQ,IACP,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,EAC/B,KAAK,EAAE,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,EAC3C,WAAW,EAAC,KAAK,GACjB,GACY,CACjB,EACD,KAAC,MAAM,IACL,IAAI,EAAE,QAAQ,QAAQ,EAAE,EACxB,KAAK,EAAE,SAAS,EAChB,gBAAgB,EAAE,KAAK,EACvB,aAAa,EAAE,CAAC,YAEf,KAAK,GACC,IACK,GACN,CACb,CAAC;AACJ,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAElC,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,mCAAmC;IACnC,SAAS,EAAE;QACT,SAAS,EAAE,YAAY;KACxB;IACD,IAAI,EAAE;QACJ,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,QAAQ;QACpB,GAAG,EAAE,CAAC;QACN,WAAW,EAAE,CAAC;QACd,YAAY,EAAE,MAAM,CAAC,IAAI;KAC1B;CACF,CAAC,CAAC","sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport { Pressable, StyleSheet, type StyleProp, type ViewProps, type ViewStyle } from \"react-native\";\nimport Animated, { Easing, interpolateColor, useAnimatedStyle, useSharedValue, withTiming } from \"react-native-reanimated\";\nimport ZSText from \"../ZSText\";\nimport { useTheme } from \"../../context/ThemeContext\";\nimport { resolveTextColor } from \"../../theme/resolveColor\";\nimport { SvgCheck } from \"../../assets/SvgCheck\";\nimport type { IntentOptions, TypoColorOptions, TypoSubStyle } from \"../../theme/types\";\nimport { PASTEL_TEXT_COLOR, SOLID_TEXT_COLOR, STROKE_TEXT_COLOR } from \"../../theme/intentColors\";\nimport { DISABLED_OPACITY, DURATION, RADIUS } from \"../../theme/tokens\";\n\nconst ANIMATION_DURATION = DURATION.base;\nconst PRESS_DURATION = DURATION.press;\nconst PRESS_SCALE = 0.04;\n\nexport type ZSChipVariant = 'pastel' | 'solid' | 'stroke';\n\n// typo 크기(subStyle)별 패딩 · 체크 아이콘 크기\nconst PADDING_HORIZONTAL: Record<TypoSubStyle, number> = { '1': 18, '2': 16, '3': 14, '4': 12, '5': 10, '6': 9 };\nconst PADDING_VERTICAL: Record<TypoSubStyle, number> = { '1': 10, '2': 9, '3': 8, '4': 7, '5': 5, '6': 4 };\nconst CHECK_ICON_SIZE: Record<TypoSubStyle, number> = { '1': 18, '2': 17, '3': 15, '4': 14, '5': 12, '6': 11 };\n\nexport interface ZSChipProps extends ViewProps {\n /** 칩 라벨 */\n label: string;\n /** 선택 상태를 외부에서 제어할 때 사용 (미지정 시 내부 상태로 토글) */\n selected?: boolean;\n /** 비제어 모드의 초기 선택 상태 */\n initialSelected?: boolean;\n /** 토글 시 다음 선택 상태를 전달 */\n onChange?: (selected: boolean) => void;\n intent?: IntentOptions;\n /** 선택 상태 스타일 (기본: pastel) */\n variant?: ZSChipVariant;\n textSize?: TypoSubStyle;\n /** true면 선택 시 체크 아이콘 표시 */\n checkIcon?: boolean;\n /** 라벨 왼쪽 커스텀 요소 */\n leftIcon?: React.ReactNode;\n disabled?: boolean;\n style?: StyleProp<ViewStyle>;\n}\n\nfunction ZSChip({\n label,\n selected,\n initialSelected = false,\n onChange,\n intent = 'primary',\n variant = 'pastel',\n textSize = '3',\n checkIcon = false,\n leftIcon,\n disabled = false,\n style,\n ...props\n}: ZSChipProps) {\n const { palette } = useTheme();\n const [internalSelected, setInternalSelected] = useState(initialSelected);\n const isSelected = selected ?? internalSelected;\n const progress = useSharedValue(isSelected ? 1 : 0);\n const pressProgress = useSharedValue(0);\n\n const unselectedBackground = palette.background.base;\n const unselectedBorder = palette.grey[30];\n const selectedColors: { background: string; border: string; text: TypoColorOptions } = variant === 'solid'\n ? { background: palette[intent][50], border: palette[intent][50], text: SOLID_TEXT_COLOR[intent] }\n : variant === 'pastel'\n ? { background: palette[intent][10], border: palette[intent][30], text: PASTEL_TEXT_COLOR[intent] }\n : { background: unselectedBackground, border: palette[intent][50], text: STROKE_TEXT_COLOR[intent] };\n\n useEffect(() => {\n progress.value = withTiming(isSelected ? 1 : 0, {\n duration: ANIMATION_DURATION,\n easing: Easing.out(Easing.quad),\n });\n }, [isSelected, progress]);\n\n const chipAnimatedStyle = useAnimatedStyle(() => ({\n backgroundColor: interpolateColor(progress.value, [0, 1], [unselectedBackground, selectedColors.background]),\n borderColor: interpolateColor(progress.value, [0, 1], [unselectedBorder, selectedColors.border]),\n transform: [{ scale: 1 - pressProgress.value * PRESS_SCALE }],\n }));\n\n const handlePress = () => {\n if (disabled) return;\n const next = !isSelected;\n if (selected === undefined) setInternalSelected(next);\n onChange?.(next);\n };\n\n const textColor: TypoColorOptions = isSelected ? selectedColors.text : 'secondary';\n\n return (\n <Pressable\n onPress={handlePress}\n onPressIn={() => { pressProgress.value = withTiming(1, { duration: PRESS_DURATION }); }}\n onPressOut={() => { pressProgress.value = withTiming(0, { duration: PRESS_DURATION }); }}\n disabled={disabled}\n accessibilityRole='button'\n accessibilityState={{ selected: isSelected, disabled }}\n style={styles.pressable}\n {...props}\n >\n <Animated.View\n style={[\n styles.chip,\n {\n paddingHorizontal: PADDING_HORIZONTAL[textSize],\n paddingVertical: PADDING_VERTICAL[textSize],\n opacity: disabled ? DISABLED_OPACITY : 1,\n },\n chipAnimatedStyle,\n style,\n ]}\n >\n {leftIcon}\n {checkIcon && isSelected && (\n <Animated.View testID='zs-chip-check'>\n <SvgCheck\n size={CHECK_ICON_SIZE[textSize]}\n color={resolveTextColor(palette, textColor)}\n strokeWidth='2.4'\n />\n </Animated.View>\n )}\n <ZSText\n typo={`body.${textSize}`}\n color={textColor}\n allowFontScaling={false}\n numberOfLines={1}\n >\n {label}\n </ZSText>\n </Animated.View>\n </Pressable>\n );\n}\n\nexport default React.memo(ZSChip);\n\nconst styles = StyleSheet.create({\n // flexWrap 부모에서 콘텐츠 폭으로 렌더링되도록 hug\n pressable: {\n alignSelf: 'flex-start',\n },\n chip: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 5,\n borderWidth: 1,\n borderRadius: RADIUS.pill,\n },\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSContainer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAsF,MAAM,OAAO,CAAC;AAC7H,OAAO,EAAE,SAAS,EAAyB,UAAU,EAAE,oBAAoB,EAAE,iBAAiB,EAA6B,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSContainer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAsF,MAAM,OAAO,CAAC;AAC7H,OAAO,EAAE,SAAS,EAAyB,UAAU,EAAE,oBAAoB,EAAE,iBAAiB,EAA6B,MAAM,cAAc,CAAC;AAgBhJ,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG;IACzC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,eAAe,GAAG,cAAc,CAAC;IAC5C,KAAK,CAAC,EAAE,KAAK,CAAC,KAAK,GAAG,OAAO,GAAG,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{ StatusBar, StyleSheet, ScrollView, View, useWindowDimensions } from 'react-native';
|
|
4
4
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
5
5
|
import { useTheme } from '../../context/ThemeContext';
|
|
6
|
+
import { transparency } from '../../theme/palette';
|
|
6
7
|
import useKeyboard from '../../model/useKeyboard';
|
|
7
8
|
import useFoldingState from '../../model/useFoldingState';
|
|
8
9
|
import { FoldingState } from '../../model/types';
|
|
@@ -127,13 +128,13 @@ const ZSContainer = forwardRef(function ZSContainer({ backgroundColor, statusBar
|
|
|
127
128
|
},
|
|
128
129
|
], [innerMaxWidth, palette.background.base]);
|
|
129
130
|
const shouldShowStatusBar = useMemo(() => Boolean(barStyle || statusBarColor || translucent), [barStyle, statusBarColor, translucent]);
|
|
130
|
-
return (_jsxs(SafeAreaView, { style: safeAreaStyle, edges: edges, children: [_jsx(View, { style: styles.outerLayer, children: _jsxs(View, { style: innerContainerStyle, children: [topComponent, _jsxs(View, { style: styles.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 }))] }));
|
|
131
|
+
return (_jsxs(SafeAreaView, { style: safeAreaStyle, edges: edges, children: [_jsx(View, { style: [styles.outerLayer, { backgroundColor: palette.grey[100] + transparency['4%'] }], children: _jsxs(View, { style: innerContainerStyle, children: [topComponent, _jsxs(View, { style: styles.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 }))] }));
|
|
131
132
|
});
|
|
132
133
|
export const styles = StyleSheet.create({
|
|
133
134
|
flex1: { flex: 1 },
|
|
134
135
|
w100: { flex: 1, width: '100%' },
|
|
135
136
|
scrollContainerStyle: { alignItems: 'center', width: '100%', flexGrow: 1 },
|
|
136
|
-
outerLayer: { flex: 1, width: '100%'
|
|
137
|
+
outerLayer: { flex: 1, width: '100%' },
|
|
137
138
|
row: { flex: 1, width: '100%', flexDirection: 'row' },
|
|
138
139
|
});
|
|
139
140
|
export default ZSContainer;
|
|
@@ -1 +1 @@
|
|
|
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,IAAI,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAChJ,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;AAEjD,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;AA4BD,MAAM,WAAW,GAAG,UAAU,CAAmC,SAAS,WAAW,CACnF,EACE,eAAe,EACf,cAAc,EACd,QAAQ,EACR,KAAK,GAAG,CAAC,QAAQ,CAAC,EAClB,kBAAkB,GAAG,K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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;IAC1E,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,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
|
+
{"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,SAA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,EAAE,MAAM,EAAE;IACtC,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 { transparency } from '../../theme/palette';\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 {/* 테마 대응 딤 레이어 (light: 검정 4% · dark: 흰색 4%) */}\n <View style={[styles.outerLayer, { backgroundColor: palette.grey[100] + transparency['4%'] }]}>\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%' },\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;
|
|
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;AAM1D,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,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,iBAAS,WAAW,CAAC,EACnB,OAAO,EACP,WAAW,EACX,WAAkB,EAClB,sBAAsB,EACtB,6BAAyC,EACzC,cAAc,EACd,SAAiB,EACjB,KAAK,EACL,SAAiB,EACjB,QAAgB,EAChB,GAAG,KAAK,EACT,EAAE,gBAAgB,qBA4ElB;;AAED,wBAAuC"}
|
|
@@ -3,12 +3,17 @@ import React, { useRef } from "react";
|
|
|
3
3
|
import { Pressable, View } from "react-native";
|
|
4
4
|
import Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
5
5
|
import AnimatedWrapper from "../atoms/AnimatedWrapper";
|
|
6
|
-
|
|
6
|
+
import { useTheme } from "../../context/ThemeContext";
|
|
7
|
+
import { transparency } from "../../theme/palette";
|
|
8
|
+
import { DISABLED_OPACITY, DURATION, RADIUS } from "../../theme/tokens";
|
|
9
|
+
const DEFAULT_DURATION = { duration: DURATION.press };
|
|
7
10
|
const SCALE_VALUES = [1, 0.96];
|
|
8
11
|
const DEBOUNCE_TIME = 300;
|
|
9
|
-
function ZSPressable({ onPress, onLongPress, isAnimation = true, pressedBackgroundColor
|
|
12
|
+
function ZSPressable({ onPress, onLongPress, isAnimation = true, pressedBackgroundColor, pressedBackgroundBorderRadius = RADIUS.xl, elevationLevel, fullWidth = false, color, isLoading = false, disabled = false, ...props }) {
|
|
13
|
+
const { palette } = useTheme();
|
|
10
14
|
const isButtonPress = useSharedValue(0);
|
|
11
15
|
const lastClickTime = useRef(0);
|
|
16
|
+
const pressedBgColor = pressedBackgroundColor ?? palette.grey[50] + transparency['10%'];
|
|
12
17
|
const createPressHandler = (callback) => {
|
|
13
18
|
return () => {
|
|
14
19
|
const now = Date.now();
|
|
@@ -37,7 +42,7 @@ function ZSPressable({ onPress, onLongPress, isAnimation = true, pressedBackgrou
|
|
|
37
42
|
const handlePressStyle = (pressed) => {
|
|
38
43
|
return pressed
|
|
39
44
|
? {
|
|
40
|
-
backgroundColor:
|
|
45
|
+
backgroundColor: pressedBgColor,
|
|
41
46
|
borderRadius: pressedBackgroundBorderRadius,
|
|
42
47
|
}
|
|
43
48
|
: {
|
|
@@ -45,7 +50,7 @@ function ZSPressable({ onPress, onLongPress, isAnimation = true, pressedBackgrou
|
|
|
45
50
|
borderRadius: pressedBackgroundBorderRadius,
|
|
46
51
|
};
|
|
47
52
|
};
|
|
48
|
-
return (_jsx(View, { style: [fullWidth ? { width: '100%' } : undefined, { opacity: (isLoading || disabled) ?
|
|
53
|
+
return (_jsx(View, { style: [fullWidth ? { width: '100%' } : undefined, { opacity: (isLoading || disabled) ? DISABLED_OPACITY : 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 }) }) }) }));
|
|
49
54
|
}
|
|
50
55
|
export default React.memo(ZSPressable);
|
|
51
56
|
//# 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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YACZ,CAAC,CAAC;gBACA,eAAe,EAAE,cAAc;gBAC/B,YAAY,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,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,YAC5H,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 { useTheme } from \"../../context/ThemeContext\";\nimport { transparency } from \"../../theme/palette\";\nimport { DISABLED_OPACITY, DURATION, RADIUS } from \"../../theme/tokens\";\nimport type { ShadowLevel, ViewColorOptions } from \"../../theme/types\";\n\nconst DEFAULT_DURATION = { duration: DURATION.press } 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,\n pressedBackgroundBorderRadius = RADIUS.xl,\n elevationLevel,\n fullWidth = false,\n color,\n isLoading = false,\n disabled = false,\n ...props\n}: ZSPressableProps) {\n const { palette } = useTheme();\n const isButtonPress = useSharedValue(0);\n const lastClickTime = useRef<number>(0);\n const pressedBgColor = pressedBackgroundColor ?? palette.grey[50] + transparency['10%'];\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: pressedBgColor,\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) ? DISABLED_OPACITY : 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,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { ViewProps } from 'react-native';
|
|
3
2
|
import { RadioOption } from '../types';
|
|
4
3
|
import { ZSTextProps } from '../ZSText';
|
|
@@ -13,7 +12,7 @@ interface ZSRadioGroupProps extends ViewProps {
|
|
|
13
12
|
disabled?: boolean;
|
|
14
13
|
rowCount?: 1 | 2 | 3;
|
|
15
14
|
}
|
|
16
|
-
declare function ZSRadioGroup({ options, value, onSelect, containerStyle, valueStyle, disabled, selectStyle, selectLabel, rowCount, ...props }: ZSRadioGroupProps):
|
|
17
|
-
declare const _default:
|
|
15
|
+
declare function ZSRadioGroup({ options, value, onSelect, containerStyle, valueStyle, disabled, selectStyle, selectLabel, rowCount, ...props }: ZSRadioGroupProps): import("react").JSX.Element;
|
|
16
|
+
declare const _default: import("react").MemoExoticComponent<typeof ZSRadioGroup>;
|
|
18
17
|
export default _default;
|
|
19
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSRadioGroup/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSRadioGroup/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,SAAS,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAe,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AA6FhD,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,+BAgDnB;;AA8CD,wBAAkC"}
|
|
@@ -5,6 +5,7 @@ import ViewAtom from '../atoms/ViewAtom';
|
|
|
5
5
|
import ZSText from '../ZSText';
|
|
6
6
|
import ZSPressable from '../ZSPressable';
|
|
7
7
|
import { useTheme } from '../../context/ThemeContext';
|
|
8
|
+
import { DISABLED_OPACITY, RADIUS } from '../../theme/tokens';
|
|
8
9
|
import { SvgCheck } from '../../assets/SvgCheck';
|
|
9
10
|
const ROW_WIDTH = {
|
|
10
11
|
1: '100%',
|
|
@@ -22,7 +23,7 @@ const RadioRow = memo(function RadioRow({ option, index, optionCount, rowCount,
|
|
|
22
23
|
paddingLeft: isFullWidth ? 0 : isLastCol ? 3 : 0,
|
|
23
24
|
paddingBottom: isLastRow ? 0 : 10,
|
|
24
25
|
},
|
|
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
|
+
], children: _jsx(ZSPressable, { onPress: () => onSelect(option), pressedBackgroundColor: "transparent", fullWidth: true, accessibilityRole: 'radio', accessibilityState: { checked: isSelected }, 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
27
|
});
|
|
27
28
|
function ZSRadioGroup({ options, value, onSelect, containerStyle, valueStyle, disabled = false, selectStyle, selectLabel = '선택', rowCount = 1, ...props }) {
|
|
28
29
|
const { palette } = useTheme();
|
|
@@ -32,7 +33,14 @@ function ZSRadioGroup({ options, value, onSelect, containerStyle, valueStyle, di
|
|
|
32
33
|
onSelect(option);
|
|
33
34
|
}
|
|
34
35
|
}, [disabled, onSelect]);
|
|
35
|
-
return (_jsx(ViewAtom, { style: [
|
|
36
|
+
return (_jsx(ViewAtom, { style: [
|
|
37
|
+
styles.container,
|
|
38
|
+
{
|
|
39
|
+
flexDirection: isFullWidth ? 'column' : 'row',
|
|
40
|
+
flexWrap: isFullWidth ? 'nowrap' : 'wrap',
|
|
41
|
+
opacity: disabled ? DISABLED_OPACITY : 1,
|
|
42
|
+
},
|
|
43
|
+
], ...containerStyle, ...props, children: options.map((option, index) => {
|
|
36
44
|
const isSelected = value?.index === option.index;
|
|
37
45
|
const setColor = isSelected ? palette.primary.light : palette.background.neutral;
|
|
38
46
|
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));
|
|
@@ -50,7 +58,7 @@ const styles = StyleSheet.create({
|
|
|
50
58
|
borderWidth: 1,
|
|
51
59
|
paddingLeft: 10,
|
|
52
60
|
paddingRight: 15,
|
|
53
|
-
borderRadius:
|
|
61
|
+
borderRadius: RADIUS.pill,
|
|
54
62
|
},
|
|
55
63
|
radioOuter: {
|
|
56
64
|
width: 20,
|
|
@@ -73,7 +81,7 @@ const styles = StyleSheet.create({
|
|
|
73
81
|
},
|
|
74
82
|
selectButton: {
|
|
75
83
|
paddingHorizontal: 10,
|
|
76
|
-
borderRadius:
|
|
84
|
+
borderRadius: RADIUS.pill,
|
|
77
85
|
minWidth: 42,
|
|
78
86
|
minHeight: 24,
|
|
79
87
|
justifyContent: 'center',
|
|
@@ -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;AACjD,OAAO,EAAE,UAAU,EAAa,MAAM,cAAc,CAAC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,CAAC,MAAM,EAC1E,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,YAAY,IAbjB,MAAM,CAAC,KAAK,CAcjB,CACH,CAAC;QACJ,CAAC,CAAC,GACO,CACZ,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,KAAK,EAAE,MAAM;KACd;IACD,IAAI,EAAE,EAAE;IACR,GAAG,EAAE;QACH,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,QAAQ;QACpB,eAAe,EAAE,EAAE;QACnB,WAAW,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"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSRadioGroup/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC1C,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,gBAAgB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC9D,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,WAAW,EACX,QAAQ,EACR,UAAU,EACV,WAAW,EACX,QAAQ,EACR,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,WAAW,EACX,QAAQ,GACM;IACd,MAAM,SAAS,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,QAAQ,KAAK,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,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AU,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,MAAM,CAAC,IAAI;QACzB,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 { 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 { DISABLED_OPACITY, RADIUS } from '../../theme/tokens';\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\n onPress={() => onSelect(option)}\n pressedBackgroundColor=\"transparent\"\n fullWidth\n accessibilityRole='radio'\n accessibilityState={{ checked: isSelected }}\n >\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={[\n styles.container,\n {\n flexDirection: isFullWidth ? 'column' : 'row',\n flexWrap: isFullWidth ? 'nowrap' : 'wrap',\n opacity: disabled ? DISABLED_OPACITY : 1,\n },\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 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: RADIUS.pill,\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: RADIUS.pill,\n minWidth: 42,\n minHeight: 24,\n justifyContent: 'center',\n alignItems: 'center',\n flexShrink: 0,\n },\n});\n\nexport default memo(ZSRadioGroup);\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type StyleProp, type ViewProps, type ViewStyle } from "react-native";
|
|
3
|
+
export type ZSSegmentedTextSize = '1' | '2' | '3' | '4' | '5' | '6';
|
|
4
|
+
export interface ZSSegmentedProps extends ViewProps {
|
|
5
|
+
/** 세그먼트 라벨 목록 (2개 이상) */
|
|
6
|
+
options: string[];
|
|
7
|
+
/** 선택 인덱스를 외부에서 제어할 때 사용 (미지정 시 내부 상태로 동작) */
|
|
8
|
+
selectedIndex?: number;
|
|
9
|
+
/** 비제어 모드의 초기 선택 인덱스 */
|
|
10
|
+
initialIndex?: number;
|
|
11
|
+
onChange?: (index: number) => void;
|
|
12
|
+
/** true(기본): 부모 폭을 가득 채움 · false: 가장 긴 라벨 폭에 맞춰 콘텐츠 크기로 렌더링 */
|
|
13
|
+
fullWidth?: boolean;
|
|
14
|
+
containerHeight?: number;
|
|
15
|
+
textSize?: ZSSegmentedTextSize;
|
|
16
|
+
/** 트랙 배경색 (기본: palette.background.layer2) */
|
|
17
|
+
trackColor?: string;
|
|
18
|
+
/** 선택 블럭 색상 (기본: palette.background.base) */
|
|
19
|
+
thumbColor?: string;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
style?: StyleProp<ViewStyle>;
|
|
22
|
+
}
|
|
23
|
+
declare function ZSSegmented({ options, selectedIndex, initialIndex, onChange, fullWidth, containerHeight, textSize, trackColor, thumbColor, disabled, style, onLayout, ...props }: ZSSegmentedProps): React.JSX.Element;
|
|
24
|
+
declare const _default: React.MemoExoticComponent<typeof ZSSegmented>;
|
|
25
|
+
export default _default;
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSSegmented/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAAuD,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAUnI,MAAM,MAAM,mBAAmB,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAEpE,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IACjD,yBAAyB;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,8CAA8C;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wBAAwB;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,+DAA+D;IAC/D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,iBAAS,WAAW,CAAC,EACnB,OAAO,EACP,aAAa,EACb,YAAgB,EAChB,QAAQ,EACR,SAAgB,EAChB,eAAoB,EACpB,QAAc,EACd,UAAU,EACV,UAAU,EACV,QAAgB,EAChB,KAAK,EACL,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,gBAAgB,qBAmIlB;;AAED,wBAAuC"}
|