antd-mobile 5.12.6 → 5.13.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/README.md +10 -8
- package/2x/cjs/components/dialog/dialog.d.ts +2 -0
- package/2x/cjs/components/dialog/dialog.js +24 -13
- package/2x/cjs/components/ellipsis/ellipsis.js +1 -1
- package/2x/cjs/components/error-block/create-error-block.d.ts +12 -0
- package/2x/cjs/components/error-block/create-error-block.js +59 -0
- package/2x/cjs/components/error-block/error-block.d.ts +2 -11
- package/2x/cjs/components/error-block/error-block.js +7 -53
- package/2x/cjs/components/error-block/images/index.d.ts +4 -2
- package/2x/cjs/components/error-block/images/index.js +25 -10
- package/2x/cjs/components/error-block/index.d.ts +5 -1
- package/2x/cjs/components/error-block/index.js +8 -0
- package/2x/cjs/components/image-viewer/image-viewer.css +7 -1
- package/2x/cjs/components/image-viewer/image-viewer.d.ts +5 -2
- package/2x/cjs/components/image-viewer/image-viewer.js +24 -4
- package/2x/cjs/components/image-viewer/index.d.ts +2 -1
- package/2x/cjs/components/index-bar/index-bar.d.ts +2 -0
- package/2x/cjs/components/index-bar/index-bar.js +6 -0
- package/2x/cjs/components/index-bar/index.d.ts +1 -0
- package/2x/cjs/components/input/input.js +22 -4
- package/2x/cjs/components/mask/mask.js +9 -7
- package/2x/cjs/components/modal/modal.d.ts +2 -0
- package/2x/cjs/components/modal/modal.js +24 -11
- package/2x/cjs/components/side-bar/side-bar.js +1 -0
- package/2x/cjs/components/spin-loading/spin-loading.js +6 -2
- package/2x/cjs/components/tab-bar/tab-bar.js +1 -0
- package/2x/cjs/index.d.ts +2 -0
- package/2x/cjs/index.js +21 -1
- package/2x/cjs/locales/fr-FR.d.ts +106 -0
- package/2x/cjs/locales/fr-FR.js +119 -0
- package/2x/cjs/utils/measure-css-length.js +2 -2
- package/2x/cjs/utils/reduce-and-restore-motion.d.ts +4 -0
- package/2x/cjs/utils/reduce-and-restore-motion.js +53 -0
- package/2x/cjs/utils/use-inner-visible.d.ts +1 -0
- package/2x/cjs/utils/use-inner-visible.js +18 -0
- package/2x/es/components/dialog/dialog.d.ts +2 -0
- package/2x/es/components/dialog/dialog.js +23 -14
- package/2x/es/components/ellipsis/ellipsis.js +1 -1
- package/2x/es/components/error-block/create-error-block.d.ts +12 -0
- package/2x/es/components/error-block/create-error-block.js +44 -0
- package/2x/es/components/error-block/error-block.d.ts +2 -11
- package/2x/es/components/error-block/error-block.js +8 -46
- package/2x/es/components/error-block/images/index.d.ts +4 -2
- package/2x/es/components/error-block/images/index.js +4 -10
- package/2x/es/components/error-block/index.d.ts +5 -1
- package/2x/es/components/error-block/index.js +1 -0
- package/2x/es/components/image-viewer/image-viewer.css +7 -1
- package/2x/es/components/image-viewer/image-viewer.d.ts +5 -2
- package/2x/es/components/image-viewer/image-viewer.js +24 -5
- package/2x/es/components/image-viewer/index.d.ts +2 -1
- package/2x/es/components/index-bar/index-bar.d.ts +2 -0
- package/2x/es/components/index-bar/index-bar.js +6 -0
- package/2x/es/components/index-bar/index.d.ts +1 -0
- package/2x/es/components/input/input.js +21 -4
- package/2x/es/components/mask/mask.js +10 -8
- package/2x/es/components/modal/modal.d.ts +2 -0
- package/2x/es/components/modal/modal.js +23 -12
- package/2x/es/components/side-bar/side-bar.js +2 -0
- package/2x/es/components/spin-loading/spin-loading.js +5 -2
- package/2x/es/components/tab-bar/tab-bar.js +2 -0
- package/2x/es/index.d.ts +2 -0
- package/2x/es/index.js +3 -1
- package/2x/es/locales/fr-FR.d.ts +106 -0
- package/2x/es/locales/fr-FR.js +109 -0
- package/2x/es/utils/measure-css-length.js +2 -2
- package/2x/es/utils/reduce-and-restore-motion.d.ts +4 -0
- package/2x/es/utils/reduce-and-restore-motion.js +36 -0
- package/2x/es/utils/use-inner-visible.d.ts +1 -0
- package/2x/es/utils/use-inner-visible.js +9 -0
- package/2x/package.json +8 -7
- package/README.md +10 -8
- package/bundle/antd-mobile.cjs.js +1551 -1405
- package/bundle/antd-mobile.es.js +1547 -1404
- package/bundle/style.css +6 -1
- package/cjs/components/dialog/dialog.d.ts +2 -0
- package/cjs/components/dialog/dialog.js +24 -13
- package/cjs/components/ellipsis/ellipsis.js +1 -1
- package/cjs/components/error-block/create-error-block.d.ts +12 -0
- package/cjs/components/error-block/create-error-block.js +59 -0
- package/cjs/components/error-block/error-block.d.ts +2 -11
- package/cjs/components/error-block/error-block.js +7 -53
- package/cjs/components/error-block/images/index.d.ts +4 -2
- package/cjs/components/error-block/images/index.js +25 -10
- package/cjs/components/error-block/index.d.ts +5 -1
- package/cjs/components/error-block/index.js +8 -0
- package/cjs/components/image-viewer/image-viewer.css +6 -1
- package/cjs/components/image-viewer/image-viewer.d.ts +5 -2
- package/cjs/components/image-viewer/image-viewer.js +24 -4
- package/cjs/components/image-viewer/index.d.ts +2 -1
- package/cjs/components/index-bar/index-bar.d.ts +2 -0
- package/cjs/components/index-bar/index-bar.js +6 -0
- package/cjs/components/index-bar/index.d.ts +1 -0
- package/cjs/components/input/input.js +22 -4
- package/cjs/components/mask/mask.js +9 -7
- package/cjs/components/modal/modal.d.ts +2 -0
- package/cjs/components/modal/modal.js +24 -11
- package/cjs/components/side-bar/side-bar.js +1 -0
- package/cjs/components/spin-loading/spin-loading.js +6 -2
- package/cjs/components/tab-bar/tab-bar.js +1 -0
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +21 -1
- package/cjs/locales/fr-FR.d.ts +106 -0
- package/cjs/locales/fr-FR.js +119 -0
- package/cjs/utils/measure-css-length.js +2 -2
- package/cjs/utils/reduce-and-restore-motion.d.ts +4 -0
- package/cjs/utils/reduce-and-restore-motion.js +53 -0
- package/cjs/utils/use-inner-visible.d.ts +1 -0
- package/cjs/utils/use-inner-visible.js +18 -0
- package/es/components/dialog/dialog.d.ts +2 -0
- package/es/components/dialog/dialog.js +23 -14
- package/es/components/ellipsis/ellipsis.js +1 -1
- package/es/components/error-block/create-error-block.d.ts +12 -0
- package/es/components/error-block/create-error-block.js +44 -0
- package/es/components/error-block/error-block.d.ts +2 -11
- package/es/components/error-block/error-block.js +8 -46
- package/es/components/error-block/images/index.d.ts +4 -2
- package/es/components/error-block/images/index.js +4 -10
- package/es/components/error-block/index.d.ts +5 -1
- package/es/components/error-block/index.js +1 -0
- package/es/components/image-viewer/image-viewer.css +6 -1
- package/es/components/image-viewer/image-viewer.d.ts +5 -2
- package/es/components/image-viewer/image-viewer.js +24 -5
- package/es/components/image-viewer/index.d.ts +2 -1
- package/es/components/index-bar/index-bar.d.ts +2 -0
- package/es/components/index-bar/index-bar.js +6 -0
- package/es/components/index-bar/index.d.ts +1 -0
- package/es/components/input/input.js +21 -4
- package/es/components/mask/mask.js +10 -8
- package/es/components/modal/modal.d.ts +2 -0
- package/es/components/modal/modal.js +23 -12
- package/es/components/side-bar/side-bar.js +2 -0
- package/es/components/spin-loading/spin-loading.js +5 -2
- package/es/components/tab-bar/tab-bar.js +2 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +3 -1
- package/es/locales/fr-FR.d.ts +106 -0
- package/es/locales/fr-FR.js +109 -0
- package/es/utils/measure-css-length.js +2 -2
- package/es/utils/reduce-and-restore-motion.d.ts +4 -0
- package/es/utils/reduce-and-restore-motion.js +36 -0
- package/es/utils/use-inner-visible.d.ts +1 -0
- package/es/utils/use-inner-visible.js +9 -0
- package/package.json +8 -7
- package/umd/antd-mobile.js +1 -1
- package/umd/antd-mobile.js.LICENSE.txt +12 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { mergeProps } from '../../utils/with-default-props';
|
|
4
|
+
import { withNativeProps } from '../../utils/native-props';
|
|
5
|
+
import { useConfig } from '../config-provider';
|
|
6
|
+
const classPrefix = `adm-error-block`;
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
status: 'default'
|
|
9
|
+
};
|
|
10
|
+
export function createErrorBlock(imageRecord) {
|
|
11
|
+
const ErrorBlock = p => {
|
|
12
|
+
var _a;
|
|
13
|
+
|
|
14
|
+
const props = mergeProps(defaultProps, p);
|
|
15
|
+
const {
|
|
16
|
+
locale
|
|
17
|
+
} = useConfig();
|
|
18
|
+
const contentPack = locale.ErrorBlock[props.status];
|
|
19
|
+
const des = 'description' in props ? props.description : contentPack.description;
|
|
20
|
+
const title = 'title' in props ? props.title : contentPack.title;
|
|
21
|
+
const image = (_a = props.image) !== null && _a !== void 0 ? _a : imageRecord[props.status];
|
|
22
|
+
const imageNode = typeof image === 'string' ? React.createElement("img", {
|
|
23
|
+
src: image,
|
|
24
|
+
alt: 'error block image'
|
|
25
|
+
}) : image;
|
|
26
|
+
return withNativeProps(props, React.createElement("div", {
|
|
27
|
+
className: classNames(classPrefix, {
|
|
28
|
+
[`${classPrefix}-full-page`]: props.fullPage
|
|
29
|
+
})
|
|
30
|
+
}, React.createElement("div", {
|
|
31
|
+
className: `${classPrefix}-image`
|
|
32
|
+
}, imageNode), React.createElement("div", {
|
|
33
|
+
className: `${classPrefix}-description`
|
|
34
|
+
}, title && React.createElement("div", {
|
|
35
|
+
className: `${classPrefix}-description-title`
|
|
36
|
+
}, title), des && React.createElement("div", {
|
|
37
|
+
className: `${classPrefix}-description-subtitle`
|
|
38
|
+
}, des)), props.children && React.createElement("div", {
|
|
39
|
+
className: `${classPrefix}-content`
|
|
40
|
+
}, props.children)));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return ErrorBlock;
|
|
44
|
+
}
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare type ErrorBlockProps = {
|
|
4
|
-
status?: 'default' | 'disconnected' | 'empty' | 'busy';
|
|
5
|
-
title?: ReactNode;
|
|
6
|
-
image?: string | ReactElement;
|
|
7
|
-
description?: ReactNode;
|
|
8
|
-
fullPage?: boolean;
|
|
9
|
-
children?: React.ReactNode;
|
|
10
|
-
} & NativeProps<'--image-height' | '--image-height-full-page' | '--image-width' | '--image-width-full-page'>;
|
|
11
|
-
export declare const ErrorBlock: FC<ErrorBlockProps>;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const ErrorBlock: import("react").FC<import("./create-error-block").ErrorBlockProps>;
|
|
@@ -1,47 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const defaultProps = {
|
|
9
|
-
status: 'default'
|
|
1
|
+
import { createErrorBlock } from './create-error-block';
|
|
2
|
+
import { busyImage, defaultImage, disconnectedImage, emptyImage } from './images';
|
|
3
|
+
const imageRecord = {
|
|
4
|
+
'default': defaultImage,
|
|
5
|
+
'disconnected': disconnectedImage,
|
|
6
|
+
'empty': emptyImage,
|
|
7
|
+
'busy': busyImage
|
|
10
8
|
};
|
|
11
|
-
export const ErrorBlock =
|
|
12
|
-
const props = mergeProps(defaultProps, p);
|
|
13
|
-
const {
|
|
14
|
-
locale
|
|
15
|
-
} = useConfig();
|
|
16
|
-
const contentPack = locale.ErrorBlock[props.status];
|
|
17
|
-
const des = 'description' in props ? props.description : contentPack.description;
|
|
18
|
-
const title = 'title' in props ? props.title : contentPack.title;
|
|
19
|
-
let imageNode = imageRecord[props.status];
|
|
20
|
-
|
|
21
|
-
if (props.image) {
|
|
22
|
-
if (typeof props.image === 'string') {
|
|
23
|
-
imageNode = React.createElement("img", {
|
|
24
|
-
src: props.image,
|
|
25
|
-
alt: 'error block image'
|
|
26
|
-
});
|
|
27
|
-
} else {
|
|
28
|
-
imageNode = props.image;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return withNativeProps(props, React.createElement("div", {
|
|
33
|
-
className: classNames(classPrefix, {
|
|
34
|
-
[`${classPrefix}-full-page`]: props.fullPage
|
|
35
|
-
})
|
|
36
|
-
}, React.createElement("div", {
|
|
37
|
-
className: `${classPrefix}-image`
|
|
38
|
-
}, imageNode), React.createElement("div", {
|
|
39
|
-
className: `${classPrefix}-description`
|
|
40
|
-
}, title && React.createElement("div", {
|
|
41
|
-
className: `${classPrefix}-description-title`
|
|
42
|
-
}, title), des && React.createElement("div", {
|
|
43
|
-
className: `${classPrefix}-description-subtitle`
|
|
44
|
-
}, des)), props.children && React.createElement("div", {
|
|
45
|
-
className: `${classPrefix}-content`
|
|
46
|
-
}, props.children)));
|
|
47
|
-
};
|
|
9
|
+
export const ErrorBlock = createErrorBlock(imageRecord);
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
export { defaultImage } from './default';
|
|
2
|
+
export { disconnectedImage } from './disconnected';
|
|
3
|
+
export { emptyImage } from './empty';
|
|
4
|
+
export { busyImage } from './busy';
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const imageRecord = {
|
|
6
|
-
'default': defaultImage,
|
|
7
|
-
'disconnected': disconnectedImage,
|
|
8
|
-
'empty': emptyImage,
|
|
9
|
-
'busy': busyImage
|
|
10
|
-
};
|
|
1
|
+
export { defaultImage } from './default';
|
|
2
|
+
export { disconnectedImage } from './disconnected';
|
|
3
|
+
export { emptyImage } from './empty';
|
|
4
|
+
export { busyImage } from './busy';
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import './error-block.less';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
import { ErrorBlock } from './error-block';
|
|
3
|
-
export
|
|
4
|
+
export { createErrorBlock } from './create-error-block';
|
|
5
|
+
export type { ErrorBlockProps } from './create-error-block';
|
|
6
|
+
export declare type ErrorBlockStatus = 'default' | 'disconnected' | 'empty' | 'busy';
|
|
7
|
+
export declare type ImageRecord = Partial<Record<ErrorBlockStatus, string | ReactNode>>;
|
|
4
8
|
export default ErrorBlock;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
.adm-image-viewer-content {
|
|
2
2
|
width: 100vw;
|
|
3
3
|
height: 100vh;
|
|
4
|
-
max-height: -webkit-fill-available;
|
|
5
4
|
touch-action: none;
|
|
6
5
|
user-select: none;
|
|
7
6
|
}
|
|
8
7
|
|
|
8
|
+
.adm-image-viewer-footer {
|
|
9
|
+
position: absolute;
|
|
10
|
+
width: 100%;
|
|
11
|
+
bottom: 0;
|
|
12
|
+
z-index: 1;
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
.adm-image-viewer-slides {
|
|
10
16
|
height: 100%;
|
|
11
17
|
position: relative;
|
|
@@ -8,16 +8,19 @@ export declare type ImageViewerProps = {
|
|
|
8
8
|
visible?: boolean;
|
|
9
9
|
onClose?: () => void;
|
|
10
10
|
afterClose?: () => void;
|
|
11
|
+
renderFooter?: (image: string) => React.ReactNode;
|
|
11
12
|
};
|
|
12
13
|
export declare const ImageViewer: FC<ImageViewerProps>;
|
|
13
14
|
export declare type MultiImageViewerRef = SlidesRef;
|
|
14
|
-
export declare type MultiImageViewerProps = Omit<ImageViewerProps, 'image'> & {
|
|
15
|
+
export declare type MultiImageViewerProps = Omit<ImageViewerProps, 'image' | 'renderFooter'> & {
|
|
15
16
|
images?: string[];
|
|
16
17
|
defaultIndex?: number;
|
|
17
18
|
onIndexChange?: (index: number) => void;
|
|
19
|
+
renderFooter?: (image: string, index: number) => React.ReactNode;
|
|
18
20
|
};
|
|
19
|
-
export declare const MultiImageViewer: React.ForwardRefExoticComponent<Omit<ImageViewerProps, "image"> & {
|
|
21
|
+
export declare const MultiImageViewer: React.ForwardRefExoticComponent<Omit<ImageViewerProps, "image" | "renderFooter"> & {
|
|
20
22
|
images?: string[] | undefined;
|
|
21
23
|
defaultIndex?: number | undefined;
|
|
22
24
|
onIndexChange?: ((index: number) => void) | undefined;
|
|
25
|
+
renderFooter?: ((image: string, index: number) => React.ReactNode) | undefined;
|
|
23
26
|
} & React.RefAttributes<SlidesRef>>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';
|
|
1
|
+
import React, { forwardRef, useImperativeHandle, useRef, useState, useCallback } from 'react';
|
|
2
2
|
import { mergeProps } from '../../utils/with-default-props';
|
|
3
3
|
import { renderToContainer } from '../../utils/render-to-container';
|
|
4
4
|
import Mask from '../mask';
|
|
5
|
+
import SafeArea from '../safe-area';
|
|
5
6
|
import { Slide } from './slide';
|
|
6
7
|
import { Slides } from './slides';
|
|
7
8
|
const classPrefix = `adm-image-viewer`;
|
|
@@ -11,6 +12,8 @@ const defaultProps = {
|
|
|
11
12
|
visible: false
|
|
12
13
|
};
|
|
13
14
|
export const ImageViewer = p => {
|
|
15
|
+
var _a;
|
|
16
|
+
|
|
14
17
|
const props = mergeProps(defaultProps, p);
|
|
15
18
|
const node = React.createElement(Mask, {
|
|
16
19
|
visible: props.visible,
|
|
@@ -27,6 +30,10 @@ export const ImageViewer = p => {
|
|
|
27
30
|
(_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
28
31
|
},
|
|
29
32
|
maxZoom: props.maxZoom
|
|
33
|
+
})), props.image && React.createElement("div", {
|
|
34
|
+
className: `${classPrefix}-footer`
|
|
35
|
+
}, (_a = props.renderFooter) === null || _a === void 0 ? void 0 : _a.call(props, props.image), React.createElement(SafeArea, {
|
|
36
|
+
position: 'bottom'
|
|
30
37
|
})));
|
|
31
38
|
return renderToContainer(props.getContainer, node);
|
|
32
39
|
};
|
|
@@ -34,17 +41,25 @@ const multiDefaultProps = Object.assign(Object.assign({}, defaultProps), {
|
|
|
34
41
|
defaultIndex: 0
|
|
35
42
|
});
|
|
36
43
|
export const MultiImageViewer = forwardRef((p, ref) => {
|
|
44
|
+
var _a;
|
|
45
|
+
|
|
37
46
|
const props = mergeProps(multiDefaultProps, p);
|
|
38
|
-
const [
|
|
47
|
+
const [index, setIndex] = useState(props.defaultIndex);
|
|
39
48
|
const slidesRef = useRef(null);
|
|
40
49
|
useImperativeHandle(ref, () => ({
|
|
41
50
|
swipeTo: (index, immediate) => {
|
|
42
51
|
var _a;
|
|
43
52
|
|
|
44
|
-
|
|
53
|
+
setIndex(index);
|
|
45
54
|
(_a = slidesRef.current) === null || _a === void 0 ? void 0 : _a.swipeTo(index, immediate);
|
|
46
55
|
}
|
|
47
56
|
}));
|
|
57
|
+
const onSlideChange = useCallback(index => {
|
|
58
|
+
var _a;
|
|
59
|
+
|
|
60
|
+
setIndex(index);
|
|
61
|
+
(_a = props.onIndexChange) === null || _a === void 0 ? void 0 : _a.call(props, index);
|
|
62
|
+
}, [props.onIndexChange]);
|
|
48
63
|
const node = React.createElement(Mask, {
|
|
49
64
|
visible: props.visible,
|
|
50
65
|
disableBodyScroll: false,
|
|
@@ -54,8 +69,8 @@ export const MultiImageViewer = forwardRef((p, ref) => {
|
|
|
54
69
|
className: `${classPrefix}-content`
|
|
55
70
|
}, props.images && React.createElement(Slides, {
|
|
56
71
|
ref: slidesRef,
|
|
57
|
-
defaultIndex:
|
|
58
|
-
onIndexChange:
|
|
72
|
+
defaultIndex: index,
|
|
73
|
+
onIndexChange: onSlideChange,
|
|
59
74
|
images: props.images,
|
|
60
75
|
onTap: () => {
|
|
61
76
|
var _a;
|
|
@@ -63,6 +78,10 @@ export const MultiImageViewer = forwardRef((p, ref) => {
|
|
|
63
78
|
(_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
64
79
|
},
|
|
65
80
|
maxZoom: props.maxZoom
|
|
81
|
+
})), props.images && React.createElement("div", {
|
|
82
|
+
className: `${classPrefix}-footer`
|
|
83
|
+
}, (_a = props.renderFooter) === null || _a === void 0 ? void 0 : _a.call(props, props.images[index], index), React.createElement(SafeArea, {
|
|
84
|
+
position: 'bottom'
|
|
66
85
|
})));
|
|
67
86
|
return renderToContainer(props.getContainer, node);
|
|
68
87
|
});
|
|
@@ -4,10 +4,11 @@ import { showMultiImageViewer, showImageViewer, clearImageViewer } from './metho
|
|
|
4
4
|
export type { ImageViewerProps, MultiImageViewerProps, MultiImageViewerRef, } from './image-viewer';
|
|
5
5
|
export type { ImageViewerShowHandler } from './methods';
|
|
6
6
|
declare const _default: import("react").FC<import("./image-viewer").ImageViewerProps> & {
|
|
7
|
-
Multi: import("react").ForwardRefExoticComponent<Omit<import("./image-viewer").ImageViewerProps, "image"> & {
|
|
7
|
+
Multi: import("react").ForwardRefExoticComponent<Omit<import("./image-viewer").ImageViewerProps, "image" | "renderFooter"> & {
|
|
8
8
|
images?: string[] | undefined;
|
|
9
9
|
defaultIndex?: number | undefined;
|
|
10
10
|
onIndexChange?: ((index: number) => void) | undefined;
|
|
11
|
+
renderFooter?: ((image: string, index: number) => import("react").ReactNode) | undefined;
|
|
11
12
|
} & import("react").RefAttributes<import("./slides").SlidesRef>> & {
|
|
12
13
|
show: typeof showMultiImageViewer;
|
|
13
14
|
};
|
|
@@ -2,6 +2,7 @@ import React, { ReactNode } from 'react';
|
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
3
|
export declare type IndexBarProps = {
|
|
4
4
|
sticky?: boolean;
|
|
5
|
+
onIndexChange?: (index: string) => void;
|
|
5
6
|
children?: React.ReactNode;
|
|
6
7
|
} & NativeProps<'--sticky-offset-top'>;
|
|
7
8
|
export declare type IndexBarRef = {
|
|
@@ -9,5 +10,6 @@ export declare type IndexBarRef = {
|
|
|
9
10
|
};
|
|
10
11
|
export declare const IndexBar: React.ForwardRefExoticComponent<{
|
|
11
12
|
sticky?: boolean | undefined;
|
|
13
|
+
onIndexChange?: ((index: string) => void) | undefined;
|
|
12
14
|
children?: React.ReactNode;
|
|
13
15
|
} & NativeProps<"--sticky-offset-top"> & React.RefAttributes<IndexBarRef>>;
|
|
@@ -49,6 +49,8 @@ export const IndexBar = forwardRef((p, ref) => {
|
|
|
49
49
|
}));
|
|
50
50
|
|
|
51
51
|
function scrollTo(index) {
|
|
52
|
+
var _a;
|
|
53
|
+
|
|
52
54
|
const body = bodyRef.current;
|
|
53
55
|
if (!body) return;
|
|
54
56
|
const children = body.children;
|
|
@@ -61,6 +63,7 @@ export const IndexBar = forwardRef((p, ref) => {
|
|
|
61
63
|
if (panelIndex === index) {
|
|
62
64
|
body.scrollTop = panel.offsetTop;
|
|
63
65
|
setActiveIndex(index);
|
|
66
|
+
activeIndex !== index && ((_a = props.onIndexChange) === null || _a === void 0 ? void 0 : _a.call(props, index));
|
|
64
67
|
return;
|
|
65
68
|
}
|
|
66
69
|
}
|
|
@@ -69,6 +72,8 @@ export const IndexBar = forwardRef((p, ref) => {
|
|
|
69
72
|
const {
|
|
70
73
|
run: checkActiveIndex
|
|
71
74
|
} = useThrottleFn(() => {
|
|
75
|
+
var _a;
|
|
76
|
+
|
|
72
77
|
const body = bodyRef.current;
|
|
73
78
|
if (!body) return;
|
|
74
79
|
const scrollTop = body.scrollTop;
|
|
@@ -82,6 +87,7 @@ export const IndexBar = forwardRef((p, ref) => {
|
|
|
82
87
|
|
|
83
88
|
if (panel.offsetTop + panel.clientHeight - titleHeight > scrollTop) {
|
|
84
89
|
setActiveIndex(panelIndex);
|
|
90
|
+
activeIndex !== panelIndex && ((_a = props.onIndexChange) === null || _a === void 0 ? void 0 : _a.call(props, panelIndex));
|
|
85
91
|
return;
|
|
86
92
|
}
|
|
87
93
|
}
|
|
@@ -4,6 +4,7 @@ export type { IndexBarProps, IndexBarRef } from './index-bar';
|
|
|
4
4
|
export type { IndexBarPanelProps } from './panel';
|
|
5
5
|
declare const _default: import("react").ForwardRefExoticComponent<{
|
|
6
6
|
sticky?: boolean | undefined;
|
|
7
|
+
onIndexChange?: ((index: string) => void) | undefined;
|
|
7
8
|
children?: import("react").ReactNode;
|
|
8
9
|
} & import("../../utils/native-props").NativeProps<"--sticky-offset-top"> & import("react").RefAttributes<import("./index-bar").IndexBarRef>> & {
|
|
9
10
|
Panel: import("react").FC<import("./panel").IndexBarPanelProps>;
|
|
@@ -6,6 +6,7 @@ import { mergeProps } from '../../utils/with-default-props';
|
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import { useIsomorphicLayoutEffect } from 'ahooks';
|
|
8
8
|
import { bound } from '../../utils/bound';
|
|
9
|
+
import { isIOS } from '../../utils/validate';
|
|
9
10
|
const classPrefix = `adm-input`;
|
|
10
11
|
const defaultProps = {
|
|
11
12
|
defaultValue: '',
|
|
@@ -15,6 +16,7 @@ export const Input = forwardRef((p, ref) => {
|
|
|
15
16
|
const props = mergeProps(defaultProps, p);
|
|
16
17
|
const [value, setValue] = usePropsValue(props);
|
|
17
18
|
const [hasFocus, setHasFocus] = useState(false);
|
|
19
|
+
const compositionStartRef = useRef(false);
|
|
18
20
|
const nativeInputRef = useRef(null);
|
|
19
21
|
useImperativeHandle(ref, () => ({
|
|
20
22
|
clear: () => {
|
|
@@ -121,8 +123,18 @@ export const Input = forwardRef((p, ref) => {
|
|
|
121
123
|
autoCorrect: props.autoCorrect,
|
|
122
124
|
onKeyDown: handleKeydown,
|
|
123
125
|
onKeyUp: props.onKeyUp,
|
|
124
|
-
onCompositionStart:
|
|
125
|
-
|
|
126
|
+
onCompositionStart: e => {
|
|
127
|
+
var _a;
|
|
128
|
+
|
|
129
|
+
compositionStartRef.current = true;
|
|
130
|
+
(_a = props.onCompositionStart) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
131
|
+
},
|
|
132
|
+
onCompositionEnd: e => {
|
|
133
|
+
var _a;
|
|
134
|
+
|
|
135
|
+
compositionStartRef.current = false;
|
|
136
|
+
(_a = props.onCompositionEnd) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
137
|
+
},
|
|
126
138
|
onClick: props.onClick
|
|
127
139
|
}), shouldShowClear && React.createElement("div", {
|
|
128
140
|
className: `${classPrefix}-clear`,
|
|
@@ -130,10 +142,15 @@ export const Input = forwardRef((p, ref) => {
|
|
|
130
142
|
e.preventDefault();
|
|
131
143
|
},
|
|
132
144
|
onClick: () => {
|
|
133
|
-
var _a;
|
|
145
|
+
var _a, _b;
|
|
134
146
|
|
|
135
147
|
setValue('');
|
|
136
|
-
(_a = props.onClear) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
148
|
+
(_a = props.onClear) === null || _a === void 0 ? void 0 : _a.call(props); // https://github.com/ant-design/ant-design-mobile/issues/5212
|
|
149
|
+
|
|
150
|
+
if (isIOS() && compositionStartRef.current) {
|
|
151
|
+
compositionStartRef.current = false;
|
|
152
|
+
(_b = nativeInputRef.current) === null || _b === void 0 ? void 0 : _b.blur();
|
|
153
|
+
}
|
|
137
154
|
}
|
|
138
155
|
}, React.createElement(CloseCircleFill, null))));
|
|
139
156
|
});
|
|
@@ -6,7 +6,7 @@ import { useSpring, animated } from '@react-spring/web';
|
|
|
6
6
|
import { renderToContainer } from '../../utils/render-to-container';
|
|
7
7
|
import { mergeProps } from '../../utils/with-default-props';
|
|
8
8
|
import { useConfig } from '../config-provider';
|
|
9
|
-
import {
|
|
9
|
+
import { ShouldRender } from '../../utils/should-render';
|
|
10
10
|
import { withStopPropagation } from '../../utils/with-stop-propagation';
|
|
11
11
|
const classPrefix = `adm-mask`;
|
|
12
12
|
const opacityRecord = {
|
|
@@ -47,7 +47,7 @@ export const Mask = p => {
|
|
|
47
47
|
config: {
|
|
48
48
|
precision: 0.01,
|
|
49
49
|
mass: 1,
|
|
50
|
-
tension:
|
|
50
|
+
tension: 250,
|
|
51
51
|
friction: 30,
|
|
52
52
|
clamp: true
|
|
53
53
|
},
|
|
@@ -67,14 +67,12 @@ export const Mask = p => {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
|
-
const shouldRender = useShouldRender(active, props.forceRender, props.destroyOnClose);
|
|
71
70
|
const node = withStopPropagation(props.stopPropagation, withNativeProps(props, React.createElement(animated.div, {
|
|
72
71
|
className: classPrefix,
|
|
73
72
|
ref: ref,
|
|
74
|
-
style: Object.assign(Object.assign({
|
|
73
|
+
style: Object.assign(Object.assign({}, props.style), {
|
|
75
74
|
background,
|
|
76
|
-
opacity
|
|
77
|
-
}, props.style), {
|
|
75
|
+
opacity,
|
|
78
76
|
display: active ? undefined : 'none'
|
|
79
77
|
}),
|
|
80
78
|
onClick: e => {
|
|
@@ -91,6 +89,10 @@ export const Mask = p => {
|
|
|
91
89
|
onClick: props.onMaskClick
|
|
92
90
|
}), React.createElement("div", {
|
|
93
91
|
className: `${classPrefix}-content`
|
|
94
|
-
},
|
|
95
|
-
return
|
|
92
|
+
}, props.children))));
|
|
93
|
+
return React.createElement(ShouldRender, {
|
|
94
|
+
active: active,
|
|
95
|
+
forceRender: props.forceRender,
|
|
96
|
+
destroyOnClose: props.destroyOnClose
|
|
97
|
+
}, renderToContainer(props.getContainer, node));
|
|
96
98
|
};
|
|
@@ -2,7 +2,7 @@ import { __awaiter } from "tslib";
|
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
3
|
import { mergeProps } from '../../utils/with-default-props';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
|
-
import { useUnmountedRef } from 'ahooks';
|
|
5
|
+
import { useIsomorphicLayoutEffect, useUnmountedRef } from 'ahooks';
|
|
6
6
|
import Mask from '../mask';
|
|
7
7
|
import { ModalActionButton } from './modal-action-button';
|
|
8
8
|
import Image from '../image';
|
|
@@ -13,6 +13,8 @@ import AutoCenter from '../auto-center';
|
|
|
13
13
|
import { useSpring, animated } from '@react-spring/web';
|
|
14
14
|
import { withNativeProps } from '../../utils/native-props';
|
|
15
15
|
import { CloseOutline } from 'antd-mobile-icons';
|
|
16
|
+
import { ShouldRender } from '../../utils/should-render';
|
|
17
|
+
import { useInnerVisible } from '../../utils/use-inner-visible';
|
|
16
18
|
const defaultProps = {
|
|
17
19
|
visible: false,
|
|
18
20
|
actions: [],
|
|
@@ -21,7 +23,9 @@ const defaultProps = {
|
|
|
21
23
|
stopPropagation: ['click'],
|
|
22
24
|
showCloseButton: false,
|
|
23
25
|
getContainer: null,
|
|
24
|
-
disableBodyScroll: true
|
|
26
|
+
disableBodyScroll: true,
|
|
27
|
+
destroyOnClose: false,
|
|
28
|
+
forceRender: false
|
|
25
29
|
};
|
|
26
30
|
export const Modal = p => {
|
|
27
31
|
const props = mergeProps(defaultProps, p);
|
|
@@ -35,9 +39,6 @@ export const Modal = p => {
|
|
|
35
39
|
friction: 25,
|
|
36
40
|
clamp: true
|
|
37
41
|
},
|
|
38
|
-
onStart: () => {
|
|
39
|
-
setActive(true);
|
|
40
|
-
},
|
|
41
42
|
onRest: () => {
|
|
42
43
|
var _a, _b;
|
|
43
44
|
|
|
@@ -52,6 +53,12 @@ export const Modal = p => {
|
|
|
52
53
|
}
|
|
53
54
|
});
|
|
54
55
|
const [active, setActive] = useState(props.visible);
|
|
56
|
+
useIsomorphicLayoutEffect(() => {
|
|
57
|
+
if (props.visible) {
|
|
58
|
+
setActive(true);
|
|
59
|
+
}
|
|
60
|
+
}, [props.visible]);
|
|
61
|
+
const maskVisible = useInnerVisible(active && props.visible);
|
|
55
62
|
const body = React.createElement("div", {
|
|
56
63
|
className: classNames(cls('body'), props.image && cls('with-image'), props.bodyClassName),
|
|
57
64
|
style: props.bodyStyle
|
|
@@ -92,23 +99,27 @@ export const Modal = p => {
|
|
|
92
99
|
const node = withStopPropagation(props.stopPropagation, withNativeProps(props, React.createElement("div", {
|
|
93
100
|
className: cls(),
|
|
94
101
|
style: {
|
|
95
|
-
display: active ? undefined : 'none'
|
|
102
|
+
display: active ? undefined : 'none',
|
|
103
|
+
pointerEvents: active ? undefined : 'none'
|
|
96
104
|
}
|
|
97
105
|
}, React.createElement(Mask, {
|
|
98
|
-
visible:
|
|
106
|
+
visible: maskVisible,
|
|
107
|
+
forceRender: props.forceRender,
|
|
108
|
+
destroyOnClose: props.destroyOnClose,
|
|
99
109
|
onMaskClick: props.closeOnMaskClick ? props.onClose : undefined,
|
|
100
110
|
style: props.maskStyle,
|
|
101
111
|
className: classNames(cls('mask'), props.maskClassName),
|
|
102
112
|
disableBodyScroll: props.disableBodyScroll
|
|
103
113
|
}), React.createElement("div", {
|
|
104
|
-
className: cls('wrap')
|
|
105
|
-
style: {
|
|
106
|
-
pointerEvents: props.visible ? undefined : 'none'
|
|
107
|
-
}
|
|
114
|
+
className: cls('wrap')
|
|
108
115
|
}, React.createElement(animated.div, {
|
|
109
116
|
style: style
|
|
110
117
|
}, body)))));
|
|
111
|
-
return
|
|
118
|
+
return React.createElement(ShouldRender, {
|
|
119
|
+
active: active,
|
|
120
|
+
forceRender: props.forceRender,
|
|
121
|
+
destroyOnClose: props.destroyOnClose
|
|
122
|
+
}, renderToContainer(props.getContainer, node));
|
|
112
123
|
};
|
|
113
124
|
|
|
114
125
|
function cls(name = '') {
|
|
@@ -6,6 +6,8 @@ import { usePropsValue } from '../../utils/use-props-value';
|
|
|
6
6
|
import { Corner } from './corner';
|
|
7
7
|
import { traverseReactNode } from '../../utils/traverse-react-node';
|
|
8
8
|
const classPrefix = `adm-side-bar`;
|
|
9
|
+
/* istanbul ignore next */
|
|
10
|
+
|
|
9
11
|
export const SideBarItem = () => {
|
|
10
12
|
return null;
|
|
11
13
|
};
|
|
@@ -2,6 +2,7 @@ import React, { memo } from 'react';
|
|
|
2
2
|
import { withNativeProps } from '../../utils/native-props';
|
|
3
3
|
import { mergeProps } from '../../utils/with-default-props';
|
|
4
4
|
import { useSpring, animated } from '@react-spring/web';
|
|
5
|
+
import { useMotionReduced } from '../../utils/reduce-and-restore-motion';
|
|
5
6
|
const classPrefix = 'adm-spin-loading';
|
|
6
7
|
const colorRecord = {
|
|
7
8
|
default: 'var(--adm-color-weak)',
|
|
@@ -16,17 +17,19 @@ export const SpinLoading = memo(p => {
|
|
|
16
17
|
var _a;
|
|
17
18
|
|
|
18
19
|
const props = mergeProps(defaultProps, p);
|
|
20
|
+
const motionReduced = useMotionReduced();
|
|
19
21
|
const {
|
|
20
22
|
percent
|
|
21
23
|
} = useSpring({
|
|
24
|
+
cancel: motionReduced,
|
|
22
25
|
loop: {
|
|
23
26
|
reverse: true
|
|
24
27
|
},
|
|
25
28
|
from: {
|
|
26
|
-
percent:
|
|
29
|
+
percent: 80
|
|
27
30
|
},
|
|
28
31
|
to: {
|
|
29
|
-
percent:
|
|
32
|
+
percent: 30
|
|
30
33
|
},
|
|
31
34
|
config: {
|
|
32
35
|
duration: 1200
|
|
@@ -6,6 +6,8 @@ import Badge from '../badge';
|
|
|
6
6
|
import SafeArea from '../safe-area';
|
|
7
7
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
8
8
|
import { traverseReactNode } from '../../utils/traverse-react-node';
|
|
9
|
+
/* istanbul ignore next */
|
|
10
|
+
|
|
9
11
|
export const TabBarItem = () => {
|
|
10
12
|
return null;
|
|
11
13
|
};
|
package/2x/es/index.d.ts
CHANGED
|
@@ -77,3 +77,5 @@ export { default as Toast } from './components/toast';
|
|
|
77
77
|
export { default as TreeSelect } from './components/tree-select';
|
|
78
78
|
export { default as VirtualInput } from './components/virtual-input';
|
|
79
79
|
export { default as WaterMark } from './components/water-mark';
|
|
80
|
+
export { createErrorBlock } from './components/error-block';
|
|
81
|
+
export { reduceMotion, restoreMotion } from './utils/reduce-and-restore-motion';
|
package/2x/es/index.js
CHANGED
|
@@ -76,4 +76,6 @@ export { default as TextArea } from './components/text-area';
|
|
|
76
76
|
export { default as Toast } from './components/toast';
|
|
77
77
|
export { default as TreeSelect } from './components/tree-select';
|
|
78
78
|
export { default as VirtualInput } from './components/virtual-input';
|
|
79
|
-
export { default as WaterMark } from './components/water-mark';
|
|
79
|
+
export { default as WaterMark } from './components/water-mark';
|
|
80
|
+
export { createErrorBlock } from './components/error-block';
|
|
81
|
+
export { reduceMotion, restoreMotion } from './utils/reduce-and-restore-motion';
|