@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/dist/index.js CHANGED
@@ -4222,61 +4222,63 @@
4222
4222
  loop = _d === void 0 ? true : _d,
4223
4223
  _e = props.autoPlay,
4224
4224
  autoPlay = _e === void 0 ? true : _e,
4225
- _f = props.swipeable,
4226
- swipeable = _f === void 0 ? true : _f,
4227
- _g = props.stayDuration,
4228
- stayDuration = _g === void 0 ? 4000 : _g,
4225
+ _f = props.autoPlayDirection,
4226
+ autoPlayDirection = _f === void 0 ? 'normal' : _f,
4227
+ _g = props.swipeable,
4228
+ swipeable = _g === void 0 ? true : _g,
4229
+ _h = props.stayDuration,
4230
+ stayDuration = _h === void 0 ? 4000 : _h,
4229
4231
  boxWidth = props.boxWidth,
4230
4232
  boxHeight = props.boxHeight,
4231
4233
  baseBoxWidth = props.baseBoxWidth,
4232
4234
  baseBoxHeight = props.baseBoxHeight,
4233
- _h = props.width,
4234
- width = _h === void 0 ? 0 : _h,
4235
+ _j = props.width,
4236
+ width = _j === void 0 ? 0 : _j,
4235
4237
  height = props.height,
4236
- _j = props.initialIndex,
4237
- initialIndex = _j === void 0 ? 0 : _j,
4238
+ _k = props.initialIndex,
4239
+ initialIndex = _k === void 0 ? 0 : _k,
4238
4240
  renderIndicator = props.renderIndicator,
4239
- _k = props.indicatorPos,
4240
- indicatorPos = _k === void 0 ? 'center' : _k,
4241
- _l = props.indicatorVerticalPos,
4242
- indicatorVerticalPos = _l === void 0 ? 'left' : _l,
4241
+ _l = props.indicatorPos,
4242
+ indicatorPos = _l === void 0 ? 'center' : _l,
4243
+ _m = props.indicatorVerticalPos,
4244
+ indicatorVerticalPos = _m === void 0 ? 'left' : _m,
4243
4245
  indicatorOutside = props.indicatorOutside,
4244
- _m = props.showIndicator,
4245
- showIndicator = _m === void 0 ? true : _m,
4246
- _o = props.hideSingleIndicator,
4247
- hideSingleIndicator = _o === void 0 ? true : _o,
4248
- _p = props.indicatorType,
4249
- indicatorType = _p === void 0 ? 'square' : _p,
4250
- _q = props.indicatorClass,
4251
- indicatorClass = _q === void 0 ? '' : _q,
4246
+ _o = props.showIndicator,
4247
+ showIndicator = _o === void 0 ? true : _o,
4248
+ _p = props.hideSingleIndicator,
4249
+ hideSingleIndicator = _p === void 0 ? true : _p,
4250
+ _q = props.indicatorType,
4251
+ indicatorType = _q === void 0 ? 'square' : _q,
4252
+ _r = props.indicatorClass,
4253
+ indicatorClass = _r === void 0 ? '' : _r,
4252
4254
  indicatorInverse = props.indicatorInverse,
4253
- _r = props.spaceBetween,
4254
- spaceBetween = _r === void 0 ? 0 : _r,
4255
- _s = props.offsetBetween,
4256
- offsetBetween = _s === void 0 ? 0 : _s,
4255
+ _s = props.spaceBetween,
4256
+ spaceBetween = _s === void 0 ? 0 : _s,
4257
+ _t = props.offsetBetween,
4258
+ offsetBetween = _t === void 0 ? 0 : _t,
4257
4259
  currentIndex = props.currentIndex,
