antd-mobile 5.41.0-alpha.1 → 5.41.0-alpha.3

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 (104) hide show
  1. package/2x/bundle/antd-mobile.cjs.development.js +1480 -1410
  2. package/2x/bundle/antd-mobile.cjs.js +7 -7
  3. package/2x/bundle/antd-mobile.es.development.js +442 -372
  4. package/2x/bundle/antd-mobile.es.js +4843 -4796
  5. package/2x/bundle/antd-mobile.umd.development.js +1480 -1410
  6. package/2x/bundle/antd-mobile.umd.js +7 -7
  7. package/2x/cjs/components/avatar/avatar.d.ts +3 -1
  8. package/2x/cjs/components/avatar/avatar.js +4 -2
  9. package/2x/cjs/components/calendar/calendar.js +4 -4
  10. package/2x/cjs/components/ellipsis/useMeasure.js +4 -3
  11. package/2x/cjs/components/image/image.d.ts +1 -1
  12. package/2x/cjs/components/image/image.js +5 -5
  13. package/2x/cjs/components/image-viewer/image-viewer.d.ts +7 -4
  14. package/2x/cjs/components/image-viewer/index.d.ts +2 -1
  15. package/2x/cjs/components/image-viewer/methods.js +1 -1
  16. package/2x/cjs/components/image-viewer/slide.d.ts +3 -2
  17. package/2x/cjs/components/image-viewer/slide.js +2 -1
  18. package/2x/cjs/components/image-viewer/slides.d.ts +3 -2
  19. package/2x/cjs/components/input/input.d.ts +1 -1
  20. package/2x/cjs/components/input/input.js +1 -3
  21. package/2x/cjs/components/input/useInputHandleKeyDown.d.ts +1 -3
  22. package/2x/cjs/components/input/useInputHandleKeyDown.js +1 -12
  23. package/2x/cjs/components/number-keyboard/number-keyboard.js +21 -12
  24. package/2x/cjs/components/picker/index.d.ts +4 -2
  25. package/2x/cjs/components/swiper/swiper.d.ts +3 -3
  26. package/2x/cjs/components/swiper/swiper.js +47 -38
  27. package/2x/cjs/components/text-area/text-area.d.ts +1 -1
  28. package/2x/cjs/components/text-area/text-area.js +6 -7
  29. package/2x/es/components/avatar/avatar.d.ts +3 -1
  30. package/2x/es/components/avatar/avatar.js +4 -2
  31. package/2x/es/components/calendar/calendar.js +4 -4
  32. package/2x/es/components/ellipsis/useMeasure.js +4 -3
  33. package/2x/es/components/image/image.d.ts +1 -1
  34. package/2x/es/components/image/image.js +6 -6
  35. package/2x/es/components/image-viewer/image-viewer.d.ts +7 -4
  36. package/2x/es/components/image-viewer/index.d.ts +2 -1
  37. package/2x/es/components/image-viewer/methods.js +1 -1
  38. package/2x/es/components/image-viewer/slide.d.ts +3 -2
  39. package/2x/es/components/image-viewer/slide.js +2 -1
  40. package/2x/es/components/image-viewer/slides.d.ts +3 -2
  41. package/2x/es/components/input/input.d.ts +1 -1
  42. package/2x/es/components/input/input.js +1 -3
  43. package/2x/es/components/input/useInputHandleKeyDown.d.ts +1 -3
  44. package/2x/es/components/input/useInputHandleKeyDown.js +1 -12
  45. package/2x/es/components/number-keyboard/number-keyboard.js +21 -12
  46. package/2x/es/components/picker/index.d.ts +4 -2
  47. package/2x/es/components/swiper/swiper.d.ts +3 -3
  48. package/2x/es/components/swiper/swiper.js +28 -19
  49. package/2x/es/components/text-area/text-area.d.ts +1 -1
  50. package/2x/es/components/text-area/text-area.js +6 -7
  51. package/2x/package.json +1 -1
  52. package/bundle/antd-mobile.cjs.development.js +1480 -1410
  53. package/bundle/antd-mobile.cjs.js +7 -7
  54. package/bundle/antd-mobile.compatible.umd.js +1 -1
  55. package/bundle/antd-mobile.es.development.js +442 -372
  56. package/bundle/antd-mobile.es.js +4843 -4796
  57. package/bundle/antd-mobile.umd.development.js +1480 -1410
  58. package/bundle/antd-mobile.umd.js +7 -7
  59. package/cjs/components/avatar/avatar.d.ts +3 -1
  60. package/cjs/components/avatar/avatar.js +4 -2
  61. package/cjs/components/calendar/calendar.js +4 -4
  62. package/cjs/components/ellipsis/useMeasure.js +4 -3
  63. package/cjs/components/image/image.d.ts +1 -1
  64. package/cjs/components/image/image.js +5 -5
  65. package/cjs/components/image-viewer/image-viewer.d.ts +7 -4
  66. package/cjs/components/image-viewer/index.d.ts +2 -1
  67. package/cjs/components/image-viewer/methods.js +1 -1
  68. package/cjs/components/image-viewer/slide.d.ts +3 -2
  69. package/cjs/components/image-viewer/slide.js +2 -1
  70. package/cjs/components/image-viewer/slides.d.ts +3 -2
  71. package/cjs/components/input/input.d.ts +1 -1
  72. package/cjs/components/input/input.js +1 -3
  73. package/cjs/components/input/useInputHandleKeyDown.d.ts +1 -3
  74. package/cjs/components/input/useInputHandleKeyDown.js +1 -12
  75. package/cjs/components/number-keyboard/number-keyboard.js +21 -12
  76. package/cjs/components/picker/index.d.ts +4 -2
  77. package/cjs/components/swiper/swiper.d.ts +3 -3
  78. package/cjs/components/swiper/swiper.js +47 -38
  79. package/cjs/components/text-area/text-area.d.ts +1 -1
  80. package/cjs/components/text-area/text-area.js +6 -7
  81. package/es/components/avatar/avatar.d.ts +3 -1
  82. package/es/components/avatar/avatar.js +4 -2
  83. package/es/components/calendar/calendar.js +4 -4
  84. package/es/components/ellipsis/useMeasure.js +4 -3
  85. package/es/components/image/image.d.ts +1 -1
  86. package/es/components/image/image.js +6 -6
  87. package/es/components/image-viewer/image-viewer.d.ts +7 -4
  88. package/es/components/image-viewer/index.d.ts +2 -1
  89. package/es/components/image-viewer/methods.js +1 -1
  90. package/es/components/image-viewer/slide.d.ts +3 -2
  91. package/es/components/image-viewer/slide.js +2 -1
  92. package/es/components/image-viewer/slides.d.ts +3 -2
  93. package/es/components/input/input.d.ts +1 -1
  94. package/es/components/input/input.js +1 -3
  95. package/es/components/input/useInputHandleKeyDown.d.ts +1 -3
  96. package/es/components/input/useInputHandleKeyDown.js +1 -12
  97. package/es/components/number-keyboard/number-keyboard.js +21 -12
  98. package/es/components/picker/index.d.ts +4 -2
  99. package/es/components/swiper/swiper.d.ts +3 -3
  100. package/es/components/swiper/swiper.js +28 -19
  101. package/es/components/text-area/text-area.d.ts +1 -1
  102. package/es/components/text-area/text-area.js +6 -7
  103. package/package.json +1 -1
  104. package/umd/antd-mobile.js +1 -1
