@tendaui/react 1.1.1
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/LICENSE +21 -0
- package/README.md +2 -0
- package/es/_chunks/dep-0QH2Ee4R.js +34 -0
- package/es/_chunks/dep-0QH2Ee4R.js.map +1 -0
- package/es/_chunks/dep-B7HmDtze.js +199 -0
- package/es/_chunks/dep-B7HmDtze.js.map +1 -0
- package/es/_chunks/dep-BH5n5r1M.js +55 -0
- package/es/_chunks/dep-BH5n5r1M.js.map +1 -0
- package/es/_chunks/dep-BP0-apUT.js +9 -0
- package/es/_chunks/dep-BP0-apUT.js.map +1 -0
- package/es/_chunks/dep-C1XcmShP.js +18 -0
- package/es/_chunks/dep-C1XcmShP.js.map +1 -0
- package/es/_chunks/dep-C36au4Ip.js +104 -0
- package/es/_chunks/dep-C36au4Ip.js.map +1 -0
- package/es/_chunks/dep-CgyDw_YI.js +20 -0
- package/es/_chunks/dep-CgyDw_YI.js.map +1 -0
- package/es/_chunks/dep-CoIiHOgo.js +162 -0
- package/es/_chunks/dep-CoIiHOgo.js.map +1 -0
- package/es/_chunks/dep-Cwish4GD.js +29 -0
- package/es/_chunks/dep-Cwish4GD.js.map +1 -0
- package/es/_chunks/dep-CzLhKWCf.js +56 -0
- package/es/_chunks/dep-CzLhKWCf.js.map +1 -0
- package/es/_chunks/dep-D-UKOauR.js +12 -0
- package/es/_chunks/dep-D-UKOauR.js.map +1 -0
- package/es/_chunks/dep-D6YxJv-F.js +31 -0
- package/es/_chunks/dep-D6YxJv-F.js.map +1 -0
- package/es/_chunks/dep-D7LanWes.js +171 -0
- package/es/_chunks/dep-D7LanWes.js.map +1 -0
- package/es/_chunks/dep-D8jki30S.js +31 -0
- package/es/_chunks/dep-D8jki30S.js.map +1 -0
- package/es/_chunks/dep-DB5wmwh1.js +48 -0
- package/es/_chunks/dep-DB5wmwh1.js.map +1 -0
- package/es/_chunks/dep-DGvfel3I.js +16 -0
- package/es/_chunks/dep-DGvfel3I.js.map +1 -0
- package/es/_chunks/dep-DHWwZ2Nj.js +139 -0
- package/es/_chunks/dep-DHWwZ2Nj.js.map +1 -0
- package/es/_chunks/dep-DN7d1SzH.js +24 -0
- package/es/_chunks/dep-DN7d1SzH.js.map +1 -0
- package/es/_chunks/dep-DZ_0EvBk.js +440 -0
- package/es/_chunks/dep-DZ_0EvBk.js.map +1 -0
- package/es/_chunks/dep-Dk2xX8lh.js +691 -0
- package/es/_chunks/dep-Dk2xX8lh.js.map +1 -0
- package/es/_chunks/dep-DwWrhxkd.js +26 -0
- package/es/_chunks/dep-DwWrhxkd.js.map +1 -0
- package/es/_chunks/dep-EcrDKDlu.js +1677 -0
- package/es/_chunks/dep-EcrDKDlu.js.map +1 -0
- package/es/_chunks/dep-PPA-yoAy.js +16 -0
- package/es/_chunks/dep-PPA-yoAy.js.map +1 -0
- package/es/_chunks/dep-U1T8CQY9.js +4 -0
- package/es/_chunks/dep-U1T8CQY9.js.map +1 -0
- package/es/_chunks/dep-bWaVq_y3.js +14 -0
- package/es/_chunks/dep-bWaVq_y3.js.map +1 -0
- package/es/_chunks/dep-u1x3x6MJ.js +9 -0
- package/es/_chunks/dep-u1x3x6MJ.js.map +1 -0
- package/es/alert/Alert.js +153 -0
- package/es/alert/Alert.js.map +1 -0
- package/es/alert/index.js +23 -0
- package/es/alert/index.js.map +1 -0
- package/es/alert/style/css.js +1 -0
- package/es/alert/style/index.css +172 -0
- package/es/alert/style/index.js +2 -0
- package/es/alert/style/index.js.map +1 -0
- package/es/badge/Badge.js +81 -0
- package/es/badge/Badge.js.map +1 -0
- package/es/badge/index.js +15 -0
- package/es/badge/index.js.map +1 -0
- package/es/badge/style/css.js +1 -0
- package/es/badge/style/index.css +60 -0
- package/es/badge/style/index.js +2 -0
- package/es/badge/style/index.js.map +1 -0
- package/es/button/Button.js +94 -0
- package/es/button/Button.js.map +1 -0
- package/es/button/index.js +28 -0
- package/es/button/index.js.map +1 -0
- package/es/button/style/css.js +1 -0
- package/es/button/style/index.css +1206 -0
- package/es/button/style/index.js +2 -0
- package/es/button/style/index.js.map +1 -0
- package/es/checkbox/Checkbox.js +17 -0
- package/es/checkbox/Checkbox.js.map +1 -0
- package/es/checkbox/CheckboxGroup.js +17 -0
- package/es/checkbox/CheckboxGroup.js.map +1 -0
- package/es/checkbox/index.js +22 -0
- package/es/checkbox/index.js.map +1 -0
- package/es/checkbox/style/css.js +1 -0
- package/es/checkbox/style/index.css +151 -0
- package/es/checkbox/style/index.js +2 -0
- package/es/checkbox/style/index.js.map +1 -0
- package/es/common/Check.js +101 -0
- package/es/common/Check.js.map +1 -0
- package/es/common/FakeArrow.js +28 -0
- package/es/common/FakeArrow.js.map +1 -0
- package/es/common/PluginContainer.js +19 -0
- package/es/common/PluginContainer.js.map +1 -0
- package/es/common/Portal.js +53 -0
- package/es/common/Portal.js.map +1 -0
- package/es/config-provider/ConfigContext.js +17 -0
- package/es/config-provider/ConfigContext.js.map +1 -0
- package/es/config-provider/ConfigProvider.js +45 -0
- package/es/config-provider/ConfigProvider.js.map +1 -0
- package/es/config-provider/index.js +12 -0
- package/es/config-provider/index.js.map +1 -0
- package/es/dialog/Dialog.js +575 -0
- package/es/dialog/Dialog.js.map +1 -0
- package/es/dialog/DialogCard.js +28 -0
- package/es/dialog/DialogCard.js.map +1 -0
- package/es/dialog/index.js +44 -0
- package/es/dialog/index.js.map +1 -0
- package/es/dialog/plugin.js +199 -0
- package/es/dialog/plugin.js.map +1 -0
- package/es/dialog/style/css.js +1 -0
- package/es/dialog/style/index.css +510 -0
- package/es/dialog/style/index.js +2 -0
- package/es/dialog/style/index.js.map +1 -0
- package/es/form/Form.js +190 -0
- package/es/form/Form.js.map +1 -0
- package/es/form/FormContext.js +38 -0
- package/es/form/FormContext.js.map +1 -0
- package/es/form/FormItem.js +39 -0
- package/es/form/FormItem.js.map +1 -0
- package/es/form/FormList.js +306 -0
- package/es/form/FormList.js.map +1 -0
- package/es/form/hooks/useFormItemStyle.js +10 -0
- package/es/form/hooks/useFormItemStyle.js.map +1 -0
- package/es/form/hooks/useInstance.js +326 -0
- package/es/form/hooks/useInstance.js.map +1 -0
- package/es/form/index.js +47 -0
- package/es/form/index.js.map +1 -0
- package/es/form/style/css.js +1 -0
- package/es/form/style/index.css +296 -0
- package/es/form/style/index.js +2 -0
- package/es/form/style/index.js.map +1 -0
- package/es/form/utils/index.js +75 -0
- package/es/form/utils/index.js.map +1 -0
- package/es/hooks/useDragSorter.js +137 -0
- package/es/hooks/useDragSorter.js.map +1 -0
- package/es/index.js +103 -0
- package/es/index.js.map +1 -0
- package/es/input/Input.js +375 -0
- package/es/input/Input.js.map +1 -0
- package/es/input/InputGroup.js +23 -0
- package/es/input/InputGroup.js.map +1 -0
- package/es/input/index.js +23 -0
- package/es/input/index.js.map +1 -0
- package/es/input/style/css.js +1 -0
- package/es/input/style/index.css +450 -0
- package/es/input/style/index.js +2 -0
- package/es/input/style/index.js.map +1 -0
- package/es/loading/Gradient.js +86 -0
- package/es/loading/Gradient.js.map +1 -0
- package/es/loading/Loading.js +147 -0
- package/es/loading/Loading.js.map +1 -0
- package/es/loading/index.js +24 -0
- package/es/loading/index.js.map +1 -0
- package/es/loading/style/css.js +1 -0
- package/es/loading/style/index.css +191 -0
- package/es/loading/style/index.js +2 -0
- package/es/loading/style/index.js.map +1 -0
- package/es/myform/index.js +2 -0
- package/es/myform/index.js.map +1 -0
- package/es/notification/NotifyContainer.js +78 -0
- package/es/notification/NotifyContainer.js.map +1 -0
- package/es/notification/NotifyContext.js +149 -0
- package/es/notification/NotifyContext.js.map +1 -0
- package/es/notification/NotifyItem.js +150 -0
- package/es/notification/NotifyItem.js.map +1 -0
- package/es/notification/index.js +32 -0
- package/es/notification/index.js.map +1 -0
- package/es/notification/style/css.js +1 -0
- package/es/notification/style/index.css +142 -0
- package/es/notification/style/index.js +2 -0
- package/es/notification/style/index.js.map +1 -0
- package/es/popup/Popup.js +790 -0
- package/es/popup/Popup.js.map +1 -0
- package/es/popup/index.js +28 -0
- package/es/popup/index.js.map +1 -0
- package/es/popup/style/css.js +1 -0
- package/es/popup/style/index.css +186 -0
- package/es/popup/style/index.js +2 -0
- package/es/popup/style/index.js.map +1 -0
- package/es/portal/Portal.js +48 -0
- package/es/portal/Portal.js.map +1 -0
- package/es/portal/index.js +7 -0
- package/es/portal/index.js.map +1 -0
- package/es/select/Option.js +118 -0
- package/es/select/Option.js.map +1 -0
- package/es/select/OptionGroup.js +9 -0
- package/es/select/OptionGroup.js.map +1 -0
- package/es/select/PopupContent.js +16 -0
- package/es/select/PopupContent.js.map +1 -0
- package/es/select/Select.js +709 -0
- package/es/select/Select.js.map +1 -0
- package/es/select/index.js +66 -0
- package/es/select/index.js.map +1 -0
- package/es/select/style/css.js +1 -0
- package/es/select/style/index.css +437 -0
- package/es/select/style/index.js +2 -0
- package/es/select/style/index.js.map +1 -0
- package/es/select-input/SelectInput.js +202 -0
- package/es/select-input/SelectInput.js.map +1 -0
- package/es/select-input/hook/useMultiple.js +118 -0
- package/es/select-input/hook/useMultiple.js.map +1 -0
- package/es/select-input/hook/useSingle.js +105 -0
- package/es/select-input/hook/useSingle.js.map +1 -0
- package/es/select-input/index.js +51 -0
- package/es/select-input/index.js.map +1 -0
- package/es/select-input/style/css.js +1 -0
- package/es/select-input/style/index.css +0 -0
- package/es/select-input/style/index.js +2 -0
- package/es/select-input/style/index.js.map +1 -0
- package/es/space/index.js +2 -0
- package/es/space/index.js.map +1 -0
- package/es/style/index.css +490 -0
- package/es/style/index.js +2 -0
- package/es/style/index.js.map +1 -0
- package/es/switch/Switch.js +174 -0
- package/es/switch/Switch.js.map +1 -0
- package/es/switch/index.js +28 -0
- package/es/switch/index.js.map +1 -0
- package/es/switch/style/css.js +1 -0
- package/es/switch/style/index.css +239 -0
- package/es/switch/style/index.js +2 -0
- package/es/switch/style/index.js.map +1 -0
- package/es/tag/Tag.js +1312 -0
- package/es/tag/Tag.js.map +1 -0
- package/es/tag/index.js +21 -0
- package/es/tag/index.js.map +1 -0
- package/es/tag/style/css.js +1 -0
- package/es/tag/style/index.css +236 -0
- package/es/tag/style/index.js +2 -0
- package/es/tag/style/index.js.map +1 -0
- package/es/tag-input/TagInput.js +360 -0
- package/es/tag-input/TagInput.js.map +1 -0
- package/es/tag-input/hooks/useTagList.js +167 -0
- package/es/tag-input/hooks/useTagList.js.map +1 -0
- package/es/tag-input/index.js +35 -0
- package/es/tag-input/index.js.map +1 -0
- package/es/tag-input/style/css.js +1 -0
- package/es/tag-input/style/index.css +223 -0
- package/es/tag-input/style/index.js +2 -0
- package/es/tag-input/style/index.js.map +1 -0
- package/es/tag-input/useTagList.js +167 -0
- package/es/tag-input/useTagList.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
import { _ as _defineProperty } from '../_chunks/dep-Cwish4GD.js';
|
|
2
|
+
import { _ as _objectWithoutProperties } from '../_chunks/dep-DN7d1SzH.js';
|
|
3
|
+
import { _ as _slicedToArray } from '../_chunks/dep-CzLhKWCf.js';
|
|
4
|
+
import React, { useState, useEffect, useRef, useMemo, useCallback, Children, isValidElement, cloneElement } from 'react';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import { get, isFunction, debounce } from 'lodash-es';
|
|
7
|
+
import { a as getOffsetTopToContainer } from '../_chunks/dep-DHWwZ2Nj.js';
|
|
8
|
+
import { u as useControlled } from '../_chunks/dep-DwWrhxkd.js';
|
|
9
|
+
import { u as useConfig } from '../_chunks/dep-u1x3x6MJ.js';
|
|
10
|
+
import { f as forwardRefWithStatics } from '../_chunks/dep-BP0-apUT.js';
|
|
11
|
+
import { g as getValueToOption, a as getSelectValueArr, b as getSelectedOptions, P as PopupContent } from '../_chunks/dep-Dk2xX8lh.js';
|
|
12
|
+
import { n as noop } from '../_chunks/dep-U1T8CQY9.js';
|
|
13
|
+
import FakeArrow from '../common/FakeArrow.js';
|
|
14
|
+
import { Loading } from '../loading/index.js';
|
|
15
|
+
import { SelectInput } from '../select-input/index.js';
|
|
16
|
+
import Option from './Option.js';
|
|
17
|
+
import { O as OptionGroup, s as selectDefaultProps } from '../_chunks/dep-DB5wmwh1.js';
|
|
18
|
+
import { Tag } from '../tag/index.js';
|
|
19
|
+
import { _ as _typeof } from '../_chunks/dep-D-UKOauR.js';
|
|
20
|
+
import { c as composeRefs } from '../_chunks/dep-C1XcmShP.js';
|
|
21
|
+
import { p as parseContentTNode } from '../_chunks/dep-D8jki30S.js';
|
|
22
|
+
import { u as useDefaultProps } from '../_chunks/dep-DGvfel3I.js';
|
|
23
|
+
import '../config-provider/ConfigContext.js';
|
|
24
|
+
import 'hoist-non-react-statics';
|
|
25
|
+
import '../_chunks/dep-CgyDw_YI.js';
|
|
26
|
+
import '../loading/Loading.js';
|
|
27
|
+
import '../_chunks/dep-0QH2Ee4R.js';
|
|
28
|
+
import '../common/Portal.js';
|
|
29
|
+
import 'react-dom';
|
|
30
|
+
import '../loading/Gradient.js';
|
|
31
|
+
import '../_chunks/dep-PPA-yoAy.js';
|
|
32
|
+
import '../_chunks/dep-BH5n5r1M.js';
|
|
33
|
+
import '../loading/style/css.js';
|
|
34
|
+
import '../select-input/SelectInput.js';
|
|
35
|
+
import '../select-input/hook/useSingle.js';
|
|
36
|
+
import '../input/index.js';
|
|
37
|
+
import '../input/Input.js';
|
|
38
|
+
import '@tendaui/icons';
|
|
39
|
+
import '../_chunks/dep-D6YxJv-F.js';
|
|
40
|
+
import '../input/InputGroup.js';
|
|
41
|
+
import '../input/style/css.js';
|
|
42
|
+
import '../select-input/hook/useMultiple.js';
|
|
43
|
+
import '../tag-input/index.js';
|
|
44
|
+
import '../tag-input/TagInput.js';
|
|
45
|
+
import '../tag-input/hooks/useTagList.js';
|
|
46
|
+
import '../_chunks/dep-bWaVq_y3.js';
|
|
47
|
+
import '../hooks/useDragSorter.js';
|
|
48
|
+
import '../tag/Tag.js';
|
|
49
|
+
import '../tag/style/css.js';
|
|
50
|
+
import '../tag-input/style/css.js';
|
|
51
|
+
import '../popup/index.js';
|
|
52
|
+
import '../popup/Popup.js';
|
|
53
|
+
import '../portal/Portal.js';
|
|
54
|
+
import 'react-is';
|
|
55
|
+
import '@popperjs/core';
|
|
56
|
+
import 'react-fast-compare';
|
|
57
|
+
import 'react-transition-group';
|
|
58
|
+
import '../popup/style/css.js';
|
|
59
|
+
import '../select-input/style/css.js';
|
|
60
|
+
|
|
61
|
+
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
62
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
63
|
+
function isSelectOptionGroup(option) {
|
|
64
|
+
return !!option && "group" in option && "children" in option;
|
|
65
|
+
}
|
|
66
|
+
function UseOptions(keys, options, children, valueType, value, reserveKeyword) {
|
|
67
|
+
var _useState = useState({}),
|
|
68
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
69
|
+
valueToOption = _useState2[0],
|
|
70
|
+
setValueToOption = _useState2[1];
|
|
71
|
+
var _useState3 = useState([]),
|
|
72
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
73
|
+
currentOptions = _useState4[0],
|
|
74
|
+
setCurrentOptions = _useState4[1];
|
|
75
|
+
var _useState5 = useState([]),
|
|
76
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
77
|
+
tmpPropOptions = _useState6[0],
|
|
78
|
+
setTmpPropOptions = _useState6[1];
|
|
79
|
+
var _useState7 = useState([]),
|
|
80
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
81
|
+
selectedOptions = _useState8[0],
|
|
82
|
+
setSelectedOptions = _useState8[1];
|
|
83
|
+
useEffect(function () {
|
|
84
|
+
var transformedOptions = options;
|
|
85
|
+
var arrayChildren = React.Children.toArray(children);
|
|
86
|
+
var optionChildren = arrayChildren.filter(function (v) {
|
|
87
|
+
return v.type === Option || v.type === OptionGroup;
|
|
88
|
+
});
|
|
89
|
+
var isChildrenFilterable = arrayChildren.length > 0 && optionChildren.length === arrayChildren.length;
|
|
90
|
+
if (reserveKeyword && currentOptions.length && isChildrenFilterable) return;
|
|
91
|
+
if (isChildrenFilterable) {
|
|
92
|
+
var _handlerOptionElement = function handlerOptionElement(v) {
|
|
93
|
+
if (/*#__PURE__*/React.isValidElement(v)) {
|
|
94
|
+
if (v.type === OptionGroup) {
|
|
95
|
+
var _v$props$children;
|
|
96
|
+
return _objectSpread$1(_objectSpread$1({}, v.props), {}, {
|
|
97
|
+
group: v.props.label,
|
|
98
|
+
children: (_v$props$children = v.props.children) === null || _v$props$children === void 0 ? void 0 : _v$props$children.map(function (v2) {
|
|
99
|
+
return _handlerOptionElement(v2);
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return _objectSpread$1(_objectSpread$1({}, v.props), {}, {
|
|
104
|
+
label: v.props.label || v.props.children
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
label: v
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
transformedOptions = arrayChildren === null || arrayChildren === void 0 ? void 0 : arrayChildren.map(function (v) {
|
|
112
|
+
return _handlerOptionElement(v);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
if (keys) {
|
|
116
|
+
var _transformedOptions;
|
|
117
|
+
transformedOptions = (_transformedOptions = transformedOptions) === null || _transformedOptions === void 0 ? void 0 : _transformedOptions.map(function (option) {
|
|
118
|
+
return _objectSpread$1(_objectSpread$1({}, option), {}, {
|
|
119
|
+
value: get(option, (keys === null || keys === void 0 ? void 0 : keys.value) || "value"),
|
|
120
|
+
label: get(option, (keys === null || keys === void 0 ? void 0 : keys.label) || "label")
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
setCurrentOptions(transformedOptions);
|
|
125
|
+
setTmpPropOptions(transformedOptions);
|
|
126
|
+
setValueToOption(getValueToOption(children, options, keys) || {});
|
|
127
|
+
}, [options, keys, children, reserveKeyword]);
|
|
128
|
+
useEffect(function () {
|
|
129
|
+
var valueKey = (keys === null || keys === void 0 ? void 0 : keys.value) || "value";
|
|
130
|
+
var labelKey = (keys === null || keys === void 0 ? void 0 : keys.label) || "label";
|
|
131
|
+
setSelectedOptions(function (oldSelectedOptions) {
|
|
132
|
+
var createOptionFromValue = function createOptionFromValue(item) {
|
|
133
|
+
if (valueType === "value") {
|
|
134
|
+
return valueToOption[item] || oldSelectedOptions.find(function (option) {
|
|
135
|
+
return get(option, valueKey) === item;
|
|
136
|
+
}) || _defineProperty(_defineProperty({}, valueKey, item), labelKey, item);
|
|
137
|
+
}
|
|
138
|
+
if (_typeof(item) === "object" && item !== null) {
|
|
139
|
+
return item;
|
|
140
|
+
}
|
|
141
|
+
return [];
|
|
142
|
+
};
|
|
143
|
+
if (Array.isArray(value)) {
|
|
144
|
+
return value.map(createOptionFromValue);
|
|
145
|
+
}
|
|
146
|
+
if (value !== void 0 && value !== null) {
|
|
147
|
+
var option = createOptionFromValue(value);
|
|
148
|
+
return option ? [option] : [];
|
|
149
|
+
}
|
|
150
|
+
return [];
|
|
151
|
+
});
|
|
152
|
+
}, [value, keys, valueType, valueToOption, setSelectedOptions]);
|
|
153
|
+
return {
|
|
154
|
+
currentOptions: currentOptions,
|
|
155
|
+
setCurrentOptions: setCurrentOptions,
|
|
156
|
+
tmpPropOptions: tmpPropOptions,
|
|
157
|
+
setTmpPropOptions: setTmpPropOptions,
|
|
158
|
+
valueToOption: valueToOption,
|
|
159
|
+
setValueToOption: setValueToOption,
|
|
160
|
+
selectedOptions: selectedOptions,
|
|
161
|
+
setSelectedOptions: setSelectedOptions
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
var _excluded = ["overlayClassName", "onScroll", "onScrollToBottom"];
|
|
166
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
167
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
168
|
+
var Select = forwardRefWithStatics(function (originalProps, ref) {
|
|
169
|
+
var props = useDefaultProps(originalProps, selectDefaultProps);
|
|
170
|
+
var readonly = props.readonly,
|
|
171
|
+
borderless = props.borderless,
|
|
172
|
+
autoWidth = props.autoWidth,
|
|
173
|
+
creatable = props.creatable,
|
|
174
|
+
_props$loadingText = props.loadingText,
|
|
175
|
+
loadingText = _props$loadingText === void 0 ? "\u52A0\u8F7D\u4E2D..." : _props$loadingText,
|
|
176
|
+
max = props.max,
|
|
177
|
+
popupProps = props.popupProps,
|
|
178
|
+
reserveKeyword = props.reserveKeyword,
|
|
179
|
+
className = props.className,
|
|
180
|
+
style = props.style,
|
|
181
|
+
disabled = props.disabled,
|
|
182
|
+
size = props.size,
|
|
183
|
+
multiple = props.multiple,
|
|
184
|
+
placeholder = props.placeholder,
|
|
185
|
+
clearable = props.clearable,
|
|
186
|
+
prefixIcon = props.prefixIcon,
|
|
187
|
+
options = props.options,
|
|
188
|
+
filterable = props.filterable,
|
|
189
|
+
loading = props.loading,
|
|
190
|
+
empty = props.empty,
|
|
191
|
+
valueType = props.valueType,
|
|
192
|
+
keys = props.keys,
|
|
193
|
+
children = props.children,
|
|
194
|
+
collapsedItems = props.collapsedItems,
|
|
195
|
+
minCollapsedNum = props.minCollapsedNum,
|
|
196
|
+
valueDisplay = props.valueDisplay,
|
|
197
|
+
showArrow = props.showArrow,
|
|
198
|
+
inputProps = props.inputProps,
|
|
199
|
+
panelBottomContent = props.panelBottomContent,
|
|
200
|
+
panelTopContent = props.panelTopContent,
|
|
201
|
+
selectInputProps = props.selectInputProps,
|
|
202
|
+
tagInputProps = props.tagInputProps,
|
|
203
|
+
tagProps = props.tagProps,
|
|
204
|
+
scroll = props.scroll,
|
|
205
|
+
suffixIcon = props.suffixIcon,
|
|
206
|
+
label = props.label,
|
|
207
|
+
filter = props.filter,
|
|
208
|
+
onFocus = props.onFocus,
|
|
209
|
+
_onBlur = props.onBlur,
|
|
210
|
+
_props$onClear = props.onClear,
|
|
211
|
+
onClear = _props$onClear === void 0 ? noop : _props$onClear,
|
|
212
|
+
onCreate = props.onCreate,
|
|
213
|
+
onRemove = props.onRemove,
|
|
214
|
+
onSearch = props.onSearch,
|
|
215
|
+
onEnter = props.onEnter,
|
|
216
|
+
onPopupVisibleChange = props.onPopupVisibleChange;
|
|
217
|
+
var _useControlled = useControlled(props, "value", props.onChange),
|
|
218
|
+
_useControlled2 = _slicedToArray(_useControlled, 2),
|
|
219
|
+
value = _useControlled2[0],
|
|
220
|
+
onChange = _useControlled2[1];
|
|
221
|
+
var selectInputRef = useRef(null);
|
|
222
|
+
var _useConfig = useConfig(),
|
|
223
|
+
classPrefix = _useConfig.classPrefix;
|
|
224
|
+
var _ref = popupProps || {},
|
|
225
|
+
overlayClassName = _ref.overlayClassName,
|
|
226
|
+
onScroll = _ref.onScroll,
|
|
227
|
+
onScrollToBottom = _ref.onScrollToBottom,
|
|
228
|
+
restPopupProps = _objectWithoutProperties(_ref, _excluded);
|
|
229
|
+
var _useState = useState(false),
|
|
230
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
231
|
+
isScrolling = _useState2[0],
|
|
232
|
+
toggleIsScrolling = _useState2[1];
|
|
233
|
+
var name = "".concat(classPrefix, "-select");
|
|
234
|
+
var _useControlled3 = useControlled(props, "popupVisible", onPopupVisibleChange),
|
|
235
|
+
_useControlled4 = _slicedToArray(_useControlled3, 2),
|
|
236
|
+
showPopup = _useControlled4[0],
|
|
237
|
+
setShowPopup = _useControlled4[1];
|
|
238
|
+
var _useControlled5 = useControlled(props, "inputValue", props.onInputChange),
|
|
239
|
+
_useControlled6 = _slicedToArray(_useControlled5, 2),
|
|
240
|
+
inputValue = _useControlled6[0],
|
|
241
|
+
onInputChange = _useControlled6[1];
|
|
242
|
+
var _useOptions = UseOptions(keys, options, children, valueType, value, reserveKeyword),
|
|
243
|
+
currentOptions = _useOptions.currentOptions,
|
|
244
|
+
setCurrentOptions = _useOptions.setCurrentOptions,
|
|
245
|
+
tmpPropOptions = _useOptions.tmpPropOptions,
|
|
246
|
+
valueToOption = _useOptions.valueToOption,
|
|
247
|
+
selectedOptions = _useOptions.selectedOptions;
|
|
248
|
+
var selectedLabel = useMemo(function () {
|
|
249
|
+
if (multiple) {
|
|
250
|
+
return selectedOptions.map(function (selectedOption) {
|
|
251
|
+
return get(selectedOption || {}, (keys === null || keys === void 0 ? void 0 : keys.label) || "label") || "";
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
return get(selectedOptions[0] || {}, (keys === null || keys === void 0 ? void 0 : keys.label) || "label") || void 0;
|
|
255
|
+
}, [selectedOptions, keys, multiple]);
|
|
256
|
+
var handleShowPopup = function handleShowPopup(visible, ctx) {
|
|
257
|
+
if (disabled) return;
|
|
258
|
+
if (visible) {
|
|
259
|
+
toggleIsScrolling(false);
|
|
260
|
+
}
|
|
261
|
+
if (!visible) {
|
|
262
|
+
onInputChange("", {
|
|
263
|
+
trigger: "blur"
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
setShowPopup(visible, ctx);
|
|
267
|
+
};
|
|
268
|
+
var onTagChange = function onTagChange(_currentTags, context) {
|
|
269
|
+
var trigger = context.trigger,
|
|
270
|
+
index = context.index,
|
|
271
|
+
item = context.item,
|
|
272
|
+
e = context.e;
|
|
273
|
+
if (trigger === "backspace") {
|
|
274
|
+
e.stopPropagation();
|
|
275
|
+
var closest = -1;
|
|
276
|
+
var len = index;
|
|
277
|
+
while (len >= 0) {
|
|
278
|
+
var option = selectedOptions[len];
|
|
279
|
+
if (!isSelectOptionGroup(option) && !option.disabled) {
|
|
280
|
+
closest = len;
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
len -= 1;
|
|
284
|
+
}
|
|
285
|
+
if (closest < 0) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
var values = getSelectValueArr(value, value[closest], true, valueType, keys);
|
|
289
|
+
var _getSelectedOptions = getSelectedOptions(values, multiple, valueType, keys, valueToOption),
|
|
290
|
+
currentSelectedOptions = _getSelectedOptions.currentSelectedOptions;
|
|
291
|
+
onChange(values, {
|
|
292
|
+
e: e,
|
|
293
|
+
trigger: trigger,
|
|
294
|
+
selectedOptions: currentSelectedOptions
|
|
295
|
+
});
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
if (trigger === "tag-remove") {
|
|
299
|
+
var _e$stopPropagation;
|
|
300
|
+
e === null || e === void 0 || (_e$stopPropagation = e.stopPropagation) === null || _e$stopPropagation === void 0 || _e$stopPropagation.call(e);
|
|
301
|
+
var _values = getSelectValueArr(value, value[index], true, valueType, keys);
|
|
302
|
+
var _getSelectedOptions2 = getSelectedOptions(_values, multiple, valueType, keys, valueToOption),
|
|
303
|
+
_currentSelectedOptions = _getSelectedOptions2.currentSelectedOptions;
|
|
304
|
+
onChange(_values, {
|
|
305
|
+
e: e,
|
|
306
|
+
trigger: trigger,
|
|
307
|
+
selectedOptions: _currentSelectedOptions
|
|
308
|
+
});
|
|
309
|
+
if (isFunction(onRemove)) {
|
|
310
|
+
onRemove({
|
|
311
|
+
value: value[index],
|
|
312
|
+
data: {
|
|
313
|
+
label: item,
|
|
314
|
+
value: value[index]
|
|
315
|
+
},
|
|
316
|
+
e: e
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
var onCheckAllChange = function onCheckAllChange(checkAll, e) {
|
|
322
|
+
var _props$value;
|
|
323
|
+
var isDisabledCheckAll = function isDisabledCheckAll(opt) {
|
|
324
|
+
return opt.checkAll && opt.disabled;
|
|
325
|
+
};
|
|
326
|
+
if (!multiple || currentOptions.some(function (opt) {
|
|
327
|
+
return !isSelectOptionGroup(opt) && isDisabledCheckAll(opt);
|
|
328
|
+
})) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
var isSelectableOption = function isSelectableOption(opt) {
|
|
332
|
+
return !opt.checkAll && !opt.disabled;
|
|
333
|
+
};
|
|
334
|
+
var getOptionValue = function getOptionValue(option) {
|
|
335
|
+
return valueType === "object" ? option : option[(keys === null || keys === void 0 ? void 0 : keys.value) || "value"];
|
|
336
|
+
};
|
|
337
|
+
var values = [];
|
|
338
|
+
currentOptions.forEach(function (option) {
|
|
339
|
+
if (isSelectOptionGroup(option)) {
|
|
340
|
+
option.children.forEach(function (item) {
|
|
341
|
+
if (isSelectableOption(item)) {
|
|
342
|
+
values.push(getOptionValue(item));
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
} else if (isSelectableOption(option)) {
|
|
346
|
+
values.push(getOptionValue(option));
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
var _getSelectedOptions3 = getSelectedOptions(values, multiple, valueType, keys, valueToOption),
|
|
350
|
+
currentSelectedOptions = _getSelectedOptions3.currentSelectedOptions,
|
|
351
|
+
allSelectedValue = _getSelectedOptions3.allSelectedValue;
|
|
352
|
+
var checkAllValue = !checkAll && allSelectedValue.length !== ((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.length) ? allSelectedValue : [];
|
|
353
|
+
onChange === null || onChange === void 0 || onChange(checkAllValue, {
|
|
354
|
+
e: e,
|
|
355
|
+
trigger: !checkAll ? "check" : "uncheck",
|
|
356
|
+
selectedOptions: currentSelectedOptions
|
|
357
|
+
});
|
|
358
|
+
};
|
|
359
|
+
var handleChange = function handleChange(value2, context) {
|
|
360
|
+
var selectedValue = multiple ? context.value : value2;
|
|
361
|
+
if (multiple) {
|
|
362
|
+
if (!reserveKeyword && inputValue) {
|
|
363
|
+
onInputChange("", {
|
|
364
|
+
e: context.e,
|
|
365
|
+
trigger: "change"
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (creatable && isFunction(onCreate)) {
|
|
370
|
+
if (options.filter(function (option) {
|
|
371
|
+
return option.value === selectedValue;
|
|
372
|
+
}).length === 0) {
|
|
373
|
+
onCreate(selectedValue);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
var _getSelectedOptions4 = getSelectedOptions(value2, multiple, valueType, keys, valueToOption, selectedValue),
|
|
377
|
+
currentSelectedOptions = _getSelectedOptions4.currentSelectedOptions,
|
|
378
|
+
currentOption = _getSelectedOptions4.currentOption;
|
|
379
|
+
onChange === null || onChange === void 0 || onChange(value2, {
|
|
380
|
+
e: context.e,
|
|
381
|
+
trigger: context.trigger,
|
|
382
|
+
selectedOptions: currentSelectedOptions,
|
|
383
|
+
option: currentOption
|
|
384
|
+
});
|
|
385
|
+
if (multiple && (context === null || context === void 0 ? void 0 : context.trigger) === "uncheck" && isFunction(onRemove)) {
|
|
386
|
+
var value3 = context === null || context === void 0 ? void 0 : context.value;
|
|
387
|
+
var option = options.find(function (option2) {
|
|
388
|
+
return option2.value === value3;
|
|
389
|
+
});
|
|
390
|
+
onRemove({
|
|
391
|
+
value: value3,
|
|
392
|
+
data: option,
|
|
393
|
+
e: context.e
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
var handleFilter = function handleFilter(value2) {
|
|
398
|
+
var filteredOptions = [];
|
|
399
|
+
if (filterable && isFunction(onSearch)) {
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
if (!value2) {
|
|
403
|
+
setCurrentOptions(tmpPropOptions);
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
var filterLabels = [];
|
|
407
|
+
var filterMethods = function filterMethods(option) {
|
|
408
|
+
if (filter && isFunction(filter)) {
|
|
409
|
+
return filter(value2, option);
|
|
410
|
+
}
|
|
411
|
+
var upperValue = value2.toUpperCase();
|
|
412
|
+
return (String(option === null || option === void 0 ? void 0 : option.label) || "").toUpperCase().includes(upperValue);
|
|
413
|
+
};
|
|
414
|
+
tmpPropOptions === null || tmpPropOptions === void 0 || tmpPropOptions.forEach(function (option) {
|
|
415
|
+
if (isSelectOptionGroup(option)) {
|
|
416
|
+
var _option$children;
|
|
417
|
+
filteredOptions.push(_objectSpread(_objectSpread({}, option), {}, {
|
|
418
|
+
children: (_option$children = option.children) === null || _option$children === void 0 ? void 0 : _option$children.filter(function (child) {
|
|
419
|
+
if (filterMethods(child)) {
|
|
420
|
+
filterLabels.push(child.label);
|
|
421
|
+
return true;
|
|
422
|
+
}
|
|
423
|
+
return false;
|
|
424
|
+
})
|
|
425
|
+
}));
|
|
426
|
+
} else if (filterMethods(option)) {
|
|
427
|
+
filterLabels.push(option.label);
|
|
428
|
+
filteredOptions.push(option);
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
var isSameLabelOptionExist = filterLabels.includes(value2);
|
|
432
|
+
if (creatable && !isSameLabelOptionExist) {
|
|
433
|
+
filteredOptions = filteredOptions.concat([{
|
|
434
|
+
label: value2,
|
|
435
|
+
value: value2
|
|
436
|
+
}]);
|
|
437
|
+
}
|
|
438
|
+
setCurrentOptions(filteredOptions);
|
|
439
|
+
};
|
|
440
|
+
var handleInputChange = function handleInputChange(value2, context) {
|
|
441
|
+
if (context.trigger !== "clear") {
|
|
442
|
+
onInputChange(value2, {
|
|
443
|
+
e: context.e,
|
|
444
|
+
trigger: "input"
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
if (value2 === void 0) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
if (isFunction(onSearch)) {
|
|
451
|
+
onSearch(value2, {
|
|
452
|
+
e: context.e
|
|
453
|
+
});
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
var handleClear = function handleClear(context) {
|
|
458
|
+
context.e.stopPropagation();
|
|
459
|
+
if (Array.isArray(value)) {
|
|
460
|
+
onChange([], _objectSpread(_objectSpread({}, context), {}, {
|
|
461
|
+
trigger: "clear",
|
|
462
|
+
selectedOptions: []
|
|
463
|
+
}));
|
|
464
|
+
} else {
|
|
465
|
+
onChange(null, _objectSpread(_objectSpread({}, context), {}, {
|
|
466
|
+
trigger: "clear",
|
|
467
|
+
selectedOptions: []
|
|
468
|
+
}));
|
|
469
|
+
}
|
|
470
|
+
onClear(context);
|
|
471
|
+
};
|
|
472
|
+
useEffect(function () {
|
|
473
|
+
if (typeof inputValue !== "undefined") {
|
|
474
|
+
handleFilter(String(inputValue));
|
|
475
|
+
}
|
|
476
|
+
}, [inputValue, tmpPropOptions]);
|
|
477
|
+
var renderSuffixIcon = function renderSuffixIcon() {
|
|
478
|
+
if (suffixIcon) {
|
|
479
|
+
return suffixIcon;
|
|
480
|
+
}
|
|
481
|
+
if (loading) {
|
|
482
|
+
return /* @__PURE__ */React.createElement(Loading, {
|
|
483
|
+
className: classNames("".concat(name, "__right-icon"), "".concat(name, "__active-icon")),
|
|
484
|
+
loading: true,
|
|
485
|
+
size: "small"
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
return showArrow && /* @__PURE__ */React.createElement(FakeArrow, {
|
|
489
|
+
className: "".concat(name, "__right-icon"),
|
|
490
|
+
isActive: showPopup,
|
|
491
|
+
disabled: disabled
|
|
492
|
+
});
|
|
493
|
+
};
|
|
494
|
+
var getPopupInstance = useCallback(function () {
|
|
495
|
+
var _selectInputRef$curre;
|
|
496
|
+
return (_selectInputRef$curre = selectInputRef.current) === null || _selectInputRef$curre === void 0 ? void 0 : _selectInputRef$curre.getPopupContentElement();
|
|
497
|
+
}, []);
|
|
498
|
+
var childrenWithProps = Children.map(children, function (child) {
|
|
499
|
+
if (/*#__PURE__*/isValidElement(child)) {
|
|
500
|
+
var addedProps = {
|
|
501
|
+
multiple: multiple
|
|
502
|
+
};
|
|
503
|
+
return /*#__PURE__*/cloneElement(child, _objectSpread({}, addedProps));
|
|
504
|
+
}
|
|
505
|
+
return child;
|
|
506
|
+
});
|
|
507
|
+
var renderContent = function renderContent() {
|
|
508
|
+
var popupContentProps = {
|
|
509
|
+
onChange: handleChange,
|
|
510
|
+
value: value,
|
|
511
|
+
className: className,
|
|
512
|
+
size: size,
|
|
513
|
+
multiple: multiple,
|
|
514
|
+
showPopup: showPopup,
|
|
515
|
+
// popup弹出层内容只会在点击事件之后触发 并且无任何透传参数
|
|
516
|
+
setShowPopup: function setShowPopup(show) {
|
|
517
|
+
return handleShowPopup(show, {});
|
|
518
|
+
},
|
|
519
|
+
options: currentOptions,
|
|
520
|
+
empty: empty,
|
|
521
|
+
max: max,
|
|
522
|
+
loadingText: loadingText,
|
|
523
|
+
loading: loading,
|
|
524
|
+
valueType: valueType,
|
|
525
|
+
keys: keys,
|
|
526
|
+
panelBottomContent: panelBottomContent,
|
|
527
|
+
panelTopContent: panelTopContent,
|
|
528
|
+
onCheckAllChange: onCheckAllChange,
|
|
529
|
+
getPopupInstance: getPopupInstance,
|
|
530
|
+
scroll: scroll
|
|
531
|
+
};
|
|
532
|
+
return /* @__PURE__ */React.createElement(PopupContent, _objectSpread({}, popupContentProps), childrenWithProps);
|
|
533
|
+
};
|
|
534
|
+
var renderValueDisplay = function renderValueDisplay() {
|
|
535
|
+
if (!valueDisplay) {
|
|
536
|
+
if (!multiple) {
|
|
537
|
+
if (typeof selectedLabel !== "string") {
|
|
538
|
+
return selectedLabel;
|
|
539
|
+
}
|
|
540
|
+
return "";
|
|
541
|
+
}
|
|
542
|
+
return function (_ref2) {
|
|
543
|
+
var val = _ref2.value;
|
|
544
|
+
return val.slice(0, minCollapsedNum ? minCollapsedNum : val.length).map(function (v, key) {
|
|
545
|
+
var filterOption = options === null || options === void 0 ? void 0 : options.find(function (option) {
|
|
546
|
+
return option.label === v;
|
|
547
|
+
});
|
|
548
|
+
return /* @__PURE__ */React.createElement(Tag, _objectSpread(_objectSpread({
|
|
549
|
+
key: key,
|
|
550
|
+
closable: !(filterOption !== null && filterOption !== void 0 && filterOption.disabled) && !disabled && !readonly,
|
|
551
|
+
size: size
|
|
552
|
+
}, tagProps), {}, {
|
|
553
|
+
onClose: function onClose(_ref3) {
|
|
554
|
+
var _e$nativeEvent, _e$nativeEvent$stopIm, _tagProps$onClose;
|
|
555
|
+
var e = _ref3.e;
|
|
556
|
+
e.stopPropagation();
|
|
557
|
+
e === null || e === void 0 || (_e$nativeEvent = e.nativeEvent) === null || _e$nativeEvent === void 0 || (_e$nativeEvent$stopIm = _e$nativeEvent.stopImmediatePropagation) === null || _e$nativeEvent$stopIm === void 0 || _e$nativeEvent$stopIm.call(_e$nativeEvent);
|
|
558
|
+
var values = getSelectValueArr(value, value[key], true, valueType, keys);
|
|
559
|
+
var _getSelectedOptions5 = getSelectedOptions(values, multiple, valueType, keys, valueToOption, value),
|
|
560
|
+
currentSelectedOptions = _getSelectedOptions5.currentSelectedOptions;
|
|
561
|
+
onChange(values, {
|
|
562
|
+
e: e,
|
|
563
|
+
selectedOptions: currentSelectedOptions,
|
|
564
|
+
trigger: "tag-remove"
|
|
565
|
+
});
|
|
566
|
+
tagProps === null || tagProps === void 0 || (_tagProps$onClose = tagProps.onClose) === null || _tagProps$onClose === void 0 || _tagProps$onClose.call(tagProps, {
|
|
567
|
+
e: e
|
|
568
|
+
});
|
|
569
|
+
onRemove === null || onRemove === void 0 || onRemove({
|
|
570
|
+
value: value[key],
|
|
571
|
+
data: {
|
|
572
|
+
label: v,
|
|
573
|
+
value: value[key]
|
|
574
|
+
},
|
|
575
|
+
e: e
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
}), v);
|
|
579
|
+
});
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
if (typeof valueDisplay === "string") {
|
|
583
|
+
return valueDisplay;
|
|
584
|
+
}
|
|
585
|
+
if (multiple) {
|
|
586
|
+
return function (_ref4) {
|
|
587
|
+
var onClose = _ref4.onClose;
|
|
588
|
+
return parseContentTNode(valueDisplay, {
|
|
589
|
+
value: selectedOptions,
|
|
590
|
+
onClose: onClose
|
|
591
|
+
});
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
return parseContentTNode(valueDisplay, {
|
|
595
|
+
value: selectedLabel,
|
|
596
|
+
onClose: noop
|
|
597
|
+
});
|
|
598
|
+
};
|
|
599
|
+
var updateScrollTop = function updateScrollTop(content) {
|
|
600
|
+
if (!content || isScrolling) {
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
var firstSelectedNode = content.querySelector(".".concat(classPrefix, "-is-selected"));
|
|
604
|
+
if (!multiple && firstSelectedNode) {
|
|
605
|
+
var _getComputedStyle = getComputedStyle(firstSelectedNode),
|
|
606
|
+
paddingBottom = _getComputedStyle.paddingBottom;
|
|
607
|
+
var _getComputedStyle2 = getComputedStyle(content),
|
|
608
|
+
marginBottom = _getComputedStyle2.marginBottom;
|
|
609
|
+
var elementBottomHeight = parseInt(paddingBottom, 10) + parseInt(marginBottom, 10);
|
|
610
|
+
var updateValue = getOffsetTopToContainer(firstSelectedNode, content) - content.offsetTop - (content.clientHeight - firstSelectedNode.clientHeight) + elementBottomHeight;
|
|
611
|
+
setTimeout(function () {
|
|
612
|
+
content.scrollTop = updateValue;
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
var onMouseEnter = props.onMouseEnter,
|
|
617
|
+
onMouseLeave = props.onMouseLeave;
|
|
618
|
+
var handleEnter = function handleEnter(_, context) {
|
|
619
|
+
onEnter === null || onEnter === void 0 || onEnter(_objectSpread(_objectSpread({}, context), {}, {
|
|
620
|
+
value: value
|
|
621
|
+
}));
|
|
622
|
+
};
|
|
623
|
+
var handleScroll = function handleScroll(_ref5) {
|
|
624
|
+
var e = _ref5.e;
|
|
625
|
+
toggleIsScrolling(true);
|
|
626
|
+
onScroll === null || onScroll === void 0 || onScroll({
|
|
627
|
+
e: e
|
|
628
|
+
});
|
|
629
|
+
if (onScrollToBottom) {
|
|
630
|
+
var debounceOnScrollBottom = debounce(function (e2) {
|
|
631
|
+
return onScrollToBottom({
|
|
632
|
+
e: e2
|
|
633
|
+
});
|
|
634
|
+
}, 100);
|
|
635
|
+
var _e$target = e.target,
|
|
636
|
+
scrollTop = _e$target.scrollTop,
|
|
637
|
+
clientHeight = _e$target.clientHeight,
|
|
638
|
+
scrollHeight = _e$target.scrollHeight;
|
|
639
|
+
if (clientHeight + Math.floor(scrollTop) === scrollHeight) {
|
|
640
|
+
debounceOnScrollBottom(e);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
return /* @__PURE__ */React.createElement("div", {
|
|
645
|
+
className: classNames("".concat(name, "__wrap"), className),
|
|
646
|
+
style: style,
|
|
647
|
+
onMouseEnter: onMouseEnter,
|
|
648
|
+
onMouseLeave: onMouseLeave
|
|
649
|
+
}, /* @__PURE__ */React.createElement(SelectInput, _objectSpread({
|
|
650
|
+
autoWidth: !(style !== null && style !== void 0 && style.width) && autoWidth,
|
|
651
|
+
ref: composeRefs(ref, selectInputRef),
|
|
652
|
+
className: name,
|
|
653
|
+
readonly: readonly,
|
|
654
|
+
autofocus: props.autofocus,
|
|
655
|
+
allowInput: filterable || isFunction(filter),
|
|
656
|
+
multiple: multiple,
|
|
657
|
+
value: selectedLabel,
|
|
658
|
+
options: selectedOptions,
|
|
659
|
+
valueDisplay: renderValueDisplay(),
|
|
660
|
+
clearable: clearable,
|
|
661
|
+
disabled: disabled,
|
|
662
|
+
status: props.status,
|
|
663
|
+
tips: props.tips,
|
|
664
|
+
borderless: borderless,
|
|
665
|
+
label: label,
|
|
666
|
+
suffix: props.suffix,
|
|
667
|
+
prefixIcon: prefixIcon,
|
|
668
|
+
suffixIcon: renderSuffixIcon(),
|
|
669
|
+
panel: renderContent(),
|
|
670
|
+
placeholder: !multiple && showPopup && selectedLabel ? selectedLabel : placeholder || "\u8BF7\u9009\u62E9",
|
|
671
|
+
inputValue: inputValue,
|
|
672
|
+
tagInputProps: _objectSpread({
|
|
673
|
+
size: size
|
|
674
|
+
}, tagInputProps),
|
|
675
|
+
tagProps: _objectSpread({
|
|
676
|
+
size: size
|
|
677
|
+
}, tagProps),
|
|
678
|
+
inputProps: _objectSpread({
|
|
679
|
+
size: size
|
|
680
|
+
}, inputProps),
|
|
681
|
+
minCollapsedNum: minCollapsedNum,
|
|
682
|
+
collapsedItems: collapsedItems,
|
|
683
|
+
updateScrollTop: updateScrollTop,
|
|
684
|
+
popupProps: _objectSpread({
|
|
685
|
+
overlayClassName: ["".concat(name, "__dropdown"), overlayClassName],
|
|
686
|
+
onScroll: handleScroll
|
|
687
|
+
}, restPopupProps),
|
|
688
|
+
popupVisible: showPopup,
|
|
689
|
+
onPopupVisibleChange: handleShowPopup,
|
|
690
|
+
onTagChange: onTagChange,
|
|
691
|
+
onInputChange: handleInputChange,
|
|
692
|
+
onFocus: onFocus,
|
|
693
|
+
onEnter: handleEnter,
|
|
694
|
+
onBlur: function onBlur(_, context) {
|
|
695
|
+
_onBlur === null || _onBlur === void 0 || _onBlur({
|
|
696
|
+
value: value,
|
|
697
|
+
e: context.e
|
|
698
|
+
});
|
|
699
|
+
},
|
|
700
|
+
onClear: handleClear
|
|
701
|
+
}, selectInputProps)));
|
|
702
|
+
}, {
|
|
703
|
+
Option: Option,
|
|
704
|
+
OptionGroup: OptionGroup
|
|
705
|
+
});
|
|
706
|
+
Select.displayName = "Select";
|
|
707
|
+
|
|
708
|
+
export { Select as default };
|
|
709
|
+
//# sourceMappingURL=Select.js.map
|