4258
- _t = props.autoHeight,
4259
- autoHeight = _t === void 0 ? false : _t,
4260
- _u = props.percentToChange,
4261
- percentToChange = _u === void 0 ? 0.3 : _u,
4262
- _v = props.distanceToChange,
4263
- distanceToChange = _v === void 0 ? 10 : _v,
4264
- _w = props.speedToChange,
4265
- speedToChange = _w === void 0 ? 100 : _w,
4260
+ _u = props.autoHeight,
4261
+ autoHeight = _u === void 0 ? false : _u,
4262
+ _v = props.percentToChange,
4263
+ percentToChange = _v === void 0 ? 0.3 : _v,
4264
+ _w = props.distanceToChange,
4265
+ distanceToChange = _w === void 0 ? 10 : _w,
4266
+ _x = props.speedToChange,
4267
+ speedToChange = _x === void 0 ? 100 : _x,
4266
4268
  vertical = props.vertical,
4267
4269
  lazyloadCount = props.lazyloadCount,
4268
- _x = props.inactiveScale,
4269
- inactiveScale = _x === void 0 ? 1 : _x,
4270
- _y = props.stopPropagation,
4271
- stopPropagation = _y === void 0 ? true : _y,
4272
- _z = props.fakeItem,
4273
- fakeItem = _z === void 0 ? false : _z,
4274
- _0 = props.allowEndBlank,
4275
- allowEndBlank = _0 === void 0 ? false : _0,
4276
- _1 = props.bounceWhenNoLoop,
4277
- bounceWhenNoLoop = _1 === void 0 ? false : _1,
4278
- _2 = props.bounceDampRate,
4279
- bounceDampRate = _2 === void 0 ? 3 : _2,
4270
+ _y = props.inactiveScale,
4271
+ inactiveScale = _y === void 0 ? 1 : _y,
4272
+ _z = props.stopPropagation,
4273
+ stopPropagation = _z === void 0 ? true : _z,
4274
+ _0 = props.fakeItem,
4275
+ fakeItem = _0 === void 0 ? false : _0,
4276
+ _1 = props.allowEndBlank,
4277
+ allowEndBlank = _1 === void 0 ? false : _1,
4278
+ _2 = props.bounceWhenNoLoop,
4279
+ bounceWhenNoLoop = _2 === void 0 ? false : _2,
4280
+ _3 = props.bounceDampRate,
4281
+ bounceDampRate = _3 === void 0 ? 3 : _3,
4280
4282
  distanceProcessor = props.distanceProcessor,
4281
4283
  getInnerScrollContainer = props.getInnerScrollContainer,
4282
4284
  onChange = props.onChange,
@@ -4287,8 +4289,8 @@
4287
4289
  onTransitionStart = props.onTransitionStart,
4288
4290
  onTransitionEnd = props.onTransitionEnd,
4289
4291
  onDistanceChange = props.onDistanceChange,
4290
- _3 = props.stopTouchThreshold,
4291
- stopTouchThreshold = _3 === void 0 ? 0 : _3,
4292
+ _4 = props.stopTouchThreshold,
4293
+ stopTouchThreshold = _4 === void 0 ? 0 : _4,
4292
4294
  onTouchStopped = props.onTouchStopped,
4293
4295
  onPageVisibleChange = props.onPageVisibleChange;
4294
4296
  var domRef = React.useRef(null);
@@ -4302,13 +4304,13 @@
4302
4304
  var touchStartedRef = React.useRef(false);
4303
4305
  var touchMovedRef = React.useRef(false);
4304
4306
 
4305
- var _4 = React.useState(baseBoxWidth || 0),
4306
- wrapWidth = _4[0],
4307
- setWrapWidth = _4[1];
4307
+ var _5 = React.useState(baseBoxWidth || 0),
4308
+ wrapWidth = _5[0],
4309
+ setWrapWidth = _5[1];
4308
4310
 
4309
- var _5 = React.useState(baseBoxHeight || 0),
4310
- wrapHeight = _5[0],
4311
- setWrapHeight = _5[1];
4311
+ var _6 = React.useState(baseBoxHeight || 0),
4312
+ wrapHeight = _6[0],
4313
+ setWrapHeight = _6[1];
4312
4314
 
4313
4315
  var touchStartXRef = React.useRef(0);
4314
4316
  var touchStartYRef = React.useRef(0);
@@ -4316,45 +4318,45 @@
4316
4318
  var touchStoppedRef = React.useRef(false);