@@ -1,9 +1,11 @@
1
1
  import type { FC, ReactNode } from 'react';
2
+ import React from 'react';
2
3
  import { NativeProps } from '../../utils/native-props';
3
4
  import { ImageProps } from '../image';
4
5
  export declare type AvatarProps = {
5
6
  src: string;
6
7
  fallback?: ReactNode;
7
8
  fit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
8
- } & Pick<ImageProps, 'alt' | 'lazy' | 'onClick' | 'onError' | 'onLoad'> & NativeProps<'--size' | '--border-radius'>;
9
+ onClick?: (event: React.MouseEvent<HTMLDivElement | HTMLImageElement, Event>) => void;
10
+ } & Pick<ImageProps, 'alt' | 'lazy' | 'onError' | 'onLoad'> & NativeProps<'--size' | '--border-radius'>;
9
11
  export declare const Avatar: FC<AvatarProps>;
@@ -7,8 +7,8 @@ exports.Avatar = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _nativeProps = require("../../utils/native-props");
9
9
  var _withDefaultProps = require("../../utils/with-default-props");
10
- var _fallback = require("./fallback");
11
10
  var _image = _interopRequireDefault(require("../image"));
11
+ var _fallback = require("./fallback");
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
  const classPrefix = 'adm-avatar';
