antd-mobile 5.41.0-alpha.2 → 5.41.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2x/bundle/antd-mobile.cjs.development.js +164 -128
- package/2x/bundle/antd-mobile.cjs.js +7 -7
- package/2x/bundle/antd-mobile.es.development.js +164 -128
- package/2x/bundle/antd-mobile.es.js +3988 -3969
- package/2x/bundle/antd-mobile.umd.development.js +164 -128
- package/2x/bundle/antd-mobile.umd.js +7 -7
- package/2x/bundle/style.css +10 -6
- package/2x/cjs/components/avatar/avatar.d.ts +3 -1
- package/2x/cjs/components/avatar/avatar.js +4 -2
- package/2x/cjs/components/calendar/calendar.js +4 -4
- package/2x/cjs/components/image/image.d.ts +1 -1
- package/2x/cjs/components/image/image.js +5 -5
- package/2x/cjs/components/image-viewer/image-viewer.d.ts +7 -4
- package/2x/cjs/components/image-viewer/index.d.ts +2 -1
- package/2x/cjs/components/image-viewer/methods.js +1 -1
- package/2x/cjs/components/image-viewer/slide.d.ts +3 -2
- package/2x/cjs/components/image-viewer/slide.js +2 -1
- package/2x/cjs/components/image-viewer/slides.d.ts +3 -2
- package/2x/cjs/components/swiper/swiper.d.ts +3 -3
- package/2x/cjs/components/swiper/swiper.js +47 -38
- package/2x/cjs/components/virtual-input/virtual-input.css +10 -6
- package/2x/es/components/avatar/avatar.d.ts +3 -1
- package/2x/es/components/avatar/avatar.js +4 -2
- package/2x/es/components/calendar/calendar.js +4 -4
- package/2x/es/components/image/image.d.ts +1 -1
- package/2x/es/components/image/image.js +6 -6
- package/2x/es/components/image-viewer/image-viewer.d.ts +7 -4
- package/2x/es/components/image-viewer/index.d.ts +2 -1
- package/2x/es/components/image-viewer/methods.js +1 -1
- package/2x/es/components/image-viewer/slide.d.ts +3 -2
- package/2x/es/components/image-viewer/slide.js +2 -1
- package/2x/es/components/image-viewer/slides.d.ts +3 -2
- package/2x/es/components/swiper/swiper.d.ts +3 -3
- package/2x/es/components/swiper/swiper.js +28 -19
- package/2x/es/components/virtual-input/virtual-input.css +10 -6
- package/2x/package.json +1 -1
- package/bundle/antd-mobile.cjs.development.js +164 -128
- package/bundle/antd-mobile.cjs.js +7 -7
- package/bundle/antd-mobile.compatible.umd.js +1 -1
- package/bundle/antd-mobile.es.development.js +164 -128
- package/bundle/antd-mobile.es.js +3988 -3969
- package/bundle/antd-mobile.umd.development.js +164 -128
- package/bundle/antd-mobile.umd.js +7 -7
- package/bundle/style.css +1 -1
- package/cjs/components/avatar/avatar.d.ts +3 -1
- package/cjs/components/avatar/avatar.js +4 -2
- package/cjs/components/calendar/calendar.js +4 -4
- package/cjs/components/image/image.d.ts +1 -1
- package/cjs/components/image/image.js +5 -5
- package/cjs/components/image-viewer/image-viewer.d.ts +7 -4
- package/cjs/components/image-viewer/index.d.ts +2 -1
- package/cjs/components/image-viewer/methods.js +1 -1
- package/cjs/components/image-viewer/slide.d.ts +3 -2
- package/cjs/components/image-viewer/slide.js +2 -1
- package/cjs/components/image-viewer/slides.d.ts +3 -2
- package/cjs/components/swiper/swiper.d.ts +3 -3
- package/cjs/components/swiper/swiper.js +47 -38
- package/cjs/components/virtual-input/virtual-input.css +10 -6
- package/es/components/avatar/avatar.d.ts +3 -1
- package/es/components/avatar/avatar.js +4 -2
- package/es/components/calendar/calendar.js +4 -4
- package/es/components/image/image.d.ts +1 -1
- package/es/components/image/image.js +6 -6
- package/es/components/image-viewer/image-viewer.d.ts +7 -4
- package/es/components/image-viewer/index.d.ts +2 -1
- package/es/components/image-viewer/methods.js +1 -1
- package/es/components/image-viewer/slide.d.ts +3 -2
- package/es/components/image-viewer/slide.js +2 -1
- package/es/components/image-viewer/slides.d.ts +3 -2
- package/es/components/swiper/swiper.d.ts +3 -3
- package/es/components/swiper/swiper.js +28 -19
- package/es/components/virtual-input/virtual-input.css +10 -6
- package/package.json +1 -1
- package/umd/antd-mobile.js +1 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { FC, ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
2
3
|
import { NativeProps } from '../../utils/native-props';
|
|
3
4
|
import { ImageProps } from '../image';
|
|
4
5
|
export declare type AvatarProps = {
|
|
5
6
|
src: string;
|
|
6
7
|
fallback?: ReactNode;
|
|
7
8
|
fit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
|
|
8
|
-
|
|
9
|
+
onClick?: (event: React.MouseEvent<HTMLDivElement | HTMLImageElement, Event>) => void;
|
|
10
|
+
} & Pick<ImageProps, 'alt' | 'lazy' | 'onError' | 'onLoad'> & NativeProps<'--size' | '--border-radius'>;
|
|
9
11
|
export declare const Avatar: FC<AvatarProps>;
|
|
@@ -7,8 +7,8 @@ exports.Avatar = void 0;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _nativeProps = require("../../utils/native-props");
|
|
9
9
|
var _withDefaultProps = require("../../utils/with-default-props");
|
|
10
|
-
var _fallback = require("./fallback");
|
|
11
10
|
var _image = _interopRequireDefault(require("../image"));
|
|
11
|
+
var _fallback = require("./fallback");
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
const classPrefix = 'adm-avatar';
|
|
14
14
|
const defaultProps = {
|
|
@@ -16,10 +16,12 @@ const defaultProps = {
|
|
|
16
16
|
fit: 'cover'
|
|
17
17
|
};
|
|
18
18
|
const Avatar = p => {
|
|
19
|
+
var _a;
|
|
19
20
|
const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
|
|
21
|
+
const mergedSrc = ((_a = props.src) === null || _a === void 0 ? void 0 : _a.trim()) || undefined;
|
|
20
22
|
return (0, _nativeProps.withNativeProps)(props, _react.default.createElement(_image.default, {
|
|
21
23
|
className: classPrefix,
|
|
22
|
-
src:
|
|
24
|
+
src: mergedSrc,
|
|
23
25
|
fallback: props.fallback,
|
|
24
26
|
placeholder: props.fallback,
|
|
25
27
|
alt: props.alt,
|
|
@@ -96,12 +96,12 @@ const Calendar = (0, _react.forwardRef)((p, ref) => {
|
|
|
96
96
|
};
|
|
97
97
|
const header = _react.default.createElement("div", {
|
|
98
98
|
className: `${classPrefix}-header`
|
|
99
|
-
}, _react.default.createElement("a", {
|
|
99
|
+
}, props.prevYearButton !== null && _react.default.createElement("a", {
|
|
100
100
|
className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-year`,
|
|
101
101
|
onClick: () => {
|
|
102
102
|
handlePageChange('subtract', 1, 'year');
|
|
103
103
|
}
|
|
104
|
-
}, props.prevYearButton), _react.default.createElement("a", {
|
|
104
|
+
}, props.prevYearButton), props.prevMonthButton !== null && _react.default.createElement("a", {
|
|
105
105
|
className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-month`,
|
|
106
106
|
onClick: () => {
|
|
107
107
|
handlePageChange('subtract', 1, 'month');
|
|
@@ -111,12 +111,12 @@ const Calendar = (0, _react.forwardRef)((p, ref) => {
|
|
|
111
111
|
}, (0, _replaceMessage.replaceMessage)(locale.Calendar.yearAndMonth, {
|
|
112
112
|
year: current.year().toString(),
|
|
113
113
|
month: (current.month() + 1).toString()
|
|
114
|
-
})), _react.default.createElement("a", {
|
|
114
|
+
})), props.nextMonthButton !== null && _react.default.createElement("a", {
|
|
115
115
|
className: (0, _classnames.default)(`${classPrefix}-arrow-button`, `${classPrefix}-arrow-button-right`, `${classPrefix}-arrow-button-right-month`),
|
|
116
116
|
onClick: () => {
|
|
117
117
|
handlePageChange('add', 1, 'month');
|
|
118
118
|
}
|
|
119
|
-
}, props.nextMonthButton), _react.default.createElement("a", {
|
|
119
|
+
}, props.nextMonthButton), props.nextYearButton !== null && _react.default.createElement("a", {
|
|
120
120
|
className: (0, _classnames.default)(`${classPrefix}-arrow-button`, `${classPrefix}-arrow-button-right`, `${classPrefix}-arrow-button-right-year`),
|
|
121
121
|
onClick: () => {
|
|
122
122
|
handlePageChange('add', 1, 'year');
|
|
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Image = void 0;
|
|
7
|
-
var _withDefaultProps = require("../../utils/with-default-props");
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _nativeProps = require("../../utils/native-props");
|
|
10
8
|
var _stagedComponents = require("staged-components");
|
|
9
|
+
var _nativeProps = require("../../utils/native-props");
|
|
11
10
|
var _toCssLength = require("../../utils/to-css-length");
|
|
12
|
-
var _lazyDetector = require("./lazy-detector");
|
|
13
11
|
var _useIsomorphicUpdateLayoutEffect = require("../../utils/use-isomorphic-update-layout-effect");
|
|
14
|
-
var
|
|
12
|
+
var _withDefaultProps = require("../../utils/with-default-props");
|
|
15
13
|
var _brokenImageIcon = require("./broken-image-icon");
|
|
14
|
+
var _imageIcon = require("./image-icon");
|
|
15
|
+
var _lazyDetector = require("./lazy-detector");
|
|
16
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
17
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
18
18
|
const classPrefix = `adm-image`;
|
|
@@ -50,7 +50,7 @@ const Image = (0, _stagedComponents.staged)(p => {
|
|
|
50
50
|
}
|
|
51
51
|
}, []);
|
|
52
52
|
function renderInner() {
|
|
53
|
-
if (failed) {
|
|
53
|
+
if (failed || src === undefined && !srcSet) {
|
|
54
54
|
return _react.default.createElement(_react.default.Fragment, null, props.fallback);
|
|
55
55
|
}
|
|
56
56
|
const img = _react.default.createElement("img", {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FC, ReactNode } from 'react';
|
|
1
|
+
import type { FC, ReactNode, RefObject } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { GetContainer } from '../../utils/render-to-container';
|
|
4
4
|
import { SlidesRef } from './slides';
|
|
@@ -10,7 +10,8 @@ export declare type ImageViewerProps = {
|
|
|
10
10
|
onClose?: () => void;
|
|
11
11
|
afterClose?: () => void;
|
|
12
12
|
renderFooter?: (image: string) => ReactNode;
|
|
13
|
-
imageRender?: (image: string, { index }: {
|
|
13
|
+
imageRender?: (image: string, { ref, index }: {
|
|
14
|
+
ref: RefObject<HTMLImageElement>;
|
|
14
15
|
index: number;
|
|
15
16
|
}) => ReactNode;
|
|
16
17
|
classNames?: {
|
|
@@ -25,7 +26,8 @@ export declare type MultiImageViewerProps = Omit<ImageViewerProps, 'image' | 're
|
|
|
25
26
|
defaultIndex?: number;
|
|
26
27
|
onIndexChange?: (index: number) => void;
|
|
27
28
|
renderFooter?: (image: string, index: number) => ReactNode;
|
|
28
|
-
imageRender?: (image: string, { index }: {
|
|
29
|
+
imageRender?: (image: string, { ref, index }: {
|
|
30
|
+
ref: RefObject<HTMLImageElement>;
|
|
29
31
|
index: number;
|
|
30
32
|
}) => ReactNode;
|
|
31
33
|
};
|
|
@@ -34,7 +36,8 @@ export declare const MultiImageViewer: React.ForwardRefExoticComponent<Omit<Imag
|
|
|
34
36
|
defaultIndex?: number | undefined;
|
|
35
37
|
onIndexChange?: ((index: number) => void) | undefined;
|
|
36
38
|
renderFooter?: ((image: string, index: number) => ReactNode) | undefined;
|
|
37
|
-
imageRender?: ((image: string, { index }: {
|
|
39
|
+
imageRender?: ((image: string, { ref, index }: {
|
|
40
|
+
ref: RefObject<HTMLImageElement>;
|
|
38
41
|
index: number;
|
|
39
42
|
}) => ReactNode) | undefined;
|
|
40
43
|
} & React.RefAttributes<SlidesRef>>;
|
|
@@ -8,7 +8,8 @@ declare const _default: import("react").FC<import("./image-viewer").ImageViewerP
|
|
|
8
8
|
defaultIndex?: number | undefined;
|
|
9
9
|
onIndexChange?: ((index: number) => void) | undefined;
|
|
10
10
|
renderFooter?: ((image: string, index: number) => import("react").ReactNode) | undefined;
|
|
11
|
-
imageRender?: ((image: string, { index }: {
|
|
11
|
+
imageRender?: ((image: string, { ref, index }: {
|
|
12
|
+
ref: import("react").RefObject<HTMLImageElement>;
|
|
12
13
|
index: number;
|
|
13
14
|
}) => import("react").ReactNode) | undefined;
|
|
14
15
|
} & import("react").RefAttributes<import("./slides").SlidesRef>> & {
|
|
@@ -7,8 +7,8 @@ exports.clearImageViewer = clearImageViewer;
|
|
|
7
7
|
exports.showImageViewer = showImageViewer;
|
|
8
8
|
exports.showMultiImageViewer = showMultiImageViewer;
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _imageViewer = require("./image-viewer");
|
|
11
10
|
var _renderImperatively = require("../../utils/render-imperatively");
|
|
11
|
+
var _imageViewer = require("./image-viewer");
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
const handlerSet = new Set();
|
|
14
14
|
function showImageViewer(props) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { FC, MutableRefObject, ReactNode } from 'react';
|
|
1
|
+
import type { FC, MutableRefObject, ReactNode, RefObject } from 'react';
|
|
2
2
|
declare type Props = {
|
|
3
3
|
image: string;
|
|
4
4
|
maxZoom: number | 'auto';
|
|
5
5
|
onTap?: () => void;
|
|
6
6
|
onZoomChange?: (zoom: number) => void;
|
|
7
7
|
dragLockRef?: MutableRefObject<boolean>;
|
|
8
|
-
imageRender?: (image: string, { index }: {
|
|
8
|
+
imageRender?: (image: string, { ref, index }: {
|
|
9
|
+
ref: RefObject<HTMLImageElement>;
|
|
9
10
|
index: number;
|
|
10
11
|
}) => ReactNode;
|
|
11
12
|
index?: number;
|
|
@@ -230,7 +230,8 @@ const Slide = props => {
|
|
|
230
230
|
}
|
|
231
231
|
});
|
|
232
232
|
const customRendering = typeof imageRender === 'function' && imageRender(props.image, {
|
|
233
|
-
|
|
233
|
+
ref: imgRef,
|
|
234
|
+
index: index !== null && index !== void 0 ? index : 0
|
|
234
235
|
});
|
|
235
236
|
return _react.default.createElement("div", {
|
|
236
237
|
className: `${classPrefix}-slide`
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
1
|
+
import React, { ReactNode, RefObject } from 'react';
|
|
2
2
|
export declare type SlidesType = {
|
|
3
3
|
images: string[];
|
|
4
4
|
onTap?: () => void;
|
|
5
5
|
maxZoom: number;
|
|
6
6
|
defaultIndex: number;
|
|
7
7
|
onIndexChange?: (index: number) => void;
|
|
8
|
-
imageRender?: (image: string, { index }: {
|
|
8
|
+
imageRender?: (image: string, { ref, index }: {
|
|
9
|
+
ref: RefObject<HTMLImageElement>;
|
|
9
10
|
index: number;
|
|
10
11
|
}) => ReactNode;
|
|
11
12
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import type { ReactNode, ReactElement } from 'react';
|
|
3
3
|
import { NativeProps } from '../../utils/native-props';
|
|
4
4
|
import { PageIndicatorProps } from '../page-indicator';
|
|
5
5
|
declare const eventToPropRecord: {
|
|
@@ -59,10 +59,10 @@ export declare const Swiper: React.ForwardRefExoticComponent<{
|
|
|
59
59
|
/**
|
|
60
60
|
* renderProps is only work when `total` used
|
|
61
61
|
*/
|
|
62
|
-
children?:
|
|
62
|
+
children?: ReactElement<any, string | React.JSXElementConstructor<any>> | ReactElement<any, string | React.JSXElementConstructor<any>>[] | ((index: number) => ReactElement) | undefined;
|
|
63
63
|
} & {
|
|
64
64
|
className?: string | undefined;
|
|
65
|
-
style?: (
|
|
65
|
+
style?: (CSSProperties & Partial<Record<"--width" | "--height" | "--border-radius" | "--track-padding", string>>) | undefined;
|
|
66
66
|
tabIndex?: number | undefined;
|
|
67
67
|
} & React.AriaAttributes & React.RefAttributes<SwiperRef>>;
|
|
68
68
|
export {};
|
|
@@ -4,23 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Swiper = void 0;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _nativeProps = require("../../utils/native-props");
|
|
9
|
-
var _withDefaultProps = require("../../utils/with-default-props");
|
|
10
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
var _swiperItem = require("./swiper-item");
|
|
12
|
-
var _devLog = require("../../utils/dev-log");
|
|
13
7
|
var _web = require("@react-spring/web");
|
|
14
|
-
var
|
|
15
|
-
var
|
|
8
|
+
var _react = require("@use-gesture/react");
|
|
9
|
+
var _ahooks = require("ahooks");
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
var _toArray = _interopRequireDefault(require("rc-util/lib/Children/toArray"));
|
|
12
|
+
var _react2 = _interopRequireWildcard(require("react"));
|
|
16
13
|
var _stagedComponents = require("staged-components");
|
|
17
|
-
var _useRefState = require("../../utils/use-ref-state");
|
|
18
14
|
var _bound = require("../../utils/bound");
|
|
19
|
-
var
|
|
15
|
+
var _devLog = require("../../utils/dev-log");
|
|
16
|
+
var _nativeProps = require("../../utils/native-props");
|
|
17
|
+
var _useRefState = require("../../utils/use-ref-state");
|
|
18
|
+
var _withDefaultProps = require("../../utils/with-default-props");
|
|
20
19
|
var _withFuncProps = require("../../utils/with-func-props");
|
|
21
|
-
|
|
20
|
+
var _pageIndicator = _interopRequireDefault(require("../page-indicator"));
|
|
21
|
+
var _swiperItem = require("./swiper-item");
|
|
22
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
23
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
25
|
const classPrefix = `adm-swiper`;
|
|
25
26
|
const eventToPropRecord = {
|
|
26
27
|
'mousedown': 'onMouseDown',
|
|
@@ -41,7 +42,7 @@ const defaultProps = {
|
|
|
41
42
|
stopPropagation: []
|
|
42
43
|
};
|
|
43
44
|
let currentUid;
|
|
44
|
-
const Swiper = (0,
|
|
45
|
+
const Swiper = (0, _react2.forwardRef)((0, _stagedComponents.staged)((p, ref) => {
|
|
45
46
|
const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
|
|
46
47
|
const {
|
|
47
48
|
direction,
|
|
@@ -49,8 +50,8 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
49
50
|
children,
|
|
50
51
|
indicator
|
|
51
52
|
} = props;
|
|
52
|
-
const [uid] = (0,
|
|
53
|
-
const timeoutRef = (0,
|
|
53
|
+
const [uid] = (0, _react2.useState)({});
|
|
54
|
+
const timeoutRef = (0, _react2.useRef)(null);
|
|
54
55
|
const isVertical = direction === 'vertical';
|
|
55
56
|
const slideRatio = props.slideSize / 100;
|
|
56
57
|
const offsetRatio = props.trackOffset / 100;
|
|
@@ -58,21 +59,22 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
58
59
|
validChildren,
|
|
59
60
|
count,
|
|
60
61
|
renderChildren
|
|
61
|
-
} = (0,
|
|
62
|
+
} = (0, _react2.useMemo)(() => {
|
|
62
63
|
let count = 0;
|
|
63
64
|
let renderChildren = undefined;
|
|
64
65
|
let validChildren = undefined;
|
|
65
66
|
if (typeof children === 'function') {
|
|
66
67
|
renderChildren = children;
|
|
67
68
|
} else {
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
const childrenArray = (0, _toArray.default)(children);
|
|
70
|
+
validChildren = childrenArray.filter(child => {
|
|
71
|
+
if (!_react2.default.isValidElement(child)) return null;
|
|
70
72
|
if (child.type !== _swiperItem.SwiperItem) {
|
|
71
73
|
(0, _devLog.devWarning)('Swiper', 'The children of `Swiper` must be `Swiper.Item` components.');
|
|
72
|
-
return
|
|
74
|
+
return false;
|
|
73
75
|
}
|
|
74
76
|
count++;
|
|
75
|
-
return
|
|
77
|
+
return true;
|
|
76
78
|
});
|
|
77
79
|
}
|
|
78
80
|
return {
|
|
@@ -91,7 +93,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
91
93
|
if (slideRatio * (mergedTotal - 1) < 1) {
|
|
92
94
|
loop = false;
|
|
93
95
|
}
|
|
94
|
-
const trackRef = (0,
|
|
96
|
+
const trackRef = (0, _react2.useRef)(null);
|
|
95
97
|
function getSlidePixels() {
|
|
96
98
|
const track = trackRef.current;
|
|
97
99
|
if (!track) return 0;
|
|
@@ -130,13 +132,13 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
130
132
|
});
|
|
131
133
|
}
|
|
132
134
|
}), [mergedTotal]);
|
|
133
|
-
const dragCancelRef = (0,
|
|
135
|
+
const dragCancelRef = (0, _react2.useRef)(null);
|
|
134
136
|
function forceCancelDrag() {
|
|
135
137
|
var _a;
|
|
136
138
|
(_a = dragCancelRef.current) === null || _a === void 0 ? void 0 : _a.call(dragCancelRef);
|
|
137
139
|
draggingRef.current = false;
|
|
138
140
|
}
|
|
139
|
-
const bind = (0,
|
|
141
|
+
const bind = (0, _react.useDrag)(state => {
|
|
140
142
|
dragCancelRef.current = state.cancel;
|
|
141
143
|
if (!state.intentional) return;
|
|
142
144
|
if (state.first && !currentUid) {
|
|
@@ -211,7 +213,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
211
213
|
function swipePrev() {
|
|
212
214
|
swipeTo(Math.round(position.get() / 100) - 1);
|
|
213
215
|
}
|
|
214
|
-
(0,
|
|
216
|
+
(0, _react2.useImperativeHandle)(ref, () => ({
|
|
215
217
|
swipeTo,
|
|
216
218
|
swipeNext,
|
|
217
219
|
swipePrev
|
|
@@ -236,7 +238,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
236
238
|
runTimeSwiper();
|
|
237
239
|
}, autoplayInterval);
|
|
238
240
|
};
|
|
239
|
-
(0,
|
|
241
|
+
(0, _react2.useEffect)(() => {
|
|
240
242
|
if (!autoplay || dragging) return;
|
|
241
243
|
runTimeSwiper();
|
|
242
244
|
return () => {
|
|
@@ -245,7 +247,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
245
247
|
}, [autoplay, autoplayInterval, dragging, mergedTotal]);
|
|
246
248
|
// ============================== Render ==============================
|
|
247
249
|
// Render Item
|
|
248
|
-
function renderItem(index, child) {
|
|
250
|
+
function renderItem(index, child, key) {
|
|
249
251
|
let itemStyle = {};
|
|
250
252
|
if (loop) {
|
|
251
253
|
itemStyle = {
|
|
@@ -259,15 +261,15 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
259
261
|
[isVertical ? 'top' : 'left']: `-${index * 100}%`
|
|
260
262
|
};
|
|
261
263
|
}
|
|
262
|
-
return
|
|
264
|
+
return _react2.default.createElement(_web.animated.div, {
|
|
263
265
|
className: (0, _classnames.default)(`${classPrefix}-slide`, {
|
|
264
266
|
[`${classPrefix}-slide-active`]: current === index
|
|
265
267
|
}),
|
|
266
268
|
style: itemStyle,
|
|
267
|
-
key: index
|
|
269
|
+
key: key !== null && key !== void 0 ? key : index
|
|
268
270
|
}, child);
|
|
269
271
|
}
|
|
270
|
-
|
|
272
|
+
const renderStableItems = () => {
|
|
271
273
|
if (renderChildren && total) {
|
|
272
274
|
const offsetCount = 2;
|
|
273
275
|
const startIndex = Math.max(current - offsetCount, 0);
|
|
@@ -276,25 +278,32 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
276
278
|
for (let index = startIndex; index <= endIndex; index += 1) {
|
|
277
279
|
items.push(renderItem(index, renderChildren(index)));
|
|
278
280
|
}
|
|
279
|
-
return
|
|
281
|
+
return _react2.default.createElement(_react2.default.Fragment, null, _react2.default.createElement("div", {
|
|
280
282
|
className: `${classPrefix}-slide-placeholder`,
|
|
281
283
|
style: {
|
|
282
284
|
[isVertical ? 'height' : 'width']: `${startIndex * 100}%`
|
|
283
285
|
}
|
|
284
286
|
}), items);
|
|
285
287
|
}
|
|
286
|
-
|
|
287
|
-
return
|
|
288
|
-
|
|
288
|
+
if (validChildren) {
|
|
289
|
+
return validChildren.map((child, index) => {
|
|
290
|
+
var _a;
|
|
291
|
+
return renderItem(index, child, (_a = child === null || child === void 0 ? void 0 : child.key) !== null && _a !== void 0 ? _a : index);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
return null;
|
|
295
|
+
};
|
|
296
|
+
function renderItems() {
|
|
297
|
+
return renderStableItems();
|
|
289
298
|
}
|
|
290
299
|
// Render Track Inner
|
|
291
300
|
function renderTrackInner() {
|
|
292
301
|
if (loop) {
|
|
293
|
-
return
|
|
302
|
+
return _react2.default.createElement("div", {
|
|
294
303
|
className: `${classPrefix}-track-inner`
|
|
295
304
|
}, renderItems());
|
|
296
305
|
} else {
|
|
297
|
-
return
|
|
306
|
+
return _react2.default.createElement(_web.animated.div, {
|
|
298
307
|
className: `${classPrefix}-track-inner`,
|
|
299
308
|
style: {
|
|
300
309
|
[isVertical ? 'y' : 'x']: position.to(position => `${-position}%`)
|
|
@@ -320,18 +329,18 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
320
329
|
if (typeof indicator === 'function') {
|
|
321
330
|
indicatorNode = indicator(mergedTotal, current);
|
|
322
331
|
} else if (indicator !== false) {
|
|
323
|
-
indicatorNode =
|
|
332
|
+
indicatorNode = _react2.default.createElement("div", {
|
|
324
333
|
className: `${classPrefix}-indicator`
|
|
325
|
-
},
|
|
334
|
+
}, _react2.default.createElement(_pageIndicator.default, Object.assign({}, props.indicatorProps, {
|
|
326
335
|
total: mergedTotal,
|
|
327
336
|
current: current,
|
|
328
337
|
direction: direction
|
|
329
338
|
})));
|
|
330
339
|
}
|
|
331
|
-
return (0, _nativeProps.withNativeProps)(props,
|
|
340
|
+
return (0, _nativeProps.withNativeProps)(props, _react2.default.createElement("div", {
|
|
332
341
|
className: (0, _classnames.default)(classPrefix, `${classPrefix}-${direction}`),
|
|
333
342
|
style: style
|
|
334
|
-
},
|
|
343
|
+
}, _react2.default.createElement("div", Object.assign({
|
|
335
344
|
ref: trackRef,
|
|
336
345
|
className: (0, _classnames.default)(`${classPrefix}-track`, {
|
|
337
346
|
[`${classPrefix}-track-allow-touch-move`]: props.allowTouchMove
|
|
@@ -48,18 +48,22 @@
|
|
|
48
48
|
}
|
|
49
49
|
.adm-virtual-input-caret-container {
|
|
50
50
|
display: inline-block;
|
|
51
|
-
width:
|
|
51
|
+
width: 0;
|
|
52
|
+
margin: 0;
|
|
53
|
+
padding: 0;
|
|
54
|
+
overflow: visible;
|
|
52
55
|
height: 1.3em;
|
|
53
56
|
vertical-align: top;
|
|
54
|
-
|
|
55
|
-
position: absolute;
|
|
57
|
+
position: relative;
|
|
56
58
|
}
|
|
57
59
|
.adm-virtual-input-caret {
|
|
58
|
-
width:
|
|
59
|
-
height:
|
|
60
|
+
width: var(--caret-width);
|
|
61
|
+
height: 95%;
|
|
60
62
|
background-color: var(--caret-color);
|
|
61
|
-
position:
|
|
63
|
+
position: absolute;
|
|
62
64
|
top: 5%;
|
|
65
|
+
left: 0;
|
|
66
|
+
z-index: 1;
|
|
63
67
|
}
|
|
64
68
|
.adm-virtual-input:focus {
|
|
65
69
|
outline: none;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { FC, ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
2
3
|
import { NativeProps } from '../../utils/native-props';
|
|
3
4
|
import { ImageProps } from '../image';
|
|
4
5
|
export declare type AvatarProps = {
|
|
5
6
|
src: string;
|
|
6
7
|
fallback?: ReactNode;
|
|
7
8
|
fit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
|
|
8
|
-
|
|
9
|
+
onClick?: (event: React.MouseEvent<HTMLDivElement | HTMLImageElement, Event>) => void;
|
|
10
|
+
} & Pick<ImageProps, 'alt' | 'lazy' | 'onError' | 'onLoad'> & NativeProps<'--size' | '--border-radius'>;
|
|
9
11
|
export declare const Avatar: FC<AvatarProps>;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { withNativeProps } from '../../utils/native-props';
|
|
3
3
|
import { mergeProps } from '../../utils/with-default-props';
|
|
4
|
-
import { Fallback } from './fallback';
|
|
5
4
|
import Image from '../image';
|
|
5
|
+
import { Fallback } from './fallback';
|
|
6
6
|
const classPrefix = 'adm-avatar';
|
|
7
7
|
const defaultProps = {
|
|
8
8
|
fallback: React.createElement(Fallback, null),
|
|
9
9
|
fit: 'cover'
|
|
10
10
|
};
|
|
11
11
|
export const Avatar = p => {
|
|
12
|
+
var _a;
|
|
12
13
|
const props = mergeProps(defaultProps, p);
|
|
14
|
+
const mergedSrc = ((_a = props.src) === null || _a === void 0 ? void 0 : _a.trim()) || undefined;
|
|
13
15
|
return withNativeProps(props, React.createElement(Image, {
|
|
14
16
|
className: classPrefix,
|
|
15
|
-
src:
|
|
17
|
+
src: mergedSrc,
|
|
16
18
|
fallback: props.fallback,
|
|
17
19
|
placeholder: props.fallback,
|
|
18
20
|
alt: props.alt,
|
|
@@ -87,12 +87,12 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
87
87
|
};
|
|
88
88
|
const header = React.createElement("div", {
|
|
89
89
|
className: `${classPrefix}-header`
|
|
90
|
-
}, React.createElement("a", {
|
|
90
|
+
}, props.prevYearButton !== null && React.createElement("a", {
|
|
91
91
|
className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-year`,
|
|
92
92
|
onClick: () => {
|
|
93
93
|
handlePageChange('subtract', 1, 'year');
|
|
94
94
|
}
|
|
95
|
-
}, props.prevYearButton), React.createElement("a", {
|
|
95
|
+
}, props.prevYearButton), props.prevMonthButton !== null && React.createElement("a", {
|
|
96
96
|
className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-month`,
|
|
97
97
|
onClick: () => {
|
|
98
98
|
handlePageChange('subtract', 1, 'month');
|
|
@@ -102,12 +102,12 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
102
102
|
}, replaceMessage(locale.Calendar.yearAndMonth, {
|
|
103
103
|
year: current.year().toString(),
|
|
104
104
|
month: (current.month() + 1).toString()
|
|
105
|
-
})), React.createElement("a", {
|
|
105
|
+
})), props.nextMonthButton !== null && React.createElement("a", {
|
|
106
106
|
className: classNames(`${classPrefix}-arrow-button`, `${classPrefix}-arrow-button-right`, `${classPrefix}-arrow-button-right-month`),
|
|
107
107
|
onClick: () => {
|
|
108
108
|
handlePageChange('add', 1, 'month');
|
|
109
109
|
}
|
|
110
|
-
}, props.nextMonthButton), React.createElement("a", {
|
|
110
|
+
}, props.nextMonthButton), props.nextYearButton !== null && React.createElement("a", {
|
|
111
111
|
className: classNames(`${classPrefix}-arrow-button`, `${classPrefix}-arrow-button-right`, `${classPrefix}-arrow-button-right-year`),
|
|
112
112
|
onClick: () => {
|
|
113
113
|
handlePageChange('add', 1, 'year');
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import React, { useState, useRef, useEffect } from 'react';
|
|
3
|
-
import { withNativeProps } from '../../utils/native-props';
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
4
2
|
import { staged } from 'staged-components';
|
|
3
|
+
import { withNativeProps } from '../../utils/native-props';
|
|
5
4
|
import { toCSSLength } from '../../utils/to-css-length';
|
|
6
|
-
import { LazyDetector } from './lazy-detector';
|
|
7
5
|
import { useIsomorphicUpdateLayoutEffect } from '../../utils/use-isomorphic-update-layout-effect';
|
|
8
|
-
import {
|
|
6
|
+
import { mergeProps } from '../../utils/with-default-props';
|
|
9
7
|
import { BrokenImageIcon } from './broken-image-icon';
|
|
8
|
+
import { ImageIcon } from './image-icon';
|
|
9
|
+
import { LazyDetector } from './lazy-detector';
|
|
10
10
|
const classPrefix = `adm-image`;
|
|
11
11
|
const defaultProps = {
|
|
12
12
|
fit: 'fill',
|
|
@@ -42,7 +42,7 @@ export const Image = staged(p => {
|
|
|
42
42
|
}
|
|
43
43
|
}, []);
|
|
44
44
|
function renderInner() {
|
|
45
|
-
if (failed) {
|
|
45
|
+
if (failed || src === undefined && !srcSet) {
|
|
46
46
|
return React.createElement(React.Fragment, null, props.fallback);
|
|
47
47
|
}
|
|
48
48
|
const img = React.createElement("img", {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FC, ReactNode } from 'react';
|
|
1
|
+
import type { FC, ReactNode, RefObject } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { GetContainer } from '../../utils/render-to-container';
|
|
4
4
|
import { SlidesRef } from './slides';
|
|
@@ -10,7 +10,8 @@ export declare type ImageViewerProps = {
|
|
|
10
10
|
onClose?: () => void;
|
|
11
11
|
afterClose?: () => void;
|
|
12
12
|
renderFooter?: (image: string) => ReactNode;
|
|
13
|
-
imageRender?: (image: string, { index }: {
|
|
13
|
+
imageRender?: (image: string, { ref, index }: {
|
|
14
|
+
ref: RefObject<HTMLImageElement>;
|
|
14
15
|
index: number;
|
|
15
16
|
}) => ReactNode;
|
|
16
17
|
classNames?: {
|
|
@@ -25,7 +26,8 @@ export declare type MultiImageViewerProps = Omit<ImageViewerProps, 'image' | 're
|
|
|
25
26
|
defaultIndex?: number;
|
|
26
27
|
onIndexChange?: (index: number) => void;
|
|
27
28
|
renderFooter?: (image: string, index: number) => ReactNode;
|
|
28
|
-
imageRender?: (image: string, { index }: {
|
|
29
|
+
imageRender?: (image: string, { ref, index }: {
|
|
30
|
+
ref: RefObject<HTMLImageElement>;
|
|
29
31
|
index: number;
|
|
30
32
|
}) => ReactNode;
|
|
31
33
|
};
|
|
@@ -34,7 +36,8 @@ export declare const MultiImageViewer: React.ForwardRefExoticComponent<Omit<Imag
|
|
|
34
36
|
defaultIndex?: number | undefined;
|
|
35
37
|
onIndexChange?: ((index: number) => void) | undefined;
|
|
36
38
|
renderFooter?: ((image: string, index: number) => ReactNode) | undefined;
|
|
37
|
-
imageRender?: ((image: string, { index }: {
|
|
39
|
+
imageRender?: ((image: string, { ref, index }: {
|
|
40
|
+
ref: RefObject<HTMLImageElement>;
|
|
38
41
|
index: number;
|
|
39
42
|
}) => ReactNode) | undefined;
|
|
40
43
|
} & React.RefAttributes<SlidesRef>>;
|
|
@@ -8,7 +8,8 @@ declare const _default: import("react").FC<import("./image-viewer").ImageViewerP
|
|
|
8
8
|
defaultIndex?: number | undefined;
|
|
9
9
|
onIndexChange?: ((index: number) => void) | undefined;
|
|
10
10
|
renderFooter?: ((image: string, index: number) => import("react").ReactNode) | undefined;
|
|
11
|
-
imageRender?: ((image: string, { index }: {
|
|
11
|
+
imageRender?: ((image: string, { ref, index }: {
|
|
12
|
+
ref: import("react").RefObject<HTMLImageElement>;
|
|
12
13
|
index: number;
|
|
13
14
|
}) => import("react").ReactNode) | undefined;
|
|
14
15
|
} & import("react").RefAttributes<import("./slides").SlidesRef>> & {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ImageViewer, MultiImageViewer } from './image-viewer';
|
|
3
2
|
import { renderImperatively } from '../../utils/render-imperatively';
|
|
3
|
+
import { ImageViewer, MultiImageViewer } from './image-viewer';
|
|
4
4
|
const handlerSet = new Set();
|
|
5
5
|
export function showImageViewer(props) {
|
|
6
6
|
clearImageViewer();
|