antd-mobile 5.33.1 → 5.33.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 (46) hide show
  1. package/2x/bundle/antd-mobile.cjs.development.js +1792 -1804
  2. package/2x/bundle/antd-mobile.cjs.js +9 -9
  3. package/2x/bundle/antd-mobile.es.development.js +971 -979
  4. package/2x/bundle/antd-mobile.es.js +4604 -4569
  5. package/2x/bundle/antd-mobile.umd.development.js +2143 -2155
  6. package/2x/bundle/antd-mobile.umd.js +9 -9
  7. package/2x/bundle/style.css +2 -2
  8. package/2x/cjs/components/dropdown/dropdown.js +3 -1
  9. package/2x/cjs/components/mask/mask.js +1 -0
  10. package/2x/cjs/components/number-keyboard/number-keyboard.js +10 -6
  11. package/2x/cjs/components/tabs/tabs.d.ts +6 -0
  12. package/2x/cjs/components/tabs/tabs.js +14 -12
  13. package/2x/cjs/components/virtual-input/virtual-input.js +1 -1
  14. package/2x/cjs/global/global.css +2 -2
  15. package/2x/es/components/dropdown/dropdown.js +3 -1
  16. package/2x/es/components/mask/mask.js +1 -0
  17. package/2x/es/components/number-keyboard/number-keyboard.js +10 -6
  18. package/2x/es/components/tabs/tabs.d.ts +6 -0
  19. package/2x/es/components/tabs/tabs.js +14 -12
  20. package/2x/es/components/virtual-input/virtual-input.js +1 -1
  21. package/2x/es/global/global.css +2 -2
  22. package/2x/package.json +1 -1
  23. package/bundle/antd-mobile.cjs.development.js +1792 -1804
  24. package/bundle/antd-mobile.cjs.js +9 -9
  25. package/bundle/antd-mobile.compatible.umd.js +1 -1
  26. package/bundle/antd-mobile.es.development.js +971 -979
  27. package/bundle/antd-mobile.es.js +4604 -4569
  28. package/bundle/antd-mobile.umd.development.js +2143 -2155
  29. package/bundle/antd-mobile.umd.js +9 -9
  30. package/bundle/style.css +1 -1
  31. package/cjs/components/dropdown/dropdown.js +3 -1
  32. package/cjs/components/mask/mask.js +1 -0
  33. package/cjs/components/number-keyboard/number-keyboard.js +10 -6
  34. package/cjs/components/tabs/tabs.d.ts +6 -0
  35. package/cjs/components/tabs/tabs.js +14 -12
  36. package/cjs/components/virtual-input/virtual-input.js +1 -1
  37. package/cjs/global/global.css +2 -2
  38. package/es/components/dropdown/dropdown.js +3 -1
  39. package/es/components/mask/mask.js +1 -0
  40. package/es/components/number-keyboard/number-keyboard.js +10 -6
  41. package/es/components/tabs/tabs.d.ts +6 -0
  42. package/es/components/tabs/tabs.js +14 -12
  43. package/es/components/virtual-input/virtual-input.js +1 -1
  44. package/es/global/global.css +2 -2
  45. package/package.json +1 -1
  46. package/umd/antd-mobile.js +1 -1
