index.js
6.86 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "TreeNode", {
enumerable: true,
get: function get() {
return _rcTreeSelect.TreeNode;
}
});
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var React = _interopRequireWildcard(require("react"));
var _rcTreeSelect = _interopRequireWildcard(require("rc-tree-select"));
var _classnames = _interopRequireDefault(require("classnames"));
var _omit = _interopRequireDefault(require("omit.js"));
var _configProvider = require("../config-provider");
var _devWarning = _interopRequireDefault(require("../_util/devWarning"));
var _iconUtil = _interopRequireDefault(require("../select/utils/iconUtil"));
var _iconUtil2 = _interopRequireDefault(require("../tree/utils/iconUtil"));
var _SizeContext = _interopRequireDefault(require("../config-provider/SizeContext"));
var __rest = void 0 && (void 0).__rest || function (s, e) {
var t = {};
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
}
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
var InternalTreeSelect = function InternalTreeSelect(_a, ref) {
var _classNames2;
var customizePrefixCls = _a.prefixCls,
customizeSize = _a.size,
_a$bordered = _a.bordered,
bordered = _a$bordered === void 0 ? true : _a$bordered,
className = _a.className,
treeCheckable = _a.treeCheckable,
multiple = _a.multiple,
_a$listHeight = _a.listHeight,
listHeight = _a$listHeight === void 0 ? 256 : _a$listHeight,
_a$listItemHeight = _a.listItemHeight,
listItemHeight = _a$listItemHeight === void 0 ? 26 : _a$listItemHeight,
notFoundContent = _a.notFoundContent,
_switcherIcon = _a.switcherIcon,
treeLine = _a.treeLine,
getPopupContainer = _a.getPopupContainer,
dropdownClassName = _a.dropdownClassName,
_a$treeIcon = _a.treeIcon,
treeIcon = _a$treeIcon === void 0 ? false : _a$treeIcon,
_a$transitionName = _a.transitionName,
transitionName = _a$transitionName === void 0 ? 'slide-up' : _a$transitionName,
_a$choiceTransitionNa = _a.choiceTransitionName,
choiceTransitionName = _a$choiceTransitionNa === void 0 ? '' : _a$choiceTransitionNa,
props = __rest(_a, ["prefixCls", "size", "bordered", "className", "treeCheckable", "multiple", "listHeight", "listItemHeight", "notFoundContent", "switcherIcon", "treeLine", "getPopupContainer", "dropdownClassName", "treeIcon", "transitionName", "choiceTransitionName"]);
var _React$useContext = React.useContext(_configProvider.ConfigContext),
getContextPopupContainer = _React$useContext.getPopupContainer,
getPrefixCls = _React$useContext.getPrefixCls,
renderEmpty = _React$useContext.renderEmpty,
direction = _React$useContext.direction,
virtual = _React$useContext.virtual,
dropdownMatchSelectWidth = _React$useContext.dropdownMatchSelectWidth;
var size = React.useContext(_SizeContext["default"]);
(0, _devWarning["default"])(multiple !== false || !treeCheckable, 'TreeSelect', '`multiple` will alway be `true` when `treeCheckable` is true');
var prefixCls = getPrefixCls('select', customizePrefixCls);
var treePrefixCls = getPrefixCls('select-tree', customizePrefixCls);
var treeSelectPrefixCls = getPrefixCls('tree-select', customizePrefixCls);
var mergedDropdownClassName = (0, _classnames["default"])(dropdownClassName, "".concat(treeSelectPrefixCls, "-dropdown"), (0, _defineProperty2["default"])({}, "".concat(treeSelectPrefixCls, "-dropdown-rtl"), direction === 'rtl'));
var isMultiple = !!(treeCheckable || multiple); // ===================== Icons =====================
var _getIcons = (0, _iconUtil["default"])((0, _extends2["default"])((0, _extends2["default"])({}, props), {
multiple: isMultiple,
prefixCls: prefixCls
})),
suffixIcon = _getIcons.suffixIcon,
itemIcon = _getIcons.itemIcon,
removeIcon = _getIcons.removeIcon,
clearIcon = _getIcons.clearIcon; // ===================== Empty =====================
var mergedNotFound;
if (notFoundContent !== undefined) {
mergedNotFound = notFoundContent;
} else {
mergedNotFound = renderEmpty('Select');
} // ==================== Render =====================
var selectProps = (0, _omit["default"])(props, ['suffixIcon', 'itemIcon', 'removeIcon', 'clearIcon', 'switcherIcon']);
var mergedSize = customizeSize || size;
var mergedClassName = (0, _classnames["default"])(!customizePrefixCls && treeSelectPrefixCls, (_classNames2 = {}, (0, _defineProperty2["default"])(_classNames2, "".concat(prefixCls, "-lg"), mergedSize === 'large'), (0, _defineProperty2["default"])(_classNames2, "".concat(prefixCls, "-sm"), mergedSize === 'small'), (0, _defineProperty2["default"])(_classNames2, "".concat(prefixCls, "-rtl"), direction === 'rtl'), (0, _defineProperty2["default"])(_classNames2, "".concat(prefixCls, "-borderless"), !bordered), _classNames2), className);
return /*#__PURE__*/React.createElement(_rcTreeSelect["default"], (0, _extends2["default"])({
virtual: virtual,
dropdownMatchSelectWidth: dropdownMatchSelectWidth
}, selectProps, {
ref: ref,
prefixCls: prefixCls,
className: mergedClassName,
listHeight: listHeight,
listItemHeight: listItemHeight,
treeCheckable: treeCheckable ? /*#__PURE__*/React.createElement("span", {
className: "".concat(prefixCls, "-tree-checkbox-inner")
}) : treeCheckable,
inputIcon: suffixIcon,
menuItemSelectedIcon: itemIcon,
multiple: multiple,
removeIcon: removeIcon,
clearIcon: clearIcon,
switcherIcon: function switcherIcon(nodeProps) {
return (0, _iconUtil2["default"])(treePrefixCls, _switcherIcon, treeLine, nodeProps);
},
showTreeIcon: treeIcon,
notFoundContent: mergedNotFound,
getPopupContainer: getPopupContainer || getContextPopupContainer,
treeMotion: null,
dropdownClassName: mergedDropdownClassName,
choiceTransitionName: choiceTransitionName,
transitionName: transitionName
}));
};
var TreeSelectRef = /*#__PURE__*/React.forwardRef(InternalTreeSelect);
var TreeSelect = TreeSelectRef;
TreeSelect.TreeNode = _rcTreeSelect.TreeNode;
TreeSelect.SHOW_ALL = _rcTreeSelect.SHOW_ALL;
TreeSelect.SHOW_PARENT = _rcTreeSelect.SHOW_PARENT;
TreeSelect.SHOW_CHILD = _rcTreeSelect.SHOW_CHILD;
var _default = TreeSelect;
exports["default"] = _default;