antd-mobile 5.4.0 → 5.6.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/cjs/components/action-sheet/action-sheet.d.ts +5 -5
- package/2x/cjs/components/action-sheet/action-sheet.js +6 -46
- package/2x/cjs/components/action-sheet/index.d.ts +1 -1
- package/2x/cjs/components/badge/badge.js +1 -1
- package/2x/cjs/components/cascader-view/cascader-view.d.ts +1 -0
- package/2x/cjs/components/cascader-view/cascader-view.js +7 -0
- package/2x/cjs/components/cascader-view/use-cascader-value-extend.js +23 -0
- package/2x/cjs/components/check-list/check-list-item.js +1 -1
- package/2x/cjs/components/checkbox/checkbox.js +4 -8
- package/2x/cjs/components/checkbox/native-input.d.ts +10 -0
- package/2x/cjs/components/checkbox/native-input.js +42 -0
- package/2x/cjs/components/dialog/index.d.ts +1 -1
- package/2x/cjs/components/dialog/show.d.ts +2 -4
- package/2x/cjs/components/dialog/show.js +9 -47
- package/2x/cjs/components/dot-loading/dot-loading.js +1 -2
- package/2x/cjs/components/error-block/error-block.js +4 -2
- package/2x/cjs/components/floating-bubble/floating-bubble.css +2 -1
- package/2x/cjs/components/floating-bubble/floating-bubble.d.ts +1 -1
- package/2x/cjs/components/floating-bubble/floating-bubble.js +14 -5
- package/2x/cjs/components/form/form-array.d.ts +19 -0
- package/2x/cjs/components/form/form-array.js +52 -0
- package/2x/cjs/components/form/form-item.css +6 -1
- package/2x/cjs/components/form/form-item.js +24 -8
- package/2x/cjs/components/form/form.css +5 -0
- package/2x/cjs/components/form/form.js +16 -5
- package/2x/cjs/components/form/index.css +11 -1
- package/2x/cjs/components/form/index.d.ts +2 -0
- package/2x/cjs/components/form/index.js +3 -0
- package/2x/cjs/components/image-uploader/image-uploader.d.ts +1 -1
- package/2x/cjs/components/image-uploader/image-uploader.js +17 -1
- package/2x/cjs/components/image-viewer/index.d.ts +1 -1
- package/2x/cjs/components/image-viewer/methods.d.ts +3 -4
- package/2x/cjs/components/image-viewer/methods.js +41 -56
- package/2x/cjs/components/modal/index.d.ts +1 -1
- package/2x/cjs/components/modal/show.d.ts +2 -4
- package/2x/cjs/components/modal/show.js +9 -47
- package/2x/cjs/components/popover/index.d.ts +7 -2
- package/2x/cjs/components/popover/normalize-placement.d.ts +2 -0
- package/2x/cjs/components/popover/normalize-placement.js +22 -0
- package/2x/cjs/components/popover/popover.css +0 -104
- package/2x/cjs/components/popover/popover.d.ts +11 -5
- package/2x/cjs/components/popover/popover.js +127 -22
- package/2x/cjs/components/popover/temp-floating-ui.min.d.ts +1 -0
- package/2x/cjs/components/popover/temp-floating-ui.min.js +1 -0
- package/2x/cjs/components/popover/wrapper.d.ts +7 -0
- package/2x/cjs/components/popover/wrapper.js +41 -0
- package/2x/cjs/components/pull-to-refresh/pull-to-refresh.js +24 -9
- package/2x/cjs/components/radio/radio.js +4 -8
- package/2x/cjs/components/search-bar/search-bar.d.ts +1 -1
- package/2x/cjs/components/tab-bar/tab-bar.d.ts +1 -1
- package/2x/cjs/components/tab-bar/tab-bar.js +1 -1
- package/2x/cjs/components/tree-select/tree-select.js +2 -2
- package/2x/cjs/utils/render-imperatively.d.ts +10 -0
- package/2x/cjs/utils/render-imperatively.js +58 -0
- package/2x/cjs/utils/use-props-value.d.ts +2 -1
- package/2x/cjs/utils/use-props-value.js +4 -2
- package/2x/es/components/action-sheet/action-sheet.d.ts +5 -5
- package/2x/es/components/action-sheet/action-sheet.js +5 -41
- package/2x/es/components/action-sheet/index.d.ts +1 -1
- package/2x/es/components/badge/badge.js +1 -1
- package/2x/es/components/cascader-view/cascader-view.d.ts +1 -0
- package/2x/es/components/cascader-view/cascader-view.js +7 -0
- package/2x/es/components/cascader-view/use-cascader-value-extend.js +23 -0
- package/2x/es/components/check-list/check-list-item.js +1 -1
- package/2x/es/components/checkbox/checkbox.js +3 -8
- package/2x/es/components/checkbox/native-input.d.ts +10 -0
- package/2x/es/components/checkbox/native-input.js +28 -0
- package/2x/es/components/dialog/index.d.ts +1 -1
- package/2x/es/components/dialog/show.d.ts +2 -4
- package/2x/es/components/dialog/show.js +8 -44
- package/2x/es/components/dot-loading/dot-loading.js +1 -2
- package/2x/es/components/error-block/error-block.js +4 -2
- package/2x/es/components/floating-bubble/floating-bubble.css +2 -1
- package/2x/es/components/floating-bubble/floating-bubble.d.ts +1 -1
- package/2x/es/components/floating-bubble/floating-bubble.js +14 -5
- package/2x/es/components/form/form-array.d.ts +19 -0
- package/2x/es/components/form/form-array.js +38 -0
- package/2x/es/components/form/form-item.css +6 -1
- package/2x/es/components/form/form-item.js +22 -8
- package/2x/es/components/form/form.css +5 -0
- package/2x/es/components/form/form.js +15 -5
- package/2x/es/components/form/index.css +11 -1
- package/2x/es/components/form/index.d.ts +2 -0
- package/2x/es/components/form/index.js +2 -0
- package/2x/es/components/image-uploader/image-uploader.d.ts +1 -1
- package/2x/es/components/image-uploader/image-uploader.js +17 -1
- package/2x/es/components/image-viewer/index.d.ts +1 -1
- package/2x/es/components/image-viewer/methods.d.ts +3 -4
- package/2x/es/components/image-viewer/methods.js +38 -57
- package/2x/es/components/modal/index.d.ts +1 -1
- package/2x/es/components/modal/show.d.ts +2 -4
- package/2x/es/components/modal/show.js +8 -44
- package/2x/es/components/popover/index.d.ts +7 -2
- package/2x/es/components/popover/normalize-placement.d.ts +2 -0
- package/2x/es/components/popover/normalize-placement.js +15 -0
- package/2x/es/components/popover/popover.css +0 -104
- package/2x/es/components/popover/popover.d.ts +11 -5
- package/2x/es/components/popover/popover.js +119 -22
- package/2x/es/components/popover/temp-floating-ui.min.d.ts +1 -0
- package/2x/es/components/popover/temp-floating-ui.min.js +1 -0
- package/2x/es/components/popover/wrapper.d.ts +7 -0
- package/2x/es/components/popover/wrapper.js +28 -0
- package/2x/es/components/pull-to-refresh/pull-to-refresh.js +24 -9
- package/2x/es/components/radio/radio.js +3 -8
- package/2x/es/components/search-bar/search-bar.d.ts +1 -1
- package/2x/es/components/tab-bar/tab-bar.d.ts +1 -1
- package/2x/es/components/tab-bar/tab-bar.js +1 -1
- package/2x/es/components/tree-select/tree-select.js +2 -2
- package/2x/es/utils/render-imperatively.d.ts +10 -0
- package/2x/es/utils/render-imperatively.js +45 -0
- package/2x/es/utils/use-props-value.d.ts +2 -1
- package/2x/es/utils/use-props-value.js +4 -2
- package/2x/package.json +3 -4
- package/cjs/components/action-sheet/action-sheet.d.ts +5 -5
- package/cjs/components/action-sheet/action-sheet.js +6 -46
- package/cjs/components/action-sheet/index.d.ts +1 -1
- package/cjs/components/badge/badge.js +1 -1
- package/cjs/components/cascader-view/cascader-view.d.ts +1 -0
- package/cjs/components/cascader-view/cascader-view.js +7 -0
- package/cjs/components/cascader-view/use-cascader-value-extend.js +23 -0
- package/cjs/components/check-list/check-list-item.js +1 -1
- package/cjs/components/checkbox/checkbox.js +4 -8
- package/cjs/components/checkbox/native-input.d.ts +10 -0
- package/cjs/components/checkbox/native-input.js +42 -0
- package/cjs/components/dialog/index.d.ts +1 -1
- package/cjs/components/dialog/show.d.ts +2 -4
- package/cjs/components/dialog/show.js +9 -47
- package/cjs/components/dot-loading/dot-loading.js +1 -2
- package/cjs/components/error-block/error-block.js +4 -2
- package/cjs/components/floating-bubble/floating-bubble.css +2 -1
- package/cjs/components/floating-bubble/floating-bubble.d.ts +1 -1
- package/cjs/components/floating-bubble/floating-bubble.js +14 -5
- package/cjs/components/form/form-array.d.ts +19 -0
- package/cjs/components/form/form-array.js +52 -0
- package/cjs/components/form/form-item.css +5 -1
- package/cjs/components/form/form-item.js +24 -8
- package/cjs/components/form/form.css +4 -0
- package/cjs/components/form/form.js +16 -5
- package/cjs/components/form/index.css +9 -1
- package/cjs/components/form/index.d.ts +2 -0
- package/cjs/components/form/index.js +3 -0
- package/cjs/components/image-uploader/image-uploader.d.ts +1 -1
- package/cjs/components/image-uploader/image-uploader.js +17 -1
- package/cjs/components/image-viewer/index.d.ts +1 -1
- package/cjs/components/image-viewer/methods.d.ts +3 -4
- package/cjs/components/image-viewer/methods.js +41 -56
- package/cjs/components/modal/index.d.ts +1 -1
- package/cjs/components/modal/show.d.ts +2 -4
- package/cjs/components/modal/show.js +9 -47
- package/cjs/components/popover/index.d.ts +7 -2
- package/cjs/components/popover/normalize-placement.d.ts +2 -0
- package/cjs/components/popover/normalize-placement.js +22 -0
- package/cjs/components/popover/popover.css +0 -84
- package/cjs/components/popover/popover.d.ts +11 -5
- package/cjs/components/popover/popover.js +127 -22
- package/cjs/components/popover/temp-floating-ui.min.d.ts +1 -0
- package/cjs/components/popover/temp-floating-ui.min.js +1 -0
- package/cjs/components/popover/wrapper.d.ts +7 -0
- package/cjs/components/popover/wrapper.js +41 -0
- package/cjs/components/pull-to-refresh/pull-to-refresh.js +24 -9
- package/cjs/components/radio/radio.js +4 -8
- package/cjs/components/search-bar/search-bar.d.ts +1 -1
- package/cjs/components/tab-bar/tab-bar.d.ts +1 -1
- package/cjs/components/tab-bar/tab-bar.js +1 -1
- package/cjs/components/tree-select/tree-select.js +2 -2
- package/cjs/utils/render-imperatively.d.ts +10 -0
- package/cjs/utils/render-imperatively.js +58 -0
- package/cjs/utils/use-props-value.d.ts +2 -1
- package/cjs/utils/use-props-value.js +4 -2
- package/es/components/action-sheet/action-sheet.d.ts +5 -5
- package/es/components/action-sheet/action-sheet.js +5 -41
- package/es/components/action-sheet/index.d.ts +1 -1
- package/es/components/badge/badge.js +1 -1
- package/es/components/cascader-view/cascader-view.d.ts +1 -0
- package/es/components/cascader-view/cascader-view.js +7 -0
- package/es/components/cascader-view/use-cascader-value-extend.js +23 -0
- package/es/components/check-list/check-list-item.js +1 -1
- package/es/components/checkbox/checkbox.js +3 -8
- package/es/components/checkbox/native-input.d.ts +10 -0
- package/es/components/checkbox/native-input.js +28 -0
- package/es/components/dialog/index.d.ts +1 -1
- package/es/components/dialog/show.d.ts +2 -4
- package/es/components/dialog/show.js +8 -44
- package/es/components/dot-loading/dot-loading.js +1 -2
- package/es/components/error-block/error-block.js +4 -2
- package/es/components/floating-bubble/floating-bubble.css +2 -1
- package/es/components/floating-bubble/floating-bubble.d.ts +1 -1
- package/es/components/floating-bubble/floating-bubble.js +14 -5
- package/es/components/form/form-array.d.ts +19 -0
- package/es/components/form/form-array.js +38 -0
- package/es/components/form/form-item.css +5 -1
- package/es/components/form/form-item.js +22 -8
- package/es/components/form/form.css +4 -0
- package/es/components/form/form.js +15 -5
- package/es/components/form/index.css +9 -1
- package/es/components/form/index.d.ts +2 -0
- package/es/components/form/index.js +2 -0
- package/es/components/image-uploader/image-uploader.d.ts +1 -1
- package/es/components/image-uploader/image-uploader.js +17 -1
- package/es/components/image-viewer/index.d.ts +1 -1
- package/es/components/image-viewer/methods.d.ts +3 -4
- package/es/components/image-viewer/methods.js +38 -57
- package/es/components/modal/index.d.ts +1 -1
- package/es/components/modal/show.d.ts +2 -4
- package/es/components/modal/show.js +8 -44
- package/es/components/popover/index.d.ts +7 -2
- package/es/components/popover/normalize-placement.d.ts +2 -0
- package/es/components/popover/normalize-placement.js +15 -0
- package/es/components/popover/popover.css +0 -84
- package/es/components/popover/popover.d.ts +11 -5
- package/es/components/popover/popover.js +119 -22
- package/es/components/popover/temp-floating-ui.min.d.ts +1 -0
- package/es/components/popover/temp-floating-ui.min.js +1 -0
- package/es/components/popover/wrapper.d.ts +7 -0
- package/es/components/popover/wrapper.js +28 -0
- package/es/components/pull-to-refresh/pull-to-refresh.js +24 -9
- package/es/components/radio/radio.js +3 -8
- package/es/components/search-bar/search-bar.d.ts +1 -1
- package/es/components/tab-bar/tab-bar.d.ts +1 -1
- package/es/components/tab-bar/tab-bar.js +1 -1
- package/es/components/tree-select/tree-select.js +2 -2
- package/es/utils/render-imperatively.d.ts +10 -0
- package/es/utils/render-imperatively.js +45 -0
- package/es/utils/use-props-value.d.ts +2 -1
- package/es/utils/use-props-value.js +4 -2
- package/package.json +3 -4
- package/umd/antd-mobile.js +1 -1
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Popover = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _tslib = require("tslib");
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
|
12
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
13
|
|
|
@@ -15,10 +15,26 @@ var _usePropsValue = require("../../utils/use-props-value");
|
|
|
15
15
|
|
|
16
16
|
var _withDefaultProps = require("../../utils/with-default-props");
|
|
17
17
|
|
|
18
|
+
var _nativeProps = require("../../utils/native-props");
|
|
19
|
+
|
|
18
20
|
var _withStopPropagation = require("../../utils/with-stop-propagation");
|
|
19
21
|
|
|
20
22
|
var _arrow = require("./arrow");
|
|
21
23
|
|
|
24
|
+
var _renderToContainer = require("../../utils/render-to-container");
|
|
25
|
+
|
|
26
|
+
var _tempFloatingUiMin = require("./temp-floating-ui.min.js");
|
|
27
|
+
|
|
28
|
+
var _wrapper = require("./wrapper");
|
|
29
|
+
|
|
30
|
+
var _shouldRender = require("../../utils/should-render");
|
|
31
|
+
|
|
32
|
+
var _ahooks = require("ahooks");
|
|
33
|
+
|
|
34
|
+
var _normalizePlacement = require("./normalize-placement");
|
|
35
|
+
|
|
36
|
+
var _convertPx = require("../../utils/convert-px");
|
|
37
|
+
|
|
22
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
39
|
|
|
24
40
|
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); }
|
|
@@ -33,12 +49,11 @@ const defaultProps = {
|
|
|
33
49
|
getContainer: () => document.body
|
|
34
50
|
};
|
|
35
51
|
const Popover = (0, _react.forwardRef)((p, ref) => {
|
|
36
|
-
var _a;
|
|
37
|
-
|
|
38
52
|
const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
|
|
39
53
|
const {
|
|
40
54
|
mode = 'light'
|
|
41
55
|
} = props;
|
|
56
|
+
const placement = (0, _normalizePlacement.normalizePlacement)(props.placement);
|
|
42
57
|
const [visible, setVisible] = (0, _usePropsValue.usePropsValue)({
|
|
43
58
|
value: props.visible,
|
|
44
59
|
defaultValue: props.defaultVisible,
|
|
@@ -51,24 +66,114 @@ const Popover = (0, _react.forwardRef)((p, ref) => {
|
|
|
51
66
|
visible
|
|
52
67
|
};
|
|
53
68
|
}, [visible]);
|
|
54
|
-
const
|
|
69
|
+
const targetRef = (0, _react.useRef)(null);
|
|
70
|
+
const floatingRef = (0, _react.useRef)(null);
|
|
71
|
+
const arrowRef = (0, _react.useRef)(null);
|
|
72
|
+
const floating = (0, _withStopPropagation.withStopPropagation)(props.stopPropagation, (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
|
|
73
|
+
className: (0, _classnames.default)(classPrefix, `${classPrefix}-${mode}`, !visible && `${classPrefix}-hidden`),
|
|
74
|
+
ref: floatingRef
|
|
75
|
+
}, _react.default.createElement("div", {
|
|
76
|
+
className: `${classPrefix}-arrow`,
|
|
77
|
+
ref: arrowRef
|
|
78
|
+
}, _react.default.createElement(_arrow.Arrow, {
|
|
79
|
+
className: `${classPrefix}-arrow-icon`
|
|
80
|
+
})), _react.default.createElement("div", {
|
|
81
|
+
className: `${classPrefix}-inner`
|
|
82
|
+
}, _react.default.createElement("div", {
|
|
55
83
|
className: `${classPrefix}-inner-content`
|
|
56
|
-
}, props.content));
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
84
|
+
}, props.content)))));
|
|
85
|
+
const [targetElement, setTargetElement] = (0, _react.useState)(null);
|
|
86
|
+
|
|
87
|
+
function update() {
|
|
88
|
+
var _a, _b, _c;
|
|
89
|
+
|
|
90
|
+
return (0, _tslib.__awaiter)(this, void 0, void 0, function* () {
|
|
91
|
+
const target = (_b = (_a = targetRef.current) === null || _a === void 0 ? void 0 : _a.element) !== null && _b !== void 0 ? _b : null;
|
|
92
|
+
const floating = floatingRef.current;
|
|
93
|
+
const arrowElement = arrowRef.current;
|
|
94
|
+
setTargetElement(target);
|
|
95
|
+
if (!target || !floating || !arrowElement) return;
|
|
96
|
+
const {
|
|
97
|
+
x,
|
|
98
|
+
y,
|
|
99
|
+
placement: realPlacement,
|
|
100
|
+
middlewareData
|
|
101
|
+
} = yield (0, _tempFloatingUiMin.computePosition)(target, floating, {
|
|
102
|
+
placement,
|
|
103
|
+
middleware: [(0, _tempFloatingUiMin.offset)((0, _convertPx.convertPx)(12)), (0, _tempFloatingUiMin.shift)({
|
|
104
|
+
padding: (0, _convertPx.convertPx)(4),
|
|
105
|
+
crossAxis: false,
|
|
106
|
+
limiter: (0, _tempFloatingUiMin.limitShift)()
|
|
107
|
+
}), (0, _tempFloatingUiMin.flip)(), (0, _tempFloatingUiMin.hide)(), (0, _tempFloatingUiMin.arrow)({
|
|
108
|
+
element: arrowElement,
|
|
109
|
+
padding: (0, _convertPx.convertPx)(12)
|
|
110
|
+
})]
|
|
111
|
+
});
|
|
112
|
+
Object.assign(floating.style, {
|
|
113
|
+
left: `${x}px`,
|
|
114
|
+
top: `${y}px`
|
|
115
|
+
});
|
|
116
|
+
const side = realPlacement.split('-')[0];
|
|
117
|
+
const arrowSide = {
|
|
118
|
+
top: 'bottom',
|
|
119
|
+
right: 'left',
|
|
120
|
+
bottom: 'top',
|
|
121
|
+
left: 'right'
|
|
122
|
+
}[side];
|
|
123
|
+
const {
|
|
124
|
+
x: arrowX,
|
|
125
|
+
y: arrowY
|
|
126
|
+
} = (_c = middlewareData.arrow) !== null && _c !== void 0 ? _c : {};
|
|
127
|
+
Object.assign(arrowElement.style, {
|
|
128
|
+
left: arrowX != null ? `${arrowX}px` : '',
|
|
129
|
+
top: arrowY != null ? `${arrowY}px` : '',
|
|
130
|
+
right: '',
|
|
131
|
+
bottom: '',
|
|
132
|
+
[arrowSide]: `-${(0, _convertPx.convertPx)(8)}px`
|
|
133
|
+
});
|
|
134
|
+
const arrowRotate = {
|
|
135
|
+
top: '0deg',
|
|
136
|
+
bottom: '180deg',
|
|
137
|
+
left: '270deg',
|
|
138
|
+
right: '90deg'
|
|
139
|
+
}[side];
|
|
140
|
+
arrowElement.style.setProperty('--arrow-icon-rotate', arrowRotate);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
(0, _ahooks.useIsomorphicLayoutEffect)(() => {
|
|
145
|
+
update();
|
|
146
|
+
});
|
|
147
|
+
(0, _react.useEffect)(() => {
|
|
148
|
+
if (!targetElement) return;
|
|
149
|
+
if (!props.trigger) return;
|
|
150
|
+
|
|
151
|
+
function handleClick() {
|
|
152
|
+
console.log('handleClick');
|
|
153
|
+
setVisible(v => !v);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
targetElement.addEventListener('click', handleClick);
|
|
157
|
+
return () => {
|
|
158
|
+
targetElement.removeEventListener('click', handleClick);
|
|
159
|
+
};
|
|
160
|
+
}, [targetElement, props.trigger]);
|
|
161
|
+
(0, _react.useEffect)(() => {
|
|
162
|
+
const floatingElement = floatingRef.current;
|
|
163
|
+
if (!targetElement || !floatingElement) return;
|
|
164
|
+
return (0, _tempFloatingUiMin.autoUpdate)(targetElement, floatingElement, update);
|
|
165
|
+
}, [targetElement]);
|
|
166
|
+
(0, _ahooks.useClickAway)(() => {
|
|
167
|
+
if (!props.trigger) return;
|
|
168
|
+
setVisible(false);
|
|
169
|
+
}, () => {
|
|
170
|
+
var _a;
|
|
171
|
+
|
|
172
|
+
return (_a = targetRef.current) === null || _a === void 0 ? void 0 : _a.element;
|
|
173
|
+
});
|
|
174
|
+
const shouldRender = (0, _shouldRender.useShouldRender)(visible, false, props.destroyOnHide);
|
|
175
|
+
return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_wrapper.Wrapper, {
|
|
176
|
+
ref: targetRef
|
|
177
|
+
}, props.children), shouldRender && (0, _renderToContainer.renderToContainer)(props.getContainer, floating));
|
|
73
178
|
});
|
|
74
179
|
exports.Popover = Popover;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@floating-ui/dom'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@floating-ui/core")):"function"==typeof define&&define.amd?define(["exports","@floating-ui/core"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUIDOM={},t.FloatingUICore)}(this,(function(t,e){"use strict";function n(t){return"[object Window]"===(null==t?void 0:t.toString())}function o(t){if(null==t)return window;if(!n(t)){const e=t.ownerDocument;return e&&e.defaultView||window}return t}function i(t){return o(t).getComputedStyle(t)}function r(t){return n(t)?"":t?(t.nodeName||"").toLowerCase():""}function l(t){return t instanceof o(t).HTMLElement}function c(t){return t instanceof o(t).Element}function f(t){return t instanceof o(t).ShadowRoot||t instanceof ShadowRoot}function u(t){const{overflow:e,overflowX:n,overflowY:o}=i(t);return/auto|scroll|overlay|hidden/.test(e+o+n)}function s(t){return["table","td","th"].includes(r(t))}function d(t){const e=navigator.userAgent.toLowerCase().includes("firefox"),n=i(t);return"none"!==n.transform||"none"!==n.perspective||"paint"===n.contain||["transform","perspective"].includes(n.willChange)||e&&"filter"===n.willChange||e&&!!n.filter&&"none"!==n.filter}const h=Math.min,a=Math.max,g=Math.round;function p(t,e){void 0===e&&(e=!1);const n=t.getBoundingClientRect();let o=1,i=1;return e&&l(t)&&(o=t.offsetWidth>0&&g(n.width)/t.offsetWidth||1,i=t.offsetHeight>0&&g(n.height)/t.offsetHeight||1),{width:n.width/o,height:n.height/i,top:n.top/i,right:n.right/o,bottom:n.bottom/i,left:n.left/o,x:n.left/o,y:n.top/i}}function m(t){return(e=t,(e instanceof o(e).Node?t.ownerDocument:t.document)||window.document).documentElement;var e}function y(t){return n(t)?{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}:{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function w(t){return p(m(t)).left+y(t).scrollLeft}function b(t,e,n){const o=l(e),i=m(e),c=p(t,o&&function(t){const e=p(t);return g(e.width)!==t.offsetWidth||g(e.height)!==t.offsetHeight}(e));let f={scrollLeft:0,scrollTop:0};const s={x:0,y:0};if(o||!o&&"fixed"!==n)if(("body"!==r(e)||u(i))&&(f=y(e)),l(e)){const t=p(e,!0);s.x=t.x+e.clientLeft,s.y=t.y+e.clientTop}else i&&(s.x=w(i));return{x:c.left+f.scrollLeft-s.x,y:c.top+f.scrollTop-s.y,width:c.width,height:c.height}}function v(t){return"html"===r(t)?t:t.assignedSlot||t.parentNode||(f(t)?t.host:null)||m(t)}function x(t){return l(t)&&"fixed"!==getComputedStyle(t).position?t.offsetParent:null}function L(t){const e=o(t);let n=x(t);for(;n&&s(n)&&"static"===getComputedStyle(n).position;)n=x(n);return n&&("html"===r(n)||"body"===r(n)&&"static"===getComputedStyle(n).position&&!d(n))?e:n||function(t){let e=v(t);for(f(e)&&(e=e.host);l(e)&&!["html","body"].includes(r(e));){if(d(e))return e;e=e.parentNode}return null}(t)||e}function O(t){if(l(t))return{width:t.offsetWidth,height:t.offsetHeight};const e=p(t);return{width:e.width,height:e.height}}function P(t){const e=v(t);return["html","body","#document"].includes(r(e))?t.ownerDocument.body:l(e)&&u(e)?e:P(e)}function R(t,e){var n;void 0===e&&(e=[]);const i=P(t),r=i===(null==(n=t.ownerDocument)?void 0:n.body),l=o(i),c=r?[l].concat(l.visualViewport||[],u(i)?i:[]):i,f=e.concat(c);return r?f:f.concat(R(v(c)))}function T(t,n){return"viewport"===n?e.rectToClientRect(function(t){const e=o(t),n=m(t),i=e.visualViewport;let r=n.clientWidth,l=n.clientHeight,c=0,f=0;return i&&(r=i.width,l=i.height,Math.abs(e.innerWidth/i.scale-i.width)<.01&&(c=i.offsetLeft,f=i.offsetTop)),{width:r,height:l,x:c,y:f}}(t)):c(n)?function(t){const e=p(t),n=e.top+t.clientTop,o=e.left+t.clientLeft;return{top:n,left:o,x:o,y:n,right:o+t.clientWidth,bottom:n+t.clientHeight,width:t.clientWidth,height:t.clientHeight}}(n):e.rectToClientRect(function(t){var e;const n=m(t),o=y(t),r=null==(e=t.ownerDocument)?void 0:e.body,l=a(n.scrollWidth,n.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),c=a(n.scrollHeight,n.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0);let f=-o.scrollLeft+w(t);const u=-o.scrollTop;return"rtl"===i(r||n).direction&&(f+=a(n.clientWidth,r?r.clientWidth:0)-l),{width:l,height:c,x:f,y:u}}(m(t)))}function C(t){const e=R(t),n=["absolute","fixed"].includes(i(t).position)&&l(t)?L(t):t;return c(n)?e.filter((t=>c(t)&&function(t,e){const n=null==e.getRootNode?void 0:e.getRootNode();if(t.contains(e))return!0;if(n&&f(n)){let n=e;do{if(n&&t===n)return!0;n=n.parentNode||n.host}while(n)}return!1}(t,n)&&"body"!==r(t))):[]}const W={getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:o}=t;const i=[..."clippingAncestors"===n?C(e):[].concat(n),o],r=i[0],l=i.reduce(((t,n)=>{const o=T(e,n);return t.top=a(o.top,t.top),t.right=h(o.right,t.right),t.bottom=h(o.bottom,t.bottom),t.left=a(o.left,t.left),t}),T(e,r));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:o}=t;const i=l(n),c=m(n);if(n===c)return e;let f={scrollLeft:0,scrollTop:0};const s={x:0,y:0};if((i||!i&&"fixed"!==o)&&(("body"!==r(n)||u(c))&&(f=y(n)),l(n))){const t=p(n,!0);s.x=t.x+n.clientLeft,s.y=t.y+n.clientTop}return{...e,x:e.x-f.scrollLeft+s.x,y:e.y-f.scrollTop+s.y}},isElement:c,getDimensions:O,getOffsetParent:L,getDocumentElement:m,getElementRects:t=>{let{reference:e,floating:n,strategy:o}=t;return{reference:b(e,L(n),o),floating:{...O(n),x:0,y:0}}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>"rtl"===i(t).direction};Object.defineProperty(t,"arrow",{enumerable:!0,get:function(){return e.arrow}}),Object.defineProperty(t,"autoPlacement",{enumerable:!0,get:function(){return e.autoPlacement}}),Object.defineProperty(t,"detectOverflow",{enumerable:!0,get:function(){return e.detectOverflow}}),Object.defineProperty(t,"flip",{enumerable:!0,get:function(){return e.flip}}),Object.defineProperty(t,"hide",{enumerable:!0,get:function(){return e.hide}}),Object.defineProperty(t,"inline",{enumerable:!0,get:function(){return e.inline}}),Object.defineProperty(t,"limitShift",{enumerable:!0,get:function(){return e.limitShift}}),Object.defineProperty(t,"offset",{enumerable:!0,get:function(){return e.offset}}),Object.defineProperty(t,"shift",{enumerable:!0,get:function(){return e.shift}}),Object.defineProperty(t,"size",{enumerable:!0,get:function(){return e.size}}),t.autoUpdate=function(t,e,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:l=!0,animationFrame:f=!1}=o;let u=!1;const s=i&&!f,d=r&&!f,h=l&&!f,a=s||d?[...c(t)?R(t):[],...R(e)]:[];a.forEach((t=>{s&&t.addEventListener("scroll",n,{passive:!0}),d&&t.addEventListener("resize",n)}));let g,m=null;h&&(m=new ResizeObserver(n),c(t)&&m.observe(t),m.observe(e));let y=f?p(t):null;return f&&function e(){if(u)return;const o=p(t);!y||o.x===y.x&&o.y===y.y&&o.width===y.width&&o.height===y.height||n();y=o,g=requestAnimationFrame(e)}(),()=>{var t;u=!0,a.forEach((t=>{s&&t.removeEventListener("scroll",n),d&&t.removeEventListener("resize",n)})),null==(t=m)||t.disconnect(),m=null,f&&cancelAnimationFrame(g)}},t.computePosition=(t,n,o)=>e.computePosition(t,n,{platform:W,...o}),t.getOverflowAncestors=R,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Wrapper = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _reactDom = require("react-dom");
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
class Wrapper extends _react.default.Component {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.element = null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
componentDidMount() {
|
|
21
|
+
this.componentDidUpdate();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
componentDidUpdate() {
|
|
25
|
+
// eslint-disable-next-line
|
|
26
|
+
const node = (0, _reactDom.findDOMNode)(this);
|
|
27
|
+
|
|
28
|
+
if (node instanceof Element) {
|
|
29
|
+
this.element = node;
|
|
30
|
+
} else {
|
|
31
|
+
this.element = null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
render() {
|
|
36
|
+
return _react.default.Children.only(this.props.children);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.Wrapper = Wrapper;
|
|
@@ -126,15 +126,30 @@ const PullToRefresh = p => {
|
|
|
126
126
|
|
|
127
127
|
const [, y] = state.movement;
|
|
128
128
|
|
|
129
|
-
if (state.first) {
|
|
130
|
-
const
|
|
131
|
-
if (!
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
129
|
+
if (state.first && y > 0) {
|
|
130
|
+
const target = state.event.target;
|
|
131
|
+
if (!target || !(target instanceof Element)) return;
|
|
132
|
+
let scrollParent = (0, _getScrollParent.getScrollParent)(target);
|
|
133
|
+
|
|
134
|
+
while (true) {
|
|
135
|
+
if (!scrollParent) return;
|
|
136
|
+
const scrollTop = getScrollTop(scrollParent);
|
|
137
|
+
|
|
138
|
+
if (scrollTop > 0) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (scrollParent instanceof Window) {
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
scrollParent = (0, _getScrollParent.getScrollParent)(scrollParent.parentNode);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
pullingRef.current = true;
|
|
150
|
+
|
|
151
|
+
function getScrollTop(element) {
|
|
152
|
+
return 'scrollTop' in element ? element.scrollTop : element.scrollY;
|
|
138
153
|
}
|
|
139
154
|
}
|
|
140
155
|
|
|
@@ -23,6 +23,8 @@ var _devLog = require("../../utils/dev-log");
|
|
|
23
23
|
|
|
24
24
|
var _isDev = require("../../utils/is-dev");
|
|
25
25
|
|
|
26
|
+
var _nativeInput = require("../checkbox/native-input");
|
|
27
|
+
|
|
26
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
29
|
|
|
28
30
|
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); }
|
|
@@ -93,16 +95,10 @@ const Radio = p => {
|
|
|
93
95
|
[`${classPrefix}-disabled`]: disabled,
|
|
94
96
|
[`${classPrefix}-block`]: props.block
|
|
95
97
|
})
|
|
96
|
-
}, _react.default.createElement(
|
|
98
|
+
}, _react.default.createElement(_nativeInput.NativeInput, {
|
|
97
99
|
type: 'radio',
|
|
98
100
|
checked: checked,
|
|
99
|
-
onChange:
|
|
100
|
-
setChecked(e.target.checked);
|
|
101
|
-
},
|
|
102
|
-
onClick: e => {
|
|
103
|
-
e.stopPropagation();
|
|
104
|
-
e.nativeEvent.stopImmediatePropagation();
|
|
105
|
-
},
|
|
101
|
+
onChange: setChecked,
|
|
106
102
|
disabled: disabled,
|
|
107
103
|
id: props.id
|
|
108
104
|
}), renderIcon(), props.children && _react.default.createElement("div", {
|
|
@@ -29,4 +29,4 @@ export declare const SearchBar: React.ForwardRefExoticComponent<Pick<InputProps,
|
|
|
29
29
|
onSearch?: ((val: string) => void) | undefined;
|
|
30
30
|
onChange?: ((val: string) => void) | undefined;
|
|
31
31
|
onCancel?: (() => void) | undefined;
|
|
32
|
-
} & NativeProps<"--border-radius" | "--height" | "--padding-left" | "--
|
|
32
|
+
} & NativeProps<"--border-radius" | "--height" | "--padding-left" | "--background" | "--placeholder-color"> & React.RefAttributes<InputRef>>;
|
|
@@ -3,7 +3,7 @@ import { NativeProps } from '../../utils/native-props';
|
|
|
3
3
|
import { BadgeProps } from '../badge';
|
|
4
4
|
export declare type TabBarItemProps = {
|
|
5
5
|
icon?: ReactNode | ((active: boolean) => ReactNode);
|
|
6
|
-
title?: ReactNode;
|
|
6
|
+
title?: ReactNode | ((active: boolean) => ReactNode);
|
|
7
7
|
badge?: BadgeProps['content'];
|
|
8
8
|
} & NativeProps;
|
|
9
9
|
export declare const TabBarItem: FC<TabBarItemProps>;
|
|
@@ -74,7 +74,7 @@ const TabBar = p => {
|
|
|
74
74
|
|
|
75
75
|
const titleElement = item.props.title && _react.default.createElement("div", {
|
|
76
76
|
className: `${classPrefix}-item-title`
|
|
77
|
-
}, item.props.title);
|
|
77
|
+
}, typeof item.props.title === 'function' ? item.props.title(active) : item.props.title);
|
|
78
78
|
|
|
79
79
|
if (iconElement) {
|
|
80
80
|
return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_badge.default, {
|
|
@@ -67,12 +67,12 @@ const TreeSelect = p => {
|
|
|
67
67
|
let current = node;
|
|
68
68
|
|
|
69
69
|
while (current) {
|
|
70
|
-
parentNodes.
|
|
70
|
+
parentNodes.push(current);
|
|
71
71
|
const next = optionsParentMap.get(current[valueName]);
|
|
72
72
|
current = next;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
const values = parentNodes.map(i => i[valueName]);
|
|
75
|
+
const values = parentNodes.reverse().map(i => i[valueName]);
|
|
76
76
|
setValue(values);
|
|
77
77
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, values, {
|
|
78
78
|
options: parentNodes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
declare type ImperativeProps = {
|
|
3
|
+
visible?: boolean;
|
|
4
|
+
onClose?: () => void;
|
|
5
|
+
afterClose?: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function renderImperatively(element: ReactElement<ImperativeProps>): {
|
|
8
|
+
close: () => void;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.renderImperatively = renderImperatively;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _renderToBody = require("./render-to-body");
|
|
11
|
+
|
|
12
|
+
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); }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
function renderImperatively(element) {
|
|
17
|
+
let close = () => {};
|
|
18
|
+
|
|
19
|
+
const Wrapper = () => {
|
|
20
|
+
const [visible, setVisible] = (0, _react.useState)(false);
|
|
21
|
+
const closedRef = (0, _react.useRef)(false);
|
|
22
|
+
(0, _react.useEffect)(() => {
|
|
23
|
+
if (!closedRef.current) {
|
|
24
|
+
setVisible(true);
|
|
25
|
+
} else {
|
|
26
|
+
afterClose();
|
|
27
|
+
}
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
function onClose() {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
|
|
33
|
+
closedRef.current = true;
|
|
34
|
+
setVisible(false);
|
|
35
|
+
(_b = (_a = element.props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
close = onClose;
|
|
39
|
+
|
|
40
|
+
function afterClose() {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
|
|
43
|
+
unmount();
|
|
44
|
+
(_b = (_a = element.props).afterClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return _react.default.cloneElement(element, Object.assign(Object.assign({}, element.props), {
|
|
48
|
+
visible,
|
|
49
|
+
onClose,
|
|
50
|
+
afterClose
|
|
51
|
+
}));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const unmount = (0, _renderToBody.renderToBody)(_react.default.createElement(Wrapper, null));
|
|
55
|
+
return {
|
|
56
|
+
close
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { SetStateAction } from 'react';
|
|
1
2
|
declare type Options<T> = {
|
|
2
3
|
value?: T;
|
|
3
4
|
defaultValue: T;
|
|
4
5
|
onChange?: (v: T) => void;
|
|
5
6
|
};
|
|
6
|
-
export declare function usePropsValue<T>(options: Options<T>): readonly [T, (this: unknown, v: T) => void];
|
|
7
|
+
export declare function usePropsValue<T>(options: Options<T>): readonly [T, (this: unknown, v: SetStateAction<T>) => void];
|
|
7
8
|
export {};
|
|
@@ -23,12 +23,14 @@ function usePropsValue(options) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const setState = (0, _ahooks.useMemoizedFn)(v => {
|
|
26
|
+
const nextValue = typeof v === 'function' ? v(stateRef.current) : v;
|
|
27
|
+
|
|
26
28
|
if (value === undefined) {
|
|
27
|
-
stateRef.current =
|
|
29
|
+
stateRef.current = nextValue;
|
|
28
30
|
update();
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(
|
|
33
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(nextValue);
|
|
32
34
|
});
|
|
33
35
|
return [stateRef.current, setState];
|
|
34
36
|
}
|
|
@@ -10,7 +10,7 @@ export declare type Action = {
|
|
|
10
10
|
onClick?: () => void;
|
|
11
11
|
};
|
|
12
12
|
export declare type ActionSheetProps = {
|
|
13
|
-
visible
|
|
13
|
+
visible?: boolean;
|
|
14
14
|
actions: Action[];
|
|
15
15
|
extra?: React.ReactNode;
|
|
16
16
|
cancelText?: React.ReactNode;
|
|
@@ -22,11 +22,11 @@ export declare type ActionSheetProps = {
|
|
|
22
22
|
closeOnMaskClick?: boolean;
|
|
23
23
|
getContainer?: GetContainer;
|
|
24
24
|
safeArea?: boolean;
|
|
25
|
+
popupClassName?: string;
|
|
26
|
+
popupStyle?: React.CSSProperties;
|
|
25
27
|
} & NativeProps;
|
|
26
28
|
export declare const ActionSheet: FC<ActionSheetProps>;
|
|
27
|
-
export declare type
|
|
28
|
-
close: () => void;
|
|
29
|
-
};
|
|
30
|
-
export declare function showActionSheet(props: Omit<ActionSheetProps, 'visible'>): {
|
|
29
|
+
export declare type ActionSheetShowHandler = {
|
|
31
30
|
close: () => void;
|
|
32
31
|
};
|
|
32
|
+
export declare function showActionSheet(props: Omit<ActionSheetProps, 'visible'>): ActionSheetShowHandler;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { withNativeProps } from '../../utils/native-props';
|
|
3
3
|
import { mergeProps } from '../../utils/with-default-props';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import Popup from '../popup';
|
|
6
6
|
import Button from '../button';
|
|
7
|
-
import { renderToBody } from '../../utils/render-to-body';
|
|
8
7
|
import SafeArea from '../safe-area';
|
|
8
|
+
import { renderImperatively } from '../../utils/render-imperatively';
|
|
9
9
|
const classPrefix = `adm-action-sheet`;
|
|
10
10
|
const defaultProps = {
|
|
11
11
|
visible: false,
|
|
@@ -29,7 +29,8 @@ export const ActionSheet = p => {
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
afterClose: props.afterClose,
|
|
32
|
-
className: `${classPrefix}-popup`,
|
|
32
|
+
className: classNames(`${classPrefix}-popup`, props.popupClassName),
|
|
33
|
+
style: props.popupStyle,
|
|
33
34
|
getContainer: props.getContainer
|
|
34
35
|
}, withNativeProps(props, React.createElement("div", {
|
|
35
36
|
className: classPrefix
|
|
@@ -83,42 +84,5 @@ export const ActionSheet = p => {
|
|
|
83
84
|
}))));
|
|
84
85
|
};
|
|
85
86
|
export function showActionSheet(props) {
|
|
86
|
-
|
|
87
|
-
const [visible, setVisible] = useState(false);
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
setVisible(true);
|
|
90
|
-
}, []);
|
|
91
|
-
|
|
92
|
-
function handleClose() {
|
|
93
|
-
var _a;
|
|
94
|
-
|
|
95
|
-
(_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
96
|
-
setVisible(false);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
useImperativeHandle(ref, () => ({
|
|
100
|
-
close: handleClose
|
|
101
|
-
}));
|
|
102
|
-
return React.createElement(ActionSheet, Object.assign({}, props, {
|
|
103
|
-
visible: visible,
|
|
104
|
-
onClose: handleClose,
|
|
105
|
-
afterClose: () => {
|
|
106
|
-
var _a;
|
|
107
|
-
|
|
108
|
-
(_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
109
|
-
unmount();
|
|
110
|
-
}
|
|
111
|
-
}));
|
|
112
|
-
});
|
|
113
|
-
const ref = createRef();
|
|
114
|
-
const unmount = renderToBody(React.createElement(Wrapper, {
|
|
115
|
-
ref: ref
|
|
116
|
-
}));
|
|
117
|
-
return {
|
|
118
|
-
close: () => {
|
|
119
|
-
var _a;
|
|
120
|
-
|
|
121
|
-
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
122
|
-
}
|
|
123
|
-
};
|
|
87
|
+
return renderImperatively(React.createElement(ActionSheet, Object.assign({}, props)));
|
|
124
88
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import './action-sheet.less';
|
|
3
3
|
import { showActionSheet } from './action-sheet';
|
|
4
|
-
export type { Action, ActionSheetProps,
|
|
4
|
+
export type { Action, ActionSheetProps, ActionSheetShowHandler, } from './action-sheet';
|
|
5
5
|
declare const _default: import("react").FC<import("./action-sheet").ActionSheetProps> & {
|
|
6
6
|
show: typeof showActionSheet;
|
|
7
7
|
};
|
|
@@ -11,7 +11,7 @@ export const Badge = props => {
|
|
|
11
11
|
} = props;
|
|
12
12
|
const isDot = content === dot;
|
|
13
13
|
const badgeCls = classNames(classPrefix, !!children && `${classPrefix}-fixed`, isDot && `${classPrefix}-dot`, props.bordered && `${classPrefix}-bordered`);
|
|
14
|
-
const element = content ? withNativeProps(props, React.createElement("div", {
|
|
14
|
+
const element = content || content === 0 ? withNativeProps(props, React.createElement("div", {
|
|
15
15
|
className: badgeCls,
|
|
16
16
|
style: {
|
|
17
17
|
'--color': color
|
|
@@ -61,6 +61,13 @@ export const CascaderView = p => {
|
|
|
61
61
|
useEffect(() => {
|
|
62
62
|
setTabActiveKey(levels.length - 1);
|
|
63
63
|
}, [value]);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
const max = levels.length - 1;
|
|
66
|
+
|
|
67
|
+
if (tabActiveKey > max) {
|
|
68
|
+
setTabActiveKey(max);
|
|
69
|
+
}
|
|
70
|
+
}, [tabActiveKey, levels]);
|
|
64
71
|
|
|
65
72
|
const onItemSelect = (selectValue, depth) => {
|
|
66
73
|
const next = value.slice(0, depth);
|
|
@@ -21,11 +21,34 @@ export function useCascaderValueExtend(options) {
|
|
|
21
21
|
return ret;
|
|
22
22
|
}, val => JSON.stringify(val));
|
|
23
23
|
}, [options]);
|
|
24
|
+
const generateIsLeaf = useMemo(() => {
|
|
25
|
+
return memoize(val => {
|
|
26
|
+
var _a;
|
|
27
|
+
|
|
28
|
+
let isLeaf = false;
|
|
29
|
+
|
|
30
|
+
for (const v of val) {
|
|
31
|
+
const target = options.find(option => option.value === v);
|
|
32
|
+
|
|
33
|
+
if (!target) {
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
isLeaf = ((_a = target.children) === null || _a === void 0 ? void 0 : _a.length) === val.length;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return isLeaf;
|
|
41
|
+
}, val => JSON.stringify(val));
|
|
42
|
+
}, [options]);
|
|
24
43
|
|
|
25
44
|
function generateValueExtend(val) {
|
|
26
45
|
return {
|
|
27
46
|
get items() {
|
|
28
47
|
return generateItems(val);
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
get isLeaf() {
|
|
51
|
+
return generateIsLeaf(val);
|
|
29
52
|
}
|
|
30
53
|
|
|
31
54
|
};
|
|
@@ -20,7 +20,7 @@ export const CheckListItem = props => {
|
|
|
20
20
|
}, active ? context.activeIcon : null);
|
|
21
21
|
return withNativeProps(props, React.createElement(List.Item, {
|
|
22
22
|
title: props.title,
|
|
23
|
-
className: classNames(classPrefix, readOnly && `${classPrefix}-readonly`),
|
|
23
|
+
className: classNames(classPrefix, readOnly && `${classPrefix}-readonly`, active && `${classPrefix}-active`),
|
|
24
24
|
description: props.description,
|
|
25
25
|
prefix: props.prefix,
|
|
26
26
|
onClick: e => {
|