@arco-design/mobile-react 2.22.2 → 2.23.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 (98) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.en-US.md +2 -2
  3. package/README.md +2 -2
  4. package/cjs/carousel/index.d.ts +6 -0
  5. package/cjs/carousel/index.js +6 -4
  6. package/cjs/image-picker/index.js +18 -12
  7. package/cjs/image-picker/type.d.ts +10 -0
  8. package/cjs/index.d.ts +1 -0
  9. package/cjs/index.js +5 -1
  10. package/cjs/input/style/css/index.css +1 -0
  11. package/cjs/input/style/index.less +1 -0
  12. package/cjs/stepper/demo/style/css/mobile.css +4 -0
  13. package/cjs/stepper/demo/style/mobile.less +10 -0
  14. package/cjs/stepper/hooks/useButtonClick.d.ts +11 -0
  15. package/cjs/stepper/hooks/useButtonClick.js +74 -0
  16. package/cjs/stepper/hooks/useInputEvent.d.ts +9 -0
  17. package/cjs/stepper/hooks/useInputEvent.js +59 -0
  18. package/cjs/stepper/hooks/useValue.d.ts +6 -0
  19. package/cjs/stepper/hooks/useValue.js +44 -0
  20. package/cjs/stepper/index.d.ts +13 -0
  21. package/cjs/stepper/index.js +184 -0
  22. package/cjs/stepper/style/css/index.css +76 -0
  23. package/cjs/stepper/style/css/index.d.ts +2 -0
  24. package/cjs/stepper/style/css/index.js +5 -0
  25. package/cjs/stepper/style/index.d.ts +2 -0
  26. package/cjs/stepper/style/index.js +5 -0
  27. package/cjs/stepper/style/index.less +80 -0
  28. package/cjs/stepper/type.d.ts +159 -0
  29. package/cjs/stepper/type.js +3 -0
  30. package/cjs/style.d.ts +1 -0
  31. package/cjs/style.js +2 -0
  32. package/dist/index.js +439 -98
  33. package/dist/index.min.js +4 -4
  34. package/dist/style.css +64 -0
  35. package/dist/style.min.css +1 -1
  36. package/esm/carousel/index.d.ts +6 -0
  37. package/esm/carousel/index.js +6 -4
  38. package/esm/image-picker/index.js +18 -12
  39. package/esm/image-picker/type.d.ts +10 -0
  40. package/esm/index.d.ts +1 -0
  41. package/esm/index.js +1 -0
  42. package/esm/input/style/css/index.css +1 -0
  43. package/esm/input/style/index.less +1 -0
  44. package/esm/stepper/demo/style/css/mobile.css +4 -0
  45. package/esm/stepper/demo/style/mobile.less +10 -0
  46. package/esm/stepper/hooks/useButtonClick.d.ts +11 -0
  47. package/esm/stepper/hooks/useButtonClick.js +69 -0
  48. package/esm/stepper/hooks/useInputEvent.d.ts +9 -0
  49. package/esm/stepper/hooks/useInputEvent.js +53 -0
  50. package/esm/stepper/hooks/useValue.d.ts +6 -0
  51. package/esm/stepper/hooks/useValue.js +38 -0
  52. package/esm/stepper/index.d.ts +13 -0
  53. package/esm/stepper/index.js +157 -0
  54. package/esm/stepper/style/css/index.css +76 -0
  55. package/esm/stepper/style/css/index.d.ts +2 -0
  56. package/esm/stepper/style/css/index.js +2 -0
  57. package/esm/stepper/style/index.d.ts +2 -0
  58. package/esm/stepper/style/index.js +2 -0
  59. package/esm/stepper/style/index.less +80 -0
  60. package/esm/stepper/type.d.ts +159 -0
  61. package/esm/stepper/type.js +1 -0
  62. package/esm/style.d.ts +1 -0
  63. package/esm/style.js +1 -0
  64. package/package.json +3 -3
  65. package/tokens/app/arcodesign/default/css-variables.less +15 -0
  66. package/tokens/app/arcodesign/default/index.d.ts +15 -0
  67. package/tokens/app/arcodesign/default/index.js +16 -1
  68. package/tokens/app/arcodesign/default/index.json +180 -0
  69. package/tokens/app/arcodesign/default/index.less +15 -0
  70. package/tools/flexible.js +82 -63
  71. package/umd/carousel/index.d.ts +6 -0
  72. package/umd/carousel/index.js +6 -4
  73. package/umd/image-picker/index.js +18 -12
  74. package/umd/image-picker/type.d.ts +10 -0
  75. package/umd/index.d.ts +1 -0
  76. package/umd/index.js +7 -5
  77. package/umd/input/style/css/index.css +1 -0
  78. package/umd/input/style/index.less +1 -0
  79. package/umd/stepper/demo/style/css/mobile.css +4 -0
  80. package/umd/stepper/demo/style/mobile.less +10 -0
  81. package/umd/stepper/hooks/useButtonClick.d.ts +11 -0
  82. package/umd/stepper/hooks/useButtonClick.js +86 -0
  83. package/umd/stepper/hooks/useInputEvent.d.ts +9 -0
  84. package/umd/stepper/hooks/useInputEvent.js +71 -0
  85. package/umd/stepper/hooks/useValue.d.ts +6 -0
  86. package/umd/stepper/hooks/useValue.js +56 -0
  87. package/umd/stepper/index.d.ts +13 -0
  88. package/umd/stepper/index.js +185 -0
  89. package/umd/stepper/style/css/index.css +76 -0
  90. package/umd/stepper/style/css/index.d.ts +2 -0
  91. package/umd/stepper/style/css/index.js +15 -0
  92. package/umd/stepper/style/index.d.ts +2 -0
  93. package/umd/stepper/style/index.js +15 -0
  94. package/umd/stepper/style/index.less +80 -0
  95. package/umd/stepper/type.d.ts +159 -0
  96. package/umd/stepper/type.js +17 -0
  97. package/umd/style.d.ts +1 -0
  98. package/umd/style.js +4 -4
