antd-mobile 5.12.4 → 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/action-sheet/action-sheet.css +22 -7
- package/2x/cjs/components/action-sheet/action-sheet.js +8 -16
- package/2x/cjs/components/button/button.d.ts +1 -1
- package/2x/cjs/components/calendar/calendar.css +4 -0
- package/2x/cjs/components/calendar/calendar.d.ts +1 -0
- package/2x/cjs/components/calendar/calendar.js +1 -1
- 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/form/form-item.js +1 -4
- package/2x/cjs/components/image/image.d.ts +1 -0
- package/2x/cjs/components/image/image.js +4 -2
- 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/popover/popover.css +1 -0
- package/2x/cjs/components/search-bar/search-bar.d.ts +1 -1
- 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/swiper/index.d.ts +1 -1
- package/2x/cjs/components/swiper/swiper.d.ts +1 -1
- package/2x/cjs/components/tab-bar/tab-bar.js +1 -0
- package/2x/cjs/components/text-area/text-area.js +2 -1
- 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/action-sheet/action-sheet.css +22 -7
- package/2x/es/components/action-sheet/action-sheet.js +8 -15
- package/2x/es/components/button/button.d.ts +1 -1
- package/2x/es/components/calendar/calendar.css +4 -0
- package/2x/es/components/calendar/calendar.d.ts +1 -0
- package/2x/es/components/calendar/calendar.js +1 -1
- 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/form/form-item.js +1 -4
- package/2x/es/components/image/image.d.ts +1 -0
- package/2x/es/components/image/image.js +4 -2
- 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/popover/popover.css +1 -0
- package/2x/es/components/search-bar/search-bar.d.ts +1 -1
- 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/swiper/index.d.ts +1 -1
- package/2x/es/components/swiper/swiper.d.ts +1 -1
- package/2x/es/components/tab-bar/tab-bar.js +2 -0
- package/2x/es/components/text-area/text-area.js +2 -1
- 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 +1708 -1567
- package/bundle/antd-mobile.es.js +1705 -1567
- package/bundle/style.css +100 -79
- package/cjs/components/action-sheet/action-sheet.css +19 -7
- package/cjs/components/action-sheet/action-sheet.js +8 -16
- package/cjs/components/button/button.d.ts +1 -1
- package/cjs/components/calendar/calendar.css +3 -0
- package/cjs/components/calendar/calendar.d.ts +1 -0
- package/cjs/components/calendar/calendar.js +1 -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/form/form-item.js +1 -4
- package/cjs/components/image/image.d.ts +1 -0
- package/cjs/components/image/image.js +4 -2
- 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/popover/popover.css +1 -0
- package/cjs/components/search-bar/search-bar.d.ts +1 -1
- package/cjs/components/side-bar/side-bar.js +1 -0
- package/cjs/components/spin-loading/spin-loading.js +6 -2
- package/cjs/components/swiper/index.d.ts +1 -1
- package/cjs/components/swiper/swiper.d.ts +1 -1
- package/cjs/components/tab-bar/tab-bar.js +1 -0
- package/cjs/components/text-area/text-area.js +2 -1
- 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/action-sheet/action-sheet.css +19 -7
- package/es/components/action-sheet/action-sheet.js +8 -15
- package/es/components/button/button.d.ts +1 -1
- package/es/components/calendar/calendar.css +3 -0
- package/es/components/calendar/calendar.d.ts +1 -0
- package/es/components/calendar/calendar.js +1 -1
- 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/form/form-item.js +1 -4
- package/es/components/image/image.d.ts +1 -0
- package/es/components/image/image.js +4 -2
- 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/popover/popover.css +1 -0
- package/es/components/search-bar/search-bar.d.ts +1 -1
- package/es/components/side-bar/side-bar.js +2 -0
- package/es/components/spin-loading/spin-loading.js +5 -2
- package/es/components/swiper/index.d.ts +1 -1
- package/es/components/swiper/swiper.d.ts +1 -1
- package/es/components/tab-bar/tab-bar.js +2 -0
- package/es/components/text-area/text-area.js +2 -1
- 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
|
@@ -16,7 +16,8 @@ const defaultProps = {
|
|
|
16
16
|
fallback: React.createElement("div", {
|
|
17
17
|
className: `${classPrefix}-tip`
|
|
18
18
|
}, React.createElement(BrokenImageIcon, null)),
|
|
19
|
-
lazy: false
|
|
19
|
+
lazy: false,
|
|
20
|
+
draggable: false
|
|
20
21
|
};
|
|
21
22
|
export const Image = staged(p => {
|
|
22
23
|
const props = mergeProps(defaultProps, p);
|
|
@@ -65,7 +66,8 @@ export const Image = staged(p => {
|
|
|
65
66
|
referrerPolicy: props.referrerPolicy,
|
|
66
67
|
sizes: props.sizes,
|
|
67
68
|
srcSet: srcSet,
|
|
68
|
-
useMap: props.useMap
|
|
69
|
+
useMap: props.useMap,
|
|
70
|
+
draggable: props.draggable
|
|
69
71
|
});
|
|
70
72
|
return React.createElement(React.Fragment, null, !loaded && props.placeholder, img);
|
|
71
73
|
}
|
|
@@ -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 = '') {
|
|
@@ -31,4 +31,4 @@ export declare const SearchBar: React.ForwardRefExoticComponent<Pick<InputProps,
|
|
|
31
31
|
onSearch?: ((val: string) => void) | undefined;
|
|
32
32
|
onChange?: ((val: string) => void) | undefined;
|
|
33
33
|
onCancel?: (() => void) | undefined;
|
|
34
|
-
} & NativeProps<"--
|
|
34
|
+
} & NativeProps<"--height" | "--border-radius" | "--padding-left" | "--background" | "--placeholder-color"> & React.RefAttributes<InputRef>>;
|
|
@@ -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
|
|
@@ -16,7 +16,7 @@ declare const _default: import("react").ForwardRefExoticComponent<{
|
|
|
16
16
|
stuckAtBoundary?: boolean | undefined;
|
|
17
17
|
rubberband?: boolean | undefined;
|
|
18
18
|
children?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>[] | undefined;
|
|
19
|
-
} & import("../../utils/native-props").NativeProps<"--
|
|
19
|
+
} & import("../../utils/native-props").NativeProps<"--width" | "--height" | "--border-radius" | "--track-padding"> & import("react").RefAttributes<import("./swiper").SwiperRef>> & {
|
|
20
20
|
Item: import("react").FC<{
|
|
21
21
|
onClick?: ((e: import("react").MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
|
|
22
22
|
children?: import("react").ReactNode;
|
|
@@ -37,4 +37,4 @@ export declare const Swiper: React.ForwardRefExoticComponent<{
|
|
|
37
37
|
stuckAtBoundary?: boolean | undefined;
|
|
38
38
|
rubberband?: boolean | undefined;
|
|
39
39
|
children?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactElement<any, string | React.JSXElementConstructor<any>>[] | undefined;
|
|
40
|
-
} & NativeProps<"--
|
|
40
|
+
} & NativeProps<"--width" | "--height" | "--border-radius" | "--track-padding"> & React.RefAttributes<SwiperRef>>;
|
|
@@ -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
|
};
|
|
@@ -106,7 +106,8 @@ export const TextArea = forwardRef((p, ref) => {
|
|
|
106
106
|
compositingRef.current = false;
|
|
107
107
|
|
|
108
108
|
if (maxLength) {
|
|
109
|
-
|
|
109
|
+
const v = e.target.value;
|
|
110
|
+
setValue([...v].slice(0, maxLength).join(''));
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
(_a = props.onCompositionEnd) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
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';
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
declare const frFR: {
|
|
2
|
+
locale: string;
|
|
3
|
+
common: {
|
|
4
|
+
confirm: string;
|
|
5
|
+
cancel: string;
|
|
6
|
+
loading: string;
|
|
7
|
+
};
|
|
8
|
+
Calendar: {
|
|
9
|
+
markItems: string[];
|
|
10
|
+
renderYearAndMonth: (year: number, month: number) => string;
|
|
11
|
+
};
|
|
12
|
+
Cascader: {
|
|
13
|
+
placeholder: string;
|
|
14
|
+
};
|
|
15
|
+
Dialog: {
|
|
16
|
+
ok: string;
|
|
17
|
+
};
|
|
18
|
+
ErrorBlock: {
|
|
19
|
+
default: {
|
|
20
|
+
title: string;
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
busy: {
|
|
24
|
+
title: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
disconnected: {
|
|
28
|
+
title: string;
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
empty: {
|
|
32
|
+
title: string;
|
|
33
|
+
description: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
Form: {
|
|
37
|
+
required: string;
|
|
38
|
+
optional: string;
|
|
39
|
+
defaultValidateMessages: {
|
|
40
|
+
default: string;
|
|
41
|
+
required: string;
|
|
42
|
+
enum: string;
|
|
43
|
+
whitespace: string;
|
|
44
|
+
date: {
|
|
45
|
+
format: string;
|
|
46
|
+
parse: string;
|
|
47
|
+
invalid: string;
|
|
48
|
+
};
|
|
49
|
+
types: {
|
|
50
|
+
string: string;
|
|
51
|
+
method: string;
|
|
52
|
+
array: string;
|
|
53
|
+
object: string;
|
|
54
|
+
number: string;
|
|
55
|
+
date: string;
|
|
56
|
+
boolean: string;
|
|
57
|
+
integer: string;
|
|
58
|
+
float: string;
|
|
59
|
+
regexp: string;
|
|
60
|
+
email: string;
|
|
61
|
+
url: string;
|
|
62
|
+
hex: string;
|
|
63
|
+
};
|
|
64
|
+
string: {
|
|
65
|
+
len: string;
|
|
66
|
+
min: string;
|
|
67
|
+
max: string;
|
|
68
|
+
range: string;
|
|
69
|
+
};
|
|
70
|
+
number: {
|
|
71
|
+
len: string;
|
|
72
|
+
min: string;
|
|
73
|
+
max: string;
|
|
74
|
+
range: string;
|
|
75
|
+
};
|
|
76
|
+
array: {
|
|
77
|
+
len: string;
|
|
78
|
+
min: string;
|
|
79
|
+
max: string;
|
|
80
|
+
range: string;
|
|
81
|
+
};
|
|
82
|
+
pattern: {
|
|
83
|
+
mismatch: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
ImageUploader: {
|
|
88
|
+
uploading: string;
|
|
89
|
+
upload: string;
|
|
90
|
+
};
|
|
91
|
+
InfiniteScroll: {
|
|
92
|
+
noMore: string;
|
|
93
|
+
};
|
|
94
|
+
Mask: {
|
|
95
|
+
name: string;
|
|
96
|
+
};
|
|
97
|
+
Modal: {
|
|
98
|
+
ok: string;
|
|
99
|
+
};
|
|
100
|
+
PullToRefresh: {
|
|
101
|
+
pulling: string;
|
|
102
|
+
canRelease: string;
|
|
103
|
+
complete: string;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
export default frFR;
|