@@ -101,8 +101,8 @@ div.adm-px-tester {
101
101
  height: calc(var(--size) / 2 * 4px);
102
102
  width: 0;
103
103
  position: fixed;
104
- right: -100vw;
105
- bottom: -100vh;
104
+ left: -100vw;
105
+ top: -100vh;
106
106
  -webkit-user-select: none;
107
107
  user-select: none;
108
108
  pointer-events: none;
@@ -60,8 +60,10 @@ const Dropdown = (0, _react.forwardRef)((p, ref) => {
60
60
  const navs = _react.default.Children.map(props.children, child => {
61
61
  if ((0, _react.isValidElement)(child)) {
62
62
  const childProps = Object.assign(Object.assign({}, child.props), {
63
- onClick: () => {
63
+ onClick: event => {
64
+ var _a, _b;
64
65
  changeActive(child.key);
66
+ (_b = (_a = child.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
65
67
  },
66
68
  active: child.key === value,
67
69
  arrow: child.props.arrow === undefined ? props.arrow : child.props.arrow
@@ -79,6 +79,7 @@ const Mask = p => {
79
79
  const node = (0, _withStopPropagation.withStopPropagation)(props.stopPropagation, (0, _nativeProps.withNativeProps)(props, _react.default.createElement(_web.animated.div, {
80
80
  className: classPrefix,
81
81
  ref: ref,
82
+ "aria-hidden": true,
82
83
  style: Object.assign(Object.assign({}, props.style), {
83
84
  background,
84
85
  opacity,
@@ -13,6 +13,7 @@ var _popup = _interopRequireDefault(require("../popup"));
13
13
  var _nativeProps = require("../../utils/native-props");
14
14
  var _safeArea = _interopRequireDefault(require("../safe-area"));
15
15
  var _ahooks = require("ahooks");
16
+ var _configProvider = require("../config-provider");
16
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
18
  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); }
18
19
  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; }
@@ -39,6 +40,9 @@ const NumberKeyboard = p => {
39
40
  showCloseButton,
40
41
  onInput
41
42
  } = props;
43
+ const {
44
+ locale
45
+ } = (0, _configProvider.useConfig)();
42
46
  const keyboardRef = (0, _react.useRef)(null);
43
47
  const keys = (0, _react.useMemo)(() => {
44
48
  const defaultKeys = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
@@ -106,8 +110,8 @@ const NumberKeyboard = p => {
106
110
  var _a;
107
111
  (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
108
112
  },
109
- role: 'grid',
110
- title: 'CLOSE',
113
+ role: 'button',
114
+ title: locale.common.close,
111
115
  tabIndex: -1
112
116
  }, _react.default.createElement(_antdMobileIcons.DownOutline, null)));
113
117
  };
@@ -119,7 +123,7 @@ const NumberKeyboard = p => {
119
123
  [`${classPrefix}-key-mid`]: index === 9 && !!confirmText && keys.length < 12
120
124
  });
121
125
  const ariaProps = key ? {
122
- role: 'grid',
126
+ role: 'button',
123
127
  title: key,
124
128
  tabIndex: -1
125
129
  } : undefined;
@@ -176,13 +180,13 @@ const NumberKeyboard = p => {
176
180
  // Long press should not trigger native context menu
177
181
  e.preventDefault();
178
182
  },
179
- title: 'BACKSPACE',
180
- role: 'grid',
183
+ title: locale.Input.clear,
184
+ role: 'button',
181
185
  tabIndex: -1
182
186
  }, _react.default.createElement(_antdMobileIcons.TextDeletionOutline, null)), _react.default.createElement("div", {
183
187
  className: `${classPrefix}-key ${classPrefix}-key-extra ${classPrefix}-key-ok`,
184
188
  onTouchEnd: e => onKeyPress(e, 'OK'),
185
- role: 'grid',
189
+ role: 'button',
186
190
  tabIndex: -1,
187
191
  "aria-label": confirmText
188
192
  }, confirmText))), props.safeArea && _react.default.createElement("div", {
@@ -16,5 +16,11 @@ export declare type TabsProps = {
16
16
  onChange?: (key: string) => void;
17
17
  children?: ReactNode;
18
18
  direction?: 'ltr' | 'rtl';
19
+ /**
20
+ * @experimental Support disabled auto scroll when Tabs header content change.
21
+ * This API name or function may change in the future.
22
+ * Please lock the version if you want to use it.
23
+ */
24
+ autoScroll?: boolean;
19
25
  } & NativeProps<'--fixed-active-line-width' | '--active-line-height' | '--active-line-border-radius' | '--title-font-size' | '--content-padding' | '--active-title-color' | '--active-line-color'>;
20
26
  export declare const Tabs: FC<TabsProps>;
@@ -61,7 +61,7 @@ const Tabs = p => {
61
61
  const [{
62
62
  x,
63
63
  width
64
- }, api] = (0, _web.useSpring)(() => ({
64
+ }, inkApi] = (0, _web.useSpring)(() => ({
65
65
  x: 0,
66
66
  width: 0,
67
67
  config: {
@@ -88,12 +88,12 @@ const Tabs = p => {
88
88
  clamp: true
89
89
  }
90
90
  }));
91
- function animate(immediate = false) {
91
+ function animate(immediate = false, fromMutation = false) {
92
92
  const container = tabListContainerRef.current;
93
93
  if (!container) return;
94
94
  const activeIndex = keyToIndexRecord[activeKey];
95
95
  if (activeIndex === undefined) {
96
- api.start({
96
+ inkApi.start({
97
97
  x: 0,
98
98
  width: 0,
99
99
  immediate: true
@@ -131,7 +131,7 @@ const Tabs = p => {
131
131
  const w = ['auto', 'full'].includes(props.activeLineMode) ? width : activeLineWidth;
132
132
  x = -(containerWidth - x - w);
133
133
  }
134
- api.start({
134
+ inkApi.start({
135
135
  x,
136
136
  width,
137
137
  immediate
@@ -148,13 +148,15 @@ const Tabs = p => {
148
148
  } else {
149
149
  nextScrollLeft = (0, _bound.bound)(activeTabLeft - (containerWidth - activeTabWidth) / 2, 0, maxScrollDistance);
150
150
  }
151
- scrollApi.start({
152
- scrollLeft: nextScrollLeft,
153
- from: {
154
- scrollLeft: containerScrollLeft
155
- },
156
- immediate
157
- });
151
+ if (!fromMutation || props.autoScroll !== false) {
152
+ scrollApi.start({
153
+ scrollLeft: nextScrollLeft,
154
+ from: {
155
+ scrollLeft: containerScrollLeft
156
+ },
157
+ immediate
158
+ });
159
+ }
158
160
  }
159
161
  (0, _ahooks.useIsomorphicLayoutEffect)(() => {
160
162
  animate(!x.isAnimating);
@@ -166,7 +168,7 @@ const Tabs = p => {
166
168
  animate(!x.isAnimating);
167
169
  }, tabListContainerRef);
168
170
  (0, _useMutationEffect.useMutationEffect)(() => {
169
- animate(!x.isAnimating);
171
+ animate(!x.isAnimating, true);
170
172
  }, tabListContainerRef, {
171
173
  subtree: true,
172
174
  childList: true,
@@ -99,7 +99,7 @@ const VirtualInput = (0, _react.forwardRef)((p, ref) => {
99
99
  [`${classPrefix}-disabled`]: props.disabled
100
100
  }),
101
101
  tabIndex: props.disabled ? undefined : 0,
102
- role: 'option',
102
+ role: 'textbox',
103
103
  onFocus: onFocus,
104
104
  onBlur: onBlur,
105
105
  onClick: props.onClick
@@ -103,8 +103,8 @@ div.adm-px-tester {
103
103
  height: calc(var(--size) / 2 * 4px);
104
104
  width: 0;
105
105
  position: fixed;
106
- right: -100vw;
107
- bottom: -100vh;
106
+ left: -100vw;
107
+ top: -100vh;
108
108
  -webkit-user-select: none;
109
109
  user-select: none;
110
110
  pointer-events: none;
@@ -51,8 +51,10 @@ const Dropdown = forwardRef((p, ref) => {
51
51
  const navs = React.Children.map(props.children, child => {
52
52
  if (isValidElement(child)) {
53
53
  const childProps = Object.assign(Object.assign({}, child.props), {
54
- onClick: () => {
54
+ onClick: event => {
55
+ var _a, _b;
55
56
  changeActive(child.key);
57
+ (_b = (_a = child.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
56
58
  },
57
59
  active: child.key === value,
58
60
  arrow: child.props.arrow === undefined ? props.arrow : child.props.arrow
@@ -71,6 +71,7 @@ export const Mask = p => {
71
71
  const node = withStopPropagation(props.stopPropagation, withNativeProps(props, React.createElement(animated.div, {
72
72
  className: classPrefix,
73
73
  ref: ref,
74
+ "aria-hidden": true,
74
75
  style: Object.assign(Object.assign({}, props.style), {
75
76
  background,
76
77
  opacity,
@@ -7,6 +7,7 @@ import Popup from '../popup';
7
7
  import { withNativeProps } from '../../utils/native-props';
8
8
  import SafeArea from '../safe-area';
9
9
  import { useMemoizedFn } from 'ahooks';
10
+ import { useConfig } from '../config-provider';
10
11
  const classPrefix = 'adm-number-keyboard';
11
12
  const defaultProps = {
12
13
  defaultVisible: false,
@@ -30,6 +31,9 @@ export const NumberKeyboard = p => {
30
31
  showCloseButton,
31
32
  onInput
32
33
  } = props;
34
+ const {
35
+ locale
36
+ } = useConfig();
33
37
  const keyboardRef = useRef(null);
34
38
  const keys = useMemo(() => {
35
39
  const defaultKeys = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
@@ -97,8 +101,8 @@ export const NumberKeyboard = p => {
97
101
  var _a;
98
102
  (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
99
103
  },
100
- role: 'grid',
101
- title: 'CLOSE',
104
+ role: 'button',
105
+ title: locale.common.close,
102
106
  tabIndex: -1
103
107
  }, React.createElement(DownOutline, null)));
104
108
  };
@@ -110,7 +114,7 @@ export const NumberKeyboard = p => {
110
114
  [`${classPrefix}-key-mid`]: index === 9 && !!confirmText && keys.length < 12
111
115
  });
112
116
  const ariaProps = key ? {
113
- role: 'grid',
117
+ role: 'button',
114
118
  title: key,
115
119
  tabIndex: -1
116
120
  } : undefined;
@@ -167,13 +171,13 @@ export const NumberKeyboard = p => {
167
171
  // Long press should not trigger native context menu
168
172
  e.preventDefault();
169
173
  },
170
- title: 'BACKSPACE',
171
- role: 'grid',
174
+ title: locale.Input.clear,
175
+ role: 'button',
172
176
  tabIndex: -1
173
177
  }, React.createElement(TextDeletionOutline, null)), React.createElement("div", {
174
178
  className: `${classPrefix}-key ${classPrefix}-key-extra ${classPrefix}-key-ok`,
175
179
  onTouchEnd: e => onKeyPress(e, 'OK'),
176
- role: 'grid',
180
+ role: 'button',
177
181
  tabIndex: -1,
178
182
  "aria-label": confirmText
179
183
  }, confirmText))), props.safeArea && React.createElement("div", {
@@ -16,5 +16,11 @@ export declare type TabsProps = {
16
16
  onChange?: (key: string) => void;
17
17
  children?: ReactNode;
18
18
  direction?: 'ltr' | 'rtl';
19
+ /**
20
+ * @experimental Support disabled auto scroll when Tabs header content change.
21
+ * This API name or function may change in the future.
22
+ * Please lock the version if you want to use it.
23
+ */
24
+ autoScroll?: boolean;
19
25
  } & NativeProps<'--fixed-active-line-width' | '--active-line-height' | '--active-line-border-radius' | '--title-font-size' | '--content-padding' | '--active-title-color' | '--active-line-color'>;
20
26
  export declare const Tabs: FC<TabsProps>;
@@ -51,7 +51,7 @@ export const Tabs = p => {
51
51
  const [{
52
52
  x,
53
53
  width
54
- }, api] = useSpring(() => ({
54
+ }, inkApi] = useSpring(() => ({
55
55
  x: 0,
56
56
  width: 0,
57
57
  config: {
@@ -78,12 +78,12 @@ export const Tabs = p => {
78
78
  clamp: true
79
79
  }
80
80
  }));
81
- function animate(immediate = false) {
81
+ function animate(immediate = false, fromMutation = false) {
82
82
  const container = tabListContainerRef.current;
83
83
  if (!container) return;
84
84
  const activeIndex = keyToIndexRecord[activeKey];
85
85
  if (activeIndex === undefined) {
86
- api.start({
86
+ inkApi.start({
87
87
  x: 0,
88
88
  width: 0,
89
89
  immediate: true
@@ -121,7 +121,7 @@ export const Tabs = p => {
121
121
  const w = ['auto', 'full'].includes(props.activeLineMode) ? width : activeLineWidth;
122
122
  x = -(containerWidth - x - w);
123
123
  }
124
- api.start({
124
+ inkApi.start({
125
125
  x,
126
126
  width,
127
127
  immediate
@@ -138,13 +138,15 @@ export const Tabs = p => {
138
138
  } else {
139
139
  nextScrollLeft = bound(activeTabLeft - (containerWidth - activeTabWidth) / 2, 0, maxScrollDistance);
140
140
  }
141
- scrollApi.start({
142
- scrollLeft: nextScrollLeft,
143
- from: {
144
- scrollLeft: containerScrollLeft
145
- },
146
- immediate
147
- });
141
+ if (!fromMutation || props.autoScroll !== false) {
142
+ scrollApi.start({
143
+ scrollLeft: nextScrollLeft,
144
+ from: {
145
+ scrollLeft: containerScrollLeft
146
+ },
147
+ immediate
148
+ });
149
+ }
148
150
  }
149
151
  useIsomorphicLayoutEffect(() => {
150
152
  animate(!x.isAnimating);
@@ -156,7 +158,7 @@ export const Tabs = p => {
156
158
  animate(!x.isAnimating);
157
159
  }, tabListContainerRef);
158
160
  useMutationEffect(() => {
159
- animate(!x.isAnimating);
161
+ animate(!x.isAnimating, true);
160
162
  }, tabListContainerRef, {
161
163
  subtree: true,
162
164
  childList: true,
@@ -90,7 +90,7 @@ export const VirtualInput = forwardRef((p, ref) => {
90
90
  [`${classPrefix}-disabled`]: props.disabled
91
91
  }),
92
92
  tabIndex: props.disabled ? undefined : 0,
93
- role: 'option',
93
+ role: 'textbox',
94
94
  onFocus: onFocus,
95
95
  onBlur: onBlur,
96
96
  onClick: props.onClick
@@ -103,8 +103,8 @@ div.adm-px-tester {
103
103
  height: calc(var(--size) / 2 * 4px);
104
104
  width: 0;
105
105
  position: fixed;
106
- right: -100vw;
107
- bottom: -100vh;
106
+ left: -100vw;
107
+ top: -100vh;
108
108
  -webkit-user-select: none;
109
109
  user-select: none;
110
110
  pointer-events: none;
package/2x/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antd-mobile",
3
- "version": "5.33.1",
3
+ "version": "5.33.2",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
6
  "@floating-ui/dom": "^1.4.2",