antd-mobile 5.11.1 → 5.11.2

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 (69) hide show
  1. package/2x/cjs/components/image-uploader/image-uploader.js +9 -2
  2. package/2x/cjs/components/list/list-item.js +7 -5
  3. package/2x/cjs/components/text-area/text-area.js +1 -1
  4. package/2x/cjs/components/virtual-input/virtual-input.js +2 -1
  5. package/2x/cjs/locales/base.d.ts +1 -0
  6. package/2x/cjs/locales/base.js +2 -1
  7. package/2x/cjs/locales/en-US.d.ts +1 -0
  8. package/2x/cjs/locales/es-ES.d.ts +1 -0
  9. package/2x/cjs/locales/fa-IR.d.ts +1 -0
  10. package/2x/cjs/locales/ko-KR.d.ts +1 -0
  11. package/2x/cjs/locales/zh-CN.d.ts +1 -0
  12. package/2x/cjs/locales/zh-CN.js +2 -1
  13. package/2x/cjs/locales/zh-HK.d.ts +1 -0
  14. package/2x/cjs/locales/zh-TW.d.ts +1 -0
  15. package/2x/cjs/utils/is-node-with-content.d.ts +4 -0
  16. package/2x/cjs/utils/is-node-with-content.js +10 -0
  17. package/2x/es/components/image-uploader/image-uploader.js +8 -2
  18. package/2x/es/components/list/list-item.js +6 -5
  19. package/2x/es/components/text-area/text-area.js +2 -2
  20. package/2x/es/components/virtual-input/virtual-input.js +2 -1
  21. package/2x/es/locales/base.d.ts +1 -0
  22. package/2x/es/locales/base.js +2 -1
  23. package/2x/es/locales/en-US.d.ts +1 -0
  24. package/2x/es/locales/es-ES.d.ts +1 -0
  25. package/2x/es/locales/fa-IR.d.ts +1 -0
  26. package/2x/es/locales/ko-KR.d.ts +1 -0
  27. package/2x/es/locales/zh-CN.d.ts +1 -0
  28. package/2x/es/locales/zh-CN.js +2 -1
  29. package/2x/es/locales/zh-HK.d.ts +1 -0
  30. package/2x/es/locales/zh-TW.d.ts +1 -0
  31. package/2x/es/utils/is-node-with-content.d.ts +4 -0
  32. package/2x/es/utils/is-node-with-content.js +3 -0
  33. package/2x/package.json +1 -1
  34. package/bundle/antd-mobile.cjs.js +22 -11
  35. package/bundle/antd-mobile.es.js +23 -12
  36. package/cjs/components/image-uploader/image-uploader.js +9 -2
  37. package/cjs/components/list/list-item.js +7 -5
  38. package/cjs/components/text-area/text-area.js +1 -1
  39. package/cjs/components/virtual-input/virtual-input.js +2 -1
  40. package/cjs/locales/base.d.ts +1 -0
  41. package/cjs/locales/base.js +2 -1
  42. package/cjs/locales/en-US.d.ts +1 -0
  43. package/cjs/locales/es-ES.d.ts +1 -0
  44. package/cjs/locales/fa-IR.d.ts +1 -0
  45. package/cjs/locales/ko-KR.d.ts +1 -0
  46. package/cjs/locales/zh-CN.d.ts +1 -0
  47. package/cjs/locales/zh-CN.js +2 -1
  48. package/cjs/locales/zh-HK.d.ts +1 -0
  49. package/cjs/locales/zh-TW.d.ts +1 -0
  50. package/cjs/utils/is-node-with-content.d.ts +4 -0
  51. package/cjs/utils/is-node-with-content.js +10 -0
  52. package/es/components/image-uploader/image-uploader.js +8 -2
  53. package/es/components/list/list-item.js +6 -5
  54. package/es/components/text-area/text-area.js +2 -2
  55. package/es/components/virtual-input/virtual-input.js +2 -1
  56. package/es/locales/base.d.ts +1 -0
  57. package/es/locales/base.js +2 -1
  58. package/es/locales/en-US.d.ts +1 -0
  59. package/es/locales/es-ES.d.ts +1 -0
  60. package/es/locales/fa-IR.d.ts +1 -0
  61. package/es/locales/ko-KR.d.ts +1 -0
  62. package/es/locales/zh-CN.d.ts +1 -0
  63. package/es/locales/zh-CN.js +2 -1
  64. package/es/locales/zh-HK.d.ts +1 -0
  65. package/es/locales/zh-TW.d.ts +1 -0
  66. package/es/utils/is-node-with-content.d.ts +4 -0
  67. package/es/utils/is-node-with-content.js +3 -0
  68. package/package.json +1 -1
  69. package/umd/antd-mobile.js +1 -1
