antd-mobile 5.41.1 → 5.42.0-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.
- package/2x/bundle/antd-mobile.cjs.development.js +80 -59
- package/2x/bundle/antd-mobile.cjs.js +6 -6
- package/2x/bundle/antd-mobile.es.development.js +80 -59
- package/2x/bundle/antd-mobile.es.js +1743 -1729
- package/2x/bundle/antd-mobile.umd.development.js +80 -59
- 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.d.ts +6 -1
- package/2x/cjs/components/number-keyboard/number-keyboard.js +33 -29
- 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.d.ts +6 -1
- package/2x/es/components/number-keyboard/number-keyboard.js +33 -29
- 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 +80 -59
- package/bundle/antd-mobile.cjs.js +6 -6
- package/bundle/antd-mobile.compatible.umd.js +1 -1
- package/bundle/antd-mobile.es.development.js +80 -59
- package/bundle/antd-mobile.es.js +1743 -1729
- package/bundle/antd-mobile.umd.development.js +80 -59
- 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.d.ts +6 -1
- package/cjs/components/number-keyboard/number-keyboard.js +33 -29
- 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.d.ts +6 -1
- package/es/components/number-keyboard/number-keyboard.js +33 -29
- 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,39 +23226,51 @@ 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
|
-
const
|
|
23232
|
-
|
|
23239
|
+
const keyConfig = typeof key === "string" ? {
|
|
23240
|
+
key,
|
|
23241
|
+
title: key
|
|
23242
|
+
} : key;
|
|
23243
|
+
const realKey = keyConfig.key;
|
|
23244
|
+
const isNumberKey = /^\d$/.test(realKey);
|
|
23245
|
+
const isBackspace = realKey === "BACKSPACE";
|
|
23246
|
+
const title2 = isBackspace ? locale.Input.clear : keyConfig.title;
|
|
23233
23247
|
const className = classNames(`${classPrefix$x}-key`, {
|
|
23234
23248
|
[`${classPrefix$x}-key-number`]: isNumberKey,
|
|
23235
|
-
[`${classPrefix$x}-key-sign`]: !isNumberKey &&
|
|
23249
|
+
[`${classPrefix$x}-key-sign`]: !isNumberKey && realKey,
|
|
23236
23250
|
[`${classPrefix$x}-key-mid`]: index2 === 9 && !!confirmText && keys2.length < 12
|
|
23237
23251
|
});
|
|
23238
|
-
const ariaProps =
|
|
23252
|
+
const ariaProps = realKey ? {
|
|
23239
23253
|
role: "button",
|
|
23240
|
-
title:
|
|
23254
|
+
title: title2,
|
|
23255
|
+
"aria-label": title2,
|
|
23241
23256
|
tabIndex: -1
|
|
23242
23257
|
} : void 0;
|
|
23243
23258
|
return React__default.createElement("div", Object.assign({
|
|
23244
|
-
key,
|
|
23259
|
+
key: realKey,
|
|
23245
23260
|
className,
|
|
23246
23261
|
// 仅为 backspace 绑定,支持长按快速删除
|
|
23247
|
-
onTouchStart: isBackspace ?
|
|
23248
|
-
|
|
23249
|
-
|
|
23250
|
-
} : void 0,
|
|
23251
|
-
onTouchEnd: isBackspace ? (e2) => {
|
|
23252
|
-
stopContinueClear();
|
|
23253
|
-
onKeyPress(e2, key);
|
|
23254
|
-
} : void 0,
|
|
23262
|
+
onTouchStart: isBackspace ? onBackspaceTouchStart : void 0,
|
|
23263
|
+
onTouchEnd: isBackspace ? onBackspaceTouchEnd : void 0,
|
|
23264
|
+
onTouchCancel: isBackspace ? stopContinueClear : void 0,
|
|
23255
23265
|
// <div role="button" title="1" onTouchEnd={e => {}}>1</div> 安卓上 talback 可读不可点
|
|
23256
23266
|
// see https://ua-gilded-eef7f9.netlify.app/grid-button-bug.html
|
|
23257
|
-
//
|
|
23267
|
+
// 所以普通按钮绑定 click 事件,而 backspace 仍然额外绑定 touch 事件支持长按删除
|
|
23268
|
+
// backspace touchend 时会 preventDefault 阻止其后续 click 事件
|
|
23258
23269
|
onClick: (e2) => {
|
|
23259
23270
|
stopContinueClear();
|
|
23260
|
-
onKeyPress(e2,
|
|
23271
|
+
onKeyPress(e2, realKey);
|
|
23261
23272
|
}
|
|
23262
|
-
}, ariaProps), isBackspace ? React__default.createElement(TextDeletionOutline, null) :
|
|
23273
|
+
}, ariaProps), isBackspace ? React__default.createElement(TextDeletionOutline, null) : realKey);
|
|
23263
23274
|
};
|
|
23264
23275
|
return React__default.createElement(Popup, {
|
|
23265
23276
|
visible,
|
|
@@ -23273,10 +23284,7 @@ const NumberKeyboard = (p) => {
|
|
|
23273
23284
|
forceRender: props.forceRender
|
|
23274
23285
|
}, withNativeProps(props, React__default.createElement("div", {
|
|
23275
23286
|
ref: keyboardRef,
|
|
23276
|
-
className: classPrefix$x
|
|
23277
|
-
onMouseDown: (e2) => {
|
|
23278
|
-
e2.preventDefault();
|
|
23279
|
-
}
|
|
23287
|
+
className: classPrefix$x
|
|
23280
23288
|
}, renderHeader(), React__default.createElement("div", {
|
|
23281
23289
|
className: `${classPrefix$x}-wrapper`
|
|
23282
23290
|
}, React__default.createElement("div", {
|
|
@@ -23287,13 +23295,9 @@ const NumberKeyboard = (p) => {
|
|
|
23287
23295
|
className: `${classPrefix$x}-confirm`
|
|
23288
23296
|
}, React__default.createElement("div", {
|
|
23289
23297
|
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
|
-
},
|
|
23298
|
+
onTouchStart: onBackspaceTouchStart,
|
|
23299
|
+
onTouchEnd: onBackspaceTouchEnd,
|
|
23300
|
+
onTouchCancel: stopContinueClear,
|
|
23297
23301
|
onClick: (e2) => {
|
|
23298
23302
|
stopContinueClear();
|
|
23299
23303
|
onKeyPress(e2, "BACKSPACE");
|
|
@@ -27577,6 +27581,20 @@ const Multiple = (p) => {
|
|
|
27577
27581
|
const index = attachPropertiesToComponent(TreeSelect, {
|
|
27578
27582
|
Multiple
|
|
27579
27583
|
});
|
|
27584
|
+
function useClickOutside(handler, ref2) {
|
|
27585
|
+
useEffect(() => {
|
|
27586
|
+
function handleClick(event) {
|
|
27587
|
+
if (!ref2.current || ref2.current.contains(event.target)) {
|
|
27588
|
+
return;
|
|
27589
|
+
}
|
|
27590
|
+
handler(event);
|
|
27591
|
+
}
|
|
27592
|
+
document.addEventListener("click", handleClick, true);
|
|
27593
|
+
return () => {
|
|
27594
|
+
document.removeEventListener("click", handleClick, true);
|
|
27595
|
+
};
|
|
27596
|
+
}, [handler, ref2]);
|
|
27597
|
+
}
|
|
27580
27598
|
const classPrefix$2 = "adm-virtual-input";
|
|
27581
27599
|
const defaultProps$2 = {
|
|
27582
27600
|
defaultValue: "",
|
|
@@ -27604,15 +27622,10 @@ const VirtualInput = forwardRef((props, ref2) => {
|
|
|
27604
27622
|
const touchMoveTimeoutRef = useRef();
|
|
27605
27623
|
const clearIcon = mergeProp(React__default.createElement(CloseCircleFill, null), componentConfig.clearIcon, props.clearIcon);
|
|
27606
27624
|
function scrollToEnd() {
|
|
27607
|
-
const root2 = rootRef.current;
|
|
27608
|
-
if (!root2)
|
|
27609
|
-
return;
|
|
27610
|
-
if (document.activeElement !== root2) {
|
|
27611
|
-
return;
|
|
27612
|
-
}
|
|
27613
27625
|
const content = contentRef.current;
|
|
27614
|
-
if (!content)
|
|
27626
|
+
if (!content) {
|
|
27615
27627
|
return;
|
|
27628
|
+
}
|
|
27616
27629
|
content.scrollLeft = content.clientWidth;
|
|
27617
27630
|
}
|
|
27618
27631
|
useEffect(() => {
|
|
@@ -27642,23 +27655,31 @@ const VirtualInput = forwardRef((props, ref2) => {
|
|
|
27642
27655
|
useImperativeHandle(ref2, () => ({
|
|
27643
27656
|
focus: () => {
|
|
27644
27657
|
var _a;
|
|
27645
|
-
(_a =
|
|
27658
|
+
(_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
27646
27659
|
},
|
|
27647
27660
|
blur: () => {
|
|
27648
27661
|
var _a;
|
|
27649
|
-
(_a =
|
|
27662
|
+
(_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
27663
|
+
setBlur();
|
|
27650
27664
|
}
|
|
27651
27665
|
}));
|
|
27652
|
-
function
|
|
27666
|
+
function setFocus() {
|
|
27653
27667
|
var _a;
|
|
27668
|
+
if (hasFocus)
|
|
27669
|
+
return;
|
|
27654
27670
|
setHasFocus(true);
|
|
27655
27671
|
(_a = mergedProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
|
27656
27672
|
}
|
|
27657
|
-
function
|
|
27673
|
+
function setBlur() {
|
|
27658
27674
|
var _a;
|
|
27675
|
+
if (!hasFocus)
|
|
27676
|
+
return;
|
|
27659
27677
|
setHasFocus(false);
|
|
27660
27678
|
(_a = mergedProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
|
27661
27679
|
}
|
|
27680
|
+
useClickOutside(() => {
|
|
27681
|
+
setBlur();
|
|
27682
|
+
}, rootRef);
|
|
27662
27683
|
const keyboard = mergedProps.keyboard;
|
|
27663
27684
|
const keyboardElement = keyboard && React__default.cloneElement(keyboard, {
|
|
27664
27685
|
onInput: (v) => {
|
|
@@ -27685,23 +27706,19 @@ const VirtualInput = forwardRef((props, ref2) => {
|
|
|
27685
27706
|
},
|
|
27686
27707
|
visible: hasFocus,
|
|
27687
27708
|
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);
|
|
27709
|
+
var _a, _b;
|
|
27710
|
+
setBlur();
|
|
27711
|
+
(_b = (_a = keyboard.props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
27696
27712
|
},
|
|
27697
27713
|
getContainer: null
|
|
27698
27714
|
});
|
|
27699
|
-
const setCaretPositionToEnd = () => {
|
|
27700
|
-
var _a, _b;
|
|
27715
|
+
const setCaretPositionToEnd = (e2) => {
|
|
27716
|
+
var _a, _b, _c;
|
|
27701
27717
|
if (caretPosition !== value.length) {
|
|
27702
27718
|
setCaretPosition(value.length);
|
|
27703
27719
|
(_b = (_a = mergedProps.cursor) === null || _a === void 0 ? void 0 : _a.onMove) === null || _b === void 0 ? void 0 : _b.call(_a, value.length);
|
|
27704
27720
|
}
|
|
27721
|
+
(_c = mergedProps.onClick) === null || _c === void 0 ? void 0 : _c.call(mergedProps, e2);
|
|
27705
27722
|
};
|
|
27706
27723
|
const changeCaretPosition = (index2) => (e2) => {
|
|
27707
27724
|
var _a, _b, _c;
|
|
@@ -27768,23 +27785,27 @@ const VirtualInput = forwardRef((props, ref2) => {
|
|
|
27768
27785
|
ref: rootRef,
|
|
27769
27786
|
className: classNames(classPrefix$2, {
|
|
27770
27787
|
[`${classPrefix$2}-disabled`]: mergedProps.disabled,
|
|
27771
|
-
[`${classPrefix$2}-caret-dragging`]: isCaretDragging
|
|
27772
|
-
|
|
27773
|
-
|
|
27774
|
-
role: "textbox",
|
|
27775
|
-
onFocus,
|
|
27776
|
-
onBlur,
|
|
27777
|
-
onClick: mergedProps.onClick
|
|
27788
|
+
[`${classPrefix$2}-caret-dragging`]: isCaretDragging,
|
|
27789
|
+
[`${classPrefix$2}-focused`]: hasFocus
|
|
27790
|
+
})
|
|
27778
27791
|
}, React__default.createElement("div", {
|
|
27779
27792
|
className: `${classPrefix$2}-content`,
|
|
27780
27793
|
ref: contentRef,
|
|
27781
27794
|
"aria-disabled": mergedProps.disabled,
|
|
27782
|
-
"aria-label": mergedProps.placeholder,
|
|
27795
|
+
"aria-label": value || mergedProps.placeholder,
|
|
27796
|
+
role: "textbox",
|
|
27797
|
+
tabIndex: mergedProps.disabled ? void 0 : 0,
|
|
27798
|
+
// note: 这里增加 onFocus 有两个目的:
|
|
27799
|
+
// 1. 在安卓 talkback 模式下,role=textbox 的元素双击后只会触发 focus 而非 click
|
|
27800
|
+
// 2. 处理 content 框点击、单个字符点击时,不用再额外处理 focus 逻辑,因为 focus 事件会先触发
|
|
27801
|
+
onFocus: setFocus,
|
|
27783
27802
|
onClick: setCaretPositionToEnd,
|
|
27784
27803
|
onTouchStart: handleTouchStart,
|
|
27785
27804
|
onTouchMove: handleTouchMove,
|
|
27786
27805
|
onTouchEnd: handleTouchEnd
|
|
27787
|
-
},
|
|
27806
|
+
}, React__default.createElement("span", {
|
|
27807
|
+
className: `${classPrefix$2}-trap`
|
|
27808
|
+
}), chars.slice(0, caretPosition).map((i2, index2) => React__default.createElement("span", {
|
|
27788
27809
|
ref: index2 === 0 ? charRef : void 0,
|
|
27789
27810
|
key: index2,
|
|
27790
27811
|
onClick: changeCaretPosition(index2)
|