KeywordTrigger.js
3.33 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _rcTrigger = _interopRequireDefault(require("rc-trigger"));
var React = _interopRequireWildcard(require("react"));
var _DropdownMenu = _interopRequireDefault(require("./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) {
(0, _inherits2.default)(KeywordTrigger, _React$Component);
var _super = (0, _createSuper2.default)(KeywordTrigger);
function KeywordTrigger() {
var _this;
(0, _classCallCheck2.default)(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.default, {
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;
}
(0, _createClass2.default)(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(_rcTrigger.default, {
prefixCls: this.getDropdownPrefix(),
popupVisible: visible,
popup: popupElement,
popupPlacement: this.getDropDownPlacement(),
popupTransitionName: transitionName,
builtinPlacements: BUILT_IN_PLACEMENTS,
getPopupContainer: getPopupContainer
}, children);
}
}]);
return KeywordTrigger;
}(React.Component);
var _default = KeywordTrigger;
exports.default = _default;