antd-mobile 5.0.0-rc.5 → 5.0.0-rc.6
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/cjs/components/dialog/dialog.d.ts +1 -0
- package/2x/cjs/components/dialog/dialog.js +5 -3
- package/2x/cjs/components/modal/modal.d.ts +1 -0
- package/2x/cjs/components/modal/modal.js +5 -3
- package/2x/cjs/components/picker/picker.js +3 -2
- package/2x/cjs/components/picker-view/column.d.ts +4 -3
- package/2x/cjs/components/picker-view/column.js +23 -10
- package/2x/cjs/components/picker-view/picker-view.css +1 -0
- package/2x/cjs/components/picker-view/picker-view.js +23 -17
- package/2x/cjs/components/progress-bar/progress-bar.css +1 -0
- package/2x/cjs/components/virtual-input/virtual-input.js +1 -3
- package/2x/es/components/dialog/dialog.d.ts +1 -0
- package/2x/es/components/dialog/dialog.js +5 -3
- package/2x/es/components/modal/modal.d.ts +1 -0
- package/2x/es/components/modal/modal.js +5 -3
- package/2x/es/components/picker/picker.js +3 -2
- package/2x/es/components/picker-view/column.d.ts +4 -3
- package/2x/es/components/picker-view/column.js +21 -9
- package/2x/es/components/picker-view/picker-view.css +1 -0
- package/2x/es/components/picker-view/picker-view.js +24 -18
- package/2x/es/components/progress-bar/progress-bar.css +1 -0
- package/2x/es/components/virtual-input/virtual-input.js +1 -3
- package/2x/package.json +2 -2
- package/cjs/components/dialog/dialog.d.ts +1 -0
- package/cjs/components/dialog/dialog.js +5 -3
- package/cjs/components/modal/modal.d.ts +1 -0
- package/cjs/components/modal/modal.js +5 -3
- package/cjs/components/picker/picker.js +3 -2
- package/cjs/components/picker-view/column.d.ts +4 -3
- package/cjs/components/picker-view/column.js +23 -10
- package/cjs/components/picker-view/picker-view.css +1 -0
- package/cjs/components/picker-view/picker-view.js +23 -17
- package/cjs/components/progress-bar/progress-bar.css +1 -0
- package/cjs/components/virtual-input/virtual-input.js +1 -3
- package/es/components/dialog/dialog.d.ts +1 -0
- package/es/components/dialog/dialog.js +5 -3
- package/es/components/modal/modal.d.ts +1 -0
- package/es/components/modal/modal.js +5 -3
- package/es/components/picker/picker.js +3 -2
- package/es/components/picker-view/column.d.ts +4 -3
- package/es/components/picker-view/column.js +21 -9
- package/es/components/picker-view/picker-view.css +1 -0
- package/es/components/picker-view/picker-view.js +24 -18
- package/es/components/progress-bar/progress-bar.css +1 -0
- package/es/components/virtual-input/virtual-input.js +1 -3
- package/package.json +2 -2
- package/umd/antd-mobile.js +1 -1
- package/2x/cjs/utils/memo-with-event-marks.d.ts +0 -2
- package/2x/cjs/utils/memo-with-event-marks.js +0 -23
- package/2x/es/utils/memo-with-event-marks.d.ts +0 -2
- package/2x/es/utils/memo-with-event-marks.js +0 -15
- package/cjs/utils/memo-with-event-marks.d.ts +0 -2
- package/cjs/utils/memo-with-event-marks.js +0 -23
- package/es/utils/memo-with-event-marks.d.ts +0 -2
- package/es/utils/memo-with-event-marks.js +0 -15
|
@@ -5,6 +5,7 @@ import { PropagationEvent } from '../../utils/with-stop-propagation';
|
|
|
5
5
|
import { NativeProps } from '../../utils/native-props';
|
|
6
6
|
export declare type DialogProps = {
|
|
7
7
|
afterClose?: () => void;
|
|
8
|
+
afterShow?: () => void;
|
|
8
9
|
image?: string;
|
|
9
10
|
header?: ReactNode;
|
|
10
11
|
title?: ReactNode;
|
|
@@ -95,13 +95,15 @@ var Dialog = function Dialog(p) {
|
|
|
95
95
|
setActive(true);
|
|
96
96
|
},
|
|
97
97
|
onRest: function onRest() {
|
|
98
|
-
var _a;
|
|
98
|
+
var _a, _b;
|
|
99
99
|
|
|
100
100
|
if (unmountedRef.current) return;
|
|
101
101
|
setActive(props.visible);
|
|
102
102
|
|
|
103
|
-
if (
|
|
104
|
-
(_a = props.
|
|
103
|
+
if (props.visible) {
|
|
104
|
+
(_a = props.afterShow) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
105
|
+
} else {
|
|
106
|
+
(_b = props.afterClose) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
});
|
|
@@ -5,6 +5,7 @@ import { PropagationEvent } from '../../utils/with-stop-propagation';
|
|
|
5
5
|
import { NativeProps } from '../../utils/native-props';
|
|
6
6
|
export declare type ModalProps = {
|
|
7
7
|
afterClose?: () => void;
|
|
8
|
+
afterShow?: () => void;
|
|
8
9
|
image?: string;
|
|
9
10
|
header?: ReactNode;
|
|
10
11
|
title?: ReactNode;
|
|
@@ -95,13 +95,15 @@ var Modal = function Modal(p) {
|
|
|
95
95
|
setActive(true);
|
|
96
96
|
},
|
|
97
97
|
onRest: function onRest() {
|
|
98
|
-
var _a;
|
|
98
|
+
var _a, _b;
|
|
99
99
|
|
|
100
100
|
if (unmountedRef.current) return;
|
|
101
101
|
setActive(props.visible);
|
|
102
102
|
|
|
103
|
-
if (
|
|
104
|
-
(_a = props.
|
|
103
|
+
if (props.visible) {
|
|
104
|
+
(_a = props.afterShow) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
105
|
+
} else {
|
|
106
|
+
(_b = props.afterClose) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
});
|
|
@@ -65,7 +65,7 @@ var Picker = /*#__PURE__*/(0, _react.memo)(function (p) {
|
|
|
65
65
|
setInnerValue = _useState[1];
|
|
66
66
|
|
|
67
67
|
(0, _react.useEffect)(function () {
|
|
68
|
-
if (
|
|
68
|
+
if (innerValue !== value) {
|
|
69
69
|
setInnerValue(value);
|
|
70
70
|
}
|
|
71
71
|
}, [props.visible]);
|
|
@@ -133,4 +133,5 @@ var Picker = /*#__PURE__*/(0, _react.memo)(function (p) {
|
|
|
133
133
|
|
|
134
134
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, popupElement, (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props, generateValueExtend(value).items));
|
|
135
135
|
});
|
|
136
|
-
exports.Picker = Picker;
|
|
136
|
+
exports.Picker = Picker;
|
|
137
|
+
Picker.displayName = 'Picker';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { PickerColumnItem, PickerValue } from './index';
|
|
3
3
|
interface Props {
|
|
4
|
+
index: number;
|
|
4
5
|
column: PickerColumnItem[];
|
|
5
6
|
value: PickerValue;
|
|
6
|
-
onSelect: (value: PickerValue) => void;
|
|
7
|
+
onSelect: (value: PickerValue, index: number) => void;
|
|
7
8
|
}
|
|
8
|
-
export declare const Column:
|
|
9
|
+
export declare const Column: React.NamedExoticComponent<Props>;
|
|
9
10
|
export {};
|
|
@@ -17,18 +17,24 @@ var _rubberband = require("../../utils/rubberband");
|
|
|
17
17
|
|
|
18
18
|
var _bound = require("../../utils/bound");
|
|
19
19
|
|
|
20
|
+
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
|
+
|
|
20
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
25
|
|
|
22
26
|
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; }
|
|
23
27
|
|
|
24
28
|
var classPrefix = "adm-picker-view";
|
|
25
|
-
|
|
26
|
-
var Column = function Column(props) {
|
|
29
|
+
var Column = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
27
30
|
var itemHeight = (0, _convertPx.convertPx)(34);
|
|
28
31
|
var value = props.value,
|
|
29
|
-
onSelect = props.onSelect,
|
|
30
32
|
column = props.column;
|
|
31
33
|
|
|
34
|
+
function onSelect(val) {
|
|
35
|
+
props.onSelect(val, props.index);
|
|
36
|
+
}
|
|
37
|
+
|
|
32
38
|
var _useSpring = (0, _web.useSpring)(function () {
|
|
33
39
|
return {
|
|
34
40
|
from: {
|
|
@@ -54,20 +60,20 @@ var Column = function Column(props) {
|
|
|
54
60
|
var finalPosition = targetIndex * -itemHeight;
|
|
55
61
|
api.start({
|
|
56
62
|
y: finalPosition,
|
|
57
|
-
immediate: y.
|
|
63
|
+
immediate: y.goal !== finalPosition
|
|
58
64
|
});
|
|
59
65
|
}, [value, column]);
|
|
60
66
|
(0, _react.useLayoutEffect)(function () {
|
|
61
67
|
if (column.length === 0) {
|
|
62
68
|
if (value !== null) {
|
|
63
|
-
|
|
69
|
+
onSelect(null);
|
|
64
70
|
}
|
|
65
71
|
} else {
|
|
66
72
|
if (!column.some(function (item) {
|
|
67
73
|
return item.value === value;
|
|
68
74
|
})) {
|
|
69
75
|
var firstItem = column[0];
|
|
70
|
-
|
|
76
|
+
onSelect(firstItem.value);
|
|
71
77
|
}
|
|
72
78
|
}
|
|
73
79
|
}, [column, value]);
|
|
@@ -109,8 +115,6 @@ var Column = function Column(props) {
|
|
|
109
115
|
var selectedIndex = null;
|
|
110
116
|
|
|
111
117
|
function renderAccessible() {
|
|
112
|
-
console.log('selectedIndex', selectedIndex);
|
|
113
|
-
|
|
114
118
|
if (selectedIndex === null) {
|
|
115
119
|
return null;
|
|
116
120
|
}
|
|
@@ -171,6 +175,15 @@ var Column = function Column(props) {
|
|
|
171
175
|
className: classPrefix + "-column-item-label"
|
|
172
176
|
}, item.label));
|
|
173
177
|
})), renderAccessible());
|
|
174
|
-
}
|
|
178
|
+
}, function (prev, next) {
|
|
179
|
+
if (prev.value !== next.value) return false;
|
|
180
|
+
if (prev.onSelect !== next.onSelect) return false;
|
|
181
|
+
|
|
182
|
+
if (!(0, _isEqual["default"])(prev.column, next.column)) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
175
185
|
|
|
176
|
-
|
|
186
|
+
return true;
|
|
187
|
+
});
|
|
188
|
+
exports.Column = Column;
|
|
189
|
+
Column.displayName = 'Column';
|
|
@@ -50,31 +50,36 @@ var PickerView = /*#__PURE__*/(0, _react.memo)(function (p) {
|
|
|
50
50
|
|
|
51
51
|
if (props.value === innerValue) return;
|
|
52
52
|
setInnerValue(props.value);
|
|
53
|
-
}, [props.value]);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
}, [props.value]);
|
|
54
|
+
(0, _react.useEffect)(function () {
|
|
55
|
+
if (props.value === innerValue) return;
|
|
56
|
+
var timeout = window.setTimeout(function () {
|
|
57
|
+
if (props.value !== undefined && props.value !== innerValue) {
|
|
58
|
+
setInnerValue(props.value);
|
|
59
|
+
}
|
|
60
|
+
}, 1000);
|
|
61
|
+
return function () {
|
|
62
|
+
window.clearTimeout(timeout);
|
|
63
|
+
};
|
|
64
|
+
}, [props.value, innerValue]);
|
|
64
65
|
var columns = (0, _useColumns.useColumns)(props.columns, innerValue);
|
|
65
66
|
var generateValueExtend = (0, _usePickerValueExtend.usePickerValueExtend)(columns);
|
|
67
|
+
var handleSelect = (0, _react.useCallback)(function (val, index) {
|
|
68
|
+
setInnerValue(function (prev) {
|
|
69
|
+
var next = [].concat(prev);
|
|
70
|
+
next[index] = val;
|
|
71
|
+
return next;
|
|
72
|
+
});
|
|
73
|
+
}, []);
|
|
66
74
|
return (0, _nativeProps.withNativeProps)(props, /*#__PURE__*/_react["default"].createElement("div", {
|
|
67
75
|
className: "" + classPrefix
|
|
68
76
|
}, columns.map(function (column, index) {
|
|
69
77
|
return /*#__PURE__*/_react["default"].createElement(_column.Column, {
|
|
70
78
|
key: index,
|
|
79
|
+
index: index,
|
|
71
80
|
column: column,
|
|
72
81
|
value: innerValue[index],
|
|
73
|
-
onSelect:
|
|
74
|
-
var nextInnerValue = [].concat(innerValue);
|
|
75
|
-
nextInnerValue[index] = val;
|
|
76
|
-
setInnerValue(nextInnerValue);
|
|
77
|
-
}
|
|
82
|
+
onSelect: handleSelect
|
|
78
83
|
});
|
|
79
84
|
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
80
85
|
className: classPrefix + "-mask"
|
|
@@ -86,4 +91,5 @@ var PickerView = /*#__PURE__*/(0, _react.memo)(function (p) {
|
|
|
86
91
|
className: classPrefix + "-mask-bottom"
|
|
87
92
|
}))));
|
|
88
93
|
});
|
|
89
|
-
exports.PickerView = PickerView;
|
|
94
|
+
exports.PickerView = PickerView;
|
|
95
|
+
PickerView.displayName = 'PickerView';
|
|
@@ -53,9 +53,7 @@ var VirtualInput = /*#__PURE__*/(0, _react.forwardRef)(function (p, ref) {
|
|
|
53
53
|
|
|
54
54
|
var content = contentRef.current;
|
|
55
55
|
if (!content) return;
|
|
56
|
-
content.
|
|
57
|
-
left: content.clientWidth
|
|
58
|
-
});
|
|
56
|
+
content.scrollLeft = content.clientWidth;
|
|
59
57
|
}
|
|
60
58
|
|
|
61
59
|
(0, _react.useLayoutEffect)(function () {
|
|
@@ -5,6 +5,7 @@ import { PropagationEvent } from '../../utils/with-stop-propagation';
|
|
|
5
5
|
import { NativeProps } from '../../utils/native-props';
|
|
6
6
|
export declare type DialogProps = {
|
|
7
7
|
afterClose?: () => void;
|
|
8
|
+
afterShow?: () => void;
|
|
8
9
|
image?: string;
|
|
9
10
|
header?: ReactNode;
|
|
10
11
|
title?: ReactNode;
|
|
@@ -68,13 +68,15 @@ export var Dialog = function Dialog(p) {
|
|
|
68
68
|
setActive(true);
|
|
69
69
|
},
|
|
70
70
|
onRest: function onRest() {
|
|
71
|
-
var _a;
|
|
71
|
+
var _a, _b;
|
|
72
72
|
|
|
73
73
|
if (unmountedRef.current) return;
|
|
74
74
|
setActive(props.visible);
|
|
75
75
|
|
|
76
|
-
if (
|
|
77
|
-
(_a = props.
|
|
76
|
+
if (props.visible) {
|
|
77
|
+
(_a = props.afterShow) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
78
|
+
} else {
|
|
79
|
+
(_b = props.afterClose) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
});
|
|
@@ -5,6 +5,7 @@ import { PropagationEvent } from '../../utils/with-stop-propagation';
|
|
|
5
5
|
import { NativeProps } from '../../utils/native-props';
|
|
6
6
|
export declare type ModalProps = {
|
|
7
7
|
afterClose?: () => void;
|
|
8
|
+
afterShow?: () => void;
|
|
8
9
|
image?: string;
|
|
9
10
|
header?: ReactNode;
|
|
10
11
|
title?: ReactNode;
|
|
@@ -68,13 +68,15 @@ export var Modal = function Modal(p) {
|
|
|
68
68
|
setActive(true);
|
|
69
69
|
},
|
|
70
70
|
onRest: function onRest() {
|
|
71
|
-
var _a;
|
|
71
|
+
var _a, _b;
|
|
72
72
|
|
|
73
73
|
if (unmountedRef.current) return;
|
|
74
74
|
setActive(props.visible);
|
|
75
75
|
|
|
76
|
-
if (
|
|
77
|
-
(_a = props.
|
|
76
|
+
if (props.visible) {
|
|
77
|
+
(_a = props.afterShow) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
78
|
+
} else {
|
|
79
|
+
(_b = props.afterClose) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
});
|
|
@@ -42,7 +42,7 @@ export var Picker = /*#__PURE__*/memo(function (p) {
|
|
|
42
42
|
setInnerValue = _useState[1];
|
|
43
43
|
|
|
44
44
|
useEffect(function () {
|
|
45
|
-
if (
|
|
45
|
+
if (innerValue !== value) {
|
|
46
46
|
setInnerValue(value);
|
|
47
47
|
}
|
|
48
48
|
}, [props.visible]);
|
|
@@ -107,4 +107,5 @@ export var Picker = /*#__PURE__*/memo(function (p) {
|
|
|
107
107
|
stopPropagation: props.stopPropagation
|
|
108
108
|
}, pickerElement);
|
|
109
109
|
return /*#__PURE__*/React.createElement(React.Fragment, null, popupElement, (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props, generateValueExtend(value).items));
|
|
110
|
-
});
|
|
110
|
+
});
|
|
111
|
+
Picker.displayName = 'Picker';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { PickerColumnItem, PickerValue } from './index';
|
|
3
3
|
interface Props {
|
|
4
|
+
index: number;
|
|
4
5
|
column: PickerColumnItem[];
|
|
5
6
|
value: PickerValue;
|
|
6
|
-
onSelect: (value: PickerValue) => void;
|
|
7
|
+
onSelect: (value: PickerValue, index: number) => void;
|
|
7
8
|
}
|
|
8
|
-
export declare const Column:
|
|
9
|
+
export declare const Column: React.NamedExoticComponent<Props>;
|
|
9
10
|
export {};
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import React, { useLayoutEffect, useRef } from 'react';
|
|
1
|
+
import React, { memo, useLayoutEffect, useRef } from 'react';
|
|
2
2
|
import { useSpring, animated } from '@react-spring/web';
|
|
3
3
|
import { useDrag } from '@use-gesture/react';
|
|
4
4
|
import { convertPx } from '../../utils/convert-px';
|
|
5
5
|
import { rubberbandIfOutOfBounds } from '../../utils/rubberband';
|
|
6
6
|
import { bound } from '../../utils/bound';
|
|
7
|
+
import isEqual from 'lodash/isEqual';
|
|
7
8
|
var classPrefix = "adm-picker-view";
|
|
8
|
-
export var Column = function
|
|
9
|
+
export var Column = /*#__PURE__*/memo(function (props) {
|
|
9
10
|
var itemHeight = convertPx(34);
|
|
10
11
|
var value = props.value,
|
|
11
|
-
onSelect = props.onSelect,
|
|
12
12
|
column = props.column;
|
|
13
13
|
|
|
14
|
+
function onSelect(val) {
|
|
15
|
+
props.onSelect(val, props.index);
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
var _useSpring = useSpring(function () {
|
|
15
19
|
return {
|
|
16
20
|
from: {
|
|
@@ -36,20 +40,20 @@ export var Column = function Column(props) {
|
|
|
36
40
|
var finalPosition = targetIndex * -itemHeight;
|
|
37
41
|
api.start({
|
|
38
42
|
y: finalPosition,
|
|
39
|
-
immediate: y.
|
|
43
|
+
immediate: y.goal !== finalPosition
|
|
40
44
|
});
|
|
41
45
|
}, [value, column]);
|
|
42
46
|
useLayoutEffect(function () {
|
|
43
47
|
if (column.length === 0) {
|
|
44
48
|
if (value !== null) {
|
|
45
|
-
|
|
49
|
+
onSelect(null);
|
|
46
50
|
}
|
|
47
51
|
} else {
|
|
48
52
|
if (!column.some(function (item) {
|
|
49
53
|
return item.value === value;
|
|
50
54
|
})) {
|
|
51
55
|
var firstItem = column[0];
|
|
52
|
-
|
|
56
|
+
onSelect(firstItem.value);
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
59
|
}, [column, value]);
|
|
@@ -91,8 +95,6 @@ export var Column = function Column(props) {
|
|
|
91
95
|
var selectedIndex = null;
|
|
92
96
|
|
|
93
97
|
function renderAccessible() {
|
|
94
|
-
console.log('selectedIndex', selectedIndex);
|
|
95
|
-
|
|
96
98
|
if (selectedIndex === null) {
|
|
97
99
|
return null;
|
|
98
100
|
}
|
|
@@ -153,4 +155,14 @@ export var Column = function Column(props) {
|
|
|
153
155
|
className: classPrefix + "-column-item-label"
|
|
154
156
|
}, item.label));
|
|
155
157
|
})), renderAccessible());
|
|
156
|
-
}
|
|
158
|
+
}, function (prev, next) {
|
|
159
|
+
if (prev.value !== next.value) return false;
|
|
160
|
+
if (prev.onSelect !== next.onSelect) return false;
|
|
161
|
+
|
|
162
|
+
if (!isEqual(prev.column, next.column)) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return true;
|
|
167
|
+
});
|
|
168
|
+
Column.displayName = 'Column';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { memo, useEffect, useState } from 'react';
|
|
1
|
+
import React, { memo, useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { mergeProps } from '../../utils/with-default-props';
|
|
3
3
|
import { Column } from './column';
|
|
4
4
|
import { useColumns } from './use-columns';
|
|
@@ -32,31 +32,36 @@ export var PickerView = /*#__PURE__*/memo(function (p) {
|
|
|
32
32
|
|
|
33
33
|
if (props.value === innerValue) return;
|
|
34
34
|
setInnerValue(props.value);
|
|
35
|
-
}, [props.value]);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
}, [props.value]);
|
|
36
|
+
useEffect(function () {
|
|
37
|
+
if (props.value === innerValue) return;
|
|
38
|
+
var timeout = window.setTimeout(function () {
|
|
39
|
+
if (props.value !== undefined && props.value !== innerValue) {
|
|
40
|
+
setInnerValue(props.value);
|
|
41
|
+
}
|
|
42
|
+
}, 1000);
|
|
43
|
+
return function () {
|
|
44
|
+
window.clearTimeout(timeout);
|
|
45
|
+
};
|
|
46
|
+
}, [props.value, innerValue]);
|
|
46
47
|
var columns = useColumns(props.columns, innerValue);
|
|
47
48
|
var generateValueExtend = usePickerValueExtend(columns);
|
|
49
|
+
var handleSelect = useCallback(function (val, index) {
|
|
50
|
+
setInnerValue(function (prev) {
|
|
51
|
+
var next = [].concat(prev);
|
|
52
|
+
next[index] = val;
|
|
53
|
+
return next;
|
|
54
|
+
});
|
|
55
|
+
}, []);
|
|
48
56
|
return withNativeProps(props, /*#__PURE__*/React.createElement("div", {
|
|
49
57
|
className: "" + classPrefix
|
|
50
58
|
}, columns.map(function (column, index) {
|
|
51
59
|
return /*#__PURE__*/React.createElement(Column, {
|
|
52
60
|
key: index,
|
|
61
|
+
index: index,
|
|
53
62
|
column: column,
|
|
54
63
|
value: innerValue[index],
|
|
55
|
-
onSelect:
|
|
56
|
-
var nextInnerValue = [].concat(innerValue);
|
|
57
|
-
nextInnerValue[index] = val;
|
|
58
|
-
setInnerValue(nextInnerValue);
|
|
59
|
-
}
|
|
64
|
+
onSelect: handleSelect
|
|
60
65
|
});
|
|
61
66
|
}), /*#__PURE__*/React.createElement("div", {
|
|
62
67
|
className: classPrefix + "-mask"
|
|
@@ -67,4 +72,5 @@ export var PickerView = /*#__PURE__*/memo(function (p) {
|
|
|
67
72
|
}), /*#__PURE__*/React.createElement("div", {
|
|
68
73
|
className: classPrefix + "-mask-bottom"
|
|
69
74
|
}))));
|
|
70
|
-
});
|
|
75
|
+
});
|
|
76
|
+
PickerView.displayName = 'PickerView';
|
|
@@ -34,9 +34,7 @@ export var VirtualInput = /*#__PURE__*/forwardRef(function (p, ref) {
|
|
|
34
34
|
|
|
35
35
|
var content = contentRef.current;
|
|
36
36
|
if (!content) return;
|
|
37
|
-
content.
|
|
38
|
-
left: content.clientWidth
|
|
39
|
-
});
|
|
37
|
+
content.scrollLeft = content.clientWidth;
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
useLayoutEffect(function () {
|
package/2x/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antd-mobile",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.6",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@react-spring/web": "^9.3.1",
|
|
6
6
|
"@types/resize-observer-browser": "^0.1.6",
|
|
7
|
-
"@use-gesture/react": "^10.2.
|
|
7
|
+
"@use-gesture/react": "^10.2.4",
|
|
8
8
|
"ahooks": "^2.10.14",
|
|
9
9
|
"antd-mobile-icons": "^0.2.2",
|
|
10
10
|
"antd-mobile-v5-count": "^1.0.1",
|
|
@@ -5,6 +5,7 @@ import { PropagationEvent } from '../../utils/with-stop-propagation';
|
|
|
5
5
|
import { NativeProps } from '../../utils/native-props';
|
|
6
6
|
export declare type DialogProps = {
|
|
7
7
|
afterClose?: () => void;
|
|
8
|
+
afterShow?: () => void;
|
|
8
9
|
image?: string;
|
|
9
10
|
header?: ReactNode;
|
|
10
11
|
title?: ReactNode;
|
|
@@ -95,13 +95,15 @@ var Dialog = function Dialog(p) {
|
|
|
95
95
|
setActive(true);
|
|
96
96
|
},
|
|
97
97
|
onRest: function onRest() {
|
|
98
|
-
var _a;
|
|
98
|
+
var _a, _b;
|
|
99
99
|
|
|
100
100
|
if (unmountedRef.current) return;
|
|
101
101
|
setActive(props.visible);
|
|
102
102
|
|
|
103
|
-
if (
|
|
104
|
-
(_a = props.
|
|
103
|
+
if (props.visible) {
|
|
104
|
+
(_a = props.afterShow) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
105
|
+
} else {
|
|
106
|
+
(_b = props.afterClose) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
});
|
|
@@ -5,6 +5,7 @@ import { PropagationEvent } from '../../utils/with-stop-propagation';
|
|
|
5
5
|
import { NativeProps } from '../../utils/native-props';
|
|
6
6
|
export declare type ModalProps = {
|
|
7
7
|
afterClose?: () => void;
|
|
8
|
+
afterShow?: () => void;
|
|
8
9
|
image?: string;
|
|
9
10
|
header?: ReactNode;
|
|
10
11
|
title?: ReactNode;
|
|
@@ -95,13 +95,15 @@ var Modal = function Modal(p) {
|
|
|
95
95
|
setActive(true);
|
|
96
96
|
},
|
|
97
97
|
onRest: function onRest() {
|
|
98
|
-
var _a;
|
|
98
|
+
var _a, _b;
|
|
99
99
|
|
|
100
100
|
if (unmountedRef.current) return;
|
|
101
101
|
setActive(props.visible);
|
|
102
102
|
|
|
103
|
-
if (
|
|
104
|
-
(_a = props.
|
|
103
|
+
if (props.visible) {
|
|
104
|
+
(_a = props.afterShow) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
105
|
+
} else {
|
|
106
|
+
(_b = props.afterClose) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
});
|
|
@@ -65,7 +65,7 @@ var Picker = /*#__PURE__*/(0, _react.memo)(function (p) {
|
|
|
65
65
|
setInnerValue = _useState[1];
|
|
66
66
|
|
|
67
67
|
(0, _react.useEffect)(function () {
|
|
68
|
-
if (
|
|
68
|
+
if (innerValue !== value) {
|
|
69
69
|
setInnerValue(value);
|
|
70
70
|
}
|
|
71
71
|
}, [props.visible]);
|
|
@@ -133,4 +133,5 @@ var Picker = /*#__PURE__*/(0, _react.memo)(function (p) {
|
|
|
133
133
|
|
|
134
134
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, popupElement, (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props, generateValueExtend(value).items));
|
|
135
135
|
});
|
|
136
|
-
exports.Picker = Picker;
|
|
136
|
+
exports.Picker = Picker;
|
|
137
|
+
Picker.displayName = 'Picker';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { PickerColumnItem, PickerValue } from './index';
|
|
3
3
|
interface Props {
|
|
4
|
+
index: number;
|
|
4
5
|
column: PickerColumnItem[];
|
|
5
6
|
value: PickerValue;
|
|
6
|
-
onSelect: (value: PickerValue) => void;
|
|
7
|
+
onSelect: (value: PickerValue, index: number) => void;
|
|
7
8
|
}
|
|
8
|
-
export declare const Column:
|
|
9
|
+
export declare const Column: React.NamedExoticComponent<Props>;
|
|
9
10
|
export {};
|