@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,691 @@
|
|
|
1
|
+
import { _ as _objectWithoutProperties } from './dep-DN7d1SzH.js';
|
|
2
|
+
import { _ as _defineProperty } from './dep-Cwish4GD.js';
|
|
3
|
+
import React, { useRef, useState, useMemo, useEffect, useCallback, Children, isValidElement, cloneElement } from 'react';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { get, isPlainObject, isEqual } from 'lodash-es';
|
|
6
|
+
import { _ as _toConsumableArray } from './dep-CgyDw_YI.js';
|
|
7
|
+
import { O as OptionGroup } from './dep-DB5wmwh1.js';
|
|
8
|
+
import Option from '../select/Option.js';
|
|
9
|
+
import { u as useConfig } from './dep-u1x3x6MJ.js';
|
|
10
|
+
import { _ as _slicedToArray } from './dep-CzLhKWCf.js';
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
|
+
function isSelectOptionGroup(option) {
|
|
15
|
+
return !!option && "group" in option && "children" in option;
|
|
16
|
+
}
|
|
17
|
+
function setValueToOptionFormOptionDom(dom, valueToOption, keys) {
|
|
18
|
+
var _dom$props = dom.props,
|
|
19
|
+
value = _dom$props.value,
|
|
20
|
+
label = _dom$props.label,
|
|
21
|
+
children = _dom$props.children;
|
|
22
|
+
valueToOption[value] = _objectSpread$1(_objectSpread$1({}, dom.props), {}, _defineProperty(_defineProperty({}, (keys === null || keys === void 0 ? void 0 : keys.value) || "value", value), (keys === null || keys === void 0 ? void 0 : keys.label) || "label", label || children || value));
|
|
23
|
+
}
|
|
24
|
+
var getValueToOption = function getValueToOption(children, options, keys) {
|
|
25
|
+
var valueToOption = {};
|
|
26
|
+
if (Array.isArray(options)) {
|
|
27
|
+
options.forEach(function (option) {
|
|
28
|
+
if (isSelectOptionGroup(option)) {
|
|
29
|
+
var _option$children;
|
|
30
|
+
(_option$children = option.children) === null || _option$children === void 0 || _option$children.forEach(function (child) {
|
|
31
|
+
valueToOption[get(child, (keys === null || keys === void 0 ? void 0 : keys.value) || "value")] = _objectSpread$1(_objectSpread$1({}, child), {}, {
|
|
32
|
+
value: get(child, (keys === null || keys === void 0 ? void 0 : keys.value) || "value"),
|
|
33
|
+
label: get(child, (keys === null || keys === void 0 ? void 0 : keys.label) || "label")
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
valueToOption[get(option, (keys === null || keys === void 0 ? void 0 : keys.value) || "value")] = _objectSpread$1(_objectSpread$1({}, option), {}, {
|
|
38
|
+
value: get(option, (keys === null || keys === void 0 ? void 0 : keys.value) || "value"),
|
|
39
|
+
label: get(option, (keys === null || keys === void 0 ? void 0 : keys.label) || "label")
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return valueToOption;
|
|
44
|
+
}
|
|
45
|
+
if (isPlainObject(children)) {
|
|
46
|
+
if (children.type === Option) {
|
|
47
|
+
setValueToOptionFormOptionDom(children, valueToOption, keys);
|
|
48
|
+
return valueToOption;
|
|
49
|
+
}
|
|
50
|
+
if (children.type === OptionGroup) {
|
|
51
|
+
var groupChildren = children.props.children;
|
|
52
|
+
if (Array.isArray(groupChildren)) {
|
|
53
|
+
groupChildren.forEach(function (item) {
|
|
54
|
+
setValueToOptionFormOptionDom(item, valueToOption, keys);
|
|
55
|
+
});
|
|
56
|
+
return valueToOption;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (Array.isArray(children)) {
|
|
61
|
+
var _handlerElement = function handlerElement(item) {
|
|
62
|
+
if (item.type === Option) {
|
|
63
|
+
setValueToOptionFormOptionDom(item, valueToOption, keys);
|
|
64
|
+
}
|
|
65
|
+
if (item.type === OptionGroup) {
|
|
66
|
+
var _groupChildren = item.props.children;
|
|
67
|
+
if (Array.isArray(_groupChildren)) {
|
|
68
|
+
_groupChildren.forEach(function (groupItem) {
|
|
69
|
+
setValueToOptionFormOptionDom(groupItem, valueToOption, keys);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (Array.isArray(item)) {
|
|
74
|
+
item.forEach(function (child) {
|
|
75
|
+
_handlerElement(child);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
children.forEach(function (item) {
|
|
80
|
+
return _handlerElement(item);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return valueToOption;
|
|
84
|
+
};
|
|
85
|
+
var getLabel = function getLabel(children, value, options, keys) {
|
|
86
|
+
var selectedLabel = "";
|
|
87
|
+
if (Array.isArray(options)) {
|
|
88
|
+
options.some(function (option) {
|
|
89
|
+
if ([get(value, (keys === null || keys === void 0 ? void 0 : keys.value) || "value"), value].includes(option.value)) {
|
|
90
|
+
selectedLabel = option.label;
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
});
|
|
95
|
+
return selectedLabel;
|
|
96
|
+
}
|
|
97
|
+
if (isPlainObject(children)) {
|
|
98
|
+
selectedLabel = children.props.label;
|
|
99
|
+
if (children.type === OptionGroup) {
|
|
100
|
+
var groupChildren = children.props.children;
|
|
101
|
+
if (Array.isArray(groupChildren)) {
|
|
102
|
+
groupChildren.some(function (item) {
|
|
103
|
+
var selectedValue = isPlainObject(value) ? get(value, "value") : value;
|
|
104
|
+
if (isPlainObject(item.props) && item.props.value === selectedValue) {
|
|
105
|
+
selectedLabel = item.props.label || item.props.children;
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (Array.isArray(children)) {
|
|
114
|
+
children.some(function (item) {
|
|
115
|
+
if (item.type === OptionGroup) {
|
|
116
|
+
var _groupChildren2 = item.props.children;
|
|
117
|
+
if (Array.isArray(_groupChildren2)) {
|
|
118
|
+
var isSelected = _groupChildren2.some(function (item2) {
|
|
119
|
+
var selectedValue2 = isPlainObject(value) ? get(value, "value") : value;
|
|
120
|
+
if (isPlainObject(item2.props) && item2.props.value === selectedValue2) {
|
|
121
|
+
selectedLabel = item2.props.label || item2.props.children;
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
return false;
|
|
125
|
+
});
|
|
126
|
+
return isSelected;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
var selectedValue = isPlainObject(value) ? get(value, "value") : value;
|
|
130
|
+
if (isPlainObject(item.props) && item.props.value === selectedValue) {
|
|
131
|
+
selectedLabel = item.props.label || item.props.children;
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return selectedLabel;
|
|
138
|
+
};
|
|
139
|
+
var getMultipleTags = function getMultipleTags(values, keys) {
|
|
140
|
+
var tags = values.map(function (item) {
|
|
141
|
+
return {
|
|
142
|
+
label: get(item, (keys === null || keys === void 0 ? void 0 : keys.label) || "label") || item.toString(),
|
|
143
|
+
value: get(item, (keys === null || keys === void 0 ? void 0 : keys.value) || "value") || item
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
return tags;
|
|
147
|
+
};
|
|
148
|
+
var getSelectValueArr = function getSelectValueArr(values, activeValue, selected, valueType, keys, objVal) {
|
|
149
|
+
values = Array.isArray(values) ? values : [];
|
|
150
|
+
if (Array.isArray(values)) {
|
|
151
|
+
var currentValues = _toConsumableArray(values);
|
|
152
|
+
var isValueObj = valueType === "object";
|
|
153
|
+
if (selected) {
|
|
154
|
+
currentValues = currentValues.filter(function (item) {
|
|
155
|
+
if (isValueObj) {
|
|
156
|
+
if (isPlainObject(activeValue)) {
|
|
157
|
+
return get(item, (keys === null || keys === void 0 ? void 0 : keys.value) || "value") !== get(activeValue, (keys === null || keys === void 0 ? void 0 : keys.value) || "value");
|
|
158
|
+
}
|
|
159
|
+
return get(item, (keys === null || keys === void 0 ? void 0 : keys.value) || "value") !== activeValue;
|
|
160
|
+
}
|
|
161
|
+
return item !== activeValue;
|
|
162
|
+
});
|
|
163
|
+
} else {
|
|
164
|
+
var item = isValueObj ? objVal : activeValue;
|
|
165
|
+
currentValues.push(item);
|
|
166
|
+
}
|
|
167
|
+
return currentValues;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
var getSelectedOptions = function getSelectedOptions(value, multiple, valueType, keys, valueToOption, selectedValue) {
|
|
171
|
+
var isObjectType = valueType === "object";
|
|
172
|
+
var currentSelectedOptions = [];
|
|
173
|
+
var currentOption;
|
|
174
|
+
var allSelectedValue;
|
|
175
|
+
var tmpPropOptions = Object.values(valueToOption);
|
|
176
|
+
if (multiple) {
|
|
177
|
+
var _tmpPropOptions$filte, _currentSelectedOptio, _currentSelectedOptio2;
|
|
178
|
+
currentSelectedOptions = isObjectType ? value : tmpPropOptions === null || tmpPropOptions === void 0 || (_tmpPropOptions$filte = tmpPropOptions.filter) === null || _tmpPropOptions$filte === void 0 ? void 0 : _tmpPropOptions$filte.call(tmpPropOptions, function (v) {
|
|
179
|
+
var _value$includes;
|
|
180
|
+
return (_value$includes = value.includes) === null || _value$includes === void 0 ? void 0 : _value$includes.call(value, v[(keys === null || keys === void 0 ? void 0 : keys.value) || "value"]);
|
|
181
|
+
});
|
|
182
|
+
allSelectedValue = isObjectType ? currentSelectedOptions : (_currentSelectedOptio = currentSelectedOptions) === null || _currentSelectedOptio === void 0 ? void 0 : _currentSelectedOptio.map(function (v) {
|
|
183
|
+
return v[(keys === null || keys === void 0 ? void 0 : keys.value) || "value"];
|
|
184
|
+
});
|
|
185
|
+
currentOption = isObjectType ? value.find(function (v) {
|
|
186
|
+
return v[(keys === null || keys === void 0 ? void 0 : keys.value) || "value"] === selectedValue;
|
|
187
|
+
}) : (_currentSelectedOptio2 = currentSelectedOptions) === null || _currentSelectedOptio2 === void 0 ? void 0 : _currentSelectedOptio2.find(function (option) {
|
|
188
|
+
return option[(keys === null || keys === void 0 ? void 0 : keys.value) || "value"] === selectedValue;
|
|
189
|
+
});
|
|
190
|
+
} else {
|
|
191
|
+
var _tmpPropOptions$filte2, _currentSelectedOptio3;
|
|
192
|
+
currentSelectedOptions = isObjectType ? [value] : (tmpPropOptions === null || tmpPropOptions === void 0 || (_tmpPropOptions$filte2 = tmpPropOptions.filter) === null || _tmpPropOptions$filte2 === void 0 ? void 0 : _tmpPropOptions$filte2.call(tmpPropOptions, function (v) {
|
|
193
|
+
return value === v[(keys === null || keys === void 0 ? void 0 : keys.value) || "value"];
|
|
194
|
+
})) || [];
|
|
195
|
+
allSelectedValue = currentSelectedOptions;
|
|
196
|
+
currentOption = isObjectType ? value : (_currentSelectedOptio3 = currentSelectedOptions) === null || _currentSelectedOptio3 === void 0 ? void 0 : _currentSelectedOptio3.find(function (option) {
|
|
197
|
+
return option[(keys === null || keys === void 0 ? void 0 : keys.value) || "value"] === selectedValue;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
currentSelectedOptions: currentSelectedOptions,
|
|
202
|
+
currentOption: currentOption,
|
|
203
|
+
allSelectedValue: allSelectedValue
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
var requestAnimationFrame = (typeof window === "undefined" ? false : window.requestAnimationFrame) || function (cb) {
|
|
208
|
+
return setTimeout(cb, 16.6);
|
|
209
|
+
};
|
|
210
|
+
var useVirtualScroll = function useVirtualScroll(container, params) {
|
|
211
|
+
var data = params.data,
|
|
212
|
+
scroll = params.scroll;
|
|
213
|
+
var dataRef = useRef(data);
|
|
214
|
+
var _useState = useState([]),
|
|
215
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
216
|
+
visibleData = _useState2[0],
|
|
217
|
+
setVisibleData = _useState2[1];
|
|
218
|
+
var _useState3 = useState(function () {
|
|
219
|
+
return ((data === null || data === void 0 ? void 0 : data.length) || 0) * ((scroll === null || scroll === void 0 ? void 0 : scroll.rowHeight) || 50);
|
|
220
|
+
}),
|
|
221
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
222
|
+
translateY = _useState4[0],
|
|
223
|
+
setTranslateY = _useState4[1];
|
|
224
|
+
var _useState5 = useState(0),
|
|
225
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
226
|
+
scrollHeight = _useState6[0],
|
|
227
|
+
setScrollHeight = _useState6[1];
|
|
228
|
+
var trScrollTopHeightList = useRef([]);
|
|
229
|
+
var _useState7 = useState([]),
|
|
230
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
231
|
+
trHeightList = _useState8[0],
|
|
232
|
+
setTrHeightList = _useState8[1];
|
|
233
|
+
var containerHeight = useRef(0);
|
|
234
|
+
var _useState9 = useState(function () {
|
|
235
|
+
return [0, ((scroll === null || scroll === void 0 ? void 0 : scroll.bufferSize) || 10) * 3];
|
|
236
|
+
}),
|
|
237
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
238
|
+
startAndEndIndex = _useState0[0],
|
|
239
|
+
setStartAndEndIndex = _useState0[1];
|
|
240
|
+
var tScroll = useMemo(function () {
|
|
241
|
+
var _scroll$isFixedRowHei, _scroll$fixedRows;
|
|
242
|
+
if (!scroll) return {};
|
|
243
|
+
return {
|
|
244
|
+
bufferSize: scroll.bufferSize || 10,
|
|
245
|
+
isFixedRowHeight: (_scroll$isFixedRowHei = scroll.isFixedRowHeight) !== null && _scroll$isFixedRowHei !== void 0 ? _scroll$isFixedRowHei : false,
|
|
246
|
+
rowHeight: scroll.rowHeight || 47,
|
|
247
|
+
threshold: scroll.threshold || 100,
|
|
248
|
+
type: scroll.type,
|
|
249
|
+
fixedRows: (_scroll$fixedRows = scroll.fixedRows) !== null && _scroll$fixedRows !== void 0 ? _scroll$fixedRows : [0, 0]
|
|
250
|
+
};
|
|
251
|
+
}, [scroll]);
|
|
252
|
+
var isVirtualScroll = useMemo(function () {
|
|
253
|
+
return tScroll.type === "virtual" && tScroll.threshold < data.length;
|
|
254
|
+
}, [tScroll, data]);
|
|
255
|
+
var getTrScrollTopHeightList = function getTrScrollTopHeightList(trHeightList2) {
|
|
256
|
+
var list = [];
|
|
257
|
+
for (var i = 0, len = data.length; i < len; i++) {
|
|
258
|
+
list[i] = (list[i - 1] || 0) + (trHeightList2[i] || tScroll.rowHeight);
|
|
259
|
+
}
|
|
260
|
+
return list;
|
|
261
|
+
};
|
|
262
|
+
var updateVisibleData = function updateVisibleData(trScrollTopHeightList2, scrollTop) {
|
|
263
|
+
var currentIndex = -1;
|
|
264
|
+
for (var i = 0, len = trScrollTopHeightList2.length; i < len; i++) {
|
|
265
|
+
if (trScrollTopHeightList2[i] >= scrollTop) {
|
|
266
|
+
currentIndex = i;
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
var lastIndex = trScrollTopHeightList2.length;
|
|
271
|
+
var containerCurrentHeight = containerHeight.current || container.current.getBoundingClientRect().height;
|
|
272
|
+
var scrollBottom = scrollTop + containerCurrentHeight;
|
|
273
|
+
for (var _i = currentIndex, _len = trScrollTopHeightList2.length; _i < _len; _i++) {
|
|
274
|
+
if (trScrollTopHeightList2[_i] >= scrollBottom) {
|
|
275
|
+
lastIndex = _i;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (currentIndex < 0) return;
|
|
280
|
+
var startIndex = Math.max(currentIndex - tScroll.bufferSize, 0);
|
|
281
|
+
var endIndex = Math.min(lastIndex + tScroll.bufferSize, trScrollTopHeightList2.length);
|
|
282
|
+
var fixedRows = tScroll.fixedRows;
|
|
283
|
+
var _fixedRows = _slicedToArray(fixedRows, 2),
|
|
284
|
+
fixedStart = _fixedRows[0],
|
|
285
|
+
fixedEnd = _fixedRows[1];
|
|
286
|
+
var fixedStartData = fixedStart ? data.slice(0, fixedStart) : [];
|
|
287
|
+
if (fixedStart && startIndex < fixedStart) {
|
|
288
|
+
fixedStartData = fixedStartData.slice(0, startIndex);
|
|
289
|
+
}
|
|
290
|
+
var fixedEndData = fixedEnd ? data.slice(data.length - fixedEnd) : [];
|
|
291
|
+
var bottomStartIndex = endIndex - data.length + 1 + (fixedEnd !== null && fixedEnd !== void 0 ? fixedEnd : 0);
|
|
292
|
+
if (fixedEnd && bottomStartIndex > 0) {
|
|
293
|
+
fixedEndData = fixedEndData.slice(bottomStartIndex);
|
|
294
|
+
}
|
|
295
|
+
if (startAndEndIndex.join() !== [startIndex, endIndex].join() && startIndex >= 0) {
|
|
296
|
+
var tmpVisibleData = fixedStartData.concat(data.slice(startIndex, endIndex)).concat(fixedEndData);
|
|
297
|
+
setVisibleData(tmpVisibleData);
|
|
298
|
+
var lastScrollTop = trScrollTopHeightList2[startIndex - 1];
|
|
299
|
+
var top = lastScrollTop > 0 ? lastScrollTop : 0;
|
|
300
|
+
var stickyHeight = trScrollTopHeightList2[Math.min(startIndex, fixedStart) - 1] || 0;
|
|
301
|
+
setTranslateY(top - stickyHeight);
|
|
302
|
+
setStartAndEndIndex([startIndex, endIndex]);
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
var handleRowMounted = function handleRowMounted(rowData) {
|
|
306
|
+
if (!isVirtualScroll || !rowData || tScroll.isFixedRowHeight || !(container !== null && container !== void 0 && container.current)) return;
|
|
307
|
+
var trHeight = rowData.ref.offsetHeight;
|
|
308
|
+
var rowIndex = rowData.data.__VIRTUAL_SCROLL_INDEX;
|
|
309
|
+
var newTrHeightList = _toConsumableArray(trHeightList);
|
|
310
|
+
if (newTrHeightList[rowIndex] !== trHeight) {
|
|
311
|
+
newTrHeightList[rowIndex] = trHeight;
|
|
312
|
+
setTrHeightList(newTrHeightList);
|
|
313
|
+
var scrollTopHeightList = getTrScrollTopHeightList(newTrHeightList);
|
|
314
|
+
trScrollTopHeightList.current = scrollTopHeightList;
|
|
315
|
+
var lastIndex = scrollTopHeightList.length - 1;
|
|
316
|
+
setScrollHeight(scrollTopHeightList[lastIndex] - containerHeight.current);
|
|
317
|
+
updateVisibleData(scrollTopHeightList, container.current.scrollTop);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
var handleScroll = function handleScroll() {
|
|
321
|
+
if (!isVirtualScroll) return;
|
|
322
|
+
updateVisibleData(trScrollTopHeightList.current, container.current.scrollTop);
|
|
323
|
+
};
|
|
324
|
+
var addIndexToData = function addIndexToData(data2) {
|
|
325
|
+
data2.forEach(function (item, index) {
|
|
326
|
+
Reflect.set(item, "__VIRTUAL_SCROLL_INDEX", index);
|
|
327
|
+
});
|
|
328
|
+
};
|
|
329
|
+
var updateScrollTop = function updateScrollTop(_ref) {
|
|
330
|
+
var _container$current;
|
|
331
|
+
var index = _ref.index,
|
|
332
|
+
_ref$top = _ref.top,
|
|
333
|
+
top = _ref$top === void 0 ? 0 : _ref$top,
|
|
334
|
+
behavior = _ref.behavior;
|
|
335
|
+
var scrollTop = trScrollTopHeightList.current[index] - top;
|
|
336
|
+
(_container$current = container.current) === null || _container$current === void 0 || _container$current.scrollTo({
|
|
337
|
+
top: scrollTop,
|
|
338
|
+
behavior: behavior || "auto"
|
|
339
|
+
});
|
|
340
|
+
};
|
|
341
|
+
var scrollToElement = function scrollToElement(p) {
|
|
342
|
+
updateScrollTop(p);
|
|
343
|
+
if (!tScroll.isFixedRowHeight) {
|
|
344
|
+
requestAnimationFrame(function () {
|
|
345
|
+
var _p$time;
|
|
346
|
+
var duration = (_p$time = p.time) !== null && _p$time !== void 0 ? _p$time : 60;
|
|
347
|
+
var timer = setTimeout(function () {
|
|
348
|
+
updateScrollTop(p);
|
|
349
|
+
clearTimeout(timer);
|
|
350
|
+
}, duration);
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
useEffect(function () {
|
|
355
|
+
if (!isVirtualScroll) {
|
|
356
|
+
trScrollTopHeightList.current = getTrScrollTopHeightList(trHeightList);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
addIndexToData(data);
|
|
360
|
+
var scrollTopHeightList = trScrollTopHeightList.current;
|
|
361
|
+
var dataChanged = !isEqual(dataRef.current, data);
|
|
362
|
+
if ((scrollTopHeightList === null || scrollTopHeightList === void 0 ? void 0 : scrollTopHeightList.length) === (data === null || data === void 0 ? void 0 : data.length) && !dataChanged) {
|
|
363
|
+
var lastIndex = scrollTopHeightList.length - 1;
|
|
364
|
+
setScrollHeight(scrollTopHeightList[lastIndex]);
|
|
365
|
+
updateVisibleData(scrollTopHeightList, container.current.scrollTop);
|
|
366
|
+
} else {
|
|
367
|
+
var _container$current2;
|
|
368
|
+
dataRef.current = data;
|
|
369
|
+
setScrollHeight(data.length * tScroll.rowHeight);
|
|
370
|
+
var currentScrollTop = ((_container$current2 = container.current) === null || _container$current2 === void 0 ? void 0 : _container$current2.scrollTop) || 0;
|
|
371
|
+
var currentIndex = Math.floor(currentScrollTop / tScroll.rowHeight);
|
|
372
|
+
var prevScrollTopHeightList = trScrollTopHeightList.current;
|
|
373
|
+
for (var i = 0; i < (prevScrollTopHeightList === null || prevScrollTopHeightList === void 0 ? void 0 : prevScrollTopHeightList.length); i++) {
|
|
374
|
+
if (prevScrollTopHeightList[i] >= currentScrollTop) {
|
|
375
|
+
currentIndex = i;
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
var startIndex = Math.max(currentIndex - tScroll.bufferSize, 0);
|
|
380
|
+
var visibleCount = Math.min(tScroll.bufferSize * 3, data.length);
|
|
381
|
+
var endIndex = Math.min(startIndex + visibleCount, data.length);
|
|
382
|
+
var tmpData = data.slice(startIndex, endIndex);
|
|
383
|
+
var translateY2 = startIndex * tScroll.rowHeight;
|
|
384
|
+
if ((prevScrollTopHeightList === null || prevScrollTopHeightList === void 0 ? void 0 : prevScrollTopHeightList.length) > 0 && startIndex > 0) {
|
|
385
|
+
var prevHeight = prevScrollTopHeightList[Math.min(startIndex - 1, prevScrollTopHeightList.length - 1)] || 0;
|
|
386
|
+
translateY2 = Math.max(0, prevHeight);
|
|
387
|
+
}
|
|
388
|
+
setVisibleData(tmpData);
|
|
389
|
+
setTranslateY(translateY2);
|
|
390
|
+
}
|
|
391
|
+
var timer = setTimeout(function () {
|
|
392
|
+
if (container.current) {
|
|
393
|
+
var tmpContainerHeight = container.current.getBoundingClientRect().height;
|
|
394
|
+
containerHeight.current = tmpContainerHeight;
|
|
395
|
+
var scrollTopHeightList2 = getTrScrollTopHeightList(trHeightList);
|
|
396
|
+
trScrollTopHeightList.current = scrollTopHeightList2;
|
|
397
|
+
clearTimeout(timer);
|
|
398
|
+
}
|
|
399
|
+
}, 1);
|
|
400
|
+
},
|
|
401
|
+
// eslint-disable-next-line
|
|
402
|
+
[container, data, tScroll, isVirtualScroll, startAndEndIndex, trHeightList]);
|
|
403
|
+
return {
|
|
404
|
+
visibleData: visibleData,
|
|
405
|
+
translateY: translateY,
|
|
406
|
+
scrollHeight: scrollHeight,
|
|
407
|
+
isVirtualScroll: isVirtualScroll,
|
|
408
|
+
handleScroll: handleScroll,
|
|
409
|
+
handleRowMounted: handleRowMounted,
|
|
410
|
+
scrollToElement: scrollToElement
|
|
411
|
+
};
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
var usePanelVirtualScroll = function usePanelVirtualScroll(_ref) {
|
|
415
|
+
var popupContentRef = _ref.popupContentRef,
|
|
416
|
+
scroll = _ref.scroll,
|
|
417
|
+
options = _ref.options,
|
|
418
|
+
size = _ref.size;
|
|
419
|
+
var scrollThreshold = (scroll === null || scroll === void 0 ? void 0 : scroll.threshold) || 100;
|
|
420
|
+
var scrollType = scroll === null || scroll === void 0 ? void 0 : scroll.type;
|
|
421
|
+
var isVirtual = useMemo(function () {
|
|
422
|
+
return scrollType === "virtual" && (options === null || options === void 0 ? void 0 : options.length) > scrollThreshold;
|
|
423
|
+
}, [scrollType, scrollThreshold, options]);
|
|
424
|
+
var scrollParams = useMemo(function () {
|
|
425
|
+
var heightMap = {
|
|
426
|
+
small: 20,
|
|
427
|
+
medium: 28,
|
|
428
|
+
large: 36
|
|
429
|
+
};
|
|
430
|
+
var rowHeight = heightMap[size] || 28;
|
|
431
|
+
return {
|
|
432
|
+
type: "virtual",
|
|
433
|
+
isFixedRowHeight: (scroll === null || scroll === void 0 ? void 0 : scroll.isFixedRowHeight) || false,
|
|
434
|
+
rowHeight: (scroll === null || scroll === void 0 ? void 0 : scroll.rowHeight) || rowHeight,
|
|
435
|
+
bufferSize: (scroll === null || scroll === void 0 ? void 0 : scroll.bufferSize) || 20,
|
|
436
|
+
threshold: scrollThreshold
|
|
437
|
+
};
|
|
438
|
+
}, [scroll, scrollThreshold, size]);
|
|
439
|
+
var _useVirtualScroll = useVirtualScroll(popupContentRef, {
|
|
440
|
+
data: options || [],
|
|
441
|
+
scroll: scrollParams
|
|
442
|
+
}),
|
|
443
|
+
_useVirtualScroll$vis = _useVirtualScroll.visibleData,
|
|
444
|
+
visibleData = _useVirtualScroll$vis === void 0 ? null : _useVirtualScroll$vis,
|
|
445
|
+
_useVirtualScroll$han = _useVirtualScroll.handleScroll,
|
|
446
|
+
handleVirtualScroll = _useVirtualScroll$han === void 0 ? null : _useVirtualScroll$han,
|
|
447
|
+
_useVirtualScroll$scr = _useVirtualScroll.scrollHeight,
|
|
448
|
+
scrollHeight = _useVirtualScroll$scr === void 0 ? null : _useVirtualScroll$scr,
|
|
449
|
+
_useVirtualScroll$tra = _useVirtualScroll.translateY,
|
|
450
|
+
translateY = _useVirtualScroll$tra === void 0 ? null : _useVirtualScroll$tra,
|
|
451
|
+
_useVirtualScroll$han2 = _useVirtualScroll.handleRowMounted,
|
|
452
|
+
handleRowMounted = _useVirtualScroll$han2 === void 0 ? null : _useVirtualScroll$han2;
|
|
453
|
+
var lastScrollY = -1;
|
|
454
|
+
var onInnerVirtualScroll = useCallback(function (e) {
|
|
455
|
+
if (!isVirtual) {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
var target = e.target;
|
|
459
|
+
var top = target.scrollTop;
|
|
460
|
+
if (Math.abs(lastScrollY - top) > 5) {
|
|
461
|
+
handleVirtualScroll();
|
|
462
|
+
lastScrollY = top;
|
|
463
|
+
} else {
|
|
464
|
+
lastScrollY = -1;
|
|
465
|
+
}
|
|
466
|
+
}, []);
|
|
467
|
+
useEffect(function () {
|
|
468
|
+
var popupContentDom = popupContentRef === null || popupContentRef === void 0 ? void 0 : popupContentRef.current;
|
|
469
|
+
if (isVirtual) {
|
|
470
|
+
var _popupContentDom$addE;
|
|
471
|
+
popupContentDom === null || popupContentDom === void 0 || (_popupContentDom$addE = popupContentDom.addEventListener) === null || _popupContentDom$addE === void 0 || _popupContentDom$addE.call(popupContentDom, "scroll", onInnerVirtualScroll);
|
|
472
|
+
}
|
|
473
|
+
return function () {
|
|
474
|
+
if (isVirtual) {
|
|
475
|
+
var _popupContentDom$remo;
|
|
476
|
+
popupContentDom === null || popupContentDom === void 0 || (_popupContentDom$remo = popupContentDom.removeEventListener) === null || _popupContentDom$remo === void 0 || _popupContentDom$remo.call(popupContentDom, "scroll", onInnerVirtualScroll);
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
}, [isVirtual, onInnerVirtualScroll, popupContentRef.current]);
|
|
480
|
+
var cursorStyle = {
|
|
481
|
+
position: "absolute",
|
|
482
|
+
width: "1px",
|
|
483
|
+
height: "1px",
|
|
484
|
+
transition: "transform 0.2s",
|
|
485
|
+
transform: "translate(0, ".concat(scrollHeight, "px)"),
|
|
486
|
+
MsTransform: "translate(0, ".concat(scrollHeight, "px)"),
|
|
487
|
+
MozTransform: "translate(0, ".concat(scrollHeight, "px)"),
|
|
488
|
+
WebkitTransform: "translate(0, ".concat(scrollHeight, "px)")
|
|
489
|
+
};
|
|
490
|
+
var panelStyle = {
|
|
491
|
+
transform: "translate(0, ".concat(translateY, "px)"),
|
|
492
|
+
MsTransform: "translate(0, ".concat(translateY, "px)"),
|
|
493
|
+
MozTransform: "translate(0, ".concat(translateY, "px)"),
|
|
494
|
+
WebkitTransform: "translate(0, ".concat(translateY, "px)")
|
|
495
|
+
};
|
|
496
|
+
return {
|
|
497
|
+
scrollHeight: scrollHeight,
|
|
498
|
+
translateY: translateY,
|
|
499
|
+
visibleData: visibleData,
|
|
500
|
+
handleRowMounted: handleRowMounted,
|
|
501
|
+
isVirtual: isVirtual,
|
|
502
|
+
cursorStyle: cursorStyle,
|
|
503
|
+
panelStyle: panelStyle
|
|
504
|
+
};
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
var _excluded = ["group", "divider"],
|
|
508
|
+
_excluded2 = ["value", "label", "disabled", "content", "children"];
|
|
509
|
+
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; }
|
|
510
|
+
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; }
|
|
511
|
+
var PopupContent = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
512
|
+
var value = props.value,
|
|
513
|
+
size = props.size,
|
|
514
|
+
max = props.max,
|
|
515
|
+
multiple = props.multiple,
|
|
516
|
+
showPopup = props.showPopup,
|
|
517
|
+
setShowPopup = props.setShowPopup,
|
|
518
|
+
empty = props.empty,
|
|
519
|
+
loadingText = props.loadingText,
|
|
520
|
+
loading = props.loading,
|
|
521
|
+
valueType = props.valueType,
|
|
522
|
+
children = props.children,
|
|
523
|
+
keys = props.keys,
|
|
524
|
+
panelTopContent = props.panelTopContent,
|
|
525
|
+
panelBottomContent = props.panelBottomContent,
|
|
526
|
+
onChange = props.onChange,
|
|
527
|
+
onCheckAllChange = props.onCheckAllChange,
|
|
528
|
+
getPopupInstance = props.getPopupInstance,
|
|
529
|
+
propsOptions = props.options,
|
|
530
|
+
propsScroll = props.scroll;
|
|
531
|
+
var popupContentRef = useRef(null);
|
|
532
|
+
popupContentRef.current = getPopupInstance();
|
|
533
|
+
var _usePanelVirtualScrol = usePanelVirtualScroll({
|
|
534
|
+
popupContentRef: popupContentRef,
|
|
535
|
+
scroll: propsScroll,
|
|
536
|
+
options: propsOptions,
|
|
537
|
+
size: size
|
|
538
|
+
}),
|
|
539
|
+
visibleData = _usePanelVirtualScrol.visibleData,
|
|
540
|
+
handleRowMounted = _usePanelVirtualScrol.handleRowMounted,
|
|
541
|
+
isVirtual = _usePanelVirtualScrol.isVirtual,
|
|
542
|
+
panelStyle = _usePanelVirtualScrol.panelStyle,
|
|
543
|
+
cursorStyle = _usePanelVirtualScrol.cursorStyle;
|
|
544
|
+
var selectableOptions = useMemo(function () {
|
|
545
|
+
var uniqueOptions = {};
|
|
546
|
+
propsOptions === null || propsOptions === void 0 || propsOptions.forEach(function (option) {
|
|
547
|
+
if (option.group) {
|
|
548
|
+
option.children.forEach(function (item) {
|
|
549
|
+
if (!item.disabled && !item.checkAll) {
|
|
550
|
+
uniqueOptions[item.value] = item;
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
} else if (!option.disabled && !option.checkAll) {
|
|
554
|
+
uniqueOptions[option.value] = option;
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
return Object.values(uniqueOptions);
|
|
558
|
+
}, [propsOptions]);
|
|
559
|
+
var _useConfig = useConfig(),
|
|
560
|
+
classPrefix = _useConfig.classPrefix;
|
|
561
|
+
if (!children && !propsOptions) {
|
|
562
|
+
return null;
|
|
563
|
+
}
|
|
564
|
+
var onSelect = function onSelect(selectedValue, _ref) {
|
|
565
|
+
var label = _ref.label,
|
|
566
|
+
selected = _ref.selected,
|
|
567
|
+
event = _ref.event,
|
|
568
|
+
restData = _ref.restData;
|
|
569
|
+
var isValObj = valueType === "object";
|
|
570
|
+
var objVal = {};
|
|
571
|
+
if (isValObj) {
|
|
572
|
+
objVal = _objectSpread({}, restData);
|
|
573
|
+
if (!(keys !== null && keys !== void 0 && keys.label)) {
|
|
574
|
+
Object.assign(objVal, {
|
|
575
|
+
label: label
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
if (!(keys !== null && keys !== void 0 && keys.value)) {
|
|
579
|
+
Object.assign(objVal, {
|
|
580
|
+
value: selectedValue
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
if (!Object.keys(objVal).length) {
|
|
585
|
+
Object.assign(objVal, _defineProperty(_defineProperty({}, (keys === null || keys === void 0 ? void 0 : keys.label) || "label", label), (keys === null || keys === void 0 ? void 0 : keys.value) || "value", selectedValue));
|
|
586
|
+
}
|
|
587
|
+
if (multiple) {
|
|
588
|
+
var values = getSelectValueArr(value, selectedValue, selected, valueType, keys, objVal);
|
|
589
|
+
onChange(values, {
|
|
590
|
+
label: label,
|
|
591
|
+
value: selectedValue,
|
|
592
|
+
e: event,
|
|
593
|
+
trigger: selected ? "uncheck" : "check"
|
|
594
|
+
});
|
|
595
|
+
} else {
|
|
596
|
+
var selectVal = valueType === "object" ? objVal : selectedValue;
|
|
597
|
+
if (!isEqual(value, selectVal)) {
|
|
598
|
+
onChange(selectVal, {
|
|
599
|
+
label: label,
|
|
600
|
+
value: selectVal,
|
|
601
|
+
e: event,
|
|
602
|
+
trigger: "check"
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
setShowPopup(!showPopup);
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
var childrenWithProps = Children.map(children, function (child) {
|
|
609
|
+
if (/*#__PURE__*/isValidElement(child)) {
|
|
610
|
+
var addedProps = {
|
|
611
|
+
size: size,
|
|
612
|
+
max: max,
|
|
613
|
+
multiple: multiple,
|
|
614
|
+
selectedValue: value,
|
|
615
|
+
onSelect: onSelect
|
|
616
|
+
};
|
|
617
|
+
return /*#__PURE__*/cloneElement(child, _objectSpread({}, addedProps));
|
|
618
|
+
}
|
|
619
|
+
return child;
|
|
620
|
+
});
|
|
621
|
+
var _renderOptions = function renderOptions(options) {
|
|
622
|
+
if (options) {
|
|
623
|
+
return /* @__PURE__ */React.createElement("ul", {
|
|
624
|
+
className: "".concat(classPrefix, "-select__list")
|
|
625
|
+
}, options.map(function (item, index) {
|
|
626
|
+
var group = item.group,
|
|
627
|
+
divider = item.divider,
|
|
628
|
+
rest = _objectWithoutProperties(item, _excluded);
|
|
629
|
+
if (group) {
|
|
630
|
+
return /* @__PURE__ */React.createElement(OptionGroup, {
|
|
631
|
+
label: group,
|
|
632
|
+
divider: divider,
|
|
633
|
+
key: index
|
|
634
|
+
}, _renderOptions(rest.children));
|
|
635
|
+
}
|
|
636
|
+
var optionValue = item.value,
|
|
637
|
+
label = item.label,
|
|
638
|
+
disabled = item.disabled,
|
|
639
|
+
content = item.content,
|
|
640
|
+
children2 = item.children,
|
|
641
|
+
restData = _objectWithoutProperties(item, _excluded2);
|
|
642
|
+
return /* @__PURE__ */React.createElement(Option, _objectSpread(_objectSpread({
|
|
643
|
+
key: index,
|
|
644
|
+
max: max,
|
|
645
|
+
label: label,
|
|
646
|
+
value: optionValue,
|
|
647
|
+
onSelect: onSelect,
|
|
648
|
+
selectedValue: value,
|
|
649
|
+
optionLength: selectableOptions.length,
|
|
650
|
+
multiple: multiple,
|
|
651
|
+
size: size,
|
|
652
|
+
disabled: disabled,
|
|
653
|
+
restData: restData,
|
|
654
|
+
keys: keys,
|
|
655
|
+
content: content,
|
|
656
|
+
onCheckAllChange: onCheckAllChange,
|
|
657
|
+
onRowMounted: handleRowMounted
|
|
658
|
+
}, isVirtual ? {
|
|
659
|
+
isVirtual: isVirtual,
|
|
660
|
+
bufferSize: propsScroll === null || propsScroll === void 0 ? void 0 : propsScroll.bufferSize,
|
|
661
|
+
scrollType: propsScroll === null || propsScroll === void 0 ? void 0 : propsScroll.type
|
|
662
|
+
} : {}), restData), children2);
|
|
663
|
+
}));
|
|
664
|
+
}
|
|
665
|
+
return /* @__PURE__ */React.createElement("ul", {
|
|
666
|
+
className: "".concat(classPrefix, "-select__list")
|
|
667
|
+
}, childrenWithProps);
|
|
668
|
+
};
|
|
669
|
+
var isEmpty = Array.isArray(childrenWithProps) && !childrenWithProps.length || propsOptions && propsOptions.length === 0;
|
|
670
|
+
var renderPanel = function renderPanel(renderedOptions, extraStyle) {
|
|
671
|
+
return /* @__PURE__ */React.createElement("div", {
|
|
672
|
+
ref: ref,
|
|
673
|
+
className: classNames("".concat(classPrefix, "-select__dropdown-inner"), _defineProperty(_defineProperty(_defineProperty({}, "".concat(classPrefix, "-select__dropdown-inner--size-s"), size === "small"), "".concat(classPrefix, "-select__dropdown-inner--size-l"), size === "large"), "".concat(classPrefix, "-select__dropdown-inner--size-m"), size === "medium")),
|
|
674
|
+
style: extraStyle
|
|
675
|
+
}, loading && /* @__PURE__ */React.createElement("div", {
|
|
676
|
+
className: "".concat(classPrefix, "-select__loading-tips")
|
|
677
|
+
}, loadingText), !loading && isEmpty && /* @__PURE__ */React.createElement("div", {
|
|
678
|
+
className: "".concat(classPrefix, "-select__empty")
|
|
679
|
+
}, empty), !loading && !isEmpty && _renderOptions(renderedOptions));
|
|
680
|
+
};
|
|
681
|
+
if (isVirtual) {
|
|
682
|
+
return /* @__PURE__ */React.createElement(React.Fragment, null, panelTopContent, /* @__PURE__ */React.createElement("div", null, /* @__PURE__ */React.createElement("div", {
|
|
683
|
+
style: cursorStyle
|
|
684
|
+
}), renderPanel(visibleData, panelStyle)), panelBottomContent);
|
|
685
|
+
}
|
|
686
|
+
return /* @__PURE__ */React.createElement(React.Fragment, null, panelTopContent, renderPanel(propsOptions), panelBottomContent);
|
|
687
|
+
});
|
|
688
|
+
PopupContent.displayName = "PopupContent";
|
|
689
|
+
|
|
690
|
+
export { PopupContent as P, getSelectValueArr as a, getSelectedOptions as b, getValueToOption as g };
|
|
691
|
+
//# sourceMappingURL=dep-Dk2xX8lh.js.map
|