@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
|
@@ -2,10 +2,10 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
2
2
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
3
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
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 _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
5
6
|
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
7
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
8
|
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 _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
9
9
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
10
|
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."); }
|
|
11
11
|
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,9 +15,10 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
15
15
|
import classNames from 'classnames';
|
|
16
16
|
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
17
17
|
import { createPortal } from 'react-dom';
|
|
18
|
+
import Icon from "../Icon/Icon";
|
|
18
19
|
import Transition from "../Transition/Transition";
|
|
19
20
|
import { PopupManager, mergeDefaultProps } from "../Util";
|
|
20
|
-
import { EVENT_CODE,
|
|
21
|
+
import { EVENT_CODE, TypeComponentsMap } from "../config/Constants";
|
|
21
22
|
import { useClassNames } from "../hooks";
|
|
22
23
|
var Notification = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
23
24
|
props = mergeDefaultProps({
|
|
@@ -48,6 +49,7 @@ var Notification = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
48
49
|
afterLeave = _props.afterLeave;
|
|
49
50
|
var _useClassNames = useClassNames(classPrefix),
|
|
50
51
|
b = _useClassNames.b,
|
|
52
|
+
m = _useClassNames.m,
|
|
51
53
|
e = _useClassNames.e;
|
|
52
54
|
var _useState = useState(false),
|
|
53
55
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -61,7 +63,12 @@ var Notification = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
61
63
|
var timer = useRef(null);
|
|
62
64
|
var notificationRef = useRef(null);
|
|
63
65
|
var contentRef = useRef(null);
|
|
64
|
-
var
|
|
66
|
+
var horizontalProperty = useMemo(function () {
|
|
67
|
+
return position.endsWith('right') ? 'right' : 'left';
|
|
68
|
+
}, [position]);
|
|
69
|
+
var verticalProperty = useMemo(function () {
|
|
70
|
+
return position.startsWith('top') ? 'top' : 'bottom';
|
|
71
|
+
}, [position]);
|
|
65
72
|
var handleClose = useCallback(function () {
|
|
66
73
|
setVisible(false);
|
|
67
74
|
onClose === null || onClose === void 0 || onClose();
|
|
@@ -124,20 +131,20 @@ var Notification = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
124
131
|
}
|
|
125
132
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
126
133
|
}, [visible]);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
var _type = !iconClass && type;
|
|
131
|
-
return _type && TypeMap[_type] ? b("icon-".concat(TypeMap[_type]), false) : '';
|
|
132
|
-
}, [b, iconClass, type]);
|
|
134
|
+
var positionStyle = useMemo(function () {
|
|
135
|
+
return _defineProperty(_defineProperty({}, verticalProperty, "".concat(offset, "px")), "zIndex", PopupManager.nextZIndex());
|
|
136
|
+
}, [offset, verticalProperty]);
|
|
133
137
|
|
|
134
138
|
/** 关闭图标 */
|
|
139
|
+
// const closeIcon = useMemo(() => showClose && <div className={classNames(e`closeBtn`, b('icon-close', false))} onClick={handleClose} />, [showClose, e, b, handleClose]);
|
|
135
140
|
var closeIcon = useMemo(function () {
|
|
136
|
-
return showClose && /*#__PURE__*/React.createElement(
|
|
137
|
-
|
|
141
|
+
return showClose && /*#__PURE__*/React.createElement(Icon, {
|
|
142
|
+
name: "xmark",
|
|
143
|
+
prefix: "fal",
|
|
144
|
+
className: classNames(e(_templateObject || (_templateObject = _taggedTemplateLiteral(["closeBtn"])))),
|
|
138
145
|
onClick: handleClose
|
|
139
146
|
});
|
|
140
|
-
}, [showClose, e,
|
|
147
|
+
}, [showClose, e, handleClose]);
|
|
141
148
|
return /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(Transition, {
|
|
142
149
|
nodeRef: notificationRef,
|
|
143
150
|
name: b('notification-fade', false),
|
|
@@ -146,19 +153,19 @@ var Notification = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
146
153
|
afterLeave: afterLeave
|
|
147
154
|
}, /*#__PURE__*/React.createElement("div", {
|
|
148
155
|
ref: notificationRef,
|
|
149
|
-
className: classNames(b(),
|
|
150
|
-
style: _objectSpread(
|
|
156
|
+
className: classNames(b(), horizontalProperty, props.className),
|
|
157
|
+
style: _objectSpread(_objectSpread({}, props.style), positionStyle)
|
|
151
158
|
// 鼠标悬浮停止自动关闭
|
|
152
159
|
,
|
|
153
160
|
onMouseEnter: clearTimer,
|
|
154
161
|
onMouseLeave: startTimer,
|
|
155
162
|
onClick: props.onClick
|
|
156
|
-
}, (type || iconClass) && /*#__PURE__*/React.createElement(
|
|
157
|
-
|
|
163
|
+
}, (type || iconClass) && /*#__PURE__*/React.createElement(Icon, {
|
|
164
|
+
name: TypeComponentsMap[type],
|
|
165
|
+
prefix: "fas",
|
|
166
|
+
className: classNames(e(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["icon"]))), _defineProperty({}, m(type), type && TypeComponentsMap[type]), iconClass)
|
|
158
167
|
}), /*#__PURE__*/React.createElement("div", {
|
|
159
|
-
className: classNames(e(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["group"])))
|
|
160
|
-
'is-with-icon': typeClass || iconClass
|
|
161
|
-
})
|
|
168
|
+
className: classNames(e(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["group"]))))
|
|
162
169
|
}, /*#__PURE__*/React.createElement("h2", {
|
|
163
170
|
className: e(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["title"])))
|
|
164
171
|
}, title), /*#__PURE__*/React.createElement("div", {
|
package/dist/Select/Option.js
CHANGED
|
@@ -14,7 +14,9 @@ var Option = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
14
14
|
hoverValue = _useContext.hover,
|
|
15
15
|
setHover = _useContext.setHover,
|
|
16
16
|
multiple = _useContext.multiple;
|
|
17
|
-
var
|
|
17
|
+
var value = props.value,
|
|
18
|
+
label = props.label,
|
|
19
|
+
data = props.data,
|
|
18
20
|
disabled = props.disabled,
|
|
19
21
|
onClick = props.onClick;
|
|
20
22
|
|
|
@@ -22,31 +24,45 @@ var Option = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
22
24
|
var handleOnClick = useCallback(function (event) {
|
|
23
25
|
event.stopPropagation();
|
|
24
26
|
if (!disabled) {
|
|
25
|
-
onChoose(
|
|
26
|
-
|
|
27
|
+
onChoose(value, {
|
|
28
|
+
value: value,
|
|
29
|
+
label: label,
|
|
30
|
+
data: data
|
|
31
|
+
}, event);
|
|
32
|
+
onClick === null || onClick === void 0 || onClick(value, {
|
|
33
|
+
value: value,
|
|
34
|
+
label: label,
|
|
35
|
+
data: data
|
|
36
|
+
});
|
|
27
37
|
}
|
|
28
|
-
}, [disabled, onChoose,
|
|
38
|
+
}, [disabled, onChoose, value, label, data, onClick]);
|
|
29
39
|
|
|
30
40
|
/** 是否已选中 */
|
|
31
41
|
var selected = useMemo(function () {
|
|
32
42
|
if (multiple && selectedValue instanceof Array) {
|
|
33
|
-
return selectedValue.includes(
|
|
43
|
+
return selectedValue.includes(value);
|
|
34
44
|
}
|
|
35
|
-
return
|
|
36
|
-
}, [multiple,
|
|
45
|
+
return value === selectedValue;
|
|
46
|
+
}, [multiple, value, selectedValue]);
|
|
47
|
+
|
|
48
|
+
// useEffect(() => {
|
|
49
|
+
// onOptionCreate?.(value, { value, label, data });
|
|
50
|
+
// return () => {
|
|
51
|
+
// onOptionDestroy?.(value);
|
|
52
|
+
// };
|
|
53
|
+
// }, []);
|
|
54
|
+
|
|
37
55
|
return /*#__PURE__*/React.createElement("li", {
|
|
38
56
|
className: classNames(e(_templateObject || (_templateObject = _taggedTemplateLiteral(["item"]))), is({
|
|
39
|
-
disabled: disabled
|
|
40
|
-
}), {
|
|
57
|
+
disabled: disabled,
|
|
41
58
|
selected: selected,
|
|
42
|
-
|
|
43
|
-
}, props.className),
|
|
59
|
+
hovering: value === hoverValue
|
|
60
|
+
}), props.className),
|
|
44
61
|
style: props.style,
|
|
45
|
-
title: label,
|
|
46
|
-
key: props.value,
|
|
62
|
+
title: label + '',
|
|
47
63
|
onClick: handleOnClick,
|
|
48
64
|
onMouseEnter: function onMouseEnter() {
|
|
49
|
-
return setHover(
|
|
65
|
+
return setHover(value);
|
|
50
66
|
},
|
|
51
67
|
onMouseLeave: function onMouseLeave() {
|
|
52
68
|
return setHover(selectedValue);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import { ValueType } from './typings';
|
|
3
|
-
interface SelectContextProps {
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { OptionData, OptionValue, ValueType } from './typings';
|
|
3
|
+
export interface SelectContextProps {
|
|
4
4
|
value: ValueType;
|
|
5
5
|
hover: ValueType;
|
|
6
6
|
setHover: (value: ValueType) => void;
|
|
7
|
-
onChoose: (value:
|
|
7
|
+
onChoose: (value: OptionValue, data: OptionData, e: any) => void;
|
|
8
8
|
multiple: boolean;
|
|
9
|
+
cachedOptions: RefObject<Map<OptionValue, OptionData>>;
|
|
9
10
|
}
|
|
10
11
|
export declare const SelectContext: import("react").Context<SelectContextProps>;
|
|
11
|
-
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { SelectProps, SelectRef
|
|
3
|
-
declare const SelectCore: React.ForwardRefExoticComponent<SelectProps<ValueType> & React.RefAttributes<SelectRef>>;
|
|
2
|
+
import { SelectProps, SelectRef } from './typings';
|
|
3
|
+
declare const SelectCore: React.ForwardRefExoticComponent<SelectProps<import("./typings").ValueType> & React.RefAttributes<SelectRef>>;
|
|
4
4
|
export default SelectCore;
|