antd-mobile 5.9.4 → 5.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2x/cjs/components/capsule-tabs/capsule-tabs.js +3 -3
- package/2x/cjs/components/collapse/collapse.js +3 -3
- package/2x/cjs/components/divider/divider.css +19 -8
- package/2x/cjs/components/divider/divider.d.ts +1 -0
- package/2x/cjs/components/divider/divider.js +3 -2
- package/2x/cjs/components/form/form-item.js +3 -1
- package/2x/cjs/components/form/form.js +3 -2
- package/2x/cjs/components/image-uploader/image-uploader.d.ts +2 -0
- package/2x/cjs/components/image-uploader/image-uploader.js +4 -1
- package/2x/cjs/components/image-uploader/preview-item.d.ts +2 -0
- package/2x/cjs/components/image-uploader/preview-item.js +3 -2
- package/2x/cjs/components/index-bar/index-bar.js +3 -3
- package/2x/cjs/components/jumbo-tabs/jumbo-tabs.js +3 -3
- package/2x/cjs/components/number-keyboard/number-keyboard.js +0 -5
- package/2x/cjs/components/picker-view/picker-view.d.ts +1 -0
- package/2x/cjs/components/picker-view/wheel.js +3 -1
- package/2x/cjs/components/popover/popover-menu.js +2 -1
- package/2x/cjs/components/side-bar/side-bar.js +3 -3
- package/2x/cjs/components/stepper/stepper.js +16 -9
- package/2x/cjs/components/swiper/swiper.js +1 -0
- package/2x/cjs/components/tab-bar/tab-bar.js +3 -3
- package/2x/cjs/components/tabs/tabs.js +3 -3
- package/2x/cjs/components/tree-select/multiple.js +2 -1
- package/2x/cjs/utils/traverse-react-node.d.ts +2 -0
- package/2x/cjs/utils/traverse-react-node.js +29 -0
- package/2x/cjs/utils/undefined-fallback.d.ts +3 -0
- package/2x/cjs/utils/undefined-fallback.js +16 -0
- package/2x/es/components/capsule-tabs/capsule-tabs.js +2 -1
- package/2x/es/components/collapse/collapse.js +2 -1
- package/2x/es/components/divider/divider.css +19 -8
- package/2x/es/components/divider/divider.d.ts +1 -0
- package/2x/es/components/divider/divider.js +3 -2
- package/2x/es/components/form/form-item.js +2 -1
- package/2x/es/components/form/form.js +2 -1
- package/2x/es/components/image-uploader/image-uploader.d.ts +2 -0
- package/2x/es/components/image-uploader/image-uploader.js +4 -1
- package/2x/es/components/image-uploader/preview-item.d.ts +2 -0
- package/2x/es/components/image-uploader/preview-item.js +3 -2
- package/2x/es/components/index-bar/index-bar.js +2 -1
- package/2x/es/components/jumbo-tabs/jumbo-tabs.js +2 -1
- package/2x/es/components/number-keyboard/number-keyboard.js +0 -5
- package/2x/es/components/picker-view/picker-view.d.ts +1 -0
- package/2x/es/components/picker-view/wheel.js +3 -1
- package/2x/es/components/popover/popover-menu.js +2 -1
- package/2x/es/components/side-bar/side-bar.js +2 -1
- package/2x/es/components/stepper/stepper.js +15 -9
- package/2x/es/components/swiper/swiper.js +1 -0
- package/2x/es/components/tab-bar/tab-bar.js +2 -1
- package/2x/es/components/tabs/tabs.js +2 -1
- package/2x/es/components/tree-select/multiple.js +2 -1
- package/2x/es/utils/traverse-react-node.d.ts +2 -0
- package/2x/es/utils/traverse-react-node.js +18 -0
- package/2x/es/utils/undefined-fallback.d.ts +3 -0
- package/2x/es/utils/undefined-fallback.js +9 -0
- package/2x/package.json +5 -1
- package/bundle/antd-mobile.cjs.js +61 -29
- package/bundle/antd-mobile.es.js +60 -29
- package/bundle/style.css +18 -8
- package/cjs/components/capsule-tabs/capsule-tabs.js +3 -3
- package/cjs/components/collapse/collapse.js +3 -3
- package/cjs/components/divider/divider.css +18 -8
- package/cjs/components/divider/divider.d.ts +1 -0
- package/cjs/components/divider/divider.js +3 -2
- package/cjs/components/form/form-item.js +3 -1
- package/cjs/components/form/form.js +3 -2
- package/cjs/components/image-uploader/image-uploader.d.ts +2 -0
- package/cjs/components/image-uploader/image-uploader.js +4 -1
- package/cjs/components/image-uploader/preview-item.d.ts +2 -0
- package/cjs/components/image-uploader/preview-item.js +3 -2
- package/cjs/components/index-bar/index-bar.js +3 -3
- package/cjs/components/jumbo-tabs/jumbo-tabs.js +3 -3
- package/cjs/components/number-keyboard/number-keyboard.js +0 -5
- package/cjs/components/picker-view/picker-view.d.ts +1 -0
- package/cjs/components/picker-view/wheel.js +3 -1
- package/cjs/components/popover/popover-menu.js +2 -1
- package/cjs/components/side-bar/side-bar.js +3 -3
- package/cjs/components/stepper/stepper.js +16 -9
- package/cjs/components/swiper/swiper.js +1 -0
- package/cjs/components/tab-bar/tab-bar.js +3 -3
- package/cjs/components/tabs/tabs.js +3 -3
- package/cjs/components/tree-select/multiple.js +2 -1
- package/cjs/utils/traverse-react-node.d.ts +2 -0
- package/cjs/utils/traverse-react-node.js +29 -0
- package/cjs/utils/undefined-fallback.d.ts +3 -0
- package/cjs/utils/undefined-fallback.js +16 -0
- package/es/components/capsule-tabs/capsule-tabs.js +2 -1
- package/es/components/collapse/collapse.js +2 -1
- package/es/components/divider/divider.css +18 -8
- package/es/components/divider/divider.d.ts +1 -0
- package/es/components/divider/divider.js +3 -2
- package/es/components/form/form-item.js +2 -1
- package/es/components/form/form.js +2 -1
- package/es/components/image-uploader/image-uploader.d.ts +2 -0
- package/es/components/image-uploader/image-uploader.js +4 -1
- package/es/components/image-uploader/preview-item.d.ts +2 -0
- package/es/components/image-uploader/preview-item.js +3 -2
- package/es/components/index-bar/index-bar.js +2 -1
- package/es/components/jumbo-tabs/jumbo-tabs.js +2 -1
- package/es/components/number-keyboard/number-keyboard.js +0 -5
- package/es/components/picker-view/picker-view.d.ts +1 -0
- package/es/components/picker-view/wheel.js +3 -1
- package/es/components/popover/popover-menu.js +2 -1
- package/es/components/side-bar/side-bar.js +2 -1
- package/es/components/stepper/stepper.js +15 -9
- package/es/components/swiper/swiper.js +1 -0
- package/es/components/tab-bar/tab-bar.js +2 -1
- package/es/components/tabs/tabs.js +2 -1
- package/es/components/tree-select/multiple.js +2 -1
- package/es/utils/traverse-react-node.d.ts +2 -0
- package/es/utils/traverse-react-node.js +18 -0
- package/es/utils/undefined-fallback.d.ts +3 -0
- package/es/utils/undefined-fallback.js +9 -0
- package/package.json +5 -1
- package/umd/antd-mobile.js +1 -1
- package/umd/antd-mobile.js.LICENSE.txt +9 -0
|
@@ -2,5 +2,6 @@ import { FC } from 'react';
|
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
3
|
export declare type DividerProps = {
|
|
4
4
|
contentPosition?: 'left' | 'right' | 'center';
|
|
5
|
+
direction?: 'horizontal' | 'vertical';
|
|
5
6
|
} & NativeProps;
|
|
6
7
|
export declare const Divider: FC<DividerProps>;
|
|
@@ -4,12 +4,13 @@ import { withNativeProps } from '../../utils/native-props';
|
|
|
4
4
|
import { mergeProps } from '../../utils/with-default-props';
|
|
5
5
|
const classPrefix = `adm-divider`;
|
|
6
6
|
const defaultProps = {
|
|
7
|
-
contentPosition: 'center'
|
|
7
|
+
contentPosition: 'center',
|
|
8
|
+
direction: 'horizontal'
|
|
8
9
|
};
|
|
9
10
|
export const Divider = p => {
|
|
10
11
|
const props = mergeProps(defaultProps, p);
|
|
11
12
|
return withNativeProps(props, React.createElement("div", {
|
|
12
|
-
className: classNames(classPrefix, `${classPrefix}-${props.contentPosition}`)
|
|
13
|
+
className: classNames(classPrefix, `${classPrefix}-${props.direction}`, `${classPrefix}-${props.contentPosition}`)
|
|
13
14
|
}, props.children && React.createElement("div", {
|
|
14
15
|
className: `${classPrefix}-content`
|
|
15
16
|
}, props.children)));
|
|
@@ -10,6 +10,7 @@ import List from '../list';
|
|
|
10
10
|
import Popover from '../popover';
|
|
11
11
|
import { QuestionCircleOutline } from 'antd-mobile-icons';
|
|
12
12
|
import { useConfig } from '../config-provider';
|
|
13
|
+
import { undefinedFallback } from '../../utils/undefined-fallback';
|
|
13
14
|
const NAME_SPLIT = '__SPLIT__';
|
|
14
15
|
const classPrefix = `adm-form-item`;
|
|
15
16
|
const MemoInput = React.memo(({
|
|
@@ -142,7 +143,7 @@ export const FormItem = props => {
|
|
|
142
143
|
const {
|
|
143
144
|
validateTrigger: contextValidateTrigger
|
|
144
145
|
} = useContext(FieldContext);
|
|
145
|
-
const mergedValidateTrigger = validateTrigger
|
|
146
|
+
const mergedValidateTrigger = undefinedFallback(validateTrigger, contextValidateTrigger, trigger);
|
|
146
147
|
const updateRef = React.useRef(0);
|
|
147
148
|
updateRef.current += 1;
|
|
148
149
|
const [subMetas, setSubMetas] = useState({});
|
|
@@ -9,6 +9,7 @@ import { Header } from './header';
|
|
|
9
9
|
import { useConfig } from '../config-provider';
|
|
10
10
|
import merge from 'lodash/merge';
|
|
11
11
|
import { FormArray } from './form-array';
|
|
12
|
+
import { traverseReactNode } from '../../utils/traverse-react-node';
|
|
12
13
|
const classPrefix = 'adm-form';
|
|
13
14
|
const defaultProps = defaultFormContext;
|
|
14
15
|
export const Form = forwardRef((p, ref) => {
|
|
@@ -46,7 +47,7 @@ export const Form = forwardRef((p, ref) => {
|
|
|
46
47
|
items = [];
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
traverseReactNode(props.children, child => {
|
|
50
51
|
if (React.isValidElement(child)) {
|
|
51
52
|
if (child.type === Header) {
|
|
52
53
|
collect();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FC, InputHTMLAttributes } from 'react';
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
|
+
import type { ImageProps } from '../image';
|
|
3
4
|
export declare type TaskStatus = 'pending' | 'fail';
|
|
4
5
|
export interface ImageUploadItem {
|
|
5
6
|
key?: string | number;
|
|
@@ -25,5 +26,6 @@ export declare type ImageUploaderProps = {
|
|
|
25
26
|
onDelete?: (item: ImageUploadItem) => boolean | Promise<boolean> | void;
|
|
26
27
|
preview?: boolean;
|
|
27
28
|
showFailed?: boolean;
|
|
29
|
+
imageFit?: ImageProps['fit'];
|
|
28
30
|
} & NativeProps<'--cell-size'>;
|
|
29
31
|
export declare const ImageUploader: FC<ImageUploaderProps>;
|
|
@@ -18,7 +18,8 @@ const defaultProps = {
|
|
|
18
18
|
defaultValue: [],
|
|
19
19
|
accept: 'image/*',
|
|
20
20
|
preview: true,
|
|
21
|
-
showFailed: true
|
|
21
|
+
showFailed: true,
|
|
22
|
+
imageFit: 'cover'
|
|
22
23
|
};
|
|
23
24
|
export const ImageUploader = p => {
|
|
24
25
|
const props = mergeProps(defaultProps, p);
|
|
@@ -157,6 +158,7 @@ export const ImageUploader = p => {
|
|
|
157
158
|
key: (_a = fileItem.key) !== null && _a !== void 0 ? _a : index,
|
|
158
159
|
url: (_b = fileItem.thumbnailUrl) !== null && _b !== void 0 ? _b : fileItem.url,
|
|
159
160
|
deletable: props.deletable,
|
|
161
|
+
imageFit: props.imageFit,
|
|
160
162
|
onClick: () => {
|
|
161
163
|
if (props.preview) {
|
|
162
164
|
previewImage(index);
|
|
@@ -182,6 +184,7 @@ export const ImageUploader = p => {
|
|
|
182
184
|
file: task.file,
|
|
183
185
|
deletable: task.status !== 'pending',
|
|
184
186
|
status: task.status,
|
|
187
|
+
imageFit: props.imageFit,
|
|
185
188
|
onDelete: () => {
|
|
186
189
|
setTasks(tasks.filter(x => x.id !== task.id));
|
|
187
190
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { TaskStatus } from './image-uploader';
|
|
3
|
+
import type { ImageProps } from '../image';
|
|
3
4
|
declare type Props = {
|
|
4
5
|
onClick?: () => void;
|
|
5
6
|
onDelete?: () => void;
|
|
@@ -7,6 +8,7 @@ declare type Props = {
|
|
|
7
8
|
url?: string;
|
|
8
9
|
file?: File;
|
|
9
10
|
status?: TaskStatus;
|
|
11
|
+
imageFit: ImageProps['fit'];
|
|
10
12
|
};
|
|
11
13
|
declare const PreviewItem: FC<Props>;
|
|
12
14
|
export default PreviewItem;
|
|
@@ -14,7 +14,8 @@ const PreviewItem = props => {
|
|
|
14
14
|
url,
|
|
15
15
|
file,
|
|
16
16
|
deletable,
|
|
17
|
-
onDelete
|
|
17
|
+
onDelete,
|
|
18
|
+
imageFit
|
|
18
19
|
} = props;
|
|
19
20
|
const src = useMemo(() => {
|
|
20
21
|
if (url) {
|
|
@@ -54,7 +55,7 @@ const PreviewItem = props => {
|
|
|
54
55
|
}, React.createElement(Image, {
|
|
55
56
|
className: `${classPrefix}-cell-image`,
|
|
56
57
|
src: src,
|
|
57
|
-
fit:
|
|
58
|
+
fit: imageFit,
|
|
58
59
|
onClick: props.onClick
|
|
59
60
|
}), renderLoading(), renderDelete());
|
|
60
61
|
};
|
|
@@ -7,6 +7,7 @@ import { Sidebar } from './sidebar';
|
|
|
7
7
|
import { convertPx } from '../../utils/convert-px';
|
|
8
8
|
import { Panel } from './panel';
|
|
9
9
|
import { devWarning } from '../../utils/dev-log';
|
|
10
|
+
import { traverseReactNode } from '../../utils/traverse-react-node';
|
|
10
11
|
const classPrefix = `adm-index-bar`;
|
|
11
12
|
const defaultProps = {
|
|
12
13
|
sticky: true
|
|
@@ -17,7 +18,7 @@ export const IndexBar = forwardRef((p, ref) => {
|
|
|
17
18
|
const bodyRef = useRef(null);
|
|
18
19
|
const indexItems = [];
|
|
19
20
|
const panels = [];
|
|
20
|
-
|
|
21
|
+
traverseReactNode(props.children, child => {
|
|
21
22
|
var _a;
|
|
22
23
|
|
|
23
24
|
if (!React.isValidElement(child)) return;
|
|
@@ -7,6 +7,7 @@ import { useResizeEffect } from '../../utils/use-resize-effect';
|
|
|
7
7
|
import { useTabListScroll } from '../../utils/use-tab-list-scroll';
|
|
8
8
|
import ScrollMask from '../scroll-mask';
|
|
9
9
|
import { ShouldRender } from '../../utils/should-render';
|
|
10
|
+
import { traverseReactNode } from '../../utils/traverse-react-node';
|
|
10
11
|
const classPrefix = `adm-jumbo-tabs`;
|
|
11
12
|
export const JumboTab = () => {
|
|
12
13
|
return null;
|
|
@@ -19,7 +20,7 @@ export const JumboTabs = props => {
|
|
|
19
20
|
const keyToIndexRecord = {};
|
|
20
21
|
let firstActiveKey = null;
|
|
21
22
|
const panes = [];
|
|
22
|
-
|
|
23
|
+
traverseReactNode(props.children, (child, index) => {
|
|
23
24
|
if (!React.isValidElement(child)) return;
|
|
24
25
|
const key = child.key;
|
|
25
26
|
if (typeof key !== 'string') return;
|
|
@@ -134,9 +134,6 @@ export const NumberKeyboard = p => {
|
|
|
134
134
|
onBackspacePressEnd();
|
|
135
135
|
}
|
|
136
136
|
},
|
|
137
|
-
onMouseUp: e => {
|
|
138
|
-
onKeyPress(e, key);
|
|
139
|
-
},
|
|
140
137
|
title: key,
|
|
141
138
|
role: 'button'
|
|
142
139
|
}, key === 'BACKSPACE' ? React.createElement(TextDeletionOutline, null) : key);
|
|
@@ -173,13 +170,11 @@ export const NumberKeyboard = p => {
|
|
|
173
170
|
onKeyPress(e, 'BACKSPACE');
|
|
174
171
|
onBackspacePressEnd();
|
|
175
172
|
},
|
|
176
|
-
onMouseUp: e => onKeyPress(e, 'BACKSPACE'),
|
|
177
173
|
title: 'BACKSPACE',
|
|
178
174
|
role: 'button'
|
|
179
175
|
}, React.createElement(TextDeletionOutline, null)), React.createElement("div", {
|
|
180
176
|
className: `${classPrefix}-key extra-key ok-key`,
|
|
181
177
|
onTouchEnd: e => onKeyPress(e, 'OK'),
|
|
182
|
-
onMouseUp: e => onKeyPress(e, 'OK'),
|
|
183
178
|
role: 'button'
|
|
184
179
|
}, confirmText))), props.safeArea && React.createElement("div", {
|
|
185
180
|
className: `${classPrefix}-footer`
|
|
@@ -9,6 +9,7 @@ export declare type PickerValueExtend = {
|
|
|
9
9
|
export declare type PickerColumnItem = {
|
|
10
10
|
label: ReactNode;
|
|
11
11
|
value: string;
|
|
12
|
+
key?: string | number;
|
|
12
13
|
};
|
|
13
14
|
export declare type PickerColumn = (string | PickerColumnItem)[];
|
|
14
15
|
export declare type PickerViewProps = {
|
|
@@ -140,6 +140,8 @@ export const Wheel = memo(props => {
|
|
|
140
140
|
className: `${classPrefix}-column-wheel`,
|
|
141
141
|
"aria-hidden": true
|
|
142
142
|
}, column.map((item, index) => {
|
|
143
|
+
var _a;
|
|
144
|
+
|
|
143
145
|
const selected = props.value === item.value;
|
|
144
146
|
if (selected) selectedIndex = index;
|
|
145
147
|
|
|
@@ -149,7 +151,7 @@ export const Wheel = memo(props => {
|
|
|
149
151
|
}
|
|
150
152
|
|
|
151
153
|
return React.createElement("div", {
|
|
152
|
-
key: item.value,
|
|
154
|
+
key: (_a = item.key) !== null && _a !== void 0 ? _a : item.value,
|
|
153
155
|
"data-selected": item.value === value,
|
|
154
156
|
className: `${classPrefix}-column-item`,
|
|
155
157
|
onClick: handleClick,
|
|
@@ -3,7 +3,8 @@ import classNames from 'classnames';
|
|
|
3
3
|
import { Popover } from './popover';
|
|
4
4
|
const classPrefix = `adm-popover-menu`;
|
|
5
5
|
export const PopoverMenu = forwardRef((props, ref) => {
|
|
6
|
-
const innerRef = useRef(null);
|
|
6
|
+
const innerRef = useRef(null); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
7
|
+
|
|
7
8
|
useImperativeHandle(ref, () => innerRef.current, []);
|
|
8
9
|
const onClick = useCallback(e => {
|
|
9
10
|
var _a;
|
|
@@ -4,6 +4,7 @@ import Badge from '../badge';
|
|
|
4
4
|
import { withNativeProps } from '../../utils/native-props';
|
|
5
5
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
6
6
|
import { Corner } from './corner';
|
|
7
|
+
import { traverseReactNode } from '../../utils/traverse-react-node';
|
|
7
8
|
const classPrefix = `adm-side-bar`;
|
|
8
9
|
export const SideBarItem = () => {
|
|
9
10
|
return null;
|
|
@@ -13,7 +14,7 @@ export const SideBar = props => {
|
|
|
13
14
|
|
|
14
15
|
let firstActiveKey = null;
|
|
15
16
|
const items = [];
|
|
16
|
-
|
|
17
|
+
traverseReactNode(props.children, (child, index) => {
|
|
17
18
|
if (!React.isValidElement(child)) return;
|
|
18
19
|
const key = child.key;
|
|
19
20
|
if (typeof key !== 'string') return;
|
|
@@ -7,6 +7,7 @@ import { mergeProps } from '../../utils/with-default-props';
|
|
|
7
7
|
import { bound } from '../../utils/bound';
|
|
8
8
|
import Input from '../input';
|
|
9
9
|
import Button from '../button';
|
|
10
|
+
import Big from 'big.js';
|
|
10
11
|
const classPrefix = `adm-stepper`;
|
|
11
12
|
const defaultProps = {
|
|
12
13
|
defaultValue: 0,
|
|
@@ -24,13 +25,13 @@ export const Stepper = p => {
|
|
|
24
25
|
inputReadOnly
|
|
25
26
|
} = props;
|
|
26
27
|
const [value, setValue] = usePropsValue(props);
|
|
27
|
-
const [inputValue, setInputValue] = useState(() => convertValueToText(value));
|
|
28
|
+
const [inputValue, setInputValue] = useState(() => convertValueToText(value, props.digits));
|
|
28
29
|
|
|
29
30
|
function setValueWithCheck(v) {
|
|
30
31
|
if (isNaN(v)) return;
|
|
31
32
|
let target = bound(v, props.min, props.max);
|
|
32
33
|
|
|
33
|
-
if (props.digits
|
|
34
|
+
if (props.digits !== undefined) {
|
|
34
35
|
target = parseFloat(target.toFixed(props.digits));
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -40,14 +41,14 @@ export const Stepper = p => {
|
|
|
40
41
|
const [hasFocus, setHasFocus] = useState(false);
|
|
41
42
|
useEffect(() => {
|
|
42
43
|
if (!hasFocus) {
|
|
43
|
-
setInputValue(convertValueToText(value));
|
|
44
|
+
setInputValue(convertValueToText(value, props.digits));
|
|
44
45
|
}
|
|
45
46
|
}, [hasFocus]);
|
|
46
47
|
useEffect(() => {
|
|
47
48
|
if (!hasFocus) {
|
|
48
|
-
setInputValue(convertValueToText(value));
|
|
49
|
+
setInputValue(convertValueToText(value, props.digits));
|
|
49
50
|
}
|
|
50
|
-
}, [value]);
|
|
51
|
+
}, [value, props.digits]);
|
|
51
52
|
|
|
52
53
|
const handleInputChange = v => {
|
|
53
54
|
setInputValue(v);
|
|
@@ -65,11 +66,11 @@ export const Stepper = p => {
|
|
|
65
66
|
};
|
|
66
67
|
|
|
67
68
|
const handleMinus = () => {
|
|
68
|
-
setValueWithCheck((value !== null && value !== void 0 ? value : 0)
|
|
69
|
+
setValueWithCheck(Big(value !== null && value !== void 0 ? value : 0).minus(step).toNumber());
|
|
69
70
|
};
|
|
70
71
|
|
|
71
72
|
const handlePlus = () => {
|
|
72
|
-
setValueWithCheck((value !== null && value !== void 0 ? value : 0)
|
|
73
|
+
setValueWithCheck(Big(value !== null && value !== void 0 ? value : 0).add(step).toNumber());
|
|
73
74
|
};
|
|
74
75
|
|
|
75
76
|
const minusDisabled = () => {
|
|
@@ -137,9 +138,14 @@ export const Stepper = p => {
|
|
|
137
138
|
}, React.createElement(AddOutline, null))));
|
|
138
139
|
};
|
|
139
140
|
|
|
140
|
-
function convertValueToText(value) {
|
|
141
|
+
function convertValueToText(value, digits) {
|
|
141
142
|
if (value === null) return '';
|
|
142
|
-
|
|
143
|
+
|
|
144
|
+
if (digits !== undefined) {
|
|
145
|
+
return value.toFixed(digits);
|
|
146
|
+
} else {
|
|
147
|
+
return value.toString();
|
|
148
|
+
}
|
|
143
149
|
}
|
|
144
150
|
|
|
145
151
|
function convertTextToValue(text) {
|
|
@@ -101,6 +101,7 @@ export const Swiper = forwardRef(staged((p, ref) => {
|
|
|
101
101
|
},
|
|
102
102
|
onRest: () => {
|
|
103
103
|
if (draggingRef.current) return;
|
|
104
|
+
if (!loop) return;
|
|
104
105
|
const rawX = position.get();
|
|
105
106
|
const totalWidth = 100 * count;
|
|
106
107
|
const standardPosition = modulus(rawX, totalWidth);
|
|
@@ -5,6 +5,7 @@ import { mergeProps } from '../../utils/with-default-props';
|
|
|
5
5
|
import Badge from '../badge';
|
|
6
6
|
import SafeArea from '../safe-area';
|
|
7
7
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
8
|
+
import { traverseReactNode } from '../../utils/traverse-react-node';
|
|
8
9
|
export const TabBarItem = () => {
|
|
9
10
|
return null;
|
|
10
11
|
};
|
|
@@ -18,7 +19,7 @@ export const TabBar = p => {
|
|
|
18
19
|
const props = mergeProps(defaultProps, p);
|
|
19
20
|
let firstActiveKey = null;
|
|
20
21
|
const items = [];
|
|
21
|
-
|
|
22
|
+
traverseReactNode(props.children, (child, index) => {
|
|
22
23
|
if (!React.isValidElement(child)) return;
|
|
23
24
|
const key = child.key;
|
|
24
25
|
if (typeof key !== 'string') return;
|
|
@@ -10,6 +10,7 @@ import { useResizeEffect } from '../../utils/use-resize-effect';
|
|
|
10
10
|
import { mergeProps } from '../../utils/with-default-props';
|
|
11
11
|
import { useIsomorphicUpdateLayoutEffect } from '../../utils/use-isomorphic-update-layout-effect';
|
|
12
12
|
import { ShouldRender } from '../../utils/should-render';
|
|
13
|
+
import { traverseReactNode } from '../../utils/traverse-react-node';
|
|
13
14
|
const classPrefix = `adm-tabs`;
|
|
14
15
|
export const Tab = () => {
|
|
15
16
|
return null;
|
|
@@ -27,7 +28,7 @@ export const Tabs = p => {
|
|
|
27
28
|
const keyToIndexRecord = {};
|
|
28
29
|
let firstActiveKey = null;
|
|
29
30
|
const panes = [];
|
|
30
|
-
|
|
31
|
+
traverseReactNode(props.children, (child, index) => {
|
|
31
32
|
if (!React.isValidElement(child)) return;
|
|
32
33
|
const key = child.key;
|
|
33
34
|
if (typeof key !== 'string') return;
|
|
@@ -137,7 +137,8 @@ export const Multiple = p => {
|
|
|
137
137
|
walker(groupKeys);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
groupKeys = groupKeys.filter(i => !unusedKeys.includes(i));
|
|
140
|
+
groupKeys = groupKeys.filter(i => !unusedKeys.includes(i)); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
141
|
+
|
|
141
142
|
const groupOptions = groupKeys.map(i => optionsMap.get(i));
|
|
142
143
|
setValue(groupKeys);
|
|
143
144
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, groupKeys, groupOptions);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { isFragment } from 'react-is';
|
|
3
|
+
export function traverseReactNode(children, fn) {
|
|
4
|
+
let i = 0;
|
|
5
|
+
|
|
6
|
+
function handle(target) {
|
|
7
|
+
React.Children.forEach(target, child => {
|
|
8
|
+
if (!isFragment(child)) {
|
|
9
|
+
fn(child, i);
|
|
10
|
+
i += 1;
|
|
11
|
+
} else {
|
|
12
|
+
handle(child.props.children);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
handle(children);
|
|
18
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function undefinedFallback<T>(a: T | undefined, b: T): T;
|
|
2
|
+
export declare function undefinedFallback<T>(a: T | undefined, b: T | undefined, c: T): T;
|
|
3
|
+
export declare function undefinedFallback<T>(a: T | undefined, b: T | undefined, c: T | undefined, d: T): T;
|
package/package.json
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antd-mobile",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.10.1",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@floating-ui/dom": "^0.4.2",
|
|
6
6
|
"@react-spring/web": "^9.4.4",
|
|
7
|
+
"@types/big.js": "^6.1.3",
|
|
8
|
+
"@types/react-is": "^17.0.3",
|
|
7
9
|
"@types/resize-observer-browser": "^0.1.7",
|
|
8
10
|
"@use-gesture/react": "^10.2.10",
|
|
9
11
|
"ahooks": "^3.1.14",
|
|
10
12
|
"antd-mobile-icons": "^0.2.2",
|
|
11
13
|
"antd-mobile-v5-count": "^1.0.1",
|
|
14
|
+
"big.js": "^6.1.1",
|
|
12
15
|
"classnames": "^2.3.1",
|
|
13
16
|
"dayjs": "^1.11.0",
|
|
14
17
|
"lodash": "^4.17.21",
|
|
15
18
|
"rc-field-form": "^1.24.0",
|
|
19
|
+
"react-is": "^17.0.2",
|
|
16
20
|
"staged-components": "^1.1.2",
|
|
17
21
|
"tslib": "^2.3.1"
|
|
18
22
|
},
|