antd-mobile 5.42.1 → 5.42.2-alpha.1

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 (38) hide show
  1. package/2x/bundle/antd-mobile.cjs.development.js +13 -6
  2. package/2x/bundle/antd-mobile.cjs.js +4 -4
  3. package/2x/bundle/antd-mobile.es.development.js +13 -6
  4. package/2x/bundle/antd-mobile.es.js +372 -372
  5. package/2x/bundle/antd-mobile.umd.development.js +13 -6
  6. package/2x/bundle/antd-mobile.umd.js +4 -4
  7. package/2x/bundle/style.css +5 -0
  8. package/2x/cjs/components/space/space.css +4 -0
  9. package/2x/cjs/components/virtual-input/use-click-outside.d.ts +1 -1
  10. package/2x/cjs/components/virtual-input/use-click-outside.js +10 -4
  11. package/2x/cjs/components/virtual-input/virtual-input.css +1 -0
  12. package/2x/cjs/components/virtual-input/virtual-input.js +11 -3
  13. package/2x/es/components/space/space.css +4 -0
  14. package/2x/es/components/virtual-input/use-click-outside.d.ts +1 -1
  15. package/2x/es/components/virtual-input/use-click-outside.js +10 -4
  16. package/2x/es/components/virtual-input/virtual-input.css +1 -0
  17. package/2x/es/components/virtual-input/virtual-input.js +11 -3
  18. package/2x/package.json +1 -1
  19. package/bundle/antd-mobile.cjs.development.js +13 -6
  20. package/bundle/antd-mobile.cjs.js +4 -4
  21. package/bundle/antd-mobile.compatible.umd.js +1 -1
  22. package/bundle/antd-mobile.es.development.js +13 -6
  23. package/bundle/antd-mobile.es.js +372 -372
  24. package/bundle/antd-mobile.umd.development.js +13 -6
  25. package/bundle/antd-mobile.umd.js +4 -4
  26. package/bundle/style.css +1 -1
  27. package/cjs/components/space/space.css +3 -0
  28. package/cjs/components/virtual-input/use-click-outside.d.ts +1 -1
  29. package/cjs/components/virtual-input/use-click-outside.js +10 -4
  30. package/cjs/components/virtual-input/virtual-input.css +1 -0
  31. package/cjs/components/virtual-input/virtual-input.js +11 -3
  32. package/es/components/space/space.css +3 -0
  33. package/es/components/virtual-input/use-click-outside.d.ts +1 -1
  34. package/es/components/virtual-input/use-click-outside.js +10 -4
  35. package/es/components/virtual-input/virtual-input.css +1 -0
  36. package/es/components/virtual-input/virtual-input.js +11 -3
  37. package/package.json +1 -1
  38. package/umd/antd-mobile.js +1 -1
@@ -2963,6 +2963,10 @@ a.adm-list-item:active:not(.adm-list-item-disabled):after {
2963
2963
  margin-right: var(--gap-horizontal);
2964
2964
  }
2965
2965
 
2966
+ .adm-space-horizontal>.adm-space-item:last-child {
2967
+ margin-right: 0;
2968
+ }
2969
+
2966
2970
  .adm-space-horizontal.adm-space-wrap {
2967
2971
  flex-wrap: wrap;
2968
2972
  margin-bottom: calc(var(--gap-vertical) * -1);
@@ -5710,6 +5714,7 @@ a.adm-list-item:active:not(.adm-list-item-disabled):after {
5710
5714
  overflow-x: scroll;
5711
5715
  letter-spacing: 2px;
5712
5716
  padding-right: var(--caret-width);
5717
+ outline: none;
5713
5718
  scrollbar-width: none;
5714
5719
  }
5715
5720
 
@@ -33,6 +33,10 @@
33
33
  margin-right: var(--gap-horizontal);
34
34
  }
35
35
 
