@momo-kits/stepper 0.169.4 → 0.169.6

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 CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  } from '@momo-kits/foundation';
9
9
  import styles from './styles';
10
10
 
11
+ /** Stepper value box, typable when `editable`; shows "0" for NaN. */
11
12
  const NumberView: FC<StepperValueProps> = ({
12
13
  value = 0,
13
14
  size = 'large',
package/StepperButton.tsx CHANGED
@@ -1,9 +1,10 @@
1
- import React, {FC, useContext} from 'react';
2
- import {TouchableOpacity} from 'react-native';
1
+ import React, { FC, useContext } from 'react';
2
+ import { TouchableOpacity } from 'react-native';
3
3
  import styles from './styles';
4
- import {StepperButtonProps} from './types';
5
- import {ApplicationContext, Icon} from '@momo-kits/foundation';
4
+ import { StepperButtonProps } from './types';
5
+ import { ApplicationContext, Icon } from '@momo-kits/foundation';
6
6
 
7
+ /** Round plus or minus button of the Stepper. */
7
8
  const StepperButton: FC<StepperButtonProps> = ({
8
9
  disabled = false,
9
10
  sign = '+',
@@ -11,7 +12,7 @@ const StepperButton: FC<StepperButtonProps> = ({
11
12
  onPress,
12
13
  componentId,
13
14
  }) => {
14
- const {theme} = useContext(ApplicationContext);
15
+ const { theme } = useContext(ApplicationContext);
15
16
 
16
17
  const colors = theme.colors;
17
18
 
@@ -21,16 +22,16 @@ const StepperButton: FC<StepperButtonProps> = ({
21
22
  buttonIcon = '24_navigation_minus_circle';
22
23
  }
23
24
  const buttonColor = disabled ? colors.text.disable : colors.primary;
25
+ const signName = sign === '+' ? 'plus' : 'minus';
24
26
 
25
27
  return (
26
28
  <TouchableOpacity
27
29
  disabled={disabled}
28
30
  onPress={onPress}
29
31
  style={[sizeStyle]}
30
- accessibilityState={{disabled}}
31
- accessibilityLabel={`${componentId}|${
32
- sign === '+' ? 'plus' : 'minus'
33
- }-touch`}>
32
+ accessibilityState={{ disabled }}
33
+ accessibilityLabel={`${componentId}|${signName}-touch`}
34
+ >
34
35
  <Icon size={22} color={buttonColor} source={buttonIcon} />
35
36
  </TouchableOpacity>
36
37
  );
package/index.tsx CHANGED
@@ -6,13 +6,17 @@ import React, {
6
6
  useMemo,
7
7
  useState,
8
8
  } from 'react';
9
- import {View} from 'react-native';
9
+ import { View } from 'react-native';
10
10
  import StepperButton from './StepperButton';
11
- import {DisabledStatus, StepperProps} from './types';
11
+ import { DisabledStatus, StepperProps } from './types';
12
12
  import styles from './styles';
13
13
  import NumberView from './NumberView';
14
- import {MiniAppContext, ScreenContext} from '@momo-kits/foundation';
14
+ import { MiniAppContext, ScreenContext } from '@momo-kits/foundation';
15
15
 
16
+ /**
17
+ * Numeric stepper with minus/plus buttons and an optional editable value.
18
+ * Values are clamped to [min, max]; the ref exposes `setStepValue`.
19
+ */
16
20
  const Stepper = forwardRef(
17
21
  (
18
22
  {
@@ -26,7 +30,7 @@ const Stepper = forwardRef(
26
30
  onValueChange,
27
31
  accessibilityLabel,
28
32
  }: StepperProps,
29
- ref
33
+ ref,
30
34
  ) => {
31
35
  const [value, setValue] = useState(defaultValue);
32
36
 
@@ -132,8 +136,8 @@ const Stepper = forwardRef(
132
136
  />
133
137
  </View>
134
138
  );
135
- }
139
+ },
136
140
  );
137
141
 
138
- export {Stepper};
139
- export type {StepperProps};
142
+ export { Stepper };
143
+ export type { StepperProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/stepper",
3
- "version": "0.169.4",
3
+ "version": "0.169.6",
4
4
  "private": false,
5
5
  "main": "index.tsx",
6
6
  "peerDependencies": {
package/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {ViewStyle} from 'react-native';
1
+ import { ViewStyle } from 'react-native';
2
2
 
3
3
  /**
4
4
  * Properties for the StepperButton component, which represents the individual
@@ -27,13 +27,13 @@ export type StepperButtonProps = {
27
27
  onPress: () => void;
28
28
 
29
29
  /**
30
- * Optional. Assign accessibility label to the button for automated testing.
30
+ * Accessibility label prefix of the Stepper, used for automated testing.
31
31
  */
32
32
  componentId: string;
33
33
  };
34
34
 
35
35
  /**
36
- * Properties for the StepperValue component, which displays the current value
36
+ * Properties for the NumberView component, which displays the current value
37
37
  * within a stepper control and allows for direct input.
38
38
  */
39
39
  export type StepperValueProps = {
@@ -65,7 +65,7 @@ export type StepperValueProps = {
65
65
  onValueChange?: (value: string) => void;
66
66
 
67
67
  /**
68
- * Optional. Assign accessibility label to the button for automated testing.
68
+ * Accessibility label prefix of the Stepper, used for automated testing.
69
69
  */
70
70
  componentId: string;
71
71
  };
@@ -81,18 +81,19 @@ export type StepperProps = {
81
81
  defaultValue: number;
82
82
 
83
83
  /**
84
- * Optional. The minimum allowable value for the stepper. If not provided, there is no minimum.
84
+ * Optional. The minimum allowable value for the stepper. Defaults to 0.
85
85
  */
86
86
  min?: number;
87
87
 
88
88
  /**
89
- * Optional. The maximum allowable value for the stepper. If not provided, there is no maximum.
89
+ * Optional. The maximum allowable value for the stepper. Defaults to 100.
90
90
  */
91
91
  max?: number;
92
92
 
93
93
  /**
94
94
  * Optional. Specifies whether the entire stepper control or specific parts are disabled.
95
- * Can be a single boolean (to disable all) or an array of booleans (to control individual components).
95
+ * A boolean disables all; `[minus, plus]` disables each button, and the
96
+ * value input only when both are `true`.
96
97
  */
97
98
  disabled?: boolean | boolean[];
98
99