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
|
@@ -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: 15px;
|
|
3
3
|
--title-font-size: 15px;
|
|
4
4
|
--item-font-size: 16px;
|
|
5
|
+
--item-height: 34px;
|
|
5
6
|
width: 100%;
|
|
6
7
|
height: 300px;
|
|
7
8
|
overflow: hidden;
|
|
@@ -9,9 +10,11 @@
|
|
|
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
|
.adm-picker .adm-picker-view.adm-picker-view {
|
|
14
16
|
--item-font-size: var(---item-font-size);
|
|
17
|
+
--item-height: var(---item-height);
|
|
15
18
|
}
|
|
16
19
|
.adm-picker-header {
|
|
17
20
|
flex: none;
|
|
@@ -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: 240px;
|
|
3
|
+
--item-height: 34px;
|
|
3
4
|
--item-font-size: 16px;
|
|
4
5
|
height: var(--height);
|
|
5
6
|
width: 100%;
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
width: 100%;
|
|
21
22
|
cursor: grab;
|
|
22
23
|
position: absolute;
|
|
23
|
-
top: calc(50% -
|
|
24
|
+
top: calc(50% - var(--item-height) / 2);
|
|
24
25
|
left: 0;
|
|
25
26
|
}
|
|
26
27
|
.adm-picker-view-column-wheel::before {
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
.adm-picker-view-column-item {
|
|
43
44
|
font-size: var(--item-font-size);
|
|
44
45
|
padding: 0 6px;
|
|
45
|
-
height:
|
|
46
|
+
height: var(--item-height);
|
|
46
47
|
display: flex;
|
|
47
48
|
justify-content: center;
|
|
48
49
|
align-items: center;
|
|
@@ -52,6 +53,15 @@
|
|
|
52
53
|
text-overflow: ellipsis;
|
|
53
54
|
white-space: nowrap;
|
|
54
55
|
}
|
|
56
|
+
.adm-picker-view-column-item.adm-picker-view-column-item-dummy {
|
|
57
|
+
position: fixed;
|
|
58
|
+
left: 0;
|
|
59
|
+
bottom: 0;
|
|
60
|
+
padding: 0;
|
|
61
|
+
opacity: 0;
|
|
62
|
+
user-select: none;
|
|
63
|
+
pointer-events: none;
|
|
64
|
+
}
|
|
55
65
|
.adm-picker-view-column-accessible {
|
|
56
66
|
width: 100%;
|
|
57
67
|
height: 100%;
|
|
@@ -91,7 +101,7 @@
|
|
|
91
101
|
flex: auto;
|
|
92
102
|
}
|
|
93
103
|
.adm-picker-view-mask-middle {
|
|
94
|
-
height:
|
|
104
|
+
height: var(--item-height);
|
|
95
105
|
box-sizing: border-box;
|
|
96
106
|
flex: none;
|
|
97
107
|
border-top: solid 1px 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>;
|
|
@@ -11,8 +11,6 @@ var _web = require("@react-spring/web");
|
|
|
11
11
|
|
|
12
12
|
var _react2 = require("@use-gesture/react");
|
|
13
13
|
|
|
14
|
-
var _convertPx = require("../../utils/convert-px");
|
|
15
|
-
|
|
16
14
|
var _rubberband = require("../../utils/rubberband");
|
|
17
15
|
|
|
18
16
|
var _bound = require("../../utils/bound");
|
|
@@ -21,6 +19,8 @@ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
|
21
19
|
|
|
22
20
|
var _ahooks = require("ahooks");
|
|
23
21
|
|
|
22
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
23
|
+
|
|
24
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
25
|
|
|
26
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); }
|
|
@@ -29,7 +29,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
29
29
|
|
|
30
30
|
const classPrefix = `adm-picker-view`;
|
|
31
31
|
const Wheel = (0, _react.memo)(props => {
|
|
32
|
-
const itemHeight = (0, _convertPx.convertPx)(34);
|
|
33
32
|
const {
|
|
34
33
|
value,
|
|
35
34
|
column
|
|
@@ -51,12 +50,23 @@ const Wheel = (0, _react.memo)(props => {
|
|
|
51
50
|
}
|
|
52
51
|
}));
|
|
53
52
|
const draggingRef = (0, _react.useRef)(false);
|
|
53
|
+
const dummyItemRef = (0, _react.useRef)(null);
|
|
54
|
+
const itemHeight = (0, _react.useRef)(34);
|
|
55
|
+
(0, _ahooks.useIsomorphicLayoutEffect)(() => {
|
|
56
|
+
const dummyItem = dummyItemRef.current;
|
|
57
|
+
if (!dummyItem) return;
|
|
58
|
+
const rect = dummyItem.getBoundingClientRect();
|
|
59
|
+
|
|
60
|
+
if (rect.height > 0) {
|
|
61
|
+
itemHeight.current = rect.height;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
54
64
|
(0, _ahooks.useIsomorphicLayoutEffect)(() => {
|
|
55
65
|
if (draggingRef.current) return;
|
|
56
66
|
if (!value) return;
|
|
57
67
|
const targetIndex = column.findIndex(item => item.value === value);
|
|
58
68
|
if (targetIndex < 0) return;
|
|
59
|
-
const finalPosition = targetIndex * -itemHeight;
|
|
69
|
+
const finalPosition = targetIndex * -itemHeight.current;
|
|
60
70
|
api.start({
|
|
61
71
|
y: finalPosition,
|
|
62
72
|
immediate: y.goal !== finalPosition
|
|
@@ -76,7 +86,7 @@ const Wheel = (0, _react.memo)(props => {
|
|
|
76
86
|
}, [column, value]);
|
|
77
87
|
|
|
78
88
|
function scrollSelect(index) {
|
|
79
|
-
const finalPosition = index * -itemHeight;
|
|
89
|
+
const finalPosition = index * -itemHeight.current;
|
|
80
90
|
api.start({
|
|
81
91
|
y: finalPosition
|
|
82
92
|
});
|
|
@@ -87,18 +97,18 @@ const Wheel = (0, _react.memo)(props => {
|
|
|
87
97
|
|
|
88
98
|
const bind = (0, _react2.useDrag)(state => {
|
|
89
99
|
draggingRef.current = true;
|
|
90
|
-
const min = -((column.length - 1) * itemHeight);
|
|
100
|
+
const min = -((column.length - 1) * itemHeight.current);
|
|
91
101
|
const max = 0;
|
|
92
102
|
|
|
93
103
|
if (state.last) {
|
|
94
104
|
draggingRef.current = false;
|
|
95
105
|
const position = state.offset[1] + state.velocity[1] * state.direction[1] * 50;
|
|
96
|
-
const targetIndex = min < max ? -Math.round((0, _bound.bound)(position, min, max) / itemHeight) : 0;
|
|
106
|
+
const targetIndex = min < max ? -Math.round((0, _bound.bound)(position, min, max) / itemHeight.current) : 0;
|
|
97
107
|
scrollSelect(targetIndex);
|
|
98
108
|
} else {
|
|
99
109
|
const position = state.offset[1];
|
|
100
110
|
api.start({
|
|
101
|
-
y: (0, _rubberband.rubberbandIfOutOfBounds)(position, min, max, itemHeight * 50, 0.2)
|
|
111
|
+
y: (0, _rubberband.rubberbandIfOutOfBounds)(position, min, max, itemHeight.current * 50, 0.2)
|
|
102
112
|
});
|
|
103
113
|
}
|
|
104
114
|
}, {
|
|
@@ -146,7 +156,11 @@ const Wheel = (0, _react.memo)(props => {
|
|
|
146
156
|
|
|
147
157
|
return _react.default.createElement("div", Object.assign({
|
|
148
158
|
className: `${classPrefix}-column`
|
|
149
|
-
}, bind()), _react.default.createElement(
|
|
159
|
+
}, bind()), _react.default.createElement("div", {
|
|
160
|
+
ref: dummyItemRef,
|
|
161
|
+
className: (0, _classnames.default)(`${classPrefix}-column-item`, `${classPrefix}-column-item-dummy`),
|
|
162
|
+
"aria-hidden": true
|
|
163
|
+
}), _react.default.createElement(_web.animated.div, {
|
|
150
164
|
style: {
|
|
151
165
|
translateY: y
|
|
152
166
|
},
|
|
@@ -27,12 +27,13 @@
|
|
|
27
27
|
}
|
|
28
28
|
.adm-slider-tick {
|
|
29
29
|
position: absolute;
|
|
30
|
-
top:
|
|
30
|
+
top: 50%;
|
|
31
31
|
width: 11px;
|
|
32
32
|
height: 11px;
|
|
33
33
|
margin-left: -5px;
|
|
34
34
|
background-color: #f5f5f5;
|
|
35
35
|
border-radius: 50%;
|
|
36
|
+
transform: translate(0, -50%);
|
|
36
37
|
}
|
|
37
38
|
.adm-slider-tick-active {
|
|
38
39
|
background-color: var(--fill-color);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { ToastProps } from './toast';
|
|
2
2
|
export declare type ToastShowProps = Omit<ToastProps, 'visible'>;
|
|
3
|
-
export declare
|
|
3
|
+
export declare type ToastHandler = {
|
|
4
|
+
close: () => void;
|
|
5
|
+
};
|
|
6
|
+
export declare function show(p: ToastShowProps | string): ToastHandler;
|
|
4
7
|
export declare function clear(): void;
|
|
5
8
|
export declare function config(val: Pick<ToastProps, 'duration' | 'position' | 'maskClickable'>): void;
|
|
@@ -52,8 +52,7 @@ function show(p) {
|
|
|
52
52
|
bodyContainer.appendChild(container);
|
|
53
53
|
clear();
|
|
54
54
|
containers.push(container);
|
|
55
|
-
|
|
56
|
-
const TempToast = () => {
|
|
55
|
+
const TempToast = (0, _react.forwardRef)((_, ref) => {
|
|
57
56
|
const [visible, setVisible] = (0, _react.useState)(true);
|
|
58
57
|
(0, _react.useEffect)(() => {
|
|
59
58
|
return () => {
|
|
@@ -74,6 +73,9 @@ function show(p) {
|
|
|
74
73
|
window.clearTimeout(timer);
|
|
75
74
|
};
|
|
76
75
|
}, []);
|
|
76
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
77
|
+
close: () => setVisible(false)
|
|
78
|
+
}));
|
|
77
79
|
return _react.default.createElement(_toast.InternalToast, Object.assign({}, props, {
|
|
78
80
|
getContainer: () => container,
|
|
79
81
|
visible: visible,
|
|
@@ -81,9 +83,20 @@ function show(p) {
|
|
|
81
83
|
unmount(container);
|
|
82
84
|
}
|
|
83
85
|
}));
|
|
84
|
-
};
|
|
86
|
+
});
|
|
87
|
+
const ref = (0, _react.createRef)();
|
|
85
88
|
|
|
86
|
-
_reactDom.default.render(_react.default.createElement(TempToast,
|
|
89
|
+
_reactDom.default.render(_react.default.createElement(TempToast, {
|
|
90
|
+
ref: ref
|
|
91
|
+
}), container);
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
close: () => {
|
|
95
|
+
var _a;
|
|
96
|
+
|
|
97
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
87
100
|
}
|
|
88
101
|
|
|
89
102
|
function clear() {
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const useDragAndPinch: <Config extends import("@use-gesture/react").UserGestureConfig = import("@use-gesture/react").UserGestureConfig>(_handlers: Partial<import("@use-gesture/react").NativeHandlers<import("@use-gesture/react").EventTypes> & import("@use-gesture/react").UserHandlers<import("@use-gesture/react").EventTypes>>, _config?: {} | Config | undefined) => Config["target"] extends object ? void : (...args: any[]) => Pick<import("react").DOMAttributes<EventTarget>, "onClick" | "onChange" | "onPause" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDragCapture" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScrollCapture" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture">;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useDragAndPinch = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("@use-gesture/react");
|
|
9
|
+
|
|
10
|
+
const useDragAndPinch = (0, _react.createUseGesture)([_react.dragAction, _react.pinchAction]);
|
|
11
|
+
exports.useDragAndPinch = useDragAndPinch;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useIsomorphicUpdateLayoutEffect = void 0;
|
|
7
|
+
|
|
8
|
+
var _createUpdateEffect = require("ahooks/lib/createUpdateEffect");
|
|
9
|
+
|
|
10
|
+
var _ahooks = require("ahooks");
|
|
11
|
+
|
|
12
|
+
const useIsomorphicUpdateLayoutEffect = (0, _createUpdateEffect.createUpdateEffect)(_ahooks.useIsomorphicLayoutEffect);
|
|
13
|
+
exports.useIsomorphicUpdateLayoutEffect = useIsomorphicUpdateLayoutEffect;
|
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
background: var(--adm-color-white);
|
|
8
8
|
position: fixed;
|
|
9
9
|
z-index: var(--z-index);
|
|
10
|
-
|
|
10
|
+
bottom: 0;
|
|
11
11
|
left: 0;
|
|
12
12
|
width: 100vw;
|
|
13
13
|
display: flex;
|
|
14
14
|
flex-direction: column;
|
|
15
|
+
touch-action: none;
|
|
15
16
|
}
|
|
16
17
|
.adm-floating-panel-mask {
|
|
17
18
|
display: block;
|
|
@@ -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>>;
|
|
@@ -6,11 +6,12 @@ import { supportsPassive } from '../../utils/supports-passive';
|
|
|
6
6
|
import { nearest } from '../../utils/nearest';
|
|
7
7
|
import { mergeProps } from '../../utils/with-default-props';
|
|
8
8
|
import { useLockScroll } from '../../utils/use-lock-scroll';
|
|
9
|
+
import { useMemoizedFn } from 'ahooks';
|
|
9
10
|
const defaultProps = {
|
|
10
11
|
handleDraggingOfContent: true
|
|
11
12
|
};
|
|
12
13
|
export const FloatingPanel = forwardRef((p, ref) => {
|
|
13
|
-
var _a;
|
|
14
|
+
var _a, _b;
|
|
14
15
|
|
|
15
16
|
const props = mergeProps(defaultProps, p);
|
|
16
17
|
const {
|
|
@@ -27,6 +28,7 @@ export const FloatingPanel = forwardRef((p, ref) => {
|
|
|
27
28
|
top: possibles[possibles.length - 1],
|
|
28
29
|
bottom: possibles[0]
|
|
29
30
|
};
|
|
31
|
+
const onHeightChange = useMemoizedFn((_b = props.onHeightChange) !== null && _b !== void 0 ? _b : () => {});
|
|
30
32
|
const [{
|
|
31
33
|
y
|
|
32
34
|
}, api] = useSpring(() => ({
|
|
@@ -35,9 +37,7 @@ export const FloatingPanel = forwardRef((p, ref) => {
|
|
|
35
37
|
tension: 300
|
|
36
38
|
},
|
|
37
39
|
onChange: result => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
(_a = props.onHeightChange) === null || _a === void 0 ? void 0 : _a.call(props, result.value.y, y.isAnimating);
|
|
40
|
+
onHeightChange(result.value.y, y.isAnimating);
|
|
41
41
|
}
|
|
42
42
|
}));
|
|
43
43
|
useDrag(state => {
|
|
@@ -114,7 +114,7 @@ export const FloatingPanel = forwardRef((p, ref) => {
|
|
|
114
114
|
className: 'adm-floating-panel',
|
|
115
115
|
style: {
|
|
116
116
|
height: maxHeight,
|
|
117
|
-
y
|
|
117
|
+
translateY: y.to(y => `calc(100% + (${y}px))`)
|
|
118
118
|
}
|
|
119
119
|
}, React.createElement("div", {
|
|
120
120
|
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,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Form from '.';
|
|
3
|
+
export const FormSubscribe = ({
|
|
4
|
+
children,
|
|
5
|
+
to
|
|
6
|
+
}) => {
|
|
7
|
+
return React.createElement(Form.Item, {
|
|
8
|
+
noStyle: true,
|
|
9
|
+
dependencies: to
|
|
10
|
+
}, form => {
|
|
11
|
+
const changedValues = form.getFieldsValue(to);
|
|
12
|
+
return children(changedValues, form);
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -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
|
};
|
|
@@ -4,8 +4,10 @@ import { attachPropertiesToComponent } from '../../utils/attach-properties-to-co
|
|
|
4
4
|
import { FormItem } from './form-item';
|
|
5
5
|
import { Header } from './header';
|
|
6
6
|
import { useForm } from 'rc-field-form';
|
|
7
|
+
import { FormSubscribe } from './form-subscribe';
|
|
7
8
|
export default attachPropertiesToComponent(Form, {
|
|
8
9
|
Item: FormItem,
|
|
10
|
+
Subscribe: FormSubscribe,
|
|
9
11
|
Header,
|
|
10
12
|
useForm
|
|
11
13
|
});
|
|
@@ -5,7 +5,7 @@ import { PictureOutline, PictureWrongOutline } from 'antd-mobile-icons';
|
|
|
5
5
|
import { staged } from 'staged-components';
|
|
6
6
|
import { toCSSLength } from '../../utils/to-css-length';
|
|
7
7
|
import { LazyDetector } from './lazy-detector';
|
|
8
|
-
import {
|
|
8
|
+
import { useIsomorphicUpdateLayoutEffect } from '../../utils/use-isomorphic-update-layout-effect';
|
|
9
9
|
const classPrefix = `adm-image`;
|
|
10
10
|
const defaultProps = {
|
|
11
11
|
fit: 'fill',
|
|
@@ -27,7 +27,7 @@ export const Image = staged(p => {
|
|
|
27
27
|
const [initialized, setInitialized] = useState(!props.lazy);
|
|
28
28
|
src = initialized ? props.src : undefined;
|
|
29
29
|
srcSet = initialized ? props.srcSet : undefined;
|
|
30
|
-
|
|
30
|
+
useIsomorphicUpdateLayoutEffect(() => {
|
|
31
31
|
setLoaded(false);
|
|
32
32
|
setFailed(false);
|
|
33
33
|
}, [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>;
|
|
@@ -17,7 +17,8 @@ const defaultProps = {
|
|
|
17
17
|
maxCount: 0,
|
|
18
18
|
defaultValue: [],
|
|
19
19
|
accept: 'image/*',
|
|
20
|
-
preview: true
|
|
20
|
+
preview: true,
|
|
21
|
+
showFailed: true
|
|
21
22
|
};
|
|
22
23
|
export const ImageUploader = p => {
|
|
23
24
|
const props = mergeProps(defaultProps, p);
|
|
@@ -154,15 +155,21 @@ export const ImageUploader = p => {
|
|
|
154
155
|
setValue(value.filter((x, i) => i !== index));
|
|
155
156
|
})
|
|
156
157
|
});
|
|
157
|
-
}), tasks.map(task =>
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
deletable: task.status !== 'pending',
|
|
161
|
-
status: task.status,
|
|
162
|
-
onDelete: () => {
|
|
163
|
-
setTasks(tasks.filter(x => x.id !== task.id));
|
|
158
|
+
}), tasks.map(task => {
|
|
159
|
+
if (!props.showFailed && task.status === 'fail') {
|
|
160
|
+
return null;
|
|
164
161
|
}
|
|
165
|
-
|
|
162
|
+
|
|
163
|
+
return React.createElement(PreviewItem, {
|
|
164
|
+
key: task.id,
|
|
165
|
+
file: task.file,
|
|
166
|
+
deletable: task.status !== 'pending',
|
|
167
|
+
status: task.status,
|
|
168
|
+
onDelete: () => {
|
|
169
|
+
setTasks(tasks.filter(x => x.id !== task.id));
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}), showUpload && React.createElement("div", {
|
|
166
173
|
className: `${classPrefix}-upload-button-wrap`
|
|
167
174
|
}, props.children ? props.children : React.createElement("span", {
|
|
168
175
|
className: `${classPrefix}-cell ${classPrefix}-upload-button`,
|