antd-mobile 5.30.0 → 5.31.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 (106) hide show
  1. package/2x/README.md +1 -1
  2. package/2x/bundle/antd-mobile.cjs.development.js +281 -232
  3. package/2x/bundle/antd-mobile.cjs.js +9 -9
  4. package/2x/bundle/antd-mobile.es.development.js +281 -232
  5. package/2x/bundle/antd-mobile.es.js +4172 -4128
  6. package/2x/bundle/antd-mobile.umd.development.js +281 -232
  7. package/2x/bundle/antd-mobile.umd.js +9 -9
  8. package/2x/cjs/components/avatar/avatar.js +1 -1
  9. package/2x/cjs/components/button/button.d.ts +2 -2
  10. package/2x/cjs/components/cascader/cascader.js +1 -6
  11. package/2x/cjs/components/cascader-view/cascader-view.d.ts +1 -0
  12. package/2x/cjs/components/cascader-view/cascader-view.js +2 -1
  13. package/2x/cjs/components/date-picker/date-picker.d.ts +1 -1
  14. package/2x/cjs/components/date-picker/index.d.ts +1 -1
  15. package/2x/cjs/components/ellipsis/ellipsis.d.ts +2 -2
  16. package/2x/cjs/components/ellipsis/ellipsis.js +17 -17
  17. package/2x/cjs/components/image/image.d.ts +1 -1
  18. package/2x/cjs/components/image/image.js +1 -0
  19. package/2x/cjs/components/input/input.d.ts +2 -4
  20. package/2x/cjs/components/list/list-item.d.ts +1 -1
  21. package/2x/cjs/components/notice-bar/notice-bar.d.ts +2 -0
  22. package/2x/cjs/components/notice-bar/notice-bar.js +2 -1
  23. package/2x/cjs/components/popup/popup.d.ts +1 -0
  24. package/2x/cjs/components/popup/popup.js +2 -0
  25. package/2x/cjs/components/pull-to-refresh/pull-to-refresh.js +4 -2
  26. package/2x/cjs/components/slider/slider.js +6 -4
  27. package/2x/cjs/components/swiper/swiper.js +15 -11
  28. package/2x/cjs/components/text-area/text-area.d.ts +1 -1
  29. package/2x/cjs/utils/reduce-and-restore-motion.js +1 -1
  30. package/2x/es/components/avatar/avatar.js +1 -1
  31. package/2x/es/components/button/button.d.ts +2 -2
  32. package/2x/es/components/cascader/cascader.js +1 -6
  33. package/2x/es/components/cascader-view/cascader-view.d.ts +1 -0
  34. package/2x/es/components/cascader-view/cascader-view.js +2 -1
  35. package/2x/es/components/date-picker/date-picker.d.ts +1 -1
  36. package/2x/es/components/date-picker/index.d.ts +1 -1
  37. package/2x/es/components/ellipsis/ellipsis.d.ts +2 -2
  38. package/2x/es/components/ellipsis/ellipsis.js +17 -17
  39. package/2x/es/components/image/image.d.ts +1 -1
  40. package/2x/es/components/image/image.js +1 -0
  41. package/2x/es/components/input/input.d.ts +2 -4
  42. package/2x/es/components/list/list-item.d.ts +1 -1
  43. package/2x/es/components/notice-bar/notice-bar.d.ts +2 -0
  44. package/2x/es/components/notice-bar/notice-bar.js +2 -1
  45. package/2x/es/components/popup/popup.d.ts +1 -0
  46. package/2x/es/components/popup/popup.js +2 -0
  47. package/2x/es/components/pull-to-refresh/pull-to-refresh.js +4 -2
  48. package/2x/es/components/slider/slider.js +6 -4
  49. package/2x/es/components/swiper/swiper.js +16 -12
  50. package/2x/es/components/text-area/text-area.d.ts +1 -1
  51. package/2x/es/utils/reduce-and-restore-motion.js +1 -1
  52. package/2x/package.json +2 -2
  53. package/README.md +1 -1
  54. package/bundle/antd-mobile.cjs.development.js +281 -232
  55. package/bundle/antd-mobile.cjs.js +9 -9
  56. package/bundle/antd-mobile.compatible.umd.js +1 -1
  57. package/bundle/antd-mobile.es.development.js +281 -232
  58. package/bundle/antd-mobile.es.js +4172 -4128
  59. package/bundle/antd-mobile.umd.development.js +281 -232
  60. package/bundle/antd-mobile.umd.js +9 -9
  61. package/cjs/components/avatar/avatar.js +1 -1
  62. package/cjs/components/button/button.d.ts +2 -2
  63. package/cjs/components/cascader/cascader.js +1 -6
  64. package/cjs/components/cascader-view/cascader-view.d.ts +1 -0
  65. package/cjs/components/cascader-view/cascader-view.js +2 -1
  66. package/cjs/components/date-picker/date-picker.d.ts +1 -1
  67. package/cjs/components/date-picker/index.d.ts +1 -1
  68. package/cjs/components/ellipsis/ellipsis.d.ts +2 -2
  69. package/cjs/components/ellipsis/ellipsis.js +17 -17
  70. package/cjs/components/image/image.d.ts +1 -1
  71. package/cjs/components/image/image.js +1 -0
  72. package/cjs/components/input/input.d.ts +2 -4
  73. package/cjs/components/list/list-item.d.ts +1 -1
  74. package/cjs/components/notice-bar/notice-bar.d.ts +2 -0
  75. package/cjs/components/notice-bar/notice-bar.js +2 -1
  76. package/cjs/components/popup/popup.d.ts +1 -0
  77. package/cjs/components/popup/popup.js +2 -0
  78. package/cjs/components/pull-to-refresh/pull-to-refresh.js +4 -2
  79. package/cjs/components/slider/slider.js +6 -4
  80. package/cjs/components/swiper/swiper.js +15 -11
  81. package/cjs/components/text-area/text-area.d.ts +1 -1
  82. package/cjs/utils/reduce-and-restore-motion.js +1 -1
  83. package/es/components/avatar/avatar.js +1 -1
  84. package/es/components/button/button.d.ts +2 -2
  85. package/es/components/cascader/cascader.js +1 -6
  86. package/es/components/cascader-view/cascader-view.d.ts +1 -0
  87. package/es/components/cascader-view/cascader-view.js +2 -1
  88. package/es/components/date-picker/date-picker.d.ts +1 -1
  89. package/es/components/date-picker/index.d.ts +1 -1
  90. package/es/components/ellipsis/ellipsis.d.ts +2 -2
  91. package/es/components/ellipsis/ellipsis.js +17 -17
  92. package/es/components/image/image.d.ts +1 -1
  93. package/es/components/image/image.js +1 -0
  94. package/es/components/input/input.d.ts +2 -4
  95. package/es/components/list/list-item.d.ts +1 -1
  96. package/es/components/notice-bar/notice-bar.d.ts +2 -0
  97. package/es/components/notice-bar/notice-bar.js +2 -1
  98. package/es/components/popup/popup.d.ts +1 -0
  99. package/es/components/popup/popup.js +2 -0
  100. package/es/components/pull-to-refresh/pull-to-refresh.js +4 -2
  101. package/es/components/slider/slider.js +6 -4
  102. package/es/components/swiper/swiper.js +16 -12
  103. package/es/components/text-area/text-area.d.ts +1 -1
  104. package/es/utils/reduce-and-restore-motion.js +1 -1
  105. package/package.json +2 -2
  106. package/umd/antd-mobile.js +1 -1
