KeywordTrigger.js
2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import Trigger from 'rc-trigger';
import * as React from 'react';
import DropdownMenu from './DropdownMenu';
var BUILT_IN_PLACEMENTS = {
bottomRight: {
points: ['tl', 'br'],
offset: [0, 4],
overflow: {
adjustX: 0,
adjustY: 1
}
},
bottomLeft: {
points: ['tr', 'bl'],
offset: [0, 4],
overflow: {
adjustX: 0,
adjustY: 1
}
},
topRight: {
points: ['bl', 'tr'],
offset: [0, -4],
overflow: {
adjustX: 0,
adjustY: 1
}
},
topLeft: {
points: ['br', 'tl'],
offset: [0, -4],
overflow: {
adjustX: 0,
adjustY: 1
}
}
};
var KeywordTrigger = /*#__PURE__*/function (_React$Component) {
_inherits(KeywordTrigger, _React$Component);
var _super = _createSuper(KeywordTrigger);
function KeywordTrigger() {
var _this;
_classCallCheck(this, KeywordTrigger);
_this = _super.apply(this, arguments);
_this.getDropdownPrefix = function () {
return "".concat(_this.props.prefixCls, "-dropdown");
};
_this.getDropdownElement = function () {
var options = _this.props.options;
return React.createElement(DropdownMenu, {
prefixCls: _this.getDropdownPrefix(),
options: options
});
};
_this.getDropDownPlacement = function () {
var _this$props = _this.props,
placement = _this$props.placement,
direction = _this$props.direction;
var popupPlacement = 'topRight';
if (direction === 'rtl') {
popupPlacement = placement === 'top' ? 'topLeft' : 'bottomLeft';
} else {
popupPlacement = placement === 'top' ? 'topRight' : 'bottomRight';
}
return popupPlacement;
};
return _this;
}
_createClass(KeywordTrigger, [{
key: "render",
value: function render() {
var _this$props2 = this.props,
children = _this$props2.children,
visible = _this$props2.visible,
transitionName = _this$props2.transitionName,
getPopupContainer = _this$props2.getPopupContainer;
var popupElement = this.getDropdownElement();
return React.createElement(Trigger, {
prefixCls: this.getDropdownPrefix(),
popupVisible: visible,
popup: popupElement,
popupPlacement: this.getDropDownPlacement(),
popupTransitionName: transitionName,
builtinPlacements: BUILT_IN_PLACEMENTS,
getPopupContainer: getPopupContainer
}, children);
}
}]);
return KeywordTrigger;
}(React.Component);
export default KeywordTrigger;