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
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.Avatar = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _nativeProps = require("../../utils/native-props");
9
- var _image = _interopRequireDefault(require("../image"));
10
9
  var _withDefaultProps = require("../../utils/with-default-props");
11
10
  var _fallback = require("./fallback");
11
+ var _image = _interopRequireDefault(require("../image"));
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
  const classPrefix = 'adm-avatar';
14
14
  const defaultProps = {
@@ -14,7 +14,7 @@ export declare type ButtonProps = {
14
14
  type?: 'submit' | 'reset' | 'button';
15
15
  shape?: 'default' | 'rounded' | 'rectangular';
16
16
  children?: React.ReactNode;
17
- } & Pick<NativeButtonProps, 'onMouseDown' | 'onMouseUp' | 'onTouchStart' | 'onTouchEnd'> & NativeProps<'--text-color' | '--background-color' | '--border-radius' | '--border-width' | '--border-style' | '--border-color'>;
17
+ } & Pick<NativeButtonProps, 'onMouseDown' | 'onMouseUp' | 'onTouchStart' | 'onTouchEnd' | 'id'> & NativeProps<'--text-color' | '--background-color' | '--border-radius' | '--border-width' | '--border-style' | '--border-color'>;
18
18
  export declare type ButtonRef = {
19
19
  nativeElement: HTMLButtonElement | null;
20
20
  };
