@momo-kits/stepper 0.153.2-beta.3 → 0.154.1-beta.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.
Files changed (3) hide show
  1. package/NumberView.tsx +20 -37
  2. package/package.json +1 -1
  3. package/styles.ts +11 -0
package/NumberView.tsx CHANGED
@@ -1,7 +1,7 @@
1
- import React, {FC, useContext} from 'react';
2
- import {TextInput, View, StyleSheet} from 'react-native';
3
- import {StepperValueProps} from './types';
4
- import {ApplicationContext, useScaleSize, Radius, Spacing} from '@momo-kits/foundation';
1
+ import React, { FC, useContext } from 'react';
2
+ import { TextInput, View } from 'react-native';
3
+ import { StepperValueProps } from './types';
4
+ import { ApplicationContext, useScaleSize } from '@momo-kits/foundation';
5
5
  import styles from './styles';
6
6
 
7
7
  const NumberView: FC<StepperValueProps> = ({
@@ -12,39 +12,10 @@ const NumberView: FC<StepperValueProps> = ({
12
12
  disabled,
13
13
  componentId,
14
14
  }) => {
15
- const {theme} = useContext(ApplicationContext);
15
+ const { theme } = useContext(ApplicationContext);
16
16
  const scaledHeight28 = useScaleSize(28);
17
17
  const scaledHeight24 = useScaleSize(24);
18
18
  const scaledFontSize = useScaleSize(12);
19
-
20
- const dynamicStyles = StyleSheet.create({
21
- numberView: {
22
- minWidth: 32,
23
- height: scaledHeight28,
24
- borderWidth: 1,
25
- borderRadius: Radius.S,
26
- justifyContent: 'center',
27
- alignItems: 'center',
28
- marginHorizontal: Spacing.S,
29
- },
30
- numberViewSmall: {
31
- minWidth: 28,
32
- height: scaledHeight24,
33
- borderWidth: 1,
34
- borderRadius: Radius.S,
35
- justifyContent: 'center',
36
- alignItems: 'center',
37
- marginHorizontal: Spacing.S,
38
- },
39
- input: {
40
- fontSize: scaledFontSize,
41
- paddingVertical: 0,
42
- textAlign: 'center',
43
- },
44
- });
45
-
46
- const sizeStyle =
47
- size === 'large' ? dynamicStyles.numberView : dynamicStyles.numberViewSmall;
48
19
 
49
20
  const formattedNumber = (value: number) => {
50
21
  if (isNaN(value)) {
@@ -62,17 +33,29 @@ const NumberView: FC<StepperValueProps> = ({
62
33
  ? theme.colors.border.disable
63
34
  : theme.colors.border.default;
64
35
  return (
65
- <View style={[sizeStyle, {borderColor}]}>
36
+ <View
37
+ style={[
38
+ styles.numberViewBase,
39
+ size === 'large'
40
+ ? { minWidth: 32, height: scaledHeight28 }
41
+ : { minWidth: 28, height: scaledHeight24 },
42
+ { borderColor },
43
+ ]}
44
+ >
66
45
  <TextInput
67
46
  allowFontScaling={false}
68
47
  editable={editable}
69
- style={[dynamicStyles.input, {color: textColor}]}
48
+ style={[
49
+ styles.numberViewInput,
50
+ { fontSize: scaledFontSize },
51
+ { color: textColor },
52
+ ]}
70
53
  value={formattedNumber(value)}
71
54
  onChangeText={onValueChange}
72
55
  keyboardType={'number-pad'}
73
56
  selectionColor={theme.colors.primary}
74
57
  accessibilityLabel={`${componentId}|input`}
75
- accessibilityState={{disabled}}
58
+ accessibilityState={{ disabled }}
76
59
  />
77
60
  </View>
78
61
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/stepper",
3
- "version": "0.153.2-beta.3",
3
+ "version": "0.154.1-beta.0",
4
4
  "private": false,
5
5
  "main": "index.tsx",
6
6
  "peerDependencies": {
package/styles.ts CHANGED
@@ -30,4 +30,15 @@ export default StyleSheet.create({
30
30
  flexDirection: 'row',
31
31
  alignItems: 'center',
32
32
  },
33
+ numberViewBase: {
34
+ borderWidth: 1,
35
+ borderRadius: Radius.S,
36
+ justifyContent: 'center',
37
+ alignItems: 'center',
38
+ marginHorizontal: Spacing.S,
39
+ },
40
+ numberViewInput: {
41
+ paddingVertical: 0,
42
+ textAlign: 'center',
43
+ },
33
44
  });