antd-mobile 5.25.1 → 5.26.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.development.js +188 -121
- package/2x/bundle/antd-mobile.cjs.js +8 -8
- package/2x/bundle/antd-mobile.es.development.js +188 -121
- package/2x/bundle/antd-mobile.es.js +3936 -3910
- package/2x/bundle/antd-mobile.umd.development.js +188 -121
- package/2x/bundle/antd-mobile.umd.js +8 -8
- package/2x/bundle/style.css +29 -5
- package/2x/cjs/components/calendar/calendar.js +9 -1
- package/2x/cjs/components/floating-bubble/floating-bubble.d.ts +8 -0
- package/2x/cjs/components/floating-bubble/floating-bubble.js +25 -5
- package/2x/cjs/components/form/form.d.ts +1 -1
- package/2x/cjs/components/image-uploader/image-uploader.css +16 -1
- package/2x/cjs/components/image-uploader/image-uploader.d.ts +4 -1
- package/2x/cjs/components/image-uploader/image-uploader.js +46 -9
- package/2x/cjs/components/image-uploader/preview-item.d.ts +2 -1
- package/2x/cjs/components/image-uploader/preview-item.js +5 -7
- package/2x/cjs/components/mask/mask.d.ts +1 -1
- package/2x/cjs/components/mask/mask.js +6 -2
- package/2x/cjs/components/notice-bar/notice-bar.css +13 -4
- package/2x/cjs/components/notice-bar/notice-bar.d.ts +10 -8
- package/2x/cjs/components/notice-bar/notice-bar.js +5 -2
- package/2x/cjs/components/stepper/stepper.d.ts +2 -0
- package/2x/cjs/components/stepper/stepper.js +55 -32
- package/2x/cjs/components/water-mark/water-mark.d.ts +1 -1
- package/2x/cjs/components/water-mark/water-mark.js +5 -1
- package/2x/es/components/calendar/calendar.js +9 -1
- package/2x/es/components/floating-bubble/floating-bubble.d.ts +8 -0
- package/2x/es/components/floating-bubble/floating-bubble.js +26 -6
- package/2x/es/components/form/form.d.ts +1 -1
- package/2x/es/components/image-uploader/image-uploader.css +16 -1
- package/2x/es/components/image-uploader/image-uploader.d.ts +4 -1
- package/2x/es/components/image-uploader/image-uploader.js +48 -11
- package/2x/es/components/image-uploader/preview-item.d.ts +2 -1
- package/2x/es/components/image-uploader/preview-item.js +6 -8
- package/2x/es/components/mask/mask.d.ts +1 -1
- package/2x/es/components/mask/mask.js +6 -2
- package/2x/es/components/notice-bar/notice-bar.css +13 -4
- package/2x/es/components/notice-bar/notice-bar.d.ts +10 -8
- package/2x/es/components/notice-bar/notice-bar.js +5 -2
- package/2x/es/components/stepper/stepper.d.ts +2 -0
- package/2x/es/components/stepper/stepper.js +55 -32
- package/2x/es/components/water-mark/water-mark.d.ts +1 -1
- package/2x/es/components/water-mark/water-mark.js +5 -1
- package/2x/package.json +9 -9
- package/bundle/antd-mobile.cjs.development.js +188 -121
- package/bundle/antd-mobile.cjs.js +8 -8
- package/bundle/antd-mobile.compatible.umd.js +1 -1
- package/bundle/antd-mobile.es.development.js +188 -121
- package/bundle/antd-mobile.es.js +3936 -3910
- package/bundle/antd-mobile.umd.development.js +188 -121
- package/bundle/antd-mobile.umd.js +8 -8
- package/bundle/style.css +1 -1
- package/cjs/components/calendar/calendar.js +9 -1
- package/cjs/components/floating-bubble/floating-bubble.d.ts +8 -0
- package/cjs/components/floating-bubble/floating-bubble.js +25 -5
- package/cjs/components/form/form.d.ts +1 -1
- package/cjs/components/image-uploader/image-uploader.css +15 -1
- package/cjs/components/image-uploader/image-uploader.d.ts +4 -1
- package/cjs/components/image-uploader/image-uploader.js +46 -9
- package/cjs/components/image-uploader/preview-item.d.ts +2 -1
- package/cjs/components/image-uploader/preview-item.js +5 -7
- package/cjs/components/mask/mask.d.ts +1 -1
- package/cjs/components/mask/mask.js +6 -2
- package/cjs/components/notice-bar/notice-bar.css +11 -4
- package/cjs/components/notice-bar/notice-bar.d.ts +10 -8
- package/cjs/components/notice-bar/notice-bar.js +5 -2
- package/cjs/components/stepper/stepper.d.ts +2 -0
- package/cjs/components/stepper/stepper.js +55 -32
- package/cjs/components/water-mark/water-mark.d.ts +1 -1
- package/cjs/components/water-mark/water-mark.js +5 -1
- package/es/components/calendar/calendar.js +9 -1
- package/es/components/floating-bubble/floating-bubble.d.ts +8 -0
- package/es/components/floating-bubble/floating-bubble.js +26 -6
- package/es/components/form/form.d.ts +1 -1
- package/es/components/image-uploader/image-uploader.css +15 -1
- package/es/components/image-uploader/image-uploader.d.ts +4 -1
- package/es/components/image-uploader/image-uploader.js +48 -11
- package/es/components/image-uploader/preview-item.d.ts +2 -1
- package/es/components/image-uploader/preview-item.js +6 -8
- package/es/components/mask/mask.d.ts +1 -1
- package/es/components/mask/mask.js +6 -2
- package/es/components/notice-bar/notice-bar.css +11 -4
- package/es/components/notice-bar/notice-bar.d.ts +10 -8
- package/es/components/notice-bar/notice-bar.js +5 -2
- package/es/components/stepper/stepper.d.ts +2 -0
- package/es/components/stepper/stepper.js +55 -32
- package/es/components/water-mark/water-mark.d.ts +1 -1
- package/es/components/water-mark/water-mark.js +5 -1
- package/package.json +9 -9
- package/umd/antd-mobile.js +1 -1
- package/2x/cjs/components/image/test/image.test.d.ts +0 -1
- package/2x/cjs/components/image/test/image.test.js +0 -73
- package/2x/es/components/image/test/image.test.d.ts +0 -1
- package/2x/es/components/image/test/image.test.js +0 -70
- package/cjs/components/image/test/image.test.d.ts +0 -1
- package/cjs/components/image/test/image.test.js +0 -73
- package/es/components/image/test/image.test.d.ts +0 -1
- package/es/components/image/test/image.test.js +0 -70
|
@@ -23,35 +23,45 @@ export const Stepper = p => {
|
|
|
23
23
|
step,
|
|
24
24
|
max,
|
|
25
25
|
min,
|
|
26
|
-
inputReadOnly
|
|
26
|
+
inputReadOnly,
|
|
27
|
+
digits,
|
|
28
|
+
formatter,
|
|
29
|
+
parser
|
|
27
30
|
} = props;
|
|
28
31
|
const {
|
|
29
32
|
locale
|
|
30
33
|
} = useConfig();
|
|
34
|
+
// ========================== Parse / Format ==========================
|
|
35
|
+
const parseValue = text => {
|
|
36
|
+
if (text === '') return null;
|
|
37
|
+
return parser ? parser(text) : parseFloat(text);
|
|
38
|
+
};
|
|
39
|
+
const formatValue = value => {
|
|
40
|
+
if (value === null) return '';
|
|
41
|
+
if (formatter) {
|
|
42
|
+
return formatter(value);
|
|
43
|
+
} else if (digits !== undefined) {
|
|
44
|
+
return value.toFixed(digits);
|
|
45
|
+
} else {
|
|
46
|
+
return value.toString();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
// ======================== Value & InputValue ========================
|
|
31
50
|
const [value, setValue] = usePropsValue(props);
|
|
32
|
-
const [inputValue, setInputValue] = useState(() =>
|
|
51
|
+
const [inputValue, setInputValue] = useState(() => formatValue(value));
|
|
52
|
+
// >>>>> Value
|
|
33
53
|
function setValueWithCheck(v) {
|
|
34
54
|
if (isNaN(v)) return;
|
|
35
55
|
let target = bound(v, props.min, props.max);
|
|
36
|
-
if (
|
|
37
|
-
target = parseFloat(target.toFixed(
|
|
56
|
+
if (digits !== undefined) {
|
|
57
|
+
target = parseFloat(target.toFixed(digits));
|
|
38
58
|
}
|
|
39
59
|
setValue(target);
|
|
40
60
|
}
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (!hasFocus) {
|
|
44
|
-
setInputValue(convertValueToText(value, props.digits));
|
|
45
|
-
}
|
|
46
|
-
}, [hasFocus]);
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
if (!hasFocus) {
|
|
49
|
-
setInputValue(convertValueToText(value, props.digits));
|
|
50
|
-
}
|
|
51
|
-
}, [value, props.digits]);
|
|
61
|
+
// >>>>> Input
|
|
52
62
|
const handleInputChange = v => {
|
|
53
63
|
setInputValue(v);
|
|
54
|
-
const value =
|
|
64
|
+
const value = parseValue(v);
|
|
55
65
|
if (value === null) {
|
|
56
66
|
if (props.allowEmpty) {
|
|
57
67
|
setValue(null);
|
|
@@ -62,6 +72,29 @@ export const Stepper = p => {
|
|
|
62
72
|
setValueWithCheck(value);
|
|
63
73
|
}
|
|
64
74
|
};
|
|
75
|
+
// ============================== Focus ===============================
|
|
76
|
+
const [focused, setFocused] = useState(false);
|
|
77
|
+
const inputRef = React.useRef(null);
|
|
78
|
+
function triggerFocus(nextFocus) {
|
|
79
|
+
setFocused(nextFocus);
|
|
80
|
+
// We will convert value to original text when focus
|
|
81
|
+
if (nextFocus) {
|
|
82
|
+
setInputValue(typeof value === 'number' ? String(value) : '');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
var _a, _b, _c;
|
|
87
|
+
if (focused) {
|
|
88
|
+
(_c = (_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.nativeElement) === null || _b === void 0 ? void 0 : _b.select) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
89
|
+
}
|
|
90
|
+
}, [focused]);
|
|
91
|
+
// Focus change to format value
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (!focused) {
|
|
94
|
+
setInputValue(formatValue(value));
|
|
95
|
+
}
|
|
96
|
+
}, [focused, value, digits]);
|
|
97
|
+
// ============================ Operations ============================
|
|
65
98
|
const handleMinus = () => {
|
|
66
99
|
setValueWithCheck(Big(value !== null && value !== void 0 ? value : 0).minus(step).toNumber());
|
|
67
100
|
};
|
|
@@ -84,9 +117,10 @@ export const Stepper = p => {
|
|
|
84
117
|
}
|
|
85
118
|
return false;
|
|
86
119
|
};
|
|
120
|
+
// ============================== Render ==============================
|
|
87
121
|
return withNativeProps(props, React.createElement("div", {
|
|
88
122
|
className: classNames(classPrefix, {
|
|
89
|
-
[`${classPrefix}-active`]:
|
|
123
|
+
[`${classPrefix}-active`]: focused
|
|
90
124
|
})
|
|
91
125
|
}, React.createElement(Button, {
|
|
92
126
|
className: `${classPrefix}-minus`,
|
|
@@ -99,10 +133,11 @@ export const Stepper = p => {
|
|
|
99
133
|
}, React.createElement(MinusOutline, null)), React.createElement("div", {
|
|
100
134
|
className: `${classPrefix}-middle`
|
|
101
135
|
}, React.createElement(Input, {
|
|
136
|
+
ref: inputRef,
|
|
102
137
|
className: `${classPrefix}-input`,
|
|
103
138
|
onFocus: e => {
|
|
104
139
|
var _a;
|
|
105
|
-
|
|
140
|
+
triggerFocus(true);
|
|
106
141
|
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
107
142
|
},
|
|
108
143
|
value: inputValue,
|
|
@@ -112,7 +147,7 @@ export const Stepper = p => {
|
|
|
112
147
|
disabled: disabled,
|
|
113
148
|
onBlur: e => {
|
|
114
149
|
var _a;
|
|
115
|
-
|
|
150
|
+
triggerFocus(false);
|
|
116
151
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
117
152
|
},
|
|
118
153
|
readOnly: inputReadOnly,
|
|
@@ -130,16 +165,4 @@ export const Stepper = p => {
|
|
|
130
165
|
color: 'primary',
|
|
131
166
|
"aria-label": locale.Stepper.increase
|
|
132
167
|
}, React.createElement(AddOutline, null))));
|
|
133
|
-
};
|
|
134
|
-
function convertValueToText(value, digits) {
|
|
135
|
-
if (value === null) return '';
|
|
136
|
-
if (digits !== undefined) {
|
|
137
|
-
return value.toFixed(digits);
|
|
138
|
-
} else {
|
|
139
|
-
return value.toString();
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
function convertTextToValue(text) {
|
|
143
|
-
if (text === '') return null;
|
|
144
|
-
return parseFloat(text);
|
|
145
|
-
}
|
|
168
|
+
};
|
|
@@ -10,7 +10,7 @@ export declare type WaterMarkProps = {
|
|
|
10
10
|
image?: string;
|
|
11
11
|
imageWidth?: number;
|
|
12
12
|
imageHeight?: number;
|
|
13
|
-
content?: string;
|
|
13
|
+
content?: string | string[];
|
|
14
14
|
fontColor?: string;
|
|
15
15
|
fontStyle?: 'none' | 'normal' | 'italic' | 'oblique';
|
|
16
16
|
fontFamily?: string;
|
|
@@ -58,7 +58,11 @@ export const WaterMark = p => {
|
|
|
58
58
|
const markSize = Number(fontSize) * ratio;
|
|
59
59
|
ctx.font = `${fontStyle} normal ${fontWeight} ${markSize}px/${markHeight}px ${fontFamily}`;
|
|
60
60
|
ctx.fillStyle = fontColor;
|
|
61
|
-
|
|
61
|
+
if (Array.isArray(content)) {
|
|
62
|
+
content.forEach((item, index) => ctx.fillText(item, 0, index * markSize));
|
|
63
|
+
} else {
|
|
64
|
+
ctx.fillText(content, 0, 0);
|
|
65
|
+
}
|
|
62
66
|
ctx.restore();
|
|
63
67
|
setBase64Url(canvas.toDataURL());
|
|
64
68
|
}
|
package/2x/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antd-mobile",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.26.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@floating-ui/dom": "^1.0.
|
|
6
|
-
"@react-spring/web": "^9.
|
|
5
|
+
"@floating-ui/dom": "^1.0.6",
|
|
6
|
+
"@react-spring/web": "^9.5.5",
|
|
7
7
|
"@use-gesture/react": "10.2.20",
|
|
8
|
-
"ahooks": "^3.7.
|
|
8
|
+
"ahooks": "^3.7.2",
|
|
9
9
|
"antd-mobile-icons": "^0.3.0",
|
|
10
10
|
"antd-mobile-v5-count": "^1.0.1",
|
|
11
11
|
"big.js": "^6.2.1",
|
|
12
|
-
"classnames": "^2.3.
|
|
13
|
-
"dayjs": "^1.11.
|
|
12
|
+
"classnames": "^2.3.2",
|
|
13
|
+
"dayjs": "^1.11.6",
|
|
14
14
|
"lodash": "^4.17.21",
|
|
15
|
-
"rc-field-form": "~1.27.
|
|
15
|
+
"rc-field-form": "~1.27.3",
|
|
16
16
|
"react-is": "^17.0.2",
|
|
17
17
|
"runes": "^0.4.3",
|
|
18
18
|
"staged-components": "^1.1.3",
|
|
19
|
-
"tslib": "^2.4.
|
|
20
|
-
"use-sync-external-store": "^1.
|
|
19
|
+
"tslib": "^2.4.1",
|
|
20
|
+
"use-sync-external-store": "^1.2.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|