antd-mobile 0.0.0-dev-626cbf51f → 0.0.0-dev.fc623d614
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/badge/badge.d.ts +1 -1
- package/2x/cjs/components/badge/badge.js +3 -1
- package/2x/cjs/components/badge/index.d.ts +1 -1
- package/2x/cjs/components/button/button.d.ts +6 -4
- package/2x/cjs/components/button/button.js +5 -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 +2 -2
- package/2x/cjs/components/dialog/dialog.d.ts +4 -1
- package/2x/cjs/components/dialog/dialog.js +24 -13
- package/2x/cjs/components/dropdown/dropdown.css +1 -1
- package/2x/cjs/components/error-block/images/busy.d.ts +1 -0
- package/2x/cjs/components/error-block/images/default.d.ts +1 -0
- package/2x/cjs/components/error-block/images/disconnected.d.ts +1 -0
- package/2x/cjs/components/error-block/images/empty.d.ts +1 -0
- package/2x/cjs/components/form/form-item.js +1 -4
- package/2x/cjs/components/image/broken-image-icon.d.ts +1 -0
- package/2x/cjs/components/image/broken-image-icon.js +21 -0
- package/2x/cjs/components/image/image-icon.d.ts +1 -0
- package/2x/cjs/components/image/image-icon.js +21 -0
- package/2x/cjs/components/image/image.css +4 -2
- package/2x/cjs/components/image/image.d.ts +2 -1
- package/2x/cjs/components/image/image.js +10 -6
- package/2x/cjs/components/image-uploader/image-uploader.js +1 -4
- 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/infinite-scroll/infinite-scroll.js +8 -6
- package/2x/cjs/components/mask/mask.js +9 -7
- package/2x/cjs/components/modal/modal.d.ts +4 -1
- package/2x/cjs/components/modal/modal.js +24 -11
- package/2x/cjs/components/popover/popover.css +1 -0
- package/2x/cjs/components/popup/popup.d.ts +2 -1
- package/2x/cjs/components/search-bar/search-bar.d.ts +1 -1
- package/2x/cjs/components/search-bar/search-bar.js +5 -8
- package/2x/cjs/components/side-bar/side-bar.d.ts +2 -1
- package/2x/cjs/components/swiper/index.d.ts +1 -1
- package/2x/cjs/components/swiper/swiper.d.ts +1 -1
- package/2x/cjs/components/tabs/tabs.css +4 -3
- package/2x/cjs/components/tabs/tabs.d.ts +1 -1
- package/2x/cjs/components/text-area/text-area.js +2 -1
- package/2x/cjs/components/toast/toast.css +1 -1
- package/2x/cjs/components/toast/toast.d.ts +2 -1
- package/2x/cjs/locales/fr-FR.d.ts +106 -0
- package/2x/cjs/locales/fr-FR.js +119 -0
- package/2x/cjs/utils/get-scroll-parent.js +1 -1
- package/2x/cjs/utils/render.js +14 -2
- 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/badge/badge.d.ts +1 -1
- package/2x/es/components/badge/badge.js +1 -1
- package/2x/es/components/badge/index.d.ts +1 -1
- package/2x/es/components/button/button.d.ts +6 -4
- package/2x/es/components/button/button.js +5 -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 +2 -2
- package/2x/es/components/dialog/dialog.d.ts +4 -1
- package/2x/es/components/dialog/dialog.js +23 -14
- package/2x/es/components/dropdown/dropdown.css +1 -1
- package/2x/es/components/error-block/images/busy.d.ts +1 -0
- package/2x/es/components/error-block/images/default.d.ts +1 -0
- package/2x/es/components/error-block/images/disconnected.d.ts +1 -0
- package/2x/es/components/error-block/images/empty.d.ts +1 -0
- package/2x/es/components/form/form-item.js +1 -4
- package/2x/es/components/image/broken-image-icon.d.ts +1 -0
- package/2x/es/components/image/broken-image-icon.js +9 -0
- package/2x/es/components/image/image-icon.d.ts +1 -0
- package/2x/es/components/image/image-icon.js +9 -0
- package/2x/es/components/image/image.css +4 -2
- package/2x/es/components/image/image.d.ts +2 -1
- package/2x/es/components/image/image.js +8 -5
- package/2x/es/components/image-uploader/image-uploader.js +2 -5
- 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/infinite-scroll/infinite-scroll.js +8 -6
- package/2x/es/components/mask/mask.js +10 -8
- package/2x/es/components/modal/modal.d.ts +4 -1
- package/2x/es/components/modal/modal.js +23 -12
- package/2x/es/components/popover/popover.css +1 -0
- package/2x/es/components/popup/popup.d.ts +2 -1
- package/2x/es/components/search-bar/search-bar.d.ts +1 -1
- package/2x/es/components/search-bar/search-bar.js +5 -8
- package/2x/es/components/side-bar/side-bar.d.ts +2 -1
- package/2x/es/components/swiper/index.d.ts +1 -1
- package/2x/es/components/swiper/swiper.d.ts +1 -1
- package/2x/es/components/tabs/tabs.css +4 -3
- package/2x/es/components/tabs/tabs.d.ts +1 -1
- package/2x/es/components/text-area/text-area.js +2 -1
- package/2x/es/components/toast/toast.css +1 -1
- package/2x/es/components/toast/toast.d.ts +2 -1
- package/2x/es/locales/fr-FR.d.ts +106 -0
- package/2x/es/locales/fr-FR.js +109 -0
- package/2x/es/utils/get-scroll-parent.js +1 -1
- package/2x/es/utils/render.js +14 -2
- 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 +6 -11
- package/README.md +10 -8
- package/bundle/antd-mobile.cjs.js +293 -229
- package/bundle/antd-mobile.es.js +295 -231
- package/bundle/style.css +110 -86
- package/cjs/components/action-sheet/action-sheet.css +19 -7
- package/cjs/components/action-sheet/action-sheet.js +8 -16
- package/cjs/components/badge/badge.d.ts +1 -1
- package/cjs/components/badge/badge.js +3 -1
- package/cjs/components/badge/index.d.ts +1 -1
- package/cjs/components/button/button.d.ts +6 -4
- package/cjs/components/button/button.js +5 -1
- package/cjs/components/calendar/calendar.css +3 -0
- package/cjs/components/calendar/calendar.d.ts +1 -0
- package/cjs/components/calendar/calendar.js +2 -2
- package/cjs/components/dialog/dialog.d.ts +4 -1
- package/cjs/components/dialog/dialog.js +24 -13
- package/cjs/components/dropdown/dropdown.css +1 -1
- package/cjs/components/error-block/images/busy.d.ts +1 -0
- package/cjs/components/error-block/images/default.d.ts +1 -0
- package/cjs/components/error-block/images/disconnected.d.ts +1 -0
- package/cjs/components/error-block/images/empty.d.ts +1 -0
- package/cjs/components/form/form-item.js +1 -4
- package/cjs/components/image/broken-image-icon.d.ts +1 -0
- package/cjs/components/image/broken-image-icon.js +21 -0
- package/cjs/components/image/image-icon.d.ts +1 -0
- package/cjs/components/image/image-icon.js +21 -0
- package/cjs/components/image/image.css +4 -2
- package/cjs/components/image/image.d.ts +2 -1
- package/cjs/components/image/image.js +10 -6
- package/cjs/components/image-uploader/image-uploader.js +1 -4
- 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/infinite-scroll/infinite-scroll.js +8 -6
- package/cjs/components/mask/mask.js +9 -7
- package/cjs/components/modal/modal.d.ts +4 -1
- package/cjs/components/modal/modal.js +24 -11
- package/cjs/components/popover/popover.css +1 -0
- package/cjs/components/popup/popup.d.ts +2 -1
- package/cjs/components/search-bar/search-bar.d.ts +1 -1
- package/cjs/components/search-bar/search-bar.js +5 -8
- package/cjs/components/side-bar/side-bar.d.ts +2 -1
- package/cjs/components/swiper/index.d.ts +1 -1
- package/cjs/components/swiper/swiper.d.ts +1 -1
- package/cjs/components/tabs/tabs.css +4 -3
- package/cjs/components/tabs/tabs.d.ts +1 -1
- package/cjs/components/text-area/text-area.js +2 -1
- package/cjs/components/toast/toast.css +1 -1
- package/cjs/components/toast/toast.d.ts +2 -1
- package/cjs/locales/fr-FR.d.ts +106 -0
- package/cjs/locales/fr-FR.js +119 -0
- package/cjs/utils/get-scroll-parent.js +1 -1
- package/cjs/utils/render.js +14 -2
- 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/badge/badge.d.ts +1 -1
- package/es/components/badge/badge.js +1 -1
- package/es/components/badge/index.d.ts +1 -1
- package/es/components/button/button.d.ts +6 -4
- package/es/components/button/button.js +5 -1
- package/es/components/calendar/calendar.css +3 -0
- package/es/components/calendar/calendar.d.ts +1 -0
- package/es/components/calendar/calendar.js +2 -2
- package/es/components/dialog/dialog.d.ts +4 -1
- package/es/components/dialog/dialog.js +23 -14
- package/es/components/dropdown/dropdown.css +1 -1
- package/es/components/error-block/images/busy.d.ts +1 -0
- package/es/components/error-block/images/default.d.ts +1 -0
- package/es/components/error-block/images/disconnected.d.ts +1 -0
- package/es/components/error-block/images/empty.d.ts +1 -0
- package/es/components/form/form-item.js +1 -4
- package/es/components/image/broken-image-icon.d.ts +1 -0
- package/es/components/image/broken-image-icon.js +9 -0
- package/es/components/image/image-icon.d.ts +1 -0
- package/es/components/image/image-icon.js +9 -0
- package/es/components/image/image.css +4 -2
- package/es/components/image/image.d.ts +2 -1
- package/es/components/image/image.js +8 -5
- package/es/components/image-uploader/image-uploader.js +2 -5
- 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/infinite-scroll/infinite-scroll.js +8 -6
- package/es/components/mask/mask.js +10 -8
- package/es/components/modal/modal.d.ts +4 -1
- package/es/components/modal/modal.js +23 -12
- package/es/components/popover/popover.css +1 -0
- package/es/components/popup/popup.d.ts +2 -1
- package/es/components/search-bar/search-bar.d.ts +1 -1
- package/es/components/search-bar/search-bar.js +5 -8
- package/es/components/side-bar/side-bar.d.ts +2 -1
- package/es/components/swiper/index.d.ts +1 -1
- package/es/components/swiper/swiper.d.ts +1 -1
- package/es/components/tabs/tabs.css +4 -3
- package/es/components/tabs/tabs.d.ts +1 -1
- package/es/components/text-area/text-area.js +2 -1
- package/es/components/toast/toast.css +1 -1
- package/es/components/toast/toast.d.ts +2 -1
- package/es/locales/fr-FR.d.ts +106 -0
- package/es/locales/fr-FR.js +109 -0
- package/es/utils/get-scroll-parent.js +1 -1
- package/es/utils/render.js +14 -2
- package/es/utils/use-inner-visible.d.ts +1 -0
- package/es/utils/use-inner-visible.js +9 -0
- package/package.json +6 -11
- package/umd/antd-mobile.js +1 -1
|
@@ -5,7 +5,7 @@ import { mergeProps } from '../../utils/with-default-props';
|
|
|
5
5
|
import ImageViewer from '../image-viewer';
|
|
6
6
|
import PreviewItem from './preview-item';
|
|
7
7
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
8
|
-
import { useIsomorphicLayoutEffect,
|
|
8
|
+
import { useIsomorphicLayoutEffect, useUnmount } from 'ahooks';
|
|
9
9
|
import Space from '../space';
|
|
10
10
|
import { withNativeProps } from '../../utils/native-props';
|
|
11
11
|
import { useConfig } from '../config-provider';
|
|
@@ -28,9 +28,6 @@ export const ImageUploader = p => {
|
|
|
28
28
|
} = useConfig();
|
|
29
29
|
const props = mergeProps(defaultProps, p);
|
|
30
30
|
const [value, setValue] = usePropsValue(props);
|
|
31
|
-
const updateValue = useMemoizedFn(updater => {
|
|
32
|
-
setValue(updater(value));
|
|
33
|
-
});
|
|
34
31
|
const [tasks, setTasks] = useState([]);
|
|
35
32
|
useIsomorphicLayoutEffect(() => {
|
|
36
33
|
setTasks(prev => prev.filter(task => {
|
|
@@ -109,7 +106,7 @@ export const ImageUploader = p => {
|
|
|
109
106
|
return task;
|
|
110
107
|
});
|
|
111
108
|
});
|
|
112
|
-
|
|
109
|
+
setValue(prev => {
|
|
113
110
|
const newVal = Object.assign({}, result);
|
|
114
111
|
return [...prev, newVal];
|
|
115
112
|
});
|
|
@@ -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>;
|
|
@@ -27,9 +27,11 @@ export const InfiniteScroll = p => {
|
|
|
27
27
|
threshold: 250
|
|
28
28
|
}, p);
|
|
29
29
|
const doLoadMore = useLockFn(() => props.loadMore());
|
|
30
|
-
const elementRef = useRef(null);
|
|
30
|
+
const elementRef = useRef(null); // Prevent duplicated trigger of `check` function
|
|
31
|
+
|
|
31
32
|
const [flag, setFlag] = useState({});
|
|
32
33
|
const nextFlagRef = useRef(flag);
|
|
34
|
+
const [scrollParent, setScrollParent] = useState();
|
|
33
35
|
const check = useMemoizedFn(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
36
|
if (nextFlagRef.current !== flag) return;
|
|
35
37
|
if (!props.hasMore) return;
|
|
@@ -37,6 +39,7 @@ export const InfiniteScroll = p => {
|
|
|
37
39
|
if (!element) return;
|
|
38
40
|
if (!element.offsetParent) return;
|
|
39
41
|
const parent = getScrollParent(element);
|
|
42
|
+
setScrollParent(parent);
|
|
40
43
|
if (!parent) return;
|
|
41
44
|
const rect = element.getBoundingClientRect();
|
|
42
45
|
const elementTop = rect.top;
|
|
@@ -56,18 +59,17 @@ export const InfiniteScroll = p => {
|
|
|
56
59
|
useEffect(() => {
|
|
57
60
|
const element = elementRef.current;
|
|
58
61
|
if (!element) return;
|
|
59
|
-
|
|
60
|
-
if (!parent) return;
|
|
62
|
+
if (!scrollParent) return;
|
|
61
63
|
|
|
62
64
|
function onScroll() {
|
|
63
65
|
check();
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
|
|
68
|
+
scrollParent.addEventListener('scroll', onScroll);
|
|
67
69
|
return () => {
|
|
68
|
-
|
|
70
|
+
scrollParent.removeEventListener('scroll', onScroll);
|
|
69
71
|
};
|
|
70
|
-
}, []);
|
|
72
|
+
}, [scrollParent]);
|
|
71
73
|
return withNativeProps(props, React.createElement("div", {
|
|
72
74
|
className: classPrefix,
|
|
73
75
|
ref: elementRef
|
|
@@ -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
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { FC, ReactNode } from 'react';
|
|
2
|
+
import type { MaskProps } from '../mask';
|
|
2
3
|
import { Action } from './modal-action-button';
|
|
3
4
|
import { GetContainer } from '../../utils/render-to-container';
|
|
4
5
|
import { PropagationEvent } from '../../utils/with-stop-propagation';
|
|
@@ -19,10 +20,12 @@ export declare type ModalProps = {
|
|
|
19
20
|
getContainer?: GetContainer;
|
|
20
21
|
bodyStyle?: React.CSSProperties;
|
|
21
22
|
bodyClassName?: string;
|
|
22
|
-
maskStyle?:
|
|
23
|
+
maskStyle?: MaskProps['style'];
|
|
23
24
|
maskClassName?: string;
|
|
24
25
|
stopPropagation?: PropagationEvent[];
|
|
25
26
|
showCloseButton?: boolean;
|
|
26
27
|
disableBodyScroll?: boolean;
|
|
28
|
+
destroyOnClose?: boolean;
|
|
29
|
+
forceRender?: boolean;
|
|
27
30
|
} & NativeProps;
|
|
28
31
|
export declare const Modal: FC<ModalProps>;
|
|
@@ -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 = '') {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
|
+
import type { MaskProps } from '../mask';
|
|
3
4
|
import { GetContainer } from '../../utils/render-to-container';
|
|
4
5
|
import { PropagationEvent } from '../../utils/with-stop-propagation';
|
|
5
6
|
export declare type PopupProps = {
|
|
@@ -15,7 +16,7 @@ export declare type PopupProps = {
|
|
|
15
16
|
bodyClassName?: string;
|
|
16
17
|
bodyStyle?: React.CSSProperties;
|
|
17
18
|
maskClassName?: string;
|
|
18
|
-
maskStyle?:
|
|
19
|
+
maskStyle?: MaskProps['style'];
|
|
19
20
|
onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
20
21
|
stopPropagation?: PropagationEvent[];
|
|
21
22
|
children?: React.ReactNode;
|
|
@@ -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>>;
|
|
@@ -52,7 +52,7 @@ export const SearchBar = forwardRef((p, ref) => {
|
|
|
52
52
|
}));
|
|
53
53
|
|
|
54
54
|
const renderCancelButton = () => {
|
|
55
|
-
let isShowCancel
|
|
55
|
+
let isShowCancel;
|
|
56
56
|
|
|
57
57
|
if (typeof props.showCancelButton === 'function') {
|
|
58
58
|
isShowCancel = props.showCancelButton(hasFocus, value);
|
|
@@ -61,13 +61,7 @@ export const SearchBar = forwardRef((p, ref) => {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
return isShowCancel && React.createElement("div", {
|
|
64
|
-
className: `${classPrefix}-suffix
|
|
65
|
-
onMouseDown: e => {
|
|
66
|
-
e.preventDefault();
|
|
67
|
-
},
|
|
68
|
-
onTouchStart: e => {
|
|
69
|
-
e.preventDefault();
|
|
70
|
-
}
|
|
64
|
+
className: `${classPrefix}-suffix`
|
|
71
65
|
}, React.createElement(Button, {
|
|
72
66
|
fill: 'none',
|
|
73
67
|
className: `${classPrefix}-cancel-button`,
|
|
@@ -80,6 +74,9 @@ export const SearchBar = forwardRef((p, ref) => {
|
|
|
80
74
|
|
|
81
75
|
(_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.blur();
|
|
82
76
|
(_c = props.onCancel) === null || _c === void 0 ? void 0 : _c.call(props);
|
|
77
|
+
},
|
|
78
|
+
onMouseDown: e => {
|
|
79
|
+
e.preventDefault();
|
|
83
80
|
}
|
|
84
81
|
}, props.cancelText));
|
|
85
82
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { BadgeProps } from '../badge';
|
|
3
4
|
import { NativeProps } from '../../utils/native-props';
|
|
4
5
|
export declare type SideBarItemProps = {
|
|
5
6
|
title?: ReactNode;
|
|
6
7
|
disabled?: boolean;
|
|
7
|
-
badge?:
|
|
8
|
+
badge?: BadgeProps['content'];
|
|
8
9
|
} & NativeProps;
|
|
9
10
|
export declare const SideBarItem: FC<SideBarItemProps>;
|
|
10
11
|
export declare type SideBarProps = {
|
|
@@ -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>>;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
--content-padding: 24px;
|
|
4
4
|
--active-line-height: 4px;
|
|
5
5
|
--active-line-border-radius: var(--active-line-height);
|
|
6
|
+
--active-line-color: var(--adm-color-primary);
|
|
7
|
+
--active-title-color: var(--adm-color-primary);
|
|
6
8
|
position: relative;
|
|
7
9
|
min-width: 0;
|
|
8
10
|
}
|
|
@@ -45,7 +47,7 @@
|
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
.adm-tabs-tab-active {
|
|
48
|
-
color: var(--
|
|
50
|
+
color: var(--active-title-color);
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
.adm-tabs-tab-disabled {
|
|
@@ -57,8 +59,7 @@
|
|
|
57
59
|
position: absolute;
|
|
58
60
|
bottom: 0;
|
|
59
61
|
height: var(--active-line-height);
|
|
60
|
-
|
|
61
|
-
background: var(--adm-color-primary);
|
|
62
|
+
background: var(--active-line-color);
|
|
62
63
|
border-radius: var(--active-line-border-radius);
|
|
63
64
|
}
|
|
64
65
|
|
|
@@ -15,5 +15,5 @@ export declare type TabsProps = {
|
|
|
15
15
|
stretch?: boolean;
|
|
16
16
|
onChange?: (key: string) => void;
|
|
17
17
|
children?: React.ReactNode;
|
|
18
|
-
} & NativeProps<'--fixed-active-line-width' | '--active-line-height' | '--active-line-border-radius' | '--title-font-size' | '--content-padding'>;
|
|
18
|
+
} & NativeProps<'--fixed-active-line-width' | '--active-line-height' | '--active-line-border-radius' | '--title-font-size' | '--content-padding' | '--active-title-color' | '--active-line-color'>;
|
|
19
19
|
export declare const Tabs: FC<TabsProps>;
|
|
@@ -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);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
+
import type { MaskProps } from '../mask';
|
|
2
3
|
import { PropagationEvent } from '../../utils/with-stop-propagation';
|
|
3
4
|
import { GetContainer } from '../../utils/render-to-container';
|
|
4
5
|
export interface ToastProps {
|
|
5
6
|
afterClose?: () => void;
|
|
6
|
-
maskStyle?:
|
|
7
|
+
maskStyle?: MaskProps['style'];
|
|
7
8
|
maskClassName?: string;
|
|
8
9
|
maskClickable?: boolean;
|
|
9
10
|
content?: ReactNode;
|