4317
4319
  var bouncingRef = React.useRef(false);
4318
4320
 
4319
- var _6 = React.useState('auto'),
4320
- currentItemHeight = _6[0],
4321
- setCurrentItemHeight = _6[1];
4321
+ var _7 = React.useState('auto'),
4322
+ currentItemHeight = _7[0],
4323
+ setCurrentItemHeight = _7[1];
4322
4324
 
4323
- var _7 = useRefState(false),
4324
- posAdjusting = _7[0],
4325
- posAdjustingRef = _7[1],
4326
- setPosAdjusting = _7[2];
4325
+ var _8 = useRefState(false),
4326
+ posAdjusting = _8[0],
4327
+ posAdjustingRef = _8[1],
4328
+ setPosAdjusting = _8[2];
4327
4329
 
4328
- var _8 = useRefState(0),
4329
- distance = _8[0],
4330
- distanceRef = _8[1],
4331
- setDistance = _8[2];
4330
+ var _9 = useRefState(0),
4331
+ distance = _9[0],
4332
+ distanceRef = _9[1],
4333
+ setDistance = _9[2];
4332
4334
 
4333
- var _9 = React.useState(true),
4334
- isAutoJump = _9[0],
4335
- setIsAutoJump = _9[1];
4335
+ var _10 = React.useState(true),
4336
+ isAutoJump = _10[0],
4337
+ setIsAutoJump = _10[1];
4336
4338
 
4337
- var _10 = useRefState(currentIndex !== void 0 ? currentIndex : initialIndex),
4338
- index = _10[0],
4339
- indexRef = _10[1],
4340
- setIndex = _10[2];
4339
+ var _11 = useRefState(currentIndex !== void 0 ? currentIndex : initialIndex),
4340
+ index = _11[0],
4341
+ indexRef = _11[1],
4342
+ setIndex = _11[2];
4341
4343
 
4342
- var _11 = useRefState([]),
4343
- transforms = _11[0],
4344
- transformsRef = _11[1],
4345
- setTransforms = _11[2];
4344
+ var _12 = useRefState([]),
4345
+ transforms = _12[0],
4346
+ transformsRef = _12[1],
4347
+ setTransforms = _12[2];
4346
4348
 
4347
- var _12 = useRefState('left'),
4348
- direction = _12[0],
4349
- directionRef = _12[1],
4350
- setStateDirection = _12[2];
4349
+ var _13 = useRefState(autoPlayDirection === 'reverse' && autoPlay ? 'right' : 'left'),
4350
+ direction = _13[0],
4351
+ directionRef = _13[1],
4352
+ setStateDirection = _13[2];
4351
4353
 
4352
4354
  var lastDirectionRef = React.useRef('');
4353
4355
  var lastShownIndexRef = React.useRef(-1);
4354
4356
 
4355
- var _13 = getAllChildren(),
4356
- allChildren = _13.allChildren,
4357
- fakeTwoChildren = _13.fakeTwoChildren;
4357
+ var _14 = getAllChildren(),
4358
+ allChildren = _14.allChildren,
4359
+ fakeTwoChildren = _14.fakeTwoChildren;
4358
4360
 
4359
4361
  var total = allChildren.length;
4360
4362
  var shownTotal = fakeTwoChildren ? 2 : total;
@@ -4386,9 +4388,9 @@
4386
4388
  return Math.max(0, Math.min(inactiveScale, 1));
4387
4389
  }, [inactiveScale]);
4388
4390
 
4389
- var _14 = React.useState([]),
4390
- fakeIndexes = _14[0],
4391
- setFakeIndexes = _14[1];
4391
+ var _15 = React.useState([]),
4392
+ fakeIndexes = _15[0],
4393
+ setFakeIndexes = _15[1];
4392
4394
 
4393
4395
  var system = useSystem(); // 开启自动循环时iOS会有渲染问题需要强刷dom,但不需要autoPlay的不用强刷,这里判断下
