@kdcloudjs/kdesign 1.3.2 → 1.3.5
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/CHANGELOG.md +43 -1
- package/dist/kdesign-complete.less +176 -107
- package/dist/kdesign.css +161 -77
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +3776 -2037
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +3 -3
- package/dist/kdesign.min.js +8 -8
- package/dist/kdesign.min.js.map +1 -1
- package/es/_utils/usePopper.d.ts +1 -0
- package/es/_utils/usePopper.js +29 -25
- package/es/anchor/anchor.js +20 -1
- package/es/base-data/style/index.css +1 -0
- package/es/base-data/style/index.less +1 -0
- package/es/button/group.js +2 -1
- package/es/button/style/index.css +20 -19
- package/es/button/style/index.less +29 -27
- package/es/button/style/token.less +4 -4
- package/es/checkbox/checkbox.js +20 -12
- package/es/config-provider/compDefaultProps.d.ts +0 -1
- package/es/config-provider/compDefaultProps.js +1 -2
- package/es/form/Field.js +7 -6
- package/es/form/Form.d.ts +1 -0
- package/es/form/Form.js +3 -1
- package/es/form/interface.d.ts +1 -0
- package/es/menu/menu.d.ts +1 -1
- package/es/menu/menu.js +55 -22
- package/es/menu/menuItem.d.ts +1 -0
- package/es/menu/menuItem.js +14 -10
- package/es/menu/style/index.css +139 -53
- package/es/menu/style/index.less +101 -69
- package/es/menu/style/mixin.less +33 -1
- package/es/menu/style/token.less +4 -2
- package/es/menu/subMenu.d.ts +1 -1
- package/es/menu/subMenu.js +126 -119
- package/es/radio/radio.d.ts +1 -1
- package/es/radio/radio.js +18 -11
- package/es/select/select.js +33 -20
- package/es/style/core/reset.less +4 -4
- package/es/style/index.css +0 -4
- package/es/table/feature/useRangeSelection.d.ts +3 -0
- package/es/table/feature/useRangeSelection.js +10 -0
- package/es/table/interface.d.ts +15 -2
- package/es/table/table.js +14 -7
- package/lib/_utils/usePopper.d.ts +1 -0
- package/lib/_utils/usePopper.js +29 -25
- package/lib/anchor/anchor.js +20 -1
- package/lib/base-data/style/index.css +1 -0
- package/lib/base-data/style/index.less +1 -0
- package/lib/button/group.js +2 -1
- package/lib/button/style/index.css +20 -19
- package/lib/button/style/index.less +29 -27
- package/lib/button/style/token.less +4 -4
- package/lib/checkbox/checkbox.js +19 -11
- package/lib/config-provider/compDefaultProps.d.ts +0 -1
- package/lib/config-provider/compDefaultProps.js +1 -2
- package/lib/form/Field.js +7 -6
- package/lib/form/Form.d.ts +1 -0
- package/lib/form/Form.js +3 -1
- package/lib/form/interface.d.ts +1 -0
- package/lib/menu/menu.d.ts +1 -1
- package/lib/menu/menu.js +61 -26
- package/lib/menu/menuItem.d.ts +1 -0
- package/lib/menu/menuItem.js +16 -10
- package/lib/menu/style/index.css +139 -53
- package/lib/menu/style/index.less +101 -69
- package/lib/menu/style/mixin.less +33 -1
- package/lib/menu/style/token.less +4 -2
- package/lib/menu/subMenu.d.ts +1 -1
- package/lib/menu/subMenu.js +145 -142
- package/lib/radio/radio.d.ts +1 -1
- package/lib/radio/radio.js +30 -20
- package/lib/select/select.js +33 -20
- package/lib/style/core/reset.less +4 -4
- package/lib/style/index.css +0 -4
- package/lib/table/feature/useRangeSelection.d.ts +3 -0
- package/lib/table/feature/useRangeSelection.js +21 -0
- package/lib/table/interface.d.ts +15 -2
- package/lib/table/table.js +15 -7
- package/package.json +2 -2
package/es/menu/subMenu.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
2
2
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
3
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
4
3
|
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
5
4
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
6
5
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
@@ -19,18 +18,20 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
19
18
|
return t;
|
|
20
19
|
};
|
|
21
20
|
|
|
22
|
-
import
|
|
21
|
+
import React from 'react';
|
|
23
22
|
import { ConfigContext } from '../config-provider';
|
|
24
23
|
import { getCompProps } from '../_utils';
|
|
25
24
|
import { toArray } from '../_utils/react-children';
|
|
26
25
|
import classNames from 'classnames';
|
|
27
|
-
import { isString,
|
|
26
|
+
import { isString, getItemWidth, renderReactNodeFunction, isElementInViewport, DEFAUTL_PADDING } from './util';
|
|
28
27
|
import { useOnClickOutside } from '../_utils/hooks';
|
|
29
28
|
import { Icon } from '../index';
|
|
29
|
+
import usePopper from '../_utils/usePopper';
|
|
30
30
|
import devWarning from '../_utils/devwarning';
|
|
31
|
+
import { MENU_ITEM_CONTAINER_NAME } from './menuItem';
|
|
31
32
|
|
|
32
33
|
var SubMenu = function SubMenu(props) {
|
|
33
|
-
var _classNames2;
|
|
34
|
+
var _classNames2, _classNames3, _context4;
|
|
34
35
|
|
|
35
36
|
var _React$useContext = React.useContext(ConfigContext),
|
|
36
37
|
getPrefixCls = _React$useContext.getPrefixCls,
|
|
@@ -40,6 +41,7 @@ var SubMenu = function SubMenu(props) {
|
|
|
40
41
|
|
|
41
42
|
var _a = getCompProps('MenuSubMenu', userDefaultProps, props),
|
|
42
43
|
customPrefixcls = _a.prefixCls,
|
|
44
|
+
theme = _a.theme,
|
|
43
45
|
mode = _a.mode,
|
|
44
46
|
title = _a.title,
|
|
45
47
|
icon = _a.icon,
|
|
@@ -57,8 +59,9 @@ var SubMenu = function SubMenu(props) {
|
|
|
57
59
|
handleOnOpenChange = _a.handleOnOpenChange,
|
|
58
60
|
_a$paddingLeft = _a.paddingLeft,
|
|
59
61
|
paddingLeft = _a$paddingLeft === void 0 ? 0 : _a$paddingLeft,
|
|
60
|
-
restProps = __rest(_a, ["prefixCls", "mode", "title", "icon", "disabled", "children", "collapsed", "keyValue", "selectedKey", "openKeys", "triggerSubMenuAction", "forceSubMenuRender", "inlineIndent", "className", "style", "handleOnOpenChange", "paddingLeft"]);
|
|
62
|
+
restProps = __rest(_a, ["prefixCls", "theme", "mode", "title", "icon", "disabled", "children", "collapsed", "keyValue", "selectedKey", "openKeys", "triggerSubMenuAction", "forceSubMenuRender", "inlineIndent", "className", "style", "handleOnOpenChange", "paddingLeft"]);
|
|
61
63
|
|
|
64
|
+
var isVertical = mode === 'vertical'; // 初始化level
|
|
62
65
|
|
|
63
66
|
if (!restProps.level) {
|
|
64
67
|
restProps.level = 1;
|
|
@@ -74,19 +77,13 @@ var SubMenu = function SubMenu(props) {
|
|
|
74
77
|
var prefixCls = getPrefixCls(pkgPrefixCls, 'menu-submenu', customPrefixcls);
|
|
75
78
|
var subMenuRef = React.useRef(null);
|
|
76
79
|
var subMenuWrapperRef = React.useRef(null);
|
|
80
|
+
var subMenuVerticalRef = React.useRef(null);
|
|
81
|
+
var subMenuWrapperVerticalRef = React.useRef(null);
|
|
77
82
|
|
|
78
|
-
var
|
|
79
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
80
|
-
isVisible = _React$useState2[0],
|
|
81
|
-
setIsVisible = _React$useState2[1];
|
|
83
|
+
var visible = Array.isArray(openKeys) && _includesInstanceProperty(openKeys).call(openKeys, keyValue);
|
|
82
84
|
|
|
83
85
|
React.useEffect(function () {
|
|
84
|
-
if (
|
|
85
|
-
setIsVisible(_includesInstanceProperty(openKeys).call(openKeys, keyValue));
|
|
86
|
-
}
|
|
87
|
-
}, [keyValue]);
|
|
88
|
-
React.useEffect(function () {
|
|
89
|
-
if (!isVisible) return;
|
|
86
|
+
if (!visible || isVertical) return;
|
|
90
87
|
var subMenuWrapperEle = subMenuWrapperRef.current;
|
|
91
88
|
var subMenuEle = subMenuRef.current;
|
|
92
89
|
|
|
@@ -134,15 +131,15 @@ var SubMenu = function SubMenu(props) {
|
|
|
134
131
|
if (mode === 'inline') {
|
|
135
132
|
var height = ((_a = subMenuWrapperRef.current) === null || _a === void 0 ? void 0 : _a.scrollHeight) || 0;
|
|
136
133
|
return {
|
|
137
|
-
height:
|
|
134
|
+
height: visible && !collapsed ? "".concat(height, "px") : '0px',
|
|
138
135
|
overflow: 'hidden',
|
|
139
|
-
opacity:
|
|
136
|
+
opacity: visible && !collapsed ? 1 : 0,
|
|
140
137
|
transition: 'all 0.2s cubic-bezier(0,.4,.4,1)'
|
|
141
138
|
};
|
|
142
139
|
}
|
|
143
140
|
|
|
144
141
|
var style = {
|
|
145
|
-
visibility: forceSubMenuRender && !
|
|
142
|
+
visibility: forceSubMenuRender && !visible ? 'visible' : 'hidden'
|
|
146
143
|
};
|
|
147
144
|
|
|
148
145
|
if (restProps.subMenuMode === 'horizontal') {
|
|
@@ -171,28 +168,34 @@ var SubMenu = function SubMenu(props) {
|
|
|
171
168
|
paddingLeft: "".concat(popupOffsetPosition[0], "px"),
|
|
172
169
|
paddingTop: "".concat(popupOffsetPosition[1], "px")
|
|
173
170
|
});
|
|
174
|
-
}, [subMenuRef, restProps.popupOffset, forceSubMenuRender,
|
|
171
|
+
}, [subMenuRef, restProps.popupOffset, forceSubMenuRender, visible, mode, restProps.subMenuMode]);
|
|
172
|
+
|
|
173
|
+
var handleVisibleChange = function handleVisibleChange(status) {
|
|
174
|
+
var clean = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
175
|
+
handleOnOpenChange(keyValue, status, clean);
|
|
176
|
+
};
|
|
175
177
|
|
|
176
178
|
var closeSubMenu = function closeSubMenu() {
|
|
177
|
-
|
|
178
|
-
handleOnOpenChange(keyValue);
|
|
179
|
+
handleVisibleChange(false, true);
|
|
179
180
|
}; // 点击区域外的地方关闭
|
|
180
181
|
|
|
181
182
|
|
|
182
|
-
useOnClickOutside([
|
|
183
|
-
|
|
183
|
+
useOnClickOutside([subMenuVerticalRef, subMenuWrapperVerticalRef], function (e) {
|
|
184
|
+
var _a;
|
|
185
|
+
|
|
186
|
+
var className = ((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.className) || '';
|
|
187
|
+
|
|
188
|
+
if (!_includesInstanceProperty(className).call(className, MENU_ITEM_CONTAINER_NAME)) {
|
|
184
189
|
closeSubMenu();
|
|
185
190
|
}
|
|
186
|
-
}); // 缩略模式自动关闭子菜单
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
+
}); // // 缩略模式自动关闭子菜单
|
|
192
|
+
// if (triggerSubMenuAction === 'click' && mode === 'vertical' && collapsed) {
|
|
193
|
+
// closeSubMenu()
|
|
194
|
+
// }
|
|
191
195
|
|
|
192
196
|
var handleMouseEvent = function handleMouseEvent(status) {
|
|
193
197
|
if (disabled || triggerSubMenuAction === 'click') return;
|
|
194
|
-
|
|
195
|
-
setIsVisible(status);
|
|
198
|
+
handleVisibleChange(status);
|
|
196
199
|
};
|
|
197
200
|
|
|
198
201
|
var handleOnMouseEnter = function handleOnMouseEnter() {
|
|
@@ -209,7 +212,7 @@ var SubMenu = function SubMenu(props) {
|
|
|
209
212
|
// 保存路径
|
|
210
213
|
info.keyPath = _concatInstanceProperty(_context = info.keyPath).call(_context, [keyValue]);
|
|
211
214
|
|
|
212
|
-
if (triggerSubMenuAction === 'click' &&
|
|
215
|
+
if (triggerSubMenuAction === 'click' && isVertical) {
|
|
213
216
|
closeSubMenu();
|
|
214
217
|
}
|
|
215
218
|
|
|
@@ -217,11 +220,9 @@ var SubMenu = function SubMenu(props) {
|
|
|
217
220
|
}; // 子菜单展开收缩
|
|
218
221
|
|
|
219
222
|
|
|
220
|
-
var handleOnClickSubMenu = function handleOnClickSubMenu(
|
|
223
|
+
var handleOnClickSubMenu = function handleOnClickSubMenu() {
|
|
221
224
|
if (disabled || triggerSubMenuAction === 'hover') return;
|
|
222
|
-
|
|
223
|
-
handleOnOpenChange(keyValue);
|
|
224
|
-
setIsVisible(!isVisible);
|
|
225
|
+
handleVisibleChange(!visible);
|
|
225
226
|
};
|
|
226
227
|
|
|
227
228
|
var renderItemTitle = function renderItemTitle() {
|
|
@@ -242,86 +243,12 @@ var SubMenu = function SubMenu(props) {
|
|
|
242
243
|
if (mode !== 'inline' || collapsed) return null;
|
|
243
244
|
return /*#__PURE__*/React.createElement(Icon, {
|
|
244
245
|
type: "arrow-down",
|
|
245
|
-
className: classNames("".concat(prefixCls, "-arrow"), _defineProperty({}, _concatInstanceProperty(_context2 = "".concat(prefixCls, "-arrow-")).call(_context2,
|
|
246
|
+
className: classNames("".concat(prefixCls, "-arrow"), _defineProperty({}, _concatInstanceProperty(_context2 = "".concat(prefixCls, "-arrow-")).call(_context2, visible ? 'up' : 'down'), true))
|
|
246
247
|
});
|
|
247
248
|
};
|
|
248
249
|
|
|
249
|
-
var renderSubMenu = function renderSubMenu() {
|
|
250
|
-
var _context3;
|
|
251
|
-
|
|
252
|
-
var style = getCurrentStyle(); // 展开收缩动画。针对二级三级菜单目前使用单一的样式去区分了
|
|
253
|
-
|
|
254
|
-
var motionClassName = {};
|
|
255
|
-
|
|
256
|
-
if (mode !== 'inline') {
|
|
257
|
-
var prefixClsMotion = "".concat(prefixCls, "-sub");
|
|
258
|
-
|
|
259
|
-
if (isVisible) {
|
|
260
|
-
motionClassName["".concat(prefixClsMotion, "-second")] = restProps.level === 1;
|
|
261
|
-
motionClassName["".concat(prefixClsMotion, "-third")] = restProps.level === 2;
|
|
262
|
-
} else {
|
|
263
|
-
motionClassName["".concat(prefixClsMotion, "-hide")] = true;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
268
|
-
style: style,
|
|
269
|
-
ref: subMenuWrapperRef
|
|
270
|
-
}, /*#__PURE__*/React.createElement("ul", {
|
|
271
|
-
className: classNames("".concat(prefixCls, "-sub"), restProps.popupClassName, motionClassName)
|
|
272
|
-
}, _mapInstanceProperty(_context3 = toArray(children)).call(_context3, function (item, index) {
|
|
273
|
-
var key = item.key || index;
|
|
274
|
-
return /*#__PURE__*/React.cloneElement(item, {
|
|
275
|
-
key: key,
|
|
276
|
-
level: restProps.level + 1,
|
|
277
|
-
keyValue: key,
|
|
278
|
-
collapsed: collapsed,
|
|
279
|
-
mode: mode,
|
|
280
|
-
selectedKey: selectedKey,
|
|
281
|
-
openKeys: openKeys,
|
|
282
|
-
forceSubMenuRender: forceSubMenuRender,
|
|
283
|
-
triggerSubMenuAction: triggerSubMenuAction,
|
|
284
|
-
handleOnOpenChange: handleOnOpenChange,
|
|
285
|
-
handleOnClick: handleOnClick,
|
|
286
|
-
inlineIndent: inlineIndent,
|
|
287
|
-
paddingLeft: curPaddingLeft
|
|
288
|
-
});
|
|
289
|
-
})));
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
var renderThridMenu = function renderThridMenu() {
|
|
293
|
-
var _context4;
|
|
294
|
-
|
|
295
|
-
var style = getCurrentStyle();
|
|
296
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
297
|
-
style: style
|
|
298
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
299
|
-
className: classNames("".concat(prefixCls, "-thrid")),
|
|
300
|
-
onClick: function onClick(e) {
|
|
301
|
-
e.stopPropagation();
|
|
302
|
-
},
|
|
303
|
-
style: {
|
|
304
|
-
width: getWrapWidth(children)
|
|
305
|
-
}
|
|
306
|
-
}, _mapInstanceProperty(_context4 = toArray(children)).call(_context4, function (item, i) {
|
|
307
|
-
return /*#__PURE__*/React.cloneElement(item, {
|
|
308
|
-
level: restProps.level + 1,
|
|
309
|
-
subMenuMode: restProps.subMenuMode,
|
|
310
|
-
keyValue: item.key || i,
|
|
311
|
-
collapsed: collapsed,
|
|
312
|
-
mode: mode,
|
|
313
|
-
selectedKey: selectedKey,
|
|
314
|
-
openKeys: openKeys,
|
|
315
|
-
forceSubMenuRender: forceSubMenuRender,
|
|
316
|
-
triggerSubMenuAction: triggerSubMenuAction,
|
|
317
|
-
handleOnOpenChange: handleOnOpenChange,
|
|
318
|
-
handleOnClick: handleOnClick
|
|
319
|
-
});
|
|
320
|
-
})));
|
|
321
|
-
};
|
|
322
|
-
|
|
323
250
|
if (restProps.subMenuMode === 'horizontal' && restProps.level > 1 && children) {
|
|
324
|
-
var
|
|
251
|
+
var _context3;
|
|
325
252
|
|
|
326
253
|
var width = getItemWidth(children);
|
|
327
254
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -333,7 +260,7 @@ var SubMenu = function SubMenu(props) {
|
|
|
333
260
|
className: classNames("".concat(prefixCls, "-thrid-title"))
|
|
334
261
|
}, /*#__PURE__*/React.createElement("span", null, title)), /*#__PURE__*/React.createElement("ul", {
|
|
335
262
|
className: classNames("".concat(prefixCls, "-thrid-list"), restProps.popupClassName)
|
|
336
|
-
}, _mapInstanceProperty(
|
|
263
|
+
}, _mapInstanceProperty(_context3 = toArray(children)).call(_context3, function (item, i) {
|
|
337
264
|
return /*#__PURE__*/React.cloneElement(item, {
|
|
338
265
|
level: restProps.level + 1,
|
|
339
266
|
subMenuMode: restProps.subMenuMode,
|
|
@@ -358,19 +285,99 @@ var SubMenu = function SubMenu(props) {
|
|
|
358
285
|
var titleStyle = {
|
|
359
286
|
paddingRight: "".concat(curPaddingRight, "px"),
|
|
360
287
|
paddingLeft: "".concat(curPaddingLeft, "px")
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
className: classNames(prefixCls, className, (_classNames2 = {}, _defineProperty(_classNames2, "".concat(prefixCls, "-collapsed"), collapsed), _defineProperty(_classNames2, "".concat(prefixCls, "-disabled"), disabled), _defineProperty(_classNames2, "".concat(prefixCls, "-hover"), !disabled &&
|
|
288
|
+
}; // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
289
|
+
|
|
290
|
+
var verticalView = usePopper( /*#__PURE__*/React.createElement("li", _extends({
|
|
291
|
+
className: classNames(prefixCls, className, (_classNames2 = {}, _defineProperty(_classNames2, "light", theme === 'light'), _defineProperty(_classNames2, "".concat(prefixCls, "-collapsed"), collapsed), _defineProperty(_classNames2, "".concat(prefixCls, "-disabled"), disabled), _defineProperty(_classNames2, "".concat(prefixCls, "-hover"), !disabled && visible), _defineProperty(_classNames2, "".concat(prefixCls, "-active"), Array.isArray(openKeys) && _includesInstanceProperty(openKeys).call(openKeys, keyValue)), _classNames2)),
|
|
292
|
+
ref: subMenuVerticalRef,
|
|
365
293
|
key: keyValue
|
|
366
|
-
},
|
|
367
|
-
|
|
294
|
+
}, {
|
|
295
|
+
onMouseLeave: handleOnMouseLeave,
|
|
296
|
+
onMouseEnter: handleOnMouseEnter,
|
|
297
|
+
onClick: handleOnClickSubMenu
|
|
368
298
|
}), /*#__PURE__*/React.createElement("div", {
|
|
369
299
|
className: classNames("".concat(prefixCls, "-title")),
|
|
370
300
|
style: titleStyle
|
|
371
301
|
}, icon && /*#__PURE__*/React.cloneElement(renderReactNodeFunction(icon), {
|
|
372
302
|
className: classNames("".concat(prefixCls, "-icon"))
|
|
373
|
-
}), renderItemTitle(), renderItemArrow()),
|
|
303
|
+
}), renderItemTitle(), renderItemArrow())), /*#__PURE__*/React.createElement("div", {
|
|
304
|
+
ref: subMenuWrapperVerticalRef,
|
|
305
|
+
onMouseLeave: function onMouseLeave() {
|
|
306
|
+
handleOnMouseLeave();
|
|
307
|
+
},
|
|
308
|
+
onMouseEnter: function onMouseEnter() {
|
|
309
|
+
handleOnMouseEnter();
|
|
310
|
+
}
|
|
311
|
+
}, /*#__PURE__*/React.createElement("ul", {
|
|
312
|
+
className: classNames("".concat(prefixCls, "-sub"), restProps.popupClassName, (_classNames3 = {}, _defineProperty(_classNames3, "".concat(prefixCls, "-sub-second"), restProps.level === 1), _defineProperty(_classNames3, "".concat(prefixCls, "-sub-third"), restProps.level === 2), _classNames3))
|
|
313
|
+
}, _mapInstanceProperty(_context4 = toArray(children)).call(_context4, function (item, index) {
|
|
314
|
+
var key = item.key || index;
|
|
315
|
+
return /*#__PURE__*/React.cloneElement(item, {
|
|
316
|
+
key: key,
|
|
317
|
+
level: restProps.level + 1,
|
|
318
|
+
keyValue: key,
|
|
319
|
+
collapsed: collapsed,
|
|
320
|
+
mode: mode,
|
|
321
|
+
theme: theme,
|
|
322
|
+
selectedKey: selectedKey,
|
|
323
|
+
openKeys: openKeys,
|
|
324
|
+
forceSubMenuRender: forceSubMenuRender,
|
|
325
|
+
triggerSubMenuAction: triggerSubMenuAction,
|
|
326
|
+
handleOnOpenChange: handleOnOpenChange,
|
|
327
|
+
handleOnClick: handleOnClick,
|
|
328
|
+
inlineIndent: inlineIndent,
|
|
329
|
+
paddingLeft: curPaddingLeft
|
|
330
|
+
});
|
|
331
|
+
}))), {
|
|
332
|
+
arrow: false,
|
|
333
|
+
placement: 'rightTop',
|
|
334
|
+
gap: 0,
|
|
335
|
+
visible: isVertical ? visible : false,
|
|
336
|
+
disabled: isVertical ? undefined : true,
|
|
337
|
+
prefixCls: 'kd-menu-popper',
|
|
338
|
+
popperClassName: theme === 'light' ? 'light' : ''
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
if (isVertical) {
|
|
342
|
+
return verticalView;
|
|
343
|
+
} else {
|
|
344
|
+
var _classNames4, _context5;
|
|
345
|
+
|
|
346
|
+
return /*#__PURE__*/React.createElement("li", _extends({
|
|
347
|
+
ref: subMenuRef,
|
|
348
|
+
className: classNames(prefixCls, className, (_classNames4 = {}, _defineProperty(_classNames4, "".concat(prefixCls, "-collapsed"), collapsed), _defineProperty(_classNames4, "".concat(prefixCls, "-disabled"), disabled), _classNames4)),
|
|
349
|
+
key: keyValue
|
|
350
|
+
}, mouseEvent, {
|
|
351
|
+
style: style
|
|
352
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
353
|
+
className: classNames("".concat(prefixCls, "-title")),
|
|
354
|
+
style: titleStyle
|
|
355
|
+
}, icon && /*#__PURE__*/React.cloneElement(renderReactNodeFunction(icon), {
|
|
356
|
+
className: classNames("".concat(prefixCls, "-icon"))
|
|
357
|
+
}), renderItemTitle(), renderItemArrow()), /*#__PURE__*/React.createElement("div", {
|
|
358
|
+
style: getCurrentStyle(),
|
|
359
|
+
ref: subMenuWrapperRef
|
|
360
|
+
}, /*#__PURE__*/React.createElement("ul", {
|
|
361
|
+
className: classNames("".concat(prefixCls, "-sub"), restProps.popupClassName)
|
|
362
|
+
}, _mapInstanceProperty(_context5 = toArray(children)).call(_context5, function (item, index) {
|
|
363
|
+
var key = item.key || index;
|
|
364
|
+
return /*#__PURE__*/React.cloneElement(item, {
|
|
365
|
+
key: key,
|
|
366
|
+
level: restProps.level + 1,
|
|
367
|
+
keyValue: key,
|
|
368
|
+
collapsed: collapsed,
|
|
369
|
+
mode: mode,
|
|
370
|
+
selectedKey: selectedKey,
|
|
371
|
+
openKeys: openKeys,
|
|
372
|
+
forceSubMenuRender: forceSubMenuRender,
|
|
373
|
+
triggerSubMenuAction: triggerSubMenuAction,
|
|
374
|
+
handleOnOpenChange: handleOnOpenChange,
|
|
375
|
+
handleOnClick: handleOnClick,
|
|
376
|
+
inlineIndent: inlineIndent,
|
|
377
|
+
paddingLeft: curPaddingLeft
|
|
378
|
+
});
|
|
379
|
+
}))));
|
|
380
|
+
}
|
|
374
381
|
};
|
|
375
382
|
|
|
376
383
|
SubMenu.displayName = 'SubMenu';
|
package/es/radio/radio.d.ts
CHANGED
package/es/radio/radio.js
CHANGED
|
@@ -16,7 +16,7 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
16
16
|
return t;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
import
|
|
19
|
+
import React, { useEffect } from 'react';
|
|
20
20
|
import classNames from 'classnames';
|
|
21
21
|
import ConfigContext from '../config-provider/ConfigContext';
|
|
22
22
|
import { getCompProps } from '../_utils';
|
|
@@ -85,22 +85,29 @@ var InternalRadio = function InternalRadio(props, ref) {
|
|
|
85
85
|
|
|
86
86
|
var classString = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(radioPrefixCls), true), _defineProperty(_classNames, "".concat(radioPrefixCls, "-disabled"), radioProps.disabled), _defineProperty(_classNames, "".concat(radioPrefixCls, "-checked"), context ? radioProps.checked : isChecked), _classNames), className); // 单选包裹元素class名称
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
useEffect(function () {
|
|
89
|
+
var handleRepeatClick = function handleRepeatClick(e) {
|
|
90
|
+
var element = e.target;
|
|
91
|
+
|
|
92
|
+
if (element.tagName !== 'INPUT') {
|
|
93
|
+
e.stopPropagation();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
var radioRef = mergedRef;
|
|
98
|
+
radioRef.current.addEventListener('click', handleRepeatClick);
|
|
99
|
+
return function () {
|
|
100
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
101
|
+
radioRef.current.removeEventListener('click', handleRepeatClick);
|
|
102
|
+
};
|
|
103
|
+
}, []);
|
|
96
104
|
return (
|
|
97
105
|
/*#__PURE__*/
|
|
98
106
|
// eslint-disable-next-line
|
|
99
107
|
React.createElement("label", {
|
|
100
108
|
className: classString,
|
|
101
109
|
style: style,
|
|
102
|
-
ref: mergedRef
|
|
103
|
-
onClick: handleRepeatClick
|
|
110
|
+
ref: mergedRef
|
|
104
111
|
}, /*#__PURE__*/React.createElement("input", _extends({
|
|
105
112
|
type: "radio",
|
|
106
113
|
className: "".concat(radioPrefixCls, "-input")
|
package/es/select/select.js
CHANGED
|
@@ -67,7 +67,6 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
67
67
|
setInitValue = _useMergedState2[1];
|
|
68
68
|
|
|
69
69
|
var realChildren = Array.isArray(options) ? options : toArray(children); // options配置项和默认children
|
|
70
|
-
// console.log('real', realChildren)
|
|
71
70
|
|
|
72
71
|
var innerRef = React.useRef();
|
|
73
72
|
var selectRef = ref || innerRef;
|
|
@@ -251,6 +250,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
251
250
|
return (child === null || child === void 0 ? void 0 : child.value) === key;
|
|
252
251
|
}
|
|
253
252
|
})) || {};
|
|
253
|
+
var optionsObj = obj.props ? obj.props : obj || {};
|
|
254
254
|
|
|
255
255
|
if (value !== undefined) {
|
|
256
256
|
// onChange && onChange(labelInValue ? { value: key, label } : key)
|
|
@@ -271,13 +271,13 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
271
271
|
_spliceInstanceProperty(optsArr).call(optsArr, idx, 1);
|
|
272
272
|
} else {
|
|
273
273
|
valArr.push(key);
|
|
274
|
-
optsArr.push({
|
|
274
|
+
optsArr.push(_extends(_extends({}, optionsObj), {
|
|
275
275
|
value: key,
|
|
276
276
|
label: obj.props ? (_a = obj.props) === null || _a === void 0 ? void 0 : _a.children : obj.label || key
|
|
277
|
-
});
|
|
277
|
+
}));
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
onChange && onChange(labelInValue ? optsArr : valArr);
|
|
280
|
+
onChange && onChange(labelInValue ? optsArr : valArr, optsArr);
|
|
281
281
|
|
|
282
282
|
if (!isSelected) {
|
|
283
283
|
onDeselect && onDeselect(key); // 下拉项取消选中时调用,参数为选中项的value,多选模式下生效
|
|
@@ -287,7 +287,10 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
287
287
|
onChange && onChange(labelInValue ? {
|
|
288
288
|
value: key,
|
|
289
289
|
label: label
|
|
290
|
-
} : key)
|
|
290
|
+
} : key, _extends(_extends({}, optionsObj), {
|
|
291
|
+
value: key,
|
|
292
|
+
label: label
|
|
293
|
+
}));
|
|
291
294
|
}
|
|
292
295
|
|
|
293
296
|
onSelect && onSelect(key);
|
|
@@ -303,7 +306,10 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
303
306
|
onChange && onChange(labelInValue ? {
|
|
304
307
|
value: key,
|
|
305
308
|
label: label
|
|
306
|
-
} : key)
|
|
309
|
+
} : key, _extends(_extends({}, optionsObj), {
|
|
310
|
+
value: key,
|
|
311
|
+
label: label
|
|
312
|
+
}));
|
|
307
313
|
} else {
|
|
308
314
|
var _multipleRef$current2 = multipleRef.current,
|
|
309
315
|
_selectedVal = _multipleRef$current2.selectedVal,
|
|
@@ -318,15 +324,15 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
318
324
|
} else {
|
|
319
325
|
_selectedVal.push(key);
|
|
320
326
|
|
|
321
|
-
_selectMulOpts.push({
|
|
327
|
+
_selectMulOpts.push(_extends(_extends({}, optionsObj), {
|
|
322
328
|
value: key,
|
|
323
329
|
label: obj.props ? (_c = obj.props) === null || _c === void 0 ? void 0 : _c.children : obj.label || key
|
|
324
|
-
});
|
|
330
|
+
}));
|
|
325
331
|
} // setInitValue([...selectedVal])
|
|
326
332
|
|
|
327
333
|
|
|
328
334
|
setMulOptions(_toConsumableArray(_selectMulOpts));
|
|
329
|
-
onChange && onChange(labelInValue ? _selectMulOpts : _selectedVal);
|
|
335
|
+
onChange && onChange(labelInValue ? _selectMulOpts : _selectedVal, _selectMulOpts);
|
|
330
336
|
|
|
331
337
|
if (!isSelected) {
|
|
332
338
|
onDeselect && onDeselect(key); // 下拉项取消选中时调用,参数为选中项的value,多选模式下生效
|
|
@@ -347,9 +353,9 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
347
353
|
|
|
348
354
|
if ((realChildren === null || realChildren === void 0 ? void 0 : realChildren.length) !== selectedVal.length) {
|
|
349
355
|
_mapInstanceProperty(realChildren).call(realChildren, function (child) {
|
|
350
|
-
var
|
|
351
|
-
value =
|
|
352
|
-
children =
|
|
356
|
+
var _ref = child.props || child,
|
|
357
|
+
value = _ref.value,
|
|
358
|
+
children = _ref.children;
|
|
353
359
|
|
|
354
360
|
if (!_includesInstanceProperty(selectedVal).call(selectedVal, value)) {
|
|
355
361
|
selectedVal.push(value);
|
|
@@ -362,12 +368,12 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
362
368
|
|
|
363
369
|
setMulOptions(_toConsumableArray(selectMulOpts));
|
|
364
370
|
} else {
|
|
365
|
-
multipleRef.current.selectedVal = [];
|
|
366
|
-
multipleRef.current.selectMulOpts = [];
|
|
371
|
+
multipleRef.current.selectedVal = selectedVal = [];
|
|
372
|
+
multipleRef.current.selectMulOpts = selectMulOpts = [];
|
|
367
373
|
setMulOptions([]);
|
|
368
374
|
}
|
|
369
375
|
|
|
370
|
-
onChange && onChange(labelInValue ? selectMulOpts : selectedVal);
|
|
376
|
+
onChange && onChange(labelInValue ? selectMulOpts : selectedVal, selectMulOpts);
|
|
371
377
|
}; // 筛选内容 ---可以优化,抽成hook
|
|
372
378
|
|
|
373
379
|
|
|
@@ -428,7 +434,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
428
434
|
_spliceInstanceProperty(selectMulOpts).call(selectMulOpts, idx, 1);
|
|
429
435
|
|
|
430
436
|
setMulOptions(_toConsumableArray(selectMulOpts));
|
|
431
|
-
onChange && onChange(labelInValue ? selectMulOpts : selectedVal);
|
|
437
|
+
onChange && onChange(labelInValue ? selectMulOpts : selectedVal, selectMulOpts);
|
|
432
438
|
e.stopPropagation();
|
|
433
439
|
}; // 渲染后缀图标
|
|
434
440
|
|
|
@@ -492,8 +498,15 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
492
498
|
return (realChildren === null || realChildren === void 0 ? void 0 : realChildren.length) === 0 && /*#__PURE__*/React.createElement("div", {
|
|
493
499
|
className: emptyListCls
|
|
494
500
|
}, emptyContent);
|
|
495
|
-
};
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
var isShowSearch = useCallback(function () {
|
|
504
|
+
if (isMultiple) {
|
|
505
|
+
return showSearch !== null && showSearch !== void 0 ? showSearch : true;
|
|
506
|
+
}
|
|
496
507
|
|
|
508
|
+
return showSearch !== null && showSearch !== void 0 ? showSearch : false;
|
|
509
|
+
}, [showSearch, isMultiple]); // 渲染下拉列表框
|
|
497
510
|
|
|
498
511
|
var renderContent = function renderContent() {
|
|
499
512
|
var _a;
|
|
@@ -530,7 +543,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
530
543
|
className: dropDownCls,
|
|
531
544
|
style: dropDownStyle,
|
|
532
545
|
ref: dropDownRef
|
|
533
|
-
}, (
|
|
546
|
+
}, isShowSearch() && /*#__PURE__*/React.createElement("div", {
|
|
534
547
|
className: searchCls
|
|
535
548
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
536
549
|
ref: searchRef,
|
|
@@ -652,8 +665,8 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
652
665
|
var _a;
|
|
653
666
|
|
|
654
667
|
if (selectRef === null || selectRef === void 0 ? void 0 : selectRef.current) {
|
|
655
|
-
var
|
|
656
|
-
width =
|
|
668
|
+
var _ref2 = (_a = selectRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(),
|
|
669
|
+
width = _ref2.width;
|
|
657
670
|
|
|
658
671
|
return {
|
|
659
672
|
width: (dropdownStyle === null || dropdownStyle === void 0 ? void 0 : dropdownStyle.width) || (width > 75 ? width : 75),
|
package/es/style/core/reset.less
CHANGED
|
@@ -194,10 +194,10 @@ template {
|
|
|
194
194
|
/**
|
|
195
195
|
* Reset scrollbar style
|
|
196
196
|
*/
|
|
197
|
-
::-webkit-scrollbar {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
197
|
+
// ::-webkit-scrollbar {
|
|
198
|
+
// width: 10px !important;
|
|
199
|
+
// height: 10px !important;
|
|
200
|
+
// }
|
|
201
201
|
|
|
202
202
|
::-webkit-scrollbar-button {
|
|
203
203
|
width: 0;
|
package/es/style/index.css
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import { features } from '@kdcloudjs/table';
|
|
3
|
+
|
|
4
|
+
function useRangeSelection(pipeline, rangeSelection) {
|
|
5
|
+
if (rangeSelection) {
|
|
6
|
+
pipeline.use(features.rangeSelection(_extends({}, rangeSelection)));
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default useRangeSelection;
|
package/es/table/interface.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { TableProps as BaseTableProps, TablePipeline as TP, ArtColumnStaticPart } from '@kdcloudjs/table';
|
|
2
|
-
import { SortFeatureOptions, RowDetailFeatureOptions, FilterFeatureOptions, TreeModeFeatureOptions, ColumnDragOptions, ColumnResizeOptions, ContextMenuFeatureOptions } from '@kdcloudjs/table/es/table/pipeline/features';
|
|
3
|
-
|
|
3
|
+
import { SortFeatureOptions, RowDetailFeatureOptions, FilterFeatureOptions, TreeModeFeatureOptions, ColumnDragOptions, ColumnResizeOptions, ContextMenuFeatureOptions, RangeSelectionFeatureOptions } from '@kdcloudjs/table/es/table/pipeline/features';
|
|
4
|
+
declare type TablePropsOfComponents = Pick<BaseTableProps, 'components'> & {
|
|
5
|
+
components?: {
|
|
6
|
+
/** 复选框 */
|
|
7
|
+
Checkbox?: React.ComponentType;
|
|
8
|
+
/** 单选框 */
|
|
9
|
+
Radio?: React.ComponentType;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
declare type TablePropsOfExtend = Omit<BaseTableProps, 'components'>;
|
|
13
|
+
export interface TableProps extends TablePropsOfExtend, TablePropsOfComponents {
|
|
4
14
|
rowSelection?: TableRowSelection;
|
|
5
15
|
prefixCls?: string;
|
|
6
16
|
rowDetail?: TableRowDetail;
|
|
@@ -11,6 +21,7 @@ export interface TableProps extends BaseTableProps {
|
|
|
11
21
|
columnDrag?: boolean | ColumnDragOptions;
|
|
12
22
|
columnResize?: boolean | ColumnResizeOptions;
|
|
13
23
|
contextMenu?: IContextMenu;
|
|
24
|
+
rangeSelection?: TableRangeSelection;
|
|
14
25
|
}
|
|
15
26
|
export declare type RowSelectionType = 'checkbox' | 'radio';
|
|
16
27
|
export declare type RowSelectionFixed = 'start' | 'end';
|
|
@@ -32,3 +43,5 @@ export declare type TableSort = SortFeatureOptions;
|
|
|
32
43
|
export declare type TableTreeMode = TreeModeFeatureOptions;
|
|
33
44
|
export declare type TablePipeline = TP;
|
|
34
45
|
export declare type IContextMenu = boolean | ContextMenuFeatureOptions;
|
|
46
|
+
export declare type TableRangeSelection = RangeSelectionFeatureOptions;
|
|
47
|
+
export {};
|