antd-mobile 5.0.0-rc.4 → 5.0.0-rc.5
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/README.md +2 -0
- package/2x/cjs/components/collapse/collapse.d.ts +2 -2
- package/2x/cjs/components/collapse/collapse.js +1 -1
- package/2x/cjs/components/dialog/dialog.js +7 -4
- package/2x/cjs/components/list/list.css +5 -4
- package/2x/cjs/components/list/list.js +1 -3
- package/2x/cjs/components/number-keyboard/number-keyboard.css +2 -2
- package/2x/cjs/components/passcode-input/index.d.ts +4 -0
- package/2x/cjs/components/passcode-input/index.js +13 -0
- package/2x/cjs/components/passcode-input/passcode-input.css +166 -0
- package/2x/cjs/components/passcode-input/passcode-input.d.ts +35 -0
- package/2x/cjs/components/passcode-input/passcode-input.js +169 -0
- package/2x/cjs/components/picker/picker.js +1 -0
- package/2x/cjs/components/picker-view/column.js +47 -3
- package/2x/cjs/components/picker-view/picker-view.css +45 -5
- package/2x/cjs/components/picker-view/picker-view.js +7 -3
- package/2x/cjs/components/toast/index.d.ts +2 -1
- package/2x/cjs/components/toast/index.js +2 -1
- package/2x/cjs/components/toast/methods.d.ts +1 -0
- package/2x/cjs/components/toast/methods.js +18 -1
- package/2x/cjs/index.d.ts +1 -0
- package/2x/cjs/index.js +8 -0
- package/2x/cjs/utils/memo-with-event-marks.d.ts +2 -0
- package/2x/cjs/utils/memo-with-event-marks.js +23 -0
- package/2x/es/components/collapse/collapse.d.ts +2 -2
- package/2x/es/components/collapse/collapse.js +1 -1
- package/2x/es/components/dialog/dialog.js +6 -4
- package/2x/es/components/list/list.css +5 -4
- package/2x/es/components/list/list.js +1 -3
- package/2x/es/components/number-keyboard/number-keyboard.css +2 -2
- package/2x/es/components/passcode-input/index.d.ts +4 -0
- package/2x/es/components/passcode-input/index.js +3 -0
- package/2x/es/components/passcode-input/passcode-input.css +166 -0
- package/2x/es/components/passcode-input/passcode-input.d.ts +35 -0
- package/2x/es/components/passcode-input/passcode-input.js +149 -0
- package/2x/es/components/picker/picker.js +1 -0
- package/2x/es/components/picker-view/column.js +47 -3
- package/2x/es/components/picker-view/picker-view.css +45 -5
- package/2x/es/components/picker-view/picker-view.js +7 -3
- package/2x/es/components/toast/index.d.ts +2 -1
- package/2x/es/components/toast/index.js +3 -2
- package/2x/es/components/toast/methods.d.ts +1 -0
- package/2x/es/components/toast/methods.js +16 -1
- package/2x/es/index.d.ts +1 -0
- package/2x/es/index.js +2 -1
- package/2x/es/utils/memo-with-event-marks.d.ts +2 -0
- package/2x/es/utils/memo-with-event-marks.js +15 -0
- package/2x/package.json +1 -1
- package/README.md +2 -0
- package/cjs/components/collapse/collapse.d.ts +2 -2
- package/cjs/components/collapse/collapse.js +1 -1
- package/cjs/components/dialog/dialog.js +7 -4
- package/cjs/components/list/list.css +4 -3
- package/cjs/components/list/list.js +1 -3
- package/cjs/components/number-keyboard/number-keyboard.css +2 -2
- package/cjs/components/passcode-input/index.d.ts +4 -0
- package/cjs/components/passcode-input/index.js +13 -0
- package/cjs/components/passcode-input/passcode-input.css +136 -0
- package/cjs/components/passcode-input/passcode-input.d.ts +35 -0
- package/cjs/components/passcode-input/passcode-input.js +169 -0
- package/cjs/components/picker/picker.js +1 -0
- package/cjs/components/picker-view/column.js +47 -3
- package/cjs/components/picker-view/picker-view.css +39 -5
- package/cjs/components/picker-view/picker-view.js +7 -3
- package/cjs/components/toast/index.d.ts +2 -1
- package/cjs/components/toast/index.js +2 -1
- package/cjs/components/toast/methods.d.ts +1 -0
- package/cjs/components/toast/methods.js +18 -1
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +8 -0
- package/cjs/utils/memo-with-event-marks.d.ts +2 -0
- package/cjs/utils/memo-with-event-marks.js +23 -0
- package/es/components/collapse/collapse.d.ts +2 -2
- package/es/components/collapse/collapse.js +1 -1
- package/es/components/dialog/dialog.js +6 -4
- package/es/components/list/list.css +4 -3
- package/es/components/list/list.js +1 -3
- package/es/components/number-keyboard/number-keyboard.css +2 -2
- package/es/components/passcode-input/index.d.ts +4 -0
- package/es/components/passcode-input/index.js +3 -0
- package/es/components/passcode-input/passcode-input.css +136 -0
- package/es/components/passcode-input/passcode-input.d.ts +35 -0
- package/es/components/passcode-input/passcode-input.js +149 -0
- package/es/components/picker/picker.js +1 -0
- package/es/components/picker-view/column.js +47 -3
- package/es/components/picker-view/picker-view.css +39 -5
- package/es/components/picker-view/picker-view.js +7 -3
- package/es/components/toast/index.d.ts +2 -1
- package/es/components/toast/index.js +3 -2
- package/es/components/toast/methods.d.ts +1 -0
- package/es/components/toast/methods.js +16 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/utils/memo-with-event-marks.d.ts +2 -0
- package/es/utils/memo-with-event-marks.js +15 -0
- package/package.json +1 -1
- package/umd/antd-mobile.js +1 -1
|
@@ -77,9 +77,13 @@ var PickerView = /*#__PURE__*/(0, _react.memo)(function (p) {
|
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
80
|
-
className: classPrefix + "-mask
|
|
80
|
+
className: classPrefix + "-mask"
|
|
81
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
82
|
+
className: classPrefix + "-mask-top"
|
|
81
83
|
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
82
|
-
className: classPrefix + "-mask
|
|
83
|
-
})
|
|
84
|
+
className: classPrefix + "-mask-middle"
|
|
85
|
+
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
86
|
+
className: classPrefix + "-mask-bottom"
|
|
87
|
+
}))));
|
|
84
88
|
});
|
|
85
89
|
exports.PickerView = PickerView;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import './toast.less';
|
|
2
|
-
import { clear, show } from './methods';
|
|
2
|
+
import { clear, show, config } from './methods';
|
|
3
3
|
export type { ToastShowProps } from './methods';
|
|
4
4
|
declare const Toast: {
|
|
5
5
|
show: typeof show;
|
|
6
6
|
clear: typeof clear;
|
|
7
|
+
config: typeof config;
|
|
7
8
|
};
|
|
8
9
|
export default Toast;
|
|
@@ -2,3 +2,4 @@ import { ToastProps } from './toast';
|
|
|
2
2
|
export declare type ToastShowProps = Omit<ToastProps, 'visible'>;
|
|
3
3
|
export declare function show(p: ToastShowProps | string): void;
|
|
4
4
|
export declare function clear(): void;
|
|
5
|
+
export declare function config(val: Pick<ToastProps, 'duration' | 'position' | 'maskClickable'>): void;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.clear = clear;
|
|
7
|
+
exports.config = config;
|
|
7
8
|
exports.show = show;
|
|
8
9
|
|
|
9
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -33,7 +34,9 @@ function unmount(container) {
|
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
var defaultProps = {
|
|
36
|
-
duration: 2000
|
|
37
|
+
duration: 2000,
|
|
38
|
+
position: 'center',
|
|
39
|
+
maskClickable: true
|
|
37
40
|
};
|
|
38
41
|
|
|
39
42
|
function show(p) {
|
|
@@ -95,4 +98,18 @@ function clear() {
|
|
|
95
98
|
if (!container) break;
|
|
96
99
|
unmount(container);
|
|
97
100
|
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function config(val) {
|
|
104
|
+
if (val.duration !== undefined) {
|
|
105
|
+
defaultProps.duration = val.duration;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (val.position !== undefined) {
|
|
109
|
+
defaultProps.position = val.position;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (val.maskClickable !== undefined) {
|
|
113
|
+
defaultProps.maskClickable = val.maskClickable;
|
|
114
|
+
}
|
|
98
115
|
}
|
package/2x/cjs/index.d.ts
CHANGED
|
@@ -72,3 +72,4 @@ export { default as Toast } from './components/toast';
|
|
|
72
72
|
export { default as TreeSelect } from './components/tree-select';
|
|
73
73
|
export { default as VirtualInput } from './components/virtual-input';
|
|
74
74
|
export { default as WaterMark } from './components/water-mark';
|
|
75
|
+
export { default as PasscodeInput } from './components/passcode-input';
|
package/2x/cjs/index.js
CHANGED
|
@@ -249,6 +249,12 @@ Object.defineProperty(exports, "PageIndicator", {
|
|
|
249
249
|
return _pageIndicator["default"];
|
|
250
250
|
}
|
|
251
251
|
});
|
|
252
|
+
Object.defineProperty(exports, "PasscodeInput", {
|
|
253
|
+
enumerable: true,
|
|
254
|
+
get: function get() {
|
|
255
|
+
return _passcodeInput["default"];
|
|
256
|
+
}
|
|
257
|
+
});
|
|
252
258
|
Object.defineProperty(exports, "Picker", {
|
|
253
259
|
enumerable: true,
|
|
254
260
|
get: function get() {
|
|
@@ -586,6 +592,8 @@ var _virtualInput = _interopRequireDefault(require("./components/virtual-input")
|
|
|
586
592
|
|
|
587
593
|
var _waterMark = _interopRequireDefault(require("./components/water-mark"));
|
|
588
594
|
|
|
595
|
+
var _passcodeInput = _interopRequireDefault(require("./components/passcode-input"));
|
|
596
|
+
|
|
589
597
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
590
598
|
|
|
591
599
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.memoWithEventMarks = memoWithEventMarks;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
function memoWithEventMarks(Component, eventProps) {
|
|
11
|
+
return /*#__PURE__*/(0, _react.memo)(Component, function (prevProps, nextProps) {
|
|
12
|
+
for (var k in nextProps) {
|
|
13
|
+
var key = k;
|
|
14
|
+
if (eventProps.includes(key)) continue;
|
|
15
|
+
|
|
16
|
+
if (prevProps[key] !== nextProps[key]) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return true;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -7,14 +7,14 @@ export declare type CollapsePanelProps = {
|
|
|
7
7
|
forceRender?: boolean;
|
|
8
8
|
destroyOnClose?: boolean;
|
|
9
9
|
onClick?: (event: React.MouseEvent<Element, MouseEvent>) => void;
|
|
10
|
-
arrow?: React.ReactNode;
|
|
10
|
+
arrow?: React.ReactNode | ((active: boolean) => React.ReactNode);
|
|
11
11
|
} & NativeProps;
|
|
12
12
|
export declare const CollapsePanel: FC<CollapsePanelProps>;
|
|
13
13
|
declare type ValueProps<T> = {
|
|
14
14
|
activeKey?: T;
|
|
15
15
|
defaultActiveKey?: T;
|
|
16
16
|
onChange?: (activeKey: T) => void;
|
|
17
|
-
arrow?: React.ReactNode;
|
|
17
|
+
arrow?: React.ReactNode | ((active: boolean) => React.ReactNode);
|
|
18
18
|
};
|
|
19
19
|
export declare type CollapseProps = (({
|
|
20
20
|
accordion?: false;
|
|
@@ -142,7 +142,7 @@ export var Collapse = function Collapse(props) {
|
|
|
142
142
|
arrow = panel.props.arrow;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
145
|
+
return typeof arrow === 'function' ? arrow(active) : /*#__PURE__*/React.createElement("div", {
|
|
146
146
|
className: classNames(classPrefix + "-arrow", (_classNames = {}, _classNames[classPrefix + "-arrow-active"] = active, _classNames))
|
|
147
147
|
}, arrow);
|
|
148
148
|
};
|
|
@@ -38,6 +38,7 @@ import Mask from '../mask';
|
|
|
38
38
|
import { DialogActionButton } from './dialog-action-button';
|
|
39
39
|
import Image from '../image';
|
|
40
40
|
import Space from '../space';
|
|
41
|
+
import { renderToContainer } from '../../utils/render-to-container';
|
|
41
42
|
import { withStopPropagation } from '../../utils/with-stop-propagation';
|
|
42
43
|
import AutoCenter from '../auto-center';
|
|
43
44
|
import { useSpring, animated } from '@react-spring/web';
|
|
@@ -48,7 +49,8 @@ var defaultProps = {
|
|
|
48
49
|
actions: [],
|
|
49
50
|
closeOnAction: false,
|
|
50
51
|
closeOnMaskClick: false,
|
|
51
|
-
stopPropagation: ['click']
|
|
52
|
+
stopPropagation: ['click'],
|
|
53
|
+
getContainer: null
|
|
52
54
|
};
|
|
53
55
|
export var Dialog = function Dialog(p) {
|
|
54
56
|
var props = mergeProps(defaultProps, p);
|
|
@@ -81,14 +83,13 @@ export var Dialog = function Dialog(p) {
|
|
|
81
83
|
active = _useState[0],
|
|
82
84
|
setActive = _useState[1];
|
|
83
85
|
|
|
84
|
-
|
|
86
|
+
var node = withNativeProps(props, /*#__PURE__*/React.createElement("div", {
|
|
85
87
|
className: classPrefix,
|
|
86
88
|
style: {
|
|
87
89
|
display: active ? 'unset' : 'none'
|
|
88
90
|
}
|
|
89
91
|
}, /*#__PURE__*/React.createElement(Mask, {
|
|
90
92
|
visible: props.visible,
|
|
91
|
-
getContainer: props.getContainer,
|
|
92
93
|
onMaskClick: props.closeOnMaskClick ? props.onClose : undefined,
|
|
93
94
|
style: props.maskStyle,
|
|
94
95
|
className: classNames(classPrefix + "-mask", props.maskClassName)
|
|
@@ -158,5 +159,6 @@ export var Dialog = function Dialog(p) {
|
|
|
158
159
|
}
|
|
159
160
|
});
|
|
160
161
|
}));
|
|
161
|
-
}))))))
|
|
162
|
+
}))))));
|
|
163
|
+
return renderToContainer(props.getContainer, withStopPropagation(props.stopPropagation, node));
|
|
162
164
|
};
|
|
@@ -11,10 +11,6 @@
|
|
|
11
11
|
font-size: 34px;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
.adm-list-inner {
|
|
15
|
-
margin-bottom: -2px;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
14
|
.adm-list-default {
|
|
19
15
|
border-top: var(--border-top);
|
|
20
16
|
border-bottom: var(--border-bottom);
|
|
@@ -26,10 +22,15 @@
|
|
|
26
22
|
}
|
|
27
23
|
|
|
28
24
|
.adm-list-item {
|
|
25
|
+
margin-bottom: -2px;
|
|
29
26
|
display: block;
|
|
30
27
|
padding-left: var(--padding-left);
|
|
31
28
|
}
|
|
32
29
|
|
|
30
|
+
.adm-list-item:not(:first-child) {
|
|
31
|
+
padding-top: 2px;
|
|
32
|
+
}
|
|
33
|
+
|
|
33
34
|
.adm-list-item-title,
|
|
34
35
|
.adm-list-item-description {
|
|
35
36
|
color: var(--adm-color-weak);
|
|
@@ -10,7 +10,5 @@ export var List = function List(p) {
|
|
|
10
10
|
var props = mergeProps(defaultProps, p);
|
|
11
11
|
return withNativeProps(props, /*#__PURE__*/React.createElement("div", {
|
|
12
12
|
className: classNames(classPrefix, classPrefix + "-" + props.mode)
|
|
13
|
-
},
|
|
14
|
-
className: classPrefix + "-inner"
|
|
15
|
-
}, props.children)));
|
|
13
|
+
}, props.children));
|
|
16
14
|
};
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
flex: 1;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
.adm-number-keyboard.confirmed-style {
|
|
8
|
-
width: 75%;
|
|
7
|
+
.adm-number-keyboard-main.confirmed-style .sign-key {
|
|
9
8
|
background-color: var(--adm-color-white);
|
|
10
9
|
}
|
|
11
10
|
|
|
@@ -125,6 +124,7 @@
|
|
|
125
124
|
color: var(--adm-color-white);
|
|
126
125
|
height: 288px;
|
|
127
126
|
font-size: 32px;
|
|
127
|
+
border: none;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
.adm-number-keyboard-bs-key {
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
.adm-passcode-input {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-block;
|
|
4
|
+
--cell-size: 80px;
|
|
5
|
+
--cell-gap: 12px;
|
|
6
|
+
--dot-size: 20px;
|
|
7
|
+
--border-color: #e5e5e5;
|
|
8
|
+
--border-radius: 16px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.adm-passcode-input-cell-container {
|
|
12
|
+
display: inline-flex;
|
|
13
|
+
vertical-align: top;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.adm-passcode-input-cell {
|
|
17
|
+
flex: none;
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
font-size: 36px;
|
|
23
|
+
width: var(--cell-size);
|
|
24
|
+
height: var(--cell-size);
|
|
25
|
+
background: var(--adm-color-white);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.adm-passcode-input:not(.seperated) {
|
|
29
|
+
border-radius: var(--border-radius);
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
border: 2px solid var(--border-color);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.adm-passcode-input:not(.seperated) .adm-passcode-input-cell:not(:last-child) {
|
|
35
|
+
border-right: 2px solid var(--border-color);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.adm-passcode-input:not(.seperated).focused {
|
|
39
|
+
border-color: var(--adm-color-primary);
|
|
40
|
+
box-shadow: 0 0 4px 0 var(--adm-color-primary);
|
|
41
|
+
outline: none;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.adm-passcode-input:not(.seperated).error {
|
|
45
|
+
border-color: var(--adm-color-danger);
|
|
46
|
+
box-shadow: 0 0 4px 0 var(--adm-color-danger);
|
|
47
|
+
animation: 100ms ease-in-out 0s 3 normal none running adm-shake-horizontal;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.adm-passcode-input.seperated .adm-passcode-input-cell {
|
|
51
|
+
border-radius: var(--border-radius);
|
|
52
|
+
border: 2px solid var(--border-color);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.adm-passcode-input.seperated .adm-passcode-input-cell:not(:last-child) {
|
|
56
|
+
margin-right: var(--cell-gap);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.adm-passcode-input.seperated .adm-passcode-input-cell.focused {
|
|
60
|
+
border-color: var(--adm-color-primary);
|
|
61
|
+
box-shadow: 0 0 4px 0 var(--adm-color-primary);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.adm-passcode-input.seperated.focused {
|
|
65
|
+
outline: none;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.adm-passcode-input.seperated.error {
|
|
69
|
+
animation: 100ms ease-in-out 0s 3 normal none running adm-shake-horizontal;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.adm-passcode-input.seperated.error .adm-passcode-input-cell {
|
|
73
|
+
border-color: var(--adm-color-danger);
|
|
74
|
+
box-shadow: 0 0 4px 0 var(--adm-color-danger);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.adm-passcode-input-cell.dot::before {
|
|
78
|
+
content: '';
|
|
79
|
+
width: var(--dot-size);
|
|
80
|
+
height: var(--dot-size);
|
|
81
|
+
border-radius: 50%;
|
|
82
|
+
background: var(--adm-color-text);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.adm-passcode-input-cell.caret::after {
|
|
86
|
+
content: '';
|
|
87
|
+
width: 4px;
|
|
88
|
+
height: 1.1em;
|
|
89
|
+
margin-left: 2px;
|
|
90
|
+
background: var(--adm-color-primary);
|
|
91
|
+
animation: 1s linear infinite adm-caret-blink;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.adm-passcode-input > .adm-passcode-input-native-input {
|
|
95
|
+
position: absolute;
|
|
96
|
+
left: -200vw;
|
|
97
|
+
top: 0;
|
|
98
|
+
display: block;
|
|
99
|
+
width: 100px;
|
|
100
|
+
height: 40px;
|
|
101
|
+
opacity: 0.5;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@keyframes adm-shake-horizontal {
|
|
105
|
+
0% {
|
|
106
|
+
transform: translateX(0);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
10% {
|
|
110
|
+
transform: translateX(-8px);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
20% {
|
|
114
|
+
transform: translateX(10px);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
30% {
|
|
118
|
+
transform: translateX(-2px);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
40% {
|
|
122
|
+
transform: translateX(16px);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
50% {
|
|
126
|
+
transform: translateX(0);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
60% {
|
|
130
|
+
transform: translateX(-16px);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
70% {
|
|
134
|
+
transform: translateX(2px);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
80% {
|
|
138
|
+
transform: translateX(-10px);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
90% {
|
|
142
|
+
transform: translateX(8px);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
100% {
|
|
146
|
+
transform: translateX(0);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@keyframes adm-caret-blink {
|
|
151
|
+
from {
|
|
152
|
+
opacity: 1;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
60% {
|
|
156
|
+
opacity: 1;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
80% {
|
|
160
|
+
opacity: 0;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
to {
|
|
164
|
+
opacity: 0;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
import { NativeProps } from '../../utils/native-props';
|
|
3
|
+
import type { NumberKeyboardProps } from '../number-keyboard';
|
|
4
|
+
export declare type PasscodeInputProps = {
|
|
5
|
+
value?: string;
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
onChange?: (val: string) => void;
|
|
8
|
+
length?: number;
|
|
9
|
+
plain?: boolean;
|
|
10
|
+
error?: boolean;
|
|
11
|
+
caret?: boolean;
|
|
12
|
+
seperated?: boolean;
|
|
13
|
+
onBlur?: () => void;
|
|
14
|
+
onFocus?: () => void;
|
|
15
|
+
keyboard?: ReactElement<NumberKeyboardProps>;
|
|
16
|
+
onFill?: (val: string) => void;
|
|
17
|
+
} & NativeProps<'--cell-gap' | '--cell-size'>;
|
|
18
|
+
export declare type PasscodeInputRef = {
|
|
19
|
+
focus: () => void;
|
|
20
|
+
blur: () => void;
|
|
21
|
+
};
|
|
22
|
+
export declare const PasscodeInput: React.ForwardRefExoticComponent<{
|
|
23
|
+
value?: string | undefined;
|
|
24
|
+
defaultValue?: string | undefined;
|
|
25
|
+
onChange?: ((val: string) => void) | undefined;
|
|
26
|
+
length?: number | undefined;
|
|
27
|
+
plain?: boolean | undefined;
|
|
28
|
+
error?: boolean | undefined;
|
|
29
|
+
caret?: boolean | undefined;
|
|
30
|
+
seperated?: boolean | undefined;
|
|
31
|
+
onBlur?: (() => void) | undefined;
|
|
32
|
+
onFocus?: (() => void) | undefined;
|
|
33
|
+
keyboard?: React.ReactElement<NumberKeyboardProps, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)> | undefined;
|
|
34
|
+
onFill?: ((val: string) => void) | undefined;
|
|
35
|
+
} & NativeProps<"--cell-size" | "--cell-gap"> & React.RefAttributes<PasscodeInputRef>>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef, forwardRef, useImperativeHandle } from 'react';
|
|
2
|
+
import { mergeProps } from '../../utils/with-default-props';
|
|
3
|
+
import { withNativeProps } from '../../utils/native-props';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { bound } from '../../utils/bound';
|
|
6
|
+
import { usePropsValue } from '../../utils/use-props-value';
|
|
7
|
+
var classPrefix = 'adm-passcode-input';
|
|
8
|
+
var defaultProps = {
|
|
9
|
+
defaultValue: '',
|
|
10
|
+
length: 6,
|
|
11
|
+
plain: false,
|
|
12
|
+
error: false,
|
|
13
|
+
seperated: false,
|
|
14
|
+
caret: true
|
|
15
|
+
};
|
|
16
|
+
export var PasscodeInput = /*#__PURE__*/forwardRef(function (p, ref) {
|
|
17
|
+
var props = mergeProps(defaultProps, p); // 防止 length 值不合法
|
|
18
|
+
|
|
19
|
+
var cellLength = props.length > 0 && props.length < Infinity ? Math.floor(props.length) : defaultProps.length;
|
|
20
|
+
|
|
21
|
+
var _useState = useState(false),
|
|
22
|
+
focused = _useState[0],
|
|
23
|
+
setFocused = _useState[1];
|
|
24
|
+
|
|
25
|
+
var _usePropsValue = usePropsValue(props),
|
|
26
|
+
value = _usePropsValue[0],
|
|
27
|
+
setValue = _usePropsValue[1];
|
|
28
|
+
|
|
29
|
+
var rootRef = useRef(null);
|
|
30
|
+
var nativeInputRef = useRef(null);
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
var _a;
|
|
33
|
+
|
|
34
|
+
if (value.length >= cellLength) {
|
|
35
|
+
(_a = props.onFill) === null || _a === void 0 ? void 0 : _a.call(props, value);
|
|
36
|
+
}
|
|
37
|
+
}, [props.onFill, value, cellLength]);
|
|
38
|
+
|
|
39
|
+
var onFocus = function onFocus() {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
|
|
42
|
+
if (!props.keyboard) {
|
|
43
|
+
(_a = nativeInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
setFocused(true);
|
|
47
|
+
(_b = props.onFocus) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
useEffect(function () {
|
|
51
|
+
if (!focused) return;
|
|
52
|
+
var timeout = window.setTimeout(function () {
|
|
53
|
+
var _a;
|
|
54
|
+
|
|
55
|
+
(_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
|
|
56
|
+
block: 'center',
|
|
57
|
+
inline: 'center',
|
|
58
|
+
behavior: 'smooth'
|
|
59
|
+
});
|
|
60
|
+
}, 100);
|
|
61
|
+
return function () {
|
|
62
|
+
window.clearTimeout(timeout);
|
|
63
|
+
};
|
|
64
|
+
}, [focused]);
|
|
65
|
+
|
|
66
|
+
var onBlur = function onBlur() {
|
|
67
|
+
var _a;
|
|
68
|
+
|
|
69
|
+
setFocused(false);
|
|
70
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
useImperativeHandle(ref, function () {
|
|
74
|
+
return {
|
|
75
|
+
focus: function focus() {
|
|
76
|
+
var _a;
|
|
77
|
+
|
|
78
|
+
return (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
79
|
+
},
|
|
80
|
+
blur: function blur() {
|
|
81
|
+
var _a, _b;
|
|
82
|
+
|
|
83
|
+
(_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
84
|
+
(_b = nativeInputRef.current) === null || _b === void 0 ? void 0 : _b.blur();
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
var renderCells = function renderCells() {
|
|
90
|
+
var cells = [];
|
|
91
|
+
var chars = value.split('');
|
|
92
|
+
var caretIndex = chars.length; // 光标位置index等于当前文字长度
|
|
93
|
+
|
|
94
|
+
var focusedIndex = bound(chars.length, 0, cellLength - 1);
|
|
95
|
+
|
|
96
|
+
for (var i = 0; i < cellLength; i++) {
|
|
97
|
+
cells.push( /*#__PURE__*/React.createElement("div", {
|
|
98
|
+
className: classNames(classPrefix + "-cell", {
|
|
99
|
+
caret: props.caret && caretIndex === i && focused,
|
|
100
|
+
focused: focusedIndex === i && focused,
|
|
101
|
+
dot: !props.plain && chars[i]
|
|
102
|
+
}),
|
|
103
|
+
key: i
|
|
104
|
+
}, chars[i] && props.plain ? chars[i] : ''));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return cells;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
var cls = classNames(classPrefix, {
|
|
111
|
+
focused: focused,
|
|
112
|
+
error: props.error,
|
|
113
|
+
seperated: props.seperated
|
|
114
|
+
});
|
|
115
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, withNativeProps(props, /*#__PURE__*/React.createElement("div", {
|
|
116
|
+
ref: rootRef,
|
|
117
|
+
tabIndex: 0,
|
|
118
|
+
className: cls,
|
|
119
|
+
onFocus: onFocus,
|
|
120
|
+
onBlur: onBlur
|
|
121
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
122
|
+
className: classPrefix + "-cell-container"
|
|
123
|
+
}, renderCells()), /*#__PURE__*/React.createElement("input", {
|
|
124
|
+
ref: nativeInputRef,
|
|
125
|
+
className: classPrefix + "-native-input",
|
|
126
|
+
value: value,
|
|
127
|
+
type: 'text',
|
|
128
|
+
pattern: '[0-9]*',
|
|
129
|
+
inputMode: 'numeric',
|
|
130
|
+
onChange: function onChange(e) {
|
|
131
|
+
setValue(e.target.value.slice(0, props.length));
|
|
132
|
+
}
|
|
133
|
+
}))), props.keyboard && /*#__PURE__*/React.cloneElement(props.keyboard, {
|
|
134
|
+
visible: focused,
|
|
135
|
+
onInput: function onInput(v) {
|
|
136
|
+
if (value.length < cellLength) {
|
|
137
|
+
setValue((value + v).slice(0, props.length));
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
onDelete: function onDelete() {
|
|
141
|
+
setValue(value.slice(0, -1));
|
|
142
|
+
},
|
|
143
|
+
onClose: function onClose() {
|
|
144
|
+
var _a;
|
|
145
|
+
|
|
146
|
+
(_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
147
|
+
}
|
|
148
|
+
}));
|
|
149
|
+
});
|
|
@@ -103,6 +103,7 @@ export var Picker = /*#__PURE__*/memo(function (p) {
|
|
|
103
103
|
afterShow: props.afterShow,
|
|
104
104
|
afterClose: props.afterClose,
|
|
105
105
|
onClick: props.onClick,
|
|
106
|
+
forceRender: true,
|
|
106
107
|
stopPropagation: props.stopPropagation
|
|
107
108
|
}, pickerElement);
|
|
108
109
|
return /*#__PURE__*/React.createElement(React.Fragment, null, popupElement, (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props, generateValueExtend(value).items));
|