@@ -25,6 +25,8 @@ var _space = _interopRequireDefault(require("../space"));
25
25
 
26
26
  var _nativeProps = require("../../utils/native-props");
27
27
 
28
+ var _configProvider = require("../config-provider");
29
+
28
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
31
 
30
32
  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); }
@@ -46,6 +48,9 @@ const defaultProps = {
46
48
  };
47
49
 
48
50
  const ImageUploader = p => {
51
+ const {
52
+ locale
53
+ } = (0, _configProvider.useConfig)();
49
54
  const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
50
55
  const [value, setValue] = (0, _usePropsValue.usePropsValue)(props);
51
56
  const updateValue = (0, _ahooks.useMemoizedFn)(updater => {
@@ -218,7 +223,8 @@ const ImageUploader = p => {
218
223
  className: `${classPrefix}-upload-button-wrap`
219
224
  }, props.children ? props.children : _react.default.createElement("span", {
220
225
  className: `${classPrefix}-cell ${classPrefix}-upload-button`,
221
- role: 'button'
226
+ role: 'button',
227
+ "aria-label": locale.ImageUploader.upload
222
228
  }, _react.default.createElement("span", {
223
229
  className: `${classPrefix}-upload-button-icon`
224
230
  }, _react.default.createElement(_antdMobileIcons.AddOutline, null))), !props.disableUpload && _react.default.createElement("input", {
@@ -227,7 +233,8 @@ const ImageUploader = p => {
227
233
  multiple: props.multiple,
228
234
  type: 'file',
229
235
  className: `${classPrefix}-input`,
230
- onChange: onChange
236
+ onChange: onChange,
237
+ "aria-hidden": true
231
238
  })))));
232
239
  };
233
240
 
@@ -13,6 +13,8 @@ var _antdMobileIcons = require("antd-mobile-icons");
13
13
 
14
14
  var _classnames = _interopRequireDefault(require("classnames"));
15
15
 
16
+ var _isNodeWithContent = require("../../utils/is-node-with-content");
17
+
16
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
19
 
18
20
  const classPrefix = `adm-list-item`;
@@ -25,17 +27,17 @@ const ListItem = props => {
25
27
 
26
28
  const content = _react.default.createElement("div", {
27
29
  className: `${classPrefix}-content`
28
- }, props.prefix && _react.default.createElement("div", {
30
+ }, (0, _isNodeWithContent.isNodeWithContent)(props.prefix) && _react.default.createElement("div", {
29
31
  className: `${classPrefix}-content-prefix`
30
32
  }, props.prefix), _react.default.createElement("div", {
31
33
  className: `${classPrefix}-content-main`
32
- }, props.title && _react.default.createElement("div", {
34
+ }, (0, _isNodeWithContent.isNodeWithContent)(props.title) && _react.default.createElement("div", {
33
35
  className: `${classPrefix}-title`
34
- }, props.title), props.children, props.description && _react.default.createElement("div", {
36
+ }, props.title), props.children, (0, _isNodeWithContent.isNodeWithContent)(props.description) && _react.default.createElement("div", {
35
37
  className: `${classPrefix}-description`
36
- }, props.description)), props.extra && _react.default.createElement("div", {
38
+ }, props.description)), (0, _isNodeWithContent.isNodeWithContent)(props.extra) && _react.default.createElement("div", {
37
39
  className: `${classPrefix}-content-extra`
38
- }, props.extra), arrow && _react.default.createElement("div", {
40
+ }, props.extra), (0, _isNodeWithContent.isNodeWithContent)(arrow) && _react.default.createElement("div", {
39
41
  className: `${classPrefix}-content-arrow`
40
42
  }, arrow === true ? _react.default.createElement(_antdMobileIcons.RightOutline, null) : arrow));
41
43
 
@@ -57,7 +57,7 @@ const TextArea = (0, _react.forwardRef)((p, ref) => {
57
57
  (_a = nativeTextAreaRef.current) === null || _a === void 0 ? void 0 : _a.blur();
58
58
  }
59
59
  }));
