antd-mobile 5.33.1 → 5.34.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 +2261 -2529
- package/2x/bundle/antd-mobile.cjs.js +7 -15
- package/2x/bundle/antd-mobile.es.development.js +1281 -1545
- package/2x/bundle/antd-mobile.es.js +8799 -8952
- package/2x/bundle/antd-mobile.umd.development.js +2591 -2859
- package/2x/bundle/antd-mobile.umd.js +7 -15
- package/2x/bundle/style.css +4 -3
- package/2x/cjs/components/dropdown/dropdown.js +3 -1
- package/2x/cjs/components/mask/mask.js +1 -0
- package/2x/cjs/components/number-keyboard/number-keyboard.js +10 -6
- package/2x/cjs/components/stepper/stepper.js +2 -2
- package/2x/cjs/components/swiper/index.d.ts +3 -2
- package/2x/cjs/components/swiper/swiper.css +2 -1
- package/2x/cjs/components/swiper/swiper.d.ts +18 -4
- package/2x/cjs/components/swiper/swiper.js +98 -53
- package/2x/cjs/components/tabs/tabs.d.ts +6 -0
- package/2x/cjs/components/tabs/tabs.js +14 -12
- package/2x/cjs/components/virtual-input/virtual-input.js +1 -1
- package/2x/cjs/global/global.css +2 -2
- package/2x/es/components/dropdown/dropdown.js +3 -1
- package/2x/es/components/mask/mask.js +1 -0
- package/2x/es/components/number-keyboard/number-keyboard.js +10 -6
- package/2x/es/components/stepper/stepper.js +1 -1
- package/2x/es/components/swiper/index.d.ts +3 -2
- package/2x/es/components/swiper/swiper.css +2 -1
- package/2x/es/components/swiper/swiper.d.ts +18 -4
- package/2x/es/components/swiper/swiper.js +98 -53
- package/2x/es/components/tabs/tabs.d.ts +6 -0
- package/2x/es/components/tabs/tabs.js +14 -12
- package/2x/es/components/virtual-input/virtual-input.js +1 -1
- package/2x/es/global/global.css +2 -2
- package/2x/package.json +2 -2
- package/bundle/antd-mobile.cjs.development.js +2261 -2529
- package/bundle/antd-mobile.cjs.js +7 -15
- package/bundle/antd-mobile.compatible.umd.js +1 -1
- package/bundle/antd-mobile.es.development.js +1281 -1545
- package/bundle/antd-mobile.es.js +8799 -8952
- package/bundle/antd-mobile.umd.development.js +2591 -2859
- package/bundle/antd-mobile.umd.js +7 -15
- package/bundle/style.css +1 -1
- package/cjs/components/dropdown/dropdown.js +3 -1
- package/cjs/components/mask/mask.js +1 -0
- package/cjs/components/number-keyboard/number-keyboard.js +10 -6
- package/cjs/components/stepper/stepper.js +2 -2
- package/cjs/components/swiper/index.d.ts +3 -2
- package/cjs/components/swiper/swiper.css +2 -1
- package/cjs/components/swiper/swiper.d.ts +18 -4
- package/cjs/components/swiper/swiper.js +98 -53
- package/cjs/components/tabs/tabs.d.ts +6 -0
- package/cjs/components/tabs/tabs.js +14 -12
- package/cjs/components/virtual-input/virtual-input.js +1 -1
- package/cjs/global/global.css +2 -2
- package/es/components/dropdown/dropdown.js +3 -1
- package/es/components/mask/mask.js +1 -0
- package/es/components/number-keyboard/number-keyboard.js +10 -6
- package/es/components/stepper/stepper.js +1 -1
- package/es/components/swiper/index.d.ts +3 -2
- package/es/components/swiper/swiper.css +2 -1
- package/es/components/swiper/swiper.d.ts +18 -4
- package/es/components/swiper/swiper.js +98 -53
- package/es/components/tabs/tabs.d.ts +6 -0
- package/es/components/tabs/tabs.js +14 -12
- package/es/components/virtual-input/virtual-input.js +1 -1
- package/es/global/global.css +2 -2
- package/package.json +2 -2
- package/umd/antd-mobile.js +1 -1
- package/umd/antd-mobile.js.LICENSE.txt +0 -9
|
@@ -60,8 +60,10 @@ const Dropdown = (0, _react.forwardRef)((p, ref) => {
|
|
|
60
60
|
const navs = _react.default.Children.map(props.children, child => {
|
|
61
61
|
if ((0, _react.isValidElement)(child)) {
|
|
62
62
|
const childProps = Object.assign(Object.assign({}, child.props), {
|
|
63
|
-
onClick:
|
|
63
|
+
onClick: event => {
|
|
64
|
+
var _a, _b;
|
|
64
65
|
changeActive(child.key);
|
|
66
|
+
(_b = (_a = child.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
65
67
|
},
|
|
66
68
|
active: child.key === value,
|
|
67
69
|
arrow: child.props.arrow === undefined ? props.arrow : child.props.arrow
|
|
@@ -79,6 +79,7 @@ const Mask = p => {
|
|
|
79
79
|
const node = (0, _withStopPropagation.withStopPropagation)(props.stopPropagation, (0, _nativeProps.withNativeProps)(props, _react.default.createElement(_web.animated.div, {
|
|
80
80
|
className: classPrefix,
|
|
81
81
|
ref: ref,
|
|
82
|
+
"aria-hidden": true,
|
|
82
83
|
style: Object.assign(Object.assign({}, props.style), {
|
|
83
84
|
background,
|
|
84
85
|
opacity,
|
|
@@ -13,6 +13,7 @@ var _popup = _interopRequireDefault(require("../popup"));
|
|
|
13
13
|
var _nativeProps = require("../../utils/native-props");
|
|
14
14
|
var _safeArea = _interopRequireDefault(require("../safe-area"));
|
|
15
15
|
var _ahooks = require("ahooks");
|
|
16
|
+
var _configProvider = require("../config-provider");
|
|
16
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
19
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -39,6 +40,9 @@ const NumberKeyboard = p => {
|
|
|
39
40
|
showCloseButton,
|
|
40
41
|
onInput
|
|
41
42
|
} = props;
|
|
43
|
+
const {
|
|
44
|
+
locale
|
|
45
|
+
} = (0, _configProvider.useConfig)();
|
|
42
46
|
const keyboardRef = (0, _react.useRef)(null);
|
|
43
47
|
const keys = (0, _react.useMemo)(() => {
|
|
44
48
|
const defaultKeys = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
|
@@ -106,8 +110,8 @@ const NumberKeyboard = p => {
|
|
|
106
110
|
var _a;
|
|
107
111
|
(_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
108
112
|
},
|
|
109
|
-
role: '
|
|
110
|
-
title:
|
|
113
|
+
role: 'button',
|
|
114
|
+
title: locale.common.close,
|
|
111
115
|
tabIndex: -1
|
|
112
116
|
}, _react.default.createElement(_antdMobileIcons.DownOutline, null)));
|
|
113
117
|
};
|
|
@@ -119,7 +123,7 @@ const NumberKeyboard = p => {
|
|
|
119
123
|
[`${classPrefix}-key-mid`]: index === 9 && !!confirmText && keys.length < 12
|
|
120
124
|
});
|
|
121
125
|
const ariaProps = key ? {
|
|
122
|
-
role: '
|
|
126
|
+
role: 'button',
|
|
123
127
|
title: key,
|
|
124
128
|
tabIndex: -1
|
|
125
129
|
} : undefined;
|
|
@@ -176,13 +180,13 @@ const NumberKeyboard = p => {
|
|
|
176
180
|
// Long press should not trigger native context menu
|
|
177
181
|
e.preventDefault();
|
|
178
182
|
},
|
|
179
|
-
title:
|
|
180
|
-
role: '
|
|
183
|
+
title: locale.Input.clear,
|
|
184
|
+
role: 'button',
|
|
181
185
|
tabIndex: -1
|
|
182
186
|
}, _react.default.createElement(_antdMobileIcons.TextDeletionOutline, null)), _react.default.createElement("div", {
|
|
183
187
|
className: `${classPrefix}-key ${classPrefix}-key-extra ${classPrefix}-key-ok`,
|
|
184
188
|
onTouchEnd: e => onKeyPress(e, 'OK'),
|
|
185
|
-
role: '
|
|
189
|
+
role: 'button',
|
|
186
190
|
tabIndex: -1,
|
|
187
191
|
"aria-label": confirmText
|
|
188
192
|
}, confirmText))), props.safeArea && _react.default.createElement("div", {
|
|
@@ -8,7 +8,7 @@ exports.Stepper = void 0;
|
|
|
8
8
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _antdMobileIcons = require("antd-mobile-icons");
|
|
11
|
-
var
|
|
11
|
+
var _rcUtil = require("rc-util");
|
|
12
12
|
var _miniDecimal = _interopRequireWildcard(require("@rc-component/mini-decimal"));
|
|
13
13
|
var _nativeProps = require("../../utils/native-props");
|
|
14
14
|
var _withDefaultProps = require("../../utils/with-default-props");
|
|
@@ -77,7 +77,7 @@ function InnerStepper(p, ref) {
|
|
|
77
77
|
return formatter ? formatter(value) : fixedValue(value);
|
|
78
78
|
};
|
|
79
79
|
// ======================== Value & InputValue ========================
|
|
80
|
-
const [mergedValue, setMergedValue] = (0,
|
|
80
|
+
const [mergedValue, setMergedValue] = (0, _rcUtil.useMergedState)(defaultValue, {
|
|
81
81
|
value,
|
|
82
82
|
onChange: nextValue => {
|
|
83
83
|
onChange === null || onChange === void 0 ? void 0 : onChange(nextValue);
|
|
@@ -9,13 +9,14 @@ declare const _default: import("react").ForwardRefExoticComponent<{
|
|
|
9
9
|
direction?: "vertical" | "horizontal" | undefined;
|
|
10
10
|
onIndexChange?: ((index: number) => void) | undefined;
|
|
11
11
|
indicatorProps?: Pick<import("../page-indicator").PageIndicatorProps, "style" | "className" | "color"> | undefined;
|
|
12
|
-
indicator?: ((total: number, current: number) => import("react").ReactNode) | undefined;
|
|
12
|
+
indicator?: false | ((total: number, current: number) => import("react").ReactNode) | undefined;
|
|
13
13
|
slideSize?: number | undefined;
|
|
14
14
|
trackOffset?: number | undefined;
|
|
15
15
|
stuckAtBoundary?: boolean | undefined;
|
|
16
16
|
rubberband?: boolean | undefined;
|
|
17
17
|
stopPropagation?: ("mousedown" | "mousemove" | "mouseup")[] | undefined;
|
|
18
|
-
|
|
18
|
+
total?: number | undefined;
|
|
19
|
+
children?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>[] | ((index: number) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) | undefined;
|
|
19
20
|
} & {
|
|
20
21
|
className?: string | undefined;
|
|
21
22
|
style?: (import("react").CSSProperties & Partial<Record<"--width" | "--height" | "--border-radius" | "--track-padding", string>>) | undefined;
|
|
@@ -22,13 +22,20 @@ export declare type SwiperProps = {
|
|
|
22
22
|
direction?: 'horizontal' | 'vertical';
|
|
23
23
|
onIndexChange?: (index: number) => void;
|
|
24
24
|
indicatorProps?: Pick<PageIndicatorProps, 'color' | 'style' | 'className'>;
|
|
25
|
-
indicator?: (total: number, current: number) => ReactNode;
|
|
25
|
+
indicator?: false | ((total: number, current: number) => ReactNode);
|
|
26
26
|
slideSize?: number;
|
|
27
27
|
trackOffset?: number;
|
|
28
28
|
stuckAtBoundary?: boolean;
|
|
29
29
|
rubberband?: boolean;
|
|
30
30
|
stopPropagation?: PropagationEvent[];
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Virtual scroll usage. Should work with renderProps `children`
|
|
33
|
+
*/
|
|
34
|
+
total?: number;
|
|
35
|
+
/**
|
|
36
|
+
* renderProps is only work when `total` used
|
|
37
|
+
*/
|
|
38
|
+
children?: ReactElement | ReactElement[] | ((index: number) => ReactElement);
|
|
32
39
|
} & NativeProps<'--height' | '--width' | '--border-radius' | '--track-padding'>;
|
|
33
40
|
export declare const Swiper: React.ForwardRefExoticComponent<{
|
|
34
41
|
defaultIndex?: number | undefined;
|
|
@@ -39,13 +46,20 @@ export declare const Swiper: React.ForwardRefExoticComponent<{
|
|
|
39
46
|
direction?: "vertical" | "horizontal" | undefined;
|
|
40
47
|
onIndexChange?: ((index: number) => void) | undefined;
|
|
41
48
|
indicatorProps?: Pick<PageIndicatorProps, "style" | "className" | "color"> | undefined;
|
|
42
|
-
indicator?: ((total: number, current: number) => ReactNode) | undefined;
|
|
49
|
+
indicator?: false | ((total: number, current: number) => ReactNode) | undefined;
|
|
43
50
|
slideSize?: number | undefined;
|
|
44
51
|
trackOffset?: number | undefined;
|
|
45
52
|
stuckAtBoundary?: boolean | undefined;
|
|
46
53
|
rubberband?: boolean | undefined;
|
|
47
54
|
stopPropagation?: ("mousedown" | "mousemove" | "mouseup")[] | undefined;
|
|
48
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Virtual scroll usage. Should work with renderProps `children`
|
|
57
|
+
*/
|
|
58
|
+
total?: number | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* renderProps is only work when `total` used
|
|
61
|
+
*/
|
|
62
|
+
children?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactElement<any, string | React.JSXElementConstructor<any>>[] | ((index: number) => ReactElement) | undefined;
|
|
49
63
|
} & {
|
|
50
64
|
className?: string | undefined;
|
|
51
65
|
style?: (React.CSSProperties & Partial<Record<"--width" | "--height" | "--border-radius" | "--track-padding", string>>) | undefined;
|
|
@@ -43,37 +43,52 @@ const defaultProps = {
|
|
|
43
43
|
let currentUid;
|
|
44
44
|
const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) => {
|
|
45
45
|
const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
|
|
46
|
+
const {
|
|
47
|
+
direction,
|
|
48
|
+
total,
|
|
49
|
+
children,
|
|
50
|
+
indicator
|
|
51
|
+
} = props;
|
|
46
52
|
const [uid] = (0, _react.useState)({});
|
|
47
53
|
const timeoutRef = (0, _react.useRef)(null);
|
|
48
|
-
const isVertical =
|
|
54
|
+
const isVertical = direction === 'vertical';
|
|
49
55
|
const slideRatio = props.slideSize / 100;
|
|
50
56
|
const offsetRatio = props.trackOffset / 100;
|
|
51
57
|
const {
|
|
52
58
|
validChildren,
|
|
53
|
-
count
|
|
59
|
+
count,
|
|
60
|
+
renderChildren
|
|
54
61
|
} = (0, _react.useMemo)(() => {
|
|
55
62
|
let count = 0;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
let renderChildren = undefined;
|
|
64
|
+
let validChildren = undefined;
|
|
65
|
+
if (typeof children === 'function') {
|
|
66
|
+
renderChildren = children;
|
|
67
|
+
} else {
|
|
68
|
+
validChildren = _react.default.Children.map(children, child => {
|
|
69
|
+
if (!_react.default.isValidElement(child)) return null;
|
|
70
|
+
if (child.type !== _swiperItem.SwiperItem) {
|
|
71
|
+
(0, _devLog.devWarning)('Swiper', 'The children of `Swiper` must be `Swiper.Item` components.');
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
count++;
|
|
75
|
+
return child;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
65
78
|
return {
|
|
79
|
+
renderChildren,
|
|
66
80
|
validChildren,
|
|
67
81
|
count
|
|
68
82
|
};
|
|
69
|
-
}, [
|
|
70
|
-
|
|
83
|
+
}, [children]);
|
|
84
|
+
const mergedTotal = total !== null && total !== void 0 ? total : count;
|
|
85
|
+
if (mergedTotal === 0 || !validChildren && !renderChildren) {
|
|
71
86
|
(0, _devLog.devWarning)('Swiper', '`Swiper` needs at least one child.');
|
|
72
87
|
return null;
|
|
73
88
|
}
|
|
74
89
|
return () => {
|
|
75
90
|
let loop = props.loop;
|
|
76
|
-
if (slideRatio * (
|
|
91
|
+
if (slideRatio * (mergedTotal - 1) < 1) {
|
|
77
92
|
loop = false;
|
|
78
93
|
}
|
|
79
94
|
const trackRef = (0, _react.useRef)(null);
|
|
@@ -87,7 +102,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
87
102
|
const [dragging, setDragging, draggingRef] = (0, _useRefState.useRefState)(false);
|
|
88
103
|
function boundIndex(current) {
|
|
89
104
|
let min = 0;
|
|
90
|
-
let max =
|
|
105
|
+
let max = mergedTotal - 1;
|
|
91
106
|
if (props.stuckAtBoundary) {
|
|
92
107
|
min += offsetRatio / slideRatio;
|
|
93
108
|
max -= (1 - slideRatio - offsetRatio) / slideRatio;
|
|
@@ -106,7 +121,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
106
121
|
if (draggingRef.current) return;
|
|
107
122
|
if (!loop) return;
|
|
108
123
|
const rawX = position.get();
|
|
109
|
-
const totalWidth = 100 *
|
|
124
|
+
const totalWidth = 100 * mergedTotal;
|
|
110
125
|
const standardPosition = modulus(rawX, totalWidth);
|
|
111
126
|
if (standardPosition === rawX) return;
|
|
112
127
|
api.start({
|
|
@@ -114,7 +129,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
114
129
|
immediate: true
|
|
115
130
|
});
|
|
116
131
|
}
|
|
117
|
-
}), [
|
|
132
|
+
}), [mergedTotal]);
|
|
118
133
|
const dragCancelRef = (0, _react.useRef)(null);
|
|
119
134
|
function forceCancelDrag() {
|
|
120
135
|
var _a;
|
|
@@ -161,7 +176,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
161
176
|
if (loop) return {};
|
|
162
177
|
const slidePixels = getSlidePixels();
|
|
163
178
|
const lowerBound = boundIndex(0) * slidePixels;
|
|
164
|
-
const upperBound = boundIndex(
|
|
179
|
+
const upperBound = boundIndex(mergedTotal - 1) * slidePixels;
|
|
165
180
|
return isVertical ? {
|
|
166
181
|
top: lowerBound,
|
|
167
182
|
bottom: upperBound
|
|
@@ -180,7 +195,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
180
195
|
function swipeTo(index, immediate = false) {
|
|
181
196
|
var _a;
|
|
182
197
|
const roundedIndex = Math.round(index);
|
|
183
|
-
const targetIndex = loop ? modulus(roundedIndex,
|
|
198
|
+
const targetIndex = loop ? modulus(roundedIndex, mergedTotal) : (0, _bound.bound)(roundedIndex, 0, mergedTotal - 1);
|
|
184
199
|
if (targetIndex !== getCurrent()) {
|
|
185
200
|
(_a = props.onIndexChange) === null || _a === void 0 ? void 0 : _a.call(props, targetIndex);
|
|
186
201
|
}
|
|
@@ -202,7 +217,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
202
217
|
swipePrev
|
|
203
218
|
}));
|
|
204
219
|
(0, _ahooks.useIsomorphicLayoutEffect)(() => {
|
|
205
|
-
const maxIndex =
|
|
220
|
+
const maxIndex = mergedTotal - 1;
|
|
206
221
|
if (current > maxIndex) {
|
|
207
222
|
swipeTo(maxIndex, true);
|
|
208
223
|
}
|
|
@@ -223,43 +238,67 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
223
238
|
return () => {
|
|
224
239
|
if (timeoutRef.current) window.clearTimeout(timeoutRef.current);
|
|
225
240
|
};
|
|
226
|
-
}, [autoplay, autoplayInterval, dragging,
|
|
241
|
+
}, [autoplay, autoplayInterval, dragging, mergedTotal]);
|
|
242
|
+
// ============================== Render ==============================
|
|
243
|
+
// Render Item
|
|
244
|
+
function renderItem(index, child) {
|
|
245
|
+
let itemStyle = {};
|
|
246
|
+
if (loop) {
|
|
247
|
+
itemStyle = {
|
|
248
|
+
[isVertical ? 'y' : 'x']: position.to(position => {
|
|
249
|
+
let finalPosition = -position + index * 100;
|
|
250
|
+
const totalWidth = mergedTotal * 100;
|
|
251
|
+
const flagWidth = totalWidth / 2;
|
|
252
|
+
finalPosition = modulus(finalPosition + flagWidth, totalWidth) - flagWidth;
|
|
253
|
+
return `${finalPosition}%`;
|
|
254
|
+
}),
|
|
255
|
+
[isVertical ? 'top' : 'left']: `-${index * 100}%`
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
return _react.default.createElement(_web.animated.div, {
|
|
259
|
+
className: (0, _classnames.default)(`${classPrefix}-slide`, {
|
|
260
|
+
[`${classPrefix}-slide-active`]: current === index
|
|
261
|
+
}),
|
|
262
|
+
style: itemStyle,
|
|
263
|
+
key: index
|
|
264
|
+
}, child);
|
|
265
|
+
}
|
|
266
|
+
function renderItems() {
|
|
267
|
+
if (renderChildren && total) {
|
|
268
|
+
const offsetCount = 2;
|
|
269
|
+
const startIndex = Math.max(current - offsetCount, 0);
|
|
270
|
+
const endIndex = Math.min(current + offsetCount, total - 1);
|
|
271
|
+
const items = [];
|
|
272
|
+
for (let index = startIndex; index <= endIndex; index += 1) {
|
|
273
|
+
items.push(renderItem(index, renderChildren(index)));
|
|
274
|
+
}
|
|
275
|
+
return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement("div", {
|
|
276
|
+
className: `${classPrefix}-slide-placeholder`,
|
|
277
|
+
style: {
|
|
278
|
+
width: `${startIndex * 100}%`
|
|
279
|
+
}
|
|
280
|
+
}), items);
|
|
281
|
+
}
|
|
282
|
+
return _react.default.Children.map(validChildren, (child, index) => {
|
|
283
|
+
return renderItem(index, child);
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
// Render Track Inner
|
|
227
287
|
function renderTrackInner() {
|
|
228
288
|
if (loop) {
|
|
229
289
|
return _react.default.createElement("div", {
|
|
230
290
|
className: `${classPrefix}-track-inner`
|
|
231
|
-
},
|
|
232
|
-
return _react.default.createElement(_web.animated.div, {
|
|
233
|
-
className: (0, _classnames.default)(`${classPrefix}-slide`, {
|
|
234
|
-
[`${classPrefix}-slide-active`]: current === index
|
|
235
|
-
}),
|
|
236
|
-
style: {
|
|
237
|
-
[isVertical ? 'y' : 'x']: position.to(position => {
|
|
238
|
-
let finalPosition = -position + index * 100;
|
|
239
|
-
const totalWidth = count * 100;
|
|
240
|
-
const flagWidth = totalWidth / 2;
|
|
241
|
-
finalPosition = modulus(finalPosition + flagWidth, totalWidth) - flagWidth;
|
|
242
|
-
return `${finalPosition}%`;
|
|
243
|
-
}),
|
|
244
|
-
[isVertical ? 'top' : 'left']: `-${index * 100}%`
|
|
245
|
-
}
|
|
246
|
-
}, child);
|
|
247
|
-
}));
|
|
291
|
+
}, renderItems());
|
|
248
292
|
} else {
|
|
249
293
|
return _react.default.createElement(_web.animated.div, {
|
|
250
294
|
className: `${classPrefix}-track-inner`,
|
|
251
295
|
style: {
|
|
252
296
|
[isVertical ? 'y' : 'x']: position.to(position => `${-position}%`)
|
|
253
297
|
}
|
|
254
|
-
},
|
|
255
|
-
return _react.default.createElement("div", {
|
|
256
|
-
className: (0, _classnames.default)(`${classPrefix}-slide`, {
|
|
257
|
-
[`${classPrefix}-slide-active`]: current === index
|
|
258
|
-
})
|
|
259
|
-
}, child);
|
|
260
|
-
}));
|
|
298
|
+
}, renderItems());
|
|
261
299
|
}
|
|
262
300
|
}
|
|
301
|
+
// Render
|
|
263
302
|
const style = {
|
|
264
303
|
'--slide-size': `${props.slideSize}%`,
|
|
265
304
|
'--track-offset': `${props.trackOffset}%`
|
|
@@ -273,8 +312,20 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
273
312
|
};
|
|
274
313
|
}
|
|
275
314
|
const mergedProps = (0, _withFuncProps.mergeFuncProps)(dragProps, stopPropagationProps);
|
|
315
|
+
let indicatorNode = null;
|
|
316
|
+
if (typeof indicator === 'function') {
|
|
317
|
+
indicatorNode = indicator(mergedTotal, current);
|
|
318
|
+
} else if (indicator !== false) {
|
|
319
|
+
indicatorNode = _react.default.createElement("div", {
|
|
320
|
+
className: `${classPrefix}-indicator`
|
|
321
|
+
}, _react.default.createElement(_pageIndicator.default, Object.assign({}, props.indicatorProps, {
|
|
322
|
+
total: mergedTotal,
|
|
323
|
+
current: current,
|
|
324
|
+
direction: direction
|
|
325
|
+
})));
|
|
326
|
+
}
|
|
276
327
|
return (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
|
|
277
|
-
className: (0, _classnames.default)(classPrefix, `${classPrefix}-${
|
|
328
|
+
className: (0, _classnames.default)(classPrefix, `${classPrefix}-${direction}`),
|
|
278
329
|
style: style
|
|
279
330
|
}, _react.default.createElement("div", Object.assign({
|
|
280
331
|
ref: trackRef,
|
|
@@ -287,13 +338,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
287
338
|
}
|
|
288
339
|
forceCancelDrag();
|
|
289
340
|
}
|
|
290
|
-
}, mergedProps), renderTrackInner()),
|
|
291
|
-
className: `${classPrefix}-indicator`
|
|
292
|
-
}, _react.default.createElement(_pageIndicator.default, Object.assign({}, props.indicatorProps, {
|
|
293
|
-
total: count,
|
|
294
|
-
current: current,
|
|
295
|
-
direction: props.direction
|
|
296
|
-
}))) : props.indicator(count, current)));
|
|
341
|
+
}, mergedProps), renderTrackInner()), indicatorNode));
|
|
297
342
|
};
|
|
298
343
|
}));
|
|
299
344
|
exports.Swiper = Swiper;
|
|
@@ -16,5 +16,11 @@ export declare type TabsProps = {
|
|
|
16
16
|
onChange?: (key: string) => void;
|
|
17
17
|
children?: ReactNode;
|
|
18
18
|
direction?: 'ltr' | 'rtl';
|
|
19
|
+
/**
|
|
20
|
+
* @experimental Support disabled auto scroll when Tabs header content change.
|
|
21
|
+
* This API name or function may change in the future.
|
|
22
|
+
* Please lock the version if you want to use it.
|
|
23
|
+
*/
|
|
24
|
+
autoScroll?: boolean;
|
|
19
25
|
} & NativeProps<'--fixed-active-line-width' | '--active-line-height' | '--active-line-border-radius' | '--title-font-size' | '--content-padding' | '--active-title-color' | '--active-line-color'>;
|
|
20
26
|
export declare const Tabs: FC<TabsProps>;
|
|
@@ -61,7 +61,7 @@ const Tabs = p => {
|
|
|
61
61
|
const [{
|
|
62
62
|
x,
|
|
63
63
|
width
|
|
64
|
-
},
|
|
64
|
+
}, inkApi] = (0, _web.useSpring)(() => ({
|
|
65
65
|
x: 0,
|
|
66
66
|
width: 0,
|
|
67
67
|
config: {
|
|
@@ -88,12 +88,12 @@ const Tabs = p => {
|
|
|
88
88
|
clamp: true
|
|
89
89
|
}
|
|
90
90
|
}));
|
|
91
|
-
function animate(immediate = false) {
|
|
91
|
+
function animate(immediate = false, fromMutation = false) {
|
|
92
92
|
const container = tabListContainerRef.current;
|
|
93
93
|
if (!container) return;
|
|
94
94
|
const activeIndex = keyToIndexRecord[activeKey];
|
|
95
95
|
if (activeIndex === undefined) {
|
|
96
|
-
|
|
96
|
+
inkApi.start({
|
|
97
97
|
x: 0,
|
|
98
98
|
width: 0,
|
|
99
99
|
immediate: true
|
|
@@ -131,7 +131,7 @@ const Tabs = p => {
|
|
|
131
131
|
const w = ['auto', 'full'].includes(props.activeLineMode) ? width : activeLineWidth;
|
|
132
132
|
x = -(containerWidth - x - w);
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
inkApi.start({
|
|
135
135
|
x,
|
|
136
136
|
width,
|
|
137
137
|
immediate
|
|
@@ -148,13 +148,15 @@ const Tabs = p => {
|
|
|
148
148
|
} else {
|
|
149
149
|
nextScrollLeft = (0, _bound.bound)(activeTabLeft - (containerWidth - activeTabWidth) / 2, 0, maxScrollDistance);
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
151
|
+
if (!fromMutation || props.autoScroll !== false) {
|
|
152
|
+
scrollApi.start({
|
|
153
|
+
scrollLeft: nextScrollLeft,
|
|
154
|
+
from: {
|
|
155
|
+
scrollLeft: containerScrollLeft
|
|
156
|
+
},
|
|
157
|
+
immediate
|
|
158
|
+
});
|
|
159
|
+
}
|
|
158
160
|
}
|
|
159
161
|
(0, _ahooks.useIsomorphicLayoutEffect)(() => {
|
|
160
162
|
animate(!x.isAnimating);
|
|
@@ -166,7 +168,7 @@ const Tabs = p => {
|
|
|
166
168
|
animate(!x.isAnimating);
|
|
167
169
|
}, tabListContainerRef);
|
|
168
170
|
(0, _useMutationEffect.useMutationEffect)(() => {
|
|
169
|
-
animate(!x.isAnimating);
|
|
171
|
+
animate(!x.isAnimating, true);
|
|
170
172
|
}, tabListContainerRef, {
|
|
171
173
|
subtree: true,
|
|
172
174
|
childList: true,
|
|
@@ -99,7 +99,7 @@ const VirtualInput = (0, _react.forwardRef)((p, ref) => {
|
|
|
99
99
|
[`${classPrefix}-disabled`]: props.disabled
|
|
100
100
|
}),
|
|
101
101
|
tabIndex: props.disabled ? undefined : 0,
|
|
102
|
-
role: '
|
|
102
|
+
role: 'textbox',
|
|
103
103
|
onFocus: onFocus,
|
|
104
104
|
onBlur: onBlur,
|
|
105
105
|
onClick: props.onClick
|
package/cjs/global/global.css
CHANGED
|
@@ -51,8 +51,10 @@ const Dropdown = forwardRef((p, ref) => {
|
|
|
51
51
|
const navs = React.Children.map(props.children, child => {
|
|
52
52
|
if (isValidElement(child)) {
|
|
53
53
|
const childProps = Object.assign(Object.assign({}, child.props), {
|
|
54
|
-
onClick:
|
|
54
|
+
onClick: event => {
|
|
55
|
+
var _a, _b;
|
|
55
56
|
changeActive(child.key);
|
|
57
|
+
(_b = (_a = child.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
56
58
|
},
|
|
57
59
|
active: child.key === value,
|
|
58
60
|
arrow: child.props.arrow === undefined ? props.arrow : child.props.arrow
|
|
@@ -71,6 +71,7 @@ export const Mask = p => {
|
|
|
71
71
|
const node = withStopPropagation(props.stopPropagation, withNativeProps(props, React.createElement(animated.div, {
|
|
72
72
|
className: classPrefix,
|
|
73
73
|
ref: ref,
|
|
74
|
+
"aria-hidden": true,
|
|
74
75
|
style: Object.assign(Object.assign({}, props.style), {
|
|
75
76
|
background,
|
|
76
77
|
opacity,
|
|
@@ -7,6 +7,7 @@ import Popup from '../popup';
|
|
|
7
7
|
import { withNativeProps } from '../../utils/native-props';
|
|
8
8
|
import SafeArea from '../safe-area';
|
|
9
9
|
import { useMemoizedFn } from 'ahooks';
|
|
10
|
+
import { useConfig } from '../config-provider';
|
|
10
11
|
const classPrefix = 'adm-number-keyboard';
|
|
11
12
|
const defaultProps = {
|
|
12
13
|
defaultVisible: false,
|
|
@@ -30,6 +31,9 @@ export const NumberKeyboard = p => {
|
|
|
30
31
|
showCloseButton,
|
|
31
32
|
onInput
|
|
32
33
|
} = props;
|
|
34
|
+
const {
|
|
35
|
+
locale
|
|
36
|
+
} = useConfig();
|
|
33
37
|
const keyboardRef = useRef(null);
|
|
34
38
|
const keys = useMemo(() => {
|
|
35
39
|
const defaultKeys = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
|
@@ -97,8 +101,8 @@ export const NumberKeyboard = p => {
|
|
|
97
101
|
var _a;
|
|
98
102
|
(_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
99
103
|
},
|
|
100
|
-
role: '
|
|
101
|
-
title:
|
|
104
|
+
role: 'button',
|
|
105
|
+
title: locale.common.close,
|
|
102
106
|
tabIndex: -1
|
|
103
107
|
}, React.createElement(DownOutline, null)));
|
|
104
108
|
};
|
|
@@ -110,7 +114,7 @@ export const NumberKeyboard = p => {
|
|
|
110
114
|
[`${classPrefix}-key-mid`]: index === 9 && !!confirmText && keys.length < 12
|
|
111
115
|
});
|
|
112
116
|
const ariaProps = key ? {
|
|
113
|
-
role: '
|
|
117
|
+
role: 'button',
|
|
114
118
|
title: key,
|
|
115
119
|
tabIndex: -1
|
|
116
120
|
} : undefined;
|
|
@@ -167,13 +171,13 @@ export const NumberKeyboard = p => {
|
|
|
167
171
|
// Long press should not trigger native context menu
|
|
168
172
|
e.preventDefault();
|
|
169
173
|
},
|
|
170
|
-
title:
|
|
171
|
-
role: '
|
|
174
|
+
title: locale.Input.clear,
|
|
175
|
+
role: 'button',
|
|
172
176
|
tabIndex: -1
|
|
173
177
|
}, React.createElement(TextDeletionOutline, null)), React.createElement("div", {
|
|
174
178
|
className: `${classPrefix}-key ${classPrefix}-key-extra ${classPrefix}-key-ok`,
|
|
175
179
|
onTouchEnd: e => onKeyPress(e, 'OK'),
|
|
176
|
-
role: '
|
|
180
|
+
role: 'button',
|
|
177
181
|
tabIndex: -1,
|
|
178
182
|
"aria-label": confirmText
|
|
179
183
|
}, confirmText))), props.safeArea && React.createElement("div", {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import React, { useEffect, useState, forwardRef, useImperativeHandle } from 'react';
|
|
3
3
|
import { MinusOutline, AddOutline } from 'antd-mobile-icons';
|
|
4
|
-
import useMergedState from 'rc-util
|
|
4
|
+
import { useMergedState } from 'rc-util';
|
|
5
5
|
import getMiniDecimal, { toFixed } from '@rc-component/mini-decimal';
|
|
6
6
|
import { withNativeProps } from '../../utils/native-props';
|
|
7
7
|
import { mergeProps } from '../../utils/with-default-props';
|
|
@@ -9,13 +9,14 @@ declare const _default: import("react").ForwardRefExoticComponent<{
|
|
|
9
9
|
direction?: "vertical" | "horizontal" | undefined;
|
|
10
10
|
onIndexChange?: ((index: number) => void) | undefined;
|
|
11
11
|
indicatorProps?: Pick<import("../page-indicator").PageIndicatorProps, "style" | "className" | "color"> | undefined;
|
|
12
|
-
indicator?: ((total: number, current: number) => import("react").ReactNode) | undefined;
|
|
12
|
+
indicator?: false | ((total: number, current: number) => import("react").ReactNode) | undefined;
|
|
13
13
|
slideSize?: number | undefined;
|
|
14
14
|
trackOffset?: number | undefined;
|
|
15
15
|
stuckAtBoundary?: boolean | undefined;
|
|
16
16
|
rubberband?: boolean | undefined;
|
|
17
17
|
stopPropagation?: ("mousedown" | "mousemove" | "mouseup")[] | undefined;
|
|
18
|
-
|
|
18
|
+
total?: number | undefined;
|
|
19
|
+
children?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>[] | ((index: number) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) | undefined;
|
|
19
20
|
} & {
|
|
20
21
|
className?: string | undefined;
|
|
21
22
|
style?: (import("react").CSSProperties & Partial<Record<"--width" | "--height" | "--border-radius" | "--track-padding", string>>) | undefined;
|