package/CHANGELOG.md CHANGED
@@ -3,6 +3,34 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.23.0](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.22.3...@arco-design/mobile-react@2.23.0) (2022-11-29)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * `ImagePicker` add click event ([#67](https://github.com/arco-design/arco-design-mobile/issues/67)) ([0f76fda](https://github.com/arco-design/arco-design-mobile/commit/0f76fda245ac9a171525800c1d170c93411f2820))
12
+
13
+
14
+ ### Features
15
+
16
+ * add new component `Stepper` ([#46](https://github.com/arco-design/arco-design-mobile/issues/46)) ([a6ce795](https://github.com/arco-design/arco-design-mobile/commit/a6ce7958345ca5170cf00b7efa5cf74d02ebe93d))
17
+
18
+
19
+
20
+
21
+
22
+ ## [2.22.3](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.22.2...@arco-design/mobile-react@2.22.3) (2022-11-23)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * `Carousel` supports autoPlayDirection ([#72](https://github.com/arco-design/arco-design-mobile/issues/72)) ([527aaf4](https://github.com/arco-design/arco-design-mobile/commit/527aaf4bdf86fe4cf995bd8e4bd2580e9db8c942))
28
+ * flexible.js support umd ([#73](https://github.com/arco-design/arco-design-mobile/issues/73)) ([d3f35c0](https://github.com/arco-design/arco-design-mobile/commit/d3f35c093a579bb404fff91dbf6437cdd93f19f7))
29
+
30
+
31
+
32
+
33
+
6
34
  ## [2.22.2](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.22.0...@arco-design/mobile-react@2.22.2) (2022-11-09)
7
35
 
8
36
 
package/README.en-US.md CHANGED
@@ -59,8 +59,8 @@ React & ReactDOM: **<a href="https://reactjs.org/docs/cdn-links.html" target="_b
59
59
  React Transition Group: **<a href="https://reactcommunity.org/react-transition-group/" target="_blank">Click here</a>**
60
60
 
61
61
  ```
62
- <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.22.0/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.22.0/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.22.3/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.22.3/dist/index.min.js"></script>
64
64
  ```
65
65
 
66
66
  ## Full import
package/README.md CHANGED
@@ -59,8 +59,8 @@ React & ReactDOM: **<a href="https://reactjs.org/docs/cdn-links.html" target="
59
59
  React Transition Group: **<a href="https://reactcommunity.org/react-transition-group/" target="_blank">戳这里获取</a>**
60
60
 
61
61
  ```
62
- <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.22.0/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.22.0/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.22.3/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.22.3/dist/index.min.js"></script>
64
64
  ```
65
65
 
66
66
  ## 引入全部
@@ -66,6 +66,12 @@ export interface CarouselProps {
66
66
  * @default true
67
67
  */
68
68
  autoPlay?: boolean;
69
+ /**
70
+ * 自动播放方向
71
+ * @en Direction when playing auto
72
+ * @default "normal"
73
+ */
74
+ autoPlayDirection?: 'normal' | 'reverse';
69
75
  /**
70
76
  * 是否响应手势滑动
71
77
  * @en Whether to respond to gesture swipe
@@ -42,6 +42,8 @@ var Carousel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
42
42
  loop = _props$loop === void 0 ? true : _props$loop,
43
43
  _props$autoPlay = props.autoPlay,
44
44
  autoPlay = _props$autoPlay === void 0 ? true : _props$autoPlay,
45
+ _props$autoPlayDirect = props.autoPlayDirection,
46
+ autoPlayDirection = _props$autoPlayDirect === void 0 ? 'normal' : _props$autoPlayDirect,
45
47
  _props$swipeable = props.swipeable,
46
48
  swipeable = _props$swipeable === void 0 ? true : _props$swipeable,
47
49
  _props$stayDuration = props.stayDuration,
@@ -164,7 +166,7 @@ var Carousel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
164
166
  transformsRef = _useRefState4[1],
165
167
  setTransforms = _useRefState4[2];
166
168
 
167
- var _useRefState5 = (0, _helpers.useRefState)('left'),
169
+ var _useRefState5 = (0, _helpers.useRefState)(autoPlayDirection === 'reverse' && autoPlay ? 'right' : 'left'),
168
170
  direction = _useRefState5[0],
169
171
  directionRef = _useRefState5[1],
170
172
  setStateDirection = _useRefState5[2];
@@ -401,7 +403,7 @@ var Carousel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
401
403
  return function () {
402
404
  clear();
403
405
  };
404
- }, [userSetBoxWidth, userSetBoxHeight, childWidth, childHeight, stayDuration, noInterval]);
406
+ }, [userSetBoxWidth, userSetBoxHeight, childWidth, childHeight, stayDuration, noInterval, autoPlayDirection]);
405
407
  (0, _helpers.useUpdateEffect)(function () {
406
408
  if (currentIndex !== void 0) {
407
409
  jumpTo(currentIndex);
@@ -541,7 +543,7 @@ var Carousel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
541
543
  var changedIndex = newIndex !== oldIndex ? getShownIndex(newIndex) : -1;
542
544
 
543
545
  if (autoJump) {
544
- setDirection('left');
546
+ setDirection(autoPlayDirection === 'reverse' ? 'right' : 'left');
545
547
  } else if (newIndex === indexRef.current) {
546
548
  setDirection(distanceRef.current > 0 ? 'right' : 'left');
547
549
  } else {
@@ -595,7 +597,7 @@ var Carousel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
595
597
  }
596
598
 
597
599
  timerRef.current = delayTimeout(function () {
598
- jumpTo(indexRef.current + 1);
600
+ jumpTo(autoPlayDirection === 'reverse' ? indexRef.current - 1 : indexRef.current + 1);
599
601
  }, stayDuration);
600
602
  }
601
603
 
@@ -84,7 +84,9 @@ var ImagePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
84
84
  onMaxSizeExceed = props.onMaxSizeExceed,
85
85
  onLimitExceed = props.onLimitExceed,
86
86
  upload = props.upload,
87
- selectAdapter = props.selectAdapter;
87
+ selectAdapter = props.selectAdapter,
88
+ onSelectClick = props.onSelectClick,
89
+ onDeleteClick = props.onDeleteClick;
88
90
  var domRef = (0, _react.useRef)(null);
89
91
  var fileRef = (0, _react.useRef)(null);
90
92
  var cacheRef = (0, _react.useRef)([]);
@@ -185,6 +187,7 @@ var ImagePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
185
187
  };
186
188
 
187
189
  var handleDelete = function handleDelete(index) {
190
+ onDeleteClick && onDeleteClick(index);
188
191
  onChange(images.filter(function (_i, j) {
189
192
  return j !== index;
190
193
  }));
@@ -208,17 +211,20 @@ var ImagePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
208
211
  }
209
212
  };
210
213
 
211
- var handleSelect = function handleSelect() {
212
- var _fileRef$current;
213
-
214
- selectAdapter ? selectAdapter().then(function (_ref4) {
215
- var files = _ref4.files;
216
- return handleChange({
217
- target: {
218
- files: files
219
- }
220
- }, true);
221
- }) : (_fileRef$current = fileRef.current) == null ? void 0 : _fileRef$current.click();
214
+ var handleSelect = function handleSelect(e) {
215
+ if (e.target !== fileRef.current) {
216
+ var _fileRef$current;
217
+
218
+ onSelectClick && onSelectClick();
219
+ selectAdapter ? selectAdapter().then(function (_ref4) {
220
+ var files = _ref4.files;
221
+ return handleChange({
222
+ target: {
223
+ files: files
224
+ }
225
+ }, true);
226
+ }) : (_fileRef$current = fileRef.current) == null ? void 0 : _fileRef$current.click();
227
+ }
222
228
  };
223
229
 
224
230
  var getGridData = function getGridData(prefixCls, locale) {
@@ -164,6 +164,16 @@ export interface ImagePickerProps {
164
164
  * @en Select Adaptor
165
165
  */
166
166
  selectAdapter?: () => Promise<SelectCallback>;
167
+ /**
168
+ * 选图点击事件
169
+ * @en Select Icon Click Event
170
+ */
171
+ onSelectClick?: () => void;
172
+ /**
173
+ * 删除点击事件
174
+ * @en Delete Icon Click Event
175
+ */
176
+ onDeleteClick?: (index: number) => void;
167
177
  }
168
178
  export interface ImagePickerRef {
169
179
  /**
package/cjs/index.d.ts CHANGED
@@ -42,6 +42,7 @@ export { default as Radio } from './radio';
42
42
  export { default as Rate } from './rate';
43
43
  export { default as Slider } from './slider';
44
44
  export { default as SearchBar } from './search-bar';
45
+ export { default as Stepper } from './stepper';
45
46
  export { default as Steps } from './steps';
46
47
  export { default as Sticky } from './sticky';
47
48
  export { default as SwipeAction } from './swipe-action';
package/cjs/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
5
  exports.__esModule = true;
6
- exports.Transition = exports.Toast = exports.Textarea = exports.Tag = exports.Tabs = exports.TabBar = exports.Switch = exports.SwipeLoad = exports.SwipeAction = exports.Sticky = exports.Steps = exports.Slider = exports.ShowMonitor = exports.SearchBar = exports.Rate = exports.Radio = exports.PullRefresh = exports.Progress = exports.Portal = exports.PopupSwiper = exports.Popup = exports.Popover = exports.PickerView = exports.Picker = exports.Pagination = exports.Notify = exports.NoticeBar = exports.NavBar = exports.Masking = exports.Loading = exports.LoadMore = exports.Input = exports.ImagePreview = exports.ImagePicker = exports.Image = exports.Grid = exports.Ellipsis = exports.DropdownMenu = exports.Dropdown = exports.Dialog = exports.DatePicker = exports.CountDown = exports.ContextProvider = exports.Collapse = exports.CircleProgress = exports.Checkbox = exports.Cell = exports.Carousel = exports.Button = exports.Badge = exports.Avatar = exports.ActionSheet = void 0;
6
+ exports.Transition = exports.Toast = exports.Textarea = exports.Tag = exports.Tabs = exports.TabBar = exports.Switch = exports.SwipeLoad = exports.SwipeAction = exports.Sticky = exports.Steps = exports.Stepper = exports.Slider = exports.ShowMonitor = exports.SearchBar = exports.Rate = exports.Radio = exports.PullRefresh = exports.Progress = exports.Portal = exports.PopupSwiper = exports.Popup = exports.Popover = exports.PickerView = exports.Picker = exports.Pagination = exports.Notify = exports.NoticeBar = exports.NavBar = exports.Masking = exports.Loading = exports.LoadMore = exports.Input = exports.ImagePreview = exports.ImagePicker = exports.Image = exports.Grid = exports.Ellipsis = exports.DropdownMenu = exports.Dropdown = exports.Dialog = exports.DatePicker = exports.CountDown = exports.ContextProvider = exports.Collapse = exports.CircleProgress = exports.Checkbox = exports.Cell = exports.Carousel = exports.Button = exports.Badge = exports.Avatar = exports.ActionSheet = void 0;
7
7
 
8
8
  var _actionSheet = _interopRequireDefault(require("./action-sheet"));
9
9
 
@@ -181,6 +181,10 @@ var _searchBar = _interopRequireDefault(require("./search-bar"));
181
181
 
182
182
  exports.SearchBar = _searchBar.default;
183
183
 
184
+ var _stepper = _interopRequireDefault(require("./stepper"));
185
+
186
+ exports.Stepper = _stepper.default;
187
+
184
188
  var _steps = _interopRequireDefault(require("./steps"));
185
189
 
186
190
  exports.Steps = _steps.default;
@@ -124,6 +124,7 @@
124
124
  }
125
125
  .arco-input-clear {
126
126
  color: #c9cdd4 ;
127
+ font-size: 16PX ;
127
128
  }
128
129
  .arco-input {
129
130
  display: inline-block;
@@ -85,6 +85,7 @@
85
85
  }
86
86
  .@{prefix}-input-clear {
87
87
  .use-var(color, input-clear-icon-color);
88
+ .use-var(font-size, input-clear-icon-font-size);
88
89
  }
89
90
 
90
91
  .@{prefix}-input {
@@ -0,0 +1,4 @@
1
+ #demo-stepper .arcodesign-mobile-demo-content {
2
+ padding: 0;
3
+ background: transparent;
4
+ }
@@ -0,0 +1,10 @@
1
+ @import "../../../../style/mixin.less";
2
+
3
+ #demo-stepper {
4
+
5
+ .arcodesign-mobile-demo-content {
6
+ padding: 0;
7
+ background: transparent;
8
+ }
9
+
10
+ }
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { StepperProps } from '../type';
3
+ export default function useButtonClick(params: Required<Pick<StepperProps, 'min' | 'max' | 'step' | 'disabled' | 'digits' | 'digits' | 'equalLimitDisabled'>> & Pick<StepperProps, 'onAddButtonClick' | 'onMinusButtonClick'> & {
4
+ actualInputValue: number;
5
+ updateValue: (updater: number | ((oldValue: number) => number)) => void;
6
+ }): {
7
+ minusButtonDisable: boolean;
8
+ addButtonDisable: boolean;
9
+ handleMinusButtonClick: (e: React.MouseEvent) => void;
10
+ handleAddButtonClick: (e: React.MouseEvent) => void;
11
+ };
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = useButtonClick;
5
+
6
+ var _react = require("react");
7
+
8
+ function correctCalculation(leftNumber, rightNumber, operator) {
9
+ var magnification = 1e17;
10
+ var left = leftNumber * magnification;
11
+ var right = rightNumber * magnification;
12
+ return operator === '-' ? (left - right) / magnification : (left + right) / magnification;
13
+ }
14
+
15
+ function useButtonClick(params) {
16
+ var actualInputValue = params.actualInputValue,
17
+ min = params.min,
18
+ max = params.max,
19
+ step = params.step,
20
+ disabled = params.disabled,
21
+ equalLimitDisabled = params.equalLimitDisabled,
22
+ updateValue = params.updateValue,
23
+ onAddButtonClick = params.onAddButtonClick,
24
+ onMinusButtonClick = params.onMinusButtonClick;
25
+
26
+ var _useState = (0, _react.useState)(function () {
27
+ return actualInputValue === min || disabled;
28
+ }),
29
+ minusButtonDisable = _useState[0],
30
+ setMinusButtonDisable = _useState[1];
31
+
32
+ var _useState2 = (0, _react.useState)(function () {
33
+ return actualInputValue === max || disabled;
34
+ }),
35
+ addButtonDisable = _useState2[0],
36
+ setAddButtonDisable = _useState2[1];
37
+
38
+ var handleMinusButtonClick = function handleMinusButtonClick(e) {
39
+ if (minusButtonDisable) {
40
+ return;
41
+ }
42
+
43
+ updateValue(function (oldValue) {
44
+ var result = correctCalculation(oldValue, step, '-');
45
+ return result < min ? equalLimitDisabled ? oldValue : min : result;
46
+ });
47
+ onMinusButtonClick && onMinusButtonClick(e);
48
+ };
49
+
50
+ var handleAddButtonClick = function handleAddButtonClick(e) {
51
+ if (addButtonDisable) {
52
+ return;
53
+ }
54
+
55
+ updateValue(function (oldValue) {
56
+ var result = correctCalculation(Number(oldValue), step, '+');
57
+ return result > max ? equalLimitDisabled ? oldValue : max : result;
58
+ });
59
+ onAddButtonClick && onAddButtonClick(e);
60
+ }; // 当前值改变时,更新按钮状态
61
+ // Changes button status when value changed
62
+
63
+
64
+ (0, _react.useEffect)(function () {
65
+ setMinusButtonDisable(actualInputValue <= min);
66
+ setAddButtonDisable(actualInputValue >= max);
67
+ }, [actualInputValue]);
68
+ return {
69
+ minusButtonDisable: minusButtonDisable,
70
+ addButtonDisable: addButtonDisable,
71
+ handleMinusButtonClick: handleMinusButtonClick,
72
+ handleAddButtonClick: handleAddButtonClick
73
+ };
74
+ }
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { StepperProps } from '../type';
3
+ export default function useInputEvent(params: Required<Pick<StepperProps, 'defaultValue' | 'min' | 'max' | 'digits' | 'allowEmpty'>> & Pick<StepperProps, 'onBlur' | 'onChange' | 'onInput'> & {
4
+ actualInputValue: number;
5
+ updateValue: (updater: number | ((oldValue: number) => number)) => void;
6
+ }): {
7
+ handleInput: (e: React.FocusEvent<HTMLInputElement>) => void;
8
+ handleBlur: (e: React.FocusEvent<HTMLInputElement>) => void;
9
+ };
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = useInputEvent;
5
+
6
+ var _helpers = require("../../_helpers");
7
+
8
+ function useInputEvent(params) {
9
+ var defaultValue = params.defaultValue,
10
+ min = params.min,
11
+ max = params.max,
12
+ digits = params.digits,
13
+ actualInputValue = params.actualInputValue,
14
+ allowEmpty = params.allowEmpty,
15
+ updateValue = params.updateValue,
16
+ onBlur = params.onBlur,
17
+ onChange = params.onChange,
18
+ onInput = params.onInput;
19
+
20
+ var handleInput = function handleInput(e) {
21
+ var targetValue = e.target.value;
22
+ var numberValue = Number(targetValue);
23
+ var pointIndex = targetValue.indexOf('.');
24
+
25
+ if (digits > 0 && pointIndex !== -1) {
26
+ var decimalLength = targetValue.slice(pointIndex + 1).length;
27
+ updateValue(decimalLength > digits ? actualInputValue : numberValue);
28
+ } else if (allowEmpty && targetValue === '') {
29
+ updateValue(Number.MIN_VALUE);
30
+ } else {
31
+ updateValue(numberValue);
32
+ }
33
+
34
+ onInput && onInput(e);
35
+ };
36
+
37
+ var handleBlur = function handleBlur(e) {
38
+ var targetValue = e.target.value;
39
+ var numberValue = Number(targetValue);
40
+
41
+ if (allowEmpty && targetValue === '') {
42
+ updateValue(Number.MIN_VALUE);
43
+ } else if (!allowEmpty && targetValue === '') {
44
+ updateValue(defaultValue);
45
+ } else {
46
+ updateValue(Math.max(min, Math.min(max, numberValue)));
47
+ }
48
+
49
+ onBlur && onBlur(e);
50
+ };
51
+
52
+ (0, _helpers.useUpdateEffect)(function () {
53
+ onChange && onChange(actualInputValue);
54
+ }, [actualInputValue]);
55
+ return {
56
+ handleInput: handleInput,
57
+ handleBlur: handleBlur
58
+ };
59
+ }
@@ -0,0 +1,6 @@
1
+ import { StepperProps } from '..';
2
+ export default function useValue(params: Required<Pick<StepperProps, 'defaultValue' | 'min' | 'max' | 'digits'>> & Pick<StepperProps, 'formatter' | 'value'>): {
3
+ updateValue: (updater: number | ((oldValue: number) => number)) => void;
4
+ actualInputValue: number;
5
+ showValue: string | number;
6
+ };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = useValue;
5
+
6
+ var _react = require("react");
7
+
8
+ function useValue(params) {
9
+ var defaultValue = params.defaultValue,
10
+ formatter = params.formatter,
11
+ max = params.max,
12
+ min = params.min,
13
+ value = params.value,
14
+ digits = params.digits;
15
+
16
+ var _useState = (0, _react.useState)(defaultValue),
17
+ innerValue = _useState[0],
18
+ setInnerValue = _useState[1];
19
+
20
+ var updateValue = function updateValue(updater) {
21
+ var tempValue = typeof updater === 'function' ? updater(innerValue) : updater;
22
+
23
+ if (formatter) {
24
+ new Promise(function (resolve) {
25
+ resolve(formatter(Number(tempValue)));
26
+ }).then(function (result) {
27
+ var res = Math.max(min, Math.min(max, result));
28
+ setInnerValue(res);
29
+ });
30
+ } else {
31
+ setInnerValue(tempValue);
32
+ }
33
+ };
34
+
35
+ var actualInputValue = value !== undefined ? value : innerValue; // 将actualInputValue等于Number.MIN_VALUE的情况视为空值
36
+ // @en If actualInputValue equal Number.MIN_VALUE, actualInputValue equal ''
37
+
38
+ var showValue = actualInputValue === Number.MIN_VALUE ? '' : digits > 0 ? parseFloat(String(actualInputValue)).toFixed(digits) : actualInputValue;
39
+ return {
40
+ updateValue: updateValue,
41
+ actualInputValue: actualInputValue,
42
+ showValue: showValue
43
+ };
44
+ }
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { StepperProps, StepperRef } from './type';
3
+ export * from './type';
4
+ /**
5
+ * 步进器组件,支持受控模式
6
+ * @en Stepper component, provide controlled mode
7
+ * @type 数据录入
8
+ * @type_en Data Entry
9
+ * @name 步进器
10
+ * @name_en Stepper
11
+ */
12
+ declare const Stepper: React.ForwardRefExoticComponent<StepperProps & React.RefAttributes<StepperRef>>;
13
+ export default Stepper;
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ exports.__esModule = true;
6
+ var _exportNames = {};
7
+ exports.default = void 0;
8
+
9
+ var _mobileUtils = require("@arco-design/mobile-utils");
10
+
11
+ var _react = _interopRequireWildcard(require("react"));
12
+
13
+ var _contextProvider = require("../context-provider");
14
+
15
+ var _useButtonClick2 = _interopRequireDefault(require("./hooks/useButtonClick"));
16
+
17
+ var _useInputEvent2 = _interopRequireDefault(require("./hooks/useInputEvent"));
18
+
19
+ var _icon = require("../icon");
20
+
21
+ var _useValue2 = _interopRequireDefault(require("./hooks/useValue"));
22
+
23
+ var _type = require("./type");
24
+
25
+ Object.keys(_type).forEach(function (key) {
26
+ if (key === "default" || key === "__esModule") return;
27
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
28
+ if (key in exports && exports[key] === _type[key]) return;
29
+ exports[key] = _type[key];
30
+ });
31
+
32
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
33
+
34
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
35
+
36
+ /**
37
+ * 步进器组件,支持受控模式
38
+ * @en Stepper component, provide controlled mode
39
+ * @type 数据录入
40
+ * @type_en Data Entry
41
+ * @name 步进器
42
+ * @name_en Stepper
43
+ */
44
+ var Stepper = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
45
+ var _props$className = props.className,
46
+ className = _props$className === void 0 ? '' : _props$className,
47
+ style = props.style,
48
+ inputStyle = props.inputStyle,
49
+ _props$inputClass = props.inputClass,
50
+ inputClass = _props$inputClass === void 0 ? '' : _props$inputClass,
51
+ value = props.value,
52
+ _props$defaultValue = props.defaultValue,
53
+ defaultValue = _props$defaultValue === void 0 ? 1 : _props$defaultValue,
54
+ _props$allowEmpty = props.allowEmpty,
55
+ allowEmpty = _props$allowEmpty === void 0 ? false : _props$allowEmpty,
56
+ _props$digits = props.digits,
57
+ digits = _props$digits === void 0 ? 0 : _props$digits,
58
+ _props$disabled = props.disabled,
59
+ disabled = _props$disabled === void 0 ? false : _props$disabled,
60
+ _props$inputReadonly = props.inputReadonly,
61
+ inputReadonly = _props$inputReadonly === void 0 ? false : _props$inputReadonly,
62
+ _props$max = props.max,
63
+ max = _props$max === void 0 ? Infinity : _props$max,
64
+ _props$min = props.min,
65
+ min = _props$min === void 0 ? 1 : _props$min,
66
+ _props$equalLimitDisa = props.equalLimitDisabled,
67
+ equalLimitDisabled = _props$equalLimitDisa === void 0 ? false : _props$equalLimitDisa,
68
+ _props$step = props.step,
69
+ step = _props$step === void 0 ? 1 : _props$step,
70
+ _props$theme = props.theme,
71
+ theme = _props$theme === void 0 ? 'default' : _props$theme,
72
+ formatter = props.formatter,
73
+ addButton = props.addButton,
74
+ minusButton = props.minusButton,
75
+ renderContent = props.renderContent,
76
+ onBlur = props.onBlur,
77
+ onChange = props.onChange,
78
+ onFocus = props.onFocus,
79
+ onAddButtonClick = props.onAddButtonClick,
80
+ onMinusButtonClick = props.onMinusButtonClick,
81
+ onClick = props.onClick,
82
+ onInput = props.onInput; // 值的相关逻辑
83
+ // @en The logic is that handle value
84
+
85
+ var _useValue = (0, _useValue2.default)({
86
+ defaultValue: defaultValue,
87
+ formatter: formatter,
88
+ min: min,
89
+ max: max,
90
+ value: value,
91
+ digits: digits
92
+ }),
93
+ updateValue = _useValue.updateValue,
94
+ actualInputValue = _useValue.actualInputValue,
95
+ showValue = _useValue.showValue; // 按钮点击的相关逻辑
96
+ // @en The logic is that handle button click
97
+
98
+
99
+ var _useButtonClick = (0, _useButtonClick2.default)({
100
+ actualInputValue: actualInputValue,
101
+ min: min,
102
+ max: max,
103
+ step: step,
104
+ disabled: disabled,
105
+ digits: digits,
106
+ equalLimitDisabled: equalLimitDisabled,
107
+ updateValue: updateValue,
108
+ onAddButtonClick: onAddButtonClick,
109
+ onMinusButtonClick: onMinusButtonClick
110
+ }),
111
+ minusButtonDisable = _useButtonClick.minusButtonDisable,
112
+ addButtonDisable = _useButtonClick.addButtonDisable,
113
+ handleAddButtonClick = _useButtonClick.handleAddButtonClick,
114
+ handleMinusButtonClick = _useButtonClick.handleMinusButtonClick; // 输入框操作的相关逻辑
115
+ // @en The logic is that handle input operation
116
+
117
+
118
+ var _useInputEvent = (0, _useInputEvent2.default)({
119
+ defaultValue: defaultValue,
120
+ min: min,
121
+ max: max,
122
+ digits: digits,
123
+ actualInputValue: actualInputValue,
124
+ allowEmpty: allowEmpty,
125
+ updateValue: updateValue,
126
+ onBlur: onBlur,
127
+ onChange: onChange,
128
+ onInput: onInput
129
+ }),
130
+ handleInput = _useInputEvent.handleInput,
131
+ handleBlur = _useInputEvent.handleBlur;
132
+
133
+ var domRef = (0, _react.useRef)(null);
134
+ var inputRef = (0, _react.useRef)(null);
135
+ (0, _react.useImperativeHandle)(ref, function () {
136
+ return {
137
+ dom: domRef.current,
138
+ input: inputRef.current,
139
+ changeValue: function changeValue(newValue) {
140
+ var tempValue = newValue != null ? newValue : defaultValue;
141
+ tempValue = Math.min(max, Math.max(tempValue, min));
142
+ updateValue(tempValue);
143
+ }
144
+ };
145
+ });
146
+ return /*#__PURE__*/_react.default.createElement(_contextProvider.ContextLayout, null, function (_ref) {
147
+ var prefixCls = _ref.prefixCls;
148
+ return /*#__PURE__*/_react.default.createElement("div", {
149
+ className: (0, _mobileUtils.cls)(prefixCls + "-stepper", prefixCls + "-" + theme, className),
150
+ style: style,
151
+ ref: domRef,
152
+ onClick: onClick
153
+ }, /*#__PURE__*/_react.default.createElement("div", {
154
+ onClick: handleMinusButtonClick
155
+ }, minusButton || /*#__PURE__*/_react.default.createElement("div", {
156
+ className: (0, _mobileUtils.cls)(prefixCls + "-stepper-minus-button")
157
+ }, /*#__PURE__*/_react.default.createElement(_icon.IconMinus, {
158
+ className: (0, _mobileUtils.cls)(prefixCls + "-stepper-minus-button-icon", {
159
+ disabled: minusButtonDisable
160
+ })
161
+ }))), renderContent ? renderContent(actualInputValue) : /*#__PURE__*/_react.default.createElement("input", {
162
+ style: inputStyle,
163
+ className: (0, _mobileUtils.cls)(prefixCls + "-stepper-input", inputClass),
164
+ onFocus: onFocus,
165
+ onInput: handleInput,
166
+ onBlur: handleBlur,
167
+ disabled: disabled,
168
+ value: showValue,
169
+ readOnly: inputReadonly,
170
+ ref: inputRef,
171
+ type: "number"
172
+ }), /*#__PURE__*/_react.default.createElement("div", {
173
+ onClick: handleAddButtonClick
174
+ }, addButton || /*#__PURE__*/_react.default.createElement("div", {
175
+ className: (0, _mobileUtils.cls)(prefixCls + "-stepper-add-button")
176
+ }, /*#__PURE__*/_react.default.createElement(_icon.IconAdd, {
177
+ className: (0, _mobileUtils.cls)(prefixCls + "-stepper-add-button-icon", {
178
+ disabled: addButtonDisable
179
+ })
180
+ }))));
181
+ });
182
+ });
183
+ var _default = Stepper;
184
+ exports.default = _default;