4394
4396
  // @en When the automatic loop is turned on, there will be rendering problems in iOS. Need to brush the dom, but if you don't need autoPlay, don't need to brush.
@@ -4581,7 +4583,7 @@
4581
4583
  return function () {
4582
4584
  clear();
4583
4585
  };
4584
- }, [userSetBoxWidth, userSetBoxHeight, childWidth, childHeight, stayDuration, noInterval]);
4586
+ }, [userSetBoxWidth, userSetBoxHeight, childWidth, childHeight, stayDuration, noInterval, autoPlayDirection]);
4585
4587
  useUpdateEffect(function () {
4586
4588
  if (currentIndex !== void 0) {
4587
4589
  jumpTo(currentIndex);
@@ -4721,7 +4723,7 @@
4721
4723
  var changedIndex = newIndex !== oldIndex ? getShownIndex(newIndex) : -1;
4722
4724
 
4723
4725
  if (autoJump) {
4724
- setDirection('left');
4726
+ setDirection(autoPlayDirection === 'reverse' ? 'right' : 'left');
4725
4727
  } else if (newIndex === indexRef.current) {
4726
4728
  setDirection(distanceRef.current > 0 ? 'right' : 'left');
4727
4729
  } else {
@@ -4775,7 +4777,7 @@
4775
4777
  }
4776
4778
 
4777
4779
  timerRef.current = delayTimeout(function () {
4778
- jumpTo(indexRef.current + 1);
4780
+ jumpTo(autoPlayDirection === 'reverse' ? indexRef.current - 1 : indexRef.current + 1);
4779
4781
  }, stayDuration);
4780
4782
  }
4781
4783
 
@@ -14176,6 +14178,30 @@
14176
14178
 
14177
14179
  });
14178
14180
 
14181
+ function IconMinus(props) {
14182
+ var _a = props.className,
14183
+ className = _a === void 0 ? '' : _a,
14184
+ _b = props.useCurrentColor,
14185
+ useCurrentColor = _b === void 0 ? true : _b,
14186
+ style = props.style,
14187
+ other = __rest(props, ["className", "useCurrentColor", "style"]);
14188
+
14189
+ return /*#__PURE__*/React__default["default"].createElement(ContextLayout, null, function (_a) {
14190
+ var prefixCls = _a.prefixCls;
14191
+ return /*#__PURE__*/React__default["default"].createElement("svg", __assign({
14192
+ className: prefixCls + "-icon " + prefixCls + "-icon-minus " + className,
14193
+ width: "1em",
14194
+ height: "1em",
14195
+ style: style,
14196
+ fill: useCurrentColor ? 'currentColor' : '#000',
14197
+ viewBox: "0 0 1024 1024",
14198
+ xmlns: "http://www.w3.org/2000/svg"
14199
+ }, other), /*#__PURE__*/React__default["default"].createElement("defs", null, /*#__PURE__*/React__default["default"].createElement("style", null)), /*#__PURE__*/React__default["default"].createElement("path", {
14200
+ d: "M115.2 467.2h819.2c6.4 0 6.4 6.4 6.4 6.4V544c0 6.4-6.4 6.4-6.4 6.4H96c-6.4 0-6.4-6.4-6.4-6.4v-64c0-6.4 6.4-6.4 6.4-6.4 6.4-6.4 6.4-6.4 19.2-6.4z"
14201
+ }));
14202
+ });
14203
+ }
14204
+
14179
14205
  function IconStarFill(props) {
14180
14206
  var _a = props.className,
14181
14207
  className = _a === void 0 ? '' : _a,
@@ -14438,7 +14464,9 @@
14438
14464
  onMaxSizeExceed = props.onMaxSizeExceed,
14439
14465
  onLimitExceed = props.onLimitExceed,
14440
14466
  upload = props.upload,
14441
- selectAdapter = props.selectAdapter;
14467
+ selectAdapter = props.selectAdapter,
14468
+ onSelectClick = props.onSelectClick,
14469
+ onDeleteClick = props.onDeleteClick;
14442
14470
  var domRef = React.useRef(null);
14443
14471
  var fileRef = React.useRef(null);
14444
14472
  var cacheRef = React.useRef([]);
@@ -14539,6 +14567,7 @@
14539
14567
  };
