sapo-components-ui-rn 1.1.70 → 1.1.72
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/Switch/Switch.d.ts +2 -1
- package/dist/index.esm.js +36 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +36 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Switch/Switch.tsx +113 -92
- package/src/components/TextInput/TextInputNumber.tsx +1 -1
|
@@ -8,10 +8,11 @@ export type Props = {
|
|
|
8
8
|
* Value of the switch, true means 'on', false means 'off'.
|
|
9
9
|
*/
|
|
10
10
|
value?: boolean;
|
|
11
|
+
size?: "small" | "normal";
|
|
11
12
|
/**
|
|
12
13
|
* Callback called with the new value when it changes.
|
|
13
14
|
*/
|
|
14
15
|
onValueChange?: (value: boolean) => void;
|
|
15
16
|
};
|
|
16
|
-
declare const Switch: React.MemoExoticComponent<({ value, disabled, onValueChange }: Props) => React.JSX.Element>;
|
|
17
|
+
declare const Switch: React.MemoExoticComponent<({ value, disabled, onValueChange, size }: Props) => React.JSX.Element>;
|
|
17
18
|
export default Switch;
|
package/dist/index.esm.js
CHANGED
|
@@ -1594,7 +1594,7 @@ var ViewCustom = forwardRef$1(function (_a, ref) {
|
|
|
1594
1594
|
var View = React__default.memo(ViewCustom);
|
|
1595
1595
|
|
|
1596
1596
|
var Switch = memo(function (_a) {
|
|
1597
|
-
var value = _a.value, disabled = _a.disabled, onValueChange = _a.onValueChange;
|
|
1597
|
+
var value = _a.value, disabled = _a.disabled, onValueChange = _a.onValueChange, _b = _a.size, size = _b === void 0 ? "normal" : _b;
|
|
1598
1598
|
var theme = useInternalTheme();
|
|
1599
1599
|
var colors = theme.colors;
|
|
1600
1600
|
var progress = useSharedValue(value ? 1 : 0);
|
|
@@ -1634,26 +1634,42 @@ var Switch = memo(function (_a) {
|
|
|
1634
1634
|
}));
|
|
1635
1635
|
}
|
|
1636
1636
|
}, [value]);
|
|
1637
|
+
var getSizeSwitch = useCallback(function () {
|
|
1638
|
+
switch (size) {
|
|
1639
|
+
case "small":
|
|
1640
|
+
return {
|
|
1641
|
+
width: 48,
|
|
1642
|
+
height: 28,
|
|
1643
|
+
};
|
|
1644
|
+
default:
|
|
1645
|
+
return {
|
|
1646
|
+
width: 52,
|
|
1647
|
+
height: 32,
|
|
1648
|
+
};
|
|
1649
|
+
}
|
|
1650
|
+
}, [size]);
|
|
1651
|
+
var getSizeCircle = useCallback(function () {
|
|
1652
|
+
switch (size) {
|
|
1653
|
+
case "small":
|
|
1654
|
+
return {
|
|
1655
|
+
width: 24,
|
|
1656
|
+
height: 24,
|
|
1657
|
+
borderRadius: 12,
|
|
1658
|
+
backgroundColor: colors.surfacePrimaryDefault,
|
|
1659
|
+
};
|
|
1660
|
+
default:
|
|
1661
|
+
return {
|
|
1662
|
+
width: 28,
|
|
1663
|
+
height: 28,
|
|
1664
|
+
borderRadius: 14,
|
|
1665
|
+
backgroundColor: colors.surfacePrimaryDefault,
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
}, [size, colors]);
|
|
1637
1669
|
return (React$3.createElement(View, { row: true },
|
|
1638
1670
|
React$3.createElement(TouchableOpacity, { activeOpacity: 1, onPress: handleSwitch, disabled: disabled, style: disabled ? { opacity: 0.6 } : {} },
|
|
1639
|
-
React$3.createElement(Animated.View, { style: [
|
|
1640
|
-
|
|
1641
|
-
backgroundColor,
|
|
1642
|
-
{
|
|
1643
|
-
width: 52,
|
|
1644
|
-
height: 32,
|
|
1645
|
-
},
|
|
1646
|
-
] },
|
|
1647
|
-
React$3.createElement(Animated.View, { style: [
|
|
1648
|
-
styles$j.animated,
|
|
1649
|
-
animatedStyle,
|
|
1650
|
-
{
|
|
1651
|
-
width: 28,
|
|
1652
|
-
height: 28,
|
|
1653
|
-
borderRadius: 14,
|
|
1654
|
-
backgroundColor: colors.surfacePrimaryDefault,
|
|
1655
|
-
},
|
|
1656
|
-
] })))));
|
|
1671
|
+
React$3.createElement(Animated.View, { style: [styles$j.vSegment, backgroundColor, getSizeSwitch()] },
|
|
1672
|
+
React$3.createElement(Animated.View, { style: [styles$j.animated, animatedStyle, getSizeCircle()] })))));
|
|
1657
1673
|
});
|
|
1658
1674
|
var styles$j = StyleSheet.create({
|
|
1659
1675
|
vSegment: {
|
|
@@ -5799,7 +5815,7 @@ var TextInputNumber = function (_a) {
|
|
|
5799
5815
|
borderRadius: BORDER_RADIUS_6,
|
|
5800
5816
|
},
|
|
5801
5817
|
{
|
|
5802
|
-
height: height ? height :
|
|
5818
|
+
height: height ? height : 48,
|
|
5803
5819
|
},
|
|
5804
5820
|
[
|
|
5805
5821
|
styles$c.border,
|