antd-mobile 5.18.0 → 5.19.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.js +47 -18976
- package/2x/bundle/antd-mobile.compatible.umd.js +25752 -0
- package/2x/bundle/antd-mobile.es.js +16123 -16565
- package/2x/bundle/antd-mobile.umd.js +64 -0
- package/2x/bundle/style.css +227 -273
- package/2x/cjs/components/action-sheet/action-sheet.d.ts +1 -1
- package/2x/cjs/components/button/button.js +1 -1
- package/2x/cjs/components/calendar/calendar.d.ts +1 -1
- package/2x/cjs/components/cascader/cascader.d.ts +2 -0
- package/2x/cjs/components/cascader/index.d.ts +1 -0
- package/2x/cjs/components/cascader-view/cascader-view.d.ts +2 -1
- package/2x/cjs/components/cascader-view/cascader-view.js +2 -1
- package/2x/cjs/components/dialog/show.d.ts +1 -1
- package/2x/cjs/components/image-viewer/slide.js +75 -56
- package/2x/cjs/components/input/input.js +9 -2
- package/2x/cjs/components/modal/show.d.ts +1 -1
- package/2x/cjs/components/number-keyboard/number-keyboard.css +11 -15
- package/2x/cjs/components/number-keyboard/number-keyboard.d.ts +1 -1
- package/2x/cjs/components/number-keyboard/number-keyboard.js +19 -17
- package/2x/cjs/components/passcode-input/index.d.ts +1 -1
- package/2x/cjs/components/passcode-input/passcode-input.css +12 -12
- package/2x/cjs/components/passcode-input/passcode-input.js +16 -8
- package/2x/cjs/components/result/result.d.ts +1 -1
- package/2x/cjs/components/result/result.js +7 -1
- package/2x/cjs/components/search-bar/search-bar.js +12 -2
- package/2x/cjs/locales/base.d.ts +9 -0
- package/2x/cjs/locales/base.js +9 -0
- package/2x/cjs/locales/en-US.d.ts +9 -0
- package/2x/cjs/locales/es-ES.d.ts +9 -0
- package/2x/cjs/locales/fa-IR.d.ts +9 -0
- package/2x/cjs/locales/fr-FR.d.ts +9 -0
- package/2x/cjs/locales/id-ID.d.ts +9 -0
- package/2x/cjs/locales/kk-KZ.d.ts +9 -0
- package/2x/cjs/locales/ko-KR.d.ts +9 -0
- package/2x/cjs/locales/zh-CN.d.ts +9 -0
- package/2x/cjs/locales/zh-CN.js +9 -0
- package/2x/cjs/locales/zh-HK.d.ts +9 -0
- package/2x/cjs/locales/zh-TW.d.ts +9 -0
- package/2x/cjs/utils/matrix.d.ts +10 -0
- package/2x/cjs/utils/matrix.js +60 -0
- package/2x/es/components/action-sheet/action-sheet.d.ts +1 -1
- package/2x/es/components/button/button.js +1 -1
- package/2x/es/components/calendar/calendar.d.ts +1 -1
- package/2x/es/components/cascader/cascader.d.ts +2 -0
- package/2x/es/components/cascader/index.d.ts +1 -0
- package/2x/es/components/cascader-view/cascader-view.d.ts +2 -1
- package/2x/es/components/cascader-view/cascader-view.js +2 -1
- package/2x/es/components/dialog/show.d.ts +1 -1
- package/2x/es/components/image-viewer/slide.js +73 -56
- package/2x/es/components/input/input.js +8 -2
- package/2x/es/components/modal/show.d.ts +1 -1
- package/2x/es/components/number-keyboard/number-keyboard.css +11 -15
- package/2x/es/components/number-keyboard/number-keyboard.d.ts +1 -1
- package/2x/es/components/number-keyboard/number-keyboard.js +19 -17
- package/2x/es/components/passcode-input/index.d.ts +1 -1
- package/2x/es/components/passcode-input/passcode-input.css +12 -12
- package/2x/es/components/passcode-input/passcode-input.js +15 -8
- package/2x/es/components/result/result.d.ts +1 -1
- package/2x/es/components/result/result.js +6 -1
- package/2x/es/components/search-bar/search-bar.js +12 -2
- package/2x/es/locales/base.d.ts +9 -0
- package/2x/es/locales/base.js +9 -0
- package/2x/es/locales/en-US.d.ts +9 -0
- package/2x/es/locales/es-ES.d.ts +9 -0
- package/2x/es/locales/fa-IR.d.ts +9 -0
- package/2x/es/locales/fr-FR.d.ts +9 -0
- package/2x/es/locales/id-ID.d.ts +9 -0
- package/2x/es/locales/kk-KZ.d.ts +9 -0
- package/2x/es/locales/ko-KR.d.ts +9 -0
- package/2x/es/locales/zh-CN.d.ts +9 -0
- package/2x/es/locales/zh-CN.js +9 -0
- package/2x/es/locales/zh-HK.d.ts +9 -0
- package/2x/es/locales/zh-TW.d.ts +9 -0
- package/2x/es/utils/matrix.d.ts +10 -0
- package/2x/es/utils/matrix.js +27 -0
- package/2x/package.json +1 -1
- package/2x/umd/antd-mobile.js +25752 -2
- package/bundle/antd-mobile.cjs.js +47 -18976
- package/bundle/antd-mobile.compatible.umd.js +25752 -0
- package/bundle/antd-mobile.es.js +16123 -16565
- package/bundle/antd-mobile.umd.js +64 -0
- package/bundle/style.css +1 -4088
- package/cjs/components/action-sheet/action-sheet.d.ts +1 -1
- package/cjs/components/button/button.js +1 -1
- package/cjs/components/calendar/calendar.d.ts +1 -1
- package/cjs/components/cascader/cascader.d.ts +2 -0
- package/cjs/components/cascader/index.d.ts +1 -0
- package/cjs/components/cascader-view/cascader-view.d.ts +2 -1
- package/cjs/components/cascader-view/cascader-view.js +2 -1
- package/cjs/components/dialog/show.d.ts +1 -1
- package/cjs/components/image-viewer/slide.js +75 -56
- package/cjs/components/input/input.js +9 -2
- package/cjs/components/modal/show.d.ts +1 -1
- package/cjs/components/number-keyboard/number-keyboard.css +11 -14
- package/cjs/components/number-keyboard/number-keyboard.d.ts +1 -1
- package/cjs/components/number-keyboard/number-keyboard.js +19 -17
- package/cjs/components/passcode-input/index.d.ts +1 -1
- package/cjs/components/passcode-input/passcode-input.css +12 -12
- package/cjs/components/passcode-input/passcode-input.js +16 -8
- package/cjs/components/result/result.d.ts +1 -1
- package/cjs/components/result/result.js +7 -1
- package/cjs/components/search-bar/search-bar.js +12 -2
- package/cjs/locales/base.d.ts +9 -0
- package/cjs/locales/base.js +9 -0
- package/cjs/locales/en-US.d.ts +9 -0
- package/cjs/locales/es-ES.d.ts +9 -0
- package/cjs/locales/fa-IR.d.ts +9 -0
- package/cjs/locales/fr-FR.d.ts +9 -0
- package/cjs/locales/id-ID.d.ts +9 -0
- package/cjs/locales/kk-KZ.d.ts +9 -0
- package/cjs/locales/ko-KR.d.ts +9 -0
- package/cjs/locales/zh-CN.d.ts +9 -0
- package/cjs/locales/zh-CN.js +9 -0
- package/cjs/locales/zh-HK.d.ts +9 -0
- package/cjs/locales/zh-TW.d.ts +9 -0
- package/cjs/utils/matrix.d.ts +10 -0
- package/cjs/utils/matrix.js +60 -0
- package/es/components/action-sheet/action-sheet.d.ts +1 -1
- package/es/components/button/button.js +1 -1
- package/es/components/calendar/calendar.d.ts +1 -1
- package/es/components/cascader/cascader.d.ts +2 -0
- package/es/components/cascader/index.d.ts +1 -0
- package/es/components/cascader-view/cascader-view.d.ts +2 -1
- package/es/components/cascader-view/cascader-view.js +2 -1
- package/es/components/dialog/show.d.ts +1 -1
- package/es/components/image-viewer/slide.js +73 -56
- package/es/components/input/input.js +8 -2
- package/es/components/modal/show.d.ts +1 -1
- package/es/components/number-keyboard/number-keyboard.css +11 -14
- package/es/components/number-keyboard/number-keyboard.d.ts +1 -1
- package/es/components/number-keyboard/number-keyboard.js +19 -17
- package/es/components/passcode-input/index.d.ts +1 -1
- package/es/components/passcode-input/passcode-input.css +12 -12
- package/es/components/passcode-input/passcode-input.js +15 -8
- package/es/components/result/result.d.ts +1 -1
- package/es/components/result/result.js +6 -1
- package/es/components/search-bar/search-bar.js +12 -2
- package/es/locales/base.d.ts +9 -0
- package/es/locales/base.js +9 -0
- package/es/locales/en-US.d.ts +9 -0
- package/es/locales/es-ES.d.ts +9 -0
- package/es/locales/fa-IR.d.ts +9 -0
- package/es/locales/fr-FR.d.ts +9 -0
- package/es/locales/id-ID.d.ts +9 -0
- package/es/locales/kk-KZ.d.ts +9 -0
- package/es/locales/ko-KR.d.ts +9 -0
- package/es/locales/zh-CN.d.ts +9 -0
- package/es/locales/zh-CN.js +9 -0
- package/es/locales/zh-HK.d.ts +9 -0
- package/es/locales/zh-TW.d.ts +9 -0
- package/es/utils/matrix.d.ts +10 -0
- package/es/utils/matrix.js +27 -0
- package/package.json +1 -1
- package/umd/antd-mobile.js +1 -1
- package/2x/umd/antd-mobile.js.LICENSE.txt +0 -35
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React, { useRef } from 'react';
|
|
2
2
|
import { useSpring, animated } from '@react-spring/web';
|
|
3
|
+
import { useSize } from 'ahooks';
|
|
3
4
|
import { rubberbandIfOutOfBounds } from '../../utils/rubberband';
|
|
4
5
|
import { useDragAndPinch } from '../../utils/use-drag-and-pinch';
|
|
5
6
|
import { bound } from '../../utils/bound';
|
|
7
|
+
import * as mat from '../../utils/matrix';
|
|
6
8
|
const classPrefix = `adm-image-viewer`;
|
|
7
9
|
export const Slide = props => {
|
|
8
10
|
const {
|
|
@@ -11,54 +13,71 @@ export const Slide = props => {
|
|
|
11
13
|
const controlRef = useRef(null);
|
|
12
14
|
const imgRef = useRef(null);
|
|
13
15
|
const [{
|
|
14
|
-
|
|
15
|
-
x,
|
|
16
|
-
y
|
|
16
|
+
matrix
|
|
17
17
|
}, api] = useSpring(() => ({
|
|
18
|
-
|
|
19
|
-
x: 0,
|
|
20
|
-
y: 0,
|
|
18
|
+
matrix: mat.create(),
|
|
21
19
|
config: {
|
|
22
20
|
tension: 200
|
|
23
21
|
}
|
|
24
22
|
}));
|
|
23
|
+
const controlSize = useSize(controlRef);
|
|
24
|
+
const imgSize = useSize(imgRef);
|
|
25
25
|
const pinchLockRef = useRef(false);
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const boundMatrix = (nextMatrix, type, last = false) => {
|
|
28
|
+
if (!controlSize || !imgSize) return nextMatrix;
|
|
29
|
+
const controlLeft = -controlSize.width / 2;
|
|
30
|
+
const controlTop = -controlSize.height / 2;
|
|
31
|
+
const imgLeft = -imgSize.width / 2;
|
|
32
|
+
const imgTop = -imgSize.height / 2;
|
|
33
|
+
const zoom = mat.getScaleX(nextMatrix);
|
|
34
|
+
const scaledImgWidth = zoom * imgSize.width;
|
|
35
|
+
const scaledImgHeight = zoom * imgSize.height;
|
|
36
|
+
const [x, y] = mat.apply(nextMatrix, [imgLeft, imgTop]);
|
|
31
37
|
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
if (type === 'translate') {
|
|
39
|
+
let boundedX = x;
|
|
40
|
+
let boundedY = y;
|
|
41
|
+
|
|
42
|
+
if (scaledImgWidth > controlSize.width) {
|
|
43
|
+
const minX = controlLeft - (scaledImgWidth - controlSize.width);
|
|
44
|
+
const maxX = controlLeft;
|
|
45
|
+
boundedX = last ? bound(x, minX, maxX) : rubberbandIfOutOfBounds(x, minX, maxX, zoom * 50);
|
|
46
|
+
} else {
|
|
47
|
+
boundedX = -scaledImgWidth / 2;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (scaledImgHeight > controlSize.height) {
|
|
51
|
+
const minY = controlTop - (scaledImgHeight - controlSize.height);
|
|
52
|
+
const maxY = controlTop;
|
|
53
|
+
boundedY = last ? bound(y, minY, maxY) : rubberbandIfOutOfBounds(y, minY, maxY, zoom * 50);
|
|
54
|
+
} else {
|
|
55
|
+
boundedY = -scaledImgHeight / 2;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return mat.translate(nextMatrix, boundedX - x, boundedY - y);
|
|
35
59
|
}
|
|
36
60
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
left: -xOffset,
|
|
41
|
-
right: xOffset,
|
|
42
|
-
top: -yOffset,
|
|
43
|
-
bottom: yOffset
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
if (rubberband) {
|
|
47
|
-
return [rubberbandIfOutOfBounds(x, bounds.left, bounds.right, currentZoom * 50), rubberbandIfOutOfBounds(y, bounds.top, bounds.bottom, currentZoom * 50)];
|
|
48
|
-
} else {
|
|
49
|
-
return [bound(x, bounds.left, bounds.right), bound(y, bounds.top, bounds.bottom)];
|
|
61
|
+
if (type === 'scale' && last) {
|
|
62
|
+
const [boundedX, boundedY] = [scaledImgWidth > controlSize.width ? bound(x, controlLeft - (scaledImgWidth - controlSize.width), controlLeft) : -scaledImgWidth / 2, scaledImgHeight > controlSize.height ? bound(y, controlTop - (scaledImgHeight - controlSize.height), controlTop) : -scaledImgHeight / 2];
|
|
63
|
+
return mat.translate(nextMatrix, boundedX - x, boundedY - y);
|
|
50
64
|
}
|
|
51
|
-
|
|
65
|
+
|
|
66
|
+
return nextMatrix;
|
|
67
|
+
};
|
|
52
68
|
|
|
53
69
|
useDragAndPinch({
|
|
54
70
|
onDrag: state => {
|
|
71
|
+
if (state.first) return;
|
|
72
|
+
if (state.pinching) return state.cancel();
|
|
73
|
+
|
|
55
74
|
if (state.tap && state.elapsedTime > 0 && state.elapsedTime < 1000) {
|
|
56
75
|
// 判断点击时间>0是为了过滤掉非正常操作,例如用户长按选择图片之后的取消操作(也是一次点击)
|
|
57
76
|
props.onTap();
|
|
58
77
|
return;
|
|
59
78
|
}
|
|
60
79
|
|
|
61
|
-
const currentZoom =
|
|
80
|
+
const currentZoom = mat.getScaleX(matrix.get());
|
|
62
81
|
|
|
63
82
|
if (dragLockRef) {
|
|
64
83
|
dragLockRef.current = currentZoom !== 1;
|
|
@@ -66,24 +85,16 @@ export const Slide = props => {
|
|
|
66
85
|
|
|
67
86
|
if (!pinchLockRef.current && currentZoom <= 1) {
|
|
68
87
|
api.start({
|
|
69
|
-
|
|
70
|
-
y: 0
|
|
88
|
+
matrix: mat.create()
|
|
71
89
|
});
|
|
72
90
|
} else {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
const [x, y] = boundXY(state.offset, true);
|
|
81
|
-
api.start({
|
|
82
|
-
x,
|
|
83
|
-
y,
|
|
84
|
-
immediate: true
|
|
85
|
-
});
|
|
86
|
-
}
|
|
91
|
+
const currentMatrix = matrix.get();
|
|
92
|
+
const offset = [state.offset[0] - mat.getTranslateX(currentMatrix), state.offset[1] - mat.getTranslateY(currentMatrix)];
|
|
93
|
+
const nextMatrix = mat.translate(currentMatrix, ...(state.last ? [offset[0] + state.velocity[0] * state.direction[0] * 200, offset[1] + state.velocity[1] * state.direction[1] * 200] : offset));
|
|
94
|
+
api.start({
|
|
95
|
+
matrix: boundMatrix(nextMatrix, 'translate', state.last),
|
|
96
|
+
immediate: !state.last
|
|
97
|
+
});
|
|
87
98
|
}
|
|
88
99
|
},
|
|
89
100
|
onPinch: state => {
|
|
@@ -93,22 +104,30 @@ export const Slide = props => {
|
|
|
93
104
|
const [d] = state.offset;
|
|
94
105
|
if (d < 0) return;
|
|
95
106
|
const nextZoom = state.last ? bound(d, 1, props.maxZoom) : d;
|
|
96
|
-
api.start({
|
|
97
|
-
zoom: nextZoom,
|
|
98
|
-
immediate: !state.last
|
|
99
|
-
});
|
|
100
107
|
(_a = props.onZoomChange) === null || _a === void 0 ? void 0 : _a.call(props, nextZoom);
|
|
101
108
|
|
|
102
109
|
if (state.last && nextZoom <= 1) {
|
|
103
110
|
api.start({
|
|
104
|
-
|
|
105
|
-
y: 0
|
|
111
|
+
matrix: mat.create()
|
|
106
112
|
});
|
|
107
113
|
|
|
108
114
|
if (dragLockRef) {
|
|
109
115
|
dragLockRef.current = false;
|
|
110
116
|
}
|
|
111
117
|
} else {
|
|
118
|
+
if (!controlSize) return;
|
|
119
|
+
const currentMatrix = matrix.get();
|
|
120
|
+
const currentZoom = mat.getScaleX(currentMatrix);
|
|
121
|
+
const originOffsetX = state.origin[0] - controlSize.width / 2;
|
|
122
|
+
const originOffsetY = state.origin[1] - controlSize.height / 2;
|
|
123
|
+
let nextMatrix = mat.translate(currentMatrix, -originOffsetX, -originOffsetY);
|
|
124
|
+
nextMatrix = mat.scale(nextMatrix, nextZoom / currentZoom);
|
|
125
|
+
nextMatrix = mat.translate(nextMatrix, originOffsetX, originOffsetY);
|
|
126
|
+
api.start({
|
|
127
|
+
matrix: boundMatrix(nextMatrix, 'scale', state.last),
|
|
128
|
+
immediate: !state.last
|
|
129
|
+
});
|
|
130
|
+
|
|
112
131
|
if (dragLockRef) {
|
|
113
132
|
dragLockRef.current = true;
|
|
114
133
|
}
|
|
@@ -118,13 +137,13 @@ export const Slide = props => {
|
|
|
118
137
|
target: controlRef,
|
|
119
138
|
drag: {
|
|
120
139
|
// filterTaps: true,
|
|
121
|
-
from: () => [
|
|
140
|
+
from: () => [mat.getTranslateX(matrix.get()), mat.getTranslateY(matrix.get())],
|
|
122
141
|
pointer: {
|
|
123
142
|
touch: true
|
|
124
143
|
}
|
|
125
144
|
},
|
|
126
145
|
pinch: {
|
|
127
|
-
from: () => [
|
|
146
|
+
from: () => [mat.getScaleX(matrix.get()), 0],
|
|
128
147
|
pointer: {
|
|
129
148
|
touch: true
|
|
130
149
|
}
|
|
@@ -133,7 +152,7 @@ export const Slide = props => {
|
|
|
133
152
|
return React.createElement("div", {
|
|
134
153
|
className: `${classPrefix}-slide`,
|
|
135
154
|
onPointerMove: e => {
|
|
136
|
-
if (
|
|
155
|
+
if (mat.getScaleX(matrix.get()) !== 1) {
|
|
137
156
|
e.stopPropagation();
|
|
138
157
|
}
|
|
139
158
|
}
|
|
@@ -143,9 +162,7 @@ export const Slide = props => {
|
|
|
143
162
|
}, React.createElement(animated.div, {
|
|
144
163
|
className: `${classPrefix}-image-wrapper`,
|
|
145
164
|
style: {
|
|
146
|
-
|
|
147
|
-
translateY: y,
|
|
148
|
-
scale: zoom
|
|
165
|
+
matrix
|
|
149
166
|
}
|
|
150
167
|
}, React.createElement("img", {
|
|
151
168
|
ref: imgRef,
|
|
@@ -7,6 +7,7 @@ import classNames from 'classnames';
|
|
|
7
7
|
import { useIsomorphicLayoutEffect } from 'ahooks';
|
|
8
8
|
import { bound } from '../../utils/bound';
|
|
9
9
|
import { isIOS } from '../../utils/validate';
|
|
10
|
+
import { useConfig } from '../config-provider';
|
|
10
11
|
const classPrefix = `adm-input`;
|
|
11
12
|
const defaultProps = {
|
|
12
13
|
defaultValue: '',
|
|
@@ -18,6 +19,9 @@ export const Input = forwardRef((p, ref) => {
|
|
|
18
19
|
const [hasFocus, setHasFocus] = useState(false);
|
|
19
20
|
const compositionStartRef = useRef(false);
|
|
20
21
|
const nativeInputRef = useRef(null);
|
|
22
|
+
const {
|
|
23
|
+
locale
|
|
24
|
+
} = useConfig();
|
|
21
25
|
useImperativeHandle(ref, () => ({
|
|
22
26
|
clear: () => {
|
|
23
27
|
setValue('');
|
|
@@ -139,7 +143,8 @@ export const Input = forwardRef((p, ref) => {
|
|
|
139
143
|
role: props.role,
|
|
140
144
|
"aria-valuenow": props['aria-valuenow'],
|
|
141
145
|
"aria-valuemax": props['aria-valuemax'],
|
|
142
|
-
"aria-valuemin": props['aria-valuemin']
|
|
146
|
+
"aria-valuemin": props['aria-valuemin'],
|
|
147
|
+
"aria-label": props['aria-label']
|
|
143
148
|
}), shouldShowClear && React.createElement("div", {
|
|
144
149
|
className: `${classPrefix}-clear`,
|
|
145
150
|
onMouseDown: e => {
|
|
@@ -155,6 +160,7 @@ export const Input = forwardRef((p, ref) => {
|
|
|
155
160
|
compositionStartRef.current = false;
|
|
156
161
|
(_b = nativeInputRef.current) === null || _b === void 0 ? void 0 : _b.blur();
|
|
157
162
|
}
|
|
158
|
-
}
|
|
163
|
+
},
|
|
164
|
+
"aria-label": locale.Input.clear
|
|
159
165
|
}, React.createElement(CloseCircleFill, null))));
|
|
160
166
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ModalProps } from './modal';
|
|
2
|
-
export declare type ModalShowProps = Omit<ModalProps, 'visible'>;
|
|
2
|
+
export declare type ModalShowProps = Omit<ModalProps, 'visible' | 'destroyOnClose' | 'forceRender'>;
|
|
3
3
|
export declare type ModalShowHandler = {
|
|
4
4
|
close: () => void;
|
|
5
5
|
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
flex: 1;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
.adm-number-keyboard-main.confirmed-style .
|
|
7
|
+
.adm-number-keyboard-main.adm-number-keyboard-main-confirmed-style .adm-number-keyboard-key-sign {
|
|
8
8
|
background-color: var(--adm-color-white);
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
font-size: 32px;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
.adm-number-keyboard-header.with-title {
|
|
43
|
+
.adm-number-keyboard-header.adm-number-keyboard-header-with-title {
|
|
44
44
|
justify-content: space-between;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
.adm-number-keyboard-header.with-title .adm-number-keyboard-header-close-button {
|
|
47
|
+
.adm-number-keyboard-header.adm-number-keyboard-header-with-title .adm-number-keyboard-header-close-button {
|
|
48
48
|
padding-right: 0;
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -97,37 +97,33 @@
|
|
|
97
97
|
box-sizing: content-box;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
.adm-number-keyboard-key.
|
|
100
|
+
.adm-number-keyboard-key.adm-number-keyboard-key-mid {
|
|
101
101
|
flex-basis: 66.67%;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
.adm-number-keyboard-key.
|
|
104
|
+
.adm-number-keyboard-key.adm-number-keyboard-key-sign:active::before {
|
|
105
105
|
opacity: 0.1;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
.adm-number-keyboard-key.
|
|
108
|
+
.adm-number-keyboard-key.adm-number-keyboard-key-extra {
|
|
109
109
|
border-left: solid 2px var(--adm-color-border);
|
|
110
110
|
border-right: none;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
.adm-number-keyboard-key.
|
|
114
|
-
.adm-number-keyboard-key.number-key {
|
|
113
|
+
.adm-number-keyboard-key.adm-number-keyboard-key-extra,
|
|
114
|
+
.adm-number-keyboard-key.adm-number-keyboard-key-number {
|
|
115
115
|
background-color: var(--adm-color-background);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
.adm-number-keyboard-key.
|
|
119
|
-
.adm-number-keyboard-key.number-key:active::before {
|
|
118
|
+
.adm-number-keyboard-key.adm-number-keyboard-key-extra:active::before,
|
|
119
|
+
.adm-number-keyboard-key.adm-number-keyboard-key-number:active::before {
|
|
120
120
|
opacity: 0.1;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
.adm-number-keyboard-key.
|
|
123
|
+
.adm-number-keyboard-key.adm-number-keyboard-key-ok {
|
|
124
124
|
background-color: var(--adm-color-primary);
|
|
125
125
|
color: var(--adm-color-white);
|
|
126
126
|
height: 288px;
|
|
127
127
|
font-size: 32px;
|
|
128
128
|
border: none;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.adm-number-keyboard-bs-key {
|
|
132
|
-
height: 40px;
|
|
133
129
|
}
|
|
@@ -5,7 +5,7 @@ export declare type NumberKeyboardProps = {
|
|
|
5
5
|
visible?: boolean;
|
|
6
6
|
title?: string;
|
|
7
7
|
confirmText?: string | null;
|
|
8
|
-
customKey?:
|
|
8
|
+
customKey?: string | [string, string];
|
|
9
9
|
randomOrder?: boolean;
|
|
10
10
|
showCloseButton?: boolean;
|
|
11
11
|
onInput?: (v: string) => void;
|
|
@@ -34,13 +34,18 @@ export const NumberKeyboard = p => {
|
|
|
34
34
|
const keys = useMemo(() => {
|
|
35
35
|
const defaultKeys = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
|
36
36
|
const keyList = randomOrder ? shuffle(defaultKeys) : defaultKeys;
|
|
37
|
+
const customKeys = Array.isArray(customKey) ? customKey : [customKey];
|
|
37
38
|
keyList.push('0');
|
|
38
39
|
|
|
39
40
|
if (confirmText) {
|
|
40
|
-
|
|
41
|
+
if (customKeys.length === 2) {
|
|
42
|
+
keyList.splice(9, 0, customKeys.pop());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
keyList.push(customKeys[0] || '');
|
|
41
46
|
} else {
|
|
42
|
-
keyList.splice(9, 0,
|
|
43
|
-
keyList.push('BACKSPACE');
|
|
47
|
+
keyList.splice(9, 0, customKeys[0] || '');
|
|
48
|
+
keyList.push(customKeys[1] || 'BACKSPACE');
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
return keyList;
|
|
@@ -63,8 +68,7 @@ export const NumberKeyboard = p => {
|
|
|
63
68
|
const onBackspacePressEnd = () => {
|
|
64
69
|
clearTimeout(timeoutRef.current);
|
|
65
70
|
clearInterval(intervalRef.current);
|
|
66
|
-
};
|
|
67
|
-
|
|
71
|
+
};
|
|
68
72
|
|
|
69
73
|
const onKeyPress = (e, key) => {
|
|
70
74
|
var _a, _b;
|
|
@@ -86,18 +90,17 @@ export const NumberKeyboard = p => {
|
|
|
86
90
|
break;
|
|
87
91
|
|
|
88
92
|
default:
|
|
89
|
-
//
|
|
93
|
+
// onInput should't be called when customKey doesn't exist
|
|
90
94
|
if (key !== '') onInput === null || onInput === void 0 ? void 0 : onInput(key);
|
|
91
95
|
break;
|
|
92
96
|
}
|
|
93
|
-
};
|
|
94
|
-
|
|
97
|
+
};
|
|
95
98
|
|
|
96
99
|
const renderHeader = () => {
|
|
97
100
|
if (!showCloseButton && !title) return null;
|
|
98
101
|
return React.createElement("div", {
|
|
99
102
|
className: classNames(`${classPrefix}-header`, {
|
|
100
|
-
|
|
103
|
+
[`${classPrefix}-header-with-title`]: !!title
|
|
101
104
|
})
|
|
102
105
|
}, title && React.createElement("div", {
|
|
103
106
|
className: `${classPrefix}-title`
|
|
@@ -111,15 +114,14 @@ export const NumberKeyboard = p => {
|
|
|
111
114
|
role: 'button',
|
|
112
115
|
title: 'CLOSE'
|
|
113
116
|
}, React.createElement(DownOutline, null)));
|
|
114
|
-
};
|
|
115
|
-
|
|
117
|
+
};
|
|
116
118
|
|
|
117
119
|
const renderKey = (key, index) => {
|
|
118
120
|
const isNumberKey = /^\d$/.test(key);
|
|
119
121
|
const className = classNames(`${classPrefix}-key`, {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
[`${classPrefix}-key-number`]: isNumberKey,
|
|
123
|
+
[`${classPrefix}-key-sign`]: !isNumberKey && key,
|
|
124
|
+
[`${classPrefix}-key-mid`]: index === 9 && !!confirmText && keys.length < 12
|
|
123
125
|
});
|
|
124
126
|
const ariaProps = key ? {
|
|
125
127
|
role: 'button',
|
|
@@ -163,12 +165,12 @@ export const NumberKeyboard = p => {
|
|
|
163
165
|
className: `${classPrefix}-wrapper`
|
|
164
166
|
}, React.createElement("div", {
|
|
165
167
|
className: classNames(`${classPrefix}-main`, {
|
|
166
|
-
|
|
168
|
+
[`${classPrefix}-main-confirmed-style`]: !!confirmText
|
|
167
169
|
})
|
|
168
170
|
}, keys.map(renderKey)), !!confirmText && React.createElement("div", {
|
|
169
171
|
className: `${classPrefix}-confirm`
|
|
170
172
|
}, React.createElement("div", {
|
|
171
|
-
className: `${classPrefix}-key
|
|
173
|
+
className: `${classPrefix}-key ${classPrefix}-key-extra ${classPrefix}-key-bs`,
|
|
172
174
|
onTouchStart: () => {
|
|
173
175
|
onBackspacePressStart();
|
|
174
176
|
},
|
|
@@ -179,7 +181,7 @@ export const NumberKeyboard = p => {
|
|
|
179
181
|
title: 'BACKSPACE',
|
|
180
182
|
role: 'button'
|
|
181
183
|
}, React.createElement(TextDeletionOutline, null)), React.createElement("div", {
|
|
182
|
-
className: `${classPrefix}-key
|
|
184
|
+
className: `${classPrefix}-key ${classPrefix}-key-extra ${classPrefix}-key-ok`,
|
|
183
185
|
onTouchEnd: e => onKeyPress(e, 'OK'),
|
|
184
186
|
role: 'button'
|
|
185
187
|
}, confirmText))), props.safeArea && React.createElement("div", {
|
|
@@ -25,56 +25,56 @@
|
|
|
25
25
|
background: var(--adm-color-background);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
.adm-passcode-input:not(.seperated) {
|
|
28
|
+
.adm-passcode-input:not(.adm-passcode-input-seperated) {
|
|
29
29
|
border-radius: var(--border-radius);
|
|
30
30
|
overflow: hidden;
|
|
31
31
|
border: 2px solid var(--border-color);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
.adm-passcode-input:not(.seperated) .adm-passcode-input-cell:not(:last-child) {
|
|
34
|
+
.adm-passcode-input:not(.adm-passcode-input-seperated) .adm-passcode-input-cell:not(:last-child) {
|
|
35
35
|
border-right: 2px solid var(--border-color);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
.adm-passcode-input:not(.seperated).focused {
|
|
38
|
+
.adm-passcode-input:not(.adm-passcode-input-seperated).adm-passcode-input-focused {
|
|
39
39
|
border-color: var(--adm-color-primary);
|
|
40
40
|
box-shadow: 0 0 4px 0 var(--adm-color-primary);
|
|
41
41
|
outline: none;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
.adm-passcode-input:not(.seperated).error {
|
|
44
|
+
.adm-passcode-input:not(.adm-passcode-input-seperated).adm-passcode-input-error {
|
|
45
45
|
border-color: var(--adm-color-danger);
|
|
46
46
|
box-shadow: 0 0 4px 0 var(--adm-color-danger);
|
|
47
47
|
animation: 100ms ease-in-out 0s 3 normal none running adm-shake-horizontal;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
.adm-passcode-input.seperated .adm-passcode-input-cell {
|
|
50
|
+
.adm-passcode-input.adm-passcode-input-seperated .adm-passcode-input-cell {
|
|
51
51
|
border-radius: var(--border-radius);
|
|
52
52
|
border: 2px solid var(--border-color);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
.adm-passcode-input.seperated .adm-passcode-input-cell:not(:last-child) {
|
|
55
|
+
.adm-passcode-input.adm-passcode-input-seperated .adm-passcode-input-cell:not(:last-child) {
|
|
56
56
|
margin-right: var(--cell-gap);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
.adm-passcode-input.seperated .adm-passcode-input-cell
|
|
59
|
+
.adm-passcode-input.adm-passcode-input-seperated .adm-passcode-input-cell-focused {
|
|
60
60
|
border-color: var(--adm-color-primary);
|
|
61
61
|
box-shadow: 0 0 4px 0 var(--adm-color-primary);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
.adm-passcode-input
|
|
64
|
+
.adm-passcode-input-seperated.adm-passcode-input-focused {
|
|
65
65
|
outline: none;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
.adm-passcode-input.seperated.error {
|
|
68
|
+
.adm-passcode-input.adm-passcode-input-seperated.adm-passcode-input-error {
|
|
69
69
|
animation: 100ms ease-in-out 0s 3 normal none running adm-shake-horizontal;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
.adm-passcode-input.seperated.error .adm-passcode-input-cell {
|
|
72
|
+
.adm-passcode-input.adm-passcode-input-seperated.adm-passcode-input-error .adm-passcode-input-cell {
|
|
73
73
|
border-color: var(--adm-color-danger);
|
|
74
74
|
box-shadow: 0 0 4px 0 var(--adm-color-danger);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
.adm-passcode-input-cell
|
|
77
|
+
.adm-passcode-input-cell-dot::before {
|
|
78
78
|
content: '';
|
|
79
79
|
width: var(--dot-size);
|
|
80
80
|
height: var(--dot-size);
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
background: var(--adm-color-text);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
.adm-passcode-input-cell
|
|
85
|
+
.adm-passcode-input-cell-caret::after {
|
|
86
86
|
content: '';
|
|
87
87
|
width: 4px;
|
|
88
88
|
height: 1.1em;
|
|
@@ -4,6 +4,7 @@ import { withNativeProps } from '../../utils/native-props';
|
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import { bound } from '../../utils/bound';
|
|
6
6
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
7
|
+
import { useConfig } from '../config-provider';
|
|
7
8
|
const classPrefix = 'adm-passcode-input';
|
|
8
9
|
const defaultProps = {
|
|
9
10
|
defaultValue: '',
|
|
@@ -17,6 +18,9 @@ export const PasscodeInput = forwardRef((p, ref) => {
|
|
|
17
18
|
const props = mergeProps(defaultProps, p); // 防止 length 值不合法
|
|
18
19
|
|
|
19
20
|
const cellLength = props.length > 0 && props.length < Infinity ? Math.floor(props.length) : defaultProps.length;
|
|
21
|
+
const {
|
|
22
|
+
locale
|
|
23
|
+
} = useConfig();
|
|
20
24
|
const [focused, setFocused] = useState(false);
|
|
21
25
|
const [value, setValue] = usePropsValue(props);
|
|
22
26
|
const rootRef = useRef(null);
|
|
@@ -87,9 +91,9 @@ export const PasscodeInput = forwardRef((p, ref) => {
|
|
|
87
91
|
for (let i = 0; i < cellLength; i++) {
|
|
88
92
|
cells.push(React.createElement("div", {
|
|
89
93
|
className: classNames(`${classPrefix}-cell`, {
|
|
90
|
-
caret: props.caret && caretIndex === i && focused,
|
|
91
|
-
focused: focusedIndex === i && focused,
|
|
92
|
-
dot: !props.plain && chars[i]
|
|
94
|
+
[`${classPrefix}-cell-caret`]: props.caret && caretIndex === i && focused,
|
|
95
|
+
[`${classPrefix}-cell-focused`]: focusedIndex === i && focused,
|
|
96
|
+
[`${classPrefix}-cell-dot`]: !props.plain && chars[i]
|
|
93
97
|
}),
|
|
94
98
|
key: i
|
|
95
99
|
}, chars[i] && props.plain ? chars[i] : ''));
|
|
@@ -99,16 +103,18 @@ export const PasscodeInput = forwardRef((p, ref) => {
|
|
|
99
103
|
};
|
|
100
104
|
|
|
101
105
|
const cls = classNames(classPrefix, {
|
|
102
|
-
focused: focused,
|
|
103
|
-
error: props.error,
|
|
104
|
-
seperated: props.seperated
|
|
106
|
+
[`${classPrefix}-focused`]: focused,
|
|
107
|
+
[`${classPrefix}-error`]: props.error,
|
|
108
|
+
[`${classPrefix}-seperated`]: props.seperated
|
|
105
109
|
});
|
|
106
110
|
return React.createElement(React.Fragment, null, withNativeProps(props, React.createElement("div", {
|
|
107
111
|
ref: rootRef,
|
|
108
112
|
tabIndex: 0,
|
|
109
113
|
className: cls,
|
|
110
114
|
onFocus: onFocus,
|
|
111
|
-
onBlur: onBlur
|
|
115
|
+
onBlur: onBlur,
|
|
116
|
+
role: 'button',
|
|
117
|
+
"aria-label": locale.PasscodeInput.name
|
|
112
118
|
}, React.createElement("div", {
|
|
113
119
|
className: `${classPrefix}-cell-container`
|
|
114
120
|
}, renderCells()), React.createElement("input", {
|
|
@@ -120,7 +126,8 @@ export const PasscodeInput = forwardRef((p, ref) => {
|
|
|
120
126
|
inputMode: 'numeric',
|
|
121
127
|
onChange: e => {
|
|
122
128
|
setValue(e.target.value.slice(0, props.length));
|
|
123
|
-
}
|
|
129
|
+
},
|
|
130
|
+
"aria-hidden": true
|
|
124
131
|
}))), props.keyboard && React.cloneElement(props.keyboard, {
|
|
125
132
|
visible: focused,
|
|
126
133
|
onInput: v => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
3
|
export declare type ResultProps = {
|
|
4
|
-
status
|
|
4
|
+
status?: 'success' | 'error' | 'info' | 'waiting' | 'warning';
|
|
5
5
|
title: ReactNode;
|
|
6
6
|
description?: ReactNode;
|
|
7
7
|
icon?: ReactNode;
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { CheckCircleFill, CloseCircleFill, InformationCircleFill, ClockCircleFill, ExclamationCircleFill } from 'antd-mobile-icons';
|
|
4
4
|
import { withNativeProps } from '../../utils/native-props';
|
|
5
|
+
import { mergeProps } from '../../utils/with-default-props';
|
|
5
6
|
const classPrefix = `adm-result`;
|
|
6
7
|
const iconRecord = {
|
|
7
8
|
success: CheckCircleFill,
|
|
@@ -10,7 +11,11 @@ const iconRecord = {
|
|
|
10
11
|
waiting: ClockCircleFill,
|
|
11
12
|
warning: ExclamationCircleFill
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
+
const defaultProps = {
|
|
15
|
+
status: 'info'
|
|
16
|
+
};
|
|
17
|
+
export const Result = p => {
|
|
18
|
+
const props = mergeProps(defaultProps, p);
|
|
14
19
|
const {
|
|
15
20
|
status,
|
|
16
21
|
title,
|
|
@@ -26,6 +26,7 @@ export const SearchBar = forwardRef((p, ref) => {
|
|
|
26
26
|
const [value, setValue] = usePropsValue(props);
|
|
27
27
|
const [hasFocus, setHasFocus] = useState(false);
|
|
28
28
|
const inputRef = useRef(null);
|
|
29
|
+
const composingRef = useRef(false);
|
|
29
30
|
useImperativeHandle(ref, () => ({
|
|
30
31
|
clear: () => {
|
|
31
32
|
var _a;
|
|
@@ -118,8 +119,17 @@ export const SearchBar = forwardRef((p, ref) => {
|
|
|
118
119
|
onEnterPress: () => {
|
|
119
120
|
var _a, _b;
|
|
120
121
|
|
|
121
|
-
(
|
|
122
|
-
|
|
122
|
+
if (!composingRef.current) {
|
|
123
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
124
|
+
(_b = props.onSearch) === null || _b === void 0 ? void 0 : _b.call(props, value);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"aria-label": locale.SearchBar.name,
|
|
128
|
+
onCompositionStart: () => {
|
|
129
|
+
composingRef.current = true;
|
|
130
|
+
},
|
|
131
|
+
onCompositionEnd: () => {
|
|
132
|
+
composingRef.current = false;
|
|
123
133
|
}
|
|
124
134
|
})), renderCancelButton()));
|
|
125
135
|
});
|
package/2x/es/locales/base.d.ts
CHANGED
|
@@ -93,17 +93,26 @@ export declare const base: {
|
|
|
93
93
|
failedToLoad: string;
|
|
94
94
|
retry: string;
|
|
95
95
|
};
|
|
96
|
+
Input: {
|
|
97
|
+
clear: string;
|
|
98
|
+
};
|
|
96
99
|
Mask: {
|
|
97
100
|
name: string;
|
|
98
101
|
};
|
|
99
102
|
Modal: {
|
|
100
103
|
ok: string;
|
|
101
104
|
};
|
|
105
|
+
PasscodeInput: {
|
|
106
|
+
name: string;
|
|
107
|
+
};
|
|
102
108
|
PullToRefresh: {
|
|
103
109
|
pulling: string;
|
|
104
110
|
canRelease: string;
|
|
105
111
|
complete: string;
|
|
106
112
|
};
|
|
113
|
+
SearchBar: {
|
|
114
|
+
name: string;
|
|
115
|
+
};
|
|
107
116
|
Slider: {
|
|
108
117
|
name: string;
|
|
109
118
|
};
|