antd-mobile 5.41.1 → 5.42.0-alpha.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.
- package/2x/bundle/antd-mobile.cjs.development.js +65 -51
- package/2x/bundle/antd-mobile.cjs.js +6 -6
- package/2x/bundle/antd-mobile.es.development.js +65 -51
- package/2x/bundle/antd-mobile.es.js +1534 -1524
- package/2x/bundle/antd-mobile.umd.development.js +65 -51
- package/2x/bundle/antd-mobile.umd.js +6 -6
- package/2x/bundle/style.css +9 -2
- package/2x/cjs/components/dialog/dialog.d.ts +2 -2
- package/2x/cjs/components/dialog/dialog.js +3 -3
- package/2x/cjs/components/modal/modal.d.ts +2 -2
- package/2x/cjs/components/modal/modal.js +4 -4
- package/2x/cjs/components/number-keyboard/number-keyboard.js +18 -21
- package/2x/cjs/components/virtual-input/use-click-outside.d.ts +2 -0
- package/2x/cjs/components/virtual-input/use-click-outside.js +25 -0
- package/2x/cjs/components/virtual-input/virtual-input.css +9 -2
- package/2x/cjs/components/virtual-input/virtual-input.js +32 -30
- package/2x/es/components/dialog/dialog.d.ts +2 -2
- package/2x/es/components/dialog/dialog.js +3 -3
- package/2x/es/components/modal/modal.d.ts +2 -2
- package/2x/es/components/modal/modal.js +4 -4
- package/2x/es/components/number-keyboard/number-keyboard.js +18 -21
- package/2x/es/components/virtual-input/use-click-outside.d.ts +2 -0
- package/2x/es/components/virtual-input/use-click-outside.js +18 -0
- package/2x/es/components/virtual-input/virtual-input.css +9 -2
- package/2x/es/components/virtual-input/virtual-input.js +32 -30
- package/2x/package.json +1 -1
- package/bundle/antd-mobile.cjs.development.js +65 -51
- package/bundle/antd-mobile.cjs.js +6 -6
- package/bundle/antd-mobile.compatible.umd.js +1 -1
- package/bundle/antd-mobile.es.development.js +65 -51
- package/bundle/antd-mobile.es.js +1534 -1524
- package/bundle/antd-mobile.umd.development.js +65 -51
- package/bundle/antd-mobile.umd.js +6 -6
- package/bundle/style.css +1 -1
- package/cjs/components/dialog/dialog.d.ts +2 -2
- package/cjs/components/dialog/dialog.js +3 -3
- package/cjs/components/modal/modal.d.ts +2 -2
- package/cjs/components/modal/modal.js +4 -4
- package/cjs/components/number-keyboard/number-keyboard.js +18 -21
- package/cjs/components/virtual-input/use-click-outside.d.ts +2 -0
- package/cjs/components/virtual-input/use-click-outside.js +25 -0
- package/cjs/components/virtual-input/virtual-input.css +8 -2
- package/cjs/components/virtual-input/virtual-input.js +32 -30
- package/es/components/dialog/dialog.d.ts +2 -2
- package/es/components/dialog/dialog.js +3 -3
- package/es/components/modal/modal.d.ts +2 -2
- package/es/components/modal/modal.js +4 -4
- package/es/components/number-keyboard/number-keyboard.js +18 -21
- package/es/components/virtual-input/use-click-outside.d.ts +2 -0
- package/es/components/virtual-input/use-click-outside.js +18 -0
- package/es/components/virtual-input/virtual-input.css +8 -2
- package/es/components/virtual-input/virtual-input.js +32 -30
- package/package.json +1 -1
- package/umd/antd-mobile.js +1 -1
|
@@ -23189,7 +23189,6 @@ const NumberKeyboard = (p) => {
|
|
|
23189
23189
|
};
|
|
23190
23190
|
const onKeyPress = (e2, key) => {
|
|
23191
23191
|
var _a, _b;
|
|
23192
|
-
e2.preventDefault();
|
|
23193
23192
|
switch (key) {
|
|
23194
23193
|
case "BACKSPACE":
|
|
23195
23194
|
onDelete === null || onDelete === void 0 ? void 0 : onDelete();
|
|
@@ -23227,6 +23226,15 @@ const NumberKeyboard = (p) => {
|
|
|
23227
23226
|
tabIndex: -1
|
|
23228
23227
|
}, React__default.createElement(DownOutline, null)));
|
|
23229
23228
|
};
|
|
23229
|
+
const onBackspaceTouchStart = () => {
|
|
23230
|
+
stopContinueClear();
|
|
23231
|
+
startContinueClear();
|
|
23232
|
+
};
|
|
23233
|
+
const onBackspaceTouchEnd = (e2) => {
|
|
23234
|
+
e2.preventDefault();
|
|
23235
|
+
stopContinueClear();
|
|
23236
|
+
onKeyPress(e2, "BACKSPACE");
|
|
23237
|
+
};
|
|
23230
23238
|
const renderKey = (key, index2) => {
|
|
23231
23239
|
const isNumberKey = /^\d$/.test(key);
|
|
23232
23240
|
const isBackspace = key === "BACKSPACE";
|
|
@@ -23244,17 +23252,13 @@ const NumberKeyboard = (p) => {
|
|
|
23244
23252
|
key,
|
|
23245
23253
|
className,
|
|
23246
23254
|
// 仅为 backspace 绑定,支持长按快速删除
|
|
23247
|
-
onTouchStart: isBackspace ?
|
|
23248
|
-
|
|
23249
|
-
|
|
23250
|
-
} : void 0,
|
|
23251
|
-
onTouchEnd: isBackspace ? (e2) => {
|
|
23252
|
-
stopContinueClear();
|
|
23253
|
-
onKeyPress(e2, key);
|
|
23254
|
-
} : void 0,
|
|
23255
|
+
onTouchStart: isBackspace ? onBackspaceTouchStart : void 0,
|
|
23256
|
+
onTouchEnd: isBackspace ? onBackspaceTouchEnd : void 0,
|
|
23257
|
+
onTouchCancel: isBackspace ? stopContinueClear : void 0,
|
|
23255
23258
|
// <div role="button" title="1" onTouchEnd={e => {}}>1</div> 安卓上 talback 可读不可点
|
|
23256
23259
|
// see https://ua-gilded-eef7f9.netlify.app/grid-button-bug.html
|
|
23257
|
-
//
|
|
23260
|
+
// 所以普通按钮绑定 click 事件,而 backspace 仍然额外绑定 touch 事件支持长按删除
|
|
23261
|
+
// backspace touchend 时会 preventDefault 阻止其后续 click 事件
|
|
23258
23262
|
onClick: (e2) => {
|
|
23259
23263
|
stopContinueClear();
|
|
23260
23264
|
onKeyPress(e2, key);
|
|
@@ -23273,10 +23277,7 @@ const NumberKeyboard = (p) => {
|
|
|
23273
23277
|
forceRender: props.forceRender
|
|
23274
23278
|
}, withNativeProps(props, React__default.createElement("div", {
|
|
23275
23279
|
ref: keyboardRef,
|
|
23276
|
-
className: classPrefix$x
|
|
23277
|
-
onMouseDown: (e2) => {
|
|
23278
|
-
e2.preventDefault();
|
|
23279
|
-
}
|
|
23280
|
+
className: classPrefix$x
|
|
23280
23281
|
}, renderHeader(), React__default.createElement("div", {
|
|
23281
23282
|
className: `${classPrefix$x}-wrapper`
|
|
23282
23283
|
}, React__default.createElement("div", {
|
|
@@ -23287,13 +23288,9 @@ const NumberKeyboard = (p) => {
|
|
|
23287
23288
|
className: `${classPrefix$x}-confirm`
|
|
23288
23289
|
}, React__default.createElement("div", {
|
|
23289
23290
|
className: `${classPrefix$x}-key ${classPrefix$x}-key-extra ${classPrefix$x}-key-bs`,
|
|
23290
|
-
onTouchStart:
|
|
23291
|
-
|
|
23292
|
-
|
|
23293
|
-
onTouchEnd: (e2) => {
|
|
23294
|
-
stopContinueClear();
|
|
23295
|
-
onKeyPress(e2, "BACKSPACE");
|
|
23296
|
-
},
|
|
23291
|
+
onTouchStart: onBackspaceTouchStart,
|
|
23292
|
+
onTouchEnd: onBackspaceTouchEnd,
|
|
23293
|
+
onTouchCancel: stopContinueClear,
|
|
23297
23294
|
onClick: (e2) => {
|
|
23298
23295
|
stopContinueClear();
|
|
23299
23296
|
onKeyPress(e2, "BACKSPACE");
|
|
@@ -27577,6 +27574,20 @@ const Multiple = (p) => {
|
|
|
27577
27574
|
const index = attachPropertiesToComponent(TreeSelect, {
|
|
27578
27575
|
Multiple
|
|
27579
27576
|
});
|
|
27577
|
+
function useClickOutside(handler, ref2) {
|
|
27578
|
+
useEffect(() => {
|
|
27579
|
+
function handleClick(event) {
|
|
27580
|
+
if (!ref2.current || ref2.current.contains(event.target)) {
|
|
27581
|
+
return;
|
|
27582
|
+
}
|
|
27583
|
+
handler(event);
|
|
27584
|
+
}
|
|
27585
|
+
document.addEventListener("click", handleClick, true);
|
|
27586
|
+
return () => {
|
|
27587
|
+
document.removeEventListener("click", handleClick, true);
|
|
27588
|
+
};
|
|
27589
|
+
}, [handler, ref2]);
|
|
27590
|
+
}
|
|
27580
27591
|
const classPrefix$2 = "adm-virtual-input";
|
|
27581
27592
|
const defaultProps$2 = {
|
|
27582
27593
|
defaultValue: "",
|
|
@@ -27604,15 +27615,10 @@ const VirtualInput = forwardRef((props, ref2) => {
|
|
|
27604
27615
|
const touchMoveTimeoutRef = useRef();
|
|
27605
27616
|
const clearIcon = mergeProp(React__default.createElement(CloseCircleFill, null), componentConfig.clearIcon, props.clearIcon);
|
|
27606
27617
|
function scrollToEnd() {
|
|
27607
|
-
const root2 = rootRef.current;
|
|
27608
|
-
if (!root2)
|
|
27609
|
-
return;
|
|
27610
|
-
if (document.activeElement !== root2) {
|
|
27611
|
-
return;
|
|
27612
|
-
}
|
|
27613
27618
|
const content = contentRef.current;
|
|
27614
|
-
if (!content)
|
|
27619
|
+
if (!content) {
|
|
27615
27620
|
return;
|
|
27621
|
+
}
|
|
27616
27622
|
content.scrollLeft = content.clientWidth;
|
|
27617
27623
|
}
|
|
27618
27624
|
useEffect(() => {
|
|
@@ -27642,23 +27648,31 @@ const VirtualInput = forwardRef((props, ref2) => {
|
|
|
27642
27648
|
useImperativeHandle(ref2, () => ({
|
|
27643
27649
|
focus: () => {
|
|
27644
27650
|
var _a;
|
|
27645
|
-
(_a =
|
|
27651
|
+
(_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
27646
27652
|
},
|
|
27647
27653
|
blur: () => {
|
|
27648
27654
|
var _a;
|
|
27649
|
-
(_a =
|
|
27655
|
+
(_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
27656
|
+
setBlur();
|
|
27650
27657
|
}
|
|
27651
27658
|
}));
|
|
27652
|
-
function
|
|
27659
|
+
function setFocus() {
|
|
27653
27660
|
var _a;
|
|
27661
|
+
if (hasFocus)
|
|
27662
|
+
return;
|
|
27654
27663
|
setHasFocus(true);
|
|
27655
27664
|
(_a = mergedProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
|
27656
27665
|
}
|
|
27657
|
-
function
|
|
27666
|
+
function setBlur() {
|
|
27658
27667
|
var _a;
|
|
27668
|
+
if (!hasFocus)
|
|
27669
|
+
return;
|
|
27659
27670
|
setHasFocus(false);
|
|
27660
27671
|
(_a = mergedProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
|
27661
27672
|
}
|
|
27673
|
+
useClickOutside(() => {
|
|
27674
|
+
setBlur();
|
|
27675
|
+
}, rootRef);
|
|
27662
27676
|
const keyboard = mergedProps.keyboard;
|
|
27663
27677
|
const keyboardElement = keyboard && React__default.cloneElement(keyboard, {
|
|
27664
27678
|
onInput: (v) => {
|
|
@@ -27685,23 +27699,19 @@ const VirtualInput = forwardRef((props, ref2) => {
|
|
|
27685
27699
|
},
|
|
27686
27700
|
visible: hasFocus,
|
|
27687
27701
|
onClose: () => {
|
|
27688
|
-
var _a, _b
|
|
27689
|
-
|
|
27690
|
-
|
|
27691
|
-
activeElement.blur();
|
|
27692
|
-
} else {
|
|
27693
|
-
(_b = rootRef.current) === null || _b === void 0 ? void 0 : _b.blur();
|
|
27694
|
-
}
|
|
27695
|
-
(_d = (_c = keyboard.props).onClose) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
27702
|
+
var _a, _b;
|
|
27703
|
+
setBlur();
|
|
27704
|
+
(_b = (_a = keyboard.props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
27696
27705
|
},
|
|
27697
27706
|
getContainer: null
|
|
27698
27707
|
});
|
|
27699
|
-
const setCaretPositionToEnd = () => {
|
|
27700
|
-
var _a, _b;
|
|
27708
|
+
const setCaretPositionToEnd = (e2) => {
|
|
27709
|
+
var _a, _b, _c;
|
|
27701
27710
|
if (caretPosition !== value.length) {
|
|
27702
27711
|
setCaretPosition(value.length);
|
|
27703
27712
|
(_b = (_a = mergedProps.cursor) === null || _a === void 0 ? void 0 : _a.onMove) === null || _b === void 0 ? void 0 : _b.call(_a, value.length);
|
|
27704
27713
|
}
|
|
27714
|
+
(_c = mergedProps.onClick) === null || _c === void 0 ? void 0 : _c.call(mergedProps, e2);
|
|
27705
27715
|
};
|
|
27706
27716
|
const changeCaretPosition = (index2) => (e2) => {
|
|
27707
27717
|
var _a, _b, _c;
|
|
@@ -27768,23 +27778,27 @@ const VirtualInput = forwardRef((props, ref2) => {
|
|
|
27768
27778
|
ref: rootRef,
|
|
27769
27779
|
className: classNames(classPrefix$2, {
|
|
27770
27780
|
[`${classPrefix$2}-disabled`]: mergedProps.disabled,
|
|
27771
|
-
[`${classPrefix$2}-caret-dragging`]: isCaretDragging
|
|
27772
|
-
|
|
27773
|
-
|
|
27774
|
-
role: "textbox",
|
|
27775
|
-
onFocus,
|
|
27776
|
-
onBlur,
|
|
27777
|
-
onClick: mergedProps.onClick
|
|
27781
|
+
[`${classPrefix$2}-caret-dragging`]: isCaretDragging,
|
|
27782
|
+
[`${classPrefix$2}-focused`]: hasFocus
|
|
27783
|
+
})
|
|
27778
27784
|
}, React__default.createElement("div", {
|
|
27779
27785
|
className: `${classPrefix$2}-content`,
|
|
27780
27786
|
ref: contentRef,
|
|
27781
27787
|
"aria-disabled": mergedProps.disabled,
|
|
27782
|
-
"aria-label": mergedProps.placeholder,
|
|
27788
|
+
"aria-label": value || mergedProps.placeholder,
|
|
27789
|
+
role: "textbox",
|
|
27790
|
+
tabIndex: mergedProps.disabled ? void 0 : 0,
|
|
27791
|
+
// note: 这里增加 onFocus 有两个目的:
|
|
27792
|
+
// 1. 在安卓 talkback 模式下,role=textbox 的元素双击后只会触发 focus 而非 click
|
|
27793
|
+
// 2. 处理 content 框点击、单个字符点击时,不用再额外处理 focus 逻辑,因为 focus 事件会先触发
|
|
27794
|
+
onFocus: setFocus,
|
|
27783
27795
|
onClick: setCaretPositionToEnd,
|
|
27784
27796
|
onTouchStart: handleTouchStart,
|
|
27785
27797
|
onTouchMove: handleTouchMove,
|
|
27786
27798
|
onTouchEnd: handleTouchEnd
|
|
27787
|
-
},
|
|
27799
|
+
}, React__default.createElement("span", {
|
|
27800
|
+
className: `${classPrefix$2}-trap`
|
|
27801
|
+
}), chars.slice(0, caretPosition).map((i2, index2) => React__default.createElement("span", {
|
|
27788
27802
|
ref: index2 === 0 ? charRef : void 0,
|
|
27789
27803
|
key: index2,
|
|
27790
27804
|
onClick: changeCaretPosition(index2)
|