@0610studio/zs-ui 0.17.0 → 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 +72 -42
- 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.d.ts.map +1 -1
- package/build/overlay/BottomSheetOverlay/index.js +3 -18
- 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.d.ts.map +1 -1
- package/build/overlay/Modality/index.js +20 -32
- 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.d.ts.map +1 -1
- package/build/ui/ZSPressable/index.js +2 -10
- 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.d.ts.map +1 -1
- package/build/ui/ZSSkeleton/index.js +3 -13
- package/build/ui/ZSSkeleton/index.js.map +1 -1
- package/build/ui/ZSSkeletonBox/index.d.ts.map +1 -1
- package/build/ui/ZSSkeletonBox/index.js +9 -17
- package/build/ui/ZSSkeletonBox/index.js.map +1 -1
- package/build/ui/ZSSwitch/index.d.ts.map +1 -1
- package/build/ui/ZSSwitch/index.js +16 -23
- 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.d.ts.map +1 -1
- package/build/ui/ZSTextField/index.js +40 -59
- 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.d.ts.map +1 -1
- package/build/ui/atoms/AnimatedWrapper.js +4 -6
- 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 +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,CAA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,CAAC,UAAU,CAAC,MAAM;oCAC7B,iBAAiB,EAAE,EAAE;oCACrB,YAAY,EAAE,GAAG;oCACjB,QAAQ,EAAE,EAAE;oCACZ,SAAS,EAAE,EAAE;oCACb,cAAc,EAAE,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSSkeleton/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAc,KAAK,SAAS,EAAoB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAM5G,UAAU,eAAgB,SAAQ,SAAS;IACvC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,iBAAS,UAAU,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSSkeleton/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAc,KAAK,SAAS,EAAoB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAM5G,UAAU,eAAgB,SAAQ,SAAS;IACvC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,iBAAS,UAAU,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,mSAuC3F;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -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";
|
|
@@ -20,22 +21,11 @@ function ZSSkeleton({ isFetching, style, children, overlayColor, ...props }) {
|
|
|
20
21
|
};
|
|
21
22
|
}, [isFetching]);
|
|
22
23
|
const animatedStyle = useAnimatedStyle(() => {
|
|
23
|
-
"worklet";
|
|
24
24
|
return {
|
|
25
25
|
transform: [{ translateX: translateX.value }],
|
|
26
26
|
};
|
|
27
27
|
});
|
|
28
|
-
return isFetching ? (
|
|
29
|
-
<View style={styles.container}>
|
|
30
|
-
{children}
|
|
31
|
-
|
|
32
|
-
<Animated.View style={[styles.shimmer, animatedStyle]}>
|
|
33
|
-
<View style={[styles.shimmerSub, { backgroundColor: effectColor }]}/>
|
|
34
|
-
<View style={[styles.shimmerCenter, { backgroundColor: effectColor }]}/>
|
|
35
|
-
<View style={[styles.shimmerSub, { backgroundColor: effectColor }]}/>
|
|
36
|
-
</Animated.View>
|
|
37
|
-
</View>
|
|
38
|
-
</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);
|
|
39
29
|
}
|
|
40
30
|
export default ZSSkeleton;
|
|
41
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,EAA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AAE;QACP,QAAQ,EAAE,QAAQ;QAClB,OAAO,EAAE,GAAG;QACZ,KAAK,EAAE,MAAM;KAChB;IACD,OAAO,EAAE;QACL,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,UAAU;QACpB,aAAa,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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSSkeletonBox/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAc,KAAK,SAAS,EAAoB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAI5G,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAIrD,UAAU,kBAAmB,SAAQ,SAAS;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC5B;AAED,iBAAS,aAAa,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,KAAiB,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSSkeletonBox/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAc,KAAK,SAAS,EAAoB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAI5G,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAIrD,UAAU,kBAAmB,SAAQ,SAAS;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC5B;AAED,iBAAS,aAAa,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,KAAiB,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,qBAuCtG;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -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";
|
|
@@ -15,26 +16,17 @@ function ZSSkeletonBox({ height, style, overlayColor, color = 'neutral', ...prop
|
|
|
15
16
|
};
|
|
16
17
|
}, []);
|
|
17
18
|
const animatedStyle = useAnimatedStyle(() => {
|
|
18
|
-
"worklet";
|
|
19
19
|
return {
|
|
20
20
|
transform: [{ translateX: translateX.value }],
|
|
21
21
|
};
|
|
22
22
|
});
|
|
23
|
-
return (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
]} color={color}>
|
|
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
|
-
</ZSView>
|
|
37
|
-
</View>);
|
|
23
|
+
return (_jsx(View, { style: [{ width: '100%' }, style, { height, overflow: "hidden" }], ...props, children: _jsx(ZSView, { style: [
|
|
24
|
+
styles.container,
|
|
25
|
+
{
|
|
26
|
+
width: DEVICE_WIDTH,
|
|
27
|
+
height,
|
|
28
|
+
},
|
|
29
|
+
], color: color, children: _jsxs(Animated.View, { style: [styles.shimmer, animatedStyle], children: [_jsx(View, { style: [styles.shimmerSub, { backgroundColor: effectColor }] }), _jsx(View, { style: [styles.shimmerCenter, { backgroundColor: effectColor }] }), _jsx(View, { style: [styles.shimmerSub, { backgroundColor: effectColor }] })] }) }) }));
|
|
38
30
|
}
|
|
39
31
|
export default ZSSkeletonBox;
|
|
40
32
|
const styles = StyleSheet.create({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSSkeletonBox/index.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSSkeletonBox/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;AACtD,OAAO,MAAM,MAAM,WAAW,CAAC;AAG/B,MAAM,YAAY,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;AASpD,SAAS,aAA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eAAe,EAAE,WAAW,EAAE,CAAC,GAAI,EACtE,KAAC,IAAI,IAAC,KAAK,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC,GAAI,EACzE,KAAC,IAAI,IAAC,KAAK,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC,GAAI,IAC1D,GACX,GACN,CACV,CAAC;AACN,CAAC;AAED,eAAe,aAAa,CAAC;AAE7B,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC7B,SAAS,EAAE;QACP,QAAQ,EAAE,QAAQ;QAClB,OAAO,EAAE,GAAG;KACf;IACD,OAAO,EAAE;QACL,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,UAAU;QACpB,aAAa,EAAE,KAAK;KACvB;IACD,UAAU,EAAE;QACR,MAAM,EAAE,MAAM;QACd,eAAe,EAAE,SAAS;QAC1B,OAAO,EAAE,GAAG;QACZ,KAAK,EAAE,YAAY,GAAG,GAAG;KAC5B;IACD,aAAa,EAAE;QACX,MAAM,EAAE,MAAM;QACd,eAAe,EAAE,SAAS;QAC1B,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\";\nimport ZSView from \"../ZSView\";\nimport { ViewColorOptions } from \"../../theme/types\";\n\nconst DEVICE_WIDTH = Dimensions.get(\"window\").width;\n\ninterface ZSSkeletonBoxProps extends ViewProps {\n height: number;\n style?: StyleProp<ViewStyle>;\n overlayColor?: string;\n color?: ViewColorOptions;\n}\n\nfunction ZSSkeletonBox({ height, style, overlayColor, color = 'neutral', ...props }: ZSSkeletonBoxProps) {\n const translateX = useSharedValue(-DEVICE_WIDTH * 1.2);\n const { palette } = useTheme();\n const effectColor = overlayColor || palette.background.layer1;\n\n useEffect(() => {\n translateX.value = withRepeat(withTiming(DEVICE_WIDTH * 1.2, { duration: 800 }), -1, false);\n\n return () => {\n cancelAnimation(translateX);\n };\n }, []);\n\n const animatedStyle = useAnimatedStyle(() => {\n return {\n transform: [{ translateX: translateX.value }],\n };\n });\n\n return (\n <View style={[{ width: '100%' }, style, { height, overflow: \"hidden\" }]} {...props}>\n <ZSView\n style={[\n styles.container,\n {\n width: DEVICE_WIDTH,\n height,\n },\n ]}\n color={color}\n >\n <Animated.View style={[styles.shimmer, animatedStyle]}>\n <View style={[styles.shimmerSub, { backgroundColor: effectColor }]} />\n <View style={[styles.shimmerCenter, { backgroundColor: effectColor }]} />\n <View style={[styles.shimmerSub, { backgroundColor: effectColor }]} />\n </Animated.View>\n </ZSView>\n </View>\n );\n}\n\nexport default ZSSkeletonBox;\n\nconst styles = StyleSheet.create({\n container: {\n overflow: \"hidden\",\n opacity: 0.4,\n },\n shimmer: {\n width: \"100%\",\n height: \"100%\",\n position: \"absolute\",\n flexDirection: \"row\",\n },\n shimmerSub: {\n height: \"100%\",\n backgroundColor: \"#ebebeb\",\n opacity: 0.3,\n width: DEVICE_WIDTH * 0.3,\n },\n shimmerCenter: {\n height: \"100%\",\n backgroundColor: \"#f5f5f5\",\n opacity: 0.7,\n width: DEVICE_WIDTH * 0.4,\n },\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSSwitch/index.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSSwitch/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAa,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAUzF,UAAU,aAAc,SAAQ,SAAS;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,iBAAS,QAAQ,CAAC,EAChB,QAAgB,EAChB,QAAQ,EACR,KAAK,EACL,KAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,UAAsB,EACtB,GAAG,KAAK,EACT,EAAE,aAAa,qBAyCf;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Pressable } from "react-native";
|
|
3
|
-
import Animated
|
|
3
|
+
import Animated from "react-native-reanimated";
|
|
4
4
|
import { useTheme } from "../../context/ThemeContext";
|
|
5
|
+
const SWITCH_TRANSITION_DURATION = 200;
|
|
6
|
+
const SWITCH_TRANSITION = {
|
|
7
|
+
transitionDuration: SWITCH_TRANSITION_DURATION,
|
|
8
|
+
transitionTimingFunction: 'ease-in-out',
|
|
9
|
+
};
|
|
5
10
|
function ZSSwitch({ isActive = false, onToggle, style, width = 50, trackColorInactive, trackColorActive, thumbColor = '#ffffff', ...props }) {
|
|
6
|
-
const [toggledWidth, setToggledWidth] = useState(0);
|
|
7
11
|
const { palette } = useTheme();
|
|
8
12
|
const height = width * 0.6;
|
|
9
13
|
const padding = width * 0.04;
|
|
@@ -12,39 +16,28 @@ function ZSSwitch({ isActive = false, onToggle, style, width = 50, trackColorIna
|
|
|
12
16
|
const thumbBorderRadius = thumbSize / 2;
|
|
13
17
|
const inactiveColor = trackColorInactive ?? palette.grey[30];
|
|
14
18
|
const activeColor = trackColorActive ?? palette.primary.main;
|
|
15
|
-
const
|
|
16
|
-
return withTiming(isActive ? 1 : 0, { duration: 200 });
|
|
17
|
-
}, [isActive]);
|
|
18
|
-
const colorAnimation = useAnimatedStyle(() => {
|
|
19
|
-
'worklet';
|
|
20
|
-
const color = interpolateColor(toggleProgress.value, [0, 1], [inactiveColor, activeColor]);
|
|
21
|
-
return { backgroundColor: color };
|
|
22
|
-
}, [inactiveColor, activeColor]);
|
|
23
|
-
const togglePositionAnimation = useAnimatedStyle(() => {
|
|
24
|
-
'worklet';
|
|
25
|
-
const positionStyle = interpolate(toggleProgress.value, [0, 1], [0, toggledWidth - thumbSize - padding * 2], 'clamp');
|
|
26
|
-
return {
|
|
27
|
-
transform: [{ translateX: positionStyle }],
|
|
28
|
-
};
|
|
29
|
-
}, [toggledWidth, thumbSize, padding]);
|
|
19
|
+
const thumbTranslateX = isActive ? width - thumbSize - padding * 2 : 0;
|
|
30
20
|
const toggleStyle = {
|
|
31
21
|
width,
|
|
32
22
|
height,
|
|
33
23
|
borderRadius: toggleBorderRadius,
|
|
34
24
|
padding,
|
|
35
25
|
justifyContent: "center",
|
|
26
|
+
backgroundColor: isActive ? activeColor : inactiveColor,
|
|
27
|
+
transitionProperty: 'backgroundColor',
|
|
28
|
+
...SWITCH_TRANSITION,
|
|
36
29
|
};
|
|
37
30
|
const thumbStyle = {
|
|
38
31
|
width: thumbSize,
|
|
39
32
|
height: thumbSize,
|
|
40
33
|
borderRadius: thumbBorderRadius,
|
|
41
34
|
justifyContent: "center",
|
|
35
|
+
backgroundColor: thumbColor,
|
|
36
|
+
transform: [{ translateX: thumbTranslateX }],
|
|
37
|
+
transitionProperty: 'transform',
|
|
38
|
+
...SWITCH_TRANSITION,
|
|
42
39
|
};
|
|
43
|
-
return (
|
|
44
|
-
<Animated.View style={[colorAnimation, toggleStyle]} onLayout={e => setToggledWidth(e.nativeEvent.layout.width)}>
|
|
45
|
-
<Animated.View style={[togglePositionAnimation, thumbStyle, { backgroundColor: thumbColor }]}/>
|
|
46
|
-
</Animated.View>
|
|
47
|
-
</Pressable>);
|
|
40
|
+
return (_jsx(Pressable, { onPress: onToggle, style: style, ...props, children: _jsx(Animated.View, { style: toggleStyle, children: _jsx(Animated.View, { style: thumbStyle }) }) }));
|
|
48
41
|
}
|
|
49
42
|
;
|
|
50
43
|
export default ZSSwitch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSSwitch/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSSwitch/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAkC,SAAS,EAAkB,MAAM,cAAc,CAAC;AACzF,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,MAAM,0BAA0B,GAAG,GAAG,CAAC;AACvC,MAAM,iBAAiB,GAAG;IACxB,kBAAkB,EAAE,0BAA0B;IAC9C,wBAAwB,EAAE,aAAa;CAC/B,CAAC;AAYX,SAAS,QAAQ,CAAC,EAChB,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,KAAK,EACL,KAAK,GAAG,EAAE,EACV,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,GAAG,SAAS,EACtB,GAAG,KAAK,EACM;IACd,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC/B,MAAM,MAAM,GAAG,KAAK,GAAG,GAAG,CAAC;IAC3B,MAAM,OAAO,GAAG,KAAK,GAAG,IAAI,CAAC;IAC7B,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,CAAC,CAAC;IACvC,MAAM,kBAAkB,GAAG,MAAM,GAAG,GAAG,CAAC;IACxC,MAAM,iBAAiB,GAAG,SAAS,GAAG,CAAC,CAAC;IAExC,MAAM,aAAa,GAAG,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7D,MAAM,WAAW,GAAG,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;IAC7D,MAAM,eAAe,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEvE,MAAM,WAAW,GAAG;QAClB,KAAK;QACL,MAAM;QACN,YAAY,EAAE,kBAAkB;QAChC,OAAO;QACP,cAAc,EAAE,QAAiB;QACjC,eAAe,EAAE,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa;QACvD,kBAAkB,EAAE,iBAA0B;QAC9C,GAAG,iBAAiB;KACrB,CAAC;IAEF,MAAM,UAAU,GAAG;QACjB,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,SAAS;QACjB,YAAY,EAAE,iBAAiB;QAC/B,cAAc,EAAE,QAAiB;QACjC,eAAe,EAAE,UAAU;QAC3B,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;QAC5C,kBAAkB,EAAE,WAAoB;QACxC,GAAG,iBAAiB;KACrB,CAAC;IAEF,OAAO,CACL,KAAC,SAAS,IAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,KAAM,KAAK,YACnD,KAAC,QAAQ,CAAC,IAAI,IAAC,KAAK,EAAE,WAAW,YAC/B,KAAC,QAAQ,CAAC,IAAI,IAAC,KAAK,EAAE,UAAU,GAAI,GACtB,GACN,CACb,CAAC;AACJ,CAAC;AAAA,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import React from \"react\";\nimport { type StyleProp, type ViewStyle, Pressable, type ViewProps } from \"react-native\";\nimport Animated from \"react-native-reanimated\";\nimport { useTheme } from \"../../context/ThemeContext\";\n\nconst SWITCH_TRANSITION_DURATION = 200;\nconst SWITCH_TRANSITION = {\n transitionDuration: SWITCH_TRANSITION_DURATION,\n transitionTimingFunction: 'ease-in-out',\n} as const;\n\ninterface ZSSwitchProps extends ViewProps {\n isActive: boolean;\n onToggle: () => void;\n style?: StyleProp<ViewStyle>;\n width?: number;\n trackColorInactive?: string;\n trackColorActive?: string;\n thumbColor?: string;\n}\n\nfunction ZSSwitch({\n isActive = false,\n onToggle,\n style,\n width = 50,\n trackColorInactive,\n trackColorActive,\n thumbColor = '#ffffff',\n ...props\n}: ZSSwitchProps) {\n const { palette } = useTheme();\n const height = width * 0.6;\n const padding = width * 0.04;\n const thumbSize = height - padding * 2;\n const toggleBorderRadius = height * 1.2;\n const thumbBorderRadius = thumbSize / 2;\n\n const inactiveColor = trackColorInactive ?? palette.grey[30];\n const activeColor = trackColorActive ?? palette.primary.main;\n const thumbTranslateX = isActive ? width - thumbSize - padding * 2 : 0;\n\n const toggleStyle = {\n width,\n height,\n borderRadius: toggleBorderRadius,\n padding,\n justifyContent: \"center\" as const,\n backgroundColor: isActive ? activeColor : inactiveColor,\n transitionProperty: 'backgroundColor' as const,\n ...SWITCH_TRANSITION,\n };\n\n const thumbStyle = {\n width: thumbSize,\n height: thumbSize,\n borderRadius: thumbBorderRadius,\n justifyContent: \"center\" as const,\n backgroundColor: thumbColor,\n transform: [{ translateX: thumbTranslateX }],\n transitionProperty: 'transform' as const,\n ...SWITCH_TRANSITION,\n };\n\n return (\n <Pressable onPress={onToggle} style={style} {...props}>\n <Animated.View style={toggleStyle}>\n <Animated.View style={thumbStyle} />\n </Animated.View>\n </Pressable>\n );\n};\n\nexport default ZSSwitch;\n"]}
|
package/build/ui/ZSText/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useTheme } from "../../context/ThemeContext";
|
|
3
3
|
import TextAtom from "../atoms/TextAtom";
|
|
4
4
|
function isColorMap(value) {
|
|
@@ -18,7 +18,7 @@ function ZSText({ typo = 'body.2', color = 'base', ...props }) {
|
|
|
18
18
|
const semanticPalette = palette[c01];
|
|
19
19
|
return isColorMap(semanticPalette) ? semanticPalette[c02] : undefined;
|
|
20
20
|
})();
|
|
21
|
-
return
|
|
21
|
+
return _jsx(TextAtom, { ...props, style: [typography[s01][s02], { color: textColor }, props.style], children: props.children });
|
|
22
22
|
}
|
|
23
23
|
export default ZSText;
|
|
24
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSText/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/ZSText/index.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,OAAO,QAAQ,MAAM,mBAAmB,CAAA;AAKxC,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAOD,SAAS,MAAM,CAAC,EACd,IAAI,GAAG,QAAQ,EACf,KAAK,GAAG,MAAM,EACd,GAAG,KAAK,EACI;IACV,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC3C,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAA8B,CAAC;IAChE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAiC,CAAC;IACpE,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE;QACtB,IAAI,CAAC,GAAG;YAAE,OAAO,OAAO,CAAC,IAAI,CAAC,GAA0B,CAAC,CAAC;QAC1D,IAAI,GAAG,KAAK,MAAM;YAAE,OAAO,OAAO,CAAC,IAAI,CAAC,GAA0B,CAAC,CAAC;QACpE,IAAI,GAAG,KAAK,YAAY;YAAE,OAAO,OAAO,CAAC,UAAU,CAAC,GAA4B,CAAC,CAAC;QAElF,MAAM,eAAe,GAAG,OAAO,CAAC,GAAyB,CAAC,CAAC;QAC3D,OAAO,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,GAAmB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxF,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO,KAAC,QAAQ,OAAK,KAAK,EAAE,KAAK,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,YAAG,KAAK,CAAC,QAAQ,GAAY,CAAA;AAC7H,CAAC;AAED,eAAe,MAAM,CAAC","sourcesContent":["import React from \"react\";\nimport { TextProps } from \"react-native\";\nimport { useTheme } from \"../../context/ThemeContext\";\nimport { ColorPalette, ThemeTextType, TypoOptions, TypoStyle, TypoColorOptions, TypoSubStyle, ThemeBackground } from \"../../theme/types\";\nimport TextAtom from \"../atoms/TextAtom\"\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\nexport interface ZSTextProps extends TextProps {\n typo?: TypoOptions;\n color?: TypoColorOptions;\n}\n\nfunction ZSText({\n typo = 'body.2',\n color = 'base',\n ...props\n}: ZSTextProps) {\n const { palette, typography } = useTheme();\n const [s01, s02] = typo.split('.') as [TypoStyle, TypoSubStyle];\n const [c01, c02] = color.split('.') as [string, string | undefined];\n const textColor = (() => {\n if (!c02) return palette.text[c01 as keyof ThemeTextType];\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\n return <TextAtom {...props} style={[typography[s01][s02], { color: textColor }, props.style]}>{props.children}</TextAtom>\n}\n\nexport default ZSText;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/ZSTextField/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAA0C,SAAS,EAAE,cAAc,EAAa,MAAM,cAAc,CAAC;AAI5G,OAAO,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAC;AAKzE,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;AAMzD,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB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,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,aAAa,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,cAAc,GAAG,SAAS,CAAC;AAEvC,QAAA,MAAM,WAAW,sGAkPf,CAAC;AAIH,eAAe,WAAW,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useCallback, useState, forwardRef, useEffect, useRef } from 'react';
|
|
2
3
|
import { Platform, TextInput } from 'react-native';
|
|
3
4
|
import Animated, { interpolate, useAnimatedStyle, useSharedValue, withTiming, ReduceMotion } from 'react-native-reanimated';
|
|
4
5
|
import ButtonClose from './ui/ButtonClose';
|
|
@@ -15,19 +16,20 @@ const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, on
|
|
|
15
16
|
const fErrorColor = errorColor || palette.danger.main;
|
|
16
17
|
const fontSize = extractStyle(typography[primaryStyle][subStyle], 'fontSize') || 17;
|
|
17
18
|
const fontFamily = extractStyle(typography[primaryStyle][subStyle], 'fontFamily') || '';
|
|
18
|
-
const
|
|
19
|
-
const focusProgress = useSharedValue(0);
|
|
20
|
-
const errorProgress = useSharedValue(0);
|
|
19
|
+
const floatProgress = useSharedValue(value !== '' ? 1 : 0);
|
|
21
20
|
const [isFocusedForUI, setIsFocusedForUI] = useState(false);
|
|
22
21
|
const boxHeightValue = useSharedValue(0);
|
|
23
22
|
const isError = status === 'error';
|
|
24
23
|
const hasValue = value !== '';
|
|
24
|
+
const isFocusedRef = useRef(false);
|
|
25
|
+
const hasValueRef = useRef(hasValue);
|
|
26
|
+
hasValueRef.current = hasValue;
|
|
25
27
|
useEffect(() => {
|
|
26
|
-
|
|
28
|
+
const target = hasValue ? 1 : 0;
|
|
29
|
+
if (!isFocusedRef.current && floatProgress.value !== target) {
|
|
30
|
+
floatProgress.value = withTiming(target, TIMING_CONFIG);
|
|
31
|
+
}
|
|
27
32
|
}, [hasValue]);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
errorProgress.value = withTiming(isError ? 1 : 0, TIMING_CONFIG);
|
|
30
|
-
}, [isError]);
|
|
31
33
|
const animationConstants = useMemo(() => ({
|
|
32
34
|
baseFontSize: fontSize + (boxStyle === 'inbox' ? 1 : 0),
|
|
33
35
|
targetFontSize: boxStyle === 'inbox' ? 10 : 11,
|
|
@@ -35,16 +37,13 @@ const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, on
|
|
|
35
37
|
targetTopOffset: boxStyle === 'inbox' ? 17 : 2,
|
|
36
38
|
}), [fontSize, boxStyle, isTextArea]);
|
|
37
39
|
const animatedLabelStyle = useAnimatedStyle(() => {
|
|
38
|
-
|
|
39
|
-
const progress = Math.max(labelProgress.value, focusProgress.value);
|
|
40
|
+
const progress = floatProgress.value;
|
|
40
41
|
const labelTranslateY = interpolate(progress, [0, 1], [
|
|
41
42
|
0,
|
|
42
43
|
isTextArea ? -24 : -(boxHeightValue.value / 2) - 1 + animationConstants.targetTopOffset - animationConstants.baseTop,
|
|
43
44
|
], 'clamp');
|
|
44
45
|
const labelScale = interpolate(progress, [0, 1], [1, animationConstants.targetFontSize / animationConstants.baseFontSize], 'clamp');
|
|
45
46
|
return {
|
|
46
|
-
top: animationConstants.baseTop,
|
|
47
|
-
transformOrigin: 'left center',
|
|
48
47
|
transform: [
|
|
49
48
|
{ translateY: labelTranslateY },
|
|
50
49
|
{ scale: labelScale },
|
|
@@ -56,11 +55,18 @@ const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, on
|
|
|
56
55
|
boxHeightValue.value = height;
|
|
57
56
|
}, []);
|
|
58
57
|
const handleFocus = useCallback(() => {
|
|
59
|
-
|
|
58
|
+
isFocusedRef.current = true;
|
|
59
|
+
if (floatProgress.value !== 1) {
|
|
60
|
+
floatProgress.value = withTiming(1, TIMING_CONFIG);
|
|
61
|
+
}
|
|
60
62
|
setIsFocusedForUI(true);
|
|
61
63
|
}, []);
|
|
62
64
|
const handleBlur = useCallback(() => {
|
|
63
|
-
|
|
65
|
+
isFocusedRef.current = false;
|
|
66
|
+
const target = hasValueRef.current ? 1 : 0;
|
|
67
|
+
if (floatProgress.value !== target) {
|
|
68
|
+
floatProgress.value = withTiming(target, TIMING_CONFIG);
|
|
69
|
+
}
|
|
64
70
|
setIsFocusedForUI(false);
|
|
65
71
|
}, []);
|
|
66
72
|
const colorConfig = useMemo(() => ({
|
|
@@ -70,31 +76,18 @@ const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, on
|
|
|
70
76
|
placeholderColor: placeHolderColor || palette.grey[40],
|
|
71
77
|
errorColor: fErrorColor,
|
|
72
78
|
}), [focusColor, palette.primary.main, borderColor, palette.grey, labelColor, palette.text.secondary, placeHolderColor, fErrorColor]);
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
? colorConfig.
|
|
77
|
-
:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
'worklet';
|
|
86
|
-
const floatProgress = Math.max(labelProgress.value, focusProgress.value);
|
|
87
|
-
const labelColor = errorProgress.value > 0
|
|
88
|
-
? colorConfig.errorColor
|
|
89
|
-
: focusProgress.value > 0
|
|
90
|
-
? colorConfig.primaryColor
|
|
91
|
-
: floatProgress > 0
|
|
92
|
-
? colorConfig.defaultLabelColor
|
|
93
|
-
: colorConfig.placeholderColor;
|
|
94
|
-
return {
|
|
95
|
-
color: labelColor,
|
|
96
|
-
};
|
|
97
|
-
}, [colorConfig]);
|
|
79
|
+
const currentBorderColor = isError
|
|
80
|
+
? colorConfig.errorColor
|
|
81
|
+
: isFocusedForUI
|
|
82
|
+
? colorConfig.primaryColor
|
|
83
|
+
: colorConfig.defaultBorderColor;
|
|
84
|
+
const currentLabelColor = isError
|
|
85
|
+
? colorConfig.errorColor
|
|
86
|
+
: isFocusedForUI
|
|
87
|
+
? colorConfig.primaryColor
|
|
88
|
+
: hasValue
|
|
89
|
+
? colorConfig.defaultLabelColor
|
|
90
|
+
: colorConfig.placeholderColor;
|
|
98
91
|
const styleConfig = useMemo(() => {
|
|
99
92
|
const baseStyle = {
|
|
100
93
|
width: '100%',
|
|
@@ -137,22 +130,24 @@ const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, on
|
|
|
137
130
|
}
|
|
138
131
|
return { ...baseStyle, ...borderStyle, ...innerStyle };
|
|
139
132
|
}, [isTextArea, borderRadius, paddingHorizontal, inputBgColor, borderWidth, boxStyle, innerBoxStyle, palette.background.base]);
|
|
140
|
-
const labelTextStyle = {
|
|
133
|
+
const labelTextStyle = useMemo(() => ({
|
|
141
134
|
fontSize,
|
|
135
|
+
top: animationConstants.baseTop,
|
|
142
136
|
left: paddingHorizontal,
|
|
137
|
+
transformOrigin: 'left center',
|
|
143
138
|
backgroundColor: labelBgColor || palette.background.base,
|
|
144
139
|
paddingHorizontal: boxStyle === 'outline' ? 5 : 0,
|
|
145
140
|
paddingVertical: 2,
|
|
146
141
|
textAlignVertical: 'center',
|
|
147
142
|
fontFamily,
|
|
148
143
|
borderRadius: boxStyle === 'outline' ? 5 : 0,
|
|
149
|
-
overflow: 'hidden',
|
|
150
|
-
};
|
|
144
|
+
...(Platform.OS === 'android' ? { overflow: 'hidden' } : {}),
|
|
145
|
+
}), [fontSize, animationConstants.baseTop, paddingHorizontal, labelBgColor, palette.background.base, boxStyle, fontFamily]);
|
|
151
146
|
const handleTextChange = (text) => {
|
|
152
147
|
if (onChangeText)
|
|
153
148
|
onChangeText(text);
|
|
154
149
|
};
|
|
155
|
-
const textInputStyle = [
|
|
150
|
+
const textInputStyle = useMemo(() => [
|
|
156
151
|
{
|
|
157
152
|
paddingTop: 7 + iosOffset,
|
|
158
153
|
paddingBottom: 5 + iosOffset,
|
|
@@ -164,24 +159,10 @@ const ZSTextField = forwardRef(({ typo = 'body.2', status = 'default', value, on
|
|
|
164
159
|
...(Platform.OS === 'web' ? { outline: 'none' } : {}),
|
|
165
160
|
},
|
|
166
161
|
textInputProps?.style,
|
|
167
|
-
];
|
|
162
|
+
], [palette.text.base, fontSize, fontFamily, textInputProps?.style]);
|
|
168
163
|
const shouldShowCloseButton = value && isFocusedForUI;
|
|
169
164
|
const shouldShowError = status === 'error' && errorMessage;
|
|
170
|
-
return (
|
|
171
|
-
<Animated.View style={[styleConfig, animatedColorStyle]} onLayout={handleLayout} pointerEvents={disabled ? 'none' : 'auto'}>
|
|
172
|
-
<TextInput {...textInputProps} ref={ref} style={textInputStyle} value={value} onFocus={handleFocus} onBlur={handleBlur} onChangeText={handleTextChange} allowFontScaling={allowFontScaling} selectionColor={palette.grey[50]} autoCorrect={false} spellCheck={false}/>
|
|
173
|
-
|
|
174
|
-
<ViewAtom pointerEvents="none" style={{ position: 'absolute' }}>
|
|
175
|
-
<Animated.Text allowFontScaling={allowFontScaling} style={[animatedLabelStyle, labelTextStyle, animatedLabelColorStyle]}>
|
|
176
|
-
{label}
|
|
177
|
-
</Animated.Text>
|
|
178
|
-
</ViewAtom>
|
|
179
|
-
|
|
180
|
-
{shouldShowCloseButton && (<ButtonClose marginTop={isTextArea ? 13 : undefined} onChangeText={onChangeText}/>)}
|
|
181
|
-
</Animated.View>
|
|
182
|
-
|
|
183
|
-
{shouldShowError && (<ErrorComponent errorMessage={errorMessage} errorColor={fErrorColor}/>)}
|
|
184
|
-
</ViewAtom>);
|
|
165
|
+
return (_jsxs(ViewAtom, { style: { alignSelf: 'stretch', width: '100%' }, children: [_jsxs(ViewAtom, { style: [styleConfig, { borderColor: currentBorderColor }], onLayout: handleLayout, pointerEvents: disabled ? 'none' : 'auto', children: [_jsx(TextInput, { ...textInputProps, ref: ref, style: textInputStyle, value: value, onFocus: handleFocus, onBlur: handleBlur, onChangeText: handleTextChange, allowFontScaling: allowFontScaling, selectionColor: palette.grey[50], autoCorrect: false, spellCheck: false }), _jsx(ViewAtom, { pointerEvents: "none", style: { position: 'absolute' }, children: _jsx(Animated.Text, { allowFontScaling: allowFontScaling, style: [labelTextStyle, { color: currentLabelColor }, animatedLabelStyle], children: label }) }), shouldShowCloseButton && (_jsx(ButtonClose, { marginTop: isTextArea ? 13 : undefined, onChangeText: onChangeText }))] }), shouldShowError && (_jsx(ErrorComponent, { errorMessage: errorMessage, errorColor: fErrorColor }))] }));
|
|
185
166
|
});
|
|
186
167
|
ZSTextField.displayName = 'ZSTextField';
|
|
187
168
|
export default ZSTextField;
|