60
- (0, _react.useEffect)(() => {
60
+ (0, _react.useLayoutEffect)(() => {
61
61
  if (!autoSize) return;
62
62
  const textArea = nativeTextAreaRef.current;
63
63
  if (!textArea) return;
@@ -105,7 +105,8 @@ const VirtualInput = (0, _react.forwardRef)((p, ref) => {
105
105
 
106
106
  (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.blur();
107
107
  (_c = (_b = keyboard.props).onClose) === null || _c === void 0 ? void 0 : _c.call(_b);
108
- }
108
+ },
109
+ getContainer: null
109
110
  });
110
111
 
111
112
  return (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
@@ -86,6 +86,7 @@ export declare const base: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -92,7 +92,8 @@ const base = {
92
92
  }
93
93
  },
94
94
  ImageUploader: {
95
- uploading: 'Uploading...'
95
+ uploading: 'Uploading...',
96
+ upload: 'Upload'
96
97
  },
97
98
  InfiniteScroll: {
98
99
  noMore: 'No more'
@@ -86,6 +86,7 @@ declare const enUS: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -86,6 +86,7 @@ declare const esES: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -86,6 +86,7 @@ declare const faIR: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -86,6 +86,7 @@ declare const koKR: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -86,6 +86,7 @@ declare const zhCN: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -97,7 +97,8 @@ const zhCN = (0, _mergeLocale.mergeLocale)(_base.base, {
97
97
  }
98
98
  },
99
99
  ImageUploader: {
100
- uploading: '上传中...'
100
+ uploading: '上传中...',
101
+ upload: '上传'
101
102
  },
102
103
  InfiniteScroll: {
103
104
  noMore: '没有更多了'
@@ -86,6 +86,7 @@ declare const zhHK: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -86,6 +86,7 @@ declare const zhTW: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -0,0 +1,4 @@
1
+ import { ReactNode } from 'react';
2
+ declare type Regulated<T> = T extends null | undefined | false ? never : T;
3
+ export declare function isNodeWithContent(node: ReactNode): node is Regulated<ReactNode>;
4
+ export {};
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isNodeWithContent = isNodeWithContent;
7
+
8
+ function isNodeWithContent(node) {
9
+ return node !== undefined && node !== null && node !== false;
10
+ }
@@ -8,6 +8,7 @@ import { usePropsValue } from '../../utils/use-props-value';
8
8
  import { useIsomorphicLayoutEffect, useMemoizedFn, useUnmount } from 'ahooks';
9
9
  import Space from '../space';
10
10
  import { withNativeProps } from '../../utils/native-props';
11
+ import { useConfig } from '../config-provider';
11
12
  const classPrefix = `adm-image-uploader`;
12
13
  const defaultProps = {
13
14
  disableUpload: false,
@@ -22,6 +23,9 @@ const defaultProps = {
22
23
  imageFit: 'cover'
23
24
  };
24
25
  export const ImageUploader = p => {
26
+ const {
27
+ locale
28
+ } = useConfig();
25
29
  const props = mergeProps(defaultProps, p);
26
30
  const [value, setValue] = usePropsValue(props);
27
31
  const updateValue = useMemoizedFn(updater => {
@@ -194,7 +198,8 @@ export const ImageUploader = p => {
194
198
  className: `${classPrefix}-upload-button-wrap`
195
199
  }, props.children ? props.children : React.createElement("span", {
196
200
  className: `${classPrefix}-cell ${classPrefix}-upload-button`,
197
- role: 'button'
201
+ role: 'button',
202
+ "aria-label": locale.ImageUploader.upload
198
203
  }, React.createElement("span", {
199
204
  className: `${classPrefix}-upload-button-icon`
200
205
  }, React.createElement(AddOutline, null))), !props.disableUpload && React.createElement("input", {
@@ -203,6 +208,7 @@ export const ImageUploader = p => {
203
208
  multiple: props.multiple,
204
209
  type: 'file',
205
210
  className: `${classPrefix}-input`,
206
- onChange: onChange
211
+ onChange: onChange,
212
+ "aria-hidden": true
207
213
  })))));
208
214
  };
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { withNativeProps } from '../../utils/native-props';
3
3
  import { RightOutline } from 'antd-mobile-icons';
4
4
  import classNames from 'classnames';
5
+ import { isNodeWithContent } from '../../utils/is-node-with-content';
5
6
  const classPrefix = `adm-list-item`;
6
7
  export const ListItem = props => {
7
8
  var _a;
@@ -10,17 +11,17 @@ export const ListItem = props => {
10
11
  const arrow = props.arrow === undefined ? clickable : props.arrow;
11
12
  const content = React.createElement("div", {
12
13
  className: `${classPrefix}-content`
13
- }, props.prefix && React.createElement("div", {
14
+ }, isNodeWithContent(props.prefix) && React.createElement("div", {
14
15
  className: `${classPrefix}-content-prefix`
15
16
  }, props.prefix), React.createElement("div", {
16
17
  className: `${classPrefix}-content-main`
17
- }, props.title && React.createElement("div", {
18
+ }, isNodeWithContent(props.title) && React.createElement("div", {
18
19
  className: `${classPrefix}-title`
19
- }, props.title), props.children, props.description && React.createElement("div", {
20
+ }, props.title), props.children, isNodeWithContent(props.description) && React.createElement("div", {
20
21
  className: `${classPrefix}-description`
21
- }, props.description)), props.extra && React.createElement("div", {
22
+ }, props.description)), isNodeWithContent(props.extra) && React.createElement("div", {
22
23
  className: `${classPrefix}-content-extra`
23
- }, props.extra), arrow && React.createElement("div", {
24
+ }, props.extra), isNodeWithContent(arrow) && React.createElement("div", {
24
25
  className: `${classPrefix}-content-arrow`
25
26
  }, arrow === true ? React.createElement(RightOutline, null) : arrow));
26
27
  return withNativeProps(props, React.createElement(clickable ? 'a' : 'div', {
@@ -1,4 +1,4 @@
1
- import React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
1
+ import React, { forwardRef, useLayoutEffect, useImperativeHandle, useRef } from 'react';
2
2
  import { withNativeProps } from '../../utils/native-props';
3
3
  import { usePropsValue } from '../../utils/use-props-value';
4
4
  import { mergeProps } from '../../utils/with-default-props';
@@ -41,7 +41,7 @@ export const TextArea = forwardRef((p, ref) => {
41
41
  (_a = nativeTextAreaRef.current) === null || _a === void 0 ? void 0 : _a.blur();
42
42
  }
43
43
  }));
44
- useEffect(() => {
44
+ useLayoutEffect(() => {
45
45
  if (!autoSize) return;
46
46
  const textArea = nativeTextAreaRef.current;
47
47
  if (!textArea) return;
@@ -84,7 +84,8 @@ export const VirtualInput = forwardRef((p, ref) => {
84
84
 
85
85
  (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.blur();
86
86
  (_c = (_b = keyboard.props).onClose) === null || _c === void 0 ? void 0 : _c.call(_b);
87
- }
87
+ },
88
+ getContainer: null
88
89
  });
89
90
  return withNativeProps(props, React.createElement("div", {
90
91
  ref: rootRef,
@@ -86,6 +86,7 @@ export declare const base: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -86,7 +86,8 @@ export const base = {
86
86
  }
87
87
  },
88
88
  ImageUploader: {
89
- uploading: 'Uploading...'
89
+ uploading: 'Uploading...',
90
+ upload: 'Upload'
90
91
  },
91
92
  InfiniteScroll: {
92
93
  noMore: 'No more'
@@ -86,6 +86,7 @@ declare const enUS: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -86,6 +86,7 @@ declare const esES: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -86,6 +86,7 @@ declare const faIR: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -86,6 +86,7 @@ declare const koKR: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -86,6 +86,7 @@ declare const zhCN: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -88,7 +88,8 @@ const zhCN = mergeLocale(base, {
88
88
  }
89
89
  },
90
90
  ImageUploader: {
91
- uploading: '上传中...'
91
+ uploading: '上传中...',
92
+ upload: '上传'
92
93
  },
93
94
  InfiniteScroll: {
94
95
  noMore: '没有更多了'
@@ -86,6 +86,7 @@ declare const zhHK: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -86,6 +86,7 @@ declare const zhTW: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -0,0 +1,4 @@
1
+ import { ReactNode } from 'react';
2
+ declare type Regulated<T> = T extends null | undefined | false ? never : T;
3
+ export declare function isNodeWithContent(node: ReactNode): node is Regulated<ReactNode>;
4
+ export {};
@@ -0,0 +1,3 @@
1
+ export function isNodeWithContent(node) {
2
+ return node !== undefined && node !== null && node !== false;
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antd-mobile",
3
- "version": "5.11.1",
3
+ "version": "5.11.2",
4
4
  "dependencies": {
5
5
  "@floating-ui/dom": "^0.4.2",
6
6
  "@react-spring/web": "^9.4.4",