@@ -31,7 +31,7 @@ export declare const Button: React.ForwardRefExoticComponent<{
31
31
  type?: "reset" | "submit" | "button" | undefined;
32
32
  shape?: "default" | "rounded" | "rectangular" | undefined;
33
33
  children?: React.ReactNode;
34
- } & Pick<NativeButtonProps, "onMouseDown" | "onMouseUp" | "onTouchEnd" | "onTouchStart"> & {
34
+ } & Pick<NativeButtonProps, "id" | "onMouseDown" | "onMouseUp" | "onTouchEnd" | "onTouchStart"> & {
35
35
  className?: string | undefined;
36
36
  style?: (React.CSSProperties & Partial<Record<"--border-radius" | "--text-color" | "--background-color" | "--border-width" | "--border-style" | "--border-color", string>>) | undefined;
37
37
  tabIndex?: number | undefined;
@@ -65,12 +65,7 @@ const Cascader = (0, _react.forwardRef)((p, ref) => {
65
65
  if (!visible) {
66
66
  setInnerValue(value);
67
67
  }
68
- }, [visible]);
69
- (0, _react.useEffect)(() => {
70
- if (!visible) {
71
- setInnerValue(value);
72
- }
73
- }, [value]);
68
+ }, [visible, value]);
74
69
  const cascaderElement = (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
75
70
  className: classPrefix
76
71
  }, _react.default.createElement("div", {
@@ -19,5 +19,6 @@ export declare type CascaderViewProps = {
19
19
  placeholder?: string | ((index: number) => string);
20
20
  onTabsChange?: (index: number) => void;
21
21
  activeIcon?: ReactNode;
22
+ loading?: boolean;
22
23
  } & NativeProps<'--height'>;
23
24
  export declare const CascaderView: FC<CascaderViewProps>;
@@ -81,6 +81,7 @@ const CascaderView = p => {
81
81
  }
82
82
  setValue(next);
83
83
  };
84
+ const whetherLoading = options => props.loading || options === _optionSkeleton.optionSkeleton;
84
85
  return (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
85
86
  className: classPrefix
86
87
  }, _react.default.createElement(_tabs.default, {
@@ -101,7 +102,7 @@ const CascaderView = p => {
101
102
  forceRender: true
102
103
  }, _react.default.createElement("div", {
103
104
  className: `${classPrefix}-content`
104
- }, level.options === _optionSkeleton.optionSkeleton ? _react.default.createElement("div", {
105
+ }, whetherLoading(level.options) ? _react.default.createElement("div", {
105
106
  className: `${classPrefix}-skeleton`
106
107
  }, _react.default.createElement(_skeleton.default, {
107
108
  className: `${classPrefix}-skeleton-line-1`,
@@ -18,7 +18,7 @@ export declare type DatePickerProps = Pick<PickerProps, 'onCancel' | 'onClose' |
18
18
  filter?: DatePickerFilter;
19
19
  tillNow?: boolean;
20
20
  } & NativeProps;
21
- export declare const DatePicker: React.ForwardRefExoticComponent<Pick<PickerProps, "style" | "title" | "onClick" | "visible" | "destroyOnClose" | "forceRender" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation" | "onCancel" | "onClose" | "loading" | "closeOnMaskClick" | "cancelText" | "mouseWheel" | "loadingContent" | "confirmText"> & {
21
+ export declare const DatePicker: React.ForwardRefExoticComponent<Pick<PickerProps, "style" | "title" | "onClick" | "visible" | "destroyOnClose" | "forceRender" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation" | "closeOnMaskClick" | "onClose" | "cancelText" | "loading" | "mouseWheel" | "loadingContent" | "onCancel" | "confirmText"> & {
22
22
  value?: PickerDate | null | undefined;
23
23
  defaultValue?: PickerDate | null | undefined;
24
24
  onSelect?: ((value: PickerDate) => void) | undefined;
@@ -2,7 +2,7 @@ import './date-picker.less';
2
2
  import { prompt } from './prompt';
3
3
  export type { DatePickerProps, DatePickerRef } from './date-picker';
4
4
  export type { DatePickerFilter } from './date-picker-utils';
5
- declare const _default: import("react").ForwardRefExoticComponent<Pick<import("../picker").PickerProps, "style" | "title" | "onClick" | "visible" | "destroyOnClose" | "forceRender" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation" | "onCancel" | "onClose" | "loading" | "closeOnMaskClick" | "cancelText" | "mouseWheel" | "loadingContent" | "confirmText"> & {
5
+ declare const _default: import("react").ForwardRefExoticComponent<Pick<import("../picker").PickerProps, "style" | "title" | "onClick" | "visible" | "destroyOnClose" | "forceRender" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation" | "closeOnMaskClick" | "onClose" | "cancelText" | "loading" | "mouseWheel" | "loadingContent" | "onCancel" | "confirmText"> & {
6
6
  value?: import("./util").PickerDate | null | undefined;
7
7
  defaultValue?: import("./util").PickerDate | null | undefined;
8
8
  onSelect?: ((value: import("./util").PickerDate) => void) | undefined;
@@ -5,8 +5,8 @@ export declare type EllipsisProps = {
5
5
  content: string;
6
6
  direction?: 'start' | 'end' | 'middle';
7
7
  rows?: number;
8
- expandText?: string;
9
- collapseText?: string;
8
+ expandText?: React.ReactNode;
9
+ collapseText?: React.ReactNode;
10
10
  stopPropagationForActionButtons?: PropagationEvent[];
11
11
  onContentClick?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
12
12
  defaultExpanded?: boolean;
@@ -28,6 +28,8 @@ const defaultProps = {
28
28
  const Ellipsis = p => {
29
29
  const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
30
30
  const rootRef = (0, _react.useRef)(null);
31
+ const expandElRef = (0, _react.useRef)(null);
32
+ const collapseElRef = (0, _react.useRef)(null);
31
33
  const [ellipsised, setEllipsised] = (0, _react.useState)({});
32
34
  const [expanded, setExpanded] = (0, _react.useState)(props.defaultExpanded);
33
35
  const [exceeded, setExceeded] = (0, _react.useState)(false);
@@ -36,19 +38,18 @@ const Ellipsis = p => {
36
38
  return chars.slice(start, end).join('');
37
39
  }
38
40
  function calcEllipsised() {
41
+ var _a, _b;
39
42
  const root = rootRef.current;
40
43
  if (!root) return;
41
- if (!root.offsetParent) return;
44
+ const originDisplay = root.style.display;
45
+ root.style.display = 'block';
42
46
  const originStyle = window.getComputedStyle(root);
43
47
  const container = document.createElement('div');
44
48
  const styleNames = Array.prototype.slice.apply(originStyle);
45
49
  styleNames.forEach(name => {
46
50
  container.style.setProperty(name, originStyle.getPropertyValue(name));
47
51
  });
48
- container.style.position = 'fixed';
49
- container.style.left = '999999px';
50
- container.style.top = '999999px';
51
- container.style.zIndex = '-1000';
52
+ root.style.display = originDisplay;
52
53
  container.style.height = 'auto';
53
54
  container.style.minHeight = 'auto';
54
55
  container.style.maxHeight = 'auto';
@@ -65,7 +66,9 @@ const Ellipsis = p => {
65
66
  } else {
66
67
  setExceeded(true);
67
68
  const end = props.content.length;
68
- const actionText = expanded ? props.collapseText : props.expandText;
69
+ const collapseEl = typeof props.collapseText === 'string' ? props.collapseText : (_a = collapseElRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML;
70
+ const expandEl = typeof props.expandText === 'string' ? props.expandText : (_b = expandElRef.current) === null || _b === void 0 ? void 0 : _b.innerHTML;
71
+ const actionText = expanded ? collapseEl : expandEl;
69
72
  function check(left, right) {
70
73
  if (right - left <= 1) {
71
74
  if (props.direction === 'end') {
@@ -80,9 +83,9 @@ const Ellipsis = p => {
80
83
  }
81
84
  const middle = Math.round((left + right) / 2);
82
85
  if (props.direction === 'end') {
83
- container.innerText = getSubString(0, middle) + '...' + actionText;
86
+ container.innerHTML = getSubString(0, middle) + '...' + actionText;
84
87
  } else {
85
- container.innerText = actionText + '...' + getSubString(middle, end);
88
+ container.innerHTML = actionText + '...' + getSubString(middle, end);
86
89
  }
87
90
  if (container.offsetHeight <= maxHeight) {
88
91
  if (props.direction === 'end') {
@@ -107,7 +110,7 @@ const Ellipsis = p => {
107
110
  }
108
111
  const leftPartMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
109
112
  const rightPartMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
110
- container.innerText = getSubString(0, leftPartMiddle) + '...' + actionText + '...' + getSubString(rightPartMiddle, end);
113
+ container.innerHTML = getSubString(0, leftPartMiddle) + '...' + actionText + '...' + getSubString(rightPartMiddle, end);
111
114
  if (container.offsetHeight <= maxHeight) {
112
115
  return checkMiddle([leftPartMiddle, leftPart[1]], [rightPart[0], rightPartMiddle]);
113
116
  } else {
@@ -125,24 +128,21 @@ const Ellipsis = p => {
125
128
  calcEllipsised();
126
129
  }, [props.content, props.direction, props.rows, props.expandText, props.collapseText]);
127
130
  const expandActionElement = exceeded && props.expandText ? (0, _withStopPropagation.withStopPropagation)(props.stopPropagationForActionButtons, _react.default.createElement("a", {
131
+ ref: expandElRef,
128
132
  onClick: () => {
129
133
  setExpanded(true);
130
134
  }
131
135
  }, props.expandText)) : null;
132
136
  const collapseActionElement = exceeded && props.collapseText ? (0, _withStopPropagation.withStopPropagation)(props.stopPropagationForActionButtons, _react.default.createElement("a", {
137
+ ref: collapseElRef,
133
138
  onClick: () => {
134
139
  setExpanded(false);
135
140
  }
136
141
  }, props.collapseText)) : null;
137
142
  const renderContent = () => {
138
- if (!exceeded) {
139
- return props.content;
140
- }
141
- if (expanded) {
142
- return _react.default.createElement(_react.default.Fragment, null, props.content, collapseActionElement);
143
- } else {
144
- return _react.default.createElement(_react.default.Fragment, null, ellipsised.leading, expandActionElement, ellipsised.tailing);
145
- }
143
+ if (!exceeded) return props.content;
144
+ if (expanded) return _react.default.createElement(_react.default.Fragment, null, props.content, collapseActionElement);
145
+ return _react.default.createElement(_react.default.Fragment, null, ellipsised.leading, expandActionElement, ellipsised.tailing);
146
146
  };
147
147
  return (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
148
148
  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>;
@@ -55,6 +55,7 @@ const Image = (0, _stagedComponents.staged)(p => {
55
55
  }
56
56
  const img = _react.default.createElement("img", {
57
57
  ref: imgRef,
58
+ id: props.id,
58
59
  className: `${classPrefix}-img`,
59
60
  src: src,
60
61
  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 */
@@ -73,7 +73,8 @@ const NoticeBar = (0, _react.memo)(p => {
73
73
  return (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
74
74
  className: (0, _classnames.default)(classPrefix, `${classPrefix}-${props.color}`, {
75
75
  [`${classPrefix}-wrap`]: props.wrap
76
- })
76
+ }),
77
+ onClick: props.onClick
77
78
  }, props.icon && _react.default.createElement("span", {
78
79
  className: `${classPrefix}-left`
79
80
  }, props.icon), _react.default.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>;
@@ -25,6 +25,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
25
25
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
26
  const classPrefix = `adm-popup`;
27
27
  const defaultProps = Object.assign(Object.assign({}, _popupBaseProps.defaultPopupBaseProps), {
28
+ closeOnSwipe: false,
28
29
  position: 'bottom'
29
30
  });
30
31
  const Popup = p => {
@@ -67,6 +68,7 @@ const Popup = p => {
67
68
  swipe: [, swipeY]
68
69
  }) => {
69
70
  var _a;
71
+ if (!props.closeOnSwipe) return;
70
72
  if (swipeY === 1 && props.position === 'bottom' || swipeY === -1 && props.position === 'top') {
71
73
  (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
72
74
  }
@@ -49,6 +49,7 @@ const PullToRefresh = p => {
49
49
  config: {
50
50
  tension: 300,
51
51
  friction: 30,
52
+ round: true,
52
53
  clamp: true
53
54
  }
54
55
  }));
@@ -108,7 +109,8 @@ const PullToRefresh = p => {
108
109
  return;
109
110
  }
110
111
  const [, y] = state.movement;
111
- if (state.first && y > 0) {
112
+ const parsedY = Math.ceil(y);
113
+ if (state.first && parsedY > 0) {
112
114
  const target = state.event.target;
113
115
  if (!target || !(target instanceof Element)) return;
114
116
  let scrollParent = (0, _getScrollParent.getScrollParent)(target);
@@ -133,7 +135,7 @@ const PullToRefresh = p => {
133
135
  event.preventDefault();
134
136
  }
135
137
  event.stopPropagation();
136
- const height = Math.max((0, _rubberband.rubberbandIfOutOfBounds)(y, 0, 0, headHeight * 5, 0.5), 0);
138
+ const height = Math.max((0, _rubberband.rubberbandIfOutOfBounds)(parsedY, 0, 0, headHeight * 5, 0.5), 0);
137
139
  api.start({
138
140
  height
139
141
  });
@@ -87,13 +87,14 @@ const Slider = p => {
87
87
  const pointList = (0, _react.useMemo)(() => {
88
88
  if (marks) {
89
89
  return Object.keys(marks).map(parseFloat).sort((a, b) => a - b);
90
- } else {
90
+ } else if (ticks) {
91
91
  const points = [];
92
92
  for (let i = (0, _miniDecimal.default)(min); i.lessEquals((0, _miniDecimal.default)(max)); i = i.add(step)) {
93
93
  points.push(i.toNumber());
94
94
  }
95
95
  return points;
96
96
  }
97
+ return [];
97
98
  }, [marks, ticks, step, min, max]);
98
99
  function getValueByPosition(position) {
99
100
  const newPosition = position < min ? min : position > max ? max : position;
@@ -102,9 +103,10 @@ const Slider = p => {
102
103
  if (pointList.length) {
103
104
  value = (0, _nearest.nearest)(pointList, newPosition);
104
105
  } else {
105
- const lengthPerStep = 100 / ((max - min) / step);
106
- const steps = Math.round(newPosition / lengthPerStep);
107
- value = steps * lengthPerStep * (max - min) * 0.01 + min;
106
+ // 使用 MiniDecimal 避免精度问题
107
+ const cell = Math.round((newPosition - min) / step);
108
+ const nextVal = (0, _miniDecimal.default)(cell).multi(step);
109
+ value = (0, _miniDecimal.default)(min).add(nextVal.toString()).toNumber();
108
110
  }
109
111
  return value;
110
112
  }
@@ -44,6 +44,7 @@ let currentUid;
44
44
  const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) => {
45
45
  const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
46
46
  const [uid] = (0, _react.useState)({});
47
+ const timeoutRef = (0, _react.useRef)(null);
47
48
  const isVertical = props.direction === 'vertical';
48
49
  const slideRatio = props.slideSize / 100;
49
50
  const offsetRatio = props.trackOffset / 100;
@@ -82,7 +83,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
82
83
  const trackPixels = isVertical ? track.offsetHeight : track.offsetWidth;
83
84
  return trackPixels * props.slideSize / 100;
84
85
  }
85
- const [current, setCurrent] = (0, _react.useState)(props.defaultIndex);
86
+ const [current, setCurrent, getCurrent] = (0, _ahooks.useGetState)(props.defaultIndex);
86
87
  const [dragging, setDragging, draggingRef] = (0, _useRefState.useRefState)(false);
87
88
  function boundIndex(current) {
88
89
  let min = 0;
@@ -181,7 +182,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
181
182
  const roundedIndex = Math.round(index);
182
183
  const targetIndex = loop ? modulus(roundedIndex, count) : (0, _bound.bound)(roundedIndex, 0, count - 1);
183
184
  setCurrent(targetIndex);
184
- if (targetIndex !== current) {
185
+ if (targetIndex !== getCurrent()) {
185
186
  (_a = props.onIndexChange) === null || _a === void 0 ? void 0 : _a.call(props, targetIndex);
186
187
  }
187
188
  api.start({
@@ -210,16 +211,17 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
210
211
  autoplay,
211
212
  autoplayInterval
212
213
  } = props;
214
+ const runTimeSwiper = () => {
215
+ timeoutRef.current = window.setTimeout(() => {
216
+ swipeNext();
217
+ runTimeSwiper();
218
+ }, autoplayInterval);
219
+ };
213
220
  (0, _react.useEffect)(() => {
214
221
  if (!autoplay || dragging) return;
215
- let interval;
216
- function tick() {
217
- interval = window.setTimeout(tick, autoplayInterval);
218
- swipeNext();
219
- }
220
- interval = window.setTimeout(tick, autoplayInterval);
222
+ runTimeSwiper();
221
223
  return () => {
222
- if (interval) window.clearTimeout(interval);
224
+ if (timeoutRef.current) window.clearTimeout(timeoutRef.current);
223
225
  };
224
226
  }, [autoplay, autoplayInterval, dragging, count]);
225
227
  function renderTrackInner() {
@@ -249,9 +251,11 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
249
251
  style: {
250
252
  [isVertical ? 'y' : 'x']: position.to(position => `${-position}%`)
251
253
  }
252
- }, _react.default.Children.map(validChildren, child => {
254
+ }, _react.default.Children.map(validChildren, (child, index) => {
253
255
  return _react.default.createElement("div", {
254
- className: `${classPrefix}-slide`
256
+ className: (0, _classnames.default)(`${classPrefix}-slide`, {
257
+ [`${classPrefix}-slide-active`]: current === index
258
+ })
255
259
  }, child);
256
260
  }));
257
261
  }
@@ -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;
@@ -40,5 +40,5 @@ function subscribe(onStoreChange) {
40
40
  };
41
41
  }
42
42
  function useMotionReduced() {
43
- return (0, _shim.useSyncExternalStore)(subscribe, isMotionReduced);
43
+ return (0, _shim.useSyncExternalStore)(subscribe, isMotionReduced, isMotionReduced);
44
44
  }
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import { withNativeProps } from '../../utils/native-props';
3
- import Image from '../image';
4
3
  import { mergeProps } from '../../utils/with-default-props';
5
4
  import { Fallback } from './fallback';
5
+ import Image from '../image';
6
6
  const classPrefix = 'adm-avatar';
7
7
  const defaultProps = {
8
8
  fallback: React.createElement(Fallback, null),
@@ -14,7 +14,7 @@ export declare type ButtonProps = {
14
14
  type?: 'submit' | 'reset' | 'button';
15
15
  shape?: 'default' | 'rounded' | 'rectangular';
16
16
  children?: React.ReactNode;
17
- } & Pick<NativeButtonProps, 'onMouseDown' | 'onMouseUp' | 'onTouchStart' | 'onTouchEnd'> & NativeProps<'--text-color' | '--background-color' | '--border-radius' | '--border-width' | '--border-style' | '--border-color'>;
17
+ } & Pick<NativeButtonProps, 'onMouseDown' | 'onMouseUp' | 'onTouchStart' | 'onTouchEnd' | 'id'> & NativeProps<'--text-color' | '--background-color' | '--border-radius' | '--border-width' | '--border-style' | '--border-color'>;
18
18
  export declare type ButtonRef = {
19
19
  nativeElement: HTMLButtonElement | null;
20
20
  };
@@ -31,7 +31,7 @@ export declare const Button: React.ForwardRefExoticComponent<{
31
31
  type?: "reset" | "submit" | "button" | undefined;
32
32
  shape?: "default" | "rounded" | "rectangular" | undefined;
33
33
  children?: React.ReactNode;
34
- } & Pick<NativeButtonProps, "onMouseDown" | "onMouseUp" | "onTouchEnd" | "onTouchStart"> & {
34
+ } & Pick<NativeButtonProps, "id" | "onMouseDown" | "onMouseUp" | "onTouchEnd" | "onTouchStart"> & {
35
35
  className?: string | undefined;
36
36
  style?: (React.CSSProperties & Partial<Record<"--border-radius" | "--text-color" | "--background-color" | "--border-width" | "--border-style" | "--border-color", string>>) | undefined;
37
37
  tabIndex?: number | undefined;
@@ -56,12 +56,7 @@ export const Cascader = forwardRef((p, ref) => {
56
56
  if (!visible) {
57
57
  setInnerValue(value);
58
58
  }
59
- }, [visible]);
60
- useEffect(() => {
61
- if (!visible) {
62
- setInnerValue(value);
63
- }
64
- }, [value]);
59
+ }, [visible, value]);
65
60
  const cascaderElement = withNativeProps(props, React.createElement("div", {
66
61
  className: classPrefix
67
62
  }, React.createElement("div", {
@@ -19,5 +19,6 @@ export declare type CascaderViewProps = {
19
19
  placeholder?: string | ((index: number) => string);
20
20
  onTabsChange?: (index: number) => void;
21
21
  activeIcon?: ReactNode;
22
+ loading?: boolean;
22
23
  } & NativeProps<'--height'>;
23
24
  export declare const CascaderView: FC<CascaderViewProps>;
@@ -72,6 +72,7 @@ export const CascaderView = p => {
72
72
  }
73
73
  setValue(next);
74
74
  };
75
+ const whetherLoading = options => props.loading || options === optionSkeleton;
75
76
  return withNativeProps(props, React.createElement("div", {
76
77
  className: classPrefix
77
78
  }, React.createElement(Tabs, {
@@ -92,7 +93,7 @@ export const CascaderView = p => {
92
93
  forceRender: true
93
94
  }, React.createElement("div", {
94
95
  className: `${classPrefix}-content`
95
- }, level.options === optionSkeleton ? React.createElement("div", {
96
+ }, whetherLoading(level.options) ? React.createElement("div", {
96
97
  className: `${classPrefix}-skeleton`
97
98
  }, React.createElement(Skeleton, {
98
99
  className: `${classPrefix}-skeleton-line-1`,
@@ -18,7 +18,7 @@ export declare type DatePickerProps = Pick<PickerProps, 'onCancel' | 'onClose' |
18
18
  filter?: DatePickerFilter;
19
19
  tillNow?: boolean;
20
20
  } & NativeProps;
21
- export declare const DatePicker: React.ForwardRefExoticComponent<Pick<PickerProps, "style" | "title" | "onClick" | "visible" | "destroyOnClose" | "forceRender" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation" | "onCancel" | "onClose" | "loading" | "closeOnMaskClick" | "cancelText" | "mouseWheel" | "loadingContent" | "confirmText"> & {
21
+ export declare const DatePicker: React.ForwardRefExoticComponent<Pick<PickerProps, "style" | "title" | "onClick" | "visible" | "destroyOnClose" | "forceRender" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation" | "closeOnMaskClick" | "onClose" | "cancelText" | "loading" | "mouseWheel" | "loadingContent" | "onCancel" | "confirmText"> & {
22
22
  value?: PickerDate | null | undefined;
23
23
  defaultValue?: PickerDate | null | undefined;
24
24
  onSelect?: ((value: PickerDate) => void) | undefined;
@@ -2,7 +2,7 @@ import './date-picker.less';
2
2
  import { prompt } from './prompt';
3
3
  export type { DatePickerProps, DatePickerRef } from './date-picker';
4
4
  export type { DatePickerFilter } from './date-picker-utils';
5
- declare const _default: import("react").ForwardRefExoticComponent<Pick<import("../picker").PickerProps, "style" | "title" | "onClick" | "visible" | "destroyOnClose" | "forceRender" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation" | "onCancel" | "onClose" | "loading" | "closeOnMaskClick" | "cancelText" | "mouseWheel" | "loadingContent" | "confirmText"> & {
5
+ declare const _default: import("react").ForwardRefExoticComponent<Pick<import("../picker").PickerProps, "style" | "title" | "onClick" | "visible" | "destroyOnClose" | "forceRender" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation" | "closeOnMaskClick" | "onClose" | "cancelText" | "loading" | "mouseWheel" | "loadingContent" | "onCancel" | "confirmText"> & {
6
6
  value?: import("./util").PickerDate | null | undefined;
7
7
  defaultValue?: import("./util").PickerDate | null | undefined;
8
8
  onSelect?: ((value: import("./util").PickerDate) => void) | undefined;
@@ -5,8 +5,8 @@ export declare type EllipsisProps = {
5
5
  content: string;
6
6
  direction?: 'start' | 'end' | 'middle';
7
7
  rows?: number;
8
- expandText?: string;
9
- collapseText?: string;
8
+ expandText?: React.ReactNode;
9
+ collapseText?: React.ReactNode;
10
10
  stopPropagationForActionButtons?: PropagationEvent[];
11
11
  onContentClick?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
12
12
  defaultExpanded?: boolean;