1 | "use strict";
|
2 |
|
3 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
4 |
|
5 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
6 |
|
7 | Object.defineProperty(exports, "__esModule", {
|
8 | value: true
|
9 | });
|
10 | exports.default = void 0;
|
11 |
|
12 | var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
13 |
|
14 | var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
15 |
|
16 | var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
17 |
|
18 | var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
19 |
|
20 | var _rcTrigger = _interopRequireDefault(require("rc-trigger"));
|
21 |
|
22 | var React = _interopRequireWildcard(require("react"));
|
23 |
|
24 | var _DropdownMenu = _interopRequireDefault(require("./DropdownMenu"));
|
25 |
|
26 | var BUILT_IN_PLACEMENTS = {
|
27 | bottomRight: {
|
28 | points: ['tl', 'br'],
|
29 | offset: [0, 4],
|
30 | overflow: {
|
31 | adjustX: 0,
|
32 | adjustY: 1
|
33 | }
|
34 | },
|
35 | bottomLeft: {
|
36 | points: ['tr', 'bl'],
|
37 | offset: [0, 4],
|
38 | overflow: {
|
39 | adjustX: 0,
|
40 | adjustY: 1
|
41 | }
|
42 | },
|
43 | topRight: {
|
44 | points: ['bl', 'tr'],
|
45 | offset: [0, -4],
|
46 | overflow: {
|
47 | adjustX: 0,
|
48 | adjustY: 1
|
49 | }
|
50 | },
|
51 | topLeft: {
|
52 | points: ['br', 'tl'],
|
53 | offset: [0, -4],
|
54 | overflow: {
|
55 | adjustX: 0,
|
56 | adjustY: 1
|
57 | }
|
58 | }
|
59 | };
|
60 |
|
61 | var KeywordTrigger = function (_React$Component) {
|
62 | (0, _inherits2.default)(KeywordTrigger, _React$Component);
|
63 |
|
64 | var _super = (0, _createSuper2.default)(KeywordTrigger);
|
65 |
|
66 | function KeywordTrigger() {
|
67 | var _this;
|
68 |
|
69 | (0, _classCallCheck2.default)(this, KeywordTrigger);
|
70 | _this = _super.apply(this, arguments);
|
71 |
|
72 | _this.getDropdownPrefix = function () {
|
73 | return "".concat(_this.props.prefixCls, "-dropdown");
|
74 | };
|
75 |
|
76 | _this.getDropdownElement = function () {
|
77 | var options = _this.props.options;
|
78 | return React.createElement(_DropdownMenu.default, {
|
79 | prefixCls: _this.getDropdownPrefix(),
|
80 | options: options
|
81 | });
|
82 | };
|
83 |
|
84 | _this.getDropDownPlacement = function () {
|
85 | var _this$props = _this.props,
|
86 | placement = _this$props.placement,
|
87 | direction = _this$props.direction;
|
88 | var popupPlacement = 'topRight';
|
89 |
|
90 | if (direction === 'rtl') {
|
91 | popupPlacement = placement === 'top' ? 'topLeft' : 'bottomLeft';
|
92 | } else {
|
93 | popupPlacement = placement === 'top' ? 'topRight' : 'bottomRight';
|
94 | }
|
95 |
|
96 | return popupPlacement;
|
97 | };
|
98 |
|
99 | return _this;
|
100 | }
|
101 |
|
102 | (0, _createClass2.default)(KeywordTrigger, [{
|
103 | key: "render",
|
104 | value: function render() {
|
105 | var _this$props2 = this.props,
|
106 | children = _this$props2.children,
|
107 | visible = _this$props2.visible,
|
108 | transitionName = _this$props2.transitionName,
|
109 | getPopupContainer = _this$props2.getPopupContainer;
|
110 | var popupElement = this.getDropdownElement();
|
111 | return React.createElement(_rcTrigger.default, {
|
112 | prefixCls: this.getDropdownPrefix(),
|
113 | popupVisible: visible,
|
114 | popup: popupElement,
|
115 | popupPlacement: this.getDropDownPlacement(),
|
116 | popupTransitionName: transitionName,
|
117 | builtinPlacements: BUILT_IN_PLACEMENTS,
|
118 | getPopupContainer: getPopupContainer
|
119 | }, children);
|
120 | }
|
121 | }]);
|
122 | return KeywordTrigger;
|
123 | }(React.Component);
|
124 |
|
125 | var _default = KeywordTrigger;
|
126 | exports.default = _default; |
\ | No newline at end of file |