antd-mobile 5.0.0 → 5.1.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 +3 -6
- package/2x/cjs/components/floating-panel/floating-panel.css +2 -1
- package/2x/cjs/components/floating-panel/floating-panel.d.ts +2 -2
- package/2x/cjs/components/floating-panel/floating-panel.js +6 -5
- package/2x/cjs/components/form/form-subscribe.d.ts +11 -0
- package/2x/cjs/components/form/form-subscribe.js +27 -0
- package/2x/cjs/components/form/index.d.ts +2 -0
- package/2x/cjs/components/form/index.js +3 -0
- package/2x/cjs/components/image/image.js +2 -2
- package/2x/cjs/components/image-uploader/image-uploader.d.ts +1 -0
- package/2x/cjs/components/image-uploader/image-uploader.js +16 -9
- package/2x/cjs/components/image-viewer/slide.js +59 -19
- package/2x/cjs/components/index-bar/index-bar.d.ts +1 -1
- package/2x/cjs/components/index-bar/index-bar.js +12 -4
- package/2x/cjs/components/index-bar/index.d.ts +2 -1
- package/2x/cjs/components/index-bar/panel.d.ts +5 -4
- package/2x/cjs/components/index-bar/sidebar.d.ts +6 -3
- package/2x/cjs/components/index-bar/sidebar.js +6 -3
- package/2x/cjs/components/picker/picker.css +3 -0
- package/2x/cjs/components/picker/picker.d.ts +1 -1
- package/2x/cjs/components/picker-view/picker-view.css +14 -3
- package/2x/cjs/components/picker-view/picker-view.d.ts +1 -1
- package/2x/cjs/components/picker-view/wheel.js +23 -9
- package/2x/cjs/components/slider/slider.css +2 -1
- package/2x/cjs/components/toast/index.d.ts +1 -1
- package/2x/cjs/components/toast/methods.d.ts +4 -1
- package/2x/cjs/components/toast/methods.js +17 -4
- package/2x/cjs/utils/use-drag-and-pinch.d.ts +2 -0
- package/2x/cjs/utils/use-drag-and-pinch.js +11 -0
- package/2x/cjs/utils/use-isomorphic-update-layout-effect.d.ts +2 -0
- package/2x/cjs/utils/use-isomorphic-update-layout-effect.js +13 -0
- package/2x/es/components/floating-panel/floating-panel.css +2 -1
- package/2x/es/components/floating-panel/floating-panel.d.ts +2 -2
- package/2x/es/components/floating-panel/floating-panel.js +5 -5
- package/2x/es/components/form/form-subscribe.d.ts +11 -0
- package/2x/es/components/form/form-subscribe.js +14 -0
- package/2x/es/components/form/index.d.ts +2 -0
- package/2x/es/components/form/index.js +2 -0
- package/2x/es/components/image/image.js +2 -2
- package/2x/es/components/image-uploader/image-uploader.d.ts +1 -0
- package/2x/es/components/image-uploader/image-uploader.js +16 -9
- package/2x/es/components/image-viewer/slide.js +56 -18
- package/2x/es/components/index-bar/index-bar.d.ts +1 -1
- package/2x/es/components/index-bar/index-bar.js +12 -4
- package/2x/es/components/index-bar/index.d.ts +2 -1
- package/2x/es/components/index-bar/panel.d.ts +5 -4
- package/2x/es/components/index-bar/sidebar.d.ts +6 -3
- package/2x/es/components/index-bar/sidebar.js +6 -3
- package/2x/es/components/picker/picker.css +3 -0
- package/2x/es/components/picker/picker.d.ts +1 -1
- package/2x/es/components/picker-view/picker-view.css +14 -3
- package/2x/es/components/picker-view/picker-view.d.ts +1 -1
- package/2x/es/components/picker-view/wheel.js +22 -8
- package/2x/es/components/slider/slider.css +2 -1
- package/2x/es/components/toast/index.d.ts +1 -1
- package/2x/es/components/toast/methods.d.ts +4 -1
- package/2x/es/components/toast/methods.js +16 -5
- package/2x/es/utils/use-drag-and-pinch.d.ts +2 -0
- package/2x/es/utils/use-drag-and-pinch.js +2 -0
- package/2x/es/utils/use-isomorphic-update-layout-effect.d.ts +2 -0
- package/2x/es/utils/use-isomorphic-update-layout-effect.js +3 -0
- package/2x/package.json +1 -1
- package/README.md +3 -6
- package/cjs/components/floating-panel/floating-panel.css +2 -1
- package/cjs/components/floating-panel/floating-panel.d.ts +2 -2
- package/cjs/components/floating-panel/floating-panel.js +6 -5
- package/cjs/components/form/form-subscribe.d.ts +11 -0
- package/cjs/components/form/form-subscribe.js +27 -0
- package/cjs/components/form/index.d.ts +2 -0
- package/cjs/components/form/index.js +3 -0
- package/cjs/components/image/image.js +2 -2
- package/cjs/components/image-uploader/image-uploader.d.ts +1 -0
- package/cjs/components/image-uploader/image-uploader.js +16 -9
- package/cjs/components/image-viewer/slide.js +59 -19
- package/cjs/components/index-bar/index-bar.d.ts +1 -1
- package/cjs/components/index-bar/index-bar.js +12 -4
- package/cjs/components/index-bar/index.d.ts +2 -1
- package/cjs/components/index-bar/panel.d.ts +5 -4
- package/cjs/components/index-bar/sidebar.d.ts +6 -3
- package/cjs/components/index-bar/sidebar.js +6 -3
- package/cjs/components/picker/picker.css +3 -0
- package/cjs/components/picker/picker.d.ts +1 -1
- package/cjs/components/picker-view/picker-view.css +13 -3
- package/cjs/components/picker-view/picker-view.d.ts +1 -1
- package/cjs/components/picker-view/wheel.js +23 -9
- package/cjs/components/slider/slider.css +2 -1
- package/cjs/components/toast/index.d.ts +1 -1
- package/cjs/components/toast/methods.d.ts +4 -1
- package/cjs/components/toast/methods.js +17 -4
- package/cjs/utils/use-drag-and-pinch.d.ts +2 -0
- package/cjs/utils/use-drag-and-pinch.js +11 -0
- package/cjs/utils/use-isomorphic-update-layout-effect.d.ts +2 -0
- package/cjs/utils/use-isomorphic-update-layout-effect.js +13 -0
- package/es/components/floating-panel/floating-panel.css +2 -1
- package/es/components/floating-panel/floating-panel.d.ts +2 -2
- package/es/components/floating-panel/floating-panel.js +5 -5
- package/es/components/form/form-subscribe.d.ts +11 -0
- package/es/components/form/form-subscribe.js +14 -0
- package/es/components/form/index.d.ts +2 -0
- package/es/components/form/index.js +2 -0
- package/es/components/image/image.js +2 -2
- package/es/components/image-uploader/image-uploader.d.ts +1 -0
- package/es/components/image-uploader/image-uploader.js +16 -9
- package/es/components/image-viewer/slide.js +56 -18
- package/es/components/index-bar/index-bar.d.ts +1 -1
- package/es/components/index-bar/index-bar.js +12 -4
- package/es/components/index-bar/index.d.ts +2 -1
- package/es/components/index-bar/panel.d.ts +5 -4
- package/es/components/index-bar/sidebar.d.ts +6 -3
- package/es/components/index-bar/sidebar.js +6 -3
- package/es/components/picker/picker.css +3 -0
- package/es/components/picker/picker.d.ts +1 -1
- package/es/components/picker-view/picker-view.css +13 -3
- package/es/components/picker-view/picker-view.d.ts +1 -1
- package/es/components/picker-view/wheel.js +22 -8
- package/es/components/slider/slider.css +2 -1
- package/es/components/toast/index.d.ts +1 -1
- package/es/components/toast/methods.d.ts +4 -1
- package/es/components/toast/methods.js +16 -5
- package/es/utils/use-drag-and-pinch.d.ts +2 -0
- package/es/utils/use-drag-and-pinch.js +2 -0
- package/es/utils/use-isomorphic-update-layout-effect.d.ts +2 -0
- package/es/utils/use-isomorphic-update-layout-effect.js +3 -0
- package/package.json +1 -1
- package/umd/antd-mobile.js +1 -1
package/2x/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
<img src="https://gw.alipayobjects.com/mdn/rms_ee68a8/afts/img/A*
|
|
1
|
+
<img src="https://gw.alipayobjects.com/mdn/rms_ee68a8/afts/img/A*hjjDS5Yy-ooAAAAAAAAAAAAAARQnAQ" alt="logo" width="100%" />
|
|
2
|
+
|
|
3
|
+
[English Doc](https://mobile.ant.design) | [中文文档](https://mobile.ant.design/zh) | [Discord](https://discord.gg/jmNvw4WFYn) | [钉钉](https://gw.alipayobjects.com/mdn/rms_25513e/afts/img/A*hBjlR4nUWjkAAAAAAAAAAAAAARQnAQ)
|
|
2
4
|
|
|
3
5
|

|
|
4
6
|

|
|
@@ -28,11 +30,6 @@ If you found bugs or would like to request some new features, please consider op
|
|
|
28
30
|
|
|
29
31
|
If you have some question about how to use ant-mobile, you can start a [discussion thread](https://github.com/ant-design/ant-design-mobile/discussions).
|
|
30
32
|
|
|
31
|
-
And we also have some community groups here. Feel free to join us:
|
|
32
|
-
|
|
33
|
-
- [DingDing](https://gw.alipayobjects.com/mdn/rms_25513e/afts/img/A*hBjlR4nUWjkAAAAAAAAAAAAAARQnAQ)
|
|
34
|
-
- [Discord](https://discord.gg/jmNvw4WFYn)
|
|
35
|
-
|
|
36
33
|
---
|
|
37
34
|
|
|
38
35
|
Thanks to all the contributors of antd-mobile:
|
|
@@ -10,10 +10,10 @@ export declare type FloatingPanelProps = {
|
|
|
10
10
|
children: ReactNode;
|
|
11
11
|
onHeightChange?: (height: number, animating: boolean) => void;
|
|
12
12
|
handleDraggingOfContent?: boolean;
|
|
13
|
-
} & NativeProps<'--border-radius' | '--z-index'>;
|
|
13
|
+
} & NativeProps<'--border-radius' | '--z-index' | '--header-height'>;
|
|
14
14
|
export declare const FloatingPanel: React.ForwardRefExoticComponent<{
|
|
15
15
|
anchors: number[];
|
|
16
16
|
children: ReactNode;
|
|
17
17
|
onHeightChange?: ((height: number, animating: boolean) => void) | undefined;
|
|
18
18
|
handleDraggingOfContent?: boolean | undefined;
|
|
19
|
-
} & NativeProps<"--z-index" | "--border-radius"> & React.RefAttributes<FloatingPanelRef>>;
|
|
19
|
+
} & NativeProps<"--z-index" | "--border-radius" | "--header-height"> & React.RefAttributes<FloatingPanelRef>>;
|
|
@@ -21,6 +21,8 @@ var _withDefaultProps = require("../../utils/with-default-props");
|
|
|
21
21
|
|
|
22
22
|
var _useLockScroll = require("../../utils/use-lock-scroll");
|
|
23
23
|
|
|
24
|
+
var _ahooks = require("ahooks");
|
|
25
|
+
|
|
24
26
|
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); }
|
|
25
27
|
|
|
26
28
|
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; }
|
|
@@ -29,7 +31,7 @@ const defaultProps = {
|
|
|
29
31
|
handleDraggingOfContent: true
|
|
30
32
|
};
|
|
31
33
|
const FloatingPanel = (0, _react.forwardRef)((p, ref) => {
|
|
32
|
-
var _a;
|
|
34
|
+
var _a, _b;
|
|
33
35
|
|
|
34
36
|
const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
|
|
35
37
|
const {
|
|
@@ -46,6 +48,7 @@ const FloatingPanel = (0, _react.forwardRef)((p, ref) => {
|
|
|
46
48
|
top: possibles[possibles.length - 1],
|
|
47
49
|
bottom: possibles[0]
|
|
48
50
|
};
|
|
51
|
+
const onHeightChange = (0, _ahooks.useMemoizedFn)((_b = props.onHeightChange) !== null && _b !== void 0 ? _b : () => {});
|
|
49
52
|
const [{
|
|
50
53
|
y
|
|
51
54
|
}, api] = (0, _web.useSpring)(() => ({
|
|
@@ -54,9 +57,7 @@ const FloatingPanel = (0, _react.forwardRef)((p, ref) => {
|
|
|
54
57
|
tension: 300
|
|
55
58
|
},
|
|
56
59
|
onChange: result => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
(_a = props.onHeightChange) === null || _a === void 0 ? void 0 : _a.call(props, result.value.y, y.isAnimating);
|
|
60
|
+
onHeightChange(result.value.y, y.isAnimating);
|
|
60
61
|
}
|
|
61
62
|
}));
|
|
62
63
|
(0, _react2.useDrag)(state => {
|
|
@@ -133,7 +134,7 @@ const FloatingPanel = (0, _react.forwardRef)((p, ref) => {
|
|
|
133
134
|
className: 'adm-floating-panel',
|
|
134
135
|
style: {
|
|
135
136
|
height: maxHeight,
|
|
136
|
-
y
|
|
137
|
+
translateY: y.to(y => `calc(100% + (${y}px))`)
|
|
137
138
|
}
|
|
138
139
|
}, _react.default.createElement("div", {
|
|
139
140
|
className: 'adm-floating-panel-mask',
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { FormInstance } from 'rc-field-form';
|
|
3
|
+
import type { NamePath } from 'rc-field-form/es/interface';
|
|
4
|
+
declare type RenderChildren<Values = any> = (changedValues: Record<string, any>, form: FormInstance<Values>) => React.ReactNode;
|
|
5
|
+
declare type ChildrenType<Values = any> = RenderChildren<Values>;
|
|
6
|
+
export interface FormSubscribeProps {
|
|
7
|
+
to: NamePath[];
|
|
8
|
+
children: ChildrenType;
|
|
9
|
+
}
|
|
10
|
+
export declare const FormSubscribe: React.VFC<FormSubscribeProps>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FormSubscribe = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _ = _interopRequireDefault(require("."));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
const FormSubscribe = ({
|
|
15
|
+
children,
|
|
16
|
+
to
|
|
17
|
+
}) => {
|
|
18
|
+
return _react.default.createElement(_.default.Item, {
|
|
19
|
+
noStyle: true,
|
|
20
|
+
dependencies: to
|
|
21
|
+
}, form => {
|
|
22
|
+
const changedValues = form.getFieldsValue(to);
|
|
23
|
+
return children(changedValues, form);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.FormSubscribe = FormSubscribe;
|
|
@@ -4,6 +4,7 @@ import { useForm } from 'rc-field-form';
|
|
|
4
4
|
export declare type FormLayout = 'vertical' | 'horizontal';
|
|
5
5
|
export type { FormProps, FormInstance } from './form';
|
|
6
6
|
export type { FormItemProps } from './form-item';
|
|
7
|
+
export type { FormSubscribeProps } from './form-subscribe';
|
|
7
8
|
export type { ValidateMessages, FieldData, NamePath, } from 'rc-field-form/es/interface';
|
|
8
9
|
declare const _default: import("react").ForwardRefExoticComponent<Pick<import("rc-field-form").FormProps<any>, "children" | "form" | "name" | "initialValues" | "preserve" | "validateMessages" | "validateTrigger" | "onFieldsChange" | "onFinish" | "onFinishFailed" | "onValuesChange"> & import("../../utils/native-props").NativeProps<never> & Partial<import("./context").FormContextType> & {
|
|
9
10
|
footer?: import("react").ReactNode;
|
|
@@ -11,6 +12,7 @@ declare const _default: import("react").ForwardRefExoticComponent<Pick<import("r
|
|
|
11
12
|
mode?: "default" | "card" | undefined;
|
|
12
13
|
} & import("react").RefAttributes<Pick<import("rc-field-form").FormInstance<any>, "submit" | "getFieldValue" | "getFieldsValue" | "getFieldError" | "getFieldsError" | "isFieldTouched" | "isFieldsTouched" | "resetFields" | "setFields" | "setFieldsValue" | "validateFields">>> & {
|
|
13
14
|
Item: import("react").FC<import("./form-item").FormItemProps>;
|
|
15
|
+
Subscribe: import("react").VFC<import("./form-subscribe").FormSubscribeProps>;
|
|
14
16
|
Header: import("react").FC<{}>;
|
|
15
17
|
useForm: typeof useForm;
|
|
16
18
|
};
|
|
@@ -17,8 +17,11 @@ var _header = require("./header");
|
|
|
17
17
|
|
|
18
18
|
var _rcFieldForm = require("rc-field-form");
|
|
19
19
|
|
|
20
|
+
var _formSubscribe = require("./form-subscribe");
|
|
21
|
+
|
|
20
22
|
var _default = (0, _attachPropertiesToComponent.attachPropertiesToComponent)(_form.Form, {
|
|
21
23
|
Item: _formItem.FormItem,
|
|
24
|
+
Subscribe: _formSubscribe.FormSubscribe,
|
|
22
25
|
Header: _header.Header,
|
|
23
26
|
useForm: _rcFieldForm.useForm
|
|
24
27
|
});
|
|
@@ -19,7 +19,7 @@ var _toCssLength = require("../../utils/to-css-length");
|
|
|
19
19
|
|
|
20
20
|
var _lazyDetector = require("./lazy-detector");
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _useIsomorphicUpdateLayoutEffect = require("../../utils/use-isomorphic-update-layout-effect");
|
|
23
23
|
|
|
24
24
|
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); }
|
|
25
25
|
|
|
@@ -46,7 +46,7 @@ const Image = (0, _stagedComponents.staged)(p => {
|
|
|
46
46
|
const [initialized, setInitialized] = (0, _react.useState)(!props.lazy);
|
|
47
47
|
src = initialized ? props.src : undefined;
|
|
48
48
|
srcSet = initialized ? props.srcSet : undefined;
|
|
49
|
-
(0,
|
|
49
|
+
(0, _useIsomorphicUpdateLayoutEffect.useIsomorphicUpdateLayoutEffect)(() => {
|
|
50
50
|
setLoaded(false);
|
|
51
51
|
setFailed(false);
|
|
52
52
|
}, [src]);
|
|
@@ -24,5 +24,6 @@ export declare type ImageUploaderProps = {
|
|
|
24
24
|
upload: (file: File) => Promise<ImageUploadItem>;
|
|
25
25
|
onDelete?: (item: ImageUploadItem) => boolean | Promise<boolean> | void;
|
|
26
26
|
preview?: boolean;
|
|
27
|
+
showFailed?: boolean;
|
|
27
28
|
} & NativeProps<'--cell-size'>;
|
|
28
29
|
export declare const ImageUploader: FC<ImageUploaderProps>;
|
|
@@ -40,7 +40,8 @@ const defaultProps = {
|
|
|
40
40
|
maxCount: 0,
|
|
41
41
|
defaultValue: [],
|
|
42
42
|
accept: 'image/*',
|
|
43
|
-
preview: true
|
|
43
|
+
preview: true,
|
|
44
|
+
showFailed: true
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
const ImageUploader = p => {
|
|
@@ -178,15 +179,21 @@ const ImageUploader = p => {
|
|
|
178
179
|
setValue(value.filter((x, i) => i !== index));
|
|
179
180
|
})
|
|
180
181
|
});
|
|
181
|
-
}), tasks.map(task =>
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
deletable: task.status !== 'pending',
|
|
185
|
-
status: task.status,
|
|
186
|
-
onDelete: () => {
|
|
187
|
-
setTasks(tasks.filter(x => x.id !== task.id));
|
|
182
|
+
}), tasks.map(task => {
|
|
183
|
+
if (!props.showFailed && task.status === 'fail') {
|
|
184
|
+
return null;
|
|
188
185
|
}
|
|
189
|
-
|
|
186
|
+
|
|
187
|
+
return _react.default.createElement(_previewItem.default, {
|
|
188
|
+
key: task.id,
|
|
189
|
+
file: task.file,
|
|
190
|
+
deletable: task.status !== 'pending',
|
|
191
|
+
status: task.status,
|
|
192
|
+
onDelete: () => {
|
|
193
|
+
setTasks(tasks.filter(x => x.id !== task.id));
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}), showUpload && _react.default.createElement("div", {
|
|
190
197
|
className: `${classPrefix}-upload-button-wrap`
|
|
191
198
|
}, props.children ? props.children : _react.default.createElement("span", {
|
|
192
199
|
className: `${classPrefix}-cell ${classPrefix}-upload-button`,
|
|
@@ -7,10 +7,14 @@ exports.Slide = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
-
var _react2 = require("@use-gesture/react");
|
|
11
|
-
|
|
12
10
|
var _web = require("@react-spring/web");
|
|
13
11
|
|
|
12
|
+
var _rubberband = require("../../utils/rubberband");
|
|
13
|
+
|
|
14
|
+
var _useDragAndPinch = require("../../utils/use-drag-and-pinch");
|
|
15
|
+
|
|
16
|
+
var _bound = require("../../utils/bound");
|
|
17
|
+
|
|
14
18
|
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); }
|
|
15
19
|
|
|
16
20
|
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; }
|
|
@@ -22,6 +26,7 @@ const Slide = props => {
|
|
|
22
26
|
dragLockRef
|
|
23
27
|
} = props;
|
|
24
28
|
const controlRef = (0, _react.useRef)(null);
|
|
29
|
+
const imgRef = (0, _react.useRef)(null);
|
|
25
30
|
const [{
|
|
26
31
|
zoom,
|
|
27
32
|
x,
|
|
@@ -31,11 +36,38 @@ const Slide = props => {
|
|
|
31
36
|
x: 0,
|
|
32
37
|
y: 0,
|
|
33
38
|
config: {
|
|
34
|
-
tension:
|
|
39
|
+
tension: 200
|
|
35
40
|
}
|
|
36
41
|
}));
|
|
37
42
|
const pinchLockRef = (0, _react.useRef)(false);
|
|
38
|
-
|
|
43
|
+
|
|
44
|
+
function boundXY([x, y], rubberband) {
|
|
45
|
+
const currentZoom = zoom.get();
|
|
46
|
+
let xOffset = 0,
|
|
47
|
+
yOffset = 0;
|
|
48
|
+
|
|
49
|
+
if (imgRef.current && controlRef.current) {
|
|
50
|
+
xOffset = ((currentZoom * imgRef.current.width || 0) - controlRef.current.clientWidth) / 2;
|
|
51
|
+
yOffset = ((currentZoom * imgRef.current.height || 0) - controlRef.current.clientHeight) / 2;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
xOffset = xOffset > 0 ? xOffset : 0;
|
|
55
|
+
yOffset = yOffset > 0 ? yOffset : 0;
|
|
56
|
+
const bounds = {
|
|
57
|
+
left: -xOffset,
|
|
58
|
+
right: xOffset,
|
|
59
|
+
top: -yOffset,
|
|
60
|
+
bottom: yOffset
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
if (rubberband) {
|
|
64
|
+
return [(0, _rubberband.rubberbandIfOutOfBounds)(x, bounds.left, bounds.right, currentZoom * 50), (0, _rubberband.rubberbandIfOutOfBounds)(y, bounds.top, bounds.bottom, currentZoom * 50)];
|
|
65
|
+
} else {
|
|
66
|
+
return [(0, _bound.bound)(x, bounds.left, bounds.right), (0, _bound.bound)(y, bounds.top, bounds.bottom)];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
(0, _useDragAndPinch.useDragAndPinch)({
|
|
39
71
|
onDrag: state => {
|
|
40
72
|
if (state.tap && state.elapsedTime > 0 && state.elapsedTime < 1000) {
|
|
41
73
|
// 判断点击时间>0是为了过滤掉非正常操作,例如用户长按选择图片之后的取消操作(也是一次点击)
|
|
@@ -55,12 +87,20 @@ const Slide = props => {
|
|
|
55
87
|
y: 0
|
|
56
88
|
});
|
|
57
89
|
} else {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
90
|
+
if (state.last) {
|
|
91
|
+
const [x, y] = boundXY([state.offset[0] + state.velocity[0] * state.direction[0] * 200, state.offset[1] + state.velocity[1] * state.direction[1] * 200], false);
|
|
92
|
+
api.start({
|
|
93
|
+
x,
|
|
94
|
+
y
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
const [x, y] = boundXY(state.offset, true);
|
|
98
|
+
api.start({
|
|
99
|
+
x,
|
|
100
|
+
y,
|
|
101
|
+
immediate: true
|
|
102
|
+
});
|
|
103
|
+
}
|
|
64
104
|
}
|
|
65
105
|
},
|
|
66
106
|
onPinch: state => {
|
|
@@ -68,16 +108,15 @@ const Slide = props => {
|
|
|
68
108
|
|
|
69
109
|
pinchLockRef.current = !state.last;
|
|
70
110
|
const [d] = state.offset;
|
|
71
|
-
if (d < 0) return;
|
|
72
|
-
|
|
73
|
-
const zoom = state.last ? Math.max(Math.min(d, props.maxZoom), 1) : d;
|
|
111
|
+
if (d < 0) return;
|
|
112
|
+
const nextZoom = state.last ? (0, _bound.bound)(d, 1, props.maxZoom) : d;
|
|
74
113
|
api.start({
|
|
75
|
-
zoom,
|
|
114
|
+
zoom: nextZoom,
|
|
76
115
|
immediate: !state.last
|
|
77
116
|
});
|
|
78
|
-
(_a = props.onZoomChange) === null || _a === void 0 ? void 0 : _a.call(props,
|
|
117
|
+
(_a = props.onZoomChange) === null || _a === void 0 ? void 0 : _a.call(props, nextZoom);
|
|
79
118
|
|
|
80
|
-
if (state.last &&
|
|
119
|
+
if (state.last && nextZoom <= 1) {
|
|
81
120
|
api.start({
|
|
82
121
|
x: 0,
|
|
83
122
|
y: 0
|
|
@@ -121,11 +160,12 @@ const Slide = props => {
|
|
|
121
160
|
}, _react.default.createElement(_web.animated.div, {
|
|
122
161
|
className: `${classPrefix}-image-wrapper`,
|
|
123
162
|
style: {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
163
|
+
translateX: x,
|
|
164
|
+
translateY: y,
|
|
165
|
+
scale: zoom
|
|
127
166
|
}
|
|
128
167
|
}, _react.default.createElement("img", {
|
|
168
|
+
ref: imgRef,
|
|
129
169
|
src: props.image,
|
|
130
170
|
draggable: false,
|
|
131
171
|
alt: props.image
|
|
@@ -37,10 +37,12 @@ const IndexBar = (0, _react.forwardRef)((p, ref) => {
|
|
|
37
37
|
const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
|
|
38
38
|
const titleHeight = (0, _convertPx.convertPx)(35);
|
|
39
39
|
const bodyRef = (0, _react.useRef)(null);
|
|
40
|
-
const
|
|
40
|
+
const indexItems = [];
|
|
41
41
|
const panels = [];
|
|
42
42
|
|
|
43
43
|
_react.default.Children.forEach(props.children, child => {
|
|
44
|
+
var _a;
|
|
45
|
+
|
|
44
46
|
if (!_react.default.isValidElement(child)) return;
|
|
45
47
|
|
|
46
48
|
if (child.type !== _panel.Panel) {
|
|
@@ -48,7 +50,10 @@ const IndexBar = (0, _react.forwardRef)((p, ref) => {
|
|
|
48
50
|
return;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
indexItems.push({
|
|
54
|
+
index: child.props.index,
|
|
55
|
+
brief: (_a = child.props.brief) !== null && _a !== void 0 ? _a : child.props.index.charAt(0)
|
|
56
|
+
});
|
|
52
57
|
panels.push((0, _nativeProps.withNativeProps)(child.props, _react.default.createElement("div", {
|
|
53
58
|
key: child.props.index,
|
|
54
59
|
"data-index": child.props.index,
|
|
@@ -58,7 +63,10 @@ const IndexBar = (0, _react.forwardRef)((p, ref) => {
|
|
|
58
63
|
}, child.props.title || child.props.index), child.props.children)));
|
|
59
64
|
});
|
|
60
65
|
|
|
61
|
-
const [activeIndex, setActiveIndex] = (0, _react.useState)(
|
|
66
|
+
const [activeIndex, setActiveIndex] = (0, _react.useState)(() => {
|
|
67
|
+
const firstItem = indexItems[0];
|
|
68
|
+
return firstItem ? firstItem.index : null;
|
|
69
|
+
});
|
|
62
70
|
(0, _react.useImperativeHandle)(ref, () => ({
|
|
63
71
|
scrollTo
|
|
64
72
|
}));
|
|
@@ -110,7 +118,7 @@ const IndexBar = (0, _react.forwardRef)((p, ref) => {
|
|
|
110
118
|
[`${classPrefix}-sticky`]: props.sticky
|
|
111
119
|
})
|
|
112
120
|
}, _react.default.createElement(_sidebar.Sidebar, {
|
|
113
|
-
|
|
121
|
+
indexItems: indexItems,
|
|
114
122
|
activeIndex: activeIndex,
|
|
115
123
|
onActive: index => {
|
|
116
124
|
scrollTo(index);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import './index-bar.less';
|
|
3
3
|
export type { IndexBarProps, IndexBarRef } from './index-bar';
|
|
4
|
+
export type { IndexBarPanelProps } from './panel';
|
|
4
5
|
declare const _default: import("react").ForwardRefExoticComponent<{
|
|
5
6
|
sticky?: boolean | undefined;
|
|
6
7
|
children?: import("react").ReactNode;
|
|
7
8
|
} & import("../../utils/native-props").NativeProps<"--sticky-offset-top"> & import("react").RefAttributes<import("./index-bar").IndexBarRef>> & {
|
|
8
|
-
Panel: import("react").FC<import("./panel").
|
|
9
|
+
Panel: import("react").FC<import("./panel").IndexBarPanelProps>;
|
|
9
10
|
};
|
|
10
11
|
export default _default;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
|
-
export declare type
|
|
3
|
+
export declare type IndexBarPanelProps = {
|
|
4
4
|
index: string;
|
|
5
|
-
title?:
|
|
5
|
+
title?: ReactNode;
|
|
6
|
+
brief?: ReactNode;
|
|
6
7
|
} & NativeProps;
|
|
7
|
-
export declare const Panel: FC<
|
|
8
|
+
export declare const Panel: FC<IndexBarPanelProps>;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
2
|
declare type SidebarProps = {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
indexItems: {
|
|
4
|
+
index: string;
|
|
5
|
+
brief: ReactNode;
|
|
6
|
+
}[];
|
|
7
|
+
activeIndex: string | null;
|
|
5
8
|
onActive: (index: string) => void;
|
|
6
9
|
};
|
|
7
10
|
export declare const Sidebar: FC<SidebarProps>;
|
|
@@ -49,7 +49,10 @@ const Sidebar = props => {
|
|
|
49
49
|
props.onActive(index);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
}, props.
|
|
52
|
+
}, props.indexItems.map(({
|
|
53
|
+
index,
|
|
54
|
+
brief
|
|
55
|
+
}) => {
|
|
53
56
|
const active = index === props.activeIndex;
|
|
54
57
|
return _react.default.createElement("div", {
|
|
55
58
|
className: `${classPrefix}-sidebar-row`,
|
|
@@ -68,12 +71,12 @@ const Sidebar = props => {
|
|
|
68
71
|
key: index
|
|
69
72
|
}, interacting && active && _react.default.createElement("div", {
|
|
70
73
|
className: `${classPrefix}-sidebar-bubble`
|
|
71
|
-
},
|
|
74
|
+
}, brief), _react.default.createElement("div", {
|
|
72
75
|
className: (0, _classnames.default)(`${classPrefix}-sidebar-item`, {
|
|
73
76
|
[`${classPrefix}-sidebar-item-active`]: active
|
|
74
77
|
}),
|
|
75
78
|
"data-index": index
|
|
76
|
-
}, _react.default.createElement("div", null,
|
|
79
|
+
}, _react.default.createElement("div", null, brief)));
|
|
77
80
|
}));
|
|
78
81
|
};
|
|
79
82
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
--header-button-font-size: 30px;
|
|
3
3
|
--title-font-size: 30px;
|
|
4
4
|
--item-font-size: 32px;
|
|
5
|
+
--item-height: 68px;
|
|
5
6
|
width: 100%;
|
|
6
7
|
height: 600px;
|
|
7
8
|
overflow: hidden;
|
|
@@ -9,10 +10,12 @@
|
|
|
9
10
|
display: flex;
|
|
10
11
|
flex-direction: column;
|
|
11
12
|
---item-font-size: var(--item-font-size);
|
|
13
|
+
---item-height: var(--item-height);
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
.adm-picker .adm-picker-view.adm-picker-view {
|
|
15
17
|
--item-font-size: var(---item-font-size);
|
|
18
|
+
--item-height: var(---item-height);
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
.adm-picker-header {
|
|
@@ -16,5 +16,5 @@ export declare type PickerProps = {
|
|
|
16
16
|
confirmText?: ReactNode;
|
|
17
17
|
cancelText?: ReactNode;
|
|
18
18
|
children?: (items: (PickerColumnItem | null)[]) => ReactNode;
|
|
19
|
-
} & Pick<PopupProps, 'getContainer' | 'afterShow' | 'afterClose' | 'onClick' | 'stopPropagation'> & NativeProps<'--header-button-font-size' | '--title-font-size' | '--item-font-size'>;
|
|
19
|
+
} & Pick<PopupProps, 'getContainer' | 'afterShow' | 'afterClose' | 'onClick' | 'stopPropagation'> & NativeProps<'--header-button-font-size' | '--title-font-size' | '--item-font-size' | '--item-height'>;
|
|
20
20
|
export declare const Picker: React.NamedExoticComponent<PickerProps>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
.adm-picker-view {
|
|
2
2
|
--height: 480px;
|
|
3
|
+
--item-height: 68px;
|
|
3
4
|
--item-font-size: 32px;
|
|
4
5
|
height: var(--height);
|
|
5
6
|
width: 100%;
|
|
@@ -22,7 +23,7 @@
|
|
|
22
23
|
width: 100%;
|
|
23
24
|
cursor: grab;
|
|
24
25
|
position: absolute;
|
|
25
|
-
top: calc(50% -
|
|
26
|
+
top: calc(50% - var(--item-height) / 2);
|
|
26
27
|
left: 0;
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -47,7 +48,7 @@
|
|
|
47
48
|
.adm-picker-view-column-item {
|
|
48
49
|
font-size: var(--item-font-size);
|
|
49
50
|
padding: 0 12px;
|
|
50
|
-
height:
|
|
51
|
+
height: var(--item-height);
|
|
51
52
|
display: flex;
|
|
52
53
|
justify-content: center;
|
|
53
54
|
align-items: center;
|
|
@@ -59,6 +60,16 @@
|
|
|
59
60
|
white-space: nowrap;
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
.adm-picker-view-column-item.adm-picker-view-column-item-dummy {
|
|
64
|
+
position: fixed;
|
|
65
|
+
left: 0;
|
|
66
|
+
bottom: 0;
|
|
67
|
+
padding: 0;
|
|
68
|
+
opacity: 0;
|
|
69
|
+
user-select: none;
|
|
70
|
+
pointer-events: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
62
73
|
.adm-picker-view-column-accessible {
|
|
63
74
|
width: 100%;
|
|
64
75
|
height: 100%;
|
|
@@ -104,7 +115,7 @@
|
|
|
104
115
|
}
|
|
105
116
|
|
|
106
117
|
.adm-picker-view-mask-middle {
|
|
107
|
-
height:
|
|
118
|
+
height: var(--item-height);
|
|
108
119
|
box-sizing: border-box;
|
|
109
120
|
flex: none;
|
|
110
121
|
border-top: solid 2px var(--adm-border-color);
|
|
@@ -14,5 +14,5 @@ export declare type PickerViewProps = {
|
|
|
14
14
|
value?: PickerValue[];
|
|
15
15
|
defaultValue?: PickerValue[];
|
|
16
16
|
onChange?: (value: PickerValue[], extend: PickerValueExtend) => void;
|
|
17
|
-
} & NativeProps<'--height' | '--item-font-size'>;
|
|
17
|
+
} & NativeProps<'--height' | '--item-height' | '--item-font-size'>;
|
|
18
18
|
export declare const PickerView: React.NamedExoticComponent<PickerViewProps>;
|