@qsxy/element-plus-react 1.0.1 → 1.0.3
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/dist/Alert/Alert.d.ts +7 -0
- package/dist/Alert/Alert.js +98 -0
- package/dist/Alert/index.d.ts +2 -0
- package/dist/Alert/index.js +1 -0
- package/dist/Alert/typings.d.ts +45 -0
- package/dist/Alert/typings.js +1 -0
- package/dist/Calendar/Calendar.js +12 -3
- package/dist/Calendar/Footer.js +4 -2
- package/dist/Calendar/QuarterPanel.d.ts +4 -0
- package/dist/Calendar/QuarterPanel.js +109 -0
- package/dist/Calendar/WeekPanel.js +1 -1
- package/dist/Calendar/typings.d.ts +1 -1
- package/dist/Card/Card.js +13 -6
- package/dist/Card/typings.d.ts +1 -1
- package/dist/Cascader/Cascader.js +1 -1
- package/dist/Cascader/useCascader.d.ts +0 -14
- package/dist/Cascader/useCascader.js +33 -32
- package/dist/Checkbox/Checkbox.js +3 -2
- package/dist/ConfigProvider/ConfigProvider.js +2 -24
- package/dist/ConfigProvider/ConfigProviderContext.js +1 -1
- package/dist/ConfigProvider/typings.d.ts +1 -1
- package/dist/Container/Main.d.ts +1 -1
- package/dist/Container/typings.d.ts +1 -1
- package/dist/DatePicker/DatePicker.js +38 -12
- package/dist/DatePicker/DateRangePicker.js +27 -9
- package/dist/DatePicker/main.js +1 -1
- package/dist/DatePicker/typings.d.ts +1 -1
- package/dist/DateTimePicker/DateTimePicker.js +2 -2
- package/dist/Dialog/Dialog.js +5 -12
- package/dist/Input/Input.js +190 -149
- package/dist/Input/InputRange.js +1 -1
- package/dist/Input/TextArea.js +87 -12
- package/dist/Input/typings.d.ts +56 -5
- package/dist/Input/useComposition.d.ts +23 -0
- package/dist/Input/useComposition.js +63 -0
- package/dist/Input/utils.d.ts +7 -0
- package/dist/Input/utils.js +95 -0
- package/dist/InputNumber/InputNumber.js +351 -141
- package/dist/InputNumber/typings.d.ts +16 -2
- package/dist/Loading/Loading.js +5 -2
- package/dist/Menu/Menu.js +25 -1
- package/dist/Menu/MenuItem.js +4 -2
- package/dist/Menu/SubMenu.js +2 -2
- package/dist/Menu/SubMenuCollapseTransition.js +14 -9
- package/dist/Menu/typings.d.ts +2 -1
- package/dist/Message/Message.js +51 -23
- package/dist/Message/index.js +8 -10
- package/dist/Message/typings.d.ts +8 -5
- package/dist/MessageBox/MessageBox.js +52 -30
- package/dist/MessageBox/index.d.ts +2 -1
- package/dist/MessageBox/index.js +4 -2
- package/dist/MessageBox/typings.d.ts +3 -0
- package/dist/Notification/Notification.js +26 -19
- package/dist/Select/Option.js +30 -14
- package/dist/Select/SelectContext.d.ts +5 -5
- package/dist/Select/SelectContext.js +2 -1
- package/dist/Select/SelectCore.d.ts +2 -2
- package/dist/Select/SelectCore.js +172 -449
- package/dist/Select/SelectDropdown.js +85 -155
- package/dist/Select/index.d.ts +1 -1
- package/dist/Select/typings.d.ts +52 -22
- package/dist/Select/useSelect.d.ts +128 -0
- package/dist/Select/useSelect.js +524 -0
- package/dist/Space/Space.d.ts +4 -0
- package/dist/Space/Space.js +128 -0
- package/dist/Space/SpaceItem.d.ts +7 -0
- package/dist/Space/SpaceItem.js +14 -0
- package/dist/Space/index.d.ts +3 -0
- package/dist/Space/index.js +2 -0
- package/dist/Space/typings.d.ts +26 -0
- package/dist/Space/typings.js +1 -0
- package/dist/Space/useSpace.d.ts +7 -0
- package/dist/Space/useSpace.js +104 -0
- package/dist/Statistic/Statistic.d.ts +4 -0
- package/dist/Statistic/Statistic.js +92 -0
- package/dist/Statistic/index.d.ts +2 -0
- package/dist/Statistic/index.js +1 -0
- package/dist/Statistic/typings.d.ts +28 -0
- package/dist/Statistic/typings.js +1 -0
- package/dist/Switch/Switch.js +2 -2
- package/dist/Table/Table.js +3 -0
- package/dist/Table/typings.d.ts +2 -0
- package/dist/Table/util.js +6 -5
- package/dist/Tag/Tag.js +22 -17
- package/dist/Tag/typings.d.ts +1 -1
- package/dist/Text/Text.d.ts +4 -0
- package/dist/Text/Text.js +84 -0
- package/dist/Text/index.d.ts +2 -0
- package/dist/Text/index.js +1 -0
- package/dist/Text/typings.d.ts +15 -0
- package/dist/Text/typings.js +1 -0
- package/dist/TimePicker/TimePicker.js +2 -2
- package/dist/Tree/CollapseTransition.d.ts +7 -0
- package/dist/Tree/CollapseTransition.js +60 -0
- package/dist/Tree/Tree.d.ts +3 -140
- package/dist/Tree/Tree.js +350 -77
- package/dist/Tree/TreeContext.d.ts +9 -0
- package/dist/Tree/TreeContext.js +14 -0
- package/dist/Tree/TreeNode.d.ts +5 -3
- package/dist/Tree/TreeNode.js +321 -331
- package/dist/Tree/TreeNodeContent.d.ts +9 -0
- package/dist/Tree/TreeNodeContent.js +22 -0
- package/dist/Tree/index.d.ts +3 -8
- package/dist/Tree/index.js +1 -4
- package/dist/Tree/model/node.d.ts +62 -0
- package/dist/Tree/model/node.js +601 -0
- package/dist/Tree/model/tree-store.d.ts +52 -0
- package/dist/Tree/model/tree-store.js +510 -0
- package/dist/Tree/model/useDragNode.d.ts +30 -0
- package/dist/Tree/model/useDragNode.js +293 -0
- package/dist/Tree/model/useKeydown.d.ts +0 -0
- package/dist/Tree/model/useKeydown.js +104 -0
- package/dist/Tree/model/useNodeExpandEventBroadcast.d.ts +15 -0
- package/dist/Tree/model/useNodeExpandEventBroadcast.js +54 -0
- package/dist/Tree/model/util.d.ts +7 -0
- package/dist/Tree/model/util.js +24 -0
- package/dist/Tree/typings.d.ts +225 -114
- package/dist/TreeSelect/TreeSelect.d.ts +2 -10
- package/dist/TreeSelect/TreeSelect.js +90 -566
- package/dist/TreeSelect/TreeSelectOption.d.ts +6 -0
- package/dist/TreeSelect/TreeSelectOption.js +62 -0
- package/dist/TreeSelect/cacheOptions.d.ts +9 -0
- package/dist/TreeSelect/cacheOptions.js +22 -0
- package/dist/TreeSelect/index.d.ts +0 -1
- package/dist/TreeSelect/typings.d.ts +11 -63
- package/dist/TreeSelect/useSelect.d.ts +125 -0
- package/dist/TreeSelect/useSelect.js +104 -0
- package/dist/TreeSelect/useTree.d.ts +130 -0
- package/dist/TreeSelect/useTree.js +285 -0
- package/dist/TreeSelect/utils.d.ts +10 -0
- package/dist/TreeSelect/utils.js +38 -0
- package/dist/Upload/UploadContent.js +2 -0
- package/dist/Upload/ajax.js +3 -0
- package/dist/Upload/typings.d.ts +4 -0
- package/dist/Util/aria.d.ts +25 -0
- package/dist/Util/aria.js +118 -0
- package/dist/Util/base.d.ts +5 -0
- package/dist/Util/base.js +140 -1
- package/dist/config/Constants.d.ts +3 -0
- package/dist/config/Constants.js +8 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/popperPropsUtils.js +1 -1
- package/dist/hooks/treePropsUtils.d.ts +3 -3
- package/dist/hooks/treePropsUtils.js +2 -2
- package/dist/hooks/useCalcInputWidth.d.ts +8 -0
- package/dist/{Tree/useUnmount.js → hooks/useCalcInputWidth.js} +23 -27
- package/dist/hooks/useComposition.d.ts +16 -0
- package/dist/hooks/useComposition.js +39 -0
- package/dist/hooks/useConfigProvider.d.ts +27 -0
- package/dist/hooks/useConfigProvider.js +78 -0
- package/dist/hooks/useCursor.d.ts +2 -0
- package/dist/hooks/useCursor.js +52 -0
- package/dist/hooks/useFocusController.d.ts +27 -0
- package/dist/hooks/useFocusController.js +72 -0
- package/dist/hooks/useResizeObserver.js +6 -6
- package/dist/index.css +1 -1
- package/dist/index.d.ts +18 -11
- package/dist/index.js +11 -5
- package/dist/locale/en.d.ts +15 -0
- package/dist/locale/en.js +15 -0
- package/dist/locale/zhCn.d.ts +15 -0
- package/dist/locale/zhCn.js +15 -0
- package/package.json +1 -1
- package/theme-chalk/alert.scss +115 -0
- package/theme-chalk/aside.scss +8 -8
- package/theme-chalk/button-group.scss +80 -80
- package/theme-chalk/button.scss +304 -304
- package/theme-chalk/calendar/date-table.scss +164 -164
- package/theme-chalk/calendar/index.scss +1 -0
- package/theme-chalk/calendar/quarter-table.scss +78 -0
- package/theme-chalk/checkbox.scss +34 -0
- package/theme-chalk/color/index.scss +20 -20
- package/theme-chalk/common/transition.scss +142 -142
- package/theme-chalk/common/var.scss +1 -1
- package/theme-chalk/container.scss +14 -14
- package/theme-chalk/dark/css-vars.scss +39 -39
- package/theme-chalk/dark/var.scss +225 -225
- package/theme-chalk/date-picker.scss +12 -12
- package/theme-chalk/drawer.scss +1 -0
- package/theme-chalk/footer.scss +12 -12
- package/theme-chalk/header.scss +12 -12
- package/theme-chalk/index.scss +4 -0
- package/theme-chalk/input/input-range.scss +2 -1
- package/theme-chalk/input/input.scss +298 -437
- package/theme-chalk/input/input.scss--bak +578 -0
- package/theme-chalk/input-number.bak +172 -0
- package/theme-chalk/input-number.scss +192 -172
- package/theme-chalk/link.scss +87 -87
- package/theme-chalk/main.scss +14 -14
- package/theme-chalk/menu.scss +353 -353
- package/theme-chalk/message.scss +104 -178
- package/theme-chalk/mixins/_button.scss +224 -224
- package/theme-chalk/mixins/_col.scss +33 -33
- package/theme-chalk/mixins/_var.scss +67 -67
- package/theme-chalk/mixins/config.scss +5 -5
- package/theme-chalk/mixins/function.scss +99 -99
- package/theme-chalk/mixins/mixins.scss +240 -240
- package/theme-chalk/mixins/utils.scss +39 -39
- package/theme-chalk/notification.bak +156 -0
- package/theme-chalk/notification.scss +109 -156
- package/theme-chalk/popper.scss +104 -104
- package/theme-chalk/radio-button.scss +169 -169
- package/theme-chalk/select/index.scss +222 -191
- package/theme-chalk/select/index.scss--bak +247 -0
- package/theme-chalk/select/option-group.scss +2 -2
- package/theme-chalk/select/option.scss +2 -2
- package/theme-chalk/select/select-dropdown.scss +2 -2
- package/theme-chalk/space.scss +20 -0
- package/theme-chalk/statistic.scss +35 -0
- package/theme-chalk/switch.scss +300 -300
- package/theme-chalk/tag.scss +150 -172
- package/theme-chalk/tag.scss--bak +203 -0
- package/theme-chalk/text.scss +48 -0
- package/theme-chalk/transition.scss +34 -4
- package/theme-chalk/tree-select.scss +41 -25
- package/theme-chalk/tree.scss +136 -0
- package/theme-chalk/var.scss +83 -83
- package/dist/Tree/DirectoryTree.d.ts +0 -15
- package/dist/Tree/DirectoryTree.js +0 -183
- package/dist/Tree/DropIndicator.d.ts +0 -8
- package/dist/Tree/DropIndicator.js +0 -34
- package/dist/Tree/Indent.d.ts +0 -9
- package/dist/Tree/Indent.js +0 -25
- package/dist/Tree/MotionTreeNode.d.ts +0 -14
- package/dist/Tree/MotionTreeNode.js +0 -125
- package/dist/Tree/NodeList.d.ts +0 -50
- package/dist/Tree/NodeList.js +0 -301
- package/dist/Tree/RCTree.d.ts +0 -248
- package/dist/Tree/RCTree.js +0 -1216
- package/dist/Tree/contextTypes.d.ts +0 -69
- package/dist/Tree/contextTypes.js +0 -9
- package/dist/Tree/typings.tsx--bak +0 -245
- package/dist/Tree/useUnmount.d.ts +0 -5
- package/dist/Tree/util.d.ts +0 -51
- package/dist/Tree/util.js +0 -303
- package/dist/Tree/utils/conductUtil.d.ts +0 -17
- package/dist/Tree/utils/conductUtil.js +0 -209
- package/dist/Tree/utils/dictUtil.d.ts +0 -13
- package/dist/Tree/utils/dictUtil.js +0 -75
- package/dist/Tree/utils/diffUtil.d.ts +0 -7
- package/dist/Tree/utils/diffUtil.js +0 -48
- package/dist/Tree/utils/dropIndicator.d.ts +0 -11
- package/dist/Tree/utils/dropIndicator.js +0 -36
- package/dist/Tree/utils/iconUtil.d.ts +0 -5
- package/dist/Tree/utils/iconUtil.js +0 -62
- package/dist/Tree/utils/keyUtil.d.ts +0 -2
- package/dist/Tree/utils/keyUtil.js +0 -3
- package/dist/Tree/utils/motion.d.ts +0 -10
- package/dist/Tree/utils/motion.js +0 -54
- package/dist/Tree/utils/pickAttrs.d.ts +0 -11
- package/dist/Tree/utils/pickAttrs.js +0 -51
- package/dist/Tree/utils/treeUtil.d.ts +0 -86
- package/dist/Tree/utils/treeUtil.js +0 -364
- package/dist/TreeSelect/Utils.d.ts +0 -3
- package/dist/TreeSelect/Utils.js +0 -20
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["filterable", "clearable", "clearIcon", "multiple", "onChange", "allowCreate", "onEnter", "afterLeave", "onVisibleChange", "onRemoveTag", "onClear", "labelFormat", "remote", "remoteShowSuffix", "suffixIcon"];
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
13
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
16
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
17
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
19
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
20
|
+
import ensureArray from 'lodash/castArray';
|
|
21
|
+
import filter from 'lodash/filter';
|
|
22
|
+
import max from 'lodash/max';
|
|
23
|
+
import min from 'lodash/min';
|
|
24
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
25
|
+
import { useTranslation } from 'react-i18next';
|
|
26
|
+
import { useConfigProvider } from "../ConfigProvider/ConfigProviderContext";
|
|
27
|
+
import { isEmpty, isNotEmpty, isUndefined, mergeDefaultProps } from "../Util";
|
|
28
|
+
import { partitionAnimationProps, partitionHTMLProps, partitionPopperPropsUtils, useChildrenInstance, useClassNames, useControlled, useDisabled, useSize } from "../hooks";
|
|
29
|
+
import { useComposition } from "../hooks/useComposition";
|
|
30
|
+
var useSelect = function useSelect(props) {
|
|
31
|
+
var _useConfigProvider = useConfigProvider(),
|
|
32
|
+
locale = _useConfigProvider.locale;
|
|
33
|
+
var _useTranslation = useTranslation(),
|
|
34
|
+
t = _useTranslation.t;
|
|
35
|
+
props = mergeDefaultProps({
|
|
36
|
+
placeholder: t('el.select.placeholder', {
|
|
37
|
+
lng: locale
|
|
38
|
+
}),
|
|
39
|
+
noDataText: t('el.select.noData', {
|
|
40
|
+
lng: locale
|
|
41
|
+
}),
|
|
42
|
+
noMatchText: t('el.select.noMatch', {
|
|
43
|
+
lng: locale
|
|
44
|
+
}),
|
|
45
|
+
loadingText: t('el.select.loading', {
|
|
46
|
+
lng: locale
|
|
47
|
+
}),
|
|
48
|
+
showArrow: true,
|
|
49
|
+
clearable: false,
|
|
50
|
+
filterable: false,
|
|
51
|
+
error: false,
|
|
52
|
+
required: false,
|
|
53
|
+
disabled: false,
|
|
54
|
+
maxWidth: 500,
|
|
55
|
+
collapseTagsTooltip: true,
|
|
56
|
+
maxCollapseTags: 1,
|
|
57
|
+
tagType: 'info',
|
|
58
|
+
tagEffect: 'light',
|
|
59
|
+
suffixIcon: 'angle-down',
|
|
60
|
+
clearIcon: 'circle-xmark'
|
|
61
|
+
}, props);
|
|
62
|
+
var nsSelect = useClassNames('select');
|
|
63
|
+
var be = nsSelect.be,
|
|
64
|
+
is = nsSelect.is;
|
|
65
|
+
// 选择框容器div
|
|
66
|
+
var containerRef = useRef(null);
|
|
67
|
+
// 下拉选项容器div
|
|
68
|
+
var contentRef = useRef(null);
|
|
69
|
+
var popperInstRef = useRef(null);
|
|
70
|
+
var selectDropdownRef = useRef(null);
|
|
71
|
+
var tagTooltipRef = useRef(null);
|
|
72
|
+
var inputRef = useRef(null);
|
|
73
|
+
var wrapperRef = useRef(null);
|
|
74
|
+
var suffixWrapperRef = useRef(null);
|
|
75
|
+
// 输入框是否初始化
|
|
76
|
+
var initedRef = useRef(false);
|
|
77
|
+
var _props = props,
|
|
78
|
+
filterable = _props.filterable,
|
|
79
|
+
clearable = _props.clearable,
|
|
80
|
+
clearIcon = _props.clearIcon,
|
|
81
|
+
multiple = _props.multiple,
|
|
82
|
+
onChange = _props.onChange,
|
|
83
|
+
allowCreate = _props.allowCreate,
|
|
84
|
+
onEnter = _props.onEnter,
|
|
85
|
+
afterLeave = _props.afterLeave,
|
|
86
|
+
onVisibleChange = _props.onVisibleChange,
|
|
87
|
+
onRemoveTag = _props.onRemoveTag,
|
|
88
|
+
onClearProp = _props.onClear,
|
|
89
|
+
labelFormat = _props.labelFormat,
|
|
90
|
+
remote = _props.remote,
|
|
91
|
+
remoteShowSuffix = _props.remoteShowSuffix,
|
|
92
|
+
suffixIcon = _props.suffixIcon,
|
|
93
|
+
rest = _objectWithoutProperties(_props, _excluded);
|
|
94
|
+
var _partitionHTMLProps = partitionHTMLProps(rest),
|
|
95
|
+
_partitionHTMLProps2 = _slicedToArray(_partitionHTMLProps, 1),
|
|
96
|
+
htmlInputProps = _partitionHTMLProps2[0];
|
|
97
|
+
var _partitionAnimationPr = partitionAnimationProps(rest),
|
|
98
|
+
_partitionAnimationPr2 = _slicedToArray(_partitionAnimationPr, 1),
|
|
99
|
+
transitionProps = _partitionAnimationPr2[0];
|
|
100
|
+
var _partitionPopperProps = partitionPopperPropsUtils(rest),
|
|
101
|
+
_partitionPopperProps2 = _slicedToArray(_partitionPopperProps, 1),
|
|
102
|
+
popperProps = _partitionPopperProps2[0];
|
|
103
|
+
var _useControlled = useControlled(props.value, props.defaultValue),
|
|
104
|
+
_useControlled2 = _slicedToArray(_useControlled, 2),
|
|
105
|
+
value = _useControlled2[0],
|
|
106
|
+
setValue = _useControlled2[1];
|
|
107
|
+
var disabled = useDisabled(props.disabled);
|
|
108
|
+
var size = useSize(props.size);
|
|
109
|
+
|
|
110
|
+
// 单选框显示文本
|
|
111
|
+
// const [selected, setSelected] = useState<OptionData | OptionData[]>(null);
|
|
112
|
+
|
|
113
|
+
var _useState = useState(false),
|
|
114
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
115
|
+
visible = _useState2[0],
|
|
116
|
+
setVisible = _useState2[1];
|
|
117
|
+
var _useState3 = useState({}),
|
|
118
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
119
|
+
popperStyle = _useState4[0],
|
|
120
|
+
setPopperStyle = _useState4[1];
|
|
121
|
+
// 多选时input框高度
|
|
122
|
+
var _useState5 = useState(''),
|
|
123
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
124
|
+
inputValue = _useState6[0],
|
|
125
|
+
setInputValue = _useState6[1];
|
|
126
|
+
var cachedOptions = useRef(new Map());
|
|
127
|
+
|
|
128
|
+
/** 获取所有的option组件 */
|
|
129
|
+
var getOptionInstance = useChildrenInstance('ElOption', 'ElOptionGroup');
|
|
130
|
+
var optionData = useMemo(function () {
|
|
131
|
+
if (props.children) {
|
|
132
|
+
var componentChildren = getOptionInstance(props.children);
|
|
133
|
+
return componentChildren.map(function (node) {
|
|
134
|
+
var _node$props$label, _node$props$label2, _node$props;
|
|
135
|
+
cachedOptions.current.set(node.props.value, {
|
|
136
|
+
value: node.props.value,
|
|
137
|
+
label: (_node$props$label = node.props.label) !== null && _node$props$label !== void 0 ? _node$props$label : node.props.value,
|
|
138
|
+
data: node.props.data
|
|
139
|
+
});
|
|
140
|
+
return {
|
|
141
|
+
label: (_node$props$label2 = (_node$props = node.props) === null || _node$props === void 0 ? void 0 : _node$props.label) !== null && _node$props$label2 !== void 0 ? _node$props$label2 : node.props.value,
|
|
142
|
+
value: node.props.value,
|
|
143
|
+
data: node.props.data
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return [];
|
|
148
|
+
}, [getOptionInstance, props.children]);
|
|
149
|
+
|
|
150
|
+
// 多选框值
|
|
151
|
+
var multiValue = useMemo(function () {
|
|
152
|
+
if (multiple) {
|
|
153
|
+
if (value instanceof Array) {
|
|
154
|
+
return value;
|
|
155
|
+
} else if (typeof value === 'string') {
|
|
156
|
+
return [value];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return [];
|
|
160
|
+
}, [multiple, value]);
|
|
161
|
+
var multiOptionData = useMemo(function () {
|
|
162
|
+
if (multiple) {
|
|
163
|
+
return multiValue.map(function (item) {
|
|
164
|
+
return [].concat(_toConsumableArray(optionData), _toConsumableArray(Array.from(cachedOptions.current.values()))).find(function (op) {
|
|
165
|
+
return op.value === item;
|
|
166
|
+
});
|
|
167
|
+
}).filter(function (item) {
|
|
168
|
+
return isNotEmpty(item);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return [];
|
|
172
|
+
}, [multiValue, multiple, optionData]);
|
|
173
|
+
var selected = useMemo(function () {
|
|
174
|
+
if (multiple) {
|
|
175
|
+
return multiOptionData;
|
|
176
|
+
} else {
|
|
177
|
+
return [].concat(_toConsumableArray(optionData), _toConsumableArray(Array.from(cachedOptions.current.values()))).find(function (item) {
|
|
178
|
+
return item.value === value;
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}, [multiple, multiOptionData, optionData, value]);
|
|
182
|
+
var label = useMemo(function () {
|
|
183
|
+
if (!multiple && selected && !Array.isArray(selected)) {
|
|
184
|
+
var _selected$label;
|
|
185
|
+
return ((_selected$label = selected.label) !== null && _selected$label !== void 0 ? _selected$label : selected.value) + '';
|
|
186
|
+
}
|
|
187
|
+
return '';
|
|
188
|
+
}, [multiple, selected]);
|
|
189
|
+
|
|
190
|
+
// 占位符
|
|
191
|
+
var placeholder = useMemo(function () {
|
|
192
|
+
var _placeholder = '';
|
|
193
|
+
if (multiple && isNotEmpty(multiValue) || isNotEmpty(inputValue)) {
|
|
194
|
+
_placeholder = '';
|
|
195
|
+
}
|
|
196
|
+
if (!allowCreate && filterable && isEmpty(inputValue)) {
|
|
197
|
+
_placeholder = t('el.select.search', {
|
|
198
|
+
lng: locale
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (props.placeholder) {
|
|
202
|
+
_placeholder = props.placeholder;
|
|
203
|
+
}
|
|
204
|
+
return multiple || isEmpty(label) ? _placeholder : label;
|
|
205
|
+
}, [allowCreate, filterable, inputValue, label, locale, multiValue, multiple, props.placeholder, t]);
|
|
206
|
+
var shouldShowPlaceholder = useMemo(function () {
|
|
207
|
+
if (multiple && !isUndefined(value)) {
|
|
208
|
+
return ensureArray(value).length === 0 && !inputValue;
|
|
209
|
+
}
|
|
210
|
+
var _value = Array.isArray(value) ? value[0] : value;
|
|
211
|
+
return filterable || isUndefined(_value) ? !inputValue : true;
|
|
212
|
+
}, [inputValue, filterable, multiple, value]);
|
|
213
|
+
var iconComponent = useMemo(function () {
|
|
214
|
+
return remote && filterable && !remoteShowSuffix ? null : suffixIcon;
|
|
215
|
+
}, [filterable, remote, remoteShowSuffix, suffixIcon]);
|
|
216
|
+
var iconReverse = useMemo(function () {
|
|
217
|
+
return is({
|
|
218
|
+
reverse: !!(iconComponent && visible)
|
|
219
|
+
});
|
|
220
|
+
}, [iconComponent, is, visible]);
|
|
221
|
+
|
|
222
|
+
// const validateState = useMemo(() => formItem?.validateState || '');
|
|
223
|
+
// const validateIcon = useMemo(() => validateState.value && (ValidateComponentsMap[validateState.value] as Component));
|
|
224
|
+
|
|
225
|
+
// const multiLabel = useMemo(() => {
|
|
226
|
+
// if (multiple) {
|
|
227
|
+
// return multiValue.map(item => find(optionData, { value: item })?.label ?? item);
|
|
228
|
+
// }
|
|
229
|
+
// return [];
|
|
230
|
+
// }, [multiValue, multiple, optionData]);
|
|
231
|
+
|
|
232
|
+
var showClearBtn = useCallback(function (show) {
|
|
233
|
+
if (show && clearable && !disabled && isNotEmpty(value)) {
|
|
234
|
+
var _suffixWrapperRef$cur, _suffixWrapperRef$cur2;
|
|
235
|
+
(_suffixWrapperRef$cur = suffixWrapperRef.current) === null || _suffixWrapperRef$cur === void 0 || _suffixWrapperRef$cur.classList.add(nsSelect.is('hidden-arrow'));
|
|
236
|
+
(_suffixWrapperRef$cur2 = suffixWrapperRef.current) === null || _suffixWrapperRef$cur2 === void 0 || _suffixWrapperRef$cur2.classList.remove(nsSelect.is('hidden-clear'));
|
|
237
|
+
} else {
|
|
238
|
+
var _suffixWrapperRef$cur3, _suffixWrapperRef$cur4;
|
|
239
|
+
(_suffixWrapperRef$cur3 = suffixWrapperRef.current) === null || _suffixWrapperRef$cur3 === void 0 || _suffixWrapperRef$cur3.classList.remove(nsSelect.is('hidden-arrow'));
|
|
240
|
+
(_suffixWrapperRef$cur4 = suffixWrapperRef.current) === null || _suffixWrapperRef$cur4 === void 0 || _suffixWrapperRef$cur4.classList.add(nsSelect.is('hidden-clear'));
|
|
241
|
+
}
|
|
242
|
+
}, [clearable, disabled, nsSelect, value]);
|
|
243
|
+
var setInputHovering = useCallback(function (hovering) {
|
|
244
|
+
if (!disabled) {
|
|
245
|
+
if (wrapperRef.current) {
|
|
246
|
+
if (hovering) {
|
|
247
|
+
wrapperRef.current.classList.add(nsSelect.is('hovering'));
|
|
248
|
+
showClearBtn(true);
|
|
249
|
+
} else {
|
|
250
|
+
wrapperRef.current.classList.remove(nsSelect.is('hovering'));
|
|
251
|
+
if (wrapperRef.current.classList.contains(nsSelect.is('focused'))) {
|
|
252
|
+
showClearBtn(true);
|
|
253
|
+
} else {
|
|
254
|
+
showClearBtn(false);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}, [disabled, nsSelect, showClearBtn]);
|
|
260
|
+
var setIsFocused = useCallback(function (focused) {
|
|
261
|
+
if (wrapperRef.current) {
|
|
262
|
+
if (focused) {
|
|
263
|
+
wrapperRef.current.classList.add(nsSelect.is('focused'));
|
|
264
|
+
showClearBtn(true);
|
|
265
|
+
} else {
|
|
266
|
+
wrapperRef.current.classList.remove(nsSelect.is('focused'));
|
|
267
|
+
if (wrapperRef.current.classList.contains(nsSelect.is('hovering'))) {
|
|
268
|
+
showClearBtn(true);
|
|
269
|
+
} else {
|
|
270
|
+
showClearBtn(false);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}, [nsSelect, showClearBtn]);
|
|
275
|
+
var _useComposition = useComposition({
|
|
276
|
+
afterComposition: function afterComposition(event) {
|
|
277
|
+
setInputValue(event.target.value);
|
|
278
|
+
}
|
|
279
|
+
}),
|
|
280
|
+
isComposing = _useComposition.isComposing,
|
|
281
|
+
handleCompositionStart = _useComposition.handleCompositionStart,
|
|
282
|
+
handleCompositionUpdate = _useComposition.handleCompositionUpdate,
|
|
283
|
+
handleCompositionEnd = _useComposition.handleCompositionEnd;
|
|
284
|
+
|
|
285
|
+
/** 动态计算下拉框宽度 */
|
|
286
|
+
var handleEnter = useCallback(function (node) {
|
|
287
|
+
if (visible && contentRef.current && containerRef.current) {
|
|
288
|
+
var _selectDropdownRef$cu;
|
|
289
|
+
var rect = containerRef.current.getBoundingClientRect();
|
|
290
|
+
// const { width } = contentRef.current.getBoundingClientRect();
|
|
291
|
+
var options = Array.from(contentRef.current.querySelectorAll(".".concat(be('dropdown', 'item'), ">span")));
|
|
292
|
+
var maxWidth = (options.length > 0 ? max(options.map(function (item) {
|
|
293
|
+
var _item$offsetWidth;
|
|
294
|
+
return (_item$offsetWidth = item === null || item === void 0 ? void 0 : item.offsetWidth) !== null && _item$offsetWidth !== void 0 ? _item$offsetWidth : 0;
|
|
295
|
+
})) : 0) + 60;
|
|
296
|
+
if (maxWidth && maxWidth < rect.width) {
|
|
297
|
+
setPopperStyle(_objectSpread(_objectSpread({}, popperStyle), {}, {
|
|
298
|
+
width: rect.width
|
|
299
|
+
}));
|
|
300
|
+
} else {
|
|
301
|
+
setPopperStyle(_objectSpread(_objectSpread({}, popperStyle), {}, {
|
|
302
|
+
width: min([maxWidth, props.maxWidth])
|
|
303
|
+
}));
|
|
304
|
+
}
|
|
305
|
+
(_selectDropdownRef$cu = selectDropdownRef.current) === null || _selectDropdownRef$cu === void 0 || _selectDropdownRef$cu.scrollToSelected();
|
|
306
|
+
onEnter === null || onEnter === void 0 || onEnter(node);
|
|
307
|
+
}
|
|
308
|
+
}, [be, onEnter, popperStyle, props.maxWidth, visible]);
|
|
309
|
+
|
|
310
|
+
/** 关闭下拉框后清空搜索项 */
|
|
311
|
+
var handleAfterLeave = useCallback(function (node) {
|
|
312
|
+
var _selectDropdownRef$cu2;
|
|
313
|
+
(_selectDropdownRef$cu2 = selectDropdownRef.current) === null || _selectDropdownRef$cu2 === void 0 || _selectDropdownRef$cu2.clear();
|
|
314
|
+
afterLeave === null || afterLeave === void 0 || afterLeave(node);
|
|
315
|
+
}, [afterLeave]);
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* 展开/关闭下拉框
|
|
319
|
+
* @param e
|
|
320
|
+
* @returns
|
|
321
|
+
*/
|
|
322
|
+
var toggleMenu = useCallback(function (event) {
|
|
323
|
+
event === null || event === void 0 || event.preventDefault();
|
|
324
|
+
event === null || event === void 0 || event.stopPropagation();
|
|
325
|
+
if (disabled) {
|
|
326
|
+
setVisible(false);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
setVisible(!visible);
|
|
330
|
+
setIsFocused(!visible);
|
|
331
|
+
}, [disabled, setIsFocused, visible]);
|
|
332
|
+
|
|
333
|
+
/** 取消多选项 */
|
|
334
|
+
var onCloseTag = useCallback(function (event, item) {
|
|
335
|
+
event.stopPropagation();
|
|
336
|
+
var res = multiValue.filter(function (val) {
|
|
337
|
+
return val !== item.value;
|
|
338
|
+
});
|
|
339
|
+
setValue(res);
|
|
340
|
+
onChange === null || onChange === void 0 || onChange(res, multiOptionData.filter(function (val) {
|
|
341
|
+
return val.value !== item.value;
|
|
342
|
+
}));
|
|
343
|
+
onRemoveTag === null || onRemoveTag === void 0 || onRemoveTag(item);
|
|
344
|
+
setTimeout(function () {
|
|
345
|
+
if (tagTooltipRef.current) {
|
|
346
|
+
tagTooltipRef.current.updatePopper();
|
|
347
|
+
}
|
|
348
|
+
}, 50);
|
|
349
|
+
}, [multiOptionData, multiValue, onChange, onRemoveTag, setValue]);
|
|
350
|
+
|
|
351
|
+
/** 重置值 */
|
|
352
|
+
var onClear = useCallback(function (event) {
|
|
353
|
+
var _selectDropdownRef$cu3;
|
|
354
|
+
event.stopPropagation();
|
|
355
|
+
event.preventDefault();
|
|
356
|
+
setValue(multiple ? [] : '');
|
|
357
|
+
// setSelected(null);
|
|
358
|
+
(_selectDropdownRef$cu3 = selectDropdownRef.current) === null || _selectDropdownRef$cu3 === void 0 || _selectDropdownRef$cu3.hover('');
|
|
359
|
+
onChange === null || onChange === void 0 || onChange(multiple ? [] : '');
|
|
360
|
+
onClearProp === null || onClearProp === void 0 || onClearProp();
|
|
361
|
+
setInputValue('');
|
|
362
|
+
showClearBtn(false);
|
|
363
|
+
setVisible(false);
|
|
364
|
+
}, [multiple, onChange, onClearProp, setValue, showClearBtn]);
|
|
365
|
+
|
|
366
|
+
/** 选中项回调 */
|
|
367
|
+
var onChoose = useCallback(function (val, data, event) {
|
|
368
|
+
event === null || event === void 0 || event.preventDefault();
|
|
369
|
+
if (isNotEmpty(val)) {
|
|
370
|
+
var result = val;
|
|
371
|
+
var multiData = [];
|
|
372
|
+
if (multiple) {
|
|
373
|
+
if (multiValue.includes(val)) {
|
|
374
|
+
result = filter(multiValue, function (item) {
|
|
375
|
+
return item !== val;
|
|
376
|
+
});
|
|
377
|
+
multiData = multiOptionData.filter(function (item) {
|
|
378
|
+
return item.value !== val;
|
|
379
|
+
});
|
|
380
|
+
} else {
|
|
381
|
+
result = [].concat(_toConsumableArray(multiValue), [val]);
|
|
382
|
+
multiData = [].concat(_toConsumableArray(multiOptionData), [data]);
|
|
383
|
+
}
|
|
384
|
+
// setSelected(multiData);
|
|
385
|
+
} else {
|
|
386
|
+
setInputValue('');
|
|
387
|
+
// setSelected(data);
|
|
388
|
+
}
|
|
389
|
+
if (allowCreate && isNotEmpty(inputValue)) {
|
|
390
|
+
var _inputRef$current;
|
|
391
|
+
setInputValue('');
|
|
392
|
+
cachedOptions.current.set(inputValue, {
|
|
393
|
+
value: inputValue,
|
|
394
|
+
label: inputValue,
|
|
395
|
+
data: {
|
|
396
|
+
value: inputValue,
|
|
397
|
+
label: inputValue
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
setIsFocused(false);
|
|
401
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.blur();
|
|
402
|
+
}
|
|
403
|
+
setValue(result);
|
|
404
|
+
onChange === null || onChange === void 0 || onChange(result, multiple ? multiData : data);
|
|
405
|
+
!multiple && toggleMenu(event);
|
|
406
|
+
return result;
|
|
407
|
+
} else {
|
|
408
|
+
setVisible(false);
|
|
409
|
+
}
|
|
410
|
+
if (!multiValue) {
|
|
411
|
+
setInputValue('');
|
|
412
|
+
}
|
|
413
|
+
}, [multiValue, multiple, allowCreate, inputValue, setValue, onChange, toggleMenu, multiOptionData, setIsFocused]);
|
|
414
|
+
|
|
415
|
+
/** 监听加载状态,加载中时自动打开下拉 */
|
|
416
|
+
// useEffect(() => {
|
|
417
|
+
// setVisible(props.loading);
|
|
418
|
+
// popperInstRef.current?.update();
|
|
419
|
+
// }, [props.loading]);
|
|
420
|
+
|
|
421
|
+
// 打开后搜索框自动获取焦点
|
|
422
|
+
useEffect(function () {
|
|
423
|
+
onVisibleChange === null || onVisibleChange === void 0 || onVisibleChange(visible);
|
|
424
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
425
|
+
}, [visible]);
|
|
426
|
+
|
|
427
|
+
/** 搜索时 */
|
|
428
|
+
useEffect(function () {
|
|
429
|
+
if (popperInstRef.current && popperInstRef.current.update) {
|
|
430
|
+
var _popperInstRef$curren;
|
|
431
|
+
(_popperInstRef$curren = popperInstRef.current) === null || _popperInstRef$curren === void 0 || _popperInstRef$curren.update();
|
|
432
|
+
}
|
|
433
|
+
}, [popperStyle]);
|
|
434
|
+
|
|
435
|
+
/** 多选框选择选项后,动态调整input框高度 */
|
|
436
|
+
useEffect(function () {
|
|
437
|
+
setTimeout(function () {
|
|
438
|
+
if (popperInstRef.current && popperInstRef.current.update) {
|
|
439
|
+
var _popperInstRef$curren2;
|
|
440
|
+
(_popperInstRef$curren2 = popperInstRef.current) === null || _popperInstRef$curren2 === void 0 || _popperInstRef$curren2.update();
|
|
441
|
+
}
|
|
442
|
+
}, 50);
|
|
443
|
+
}, [multiValue]);
|
|
444
|
+
|
|
445
|
+
/** 初次加载时反显选中文本 */
|
|
446
|
+
useEffect(function () {
|
|
447
|
+
if (initedRef.current) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
if (multiple && Array.isArray(value)) {
|
|
451
|
+
// setSelected(multiOptionData.filter(item => value.includes(item.value)));
|
|
452
|
+
initedRef.current = true;
|
|
453
|
+
} else {
|
|
454
|
+
if (isNotEmpty(value)) {
|
|
455
|
+
var data = optionData.find(function (item) {
|
|
456
|
+
return item.value === value;
|
|
457
|
+
});
|
|
458
|
+
// setSelected(data);
|
|
459
|
+
initedRef.current = true;
|
|
460
|
+
} else {
|
|
461
|
+
// setSelected(null);
|
|
462
|
+
initedRef.current = true;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}, [value]);
|
|
466
|
+
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
467
|
+
nsSelect: nsSelect,
|
|
468
|
+
containerRef: containerRef,
|
|
469
|
+
contentRef: contentRef,
|
|
470
|
+
wrapperRef: wrapperRef,
|
|
471
|
+
popperInstRef: popperInstRef,
|
|
472
|
+
selectDropdownRef: selectDropdownRef,
|
|
473
|
+
tagTooltipRef: tagTooltipRef,
|
|
474
|
+
inputRef: inputRef,
|
|
475
|
+
suffixWrapperRef: suffixWrapperRef,
|
|
476
|
+
inputValue: inputValue,
|
|
477
|
+
setInputHovering: setInputHovering,
|
|
478
|
+
setInputValue: setInputValue,
|
|
479
|
+
setIsFocused: setIsFocused,
|
|
480
|
+
filterable: filterable,
|
|
481
|
+
clearable: clearable,
|
|
482
|
+
clearIcon: clearIcon,
|
|
483
|
+
multiple: multiple,
|
|
484
|
+
onChange: onChange,
|
|
485
|
+
allowCreate: allowCreate,
|
|
486
|
+
onEnter: onEnter,
|
|
487
|
+
afterLeave: afterLeave,
|
|
488
|
+
onVisibleChange: onVisibleChange,
|
|
489
|
+
onRemoveTag: onRemoveTag,
|
|
490
|
+
htmlInputProps: htmlInputProps,
|
|
491
|
+
transitionProps: transitionProps,
|
|
492
|
+
popperProps: popperProps,
|
|
493
|
+
value: value,
|
|
494
|
+
setValue: setValue,
|
|
495
|
+
disabled: disabled,
|
|
496
|
+
size: size,
|
|
497
|
+
optionData: optionData,
|
|
498
|
+
multiValue: multiValue,
|
|
499
|
+
multiOptionData: multiOptionData,
|
|
500
|
+
selected: selected,
|
|
501
|
+
label: label,
|
|
502
|
+
visible: visible,
|
|
503
|
+
setVisible: setVisible,
|
|
504
|
+
popperStyle: popperStyle,
|
|
505
|
+
placeholder: placeholder,
|
|
506
|
+
shouldShowPlaceholder: shouldShowPlaceholder,
|
|
507
|
+
handleEnter: handleEnter,
|
|
508
|
+
handleAfterLeave: handleAfterLeave,
|
|
509
|
+
toggleMenu: toggleMenu,
|
|
510
|
+
onCloseTag: onCloseTag,
|
|
511
|
+
onClear: onClear,
|
|
512
|
+
onChoose: onChoose,
|
|
513
|
+
labelFormat: labelFormat,
|
|
514
|
+
iconComponent: iconComponent,
|
|
515
|
+
iconReverse: iconReverse,
|
|
516
|
+
isComposing: isComposing,
|
|
517
|
+
remote: remote,
|
|
518
|
+
handleCompositionStart: handleCompositionStart,
|
|
519
|
+
handleCompositionUpdate: handleCompositionUpdate,
|
|
520
|
+
handleCompositionEnd: handleCompositionEnd,
|
|
521
|
+
cachedOptions: cachedOptions
|
|
522
|
+
});
|
|
523
|
+
};
|
|
524
|
+
export default useSelect;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
|
+
import classNames from 'classnames';
|
|
14
|
+
import { isArray } from 'lodash';
|
|
15
|
+
import React, { forwardRef, memo, useCallback, useMemo } from 'react';
|
|
16
|
+
import { mergeDefaultProps } from "../Util";
|
|
17
|
+
import SpaceItem from "./SpaceItem";
|
|
18
|
+
import { useSpace } from "./useSpace";
|
|
19
|
+
var Space = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (props, ref) {
|
|
20
|
+
props = mergeDefaultProps({
|
|
21
|
+
direction: 'horizontal',
|
|
22
|
+
prefixCls: 'el-space',
|
|
23
|
+
alignment: 'center',
|
|
24
|
+
justify: '',
|
|
25
|
+
size: 'small',
|
|
26
|
+
fillRatio: 100
|
|
27
|
+
}, props);
|
|
28
|
+
var _props = props,
|
|
29
|
+
direction = _props.direction,
|
|
30
|
+
className = _props.className,
|
|
31
|
+
style = _props.style,
|
|
32
|
+
prefixCls = _props.prefixCls,
|
|
33
|
+
spacer = _props.spacer,
|
|
34
|
+
children = _props.children;
|
|
35
|
+
var _useSpace = useSpace(props),
|
|
36
|
+
classes = _useSpace.classes,
|
|
37
|
+
containerStyle = _useSpace.containerStyle,
|
|
38
|
+
itemStyle = _useSpace.itemStyle;
|
|
39
|
+
|
|
40
|
+
// Extract children and handle fragments
|
|
41
|
+
var extractChildren = useCallback(function (childrenArray) {
|
|
42
|
+
var parentKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
43
|
+
var extractedChildren = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
44
|
+
childrenArray.forEach(function (child, loopKey) {
|
|
45
|
+
if ( /*#__PURE__*/React.isValidElement(child) && child.type === React.Fragment) {
|
|
46
|
+
var _props2;
|
|
47
|
+
// Handle React Fragment
|
|
48
|
+
var fragmentChildren = (_props2 = child.props) === null || _props2 === void 0 ? void 0 : _props2.children;
|
|
49
|
+
if (isArray(fragmentChildren)) {
|
|
50
|
+
fragmentChildren.forEach(function (nested, key) {
|
|
51
|
+
if ( /*#__PURE__*/React.isValidElement(nested) && nested.type === React.Fragment) {
|
|
52
|
+
var _props3;
|
|
53
|
+
var nestedChildren = (_props3 = nested.props) === null || _props3 === void 0 ? void 0 : _props3.children;
|
|
54
|
+
if (isArray(nestedChildren)) {
|
|
55
|
+
extractChildren(nestedChildren, "".concat(parentKey).concat(key, "-"), extractedChildren);
|
|
56
|
+
} else {
|
|
57
|
+
if ( /*#__PURE__*/React.isValidElement(nested) && nested.type === React.Fragment) {
|
|
58
|
+
extractedChildren.push(nested);
|
|
59
|
+
} else {
|
|
60
|
+
extractedChildren.push( /*#__PURE__*/React.createElement(SpaceItem, {
|
|
61
|
+
key: "nested-".concat(parentKey).concat(key),
|
|
62
|
+
style: itemStyle,
|
|
63
|
+
prefixCls: prefixCls
|
|
64
|
+
}, nested));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
extractedChildren.push( /*#__PURE__*/React.createElement(SpaceItem, {
|
|
69
|
+
key: "nested-".concat(parentKey).concat(key),
|
|
70
|
+
style: itemStyle,
|
|
71
|
+
prefixCls: prefixCls
|
|
72
|
+
}, nested));
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
} else if ( /*#__PURE__*/React.isValidElement(child)) {
|
|
77
|
+
// Handle valid React elements
|
|
78
|
+
extractedChildren.push( /*#__PURE__*/React.createElement(SpaceItem, {
|
|
79
|
+
key: "LoopKey".concat(parentKey).concat(loopKey),
|
|
80
|
+
style: itemStyle,
|
|
81
|
+
prefixCls: prefixCls
|
|
82
|
+
}, child));
|
|
83
|
+
}
|
|
84
|
+
// else if (child !== null && child !== undefined && child !== false) {
|
|
85
|
+
// // Handle text nodes and other valid content
|
|
86
|
+
// extractedChildren.push(
|
|
87
|
+
// <SpaceItem key={`LoopKey${parentKey}${loopKey}`} style={itemStyle} prefixCls={prefixCls}>
|
|
88
|
+
// {child}
|
|
89
|
+
// </SpaceItem>,
|
|
90
|
+
// );
|
|
91
|
+
// }
|
|
92
|
+
});
|
|
93
|
+
return extractedChildren;
|
|
94
|
+
}, [itemStyle, prefixCls]);
|
|
95
|
+
var childrenArray = React.Children.toArray(children);
|
|
96
|
+
var extractedChildren = useMemo(function () {
|
|
97
|
+
return extractChildren(childrenArray);
|
|
98
|
+
}, [childrenArray, extractChildren]);
|
|
99
|
+
|
|
100
|
+
// Process children
|
|
101
|
+
if (childrenArray.length === 0) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Add spacers if provided
|
|
106
|
+
if (spacer) {
|
|
107
|
+
var len = extractedChildren.length - 1;
|
|
108
|
+
extractedChildren = extractedChildren.reduce(function (acc, child, idx) {
|
|
109
|
+
var childrenNodes = [].concat(_toConsumableArray(acc), [child]);
|
|
110
|
+
if (idx !== len) {
|
|
111
|
+
childrenNodes.push( /*#__PURE__*/React.createElement("span", {
|
|
112
|
+
key: "spacer-".concat(idx),
|
|
113
|
+
style: _objectSpread(_objectSpread({}, itemStyle), direction === 'vertical' ? {
|
|
114
|
+
width: '100%'
|
|
115
|
+
} : {})
|
|
116
|
+
}, /*#__PURE__*/React.isValidElement(spacer) ? spacer : String(spacer)));
|
|
117
|
+
}
|
|
118
|
+
return childrenNodes;
|
|
119
|
+
}, []);
|
|
120
|
+
}
|
|
121
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
122
|
+
ref: ref,
|
|
123
|
+
className: classNames(classes, className),
|
|
124
|
+
style: _objectSpread(_objectSpread({}, containerStyle), style)
|
|
125
|
+
}, extractedChildren);
|
|
126
|
+
}));
|
|
127
|
+
Space.displayName = 'ElSpace';
|
|
128
|
+
export default Space;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { useClassNames } from "../hooks";
|
|
3
|
+
var SpaceItem = function SpaceItem(props) {
|
|
4
|
+
var ns = useClassNames('space');
|
|
5
|
+
var classes = useMemo(function () {
|
|
6
|
+
return "".concat(props.prefixCls || ns.b(), "__item");
|
|
7
|
+
}, [props.prefixCls, ns]);
|
|
8
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
9
|
+
className: classes,
|
|
10
|
+
style: props.style
|
|
11
|
+
}, props.children);
|
|
12
|
+
};
|
|
13
|
+
SpaceItem.displayName = 'ElSpaceItem';
|
|
14
|
+
export default SpaceItem;
|