14540
14568
 
14541
14569
  var handleDelete = function handleDelete(index) {
14570
+ onDeleteClick && onDeleteClick(index);
14542
14571
  onChange(images.filter(function (_i, j) {
14543
14572
  return j !== index;
14544
14573
  }));
@@ -14562,17 +14591,20 @@
14562
14591
  }
14563
14592
  };
14564
14593
 
14565
- var handleSelect = function handleSelect() {
14594
+ var handleSelect = function handleSelect(e) {
14566
14595
  var _a;
14567
14596
 
14568
- selectAdapter ? selectAdapter().then(function (_a) {
14569
- var files = _a.files;
14570
- return handleChange({
14571
- target: {
14572
- files: files
14573
- }
14574
- }, true);
14575
- }) : (_a = fileRef.current) === null || _a === void 0 ? void 0 : _a.click();
14597
+ if (e.target !== fileRef.current) {
14598
+ onSelectClick && onSelectClick();
14599
+ selectAdapter ? selectAdapter().then(function (_a) {
14600
+ var files = _a.files;
14601
+ return handleChange({
14602
+ target: {
14603
+ files: files
14604
+ }
14605
+ }, true);
14606
+ }) : (_a = fileRef.current) === null || _a === void 0 ? void 0 : _a.click();
14607
+ }
14576
14608
  };
14577
14609
 
14578
14610
  var getGridData = function getGridData(prefixCls, locale) {
@@ -14682,7 +14714,7 @@
14682
14714
  });
14683
14715
 
14684
14716
  /*!
14685
- * @arco-design/transformable v1.0.2
14717
+ * @arco-design/transformable v1.0.1
14686
14718
  * (c) 2022 ludan.kibbon
14687
14719
  */
14688
14720
  function _defineProperty(obj, key, value) {
@@ -22733,6 +22765,314 @@
22733
22765
  return /*#__PURE__*/React__default["default"].createElement(ContextLayout, null, renderSearchBar);
22734
22766
  });
22735
22767
 