@@ -19,6 +19,8 @@ const defaultProps = {
19
19
  export const Ellipsis = p => {
20
20
  const props = mergeProps(defaultProps, p);
21
21
  const rootRef = useRef(null);
22
+ const expandElRef = useRef(null);
23
+ const collapseElRef = useRef(null);
22
24
  const [ellipsised, setEllipsised] = useState({});
23
25
  const [expanded, setExpanded] = useState(props.defaultExpanded);
24
26
  const [exceeded, setExceeded] = useState(false);
@@ -27,19 +29,18 @@ export const Ellipsis = p => {
27
29
  return chars.slice(start, end).join('');
28
30
  }
29
31
  function calcEllipsised() {
32
+ var _a, _b;
30
33
  const root = rootRef.current;
31
34
  if (!root) return;
32
- if (!root.offsetParent) return;
35
+ const originDisplay = root.style.display;
36
+ root.style.display = 'block';
33
37
  const originStyle = window.getComputedStyle(root);
34
38
  const container = document.createElement('div');
35
39
  const styleNames = Array.prototype.slice.apply(originStyle);
36
40
  styleNames.forEach(name => {
37
41
  container.style.setProperty(name, originStyle.getPropertyValue(name));
38
42
  });
39
- container.style.position = 'fixed';
40
- container.style.left = '999999px';
41
- container.style.top = '999999px';
42
- container.style.zIndex = '-1000';
43
+ root.style.display = originDisplay;
43
44
  container.style.height = 'auto';
44
45
  container.style.minHeight = 'auto';
45
46
  container.style.maxHeight = 'auto';
@@ -56,7 +57,9 @@ export const Ellipsis = p => {
56
57
  } else {
57
58
  setExceeded(true);
58
59
  const end = props.content.length;
59
- const actionText = expanded ? props.collapseText : props.expandText;
60
+ const collapseEl = typeof props.collapseText === 'string' ? props.collapseText : (_a = collapseElRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML;
61
+ const expandEl = typeof props.expandText === 'string' ? props.expandText : (_b = expandElRef.current) === null || _b === void 0 ? void 0 : _b.innerHTML;
62
+ const actionText = expanded ? collapseEl : expandEl;
60
63
  function check(left, right) {
61
64
  if (right - left <= 1) {
62
65
  if (props.direction === 'end') {
@@ -71,9 +74,9 @@ export const Ellipsis = p => {
71
74
  }
72
75
  const middle = Math.round((left + right) / 2);
73
76
  if (props.direction === 'end') {
74
- container.innerText = getSubString(0, middle) + '...' + actionText;
77
+ container.innerHTML = getSubString(0, middle) + '...' + actionText;
75
78
  } else {
76
- container.innerText = actionText + '...' + getSubString(middle, end);
79
+ container.innerHTML = actionText + '...' + getSubString(middle, end);
77
80
  }
78
81
  if (container.offsetHeight <= maxHeight) {
79
82
  if (props.direction === 'end') {
@@ -98,7 +101,7 @@ export const Ellipsis = p => {
98
101
  }
99
102
  const leftPartMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
100
103
  const rightPartMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
101
- container.innerText = getSubString(0, leftPartMiddle) + '...' + actionText + '...' + getSubString(rightPartMiddle, end);
104
+ container.innerHTML = getSubString(0, leftPartMiddle) + '...' + actionText + '...' + getSubString(rightPartMiddle, end);
102
105
  if (container.offsetHeight <= maxHeight) {
103
106
  return checkMiddle([leftPartMiddle, leftPart[1]], [rightPart[0], rightPartMiddle]);
104
107
  } else {
@@ -116,24 +119,21 @@ export const Ellipsis = p => {
116
119
  calcEllipsised();
117
120
  }, [props.content, props.direction, props.rows, props.expandText, props.collapseText]);
118
121
  const expandActionElement = exceeded && props.expandText ? withStopPropagation(props.stopPropagationForActionButtons, React.createElement("a", {
122
+ ref: expandElRef,
119
123
  onClick: () => {
120
124
  setExpanded(true);
121
125
  }
122
126
  }, props.expandText)) : null;
123
127
  const collapseActionElement = exceeded && props.collapseText ? withStopPropagation(props.stopPropagationForActionButtons, React.createElement("a", {
128
+ ref: collapseElRef,
124
129
  onClick: () => {
125
130
  setExpanded(false);
126
131
  }
127
132
  }, props.collapseText)) : null;
128
133
  const renderContent = () => {
129
- if (!exceeded) {
130
- return props.content;
131
- }
132
- if (expanded) {
133
- return React.createElement(React.Fragment, null, props.content, collapseActionElement);
134
- } else {
135
- return React.createElement(React.Fragment, null, ellipsised.leading, expandActionElement, ellipsised.tailing);
136
- }
134
+ if (!exceeded) return props.content;
135
+ if (expanded) return React.createElement(React.Fragment, null, props.content, collapseActionElement);
136
+ return React.createElement(React.Fragment, null, ellipsised.leading, expandActionElement, ellipsised.tailing);
137
137
  };
138
138
  return withNativeProps(props, React.createElement("div", {
139
139
  ref: rootRef,
@@ -14,5 +14,5 @@ export declare type ImageProps = {
14
14
  onError?: (event: React.SyntheticEvent<HTMLImageElement, Event>) => void;
15
15
  onLoad?: (event: React.SyntheticEvent<HTMLImageElement, Event>) => void;
16
16
  onContainerClick?: (event: React.MouseEvent<HTMLDivElement, Event>) => void;
17
- } & NativeProps<'--width' | '--height'> & Pick<React.ImgHTMLAttributes<HTMLImageElement>, 'crossOrigin' | 'decoding' | 'loading' | 'referrerPolicy' | 'sizes' | 'srcSet' | 'useMap'>;
17
+ } & NativeProps<'--width' | '--height'> & Pick<React.ImgHTMLAttributes<HTMLImageElement>, 'crossOrigin' | 'decoding' | 'loading' | 'referrerPolicy' | 'sizes' | 'srcSet' | 'useMap' | 'id'>;
18
18
  export declare const Image: React.FC<ImageProps>;
@@ -47,6 +47,7 @@ export const Image = staged(p => {
47
47
  }
48
48
  const img = React.createElement("img", {
49
49
  ref: imgRef,
50
+ id: props.id,
50
51
  className: `${classPrefix}-img`,
51
52
  src: src,
52
53
  alt: props.alt,
@@ -4,7 +4,7 @@ declare type NativeInputProps = React.DetailedHTMLProps<React.InputHTMLAttribute
4
4
  declare type AriaProps = {
5
5
  role?: string;
6
6
  };
7
- export declare type InputProps = Pick<NativeInputProps, 'maxLength' | 'minLength' | 'autoComplete' | 'autoFocus' | 'pattern' | 'inputMode' | 'type' | 'name' | 'onFocus' | 'onBlur' | 'autoCapitalize' | 'autoCorrect' | 'onKeyDown' | 'onKeyUp' | 'onCompositionStart' | 'onCompositionEnd' | 'onClick' | 'step'> & {
7
+ export declare type InputProps = Pick<NativeInputProps, 'maxLength' | 'minLength' | 'autoComplete' | 'autoFocus' | 'pattern' | 'inputMode' | 'type' | 'name' | 'onFocus' | 'onBlur' | 'autoCapitalize' | 'autoCorrect' | 'onKeyDown' | 'onKeyUp' | 'onCompositionStart' | 'onCompositionEnd' | 'onClick' | 'step' | 'id'> & {
8
8
  value?: string;
9
9
  defaultValue?: string;
10
10
  onChange?: (val: string) => void;
@@ -14,7 +14,6 @@ export declare type InputProps = Pick<NativeInputProps, 'maxLength' | 'minLength
14
14
  clearable?: boolean;
15
15
  onlyShowClearWhenFocus?: boolean;
16
16
  onClear?: () => void;
17
- id?: string;
18
17
  onEnterPress?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
19
18
  enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
20
19
  min?: number;
@@ -26,7 +25,7 @@ export declare type InputRef = {
26
25
  blur: () => void;
27
26
  nativeElement: HTMLInputElement | null;
28
27
  };
29
- export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProps, "pattern" | "onClick" | "name" | "type" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "autoFocus" | "autoCapitalize" | "autoCorrect" | "inputMode" | "autoComplete" | "maxLength" | "minLength" | "step"> & {
28
+ export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProps, "pattern" | "id" | "onClick" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "type" | "step" | "autoFocus" | "autoCapitalize" | "autoCorrect" | "inputMode" | "name" | "autoComplete" | "maxLength" | "minLength"> & {
30
29
  value?: string | undefined;
31
30
  defaultValue?: string | undefined;
32
31
  onChange?: ((val: string) => void) | undefined;
@@ -36,7 +35,6 @@ export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProp
36
35
  clearable?: boolean | undefined;
37
36
  onlyShowClearWhenFocus?: boolean | undefined;
38
37
  onClear?: (() => void) | undefined;
39
- id?: string | undefined;
40
38
  onEnterPress?: ((e: React.KeyboardEvent<HTMLInputElement>) => void) | undefined;
41
39
  enterKeyHint?: "search" | "enter" | "done" | "go" | "next" | "previous" | "send" | undefined;
42
40
  min?: number | undefined;
@@ -9,6 +9,6 @@ export declare type ListItemProps = {
9
9
  clickable?: boolean;
10
10
  arrow?: boolean | ReactNode;
11
11
  disabled?: boolean;
12
- onClick?: (e: React.MouseEvent) => void;
12
+ onClick?: (e: React.MouseEvent<HTMLElement>) => void;
13
13
  } & NativeProps<'--prefix-width' | '--align-items' | '--active-background-color'>;
14
14
  export declare const ListItem: FC<ListItemProps>;
@@ -13,6 +13,8 @@ export declare type NoticeBarProps = {
13
13
  closeable?: boolean;
14
14
  /** Callback when closed */
15
15
  onClose?: () => void;
16
+ /** Event when click */
17
+ onClick?: () => void;
16
18
  /** Additional operating area, displayed to the left of the close button */
17
19
  extra?: React.ReactNode;
18
20
  /** Radio icon on the left */
@@ -64,7 +64,8 @@ export const NoticeBar = memo(p => {
64
64
  return withNativeProps(props, React.createElement("div", {
65
65
  className: classNames(classPrefix, `${classPrefix}-${props.color}`, {
66
66
  [`${classPrefix}-wrap`]: props.wrap
67
- })
67
+ }),
68
+ onClick: props.onClick
68
69
  }, props.icon && React.createElement("span", {
69
70
  className: `${classPrefix}-left`
70
71
  }, props.icon), React.createElement("span", {
@@ -3,5 +3,6 @@ import { NativeProps } from '../../utils/native-props';
3
3
  import { PopupBaseProps } from './popup-base-props';
4
4
  export declare type PopupProps = PopupBaseProps & PropsWithChildren<{
5
5
  position?: 'bottom' | 'top' | 'left' | 'right';
6
+ closeOnSwipe?: boolean;
6
7
  }> & NativeProps<'--z-index'>;
7
8
  export declare const Popup: FC<PopupProps>;
@@ -16,6 +16,7 @@ import { useConfig } from '../config-provider';
16
16
  import { useDrag } from '@use-gesture/react';
17
17
  const classPrefix = `adm-popup`;
18
18
  const defaultProps = Object.assign(Object.assign({}, defaultPopupBaseProps), {
19
+ closeOnSwipe: false,
19
20
  position: 'bottom'
20
21
  });
21
22
  export const Popup = p => {
@@ -58,6 +59,7 @@ export const Popup = p => {
58
59
  swipe: [, swipeY]
59
60
  }) => {
60
61
  var _a;
62
+ if (!props.closeOnSwipe) return;
61
63
  if (swipeY === 1 && props.position === 'bottom' || swipeY === -1 && props.position === 'top') {
62
64
  (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
63
65
  }
@@ -40,6 +40,7 @@ export const PullToRefresh = p => {
40
40
  config: {
41
41
  tension: 300,
42
42
  friction: 30,
43
+ round: true,
43
44
  clamp: true
44
45
  }
45
46
  }));
@@ -99,7 +100,8 @@ export const PullToRefresh = p => {
99
100
  return;
100
101
  }
101
102
  const [, y] = state.movement;
102
- if (state.first && y > 0) {
103
+ const parsedY = Math.ceil(y);
104
+ if (state.first && parsedY > 0) {
103
105
  const target = state.event.target;
104
106
  if (!target || !(target instanceof Element)) return;
105
107
  let scrollParent = getScrollParent(target);
@@ -124,7 +126,7 @@ export const PullToRefresh = p => {
124
126
  event.preventDefault();
125
127
  }
126
128
  event.stopPropagation();
127
- const height = Math.max(rubberbandIfOutOfBounds(y, 0, 0, headHeight * 5, 0.5), 0);
129
+ const height = Math.max(rubberbandIfOutOfBounds(parsedY, 0, 0, headHeight * 5, 0.5), 0);
128
130
  api.start({
129
131
  height
130
132
  });
@@ -78,13 +78,14 @@ export const Slider = p => {
78
78
  const pointList = useMemo(() => {
79
79
  if (marks) {
80
80
  return Object.keys(marks).map(parseFloat).sort((a, b) => a - b);
81
- } else {
81
+ } else if (ticks) {
82
82
  const points = [];
83
83
  for (let i = getMiniDecimal(min); i.lessEquals(getMiniDecimal(max)); i = i.add(step)) {
84
84
  points.push(i.toNumber());
85
85
  }
86
86
  return points;
87
87
  }
88
+ return [];
88
89
  }, [marks, ticks, step, min, max]);
89
90
  function getValueByPosition(position) {
90
91
  const newPosition = position < min ? min : position > max ? max : position;
@@ -93,9 +94,10 @@ export const Slider = p => {
93
94
  if (pointList.length) {
94
95
  value = nearest(pointList, newPosition);
95
96
  } else {
96
- const lengthPerStep = 100 / ((max - min) / step);
97
- const steps = Math.round(newPosition / lengthPerStep);
98
- value = steps * lengthPerStep * (max - min) * 0.01 + min;
97
+ // 使用 MiniDecimal 避免精度问题
98
+ const cell = Math.round((newPosition - min) / step);
99
+ const nextVal = getMiniDecimal(cell).multi(step);
100
+ value = getMiniDecimal(min).add(nextVal.toString()).toNumber();
99
101
  }
100
102
  return value;
101
103
  }
@@ -10,7 +10,7 @@ import PageIndicator from '../page-indicator';
10
10
  import { staged } from 'staged-components';
11
11
  import { useRefState } from '../../utils/use-ref-state';
12
12
  import { bound } from '../../utils/bound';
13
- import { useIsomorphicLayoutEffect } from 'ahooks';
13
+ import { useIsomorphicLayoutEffect, useGetState } from 'ahooks';
14
14
  import { mergeFuncProps } from '../../utils/with-func-props';
15
15
  const classPrefix = `adm-swiper`;
16
16
  const eventToPropRecord = {
@@ -35,6 +35,7 @@ let currentUid;
35
35
  export const Swiper = forwardRef(staged((p, ref) => {
36
36
  const props = mergeProps(defaultProps, p);
37
37
  const [uid] = useState({});
38
+ const timeoutRef = useRef(null);
38
39
  const isVertical = props.direction === 'vertical';
39
40
  const slideRatio = props.slideSize / 100;
40
41
  const offsetRatio = props.trackOffset / 100;
@@ -73,7 +74,7 @@ export const Swiper = forwardRef(staged((p, ref) => {
73
74
  const trackPixels = isVertical ? track.offsetHeight : track.offsetWidth;
74
75
  return trackPixels * props.slideSize / 100;
75
76
  }
76
- const [current, setCurrent] = useState(props.defaultIndex);
77
+ const [current, setCurrent, getCurrent] = useGetState(props.defaultIndex);
77
78
  const [dragging, setDragging, draggingRef] = useRefState(false);
78
79
  function boundIndex(current) {
79
80
  let min = 0;
@@ -172,7 +173,7 @@ export const Swiper = forwardRef(staged((p, ref) => {
172
173
  const roundedIndex = Math.round(index);
173
174
  const targetIndex = loop ? modulus(roundedIndex, count) : bound(roundedIndex, 0, count - 1);
174
175
  setCurrent(targetIndex);
175
- if (targetIndex !== current) {
176
+ if (targetIndex !== getCurrent()) {
176
177
  (_a = props.onIndexChange) === null || _a === void 0 ? void 0 : _a.call(props, targetIndex);
177
178
  }
178
179
  api.start({
@@ -201,16 +202,17 @@ export const Swiper = forwardRef(staged((p, ref) => {
201
202
  autoplay,
202
203
  autoplayInterval
203
204
  } = props;
205
+ const runTimeSwiper = () => {
206
+ timeoutRef.current = window.setTimeout(() => {
207
+ swipeNext();
208
+ runTimeSwiper();
209
+ }, autoplayInterval);
210
+ };
204
211
  useEffect(() => {
205
212
  if (!autoplay || dragging) return;
206
- let interval;
207
- function tick() {
208
- interval = window.setTimeout(tick, autoplayInterval);
209
- swipeNext();
210
- }
211
- interval = window.setTimeout(tick, autoplayInterval);
213
+ runTimeSwiper();
212
214
  return () => {
213
- if (interval) window.clearTimeout(interval);
215
+ if (timeoutRef.current) window.clearTimeout(timeoutRef.current);
214
216
  };
215
217
  }, [autoplay, autoplayInterval, dragging, count]);
216
218
  function renderTrackInner() {
@@ -240,9 +242,11 @@ export const Swiper = forwardRef(staged((p, ref) => {
240
242
  style: {
241
243
  [isVertical ? 'y' : 'x']: position.to(position => `${-position}%`)
242
244
  }
243
- }, React.Children.map(validChildren, child => {
245
+ }, React.Children.map(validChildren, (child, index) => {
244
246
  return React.createElement("div", {
245
- className: `${classPrefix}-slide`
247
+ className: classNames(`${classPrefix}-slide`, {
248
+ [`${classPrefix}-slide-active`]: current === index
249
+ })
246
250
  }, child);
247
251
  }));
248
252
  }
@@ -21,7 +21,7 @@ export declare type TextAreaRef = {
21
21
  blur: () => void;
22
22
  nativeElement: HTMLTextAreaElement | null;
23
23
  };
24
- export declare const TextArea: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "onClick" | "disabled" | "name" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "autoFocus" | "autoComplete" | "readOnly"> & {
24
+ export declare const TextArea: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "onClick" | "disabled" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "autoFocus" | "name" | "readOnly" | "autoComplete"> & {
25
25
  onChange?: ((val: string) => void) | undefined;
26
26
  value?: string | undefined;
27
27
  defaultValue?: string | undefined;
@@ -31,5 +31,5 @@ function subscribe(onStoreChange) {
31
31
  };
32
32
  }
33
33
  export function useMotionReduced() {
34
- return useSyncExternalStore(subscribe, isMotionReduced);
34
+ return useSyncExternalStore(subscribe, isMotionReduced, isMotionReduced);
35
35
  }
package/2x/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "antd-mobile",
3
- "version": "5.30.0",
3
+ "version": "5.31.0",
4
4
  "dependencies": {
5
5
  "@floating-ui/dom": "^1.2.6",
6
- "@rc-component/mini-decimal": "^1.0.1",
6
+ "@rc-component/mini-decimal": "^1.1.0",
7
7
  "@react-spring/web": "~9.6.1",
8
8
  "@use-gesture/react": "10.2.20",
9
9
  "ahooks": "^3.7.6",
package/README.md CHANGED
@@ -16,7 +16,7 @@
16
16
  <span> · </span>
17
17
  <a href="https://discord.gg/jmNvw4WFYn">Discord</a>
18
18
  <span> · </span>
19
- <a href="https://gw.alipayobjects.com/mdn/rms_25513e/afts/img/A*hBjlR4nUWjkAAAAAAAAAAAAAARQnAQ">钉钉</a>
19
+ <a href="https://user-images.githubusercontent.com/22469543/197447477-1f10603d-90e9-43ea-a023-6538c5cf40e2.jpeg">钉钉</a>
20
20
  </h4>
21
21
  </div>
22
22