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
|
@@ -23207,7 +23207,6 @@ const NumberKeyboard = (p) => {
|
|
|
23207
23207
|
};
|
|
23208
23208
|
const onKeyPress = (e2, key) => {
|
|
23209
23209
|
var _a, _b;
|
|
23210
|
-
e2.preventDefault();
|
|
23211
23210
|
switch (key) {
|
|
23212
23211
|
case "BACKSPACE":
|
|
23213
23212
|
onDelete === null || onDelete === void 0 ? void 0 : onDelete();
|
|
@@ -23245,39 +23244,51 @@ const NumberKeyboard = (p) => {
|
|
|
23245
23244
|
tabIndex: -1
|
|
23246
23245
|
}, React$3.createElement(DownOutline, null)));
|
|
23247
23246
|
};
|
|
23247
|
+
const onBackspaceTouchStart = () => {
|
|
23248
|
+
stopContinueClear();
|
|
23249
|
+
startContinueClear();
|
|
23250
|
+
};
|
|
23251
|
+
const onBackspaceTouchEnd = (e2) => {
|
|
23252
|
+
e2.preventDefault();
|
|
23253
|
+
stopContinueClear();
|
|
23254
|
+
onKeyPress(e2, "BACKSPACE");
|
|
23255
|
+
};
|
|
23248
23256
|
const renderKey = (key, index2) => {
|
|
23249
|
-
const
|
|
23250
|
-
|
|
23257
|
+
const keyConfig = typeof key === "string" ? {
|
|
23258
|
+
key,
|
|
23259
|
+
title: key
|
|
23260
|
+
} : key;
|
|
23261
|
+
const realKey = keyConfig.key;
|
|
23262
|
+
const isNumberKey = /^\d$/.test(realKey);
|
|
23263
|
+
const isBackspace = realKey === "BACKSPACE";
|
|
23264
|
+
const title2 = isBackspace ? locale.Input.clear : keyConfig.title;
|
|
23251
23265
|
const className = classNames(`${classPrefix$x}-key`, {
|
|
23252
23266
|
[`${classPrefix$x}-key-number`]: isNumberKey,
|
|
23253
|
-
[`${classPrefix$x}-key-sign`]: !isNumberKey &&
|
|
23267
|
+
[`${classPrefix$x}-key-sign`]: !isNumberKey && realKey,
|
|
23254
23268
|
[`${classPrefix$x}-key-mid`]: index2 === 9 && !!confirmText && keys2.length < 12
|
|
23255
23269
|
});
|
|
23256
|
-
const ariaProps =
|
|
23270
|
+
const ariaProps = realKey ? {
|
|
23257
23271
|
role: "button",
|
|
23258
|
-
title:
|
|
23272
|
+
title: title2,
|
|
23273
|
+
"aria-label": title2,
|
|
23259
23274
|
tabIndex: -1
|
|
23260
23275
|
} : void 0;
|
|
23261
23276
|
return React$3.createElement("div", Object.assign({
|
|
23262
|
-
key,
|
|
23277
|
+
key: realKey,
|
|
23263
23278
|
className,
|
|
23264
23279
|
// 仅为 backspace 绑定,支持长按快速删除
|
|
23265
|
-
onTouchStart: isBackspace ?
|
|
23266
|
-
|
|
23267
|
-
|
|
23268
|
-
} : void 0,
|
|
23269
|
-
onTouchEnd: isBackspace ? (e2) => {
|
|
23270
|
-
stopContinueClear();
|
|
23271
|
-
onKeyPress(e2, key);
|
|
23272
|
-
} : void 0,
|
|
23280
|
+
onTouchStart: isBackspace ? onBackspaceTouchStart : void 0,
|
|
23281
|
+
onTouchEnd: isBackspace ? onBackspaceTouchEnd : void 0,
|
|
23282
|
+
onTouchCancel: isBackspace ? stopContinueClear : void 0,
|
|
23273
23283
|
// <div role="button" title="1" onTouchEnd={e => {}}>1</div> 安卓上 talback 可读不可点
|
|
23274
23284
|
// see https://ua-gilded-eef7f9.netlify.app/grid-button-bug.html
|
|
23275
|
-
//
|
|
23285
|
+
// 所以普通按钮绑定 click 事件,而 backspace 仍然额外绑定 touch 事件支持长按删除
|
|
23286
|
+
// backspace touchend 时会 preventDefault 阻止其后续 click 事件
|
|
23276
23287
|
onClick: (e2) => {
|
|
23277
23288
|
stopContinueClear();
|
|
23278
|
-
onKeyPress(e2,
|
|
23289
|
+
onKeyPress(e2, realKey);
|
|
23279
23290
|
}
|
|
23280
|
-
}, ariaProps), isBackspace ? React$3.createElement(TextDeletionOutline, null) :
|
|
23291
|
+
}, ariaProps), isBackspace ? React$3.createElement(TextDeletionOutline, null) : realKey);
|
|
23281
23292
|
};
|
|
23282
23293
|
return React$3.createElement(Popup, {
|
|
23283
23294
|
visible,
|
|
@@ -23291,10 +23302,7 @@ const NumberKeyboard = (p) => {
|
|
|
23291
23302
|
forceRender: props.forceRender
|
|
23292
23303
|
}, withNativeProps(props, React$3.createElement("div", {
|
|
23293
23304
|
ref: keyboardRef,
|
|
23294
|
-
className: classPrefix$x
|
|
23295
|
-
onMouseDown: (e2) => {
|
|
23296
|
-
e2.preventDefault();
|
|
23297
|
-
}
|
|
23305
|
+
className: classPrefix$x
|
|
23298
23306
|
}, renderHeader(), React$3.createElement("div", {
|
|
23299
23307
|
className: `${classPrefix$x}-wrapper`
|
|
23300
23308
|
}, React$3.createElement("div", {
|
|
@@ -23305,13 +23313,9 @@ const NumberKeyboard = (p) => {
|
|
|
23305
23313
|
className: `${classPrefix$x}-confirm`
|
|
23306
23314
|
}, React$3.createElement("div", {
|
|
23307
23315
|
className: `${classPrefix$x}-key ${classPrefix$x}-key-extra ${classPrefix$x}-key-bs`,
|
|
23308
|
-
onTouchStart:
|
|
23309
|
-
|
|
23310
|
-
|
|
23311
|
-
onTouchEnd: (e2) => {
|
|
23312
|
-
stopContinueClear();
|
|
23313
|
-
onKeyPress(e2, "BACKSPACE");
|
|
23314
|
-
},
|
|
23316
|
+
onTouchStart: onBackspaceTouchStart,
|
|
23317
|
+
onTouchEnd: onBackspaceTouchEnd,
|
|
23318
|
+
onTouchCancel: stopContinueClear,
|
|
23315
23319
|
onClick: (e2) => {
|
|
23316
23320
|
stopContinueClear();
|
|
23317
23321
|
onKeyPress(e2, "BACKSPACE");
|
|
@@ -27595,6 +27599,20 @@ const Multiple = (p) => {
|
|
|
27595
27599
|
const index = attachPropertiesToComponent(TreeSelect, {
|
|
27596
27600
|
Multiple
|
|
27597
27601
|
});
|
|
27602
|
+
function useClickOutside(handler, ref2) {
|
|
27603
|
+
React$3.useEffect(() => {
|
|
27604
|
+
function handleClick(event) {
|
|
27605
|
+
if (!ref2.current || ref2.current.contains(event.target)) {
|
|
27606
|
+
return;
|
|
27607
|
+
}
|
|
27608
|
+
handler(event);
|
|
27609
|
+
}
|
|
27610
|
+
document.addEventListener("click", handleClick, true);
|
|
27611
|
+
return () => {
|
|
27612
|
+
document.removeEventListener("click", handleClick, true);
|
|
27613
|
+
};
|
|
27614
|
+
}, [handler, ref2]);
|
|
27615
|
+
}
|
|
27598
27616
|
const classPrefix$2 = "adm-virtual-input";
|
|
27599
27617
|
const defaultProps$2 = {
|
|
27600
27618
|
defaultValue: "",
|
|
@@ -27622,15 +27640,10 @@ const VirtualInput = React$3.forwardRef((props, ref2) => {
|
|
|
27622
27640
|
const touchMoveTimeoutRef = React$3.useRef();
|
|
27623
27641
|
const clearIcon = mergeProp(React$3.createElement(CloseCircleFill, null), componentConfig.clearIcon, props.clearIcon);
|
|
27624
27642
|
function scrollToEnd() {
|
|
27625
|
-
const root2 = rootRef.current;
|
|
27626
|
-
if (!root2)
|
|
27627
|
-
return;
|
|
27628
|
-
if (document.activeElement !== root2) {
|
|
27629
|
-
return;
|
|
27630
|
-
}
|
|
27631
27643
|
const content = contentRef.current;
|
|
27632
|
-
if (!content)
|
|
27644
|
+
if (!content) {
|
|
27633
27645
|
return;
|
|
27646
|
+
}
|
|
27634
27647
|
content.scrollLeft = content.clientWidth;
|
|
27635
27648
|
}
|
|
27636
27649
|
React$3.useEffect(() => {
|
|
@@ -27660,23 +27673,31 @@ const VirtualInput = React$3.forwardRef((props, ref2) => {
|
|
|
27660
27673
|
React$3.useImperativeHandle(ref2, () => ({
|
|
27661
27674
|
focus: () => {
|
|
27662
27675
|
var _a;
|
|
27663
|
-
(_a =
|
|
27676
|
+
(_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
27664
27677
|
},
|
|
27665
27678
|
blur: () => {
|
|
27666
27679
|
var _a;
|
|
27667
|
-
(_a =
|
|
27680
|
+
(_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
27681
|
+
setBlur();
|
|
27668
27682
|
}
|
|
27669
27683
|
}));
|
|
27670
|
-
function
|
|
27684
|
+
function setFocus() {
|
|
27671
27685
|
var _a;
|
|
27686
|
+
if (hasFocus)
|
|
27687
|
+
return;
|
|
27672
27688
|
setHasFocus(true);
|
|
27673
27689
|
(_a = mergedProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
|
27674
27690
|
}
|
|
27675
|
-
function
|
|
27691
|
+
function setBlur() {
|
|
27676
27692
|
var _a;
|
|
27693
|
+
if (!hasFocus)
|
|
27694
|
+
return;
|
|
27677
27695
|
setHasFocus(false);
|
|
27678
27696
|
(_a = mergedProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
|
27679
27697
|
}
|
|
27698
|
+
useClickOutside(() => {
|
|
27699
|
+
setBlur();
|
|
27700
|
+
}, rootRef);
|
|
27680
27701
|
const keyboard = mergedProps.keyboard;
|
|
27681
27702
|
const keyboardElement = keyboard && React$3.cloneElement(keyboard, {
|
|
27682
27703
|
onInput: (v) => {
|
|
@@ -27703,23 +27724,19 @@ const VirtualInput = React$3.forwardRef((props, ref2) => {
|
|
|
27703
27724
|
},
|
|
27704
27725
|
visible: hasFocus,
|
|
27705
27726
|
onClose: () => {
|
|
27706
|
-
var _a, _b
|
|
27707
|
-
|
|
27708
|
-
|
|
27709
|
-
activeElement.blur();
|
|
27710
|
-
} else {
|
|
27711
|
-
(_b = rootRef.current) === null || _b === void 0 ? void 0 : _b.blur();
|
|
27712
|
-
}
|
|
27713
|
-
(_d = (_c = keyboard.props).onClose) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
27727
|
+
var _a, _b;
|
|
27728
|
+
setBlur();
|
|
27729
|
+
(_b = (_a = keyboard.props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
27714
27730
|
},
|
|
27715
27731
|
getContainer: null
|
|
27716
27732
|
});
|
|
27717
|
-
const setCaretPositionToEnd = () => {
|
|
27718
|
-
var _a, _b;
|
|
27733
|
+
const setCaretPositionToEnd = (e2) => {
|
|
27734
|
+
var _a, _b, _c;
|
|
27719
27735
|
if (caretPosition !== value.length) {
|
|
27720
27736
|
setCaretPosition(value.length);
|
|
27721
27737
|
(_b = (_a = mergedProps.cursor) === null || _a === void 0 ? void 0 : _a.onMove) === null || _b === void 0 ? void 0 : _b.call(_a, value.length);
|
|
27722
27738
|
}
|
|
27739
|
+
(_c = mergedProps.onClick) === null || _c === void 0 ? void 0 : _c.call(mergedProps, e2);
|
|
27723
27740
|
};
|
|
27724
27741
|
const changeCaretPosition = (index2) => (e2) => {
|
|
27725
27742
|
var _a, _b, _c;
|
|
@@ -27786,23 +27803,27 @@ const VirtualInput = React$3.forwardRef((props, ref2) => {
|
|
|
27786
27803
|
ref: rootRef,
|
|
27787
27804
|
className: classNames(classPrefix$2, {
|
|
27788
27805
|
[`${classPrefix$2}-disabled`]: mergedProps.disabled,
|
|
27789
|
-
[`${classPrefix$2}-caret-dragging`]: isCaretDragging
|
|
27790
|
-
|
|
27791
|
-
|
|
27792
|
-
role: "textbox",
|
|
27793
|
-
onFocus,
|
|
27794
|
-
onBlur,
|
|
27795
|
-
onClick: mergedProps.onClick
|
|
27806
|
+
[`${classPrefix$2}-caret-dragging`]: isCaretDragging,
|
|
27807
|
+
[`${classPrefix$2}-focused`]: hasFocus
|
|
27808
|
+
})
|
|
27796
27809
|
}, React$3.createElement("div", {
|
|
27797
27810
|
className: `${classPrefix$2}-content`,
|
|
27798
27811
|
ref: contentRef,
|
|
27799
27812
|
"aria-disabled": mergedProps.disabled,
|
|
27800
|
-
"aria-label": mergedProps.placeholder,
|
|
27813
|
+
"aria-label": value || mergedProps.placeholder,
|
|
27814
|
+
role: "textbox",
|
|
27815
|
+
tabIndex: mergedProps.disabled ? void 0 : 0,
|
|
27816
|
+
// note: 这里增加 onFocus 有两个目的:
|
|
27817
|
+
// 1. 在安卓 talkback 模式下,role=textbox 的元素双击后只会触发 focus 而非 click
|
|
27818
|
+
// 2. 处理 content 框点击、单个字符点击时,不用再额外处理 focus 逻辑,因为 focus 事件会先触发
|
|
27819
|
+
onFocus: setFocus,
|
|
27801
27820
|
onClick: setCaretPositionToEnd,
|
|
27802
27821
|
onTouchStart: handleTouchStart,
|
|
27803
27822
|
onTouchMove: handleTouchMove,
|
|
27804
27823
|
onTouchEnd: handleTouchEnd
|
|
27805
|
-
},
|
|
27824
|
+
}, React$3.createElement("span", {
|
|
27825
|
+
className: `${classPrefix$2}-trap`
|
|
27826
|
+
}), chars.slice(0, caretPosition).map((i2, index2) => React$3.createElement("span", {
|
|
27806
27827
|
ref: index2 === 0 ? charRef : void 0,
|
|
27807
27828
|
key: index2,
|
|
27808
27829
|
onClick: changeCaretPosition(index2)
|