@arco-design/mobile-react 2.19.1-941e02b.7 → 2.20.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/CHANGELOG.md +36 -0
- package/README.en-US.md +6 -6
- package/README.md +6 -6
- package/cjs/_helpers/type.d.ts +1 -1
- package/cjs/avatar/group.js +1 -1
- package/cjs/avatar/index.js +10 -13
- package/cjs/avatar/style/css/index.css +96 -126
- package/cjs/avatar/style/index.less +54 -72
- package/cjs/badge/index.js +6 -8
- package/cjs/badge/style/css/index.css +5 -5
- package/cjs/badge/style/index.less +5 -5
- package/cjs/button/hooks.d.ts +1 -2
- package/cjs/button/hooks.js +5 -3
- package/cjs/button/index.d.ts +12 -0
- package/cjs/button/index.js +40 -33
- package/cjs/button/style/css/index.css +75 -310
- package/cjs/button/style/index.less +32 -38
- package/cjs/count-down/demo/style/mobile.less +1 -1
- package/cjs/dropdown/dropdown.d.ts +3 -0
- package/cjs/dropdown/dropdown.js +306 -0
- package/cjs/dropdown/index.d.ts +3 -4
- package/cjs/dropdown/index.js +3 -303
- package/cjs/dropdown/options.js +2 -1
- package/cjs/dropdown/type.d.ts +20 -9
- package/cjs/dropdown-menu/dropdown-menu.d.ts +4 -0
- package/cjs/dropdown-menu/dropdown-menu.js +273 -0
- package/cjs/dropdown-menu/helper.d.ts +1 -1
- package/cjs/dropdown-menu/index.d.ts +2 -3
- package/cjs/dropdown-menu/index.js +2 -245
- package/cjs/dropdown-menu/type.d.ts +21 -20
- package/cjs/image/index.js +4 -1
- package/cjs/image/style/css/index.css +2 -1
- package/cjs/image/style/index.less +2 -1
- package/cjs/image-picker/index.d.ts +11 -8
- package/cjs/image-picker/index.js +19 -12
- package/cjs/image-picker/style/index.less +1 -1
- package/cjs/nav-bar/index.js +7 -2
- package/cjs/notify/index.d.ts +1 -0
- package/cjs/notify/index.js +12 -0
- package/cjs/notify/type.d.ts +1 -0
- package/cjs/show-monitor/index.js +31 -3
- package/cjs/transition/index.js +4 -2
- package/dist/index.js +677 -617
- package/dist/index.min.js +4 -4
- package/dist/style.css +174 -438
- package/dist/style.min.css +1 -1
- package/esm/_helpers/type.d.ts +1 -1
- package/esm/avatar/group.js +1 -1
- package/esm/avatar/index.js +10 -13
- package/esm/avatar/style/css/index.css +96 -126
- package/esm/avatar/style/index.less +54 -72
- package/esm/badge/index.js +6 -8
- package/esm/badge/style/css/index.css +5 -5
- package/esm/badge/style/index.less +5 -5
- package/esm/button/hooks.d.ts +1 -2
- package/esm/button/hooks.js +5 -3
- package/esm/button/index.d.ts +12 -0
- package/esm/button/index.js +42 -35
- package/esm/button/style/css/index.css +75 -310
- package/esm/button/style/index.less +32 -38
- package/esm/count-down/demo/style/mobile.less +1 -1
- package/esm/dropdown/dropdown.d.ts +3 -0
- package/esm/dropdown/dropdown.js +288 -0
- package/esm/dropdown/index.d.ts +3 -4
- package/esm/dropdown/index.js +3 -293
- package/esm/dropdown/options.js +2 -1
- package/esm/dropdown/type.d.ts +20 -9
- package/esm/dropdown-menu/dropdown-menu.d.ts +4 -0
- package/esm/dropdown-menu/dropdown-menu.js +256 -0
- package/esm/dropdown-menu/helper.d.ts +1 -1
- package/esm/dropdown-menu/index.d.ts +2 -3
- package/esm/dropdown-menu/index.js +2 -237
- package/esm/dropdown-menu/type.d.ts +21 -20
- package/esm/image/index.js +4 -1
- package/esm/image/style/css/index.css +2 -1
- package/esm/image/style/index.less +2 -1
- package/esm/image-picker/index.d.ts +11 -8
- package/esm/image-picker/index.js +19 -12
- package/esm/image-picker/style/index.less +1 -1
- package/esm/nav-bar/index.js +6 -2
- package/esm/notify/index.d.ts +1 -0
- package/esm/notify/index.js +1 -0
- package/esm/notify/type.d.ts +1 -0
- package/esm/show-monitor/index.js +31 -3
- package/esm/transition/index.js +4 -2
- package/package.json +3 -3
- package/tokens/app/arcodesign/default/css-variables.less +2 -1
- package/tokens/app/arcodesign/default/index.d.ts +2 -1
- package/tokens/app/arcodesign/default/index.js +2 -1
- package/tokens/app/arcodesign/default/index.json +123 -47
- package/tokens/app/arcodesign/default/index.less +2 -1
- package/umd/_helpers/type.d.ts +1 -1
- package/umd/avatar/group.js +1 -1
- package/umd/avatar/index.js +10 -13
- package/umd/avatar/style/css/index.css +96 -126
- package/umd/avatar/style/index.less +54 -72
- package/umd/badge/index.js +6 -8
- package/umd/badge/style/css/index.css +5 -5
- package/umd/badge/style/index.less +5 -5
- package/umd/button/hooks.d.ts +1 -2
- package/umd/button/hooks.js +5 -3
- package/umd/button/index.d.ts +12 -0
- package/umd/button/index.js +40 -33
- package/umd/button/style/css/index.css +75 -310
- package/umd/button/style/index.less +32 -38
- package/umd/count-down/demo/style/mobile.less +1 -1
- package/umd/dropdown/dropdown.d.ts +3 -0
- package/umd/dropdown/dropdown.js +309 -0
- package/umd/dropdown/index.d.ts +3 -4
- package/umd/dropdown/index.js +5 -298
- package/umd/dropdown/options.js +2 -1
- package/umd/dropdown/type.d.ts +20 -9
- package/umd/dropdown-menu/dropdown-menu.d.ts +4 -0
- package/umd/dropdown-menu/dropdown-menu.js +278 -0
- package/umd/dropdown-menu/helper.d.ts +1 -1
- package/umd/dropdown-menu/index.d.ts +2 -3
- package/umd/dropdown-menu/index.js +5 -241
- package/umd/dropdown-menu/type.d.ts +21 -20
- package/umd/image/index.js +4 -1
- package/umd/image/style/css/index.css +2 -1
- package/umd/image/style/index.less +2 -1
- package/umd/image-picker/index.d.ts +11 -8
- package/umd/image-picker/index.js +19 -12
- package/umd/image-picker/style/index.less +1 -1
- package/umd/nav-bar/index.js +9 -6
- package/umd/notify/index.d.ts +1 -0
- package/umd/notify/index.js +13 -4
- package/umd/notify/type.d.ts +1 -0
- package/umd/show-monitor/index.js +31 -3
- package/umd/transition/index.js +4 -2
@@ -6,21 +6,29 @@
|
|
6
6
|
|
7
7
|
.button-has-border(@color) {
|
8
8
|
.use-var(border, @color, 1PX solid);
|
9
|
-
&.half-border
|
9
|
+
&.half-border {
|
10
10
|
border-width: 0;
|
11
11
|
.hairline-var(@color);
|
12
12
|
}
|
13
13
|
}
|
14
14
|
|
15
|
+
.button-has-border-value(@value) {
|
16
|
+
border: 1PX solid @value;
|
17
|
+
&.half-border {
|
18
|
+
border-width: 0;
|
19
|
+
.hairline(@value);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
15
23
|
.button-no-border() {
|
16
24
|
border-width: 0;
|
17
25
|
box-shadow: none;
|
18
26
|
}
|
19
27
|
|
20
28
|
.button-text-size(@font-size) {
|
21
|
-
|
29
|
+
.@{prefix}-button-icon,
|
22
30
|
i,
|
23
|
-
|
31
|
+
.@{prefix}-button-text,
|
24
32
|
svg {
|
25
33
|
.use-var(font-size, @font-size);
|
26
34
|
}
|
@@ -28,10 +36,10 @@
|
|
28
36
|
|
29
37
|
.button-size-height(@height) {
|
30
38
|
.use-var(height, @height);
|
31
|
-
|
39
|
+
&-is-round {
|
32
40
|
.use-var(border-radius, @height);
|
33
41
|
}
|
34
|
-
|
42
|
+
&-is-square {
|
35
43
|
.rem(border-radius, 0);
|
36
44
|
}
|
37
45
|
}
|
@@ -44,45 +52,48 @@
|
|
44
52
|
display: block;
|
45
53
|
width: 100%;
|
46
54
|
box-sizing: border-box;
|
55
|
+
.use-var(line-height, button-line-height);
|
47
56
|
.use-var(border-radius, button-radius);
|
48
|
-
.button-has-border(button-border-color);
|
49
57
|
.noselect();
|
50
58
|
|
51
|
-
|
59
|
+
&-inline {
|
52
60
|
width: auto;
|
53
61
|
display: inline-block;
|
54
62
|
}
|
55
63
|
|
56
64
|
.set-button-type(length(@type-map));
|
57
65
|
|
66
|
+
&-type-ghost {
|
67
|
+
.button-has-border-value(currentColor);
|
68
|
+
}
|
69
|
+
|
58
70
|
.set-button-size(length(@size-map));
|
59
71
|
|
60
|
-
|
72
|
+
&-text-android {
|
61
73
|
.rem(padding-top, 2);
|
62
74
|
}
|
63
75
|
|
64
|
-
|
76
|
+
&-icon {
|
65
77
|
vertical-align: middle;
|
66
78
|
display: inline-flex;
|
67
79
|
align-items: center;
|
68
80
|
justify-content: center;
|
69
81
|
}
|
70
|
-
|
71
|
-
.rem(font-size, 15);
|
82
|
+
&-text {
|
72
83
|
display: inline-block;
|
73
84
|
vertical-align: middle;
|
74
85
|
}
|
75
|
-
|
76
|
-
.
|
86
|
+
&-text-has-icon {
|
87
|
+
.use-var(margin-left, button-icon-text-gutter);
|
77
88
|
}
|
78
89
|
|
79
|
-
|
90
|
+
&-loading-icon {
|
80
91
|
display: inline-block;
|
81
92
|
vertical-align: middle;
|
93
|
+
}
|
82
94
|
|
83
|
-
|
84
|
-
|
85
|
-
}
|
95
|
+
&.has-custom-border {
|
96
|
+
border: 1PX solid;
|
86
97
|
}
|
87
98
|
}
|
88
99
|
|
@@ -90,33 +101,16 @@
|
|
90
101
|
.set-button-type(@index) when (@index > 0) {
|
91
102
|
@type: extract(@type-map, @index);
|
92
103
|
|
93
|
-
|
94
|
-
.button-has-border('button-@{type}-background');
|
104
|
+
&-type-@{type} {
|
95
105
|
.use-var(background, 'button-@{type}-background');
|
96
106
|
.use-var(color, 'button-@{type}-text-color');
|
97
107
|
.set-loading-color-var('button-@{type}-text-color');
|
98
|
-
|
99
|
-
&.ios,
|
100
|
-
&.android {
|
101
|
-
.button-no-border();
|
102
|
-
}
|
108
|
+
&-disabled {
|
103
109
|
.use-var(background, 'button-@{type}-disabled-background');
|
104
110
|
.use-var(color, 'button-@{type}-disabled-text-color')
|
105
111
|
}
|
106
|
-
|
112
|
+
&-active {
|
107
113
|
.use-var(background, 'button-@{type}-clicked-background');
|
108
|
-
.button-has-border('button-@{type}-clicked-background');
|
109
|
-
}
|
110
|
-
}
|
111
|
-
|
112
|
-
&.type-ghost {
|
113
|
-
&, &.active {
|
114
|
-
.button-has-border(button-ghost-text-color);
|
115
|
-
}
|
116
|
-
&.disabled {
|
117
|
-
&.ios, &.android {
|
118
|
-
.button-has-border(button-ghost-disabled-text-color);
|
119
|
-
}
|
120
114
|
}
|
121
115
|
}
|
122
116
|
|
@@ -126,7 +120,7 @@
|
|
126
120
|
.set-button-size(@index) when (@index > 0) {
|
127
121
|
@size: extract(@size-map, @index);
|
128
122
|
|
129
|
-
|
123
|
+
&-size-@{size} {
|
130
124
|
.use-var(padding, "button-@{size}-padding");
|
131
125
|
.button-size-height("button-@{size}-height");
|
132
126
|
.button-text-size("button-@{size}-text-size");
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { DropdownOptionsProps, DropdownOptionsRef, DropdownRef } from './type';
|
3
|
+
export declare function componentGenerator<P extends DropdownOptionsProps = DropdownOptionsProps, R extends DropdownOptionsRef = DropdownOptionsRef>(Comp: React.ForwardRefExoticComponent<P & React.RefAttributes<R>>): React.ForwardRefExoticComponent<(import("./type").DropdownBasicProps & import("./type").SingleOptionProps & React.RefAttributes<DropdownRef>) | (import("./type").DropdownBasicProps & import("./type").MultipleOptionProps & React.RefAttributes<DropdownRef>)>;
|
@@ -0,0 +1,309 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(["exports", "@babel/runtime/helpers/extends", "react", "@arco-design/mobile-utils", "react-transition-group", "../context-provider", "../_helpers", "../portal"], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require("@babel/runtime/helpers/extends"), require("react"), require("@arco-design/mobile-utils"), require("react-transition-group"), require("../context-provider"), require("../_helpers"), require("../portal"));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global._extends, global.react, global.mobileUtils, global.reactTransitionGroup, global.contextProvider, global._helpers, global.portal);
|
11
|
+
global.dropdown = mod.exports;
|
12
|
+
}
|
13
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _extends2, _react, _mobileUtils, _reactTransitionGroup, _contextProvider, _helpers, _portal) {
|
14
|
+
"use strict";
|
15
|
+
|
16
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
17
|
+
|
18
|
+
_exports.__esModule = true;
|
19
|
+
_exports.componentGenerator = componentGenerator;
|
20
|
+
_extends2 = _interopRequireDefault(_extends2);
|
21
|
+
_react = _interopRequireWildcard(_react);
|
22
|
+
_portal = _interopRequireDefault(_portal);
|
23
|
+
|
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); }
|
25
|
+
|
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; }
|
27
|
+
|
28
|
+
function componentGenerator(Comp) {
|
29
|
+
return /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
30
|
+
var optionsWrapper = (0, _react.useRef)(null);
|
31
|
+
var domRef = (0, _react.useRef)(null);
|
32
|
+
var _props$className = props.className,
|
33
|
+
className = _props$className === void 0 ? '' : _props$className,
|
34
|
+
_props$style = props.style,
|
35
|
+
style = _props$style === void 0 ? {} : _props$style,
|
36
|
+
_props$options = props.options,
|
37
|
+
options = _props$options === void 0 ? [] : _props$options,
|
38
|
+
_props$showDropdown = props.showDropdown,
|
39
|
+
showDropdown = _props$showDropdown === void 0 ? false : _props$showDropdown,
|
40
|
+
_props$showMask = props.showMask,
|
41
|
+
showMask = _props$showMask === void 0 ? true : _props$showMask,
|
42
|
+
_props$direction = props.direction,
|
43
|
+
direction = _props$direction === void 0 ? 'down' : _props$direction,
|
44
|
+
height = props.height,
|
45
|
+
_props$maxHeight = props.maxHeight,
|
46
|
+
maxHeight = _props$maxHeight === void 0 ? 500 : _props$maxHeight,
|
47
|
+
_props$touchToClose = props.touchToClose,
|
48
|
+
touchToClose = _props$touchToClose === void 0 ? true : _props$touchToClose,
|
49
|
+
useColumn = props.useColumn,
|
50
|
+
optionIcon = props.optionIcon,
|
51
|
+
multiple = props.multiple,
|
52
|
+
defaultSelectedValue = props.defaultSelectedValue,
|
53
|
+
onCancel = props.onCancel,
|
54
|
+
getAnchorElement = props.getAnchorElement,
|
55
|
+
isStopTouchEl = props.isStopTouchEl,
|
56
|
+
getStopTouchElements = props.getStopTouchElements,
|
57
|
+
_props$getScrollConta = props.getScrollContainer,
|
58
|
+
getScrollContainer = _props$getScrollConta === void 0 ? function () {
|
59
|
+
return optionsWrapper.current;
|
60
|
+
} : _props$getScrollConta,
|
61
|
+
getPortalContainer = props.getPortalContainer,
|
62
|
+
_props$clickOtherToCl = props.clickOtherToClose,
|
63
|
+
clickOtherToClose = _props$clickOtherToCl === void 0 ? true : _props$clickOtherToCl,
|
64
|
+
_props$dropdownAnimat = props.dropdownAnimationTimeout,
|
65
|
+
dropdownAnimationTimeout = _props$dropdownAnimat === void 0 ? 300 : _props$dropdownAnimat,
|
66
|
+
_props$dropdownAnimat2 = props.dropdownAnimationFunction,
|
67
|
+
dropdownAnimationFunction = _props$dropdownAnimat2 === void 0 ? 'cubic-bezier(0.32, 0.96, 0.6, 1)' : _props$dropdownAnimat2,
|
68
|
+
_props$maskAnimationT = props.maskAnimationTimeout,
|
69
|
+
maskAnimationTimeout = _props$maskAnimationT === void 0 ? 500 : _props$maskAnimationT,
|
70
|
+
_props$maskAnimationF = props.maskAnimationFunction,
|
71
|
+
maskAnimationFunction = _props$maskAnimationF === void 0 ? 'cubic-bezier(0.32, 0.96, 0.6, 1)' : _props$maskAnimationF,
|
72
|
+
_props$mountOnEnter = props.mountOnEnter,
|
73
|
+
mountOnEnter = _props$mountOnEnter === void 0 ? true : _props$mountOnEnter,
|
74
|
+
_props$unmountOnExit = props.unmountOnExit,
|
75
|
+
unmountOnExit = _props$unmountOnExit === void 0 ? true : _props$unmountOnExit,
|
76
|
+
_props$preventBodyScr = props.preventBodyScroll,
|
77
|
+
preventBodyScroll = _props$preventBodyScr === void 0 ? true : _props$preventBodyScr,
|
78
|
+
initialBodyOverflow = props.initialBodyOverflow;
|
79
|
+
var system = (0, _helpers.useSystem)();
|
80
|
+
|
81
|
+
var _useWindowSize = (0, _helpers.useWindowSize)(),
|
82
|
+
windowHeight = _useWindowSize.windowHeight,
|
83
|
+
windowWidth = _useWindowSize.windowWidth;
|
84
|
+
|
85
|
+
var _useState = (0, _react.useState)({
|
86
|
+
top: '',
|
87
|
+
bottom: ''
|
88
|
+
}),
|
89
|
+
positionStyle = _useState[0],
|
90
|
+
setPositionStyle = _useState[1];
|
91
|
+
|
92
|
+
var _useState2 = (0, _react.useState)(function () {
|
93
|
+
var defaultValue = multiple ? [] : 0;
|
94
|
+
return defaultSelectedValue !== void 0 ? defaultSelectedValue : defaultValue;
|
95
|
+
}),
|
96
|
+
innerValue = _useState2[0],
|
97
|
+
setInnerValue = _useState2[1]; // down=0为向上展开,1为向下展开
|
98
|
+
// @en down=0 is to expand upwards, 1 is to expand downwards
|
99
|
+
|
100
|
+
|
101
|
+
var _useState3 = (0, _react.useState)(direction === 'down'),
|
102
|
+
down = _useState3[0],
|
103
|
+
setDown = _useState3[1];
|
104
|
+
|
105
|
+
var maskHeight = (0, _react.useRef)(0);
|
106
|
+
var optionsContainer = (0, _react.useRef)(null);
|
107
|
+
var dropdownContainer = (0, _react.useRef)(null);
|
108
|
+
|
109
|
+
var _useState4 = (0, _react.useState)(0),
|
110
|
+
optionsWrapperHeight = _useState4[0],
|
111
|
+
setOptionsWrapperHeight = _useState4[1];
|
112
|
+
/**
|
113
|
+
* 判断是否阻止touch事件
|
114
|
+
* @en Determine whether to block touch events
|
115
|
+
* */
|
116
|
+
|
117
|
+
|
118
|
+
var ifStopTouch = function ifStopTouch(el) {
|
119
|
+
var _dropdownContainer$cu;
|
120
|
+
|
121
|
+
if (isStopTouchEl) return isStopTouchEl(el);
|
122
|
+
var tempEl = el;
|
123
|
+
var elements = getStopTouchElements ? getStopTouchElements() : [(_dropdownContainer$cu = dropdownContainer.current) == null ? void 0 : _dropdownContainer$cu.parentElement];
|
124
|
+
|
125
|
+
for (var i = 0; i < elements.length; i++) {
|
126
|
+
while (tempEl && elements[i]) {
|
127
|
+
if (tempEl === elements[i]) {
|
128
|
+
return true;
|
129
|
+
}
|
130
|
+
|
131
|
+
tempEl = tempEl.parentElement;
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
return false;
|
136
|
+
};
|
137
|
+
|
138
|
+
(0, _helpers.usePopupScroll)(showDropdown, domRef.current, getScrollContainer);
|
139
|
+
(0, _helpers.usePreventBodyScroll)(showDropdown, preventBodyScroll, initialBodyOverflow);
|
140
|
+
(0, _react.useEffect)(function () {
|
141
|
+
var _dropdownContainer$cu2;
|
142
|
+
|
143
|
+
// 为0的时候不改变
|
144
|
+
// @en Does not change when it is 0
|
145
|
+
if (optionsWrapperHeight === 0) return;
|
146
|
+
var tempEl = getAnchorElement ? getAnchorElement() : (_dropdownContainer$cu2 = dropdownContainer.current) == null ? void 0 : _dropdownContainer$cu2.parentElement;
|
147
|
+
|
148
|
+
var _ref = (tempEl == null ? void 0 : tempEl.getBoundingClientRect()) || {
|
149
|
+
bottom: 0,
|
150
|
+
top: 0
|
151
|
+
},
|
152
|
+
bottom = _ref.bottom,
|
153
|
+
top = _ref.top;
|
154
|
+
|
155
|
+
var tempTop = props.top || bottom;
|
156
|
+
var tempBottom = props.bottom || windowHeight - top;
|
157
|
+
var tempMaskHeight = windowHeight - tempTop; // 没有指定方向,且空间足够时,或向上展开的空间不够,向下展开
|
158
|
+
// @en If there is no specified direction and there is enough space, or there is not enough space to expand upward, expand downward
|
159
|
+
|
160
|
+
var tempDown = direction !== 'up' && optionsWrapperHeight < tempMaskHeight || optionsWrapperHeight > tempTop;
|
161
|
+
|
162
|
+
if (tempDown) {
|
163
|
+
maskHeight.current = tempMaskHeight;
|
164
|
+
setPositionStyle({
|
165
|
+
top: tempTop + "px",
|
166
|
+
bottom: ''
|
167
|
+
});
|
168
|
+
} else {
|
169
|
+
maskHeight.current = windowHeight - tempBottom;
|
170
|
+
setPositionStyle({
|
171
|
+
top: '',
|
172
|
+
bottom: tempBottom + "px"
|
173
|
+
});
|
174
|
+
}
|
175
|
+
|
176
|
+
setDown(tempDown);
|
177
|
+
}, [dropdownContainer, optionsWrapperHeight, props.top, props.bottom, Boolean(getAnchorElement), direction, windowHeight]);
|
178
|
+
/**
|
179
|
+
* 取消选择
|
180
|
+
* @en Cancel selection
|
181
|
+
* */
|
182
|
+
|
183
|
+
var handleCancel = (0, _react.useCallback)(function (e) {
|
184
|
+
var optionsWrapperDom = optionsWrapper.current;
|
185
|
+
|
186
|
+
if (!e || !optionsWrapperDom) {
|
187
|
+
return;
|
188
|
+
}
|
189
|
+
|
190
|
+
var target = e.target;
|
191
|
+
|
192
|
+
if (!optionsWrapperDom.contains(target) && !ifStopTouch(target)) {
|
193
|
+
onCancel();
|
194
|
+
}
|
195
|
+
|
196
|
+
e.stopPropagation();
|
197
|
+
}, [ifStopTouch, onCancel]);
|
198
|
+
/**
|
199
|
+
* 当面板放下时,给body添加事件监听,面板收起时,移除
|
200
|
+
* @en When the panel is down, add an event listener to the body, and when the panel is retracted, remove it
|
201
|
+
* */
|
202
|
+
|
203
|
+
(0, _react.useEffect)(function () {
|
204
|
+
var needBind = showDropdown && clickOtherToClose;
|
205
|
+
var event = touchToClose ? 'touchstart' : 'click';
|
206
|
+
|
207
|
+
if (needBind) {
|
208
|
+
document.addEventListener(event, handleCancel);
|
209
|
+
}
|
210
|
+
|
211
|
+
return function () {
|
212
|
+
if (needBind) {
|
213
|
+
document.removeEventListener(event, handleCancel);
|
214
|
+
}
|
215
|
+
};
|
216
|
+
}, [showDropdown, clickOtherToClose, handleCancel]);
|
217
|
+
(0, _react.useEffect)(function () {
|
218
|
+
(0, _mobileUtils.nextTick)(function () {
|
219
|
+
if (height !== void 0) {
|
220
|
+
// 受控模式下,完全交由外层控制
|
221
|
+
// @en In controlled mode, it is completely controlled by the outer layer
|
222
|
+
setOptionsWrapperHeight(height);
|
223
|
+
} else {
|
224
|
+
if (!optionsContainer.current) return;
|
225
|
+
if (!showDropdown) setOptionsWrapperHeight(0);else {
|
226
|
+
setOptionsWrapperHeight(optionsContainer.current.getBoundingClientRect().height);
|
227
|
+
}
|
228
|
+
}
|
229
|
+
});
|
230
|
+
}, [showDropdown, options.length, height]);
|
231
|
+
(0, _react.useImperativeHandle)(ref, function () {
|
232
|
+
return {
|
233
|
+
dom: domRef.current
|
234
|
+
};
|
235
|
+
});
|
236
|
+
|
237
|
+
function getOptionsStyle() {
|
238
|
+
var trans = down ? 'translateY(-100%)' : 'translateY(100%)';
|
239
|
+
return (0, _helpers.getStyleWithVendor)({
|
240
|
+
// height: `${optionsWrapperHeight}px`,
|
241
|
+
transform: optionsWrapperHeight ? '' : trans,
|
242
|
+
transition: "transform " + dropdownAnimationTimeout + "ms " + dropdownAnimationFunction,
|
243
|
+
overflow: optionsWrapperHeight > maxHeight || height ? 'auto' : 'hidden',
|
244
|
+
maxHeight: maxHeight + "px"
|
245
|
+
});
|
246
|
+
}
|
247
|
+
|
248
|
+
function renderInnerOptions() {
|
249
|
+
var value = props.selectedValue !== void 0 ? props.selectedValue : innerValue;
|
250
|
+
var optionProps = {
|
251
|
+
options: options,
|
252
|
+
useColumn: useColumn,
|
253
|
+
icon: optionIcon,
|
254
|
+
selectedValue: value,
|
255
|
+
multiple: props.multiple,
|
256
|
+
onOptionClick: props.onOptionClick,
|
257
|
+
onOptionChange: function onOptionChange(vals, op) {
|
258
|
+
setInnerValue(vals);
|
259
|
+
props.onOptionChange == null ? void 0 : props.onOptionChange(vals, op);
|
260
|
+
}
|
261
|
+
};
|
262
|
+
return /*#__PURE__*/_react.default.createElement(Comp, optionProps);
|
263
|
+
}
|
264
|
+
|
265
|
+
return /*#__PURE__*/_react.default.createElement(_contextProvider.ContextLayout, null, function (_ref2) {
|
266
|
+
var prefixCls = _ref2.prefixCls;
|
267
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
268
|
+
ref: dropdownContainer
|
269
|
+
}, /*#__PURE__*/_react.default.createElement(_portal.default, {
|
270
|
+
getContainer: getPortalContainer
|
271
|
+
}, /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.CSSTransition, {
|
272
|
+
in: showDropdown,
|
273
|
+
timeout: Math.max(dropdownAnimationTimeout, maskAnimationTimeout),
|
274
|
+
onEnter: function onEnter(el) {
|
275
|
+
el.style.visibility = 'visible';
|
276
|
+
},
|
277
|
+
onExited: function onExited(el) {
|
278
|
+
el.style.visibility = 'hidden';
|
279
|
+
},
|
280
|
+
mountOnEnter: mountOnEnter,
|
281
|
+
unmountOnExit: unmountOnExit
|
282
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
283
|
+
className: (0, _mobileUtils.cls)(prefixCls + "-dropdown all-border-box", system, className, {
|
284
|
+
'drop-up': !down
|
285
|
+
}),
|
286
|
+
ref: domRef,
|
287
|
+
style: (0, _extends2.default)({
|
288
|
+
height: maskHeight.current + "px",
|
289
|
+
maxWidth: windowWidth + "px"
|
290
|
+
}, style, positionStyle)
|
291
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
292
|
+
className: (0, _mobileUtils.cls)(prefixCls + "-dropdown-options"),
|
293
|
+
ref: optionsWrapper,
|
294
|
+
style: getOptionsStyle()
|
295
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
296
|
+
className: (0, _mobileUtils.cls)(prefixCls + "-dropdown-options-container"),
|
297
|
+
ref: optionsContainer
|
298
|
+
}, props.children || renderInnerOptions(), props.extraNode)), showMask && /*#__PURE__*/_react.default.createElement("div", {
|
299
|
+
className: (0, _mobileUtils.cls)(prefixCls + "-dropdown-mask", {
|
300
|
+
'is-show': optionsWrapperHeight
|
301
|
+
}),
|
302
|
+
style: {
|
303
|
+
transition: "opacity " + maskAnimationTimeout + "ms " + maskAnimationFunction
|
304
|
+
}
|
305
|
+
})))));
|
306
|
+
});
|
307
|
+
});
|
308
|
+
}
|
309
|
+
});
|
package/umd/dropdown/index.d.ts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
|
2
|
-
import { DropdownRef } from './type';
|
1
|
+
/// <reference types="react" />
|
3
2
|
export * from './type';
|
4
|
-
declare const _default:
|
5
|
-
Options:
|
3
|
+
declare const _default: import("react").ForwardRefExoticComponent<(import("./type").DropdownBasicProps & import("./type").SingleOptionProps & import("react").RefAttributes<import("./type").DropdownRef>) | (import("./type").DropdownBasicProps & import("./type").MultipleOptionProps & import("react").RefAttributes<import("./type").DropdownRef>)> & {
|
4
|
+
Options: import("react").ForwardRefExoticComponent<(import("./type").DropdownOptionsBasicProps & import("./type").SingleOptionProps & import("react").RefAttributes<import("./type").DropdownOptionsRef>) | (import("./type").DropdownOptionsBasicProps & import("./type").MultipleOptionProps & import("react").RefAttributes<import("./type").DropdownOptionsRef>)>;
|
6
5
|
};
|
7
6
|
/**
|
8
7
|
* 下拉面板,展示供选择的选择项
|