22768
+ function correctCalculation(leftNumber, rightNumber, operator) {
22769
+ var magnification = 1e17;
22770
+ var left = leftNumber * magnification;
22771
+ var right = rightNumber * magnification;
22772
+ return operator === '-' ? (left - right) / magnification : (left + right) / magnification;
22773
+ }
22774
+
22775
+ function useButtonClick(params) {
22776
+ var actualInputValue = params.actualInputValue,
22777
+ min = params.min,
22778
+ max = params.max,
22779
+ step = params.step,
22780
+ disabled = params.disabled,
22781
+ equalLimitDisabled = params.equalLimitDisabled,
22782
+ updateValue = params.updateValue,
22783
+ onAddButtonClick = params.onAddButtonClick,
22784
+ onMinusButtonClick = params.onMinusButtonClick;
22785
+
22786
+ var _a = React.useState(function () {
22787
+ return actualInputValue === min || disabled;
22788
+ }),
22789
+ minusButtonDisable = _a[0],
22790
+ setMinusButtonDisable = _a[1];
22791
+
22792
+ var _b = React.useState(function () {
22793
+ return actualInputValue === max || disabled;
22794
+ }),
22795
+ addButtonDisable = _b[0],
22796
+ setAddButtonDisable = _b[1];
22797
+
22798
+ var handleMinusButtonClick = function handleMinusButtonClick(e) {
22799
+ if (minusButtonDisable) {
22800
+ return;
22801
+ }
22802
+
22803
+ updateValue(function (oldValue) {
22804
+ var result = correctCalculation(oldValue, step, '-');
22805
+ return result < min ? equalLimitDisabled ? oldValue : min : result;
22806
+ });
22807
+ onMinusButtonClick && onMinusButtonClick(e);
22808
+ };
22809
+
22810
+ var handleAddButtonClick = function handleAddButtonClick(e) {
22811
+ if (addButtonDisable) {
22812
+ return;
22813
+ }
22814
+
22815
+ updateValue(function (oldValue) {
22816
+ var result = correctCalculation(Number(oldValue), step, '+');
22817
+ return result > max ? equalLimitDisabled ? oldValue : max : result;
22818
+ });
22819
+ onAddButtonClick && onAddButtonClick(e);
22820
+ }; // 当前值改变时,更新按钮状态
22821
+ // Changes button status when value changed
22822
+
22823
+
22824
+ React.useEffect(function () {
22825
+ setMinusButtonDisable(actualInputValue <= min);
22826
+ setAddButtonDisable(actualInputValue >= max);
22827
+ }, [actualInputValue]);
22828
+ return {
22829
+ minusButtonDisable: minusButtonDisable,
22830
+ addButtonDisable: addButtonDisable,
22831
+ handleMinusButtonClick: handleMinusButtonClick,
22832
+ handleAddButtonClick: handleAddButtonClick
22833
+ };
22834
+ }
22835
+
22836
+ function useInputEvent(params) {
22837
+ var defaultValue = params.defaultValue,
22838
+ min = params.min,
22839
+ max = params.max,
22840
+ digits = params.digits,
22841
+ actualInputValue = params.actualInputValue,
22842
+ allowEmpty = params.allowEmpty,
22843
+ updateValue = params.updateValue,
22844
+ onBlur = params.onBlur,
22845
+ onChange = params.onChange,
22846
+ onInput = params.onInput;
22847
+
22848
+ var handleInput = function handleInput(e) {
22849
+ var targetValue = e.target.value;
22850
+ var numberValue = Number(targetValue);
22851
+ var pointIndex = targetValue.indexOf('.');
22852
+
22853
+ if (digits > 0 && pointIndex !== -1) {
22854
+ var decimalLength = targetValue.slice(pointIndex + 1).length;
22855
+ updateValue(decimalLength > digits ? actualInputValue : numberValue);
22856
+ } else if (allowEmpty && targetValue === '') {
22857
+ updateValue(Number.MIN_VALUE);
22858
+ } else {
22859
+ updateValue(numberValue);
22860
+ }
22861
+
22862
+ onInput && onInput(e);
22863
+ };
22864
+
22865
+ var handleBlur = function handleBlur(e) {
22866
+ var targetValue = e.target.value;
22867
+ var numberValue = Number(targetValue);
22868
+
22869
+ if (allowEmpty && targetValue === '') {
22870
+ updateValue(Number.MIN_VALUE);
22871
+ } else if (!allowEmpty && targetValue === '') {
22872
+ updateValue(defaultValue);
22873
+ } else {
22874
+ updateValue(Math.max(min, Math.min(max, numberValue)));
22875
+ }
22876
+
22877
+ onBlur && onBlur(e);
22878
+ };
22879
+
22880
+ useUpdateEffect(function () {
22881
+ onChange && onChange(actualInputValue);
22882
+ }, [actualInputValue]);
22883
+ return {
22884
+ handleInput: handleInput,
22885
+ handleBlur: handleBlur
22886
+ };
22887
+ }
22888
+
22889
+ function useValue(params) {
22890
+ var defaultValue = params.defaultValue,
22891
+ formatter = params.formatter,
22892
+ max = params.max,
22893
+ min = params.min,
22894
+ value = params.value,
22895
+ digits = params.digits;
22896
+
22897
+ var _a = React.useState(defaultValue),
22898
+ innerValue = _a[0],
22899
+ setInnerValue = _a[1];
22900
+
22901
+ var updateValue = function updateValue(updater) {
22902
+ var tempValue = typeof updater === 'function' ? updater(innerValue) : updater;
22903
+
22904
+ if (formatter) {
22905
+ new Promise(function (resolve) {
22906
+ resolve(formatter(Number(tempValue)));
22907
+ }).then(function (result) {
22908
+ var res = Math.max(min, Math.min(max, result));
22909
+ setInnerValue(res);
22910
+ });
22911
+ } else {
22912
+ setInnerValue(tempValue);
22913
+ }
22914
+ };
22915
+
22916
+ var actualInputValue = value !== undefined ? value : innerValue; // 将actualInputValue等于Number.MIN_VALUE的情况视为空值
22917
+ // @en If actualInputValue equal Number.MIN_VALUE, actualInputValue equal ''
22918
+
22919
+ var showValue = actualInputValue === Number.MIN_VALUE ? '' : digits > 0 ? parseFloat(String(actualInputValue)).toFixed(digits) : actualInputValue;
22920
+ return {
22921
+ updateValue: updateValue,
22922
+ actualInputValue: actualInputValue,
22923
+ showValue: showValue
22924
+ };
22925
+ }
22926
+
22927
+ /**
22928
+ * 步进器组件,支持受控模式
22929
+ * @en Stepper component, provide controlled mode
22930
+ * @type 数据录入
22931
+ * @type_en Data Entry
22932
+ * @name 步进器
22933
+ * @name_en Stepper
22934
+ */
22935
+
22936
+ var Stepper = /*#__PURE__*/React.forwardRef(function (props, ref) {
22937
+ var _a = props.className,
22938
+ className = _a === void 0 ? '' : _a,
22939
+ style = props.style,
22940
+ inputStyle = props.inputStyle,
22941
+ _b = props.inputClass,
22942
+ inputClass = _b === void 0 ? '' : _b,
22943
+ value = props.value,
22944
+ _c = props.defaultValue,
22945
+ defaultValue = _c === void 0 ? 1 : _c,
22946
+ _d = props.allowEmpty,
22947
+ allowEmpty = _d === void 0 ? false : _d,
22948
+ _e = props.digits,
22949
+ digits = _e === void 0 ? 0 : _e,
22950
+ _f = props.disabled,
22951
+ disabled = _f === void 0 ? false : _f,
22952
+ _g = props.inputReadonly,
22953
+ inputReadonly = _g === void 0 ? false : _g,
22954
+ _h = props.max,
22955
+ max = _h === void 0 ? Infinity : _h,
22956
+ _j = props.min,
22957
+ min = _j === void 0 ? 1 : _j,
22958
+ _k = props.equalLimitDisabled,
22959
+ equalLimitDisabled = _k === void 0 ? false : _k,
22960
+ _l = props.step,
22961
+ step = _l === void 0 ? 1 : _l,
22962
+ _m = props.theme,
22963
+ theme = _m === void 0 ? 'default' : _m,
22964
+ formatter = props.formatter,
22965
+ addButton = props.addButton,
22966
+ minusButton = props.minusButton,
22967
+ renderContent = props.renderContent,
22968
+ onBlur = props.onBlur,
22969
+ onChange = props.onChange,
22970
+ onFocus = props.onFocus,
22971
+ onAddButtonClick = props.onAddButtonClick,
22972
+ onMinusButtonClick = props.onMinusButtonClick,
22973
+ onClick = props.onClick,
22974
+ onInput = props.onInput; // 值的相关逻辑
22975
+ // @en The logic is that handle value
22976
+
22977
+ var _o = useValue({
22978
+ defaultValue: defaultValue,
22979
+ formatter: formatter,
22980
+ min: min,
22981
+ max: max,
22982
+ value: value,
22983
+ digits: digits
22984
+ }),
22985
+ updateValue = _o.updateValue,
22986
+ actualInputValue = _o.actualInputValue,
22987
+ showValue = _o.showValue; // 按钮点击的相关逻辑
22988
+ // @en The logic is that handle button click
22989
+
22990
+
22991
+ var _p = useButtonClick({
22992
+ actualInputValue: actualInputValue,
22993
+ min: min,
22994
+ max: max,
22995
+ step: step,
22996
+ disabled: disabled,
22997
+ digits: digits,
22998
+ equalLimitDisabled: equalLimitDisabled,
22999
+ updateValue: updateValue,
23000
+ onAddButtonClick: onAddButtonClick,
23001
+ onMinusButtonClick: onMinusButtonClick
23002
+ }),
23003
+ minusButtonDisable = _p.minusButtonDisable,
23004
+ addButtonDisable = _p.addButtonDisable,
23005
+ handleAddButtonClick = _p.handleAddButtonClick,
23006
+ handleMinusButtonClick = _p.handleMinusButtonClick; // 输入框操作的相关逻辑
23007
+ // @en The logic is that handle input operation
23008
+
23009
+
23010
+ var _q = useInputEvent({
23011
+ defaultValue: defaultValue,
23012
+ min: min,
23013
+ max: max,
23014
+ digits: digits,
23015
+ actualInputValue: actualInputValue,
23016
+ allowEmpty: allowEmpty,
23017
+ updateValue: updateValue,
23018
+ onBlur: onBlur,
23019
+ onChange: onChange,
23020
+ onInput: onInput
23021
+ }),
23022
+ handleInput = _q.handleInput,
23023
+ handleBlur = _q.handleBlur;
23024
+
23025
+ var domRef = React.useRef(null);
23026
+ var inputRef = React.useRef(null);
23027
+ React.useImperativeHandle(ref, function () {
23028
+ return {
23029
+ dom: domRef.current,
23030
+ input: inputRef.current,
23031
+ changeValue: function changeValue(newValue) {
23032
+ var tempValue = newValue != null ? newValue : defaultValue;
23033
+ tempValue = Math.min(max, Math.max(tempValue, min));
23034
+ updateValue(tempValue);
23035
+ }
23036
+ };
23037
+ });
23038
+ return /*#__PURE__*/React__default["default"].createElement(ContextLayout, null, function (_a) {
23039
+ var prefixCls = _a.prefixCls;
23040
+ return /*#__PURE__*/React__default["default"].createElement("div", {
23041
+ className: cls(prefixCls + "-stepper", prefixCls + "-" + theme, className),
23042
+ style: style,
23043
+ ref: domRef,
23044
+ onClick: onClick
23045
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
23046
+ onClick: handleMinusButtonClick
23047
+ }, minusButton || /*#__PURE__*/React__default["default"].createElement("div", {
23048
+ className: cls(prefixCls + "-stepper-minus-button")
23049
+ }, /*#__PURE__*/React__default["default"].createElement(IconMinus, {
23050
+ className: cls(prefixCls + "-stepper-minus-button-icon", {
23051
+ disabled: minusButtonDisable
23052
+ })
23053
+ }))), renderContent ? renderContent(actualInputValue) : /*#__PURE__*/React__default["default"].createElement("input", {
23054
+ style: inputStyle,
23055
+ className: cls(prefixCls + "-stepper-input", inputClass),
23056
+ onFocus: onFocus,
23057
+ onInput: handleInput,
23058
+ onBlur: handleBlur,
23059
+ disabled: disabled,
23060
+ value: showValue,
23061
+ readOnly: inputReadonly,
23062
+ ref: inputRef,
23063
+ type: "number"
23064
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
23065
+ onClick: handleAddButtonClick
23066
+ }, addButton || /*#__PURE__*/React__default["default"].createElement("div", {
23067
+ className: cls(prefixCls + "-stepper-add-button")
23068
+ }, /*#__PURE__*/React__default["default"].createElement(IconAdd, {
23069
+ className: cls(prefixCls + "-stepper-add-button-icon", {
23070
+ disabled: addButtonDisable
23071
+ })
23072
+ }))));
23073
+ });
23074
+ });
23075
+
22736
23076
  var Step = /*#__PURE__*/React.forwardRef(function (props, ref) {
22737
23077
  var title = props.title,
22738
23078
  description = props.description,
@@ -24212,6 +24552,7 @@
24212
24552
  exports.SearchBar = SearchBar;
24213
24553
  exports.ShowMonitor = ShowMonitor;
24214
24554
  exports.Slider = SliderWrapper;
24555
+ exports.Stepper = Stepper;
24215
24556
  exports.Steps = index$2;
24216
24557
  exports.Sticky = Sticky;
24217
24558
  exports.SwipeAction = SwipeAction;