14
14
  const defaultProps = {
@@ -16,10 +16,12 @@ const defaultProps = {
16
16
  fit: 'cover'
17
17
  };
18
18
  const Avatar = p => {
19
+ var _a;
19
20
  const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
21
+ const mergedSrc = ((_a = props.src) === null || _a === void 0 ? void 0 : _a.trim()) || undefined;
20
22
  return (0, _nativeProps.withNativeProps)(props, _react.default.createElement(_image.default, {
21
23
  className: classPrefix,
22
- src: props.src,
24
+ src: mergedSrc,
23
25
  fallback: props.fallback,
24
26
  placeholder: props.fallback,
25
27
  alt: props.alt,
@@ -96,12 +96,12 @@ const Calendar = (0, _react.forwardRef)((p, ref) => {
96
96
  };
97
97
  const header = _react.default.createElement("div", {
98
98
  className: `${classPrefix}-header`
99
- }, _react.default.createElement("a", {
99
+ }, props.prevYearButton !== null && _react.default.createElement("a", {
100
100
  className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-year`,
101
101
  onClick: () => {
102
102
  handlePageChange('subtract', 1, 'year');
103
103
  }
104
- }, props.prevYearButton), _react.default.createElement("a", {
104
+ }, props.prevYearButton), props.prevMonthButton !== null && _react.default.createElement("a", {
105
105
  className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-month`,
106
106
  onClick: () => {
107
107
  handlePageChange('subtract', 1, 'month');
@@ -111,12 +111,12 @@ const Calendar = (0, _react.forwardRef)((p, ref) => {
111
111
  }, (0, _replaceMessage.replaceMessage)(locale.Calendar.yearAndMonth, {
112
112
  year: current.year().toString(),
113
113
  month: (current.month() + 1).toString()
114
- })), _react.default.createElement("a", {
114
+ })), props.nextMonthButton !== null && _react.default.createElement("a", {
115
115
  className: (0, _classnames.default)(`${classPrefix}-arrow-button`, `${classPrefix}-arrow-button-right`, `${classPrefix}-arrow-button-right-month`),
116
116
  onClick: () => {
117
117
  handlePageChange('add', 1, 'month');
118
118
  }
119
- }, props.nextMonthButton), _react.default.createElement("a", {
119
+ }, props.nextMonthButton), props.nextYearButton !== null && _react.default.createElement("a", {
120
120
  className: (0, _classnames.default)(`${classPrefix}-arrow-button`, `${classPrefix}-arrow-button-right`, `${classPrefix}-arrow-button-right-year`),
121
121
  onClick: () => {
122
122
  handlePageChange('add', 1, 'year');
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = useMeasure;
7
7
  var _rcUtil = require("rc-util");
8
+ var _useLayoutEffect = _interopRequireDefault(require("rc-util/lib/hooks/useLayoutEffect"));
8
9
  var _react = _interopRequireDefault(require("react"));
9
10
  var _reactDom = require("react-dom");
10
11
  var _runes = _interopRequireDefault(require("runes2"));
@@ -34,11 +35,11 @@ function useMeasure(containerRef, content, rows, direction, expanded, expandNode
34
35
  });
35
36
  });
36
37
  // Initialize
37
- _react.default.useLayoutEffect(() => {
38
+ (0, _useLayoutEffect.default)(() => {
38
39
  startMeasure();
39
40
  }, [contentChars, rows]);
40
41
  // Measure element height
41
- _react.default.useLayoutEffect(() => {
42
+ (0, _useLayoutEffect.default)(() => {
42
43
  var _a, _b;
43
44
  if (status === 1 /* PREPARE */) {
44
45
  const fullMeasureHeight = ((_a = fullMeasureRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) || 0;
@@ -53,7 +54,7 @@ function useMeasure(containerRef, content, rows, direction, expanded, expandNode
53
54
  }
54
55
  }, [status]);
55
56
  // Walking measure
56
- _react.default.useLayoutEffect(() => {
57
+ (0, _useLayoutEffect.default)(() => {
57
58
  var _a;
58
59
  if (status === 2 /* MEASURE_WALKING */) {
59
60
  const diff = walkingIndexes[1] - walkingIndexes[0];
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
1
  import type { ReactNode } from 'react';
2
+ import React from 'react';
3
3
  import { NativeProps } from '../../utils/native-props';
4
4
  export declare type ImageProps = {
5
5
  src?: string;
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Image = void 0;
7
- var _withDefaultProps = require("../../utils/with-default-props");
8
7
  var _react = _interopRequireWildcard(require("react"));
9
- var _nativeProps = require("../../utils/native-props");
10
8
  var _stagedComponents = require("staged-components");
9
+ var _nativeProps = require("../../utils/native-props");
11
10
  var _toCssLength = require("../../utils/to-css-length");
12
- var _lazyDetector = require("./lazy-detector");
13
11
  var _useIsomorphicUpdateLayoutEffect = require("../../utils/use-isomorphic-update-layout-effect");
14
- var _imageIcon = require("./image-icon");
12
+ var _withDefaultProps = require("../../utils/with-default-props");
15
13
  var _brokenImageIcon = require("./broken-image-icon");
14
+ var _imageIcon = require("./image-icon");
15
+ var _lazyDetector = require("./lazy-detector");
16
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
17
  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; }
18
18
  const classPrefix = `adm-image`;
@@ -50,7 +50,7 @@ const Image = (0, _stagedComponents.staged)(p => {
50
50
  }
51
51
  }, []);
52
52
  function renderInner() {
53
- if (failed) {
53
+ if (failed || src === undefined && !srcSet) {
54
54
  return _react.default.createElement(_react.default.Fragment, null, props.fallback);
55
55
  }
56
56
  const img = _react.default.createElement("img", {
@@ -1,4 +1,4 @@
1
- import type { FC, ReactNode } from 'react';
1
+ import type { FC, ReactNode, RefObject } from 'react';
2
2
  import React from 'react';
3
3
  import { GetContainer } from '../../utils/render-to-container';
4
4
  import { SlidesRef } from './slides';
@@ -10,7 +10,8 @@ export declare type ImageViewerProps = {
10
10
  onClose?: () => void;
11
11
  afterClose?: () => void;
12
12
  renderFooter?: (image: string) => ReactNode;
13
- imageRender?: (image: string, { index }: {
13
+ imageRender?: (image: string, { ref, index }: {
14
+ ref: RefObject<HTMLImageElement>;
14
15
  index: number;
15
16
  }) => ReactNode;
16
17
  classNames?: {
@@ -25,7 +26,8 @@ export declare type MultiImageViewerProps = Omit<ImageViewerProps, 'image' | 're
25
26
  defaultIndex?: number;
26
27
  onIndexChange?: (index: number) => void;
27
28
  renderFooter?: (image: string, index: number) => ReactNode;
28
- imageRender?: (image: string, { index }: {
29
+ imageRender?: (image: string, { ref, index }: {
30
+ ref: RefObject<HTMLImageElement>;
29
31
  index: number;
30
32
  }) => ReactNode;
31
33
  };
@@ -34,7 +36,8 @@ export declare const MultiImageViewer: React.ForwardRefExoticComponent<Omit<Imag
34
36
  defaultIndex?: number | undefined;
35
37
  onIndexChange?: ((index: number) => void) | undefined;
36
38
  renderFooter?: ((image: string, index: number) => ReactNode) | undefined;
37
- imageRender?: ((image: string, { index }: {
39
+ imageRender?: ((image: string, { ref, index }: {
40
+ ref: RefObject<HTMLImageElement>;
38
41
  index: number;
39
42
  }) => ReactNode) | undefined;
40
43
  } & React.RefAttributes<SlidesRef>>;
@@ -8,7 +8,8 @@ declare const _default: import("react").FC<import("./image-viewer").ImageViewerP
8
8
  defaultIndex?: number | undefined;
9
9
  onIndexChange?: ((index: number) => void) | undefined;
10
10
  renderFooter?: ((image: string, index: number) => import("react").ReactNode) | undefined;
11
- imageRender?: ((image: string, { index }: {
11
+ imageRender?: ((image: string, { ref, index }: {
12
+ ref: import("react").RefObject<HTMLImageElement>;
12
13
  index: number;
13
14
  }) => import("react").ReactNode) | undefined;
14
15
  } & import("react").RefAttributes<import("./slides").SlidesRef>> & {
@@ -7,8 +7,8 @@ exports.clearImageViewer = clearImageViewer;
7
7
  exports.showImageViewer = showImageViewer;
8
8
  exports.showMultiImageViewer = showMultiImageViewer;
9
9
  var _react = _interopRequireDefault(require("react"));
10
- var _imageViewer = require("./image-viewer");
11
10
  var _renderImperatively = require("../../utils/render-imperatively");
11
+ var _imageViewer = require("./image-viewer");
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
  const handlerSet = new Set();
14
14
  function showImageViewer(props) {
@@ -1,11 +1,12 @@
1
- import type { FC, MutableRefObject, ReactNode } from 'react';
1
+ import type { FC, MutableRefObject, ReactNode, RefObject } from 'react';
2
2
  declare type Props = {
3
3
  image: string;
4
4
  maxZoom: number | 'auto';
5
5
  onTap?: () => void;
6
6
  onZoomChange?: (zoom: number) => void;
7
7
  dragLockRef?: MutableRefObject<boolean>;
8
- imageRender?: (image: string, { index }: {
8
+ imageRender?: (image: string, { ref, index }: {
9
+ ref: RefObject<HTMLImageElement>;
9
10
  index: number;
10
11
  }) => ReactNode;
11
12
  index?: number;
@@ -230,7 +230,8 @@ const Slide = props => {
230
230
  }
231
231
  });
232
232
  const customRendering = typeof imageRender === 'function' && imageRender(props.image, {
233
- index
233
+ ref: imgRef,
234
+ index: index !== null && index !== void 0 ? index : 0
234
235
  });
235
236
  return _react.default.createElement("div", {
236
237
  className: `${classPrefix}-slide`
@@ -1,11 +1,12 @@
1
- import React, { ReactNode } from 'react';
1
+ import React, { ReactNode, RefObject } from 'react';
2
2
  export declare type SlidesType = {
3
3
  images: string[];
4
4
  onTap?: () => void;
5
5
  maxZoom: number;
6
6
  defaultIndex: number;
7
7
  onIndexChange?: (index: number) => void;
8
- imageRender?: (image: string, { index }: {
8
+ imageRender?: (image: string, { ref, index }: {
9
+ ref: RefObject<HTMLImageElement>;
9
10
  index: number;
10
11
  }) => ReactNode;
11
12
  };
@@ -22,7 +22,7 @@ export declare type InputRef = {
22
22
  blur: () => void;
23
23
  nativeElement: HTMLInputElement | null;
24
24
  };
25
- export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProps, "pattern" | "id" | "onClick" | "disabled" | "onPaste" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "type" | "step" | "autoFocus" | "placeholder" | "autoCapitalize" | "autoCorrect" | "inputMode" | "name" | "readOnly" | "autoComplete" | "enterKeyHint" | "maxLength" | "minLength"> & {
25
+ export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProps, "pattern" | "id" | "onClick" | "disabled" | "onPaste" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "type" | "step" | "autoCapitalize" | "autoFocus" | "enterKeyHint" | "autoCorrect" | "inputMode" | "placeholder" | "name" | "readOnly" | "autoComplete" | "maxLength" | "minLength"> & {
26
26
  value?: string | undefined;
27
27
  defaultValue?: string | undefined;
28
28
  onChange?: ((val: string) => void) | undefined;
@@ -35,9 +35,7 @@ const Input = (0, _react.forwardRef)((props, ref) => {
35
35
  const nativeInputRef = (0, _react.useRef)(null);
36
36
  const handleKeydown = (0, _useInputHandleKeyDown.default)({
37
37
  onEnterPress: mergedProps.onEnterPress,
38
- onKeyDown: mergedProps.onKeyDown,
39
- nativeInputRef,
40
- enterKeyHint: mergedProps.enterKeyHint
38
+ onKeyDown: mergedProps.onKeyDown
41
39
  });
42
40
  (0, _react.useImperativeHandle)(ref, () => ({
43
41
  clear: () => {
@@ -1,8 +1,6 @@
1
1
  interface InputHandleKeyDownType<T> {
2
2
  onEnterPress?: (e: React.KeyboardEvent<T>) => void;
3
3
  onKeyDown?: (e: React.KeyboardEvent<T>) => void;
4
- enterKeyHint?: React.InputHTMLAttributes<HTMLInputElement>['enterKeyHint'];
5
- nativeInputRef: React.RefObject<T>;
6
4
  }
7
- export default function useInputHandleKeyDown<T extends HTMLInputElement | HTMLTextAreaElement>({ onEnterPress, onKeyDown, nativeInputRef, enterKeyHint, }: InputHandleKeyDownType<T>): (e: React.KeyboardEvent<T>) => void;
5
+ export default function useInputHandleKeyDown<T extends HTMLInputElement | HTMLTextAreaElement>({ onEnterPress, onKeyDown }: InputHandleKeyDownType<T>): (e: React.KeyboardEvent<T>) => void;
8
6
  export {};
@@ -4,12 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = useInputHandleKeyDown;
7
- var _ahooks = require("ahooks");
8
7
  function useInputHandleKeyDown({
9
8
  onEnterPress,
10
- onKeyDown,
11
- nativeInputRef,
12
- enterKeyHint
9
+ onKeyDown
13
10
  }) {
14
11
  const handleKeydown = e => {
15
12
  if (onEnterPress && (e.code === 'Enter' || e.keyCode === 13)) {
@@ -17,13 +14,5 @@ function useInputHandleKeyDown({
17
14
  }
18
15
  onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
19
16
  };
20
- (0, _ahooks.useIsomorphicLayoutEffect)(() => {
21
- const ele = nativeInputRef.current;
22
- if (!enterKeyHint || !ele) return;
23
- ele.setAttribute('enterkeyhint', enterKeyHint);
24
- return () => {
25
- ele.removeAttribute('enterkeyhint');
26
- };
27
- }, [enterKeyHint]);
28
17
  return handleKeydown;
29
18
  }
@@ -117,6 +117,7 @@ const NumberKeyboard = p => {
117
117
  };
118
118
  const renderKey = (key, index) => {
119
119
  const isNumberKey = /^\d$/.test(key);
120
+ const isBackspace = key === 'BACKSPACE';
120
121
  const className = (0, _classnames.default)(`${classPrefix}-key`, {
121
122
  [`${classPrefix}-key-number`]: isNumberKey,
122
123
  [`${classPrefix}-key-sign`]: !isNumberKey && key,
@@ -124,25 +125,29 @@ const NumberKeyboard = p => {
124
125
  });
125
126
  const ariaProps = key ? {
126
127
  role: 'button',
127
- title: key,
128
+ title: isBackspace ? locale.Input.clear : key,
128
129
  tabIndex: -1
129
130
  } : undefined;
130
131
  return _react.default.createElement("div", Object.assign({
131
132
  key: key,
132
133
  className: className,
133
- onTouchStart: () => {
134
+ // 仅为 backspace 绑定,支持长按快速删除
135
+ onTouchStart: isBackspace ? () => {
136
+ stopContinueClear();
137
+ startContinueClear();
138
+ } : undefined,
139
+ onTouchEnd: isBackspace ? e => {
140
+ stopContinueClear();
141
+ onKeyPress(e, key);
142
+ } : undefined,
143
+ // <div role="button" title="1" onTouchEnd={e => {}}>1</div> 安卓上 talback 可读不可点
144
+ // see https://ua-gilded-eef7f9.netlify.app/grid-button-bug.html
145
+ // 所以还是绑定 click,通过 touchEnd 的 preventDefault 防重复触发
146
+ onClick: e => {
134
147
  stopContinueClear();
135
- if (key === 'BACKSPACE') {
136
- startContinueClear();
137
- }
138
- },
139
- onTouchEnd: e => {
140
148
  onKeyPress(e, key);
141
- if (key === 'BACKSPACE') {
142
- stopContinueClear();
143
- }
144
149
  }
145
- }, ariaProps), key === 'BACKSPACE' ? _react.default.createElement(_antdMobileIcons.TextDeletionOutline, null) : key);
150
+ }, ariaProps), isBackspace ? _react.default.createElement(_antdMobileIcons.TextDeletionOutline, null) : key);
146
151
  };
147
152
  return _react.default.createElement(_popup.default, {
148
153
  visible: visible,
@@ -174,8 +179,12 @@ const NumberKeyboard = p => {
174
179
  startContinueClear();
175
180
  },
176
181
  onTouchEnd: e => {
182
+ stopContinueClear();
177
183
  onKeyPress(e, 'BACKSPACE');
184
+ },
185
+ onClick: e => {
178
186
  stopContinueClear();
187
+ onKeyPress(e, 'BACKSPACE');
179
188
  },
180
189
  onContextMenu: e => {
181
190
  // Long press should not trigger native context menu
@@ -186,7 +195,7 @@ const NumberKeyboard = p => {
186
195
  tabIndex: -1
187
196
  }, _react.default.createElement(_antdMobileIcons.TextDeletionOutline, null)), _react.default.createElement("div", {
188
197
  className: `${classPrefix}-key ${classPrefix}-key-extra ${classPrefix}-key-ok`,
189
- onTouchEnd: e => onKeyPress(e, 'OK'),
198
+ onClick: e => onKeyPress(e, 'OK'),
190
199
  role: 'button',
191
200
  tabIndex: -1,
192
201
  "aria-label": confirmText
@@ -2,7 +2,7 @@ import './picker.less';
2
2
  import { prompt } from './prompt';
3
3
  export type { PickerProps, PickerRef, PickerActions } from './picker';
4
4
  export type { PickerValue, PickerColumnItem, PickerColumn, PickerValueExtend, } from '../picker-view';
5
- declare const _default: import("react").NamedExoticComponent<{
5
+ declare const _default: import("react").NamedExoticComponent<Omit<{
6
6
  columns: import("../picker-view").PickerColumn[] | ((value: import("../picker-view").PickerValue[]) => import("../picker-view").PickerColumn[]);
7
7
  value?: import("../picker-view").PickerValue[] | undefined;
8
8
  defaultValue?: import("../picker-view").PickerValue[] | undefined;
@@ -26,7 +26,9 @@ declare const _default: import("react").NamedExoticComponent<{
26
26
  className?: string | undefined;
27
27
  style?: (import("react").CSSProperties & Partial<Record<"--header-button-font-size" | "--title-font-size" | "--item-font-size" | "--item-height", string>>) | undefined;
28
28
  tabIndex?: number | undefined;
29
- } & import("react").AriaAttributes & import("react").RefAttributes<import("./picker").PickerActions>> & {
29
+ } & import("react").AriaAttributes & import("react").RefAttributes<import("./picker").PickerActions>, "ref"> & {
30
+ ref?: ((instance: import("./picker").PickerActions | null) => void) | import("react").RefObject<import("./picker").PickerActions> | null | undefined;
31
+ }> & {
30
32
  readonly type: import("react").ForwardRefExoticComponent<{
31
33
  columns: import("../picker-view").PickerColumn[] | ((value: import("../picker-view").PickerValue[]) => import("../picker-view").PickerColumn[]);
32
34
  value?: import("../picker-view").PickerValue[] | undefined;
@@ -1,5 +1,5 @@
1
+ import type { CSSProperties, ReactElement, ReactNode } from 'react';
1
2
  import React from 'react';
2
- import type { ReactNode, ReactElement } from 'react';
3
3
  import { NativeProps } from '../../utils/native-props';
4
4
  import { PageIndicatorProps } from '../page-indicator';
5
5
  declare const eventToPropRecord: {
@@ -59,10 +59,10 @@ export declare const Swiper: React.ForwardRefExoticComponent<{
59
59
  /**
60
60
  * renderProps is only work when `total` used
61
61
  */
62
- children?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactElement<any, string | React.JSXElementConstructor<any>>[] | ((index: number) => ReactElement) | undefined;
62
+ children?: ReactElement<any, string | React.JSXElementConstructor<any>> | ReactElement<any, string | React.JSXElementConstructor<any>>[] | ((index: number) => ReactElement) | undefined;
63
63
  } & {
64
64
  className?: string | undefined;
65
- style?: (React.CSSProperties & Partial<Record<"--width" | "--height" | "--border-radius" | "--track-padding", string>>) | undefined;
65
+ style?: (CSSProperties & Partial<Record<"--width" | "--height" | "--border-radius" | "--track-padding", string>>) | undefined;
66
66
  tabIndex?: number | undefined;
67
67
  } & React.AriaAttributes & React.RefAttributes<SwiperRef>>;
68
68
  export {};
@@ -4,23 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Swiper = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _nativeProps = require("../../utils/native-props");
9
- var _withDefaultProps = require("../../utils/with-default-props");
10
- var _classnames = _interopRequireDefault(require("classnames"));
11
- var _swiperItem = require("./swiper-item");
12
- var _devLog = require("../../utils/dev-log");
13
7
  var _web = require("@react-spring/web");
14
- var _react2 = require("@use-gesture/react");
15
- var _pageIndicator = _interopRequireDefault(require("../page-indicator"));
8
+ var _react = require("@use-gesture/react");
9
+ var _ahooks = require("ahooks");
10
+ var _classnames = _interopRequireDefault(require("classnames"));
11
+ var _toArray = _interopRequireDefault(require("rc-util/lib/Children/toArray"));
12
+ var _react2 = _interopRequireWildcard(require("react"));
16
13
  var _stagedComponents = require("staged-components");
17
- var _useRefState = require("../../utils/use-ref-state");
18
14
  var _bound = require("../../utils/bound");
19
- var _ahooks = require("ahooks");
15
+ var _devLog = require("../../utils/dev-log");
16
+ var _nativeProps = require("../../utils/native-props");
17
+ var _useRefState = require("../../utils/use-ref-state");
18
+ var _withDefaultProps = require("../../utils/with-default-props");
20
19
  var _withFuncProps = require("../../utils/with-func-props");
21
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+ var _pageIndicator = _interopRequireDefault(require("../page-indicator"));
21
+ var _swiperItem = require("./swiper-item");
22
22
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
23
  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; }
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
25
  const classPrefix = `adm-swiper`;
25
26
  const eventToPropRecord = {
26
27
  'mousedown': 'onMouseDown',
@@ -41,7 +42,7 @@ const defaultProps = {
41
42
  stopPropagation: []
42
43
  };
43
44
  let currentUid;
44
- const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) => {
45
+ const Swiper = (0, _react2.forwardRef)((0, _stagedComponents.staged)((p, ref) => {
45
46
  const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
46
47
  const {
47
48
  direction,
@@ -49,8 +50,8 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
49
50
  children,
50
51
  indicator
51
52
  } = props;
52
- const [uid] = (0, _react.useState)({});
53
- const timeoutRef = (0, _react.useRef)(null);
53
+ const [uid] = (0, _react2.useState)({});
54
+ const timeoutRef = (0, _react2.useRef)(null);
54
55
  const isVertical = direction === 'vertical';
55
56
  const slideRatio = props.slideSize / 100;
56
57
  const offsetRatio = props.trackOffset / 100;
@@ -58,21 +59,22 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
58
59
  validChildren,
59
60
  count,
60
61
  renderChildren
61
- } = (0, _react.useMemo)(() => {
62
+ } = (0, _react2.useMemo)(() => {
62
63
  let count = 0;
63
64
  let renderChildren = undefined;
64
65
  let validChildren = undefined;
65
66
  if (typeof children === 'function') {
66
67
  renderChildren = children;
67
68
  } else {
68
- validChildren = _react.default.Children.map(children, child => {
69
- if (!_react.default.isValidElement(child)) return null;
69
+ const childrenArray = (0, _toArray.default)(children);
70
+ validChildren = childrenArray.filter(child => {
71
+ if (!_react2.default.isValidElement(child)) return null;
70
72
  if (child.type !== _swiperItem.SwiperItem) {
71
73
  (0, _devLog.devWarning)('Swiper', 'The children of `Swiper` must be `Swiper.Item` components.');
72
- return null;
74
+ return false;
73
75
  }
74
76
  count++;
75
- return child;
77
+ return true;
76
78
  });
77
79
  }
78
80
  return {
@@ -91,7 +93,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
91
93
  if (slideRatio * (mergedTotal - 1) < 1) {
92
94
  loop = false;
93
95
  }
94
- const trackRef = (0, _react.useRef)(null);
96
+ const trackRef = (0, _react2.useRef)(null);
95
97
  function getSlidePixels() {
96
98
  const track = trackRef.current;
97
99
  if (!track) return 0;
@@ -130,13 +132,13 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
130
132
  });
131
133
  }
132
134
  }), [mergedTotal]);
133
- const dragCancelRef = (0, _react.useRef)(null);
135
+ const dragCancelRef = (0, _react2.useRef)(null);
134
136
  function forceCancelDrag() {
135
137
  var _a;
136
138
  (_a = dragCancelRef.current) === null || _a === void 0 ? void 0 : _a.call(dragCancelRef);
137
139
  draggingRef.current = false;
138
140
  }
139
- const bind = (0, _react2.useDrag)(state => {
141
+ const bind = (0, _react.useDrag)(state => {
140
142
  dragCancelRef.current = state.cancel;
141
143
  if (!state.intentional) return;
142
144
  if (state.first && !currentUid) {
@@ -211,7 +213,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
211
213
  function swipePrev() {
212
214
  swipeTo(Math.round(position.get() / 100) - 1);
213
215
  }
214
- (0, _react.useImperativeHandle)(ref, () => ({
216
+ (0, _react2.useImperativeHandle)(ref, () => ({
215
217
  swipeTo,
216
218
  swipeNext,
217
219
  swipePrev
@@ -236,7 +238,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
236
238
  runTimeSwiper();
237
239
  }, autoplayInterval);
238
240
  };
239
- (0, _react.useEffect)(() => {
241
+ (0, _react2.useEffect)(() => {
240
242
  if (!autoplay || dragging) return;
241
243
  runTimeSwiper();
242
244
  return () => {
@@ -245,7 +247,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
245
247
  }, [autoplay, autoplayInterval, dragging, mergedTotal]);
246
248
  // ============================== Render ==============================
247
249
  // Render Item
248
- function renderItem(index, child) {
250
+ function renderItem(index, child, key) {
249
251
  let itemStyle = {};
250
252
  if (loop) {
251
253
  itemStyle = {
@@ -259,15 +261,15 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
259
261
  [isVertical ? 'top' : 'left']: `-${index * 100}%`
260
262
  };
261
263
  }
262
- return _react.default.createElement(_web.animated.div, {
264
+ return _react2.default.createElement(_web.animated.div, {
263
265
  className: (0, _classnames.default)(`${classPrefix}-slide`, {
264
266
  [`${classPrefix}-slide-active`]: current === index
265
267
  }),
266
268
  style: itemStyle,
267
- key: index
269
+ key: key !== null && key !== void 0 ? key : index
268
270
  }, child);
269
271
  }
270
- function renderItems() {
272
+ const renderStableItems = () => {
271
273
  if (renderChildren && total) {
272
274
  const offsetCount = 2;
273
275
  const startIndex = Math.max(current - offsetCount, 0);
@@ -276,25 +278,32 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
276
278
  for (let index = startIndex; index <= endIndex; index += 1) {
277
279
  items.push(renderItem(index, renderChildren(index)));
278
280
  }
279
- return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement("div", {
281
+ return _react2.default.createElement(_react2.default.Fragment, null, _react2.default.createElement("div", {
280
282
  className: `${classPrefix}-slide-placeholder`,
281
283
  style: {
282
284
  [isVertical ? 'height' : 'width']: `${startIndex * 100}%`
283
285
  }
284
286
  }), items);
285
287
  }
286
- return _react.default.Children.map(validChildren, (child, index) => {
287
- return renderItem(index, child);
288
- });
288
+ if (validChildren) {
289
+ return validChildren.map((child, index) => {
290
+ var _a;
291
+ return renderItem(index, child, (_a = child === null || child === void 0 ? void 0 : child.key) !== null && _a !== void 0 ? _a : index);
292
+ });
293
+ }
294
+ return null;
295
+ };
296
+ function renderItems() {
297
+ return renderStableItems();
289
298
  }
290
299
  // Render Track Inner
291
300
  function renderTrackInner() {
292
301
  if (loop) {
293
- return _react.default.createElement("div", {
302
+ return _react2.default.createElement("div", {
294
303
  className: `${classPrefix}-track-inner`
295
304
  }, renderItems());
296
305
  } else {
297
- return _react.default.createElement(_web.animated.div, {
306
+ return _react2.default.createElement(_web.animated.div, {
298
307
  className: `${classPrefix}-track-inner`,
299
308
  style: {
300
309
  [isVertical ? 'y' : 'x']: position.to(position => `${-position}%`)
@@ -320,18 +329,18 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
320
329
  if (typeof indicator === 'function') {
321
330
  indicatorNode = indicator(mergedTotal, current);
322
331
  } else if (indicator !== false) {
323
- indicatorNode = _react.default.createElement("div", {
332
+ indicatorNode = _react2.default.createElement("div", {
324
333
  className: `${classPrefix}-indicator`
325
- }, _react.default.createElement(_pageIndicator.default, Object.assign({}, props.indicatorProps, {
334
+ }, _react2.default.createElement(_pageIndicator.default, Object.assign({}, props.indicatorProps, {
326
335
  total: mergedTotal,
327
336
  current: current,
328
337
  direction: direction
329
338
  })));
330
339
  }
331
- return (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
340
+ return (0, _nativeProps.withNativeProps)(props, _react2.default.createElement("div", {
332
341
  className: (0, _classnames.default)(classPrefix, `${classPrefix}-${direction}`),
333
342
  style: style
334
- }, _react.default.createElement("div", Object.assign({
343
+ }, _react2.default.createElement("div", Object.assign({
335
344
  ref: trackRef,
336
345
  className: (0, _classnames.default)(`${classPrefix}-track`, {
337
346
  [`${classPrefix}-track-allow-touch-move`]: props.allowTouchMove
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
1
  import type { ReactNode } from 'react';
2
+ import React from 'react';
3
3
  import { NativeProps } from '../../utils/native-props';
4
4
  export declare type TextAreaProps = Pick<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, 'autoComplete' | 'autoFocus' | 'disabled' | 'readOnly' | 'name' | 'onFocus' | 'onBlur' | 'onCompositionStart' | 'onCompositionEnd' | 'onClick' | 'onKeyDown'> & {
5
5
  onChange?: (val: string) => void;