@momo-kits/stepper 0.112.1-beta.11 → 0.112.1-beta.13
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/NumberView.tsx +3 -5
- package/StepperButton.tsx +9 -4
- package/index.tsx +19 -7
- package/package.json +1 -1
- package/styles.ts +2 -2
- package/types.ts +2 -17
package/NumberView.tsx
CHANGED
|
@@ -10,7 +10,7 @@ const NumberView: FC<StepperValueProps> = ({
|
|
|
10
10
|
editable = false,
|
|
11
11
|
onValueChange,
|
|
12
12
|
disabled,
|
|
13
|
-
|
|
13
|
+
componentId,
|
|
14
14
|
}) => {
|
|
15
15
|
const {theme} = useContext(ApplicationContext);
|
|
16
16
|
const sizeStyle =
|
|
@@ -40,10 +40,8 @@ const NumberView: FC<StepperValueProps> = ({
|
|
|
40
40
|
onChangeText={onValueChange}
|
|
41
41
|
keyboardType={'number-pad'}
|
|
42
42
|
selectionColor={theme.colors.primary}
|
|
43
|
-
accessibilityLabel={
|
|
44
|
-
accessibilityState={{
|
|
45
|
-
disabled: !editable,
|
|
46
|
-
}}
|
|
43
|
+
accessibilityLabel={`${componentId}|input`}
|
|
44
|
+
accessibilityState={{disabled}}
|
|
47
45
|
/>
|
|
48
46
|
</View>
|
|
49
47
|
);
|
package/StepperButton.tsx
CHANGED
|
@@ -9,7 +9,7 @@ const StepperButton: FC<StepperButtonProps> = ({
|
|
|
9
9
|
sign = '+',
|
|
10
10
|
size = 'large',
|
|
11
11
|
onPress,
|
|
12
|
-
|
|
12
|
+
componentId,
|
|
13
13
|
}) => {
|
|
14
14
|
const {theme} = useContext(ApplicationContext);
|
|
15
15
|
|
|
@@ -21,9 +21,14 @@ const StepperButton: FC<StepperButtonProps> = ({
|
|
|
21
21
|
: theme.colors.primary;
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
|
-
<TouchableOpacity
|
|
25
|
-
disabled
|
|
26
|
-
|
|
24
|
+
<TouchableOpacity
|
|
25
|
+
disabled={disabled}
|
|
26
|
+
onPress={onPress}
|
|
27
|
+
style={[sizeStyle]}
|
|
28
|
+
accessibilityState={{disabled}}
|
|
29
|
+
accessibilityLabel={`${componentId}|${
|
|
30
|
+
sign === '+' ? 'plus' : 'minus'
|
|
31
|
+
}-touch`}>
|
|
27
32
|
<Icon size={22} color={buttonColor} source={buttonIcon} />
|
|
28
33
|
</TouchableOpacity>
|
|
29
34
|
);
|
package/index.tsx
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
forwardRef,
|
|
3
|
+
useContext,
|
|
3
4
|
useEffect,
|
|
4
5
|
useImperativeHandle,
|
|
6
|
+
useMemo,
|
|
5
7
|
useState,
|
|
6
8
|
} from 'react';
|
|
7
9
|
import {View} from 'react-native';
|
|
@@ -9,6 +11,7 @@ import StepperButton from './StepperButton';
|
|
|
9
11
|
import {DisabledStatus, StepperProps} from './types';
|
|
10
12
|
import styles from './styles';
|
|
11
13
|
import NumberView from './NumberView';
|
|
14
|
+
import {MiniAppContext, ScreenContext} from '@momo-kits/foundation';
|
|
12
15
|
|
|
13
16
|
const Stepper = forwardRef(
|
|
14
17
|
(
|
|
@@ -22,14 +25,23 @@ const Stepper = forwardRef(
|
|
|
22
25
|
editable = false,
|
|
23
26
|
onValueChange,
|
|
24
27
|
accessibilityLabel,
|
|
25
|
-
accessbibilityLabelMinus,
|
|
26
|
-
accessbibilityLabelPlus,
|
|
27
|
-
accessbibilityLabelNumber
|
|
28
28
|
}: StepperProps,
|
|
29
29
|
ref
|
|
30
30
|
) => {
|
|
31
31
|
const [value, setValue] = useState(defaultValue);
|
|
32
32
|
|
|
33
|
+
const app = useContext<any>(MiniAppContext);
|
|
34
|
+
const screen = useContext<any>(ScreenContext);
|
|
35
|
+
const componentName = 'Stepper';
|
|
36
|
+
|
|
37
|
+
const componentId = useMemo(() => {
|
|
38
|
+
if (accessibilityLabel) {
|
|
39
|
+
return accessibilityLabel;
|
|
40
|
+
}
|
|
41
|
+
let id = `${app.appId}/${app.code}/${screen.screenName}/${componentName}`;
|
|
42
|
+
return id;
|
|
43
|
+
}, [componentName, accessibilityLabel, app, screen]);
|
|
44
|
+
|
|
33
45
|
useImperativeHandle(ref, () => ({
|
|
34
46
|
setStepValue: (value: React.SetStateAction<number>) => {
|
|
35
47
|
setValue(value);
|
|
@@ -96,13 +108,13 @@ const Stepper = forwardRef(
|
|
|
96
108
|
const viewStatus = getViewDisabledStatus();
|
|
97
109
|
|
|
98
110
|
return (
|
|
99
|
-
<View style={styles.stepper} accessibilityLabel={
|
|
111
|
+
<View style={styles.stepper} accessibilityLabel={componentId}>
|
|
100
112
|
<StepperButton
|
|
101
113
|
onPress={onMinus}
|
|
102
114
|
sign={'-'}
|
|
103
115
|
size={size}
|
|
104
116
|
disabled={viewStatus.minus}
|
|
105
|
-
|
|
117
|
+
componentId={componentId}
|
|
106
118
|
/>
|
|
107
119
|
<NumberView
|
|
108
120
|
onValueChange={_onValueChange}
|
|
@@ -110,13 +122,13 @@ const Stepper = forwardRef(
|
|
|
110
122
|
value={value}
|
|
111
123
|
disabled={viewStatus.number}
|
|
112
124
|
editable={editable}
|
|
113
|
-
|
|
125
|
+
componentId={componentId}
|
|
114
126
|
/>
|
|
115
127
|
<StepperButton
|
|
116
128
|
onPress={onPlus}
|
|
117
129
|
size={size}
|
|
118
130
|
disabled={viewStatus.plus}
|
|
119
|
-
|
|
131
|
+
componentId={componentId}
|
|
120
132
|
/>
|
|
121
133
|
</View>
|
|
122
134
|
);
|
package/package.json
CHANGED
package/styles.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {StyleSheet} from 'react-native';
|
|
2
|
-
import {Colors, Radius, Spacing} from '@momo-kits/foundation';
|
|
2
|
+
import {Colors, Radius, scaleSize, Spacing} from '@momo-kits/foundation';
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
button: {
|
|
@@ -49,7 +49,7 @@ export default StyleSheet.create({
|
|
|
49
49
|
marginHorizontal: Spacing.S,
|
|
50
50
|
},
|
|
51
51
|
input: {
|
|
52
|
-
fontSize: 12,
|
|
52
|
+
fontSize: scaleSize(12),
|
|
53
53
|
paddingVertical: 0,
|
|
54
54
|
textAlign: 'center',
|
|
55
55
|
},
|
package/types.ts
CHANGED
|
@@ -29,7 +29,7 @@ export type StepperButtonProps = {
|
|
|
29
29
|
/**
|
|
30
30
|
* Optional. Assign accessibility label to the button for automated testing.
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
componentId: string;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
/**
|
|
@@ -67,7 +67,7 @@ export type StepperValueProps = {
|
|
|
67
67
|
/**
|
|
68
68
|
* Optional. Assign accessibility label to the button for automated testing.
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
componentId: string;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
/**
|
|
@@ -126,21 +126,6 @@ export type StepperProps = {
|
|
|
126
126
|
* Optional. Assign accessibility label to the button for automated testing.
|
|
127
127
|
*/
|
|
128
128
|
accessibilityLabel?: string;
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Optional. Assign accessibility label to the button for automated testing.
|
|
132
|
-
*/
|
|
133
|
-
accessbibilityLabelPlus?: string;
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Optional. Assign accessibility label to the button for automated testing.
|
|
137
|
-
*/
|
|
138
|
-
accessbibilityLabelMinus?: string;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Optional. Assign accessibility label to the button for automated testing.
|
|
142
|
-
*/
|
|
143
|
-
accessbibilityLabelNumber?: string;
|
|
144
129
|
};
|
|
145
130
|
|
|
146
131
|
/**
|