sapo-components-ui-rn 1.0.63 → 1.0.64
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/dist/components/NumberKeyboard/index.d.ts +21 -0
- package/dist/components/Switch/Switch.d.ts +3 -33
- package/dist/index.esm.js +86 -108
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +85 -106
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/NumberKeyboard/index.tsx +315 -0
- package/src/components/Switch/Switch.tsx +123 -76
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface NumberKeyboardProps {
|
|
3
|
+
/** Giá trị hiện tại của input */
|
|
4
|
+
value?: string | number;
|
|
5
|
+
/** Label hiển thị trên modal */
|
|
6
|
+
label?: string;
|
|
7
|
+
/** Callback khi giá trị thay đổi */
|
|
8
|
+
onChangeText?: (value: string) => void;
|
|
9
|
+
/** Giá trị tối đa cho phép */
|
|
10
|
+
maxValue?: number;
|
|
11
|
+
/** Loại input: integer hoặc float */
|
|
12
|
+
type?: "integer" | "float";
|
|
13
|
+
/** Số chữ số thập phân cho phép */
|
|
14
|
+
formatDecimal?: 1 | 2 | 3;
|
|
15
|
+
/** Trạng thái hiển thị modal */
|
|
16
|
+
visible: boolean;
|
|
17
|
+
/** Callback khi đóng modal */
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
}
|
|
20
|
+
declare const _default: React.NamedExoticComponent<NumberKeyboardProps>;
|
|
21
|
+
export default _default;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import type { ThemeProp } from "../../types";
|
|
4
|
-
export type Props = React.ComponentPropsWithRef<typeof NativeSwitch> & {
|
|
2
|
+
export type Props = {
|
|
5
3
|
/**
|
|
6
4
|
* Disable toggling the switch.
|
|
7
5
|
*/
|
|
@@ -10,38 +8,10 @@ export type Props = React.ComponentPropsWithRef<typeof NativeSwitch> & {
|
|
|
10
8
|
* Value of the switch, true means 'on', false means 'off'.
|
|
11
9
|
*/
|
|
12
10
|
value?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Custom color for switch.
|
|
15
|
-
*/
|
|
16
|
-
color?: string;
|
|
17
11
|
/**
|
|
18
12
|
* Callback called with the new value when it changes.
|
|
19
13
|
*/
|
|
20
|
-
onValueChange?:
|
|
21
|
-
style?: StyleProp<ViewStyle>;
|
|
22
|
-
/**
|
|
23
|
-
* @optional
|
|
24
|
-
*/
|
|
25
|
-
theme?: ThemeProp;
|
|
14
|
+
onValueChange?: (value: boolean) => void;
|
|
26
15
|
};
|
|
27
|
-
|
|
28
|
-
* Switch is a visual toggle between two mutually exclusive states — on and off.
|
|
29
|
-
*
|
|
30
|
-
* ## Usage
|
|
31
|
-
* ```js
|
|
32
|
-
* import * as React from 'react';
|
|
33
|
-
* import { Switch } from 'react-native-paper';
|
|
34
|
-
*
|
|
35
|
-
* const MyComponent = () => {
|
|
36
|
-
* const [isSwitchOn, setIsSwitchOn] = React.useState(false);
|
|
37
|
-
*
|
|
38
|
-
* const onToggleSwitch = () => setIsSwitchOn(!isSwitchOn);
|
|
39
|
-
*
|
|
40
|
-
* return <Switch value={isSwitchOn} onValueChange={onToggleSwitch} />;
|
|
41
|
-
* };
|
|
42
|
-
*
|
|
43
|
-
* export default MyComponent;
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
declare const Switch: ({ value, disabled, onValueChange, color, theme: themeOverrides, ...rest }: Props) => React.JSX.Element;
|
|
16
|
+
declare const Switch: React.MemoExoticComponent<({ value, disabled, onValueChange }: Props) => React.JSX.Element>;
|
|
47
17
|
export default Switch;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Platform, Dimensions, StyleSheet, useColorScheme, Animated, Easing, View as View$1, I18nManager, TouchableOpacity,
|
|
1
|
+
import { Platform, Dimensions, StyleSheet, useColorScheme, Animated, Easing, View as View$1, I18nManager, TouchableOpacity, Text as Text$2, Pressable, useWindowDimensions, TextInput as TextInput$1, Modal, ActivityIndicator as ActivityIndicator$1, ImageBackground, Image as Image$2 } from 'react-native';
|
|
2
2
|
import * as React$3 from 'react';
|
|
3
|
-
import React__default, { memo, forwardRef as forwardRef$1, useMemo, useState, useEffect, useRef, useImperativeHandle
|
|
3
|
+
import React__default, { memo, useCallback, forwardRef as forwardRef$1, useMemo, useState, useEffect, useRef, useImperativeHandle } from 'react';
|
|
4
4
|
import require$$1 from 'deepmerge';
|
|
5
5
|
import color from 'color';
|
|
6
|
+
import Animated$1, { useSharedValue, withSequence, withTiming, withSpring, useAnimatedStyle, interpolateColor, useAnimatedReaction } from 'react-native-reanimated';
|
|
6
7
|
import FontAwesome from 'react-native-vector-icons/FontAwesome';
|
|
7
8
|
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
|
8
9
|
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
|
@@ -1708,7 +1709,7 @@ var ActivityIndicator = function (_a) {
|
|
|
1708
1709
|
height: size / 2,
|
|
1709
1710
|
overflow: "hidden",
|
|
1710
1711
|
};
|
|
1711
|
-
return (React$3.createElement(View$1, __assign({ style: [styles$
|
|
1712
|
+
return (React$3.createElement(View$1, __assign({ style: [styles$j.container, style] }, rest, { accessible: true, accessibilityRole: "progressbar", accessibilityState: { busy: animating } }),
|
|
1712
1713
|
React$3.createElement(Animated.View, { style: [{ width: size, height: size, opacity: fade }], collapsable: false }, [0, 1].map(function (index) {
|
|
1713
1714
|
// Thanks to https://github.com/n4kz/react-native-indicators for the great work
|
|
1714
1715
|
var inputRange = Array.from(new Array(frames), function (_, frameIndex) { return frameIndex / (frames - 1); });
|
|
@@ -1753,7 +1754,7 @@ var ActivityIndicator = function (_a) {
|
|
|
1753
1754
|
borderWidth: size / 10,
|
|
1754
1755
|
borderRadius: size / 2,
|
|
1755
1756
|
};
|
|
1756
|
-
return (React$3.createElement(Animated.View, { key: index, style: [styles$
|
|
1757
|
+
return (React$3.createElement(Animated.View, { key: index, style: [styles$j.layer] },
|
|
1757
1758
|
React$3.createElement(Animated.View, { style: layerStyle },
|
|
1758
1759
|
React$3.createElement(Animated.View, { style: [containerStyle, offsetStyle], collapsable: false },
|
|
1759
1760
|
React$3.createElement(Animated.View, { style: viewportStyle },
|
|
@@ -1761,7 +1762,7 @@ var ActivityIndicator = function (_a) {
|
|
|
1761
1762
|
React$3.createElement(Animated.View, { style: lineStyle })))))));
|
|
1762
1763
|
}))));
|
|
1763
1764
|
};
|
|
1764
|
-
var styles$
|
|
1765
|
+
var styles$j = StyleSheet.create({
|
|
1765
1766
|
container: {
|
|
1766
1767
|
justifyContent: "center",
|
|
1767
1768
|
alignItems: "center",
|
|
@@ -1869,11 +1870,11 @@ var ProgressBar = function (_a) {
|
|
|
1869
1870
|
? {}
|
|
1870
1871
|
: { min: 0, max: 100, now: Math.round(progress * 100) }, testID: testID }),
|
|
1871
1872
|
React$3.createElement(Animated.View, { style: [
|
|
1872
|
-
styles$
|
|
1873
|
+
styles$i.container,
|
|
1873
1874
|
{ backgroundColor: trackTintColor, opacity: fade },
|
|
1874
1875
|
style,
|
|
1875
1876
|
] }, width ? (React$3.createElement(Animated.View, { testID: "".concat(testID, "-fill"), style: [
|
|
1876
|
-
styles$
|
|
1877
|
+
styles$i.progressBar,
|
|
1877
1878
|
{
|
|
1878
1879
|
width: width,
|
|
1879
1880
|
backgroundColor: tintColor,
|
|
@@ -1917,7 +1918,7 @@ var ProgressBar = function (_a) {
|
|
|
1917
1918
|
fillStyle,
|
|
1918
1919
|
] })) : null)));
|
|
1919
1920
|
};
|
|
1920
|
-
var styles$
|
|
1921
|
+
var styles$i = StyleSheet.create({
|
|
1921
1922
|
container: {
|
|
1922
1923
|
height: 4,
|
|
1923
1924
|
overflow: "hidden",
|
|
@@ -2055,109 +2056,86 @@ var ViewCustom = function (_a) {
|
|
|
2055
2056
|
};
|
|
2056
2057
|
var View = React__default.memo(ViewCustom);
|
|
2057
2058
|
|
|
2058
|
-
var
|
|
2059
|
-
var
|
|
2060
|
-
if (color) {
|
|
2061
|
-
return color;
|
|
2062
|
-
}
|
|
2063
|
-
return theme.colors.toggleBackgroundActive;
|
|
2064
|
-
};
|
|
2065
|
-
var getThumbTintColor = function (_a) {
|
|
2066
|
-
var theme = _a.theme, disabled = _a.disabled, value = _a.value, checkedColor = _a.checkedColor;
|
|
2067
|
-
var isIOS = Platform.OS === "ios";
|
|
2068
|
-
if (isIOS) {
|
|
2069
|
-
return undefined;
|
|
2070
|
-
}
|
|
2071
|
-
if (disabled) {
|
|
2072
|
-
if (theme.dark) {
|
|
2073
|
-
return theme.colors.toggleBackgroundDefault;
|
|
2074
|
-
}
|
|
2075
|
-
return theme.colors.toggleBackgroundDefault;
|
|
2076
|
-
}
|
|
2077
|
-
if (value) {
|
|
2078
|
-
return checkedColor;
|
|
2079
|
-
}
|
|
2080
|
-
if (theme.dark) {
|
|
2081
|
-
return theme.colors.toggleBackgroundDefault;
|
|
2082
|
-
}
|
|
2083
|
-
return theme.colors.toggleBackgroundDefault;
|
|
2084
|
-
};
|
|
2085
|
-
var getOnTintColor = function (_a) {
|
|
2086
|
-
var theme = _a.theme, disabled = _a.disabled, value = _a.value, checkedColor = _a.checkedColor;
|
|
2087
|
-
var isIOS = Platform.OS === "ios";
|
|
2088
|
-
if (isIOS) {
|
|
2089
|
-
return checkedColor;
|
|
2090
|
-
}
|
|
2091
|
-
if (disabled) {
|
|
2092
|
-
if (theme.dark) {
|
|
2093
|
-
return theme.colors.toggleBackgroundDefault;
|
|
2094
|
-
}
|
|
2095
|
-
return theme.colors.toggleBackgroundDefault;
|
|
2096
|
-
}
|
|
2097
|
-
if (value) {
|
|
2098
|
-
return checkedColor;
|
|
2099
|
-
}
|
|
2100
|
-
if (theme.dark) {
|
|
2101
|
-
return theme.colors.toggleBackgroundDefault;
|
|
2102
|
-
}
|
|
2103
|
-
return theme.colors.toggleBackgroundDefault;
|
|
2104
|
-
};
|
|
2105
|
-
var getSwitchColor = function (_a) {
|
|
2106
|
-
var theme = _a.theme, disabled = _a.disabled, value = _a.value, color = _a.color;
|
|
2107
|
-
var checkedColor = getCheckedColor({ theme: theme, color: color });
|
|
2108
|
-
return {
|
|
2109
|
-
onTintColor: getOnTintColor({ theme: theme, disabled: disabled, value: value, checkedColor: checkedColor }),
|
|
2110
|
-
thumbTintColor: getThumbTintColor({ theme: theme, disabled: disabled, value: value, checkedColor: checkedColor }),
|
|
2111
|
-
checkedColor: checkedColor,
|
|
2112
|
-
};
|
|
2113
|
-
};
|
|
2114
|
-
|
|
2115
|
-
var version = NativeModules.PlatformConstants
|
|
2116
|
-
? NativeModules.PlatformConstants.reactNativeVersion
|
|
2117
|
-
: undefined;
|
|
2118
|
-
/**
|
|
2119
|
-
* Switch is a visual toggle between two mutually exclusive states — on and off.
|
|
2120
|
-
*
|
|
2121
|
-
* ## Usage
|
|
2122
|
-
* ```js
|
|
2123
|
-
* import * as React from 'react';
|
|
2124
|
-
* import { Switch } from 'react-native-paper';
|
|
2125
|
-
*
|
|
2126
|
-
* const MyComponent = () => {
|
|
2127
|
-
* const [isSwitchOn, setIsSwitchOn] = React.useState(false);
|
|
2128
|
-
*
|
|
2129
|
-
* const onToggleSwitch = () => setIsSwitchOn(!isSwitchOn);
|
|
2130
|
-
*
|
|
2131
|
-
* return <Switch value={isSwitchOn} onValueChange={onToggleSwitch} />;
|
|
2132
|
-
* };
|
|
2133
|
-
*
|
|
2134
|
-
* export default MyComponent;
|
|
2135
|
-
* ```
|
|
2136
|
-
*/
|
|
2137
|
-
var Switch = function (_a) {
|
|
2138
|
-
var value = _a.value, disabled = _a.disabled, onValueChange = _a.onValueChange, color = _a.color; _a.theme; var rest = __rest(_a, ["value", "disabled", "onValueChange", "color", "theme"]);
|
|
2059
|
+
var Switch = memo(function (_a) {
|
|
2060
|
+
var value = _a.value, disabled = _a.disabled, onValueChange = _a.onValueChange;
|
|
2139
2061
|
var theme = useInternalTheme();
|
|
2140
|
-
var
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2062
|
+
var colors = theme.colors;
|
|
2063
|
+
var progress = useSharedValue(value ? 1 : 0);
|
|
2064
|
+
var handleSwitch = useCallback(function () {
|
|
2065
|
+
if (disabled)
|
|
2066
|
+
return;
|
|
2067
|
+
var newValue = !value;
|
|
2068
|
+
progress.value = withSequence(withTiming(newValue ? 1 : 0, {
|
|
2069
|
+
duration: 150,
|
|
2070
|
+
}), withSpring(newValue ? 1 : 0, {
|
|
2071
|
+
damping: 20,
|
|
2072
|
+
stiffness: 200,
|
|
2073
|
+
mass: 0.5,
|
|
2074
|
+
velocity: 0.5,
|
|
2075
|
+
}));
|
|
2076
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue);
|
|
2077
|
+
}, [disabled, value, onValueChange]);
|
|
2078
|
+
var animatedStyle = useAnimatedStyle(function () {
|
|
2079
|
+
return {
|
|
2080
|
+
transform: [{ translateX: progress.value * 20 }],
|
|
2157
2081
|
};
|
|
2082
|
+
});
|
|
2083
|
+
var backgroundColor = useAnimatedStyle(function () {
|
|
2084
|
+
return {
|
|
2085
|
+
backgroundColor: interpolateColor(progress.value, [0, 1], [colors.toggleBackgroundDefault, colors.toggleBackgroundActive]),
|
|
2086
|
+
};
|
|
2087
|
+
});
|
|
2088
|
+
useAnimatedReaction(function () { return value; }, function (currentValue) {
|
|
2089
|
+
if (currentValue !== undefined) {
|
|
2090
|
+
progress.value = withSequence(withTiming(currentValue ? 1 : 0, {
|
|
2091
|
+
duration: 150,
|
|
2092
|
+
}), withSpring(currentValue ? 1 : 0, {
|
|
2093
|
+
damping: 20,
|
|
2094
|
+
stiffness: 200,
|
|
2095
|
+
mass: 0.5,
|
|
2096
|
+
velocity: 0.5,
|
|
2097
|
+
}));
|
|
2098
|
+
}
|
|
2099
|
+
}, [value]);
|
|
2158
2100
|
return (React$3.createElement(View, { row: true },
|
|
2159
|
-
React$3.createElement(
|
|
2160
|
-
|
|
2101
|
+
React$3.createElement(TouchableOpacity, { activeOpacity: 1, onPress: handleSwitch, disabled: disabled, style: disabled ? { opacity: 0.6 } : {} },
|
|
2102
|
+
React$3.createElement(Animated$1.View, { style: [
|
|
2103
|
+
styles$h.vSegment,
|
|
2104
|
+
backgroundColor,
|
|
2105
|
+
{
|
|
2106
|
+
width: 52,
|
|
2107
|
+
height: 32,
|
|
2108
|
+
},
|
|
2109
|
+
] },
|
|
2110
|
+
React$3.createElement(Animated$1.View, { style: [
|
|
2111
|
+
styles$h.animated,
|
|
2112
|
+
animatedStyle,
|
|
2113
|
+
{
|
|
2114
|
+
width: 28,
|
|
2115
|
+
height: 28,
|
|
2116
|
+
borderRadius: 14,
|
|
2117
|
+
backgroundColor: colors.surfacePrimaryDefault,
|
|
2118
|
+
},
|
|
2119
|
+
] })))));
|
|
2120
|
+
});
|
|
2121
|
+
var styles$h = StyleSheet.create({
|
|
2122
|
+
vSegment: {
|
|
2123
|
+
overflow: "hidden",
|
|
2124
|
+
borderRadius: 100,
|
|
2125
|
+
flexDirection: "row",
|
|
2126
|
+
alignItems: "center",
|
|
2127
|
+
},
|
|
2128
|
+
animated: {
|
|
2129
|
+
position: "absolute",
|
|
2130
|
+
// shadowColor: "#000000",
|
|
2131
|
+
// shadowOffset: { width: 0, height: 0 },
|
|
2132
|
+
// shadowOpacity: 0.15,
|
|
2133
|
+
// shadowRadius: BORDER_RADIUS_6,
|
|
2134
|
+
// elevation: 5,
|
|
2135
|
+
marginHorizontal: 2,
|
|
2136
|
+
},
|
|
2137
|
+
});
|
|
2138
|
+
Switch.displayName = "Switch";
|
|
2161
2139
|
|
|
2162
2140
|
var AdornmentType;
|
|
2163
2141
|
(function (AdornmentType) {
|