antd-mobile 5.0.0-rc.2 → 5.0.0-rc.3
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/cjs/components/cascader-view/cascader-view.css +7 -4
- package/2x/cjs/components/cascader-view/index.d.ts +1 -1
- package/2x/cjs/components/cascader-view/index.js +3 -3
- package/2x/cjs/components/dropdown/dropdown.d.ts +11 -4
- package/2x/cjs/components/dropdown/dropdown.js +11 -10
- package/2x/cjs/components/dropdown/index.d.ts +13 -3
- package/2x/cjs/components/dropdown/index.js +8 -1
- package/2x/cjs/components/dropdown/item.d.ts +0 -1
- package/2x/cjs/components/form/form.d.ts +3 -0
- package/2x/cjs/components/form/form.js +3 -1
- package/2x/cjs/components/form/index.d.ts +1 -0
- package/2x/cjs/components/number-keyboard/number-keyboard.js +49 -29
- package/2x/cjs/components/toast/toast.css +1 -0
- package/2x/cjs/components/virtual-input/virtual-input.css +1 -1
- package/2x/cjs/components/virtual-input/virtual-input.js +29 -14
- package/2x/es/components/cascader-view/cascader-view.css +7 -4
- package/2x/es/components/cascader-view/index.d.ts +1 -1
- package/2x/es/components/cascader-view/index.js +1 -1
- package/2x/es/components/dropdown/dropdown.d.ts +11 -4
- package/2x/es/components/dropdown/dropdown.js +12 -11
- package/2x/es/components/dropdown/index.d.ts +13 -3
- package/2x/es/components/dropdown/index.js +5 -1
- package/2x/es/components/dropdown/item.d.ts +0 -1
- package/2x/es/components/form/form.d.ts +3 -0
- package/2x/es/components/form/form.js +3 -1
- package/2x/es/components/form/index.d.ts +1 -0
- package/2x/es/components/number-keyboard/number-keyboard.js +48 -29
- package/2x/es/components/toast/toast.css +1 -0
- package/2x/es/components/virtual-input/virtual-input.css +1 -1
- package/2x/es/components/virtual-input/virtual-input.js +30 -15
- package/2x/package.json +3 -3
- package/cjs/components/cascader-view/cascader-view.css +6 -4
- package/cjs/components/cascader-view/index.d.ts +1 -1
- package/cjs/components/cascader-view/index.js +3 -3
- package/cjs/components/dropdown/dropdown.d.ts +11 -4
- package/cjs/components/dropdown/dropdown.js +11 -10
- package/cjs/components/dropdown/index.d.ts +13 -3
- package/cjs/components/dropdown/index.js +8 -1
- package/cjs/components/dropdown/item.d.ts +0 -1
- package/cjs/components/form/form.d.ts +3 -0
- package/cjs/components/form/form.js +3 -1
- package/cjs/components/form/index.d.ts +1 -0
- package/cjs/components/number-keyboard/number-keyboard.js +49 -29
- package/cjs/components/toast/toast.css +1 -0
- package/cjs/components/virtual-input/virtual-input.css +1 -1
- package/cjs/components/virtual-input/virtual-input.js +29 -14
- package/es/components/cascader-view/cascader-view.css +6 -4
- package/es/components/cascader-view/index.d.ts +1 -1
- package/es/components/cascader-view/index.js +1 -1
- package/es/components/dropdown/dropdown.d.ts +11 -4
- package/es/components/dropdown/dropdown.js +12 -11
- package/es/components/dropdown/index.d.ts +13 -3
- package/es/components/dropdown/index.js +5 -1
- package/es/components/dropdown/item.d.ts +0 -1
- package/es/components/form/form.d.ts +3 -0
- package/es/components/form/form.js +3 -1
- package/es/components/form/index.d.ts +1 -0
- package/es/components/number-keyboard/number-keyboard.js +48 -29
- package/es/components/toast/toast.css +1 -0
- package/es/components/virtual-input/virtual-input.css +1 -1
- package/es/components/virtual-input/virtual-input.js +30 -15
- package/package.json +3 -3
- package/umd/antd-mobile.js +1 -1
|
@@ -40,10 +40,10 @@ var VirtualInput = /*#__PURE__*/(0, _react.forwardRef)(function (p, ref) {
|
|
|
40
40
|
var contentRef = (0, _react.useRef)(null);
|
|
41
41
|
|
|
42
42
|
var _useState = (0, _react.useState)(false),
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
hasFocus = _useState[0],
|
|
44
|
+
setHasFocus = _useState[1];
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
function scrollToEnd() {
|
|
47
47
|
var root = rootRef.current;
|
|
48
48
|
if (!root) return;
|
|
49
49
|
|
|
@@ -56,7 +56,16 @@ var VirtualInput = /*#__PURE__*/(0, _react.forwardRef)(function (p, ref) {
|
|
|
56
56
|
content.scrollTo({
|
|
57
57
|
left: content.clientWidth
|
|
58
58
|
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
(0, _react.useLayoutEffect)(function () {
|
|
62
|
+
scrollToEnd();
|
|
59
63
|
}, [value]);
|
|
64
|
+
(0, _react.useEffect)(function () {
|
|
65
|
+
if (hasFocus) {
|
|
66
|
+
scrollToEnd();
|
|
67
|
+
}
|
|
68
|
+
}, [hasFocus]);
|
|
60
69
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
61
70
|
return {
|
|
62
71
|
focus: function focus() {
|
|
@@ -72,10 +81,17 @@ var VirtualInput = /*#__PURE__*/(0, _react.forwardRef)(function (p, ref) {
|
|
|
72
81
|
};
|
|
73
82
|
});
|
|
74
83
|
|
|
84
|
+
function onFocus() {
|
|
85
|
+
var _a;
|
|
86
|
+
|
|
87
|
+
setHasFocus(true);
|
|
88
|
+
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
89
|
+
}
|
|
90
|
+
|
|
75
91
|
function onBlur() {
|
|
76
92
|
var _a;
|
|
77
93
|
|
|
78
|
-
|
|
94
|
+
setHasFocus(false);
|
|
79
95
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
80
96
|
}
|
|
81
97
|
|
|
@@ -83,12 +99,7 @@ var VirtualInput = /*#__PURE__*/(0, _react.forwardRef)(function (p, ref) {
|
|
|
83
99
|
ref: rootRef,
|
|
84
100
|
className: (0, _classnames["default"])(classPrefix, (_classNames = {}, _classNames[classPrefix + "-disabled"] = props.disabled, _classNames)),
|
|
85
101
|
tabIndex: props.disabled ? undefined : 0,
|
|
86
|
-
onFocus:
|
|
87
|
-
var _a;
|
|
88
|
-
|
|
89
|
-
setKeyboardVisible(true);
|
|
90
|
-
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
91
|
-
},
|
|
102
|
+
onFocus: onFocus,
|
|
92
103
|
onBlur: onBlur,
|
|
93
104
|
onClick: props.onClick
|
|
94
105
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -96,9 +107,9 @@ var VirtualInput = /*#__PURE__*/(0, _react.forwardRef)(function (p, ref) {
|
|
|
96
107
|
ref: contentRef
|
|
97
108
|
}, value, /*#__PURE__*/_react["default"].createElement("div", {
|
|
98
109
|
className: classPrefix + "-caret-container"
|
|
99
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
110
|
+
}, hasFocus && /*#__PURE__*/_react["default"].createElement("div", {
|
|
100
111
|
className: classPrefix + "-caret"
|
|
101
|
-
}))), props.clearable && !!value && /*#__PURE__*/_react["default"].createElement("div", {
|
|
112
|
+
}))), props.clearable && !!value && hasFocus && /*#__PURE__*/_react["default"].createElement("div", {
|
|
102
113
|
className: classPrefix + "-clear",
|
|
103
114
|
onClick: function onClick() {
|
|
104
115
|
var _a;
|
|
@@ -115,8 +126,12 @@ var VirtualInput = /*#__PURE__*/(0, _react.forwardRef)(function (p, ref) {
|
|
|
115
126
|
onDelete: function onDelete() {
|
|
116
127
|
setValue(value.slice(0, -1));
|
|
117
128
|
},
|
|
118
|
-
visible:
|
|
119
|
-
onClose:
|
|
129
|
+
visible: hasFocus,
|
|
130
|
+
onClose: function onClose() {
|
|
131
|
+
var _a;
|
|
132
|
+
|
|
133
|
+
(_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
134
|
+
}
|
|
120
135
|
})));
|
|
121
136
|
});
|
|
122
137
|
exports.VirtualInput = VirtualInput;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.adm-cascader-view {
|
|
2
2
|
--height: fit-content;
|
|
3
3
|
}
|
|
4
|
-
.adm-cascader-view-tabs {
|
|
4
|
+
.adm-cascader-view-tabs.adm-tabs {
|
|
5
5
|
--title-font-size: 14px;
|
|
6
6
|
--content-padding: none;
|
|
7
7
|
}
|
|
@@ -12,14 +12,16 @@
|
|
|
12
12
|
text-overflow: ellipsis;
|
|
13
13
|
}
|
|
14
14
|
.adm-cascader-view-content {
|
|
15
|
-
--border-inner: none;
|
|
16
|
-
--border-bottom: none;
|
|
17
|
-
--border-top: none;
|
|
18
15
|
height: var(--height);
|
|
19
16
|
overflow-y: auto;
|
|
20
17
|
padding-top: 4px;
|
|
21
18
|
box-sizing: border-box;
|
|
22
19
|
}
|
|
20
|
+
.adm-cascader-view-content.adm-list {
|
|
21
|
+
--border-inner: none;
|
|
22
|
+
--border-bottom: none;
|
|
23
|
+
--border-top: none;
|
|
24
|
+
}
|
|
23
25
|
.adm-cascader-view-item {
|
|
24
26
|
font-size: 14px;
|
|
25
27
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CascaderView } from './cascader-view';
|
|
2
1
|
import './cascader-view.less';
|
|
2
|
+
import { CascaderView } from './cascader-view';
|
|
3
3
|
export type { CascaderViewProps, CascaderValue, CascaderValueExtend, CascaderOption, } from './cascader-view';
|
|
4
4
|
export default CascaderView;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { DropdownItemProps } from './item';
|
|
1
|
+
import React from 'react';
|
|
3
2
|
import { NativeProps } from '../../utils/native-props';
|
|
4
3
|
export declare type DropdownProps = {
|
|
5
4
|
activeKey?: string | null;
|
|
@@ -7,7 +6,15 @@ export declare type DropdownProps = {
|
|
|
7
6
|
closeOnMaskClick?: boolean;
|
|
8
7
|
onChange?: (key: string | null) => void;
|
|
9
8
|
} & NativeProps;
|
|
10
|
-
declare
|
|
11
|
-
|
|
9
|
+
export declare type DropdownRef = {
|
|
10
|
+
close: () => void;
|
|
12
11
|
};
|
|
12
|
+
declare const Dropdown: React.ForwardRefExoticComponent<{
|
|
13
|
+
activeKey?: string | null | undefined;
|
|
14
|
+
defaultActiveKey?: string | null | undefined;
|
|
15
|
+
closeOnMaskClick?: boolean | undefined;
|
|
16
|
+
onChange?: ((key: string | null) => void) | undefined;
|
|
17
|
+
} & NativeProps<never> & {
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
} & React.RefAttributes<DropdownRef>>;
|
|
13
20
|
export default Dropdown;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useClickAway } from 'ahooks';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import React, { cloneElement, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import React, { cloneElement, useEffect, useRef, useState, forwardRef, useImperativeHandle } from 'react';
|
|
4
4
|
import Popup from '../popup';
|
|
5
|
-
import
|
|
5
|
+
import { ItemChildrenWrap } from './item';
|
|
6
6
|
import { withNativeProps } from '../../utils/native-props';
|
|
7
7
|
import { mergeProps } from '../../utils/with-default-props';
|
|
8
8
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
@@ -11,8 +11,7 @@ var defaultProps = {
|
|
|
11
11
|
defaultActiveKey: null,
|
|
12
12
|
closeOnMaskClick: true
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
var Dropdown = function Dropdown(p) {
|
|
14
|
+
var Dropdown = /*#__PURE__*/forwardRef(function (p, ref) {
|
|
16
15
|
var _classNames;
|
|
17
16
|
|
|
18
17
|
var props = mergeProps(defaultProps, p);
|
|
@@ -72,6 +71,13 @@ var Dropdown = function Dropdown(p) {
|
|
|
72
71
|
return child;
|
|
73
72
|
}
|
|
74
73
|
});
|
|
74
|
+
useImperativeHandle(ref, function () {
|
|
75
|
+
return {
|
|
76
|
+
close: function close() {
|
|
77
|
+
setValue(null);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}, [setValue]);
|
|
75
81
|
return withNativeProps(props, /*#__PURE__*/React.createElement("div", {
|
|
76
82
|
className: classNames(classPrefix, (_classNames = {}, _classNames[classPrefix + "-open"] = !!value, _classNames)),
|
|
77
83
|
ref: containerRef
|
|
@@ -99,13 +105,8 @@ var Dropdown = function Dropdown(p) {
|
|
|
99
105
|
key: item.key,
|
|
100
106
|
active: isActive,
|
|
101
107
|
forceRender: item.props.forceRender,
|
|
102
|
-
destroyOnClose: item.props.destroyOnClose
|
|
103
|
-
onClick: item.props.closeOnContentClick ? function () {
|
|
104
|
-
changeActive(null);
|
|
105
|
-
} : undefined
|
|
108
|
+
destroyOnClose: item.props.destroyOnClose
|
|
106
109
|
}, item.props.children);
|
|
107
110
|
})))));
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
Dropdown.Item = Item;
|
|
111
|
+
});
|
|
111
112
|
export default Dropdown;
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import './dropdown.less';
|
|
2
|
-
|
|
3
|
-
export type { DropdownProps } from './dropdown';
|
|
3
|
+
export type { DropdownProps, DropdownRef } from './dropdown';
|
|
4
4
|
export type { DropdownItemProps } from './item';
|
|
5
|
-
|
|
5
|
+
declare const _default: import("react").ForwardRefExoticComponent<{
|
|
6
|
+
activeKey?: string | null | undefined;
|
|
7
|
+
defaultActiveKey?: string | null | undefined;
|
|
8
|
+
closeOnMaskClick?: boolean | undefined;
|
|
9
|
+
onChange?: ((key: string | null) => void) | undefined;
|
|
10
|
+
} & import("../../utils/native-props").NativeProps<never> & {
|
|
11
|
+
children?: import("react").ReactNode;
|
|
12
|
+
} & import("react").RefAttributes<import("./dropdown").DropdownRef>> & {
|
|
13
|
+
Item: import("react").FC<import("./item").DropdownItemProps>;
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import "./dropdown.css";
|
|
2
2
|
import Dropdown from './dropdown';
|
|
3
|
-
|
|
3
|
+
import { attachPropertiesToComponent } from '../../utils/attach-properties-to-component';
|
|
4
|
+
import Item from './item';
|
|
5
|
+
export default attachPropertiesToComponent(Dropdown, {
|
|
6
|
+
Item: Item
|
|
7
|
+
});
|
|
@@ -7,7 +7,6 @@ export declare type DropdownItemProps = {
|
|
|
7
7
|
highlight?: boolean;
|
|
8
8
|
forceRender?: boolean;
|
|
9
9
|
destroyOnClose?: boolean;
|
|
10
|
-
closeOnContentClick?: boolean;
|
|
11
10
|
onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
12
11
|
} & NativeProps;
|
|
13
12
|
declare const Item: FC<DropdownItemProps>;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
|
+
import { ListProps } from '../list';
|
|
3
4
|
import type { FormProps as RcFormProps, FormInstance } from 'rc-field-form';
|
|
4
5
|
import { FormContextType } from './context';
|
|
5
6
|
import type { FormLayout } from '.';
|
|
6
7
|
export declare type FormProps = RcFormProps & NativeProps & Partial<FormContextType> & {
|
|
7
8
|
footer?: ReactNode;
|
|
8
9
|
layout?: FormLayout;
|
|
10
|
+
mode?: ListProps['mode'];
|
|
9
11
|
};
|
|
10
12
|
export declare const Form: React.ForwardRefExoticComponent<RcFormProps<any> & NativeProps<never> & Partial<FormContextType> & {
|
|
11
13
|
footer?: ReactNode;
|
|
12
14
|
layout?: "horizontal" | "vertical" | undefined;
|
|
15
|
+
mode?: ListProps['mode'];
|
|
13
16
|
} & React.RefAttributes<FormInstance<any>>>;
|
|
@@ -31,13 +31,15 @@ export var Form = /*#__PURE__*/forwardRef(function (p, ref) {
|
|
|
31
31
|
children = props.children,
|
|
32
32
|
layout = props.layout,
|
|
33
33
|
footer = props.footer,
|
|
34
|
-
|
|
34
|
+
mode = props.mode,
|
|
35
|
+
formProps = __rest(props, ["className", "style", "hasFeedback", "children", "layout", "footer", "mode"]);
|
|
35
36
|
|
|
36
37
|
return /*#__PURE__*/React.createElement(RcForm, Object.assign({
|
|
37
38
|
className: classNames(classPrefix, classPrefix + "-" + layout, className),
|
|
38
39
|
style: style,
|
|
39
40
|
ref: ref
|
|
40
41
|
}, formProps), /*#__PURE__*/React.createElement(List, {
|
|
42
|
+
mode: mode,
|
|
41
43
|
style: {
|
|
42
44
|
'--prefix-width': '6em',
|
|
43
45
|
'--align-items': 'stretch'
|
|
@@ -7,6 +7,7 @@ export type { FormInstance } from 'rc-field-form';
|
|
|
7
7
|
declare const _default: import("react").ForwardRefExoticComponent<import("rc-field-form").FormProps<any> & import("../../utils/native-props").NativeProps<never> & Partial<import("./context").FormContextType> & {
|
|
8
8
|
footer?: import("react").ReactNode;
|
|
9
9
|
layout?: "horizontal" | "vertical" | undefined;
|
|
10
|
+
mode?: "default" | "card" | undefined;
|
|
10
11
|
} & import("react").RefAttributes<import("rc-field-form").FormInstance<any>>> & {
|
|
11
12
|
Item: import("react").FC<import("./form-item").FormItemProps>;
|
|
12
13
|
useForm: typeof useForm;
|
|
@@ -6,6 +6,7 @@ import { shuffle } from '../../utils/shuffle';
|
|
|
6
6
|
import Popup from '../popup';
|
|
7
7
|
import { withNativeProps } from '../../utils/native-props';
|
|
8
8
|
import SafeArea from '../safe-area';
|
|
9
|
+
import { usePersistFn } from 'ahooks';
|
|
9
10
|
var classPrefix = 'adm-number-keyboard';
|
|
10
11
|
var defaultProps = {
|
|
11
12
|
defaultVisible: false,
|
|
@@ -24,8 +25,7 @@ export var NumberKeyboard = function NumberKeyboard(p) {
|
|
|
24
25
|
customKey = props.customKey,
|
|
25
26
|
randomOrder = props.randomOrder,
|
|
26
27
|
showCloseButton = props.showCloseButton,
|
|
27
|
-
onInput = props.onInput
|
|
28
|
-
onDelete = props.onDelete;
|
|
28
|
+
onInput = props.onInput;
|
|
29
29
|
var keyboardRef = useRef(null);
|
|
30
30
|
var keys = useMemo(function () {
|
|
31
31
|
var defaultKeys = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
|
@@ -43,31 +43,30 @@ export var NumberKeyboard = function NumberKeyboard(p) {
|
|
|
43
43
|
}, [customKey, confirmText, randomOrder, randomOrder && visible]);
|
|
44
44
|
var timeoutRef = useRef(-1);
|
|
45
45
|
var intervalRef = useRef(-1);
|
|
46
|
+
var onDelete = usePersistFn(function () {
|
|
47
|
+
var _a;
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
(_a = props.onDelete) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
var onBackspacePressStart = function onBackspacePressStart() {
|
|
49
53
|
timeoutRef.current = window.setTimeout(function () {
|
|
50
54
|
onDelete();
|
|
51
55
|
intervalRef.current = window.setInterval(onDelete, 150);
|
|
52
|
-
},
|
|
56
|
+
}, 700);
|
|
53
57
|
};
|
|
54
58
|
|
|
55
|
-
var
|
|
59
|
+
var onBackspacePressEnd = function onBackspacePressEnd() {
|
|
56
60
|
clearTimeout(timeoutRef.current);
|
|
57
61
|
clearInterval(intervalRef.current);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
var backSpaceEvents = {
|
|
61
|
-
onMouseDown: onStart,
|
|
62
|
-
onTouchStart: onStart,
|
|
63
|
-
onMouseUp: onEnd,
|
|
64
|
-
onMouseLeave: onEnd,
|
|
65
|
-
onTouchEnd: onEnd
|
|
66
62
|
}; // 点击键盘按键
|
|
67
63
|
|
|
68
|
-
|
|
64
|
+
|
|
65
|
+
var onKeyPress = function onKeyPress(e, key) {
|
|
69
66
|
var _a, _b;
|
|
70
67
|
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
|
|
71
70
|
switch (key) {
|
|
72
71
|
case 'BACKSPACE':
|
|
73
72
|
onDelete === null || onDelete === void 0 ? void 0 : onDelete();
|
|
@@ -117,16 +116,27 @@ export var NumberKeyboard = function NumberKeyboard(p) {
|
|
|
117
116
|
'sign-key': !isNumberKey && key,
|
|
118
117
|
'mid-key': index === 9 && !!confirmText
|
|
119
118
|
});
|
|
120
|
-
return /*#__PURE__*/React.createElement("div",
|
|
119
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
121
120
|
key: key,
|
|
122
121
|
className: className,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
onTouchStart: function onTouchStart() {
|
|
123
|
+
if (key === 'BACKSPACE') {
|
|
124
|
+
onBackspacePressStart();
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
onTouchEnd: function onTouchEnd(e) {
|
|
128
|
+
onKeyPress(e, key);
|
|
129
|
+
|
|
130
|
+
if (key === 'BACKSPACE') {
|
|
131
|
+
onBackspacePressEnd();
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
onMouseUp: function onMouseUp(e) {
|
|
135
|
+
onKeyPress(e, key);
|
|
136
|
+
},
|
|
127
137
|
title: key,
|
|
128
138
|
role: 'button'
|
|
129
|
-
}
|
|
139
|
+
}, key === 'BACKSPACE' ? /*#__PURE__*/React.createElement(TextDeletionOutline, null) : key);
|
|
130
140
|
};
|
|
131
141
|
|
|
132
142
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
@@ -151,18 +161,27 @@ export var NumberKeyboard = function NumberKeyboard(p) {
|
|
|
151
161
|
})
|
|
152
162
|
}, keys.map(renderKey)), !!confirmText && /*#__PURE__*/React.createElement("div", {
|
|
153
163
|
className: classPrefix + "-confirm"
|
|
154
|
-
}, /*#__PURE__*/React.createElement("div",
|
|
164
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
155
165
|
className: classPrefix + "-key extra-key bs-key",
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
166
|
+
onTouchStart: function onTouchStart() {
|
|
167
|
+
onBackspacePressStart();
|
|
168
|
+
},
|
|
169
|
+
onTouchEnd: function onTouchEnd(e) {
|
|
170
|
+
onKeyPress(e, 'BACKSPACE');
|
|
171
|
+
onBackspacePressEnd();
|
|
172
|
+
},
|
|
173
|
+
onMouseUp: function onMouseUp(e) {
|
|
174
|
+
return onKeyPress(e, 'BACKSPACE');
|
|
175
|
+
},
|
|
160
176
|
title: 'BACKSPACE',
|
|
161
177
|
role: 'button'
|
|
162
|
-
}
|
|
178
|
+
}, /*#__PURE__*/React.createElement(TextDeletionOutline, null)), /*#__PURE__*/React.createElement("div", {
|
|
163
179
|
className: classPrefix + "-key extra-key ok-key",
|
|
164
|
-
|
|
165
|
-
return onKeyPress('OK');
|
|
180
|
+
onTouchEnd: function onTouchEnd(e) {
|
|
181
|
+
return onKeyPress(e, 'OK');
|
|
182
|
+
},
|
|
183
|
+
onMouseUp: function onMouseUp(e) {
|
|
184
|
+
return onKeyPress(e, 'OK');
|
|
166
185
|
},
|
|
167
186
|
role: 'button'
|
|
168
187
|
}, confirmText))), props.safeArea && /*#__PURE__*/React.createElement("div", {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react';
|
|
1
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react';
|
|
2
2
|
import { withNativeProps } from '../../utils/native-props';
|
|
3
3
|
import { mergeProps } from '../../utils/with-default-props';
|
|
4
4
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
@@ -21,10 +21,10 @@ export var VirtualInput = /*#__PURE__*/forwardRef(function (p, ref) {
|
|
|
21
21
|
var contentRef = useRef(null);
|
|
22
22
|
|
|
23
23
|
var _useState = useState(false),
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
hasFocus = _useState[0],
|
|
25
|
+
setHasFocus = _useState[1];
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
function scrollToEnd() {
|
|
28
28
|
var root = rootRef.current;
|
|
29
29
|
if (!root) return;
|
|
30
30
|
|
|
@@ -37,7 +37,16 @@ export var VirtualInput = /*#__PURE__*/forwardRef(function (p, ref) {
|
|
|
37
37
|
content.scrollTo({
|
|
38
38
|
left: content.clientWidth
|
|
39
39
|
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
useLayoutEffect(function () {
|
|
43
|
+
scrollToEnd();
|
|
40
44
|
}, [value]);
|
|
45
|
+
useEffect(function () {
|
|
46
|
+
if (hasFocus) {
|
|
47
|
+
scrollToEnd();
|
|
48
|
+
}
|
|
49
|
+
}, [hasFocus]);
|
|
41
50
|
useImperativeHandle(ref, function () {
|
|
42
51
|
return {
|
|
43
52
|
focus: function focus() {
|
|
@@ -53,10 +62,17 @@ export var VirtualInput = /*#__PURE__*/forwardRef(function (p, ref) {
|
|
|
53
62
|
};
|
|
54
63
|
});
|
|
55
64
|
|
|
65
|
+
function onFocus() {
|
|
66
|
+
var _a;
|
|
67
|
+
|
|
68
|
+
setHasFocus(true);
|
|
69
|
+
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
70
|
+
}
|
|
71
|
+
|
|
56
72
|
function onBlur() {
|
|
57
73
|
var _a;
|
|
58
74
|
|
|
59
|
-
|
|
75
|
+
setHasFocus(false);
|
|
60
76
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
61
77
|
}
|
|
62
78
|
|
|
@@ -64,12 +80,7 @@ export var VirtualInput = /*#__PURE__*/forwardRef(function (p, ref) {
|
|
|
64
80
|
ref: rootRef,
|
|
65
81
|
className: classNames(classPrefix, (_classNames = {}, _classNames[classPrefix + "-disabled"] = props.disabled, _classNames)),
|
|
66
82
|
tabIndex: props.disabled ? undefined : 0,
|
|
67
|
-
onFocus:
|
|
68
|
-
var _a;
|
|
69
|
-
|
|
70
|
-
setKeyboardVisible(true);
|
|
71
|
-
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
72
|
-
},
|
|
83
|
+
onFocus: onFocus,
|
|
73
84
|
onBlur: onBlur,
|
|
74
85
|
onClick: props.onClick
|
|
75
86
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -77,9 +88,9 @@ export var VirtualInput = /*#__PURE__*/forwardRef(function (p, ref) {
|
|
|
77
88
|
ref: contentRef
|
|
78
89
|
}, value, /*#__PURE__*/React.createElement("div", {
|
|
79
90
|
className: classPrefix + "-caret-container"
|
|
80
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
91
|
+
}, hasFocus && /*#__PURE__*/React.createElement("div", {
|
|
81
92
|
className: classPrefix + "-caret"
|
|
82
|
-
}))), props.clearable && !!value && /*#__PURE__*/React.createElement("div", {
|
|
93
|
+
}))), props.clearable && !!value && hasFocus && /*#__PURE__*/React.createElement("div", {
|
|
83
94
|
className: classPrefix + "-clear",
|
|
84
95
|
onClick: function onClick() {
|
|
85
96
|
var _a;
|
|
@@ -96,7 +107,11 @@ export var VirtualInput = /*#__PURE__*/forwardRef(function (p, ref) {
|
|
|
96
107
|
onDelete: function onDelete() {
|
|
97
108
|
setValue(value.slice(0, -1));
|
|
98
109
|
},
|
|
99
|
-
visible:
|
|
100
|
-
onClose:
|
|
110
|
+
visible: hasFocus,
|
|
111
|
+
onClose: function onClose() {
|
|
112
|
+
var _a;
|
|
113
|
+
|
|
114
|
+
(_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
115
|
+
}
|
|
101
116
|
})));
|
|
102
117
|
});
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antd-mobile",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.3",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@react-spring/web": "^9.3.1",
|
|
6
6
|
"@types/resize-observer-browser": "^0.1.6",
|
|
7
|
-
"@use-gesture/react": "^10.
|
|
8
|
-
"ahooks": "^2.10.
|
|
7
|
+
"@use-gesture/react": "^10.2.2",
|
|
8
|
+
"ahooks": "^2.10.14",
|
|
9
9
|
"antd-mobile-icons": "^0.2.2",
|
|
10
10
|
"antd-mobile-v5-count": "^1.0.1",
|
|
11
11
|
"classnames": "^2.3.1",
|