36
+ .adm-space-horizontal > .adm-space-item:last-child {
37
+ margin-right: 0;
38
+ }
39
+
36
40
  .adm-space-horizontal.adm-space-wrap {
37
41
  flex-wrap: wrap;
38
42
  margin-bottom: calc(var(--gap-vertical) * -1);
@@ -1,2 +1,2 @@
1
- declare function useClickOutside(handler: (event: MouseEvent) => void, ref: React.RefObject<HTMLElement>): void;
1
+ declare function useClickOutside(handler: (event: MouseEvent) => void, ref: React.RefObject<HTMLElement>, hasKeyboardProps?: boolean): void;
2
2
  export default useClickOutside;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = require("react");
8
8
  // 监听点击组件外部的事件
9
- function useClickOutside(handler, ref) {
9
+ function useClickOutside(handler, ref, hasKeyboardProps = false) {
10
10
  (0, _react.useEffect)(() => {
11
11
  function handleClick(event) {
12
12
  if (!ref.current || ref.current.contains(event.target)) {
@@ -14,10 +14,16 @@ function useClickOutside(handler, ref) {
14
14
  }
15
15
  handler(event);
16
16
  }
17
- // 在捕获阶段监听,以确保在事件被阻止传播之前触发
18
- document.addEventListener('click', handleClick, true);
17
+ // 向前兼容逻辑:
18
+ // 1. 对于有键盘属性的 VirtualInput,在捕获阶段监听:
19
+ // 这是为了确保在事件被阻止传播之前触发。比如输入框中的单个数字 click 事件会 stopPropagation, 但这里依然能捕获到
20
+ // 2. 对于无键盘属性的 VirtualInput 组件,在冒泡阶段监听:
21
+ // 这种情况通常是 VirtualInput + NumberKeyboard 为兄弟关系,在以前版本中点击 NumberKeyboard **不会**触发 VirtualInput 的 blur 事件
22
+ // 原先原理:通过 NumberKeyboard 内部 onMouseDown 时 preventDefault 阻止的 VirtualInput 内原生的 blur 事件
23
+ // 新的原理:NumberKeyboard 的 Popup 默认会 stopPropagation click, 这里在冒泡阶段监听不到,不会调用 VirtualInput 的 onBlur 回调(非原生事件)。
24
+ document.addEventListener('click', handleClick, hasKeyboardProps ? true : false);
19
25
  return () => {
20
- document.removeEventListener('click', handleClick, true);
26
+ document.removeEventListener('click', handleClick, hasKeyboardProps ? true : false);
21
27
  };
22
28
  }, [handler, ref]);
23
29
  }
@@ -32,6 +32,7 @@
32
32
  overflow-x: scroll;
33
33
  letter-spacing: 2px;
34
34
  padding-right: var(--caret-width);
35
+ outline: none;
35
36
  scrollbar-width: none;
36
37
  }
37
38
 
@@ -100,7 +100,7 @@ const VirtualInput = (0, _react.forwardRef)((props, ref) => {
100
100
  }
101
101
  (0, _useClickOutside.default)(() => {
102
102
  setBlur();
103
- }, rootRef);
103
+ }, rootRef, !!mergedProps.keyboard);
104
104
  const keyboard = mergedProps.keyboard;
105
105
  const keyboardElement = keyboard && _react.default.cloneElement(keyboard, {
106
106
  onInput: v => {
@@ -128,15 +128,23 @@ const VirtualInput = (0, _react.forwardRef)((props, ref) => {
128
128
  },
129
129
  visible: hasFocus,
130
130
  onClose: () => {
131
- var _a, _b;
131
+ var _a, _b, _c;
132
+ const activeElement = document.activeElement;
133
+ if (activeElement === contentRef.current) {
134
+ // 点击 NumberKeyboard 的确认和关闭时不会触发输入框的 blur 事件,手动调用让其失焦,否则之后无法 focus
135
+ (_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.blur();
136
+ }
132
137
  setBlur();
133
- (_b = (_a = keyboard.props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
138
+ (_c = (_b = keyboard.props).onClose) === null || _c === void 0 ? void 0 : _c.call(_b);
134
139
  },
135
140
  getContainer: null
136
141
  });
137
142
  // 点击输入框时,将光标置于最后
138
143
  const setCaretPositionToEnd = e => {
139
144
  var _a, _b, _c;
145
+ if (mergedProps.disabled) {
146
+ return;
147
+ }
140
148
  if (caretPosition !== value.length) {
141
149
  setCaretPosition(value.length);
142
150
  (_b = (_a = mergedProps.cursor) === null || _a === void 0 ? void 0 : _a.onMove) === null || _b === void 0 ? void 0 : _b.call(_a, value.length);
@@ -33,6 +33,10 @@
33
33
  margin-right: var(--gap-horizontal);
34
34
  }
35
35
 
36
+ .adm-space-horizontal > .adm-space-item:last-child {
37
+ margin-right: 0;
38
+ }
39
+
36
40
  .adm-space-horizontal.adm-space-wrap {
37
41
  flex-wrap: wrap;
38
42
  margin-bottom: calc(var(--gap-vertical) * -1);
@@ -1,2 +1,2 @@
1
- declare function useClickOutside(handler: (event: MouseEvent) => void, ref: React.RefObject<HTMLElement>): void;
1
+ declare function useClickOutside(handler: (event: MouseEvent) => void, ref: React.RefObject<HTMLElement>, hasKeyboardProps?: boolean): void;
2
2
  export default useClickOutside;
@@ -1,6 +1,6 @@
1
1
  import { useEffect } from 'react';
2
2
  // 监听点击组件外部的事件
3
- function useClickOutside(handler, ref) {
3
+ function useClickOutside(handler, ref, hasKeyboardProps = false) {
4
4
  useEffect(() => {
5
5
  function handleClick(event) {
6
6
  if (!ref.current || ref.current.contains(event.target)) {
@@ -8,10 +8,16 @@ function useClickOutside(handler, ref) {
8
8
  }
9
9
  handler(event);
10
10
  }
11
- // 在捕获阶段监听,以确保在事件被阻止传播之前触发
12
- document.addEventListener('click', handleClick, true);
11
+ // 向前兼容逻辑:
12
+ // 1. 对于有键盘属性的 VirtualInput,在捕获阶段监听:
13
+ // 这是为了确保在事件被阻止传播之前触发。比如输入框中的单个数字 click 事件会 stopPropagation, 但这里依然能捕获到
14
+ // 2. 对于无键盘属性的 VirtualInput 组件,在冒泡阶段监听:
15
+ // 这种情况通常是 VirtualInput + NumberKeyboard 为兄弟关系,在以前版本中点击 NumberKeyboard **不会**触发 VirtualInput 的 blur 事件
16
+ // 原先原理:通过 NumberKeyboard 内部 onMouseDown 时 preventDefault 阻止的 VirtualInput 内原生的 blur 事件
17
+ // 新的原理:NumberKeyboard 的 Popup 默认会 stopPropagation click, 这里在冒泡阶段监听不到,不会调用 VirtualInput 的 onBlur 回调(非原生事件)。
18
+ document.addEventListener('click', handleClick, hasKeyboardProps ? true : false);
13
19
  return () => {
14
- document.removeEventListener('click', handleClick, true);
20
+ document.removeEventListener('click', handleClick, hasKeyboardProps ? true : false);
15
21
  };
16
22
  }, [handler, ref]);
17
23
  }
@@ -32,6 +32,7 @@
32
32
  overflow-x: scroll;
33
33
  letter-spacing: 2px;
34
34
  padding-right: var(--caret-width);
35
+ outline: none;
35
36
  scrollbar-width: none;
36
37
  }
37
38
 
@@ -91,7 +91,7 @@ export const VirtualInput = forwardRef((props, ref) => {
91
91
  }
92
92
  useClickOutside(() => {
93
93
  setBlur();
94
- }, rootRef);
94
+ }, rootRef, !!mergedProps.keyboard);
95
95
  const keyboard = mergedProps.keyboard;
96
96
  const keyboardElement = keyboard && React.cloneElement(keyboard, {
97
97
  onInput: v => {
@@ -119,15 +119,23 @@ export const VirtualInput = forwardRef((props, ref) => {
119
119
  },
120
120
  visible: hasFocus,
121
121
  onClose: () => {
122
- var _a, _b;
122
+ var _a, _b, _c;
123
+ const activeElement = document.activeElement;
124
+ if (activeElement === contentRef.current) {
125
+ // 点击 NumberKeyboard 的确认和关闭时不会触发输入框的 blur 事件,手动调用让其失焦,否则之后无法 focus
126
+ (_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.blur();
127
+ }
123
128
  setBlur();
124
- (_b = (_a = keyboard.props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
129
+ (_c = (_b = keyboard.props).onClose) === null || _c === void 0 ? void 0 : _c.call(_b);
125
130
  },
126
131
  getContainer: null
127
132
  });
128
133
  // 点击输入框时,将光标置于最后
129
134
  const setCaretPositionToEnd = e => {
130
135
  var _a, _b, _c;
136
+ if (mergedProps.disabled) {
137
+ return;
138
+ }
131
139
  if (caretPosition !== value.length) {
132
140
  setCaretPosition(value.length);
133
141
  (_b = (_a = mergedProps.cursor) === null || _a === void 0 ? void 0 : _a.onMove) === null || _b === void 0 ? void 0 : _b.call(_a, value.length);
package/2x/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antd-mobile",
3
- "version": "5.42.1",
3
+ "version": "5.42.2-alpha.1",
4
4
  "homepage": "https://github.com/ant-design/ant-design-mobile#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/ant-design/ant-design-mobile/issues"
@@ -27604,7 +27604,7 @@ const Multiple = (p) => {
27604
27604
  const index = attachPropertiesToComponent(TreeSelect, {
27605
27605
  Multiple
27606
27606
  });
27607
- function useClickOutside(handler, ref2) {
27607
+ function useClickOutside(handler, ref2, hasKeyboardProps = false) {
27608
27608
  React$3.useEffect(() => {
27609
27609
  function handleClick(event) {
27610
27610
  if (!ref2.current || ref2.current.contains(event.target)) {
@@ -27612,9 +27612,9 @@ function useClickOutside(handler, ref2) {
27612
27612
  }
27613
27613
  handler(event);
27614
27614
  }
27615
- document.addEventListener("click", handleClick, true);
27615
+ document.addEventListener("click", handleClick, hasKeyboardProps ? true : false);
27616
27616
  return () => {
27617
- document.removeEventListener("click", handleClick, true);
27617
+ document.removeEventListener("click", handleClick, hasKeyboardProps ? true : false);
27618
27618
  };
27619
27619
  }, [handler, ref2]);
27620
27620
  }
@@ -27702,7 +27702,7 @@ const VirtualInput = React$3.forwardRef((props, ref2) => {
27702
27702
  }
27703
27703
  useClickOutside(() => {
27704
27704
  setBlur();
27705
- }, rootRef);
27705
+ }, rootRef, !!mergedProps.keyboard);
27706
27706
  const keyboard = mergedProps.keyboard;
27707
27707
  const keyboardElement = keyboard && React$3.cloneElement(keyboard, {
27708
27708
  onInput: (v) => {
@@ -27729,14 +27729,21 @@ const VirtualInput = React$3.forwardRef((props, ref2) => {
27729
27729
  },
27730
27730
  visible: hasFocus,
27731
27731
  onClose: () => {
27732
- var _a, _b;
27732
+ var _a, _b, _c;
27733
+ const activeElement = document.activeElement;
27734
+ if (activeElement === contentRef.current) {
27735
+ (_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.blur();
27736
+ }
27733
27737
  setBlur();
27734
- (_b = (_a = keyboard.props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
27738
+ (_c = (_b = keyboard.props).onClose) === null || _c === void 0 ? void 0 : _c.call(_b);
27735
27739
  },
27736
27740
  getContainer: null
27737
27741
  });
27738
27742
  const setCaretPositionToEnd = (e2) => {
27739
27743
  var _a, _b, _c;
27744
+ if (mergedProps.disabled) {
27745
+ return;
27746
+ }
27740
27747
  if (caretPosition !== value.length) {
27741
27748
  setCaretPosition(value.length);
27742
27749
  (_b = (_a = mergedProps.cursor) === null || _a === void 0 ? void 0 : _a.onMove) === null || _b === void 0 ? void 0 : _b.call(_a, value.length);