@kdcloudjs/kdesign 1.3.3 → 1.3.6
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 +49 -0
- package/dist/kdesign-complete.less +5 -4
- package/dist/kdesign.css +2 -5
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +3493 -1832
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +2 -2
- 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/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.js +12 -11
- package/es/menu/subMenu.js +58 -57
- package/es/select/select.js +24 -18
- 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/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.js +12 -11
- package/lib/menu/subMenu.js +58 -57
- package/lib/select/select.js +24 -18
- 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/table/table.js
CHANGED
|
@@ -17,6 +17,7 @@ import useTreeMode from './feature/treeMode';
|
|
|
17
17
|
import useColumnResize from './feature/columnResize';
|
|
18
18
|
import useColumnDrag from './feature/columnDrag';
|
|
19
19
|
import useContextMenu from './feature/contextMenu';
|
|
20
|
+
import useRangeSelection from './feature/useRangeSelection';
|
|
20
21
|
import devWarning from '../_utils/devwarning';
|
|
21
22
|
|
|
22
23
|
function Table(props) {
|
|
@@ -46,6 +47,7 @@ function Table(props) {
|
|
|
46
47
|
getRowProps = props.getRowProps,
|
|
47
48
|
getTableProps = props.getTableProps,
|
|
48
49
|
contextMenu = props.contextMenu,
|
|
50
|
+
rangeSelection = props.rangeSelection,
|
|
49
51
|
cssVariables = props.cssVariables;
|
|
50
52
|
|
|
51
53
|
var _useContext = useContext(ConfigContext),
|
|
@@ -56,19 +58,24 @@ function Table(props) {
|
|
|
56
58
|
var tableCls = classNames(tablePrefixCls, className);
|
|
57
59
|
var pipeline = useTablePipeline({
|
|
58
60
|
components: {
|
|
59
|
-
Checkbox: Checkbox,
|
|
60
|
-
Radio: Radio
|
|
61
|
+
Checkbox: (components === null || components === void 0 ? void 0 : components.Checkbox) || Checkbox,
|
|
62
|
+
Radio: (components === null || components === void 0 ? void 0 : components.Radio) || Radio
|
|
61
63
|
}
|
|
62
64
|
}).primaryKey(primaryKey === undefined ? '' : primaryKey).input({
|
|
63
65
|
columns: columns,
|
|
64
66
|
dataSource: dataSource
|
|
65
67
|
});
|
|
68
|
+
|
|
69
|
+
if (footerDataSource) {
|
|
70
|
+
pipeline.footerDataSource(footerDataSource);
|
|
71
|
+
}
|
|
66
72
|
/* -------------------------------------------------------------------------- */
|
|
67
73
|
|
|
68
74
|
/* features */
|
|
69
75
|
|
|
70
76
|
/* -------------------------------------------------------------------------- */
|
|
71
77
|
|
|
78
|
+
|
|
72
79
|
useRowSelection(pipeline, rowSelection);
|
|
73
80
|
useRowDetail(pipeline, rowDetail);
|
|
74
81
|
useFilter(pipeline, filter);
|
|
@@ -78,6 +85,7 @@ function Table(props) {
|
|
|
78
85
|
useColumnResize(pipeline, columnResize);
|
|
79
86
|
useColumnDrag(pipeline, columnDrag);
|
|
80
87
|
useContextMenu(pipeline, contextMenu);
|
|
88
|
+
useRangeSelection(pipeline, rangeSelection);
|
|
81
89
|
/* -------------------------------------------------------------------------- */
|
|
82
90
|
|
|
83
91
|
/* after useTablePipeline, merge pipeline.getProps result */
|
|
@@ -101,18 +109,17 @@ function Table(props) {
|
|
|
101
109
|
className: tableCls,
|
|
102
110
|
style: style,
|
|
103
111
|
isLoading: isLoading,
|
|
104
|
-
components:
|
|
105
|
-
LoadingIcon: function
|
|
112
|
+
components: {
|
|
113
|
+
LoadingIcon: (components === null || components === void 0 ? void 0 : components.LoadingIcon) || function () {
|
|
106
114
|
return /*#__PURE__*/React.createElement(Spin, {
|
|
107
115
|
type: "container"
|
|
108
116
|
});
|
|
109
117
|
},
|
|
110
|
-
EmptyContent: function
|
|
118
|
+
EmptyContent: (components === null || components === void 0 ? void 0 : components.EmptyContent) || function () {
|
|
111
119
|
return /*#__PURE__*/React.createElement(Empty, null);
|
|
112
120
|
}
|
|
113
|
-
},
|
|
121
|
+
},
|
|
114
122
|
useVirtual: useVirtual,
|
|
115
|
-
footerDataSource: footerDataSource,
|
|
116
123
|
estimatedRowHeight: estimatedRowHeight,
|
|
117
124
|
emptyCellHeight: emptyCellHeight,
|
|
118
125
|
hasHeader: hasHeader,
|
package/lib/_utils/usePopper.js
CHANGED
|
@@ -186,6 +186,8 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
186
186
|
mouseLeaveDelay = _props$mouseLeaveDela === void 0 ? 0.1 : _props$mouseLeaveDela,
|
|
187
187
|
_props$defaultVisible = props.defaultVisible,
|
|
188
188
|
defaultVisible = _props$defaultVisible === void 0 ? false : _props$defaultVisible,
|
|
189
|
+
_props$autoPlacement = props.autoPlacement,
|
|
190
|
+
autoPlacement = _props$autoPlacement === void 0 ? true : _props$autoPlacement,
|
|
189
191
|
_props$getTriggerElem = props.getTriggerElement,
|
|
190
192
|
getTriggerElement = _props$getTriggerElem === void 0 ? function (locatorNode) {
|
|
191
193
|
return locatorNode;
|
|
@@ -323,36 +325,38 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
323
325
|
var currentPos = trigger === 'contextMenu' ? mousePos : locatorPos;
|
|
324
326
|
var _currentPlacement = placement;
|
|
325
327
|
|
|
326
|
-
if (
|
|
327
|
-
|
|
328
|
-
|
|
328
|
+
if (autoPlacement) {
|
|
329
|
+
if (top - gap - popperHeight <= 5 && bottom + gap + popperHeight < document.body.clientHeight - 5) {
|
|
330
|
+
_currentPlacement = _currentPlacement.replace('top', 'bottom');
|
|
331
|
+
}
|
|
329
332
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
+
if (bottom + gap + popperHeight >= document.body.clientHeight - 5 && top - gap - popperHeight > 5) {
|
|
334
|
+
_currentPlacement = _currentPlacement.replace('bottom', 'top');
|
|
335
|
+
}
|
|
333
336
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
+
if (left + popperWidth >= document.body.clientWidth - 5 && right - popperWidth > 5) {
|
|
338
|
+
_currentPlacement = _currentPlacement.replace('Left', 'Right');
|
|
339
|
+
}
|
|
337
340
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
+
if (right - popperWidth <= 5 && left + popperWidth < document.body.clientWidth - 5) {
|
|
342
|
+
_currentPlacement = _currentPlacement.replace('Right', 'Left');
|
|
343
|
+
}
|
|
341
344
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
+
if (top + popperHeight >= document.body.clientHeight - 5 && bottom - popperHeight > 5) {
|
|
346
|
+
_currentPlacement = _currentPlacement.replace('Top', 'Bottom');
|
|
347
|
+
}
|
|
345
348
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
+
if (bottom - popperHeight <= 5 && top + popperHeight < document.body.clientHeight - 5) {
|
|
350
|
+
_currentPlacement = _currentPlacement.replace('Bottom', 'Top');
|
|
351
|
+
}
|
|
349
352
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
+
if (left - gap - popperWidth <= 5 && right + gap + popperWidth < document.body.clientWidth - 5) {
|
|
354
|
+
_currentPlacement = _currentPlacement.replace('left', 'right');
|
|
355
|
+
}
|
|
353
356
|
|
|
354
|
-
|
|
355
|
-
|
|
357
|
+
if (right + gap + popperWidth >= document.body.clientWidth - 5 && left - gap - popperWidth > 5) {
|
|
358
|
+
_currentPlacement = _currentPlacement.replace('right', 'left');
|
|
359
|
+
}
|
|
356
360
|
}
|
|
357
361
|
|
|
358
362
|
var leftLeft = currentPos.left - popperWidth - gap;
|
|
@@ -465,7 +469,7 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
465
469
|
setArrowPos(_arrowPos);
|
|
466
470
|
setCurrentPlacement(_currentPlacement);
|
|
467
471
|
}
|
|
468
|
-
}, [locatorRef, popperRef, container, trigger, mousePos, placement, gap, arrowOffset, arrowSize, arrowWidth]);
|
|
472
|
+
}, [locatorRef, popperRef, container, trigger, mousePos, placement, gap, arrowOffset, arrowSize, arrowWidth, autoPlacement]);
|
|
469
473
|
(0, _react.useEffect)(function () {
|
|
470
474
|
if (canAlign) {
|
|
471
475
|
alignPopper();
|
|
@@ -479,7 +483,7 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
479
483
|
if (arrowPos.left) arrowStyle["--arrowLeft"] = arrowPos.left + 'px';
|
|
480
484
|
var popperContainerStyle = (0, _extends2.default)((0, _extends2.default)((0, _extends2.default)({
|
|
481
485
|
position: 'absolute'
|
|
482
|
-
},
|
|
486
|
+
}, align), arrow ? arrowStyle : {}), popperStyle);
|
|
483
487
|
var popperProps = {
|
|
484
488
|
ref: popperRef,
|
|
485
489
|
style: popperContainerStyle,
|
package/lib/anchor/anchor.js
CHANGED
|
@@ -367,7 +367,9 @@ var InternalAnchor = function InternalAnchor(props, ref) {
|
|
|
367
367
|
!isLocked && setOptionShow(visible);
|
|
368
368
|
};
|
|
369
369
|
|
|
370
|
-
var popperProps = (0, _extends2.default)((0, _extends2.default)({
|
|
370
|
+
var popperProps = (0, _extends2.default)((0, _extends2.default)({
|
|
371
|
+
autoPlacement: false
|
|
372
|
+
}, anchorProps), {
|
|
371
373
|
prefixCls: anchorPrefixCls,
|
|
372
374
|
defaultVisible: optionShow,
|
|
373
375
|
visible: optionShow,
|
|
@@ -375,6 +377,22 @@ var InternalAnchor = function InternalAnchor(props, ref) {
|
|
|
375
377
|
onVisibleChange: handleVisibleChange
|
|
376
378
|
});
|
|
377
379
|
|
|
380
|
+
var fixedRef = _react.default.useRef(null);
|
|
381
|
+
|
|
382
|
+
if (type === 'advanced' && isLocked) {
|
|
383
|
+
if (fixedRef.current) {
|
|
384
|
+
var _fixedRef$current$get = fixedRef.current.getBoundingClientRect(),
|
|
385
|
+
left = _fixedRef$current$get.left,
|
|
386
|
+
top = _fixedRef$current$get.top;
|
|
387
|
+
|
|
388
|
+
popperProps.popperStyle = {
|
|
389
|
+
position: 'fixed',
|
|
390
|
+
left: left,
|
|
391
|
+
top: top
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
378
396
|
var addChildrenProps = function addChildrenProps(linksChildren) {
|
|
379
397
|
var _context4;
|
|
380
398
|
|
|
@@ -504,6 +522,7 @@ var InternalAnchor = function InternalAnchor(props, ref) {
|
|
|
504
522
|
});
|
|
505
523
|
|
|
506
524
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
525
|
+
ref: fixedRef,
|
|
507
526
|
className: anchorAdvancedClass,
|
|
508
527
|
style: dropdownStyle
|
|
509
528
|
}, lockedIcon !== false && /*#__PURE__*/_react.default.createElement("span", {
|
|
@@ -222,6 +222,7 @@
|
|
|
222
222
|
}
|
|
223
223
|
.kd-baseData-dropdown-options {
|
|
224
224
|
height: var(--kd-c-base-data-dropdown-options-sizing-height, 32px);
|
|
225
|
+
cursor: pointer;
|
|
225
226
|
}
|
|
226
227
|
.kd-baseData-dropdown-options:hover {
|
|
227
228
|
background: var(--kd-c-base-data-color-background-hover, var(--kd-g-color-hover, #f5f5f5));
|
package/lib/form/Field.js
CHANGED
|
@@ -137,7 +137,8 @@ var Field = function Field(props) {
|
|
|
137
137
|
getInternalHooks = fieldContext.getInternalHooks,
|
|
138
138
|
vertical = fieldContext.vertical,
|
|
139
139
|
getDefaultValue = fieldContext.getDefaultValue,
|
|
140
|
-
local = fieldContext.local
|
|
140
|
+
local = fieldContext.local,
|
|
141
|
+
formDisabled = fieldContext.disabled;
|
|
141
142
|
|
|
142
143
|
var _getInternalHooks = getInternalHooks(_useForm.INTERNAL_HOOK_KEY),
|
|
143
144
|
registerField = _getInternalHooks.registerField,
|
|
@@ -305,17 +306,17 @@ var Field = function Field(props) {
|
|
|
305
306
|
chDisabled = _ch$props.disabled,
|
|
306
307
|
chDefaultValue = _ch$props.defaultValue;
|
|
307
308
|
|
|
308
|
-
var onChange = function onChange(
|
|
309
|
+
var onChange = function onChange() {
|
|
309
310
|
if (chValue === undefined) {
|
|
310
|
-
setFieldValue(getInputValueFormProp(
|
|
311
|
+
setFieldValue(getInputValueFormProp(arguments.length <= 0 ? undefined : arguments[0]));
|
|
311
312
|
}
|
|
312
313
|
|
|
313
314
|
if (typeof faChange === 'function') {
|
|
314
|
-
faChange(
|
|
315
|
+
faChange.apply(void 0, arguments);
|
|
315
316
|
}
|
|
316
317
|
|
|
317
318
|
if (typeof chChange === 'function') {
|
|
318
|
-
chChange(
|
|
319
|
+
chChange.apply(void 0, arguments);
|
|
319
320
|
}
|
|
320
321
|
};
|
|
321
322
|
|
|
@@ -333,7 +334,7 @@ var Field = function Field(props) {
|
|
|
333
334
|
return (0, _extends5.default)((0, _extends5.default)({}, rest), (_extends3 = {
|
|
334
335
|
onChange: onChange,
|
|
335
336
|
defaultValue: defaultValue
|
|
336
|
-
}, (0, _defineProperty2.default)(_extends3, innerValuePropName, fieldValue), (0, _defineProperty2.default)(_extends3, "disabled", chDisabled
|
|
337
|
+
}, (0, _defineProperty2.default)(_extends3, innerValuePropName, fieldValue), (0, _defineProperty2.default)(_extends3, "disabled", chDisabled !== undefined ? chDisabled : faDisabled !== undefined ? faDisabled : formDisabled), _extends3));
|
|
337
338
|
};
|
|
338
339
|
|
|
339
340
|
return /*#__PURE__*/_react.default.createElement("div", {
|
package/lib/form/Form.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ declare type BaseFormProps = Omit<React.FormHTMLAttributes<HTMLFormElement>, 'on
|
|
|
4
4
|
export interface FormProps<Values = any> extends BaseFormProps {
|
|
5
5
|
children?: React.ReactNode;
|
|
6
6
|
defaultValues?: Store;
|
|
7
|
+
disabled?: boolean;
|
|
7
8
|
className?: string;
|
|
8
9
|
form?: FormInstance<Values>;
|
|
9
10
|
labelAlign?: LabelAlign;
|
package/lib/form/Form.js
CHANGED
|
@@ -81,7 +81,8 @@ var Form = function Form(props, ref) {
|
|
|
81
81
|
onFinish = formProps.onFinish,
|
|
82
82
|
onFinishFailed = formProps.onFinishFailed,
|
|
83
83
|
onValuesChange = formProps.onValuesChange,
|
|
84
|
-
|
|
84
|
+
disabled = formProps.disabled,
|
|
85
|
+
restProps = __rest(formProps, ["children", "defaultValues", "className", "form", "labelAlign", "labelWidth", "layout", "name", "prefixCls", "wrapperWidth", "onFinish", "onFinishFailed", "onValuesChange", "disabled"]);
|
|
85
86
|
|
|
86
87
|
var formPrefixCls = getPrefixCls(prefixCls, 'form', customizePrefixCls);
|
|
87
88
|
var formClassName = (0, _classnames2.default)((_classnames = {}, (0, _defineProperty2.default)(_classnames, "".concat(formPrefixCls), true), (0, _defineProperty2.default)(_classnames, (0, _concat.default)(_context = "".concat(formPrefixCls, "-")).call(_context, layout), true), _classnames), className);
|
|
@@ -121,6 +122,7 @@ var Form = function Form(props, ref) {
|
|
|
121
122
|
labelWidth: labelWidth,
|
|
122
123
|
wrapperWidth: wrapperWidth,
|
|
123
124
|
local: formLang,
|
|
125
|
+
disabled: disabled,
|
|
124
126
|
vertical: layout === 'vertical'
|
|
125
127
|
});
|
|
126
128
|
}, [formInstance, labelAlign, labelWidth, wrapperWidth, layout, formLang]);
|
package/lib/form/interface.d.ts
CHANGED
package/lib/menu/menu.js
CHANGED
|
@@ -108,31 +108,32 @@ var Menu = function Menu(props) {
|
|
|
108
108
|
openKeys = _React$useState4[0],
|
|
109
109
|
setOpenKeys = _React$useState4[1];
|
|
110
110
|
|
|
111
|
+
if (mode === 'inline') {
|
|
112
|
+
restProps.triggerSubMenuAction = 'click';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
(0, _react.useEffect)(function () {
|
|
116
|
+
setOpenKeys([]);
|
|
117
|
+
setSelectedKey('');
|
|
118
|
+
openSubMenuSet.clear();
|
|
119
|
+
}, [mode]);
|
|
111
120
|
(0, _react.useEffect)(function () {
|
|
112
121
|
if (userSelectedKey !== undefined) {
|
|
113
122
|
setSelectedKey(userSelectedKey);
|
|
114
123
|
}
|
|
115
124
|
}, [userSelectedKey]);
|
|
116
125
|
(0, _react.useEffect)(function () {
|
|
117
|
-
if (userOpenKeys !== undefined) {
|
|
126
|
+
if (userOpenKeys !== undefined && Array.isArray(userOpenKeys)) {
|
|
118
127
|
setOpenKeys(userOpenKeys);
|
|
119
|
-
|
|
120
|
-
}, [userOpenKeys]);
|
|
121
|
-
(0, _react.useEffect)(function () {
|
|
122
|
-
if (Array.isArray(userOpenKeys)) {
|
|
128
|
+
openSubMenuSet.clear();
|
|
123
129
|
userOpenKeys.forEach(function (d) {
|
|
124
130
|
openSubMenuSet.add(d);
|
|
125
131
|
});
|
|
126
132
|
}
|
|
127
|
-
}, []); //
|
|
128
|
-
|
|
129
|
-
if (mode === 'inline') {
|
|
130
|
-
restProps.triggerSubMenuAction = 'click';
|
|
131
|
-
} // React.useEffect(() => {
|
|
133
|
+
}, [userOpenKeys]); // React.useEffect(() => {
|
|
132
134
|
// setCollapsed(restProps.collapsed)
|
|
133
135
|
// }, [restProps.collapsed])
|
|
134
136
|
|
|
135
|
-
|
|
136
137
|
var handleOnClick = function handleOnClick(info) {
|
|
137
138
|
if (userSelectedKey === undefined) {
|
|
138
139
|
setSelectedKey(info.key);
|
package/lib/menu/subMenu.js
CHANGED
|
@@ -55,7 +55,7 @@ var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
var SubMenu = function SubMenu(props) {
|
|
58
|
-
var
|
|
58
|
+
var _classNames2, _classNames3, _context4;
|
|
59
59
|
|
|
60
60
|
var _React$useContext = _react.default.useContext(_configProvider.ConfigContext),
|
|
61
61
|
getPrefixCls = _React$useContext.getPrefixCls,
|
|
@@ -83,8 +83,9 @@ var SubMenu = function SubMenu(props) {
|
|
|
83
83
|
handleOnOpenChange = _a.handleOnOpenChange,
|
|
84
84
|
_a$paddingLeft = _a.paddingLeft,
|
|
85
85
|
paddingLeft = _a$paddingLeft === void 0 ? 0 : _a$paddingLeft,
|
|
86
|
-
restProps = __rest(_a, ["prefixCls", "theme", "mode", "title", "icon", "disabled", "children", "collapsed", "keyValue", "selectedKey", "openKeys", "triggerSubMenuAction", "forceSubMenuRender", "inlineIndent", "className", "style", "handleOnOpenChange", "paddingLeft"]);
|
|
86
|
+
restProps = __rest(_a, ["prefixCls", "theme", "mode", "title", "icon", "disabled", "children", "collapsed", "keyValue", "selectedKey", "openKeys", "triggerSubMenuAction", "forceSubMenuRender", "inlineIndent", "className", "style", "handleOnOpenChange", "paddingLeft"]);
|
|
87
87
|
|
|
88
|
+
var isVertical = mode === 'vertical'; // 初始化level
|
|
88
89
|
|
|
89
90
|
if (!restProps.level) {
|
|
90
91
|
restProps.level = 1;
|
|
@@ -110,7 +111,7 @@ var SubMenu = function SubMenu(props) {
|
|
|
110
111
|
var visible = Array.isArray(openKeys) && (0, _includes.default)(openKeys).call(openKeys, keyValue);
|
|
111
112
|
|
|
112
113
|
_react.default.useEffect(function () {
|
|
113
|
-
if (!visible) return;
|
|
114
|
+
if (!visible || isVertical) return;
|
|
114
115
|
var subMenuWrapperEle = subMenuWrapperRef.current;
|
|
115
116
|
var subMenuEle = subMenuRef.current;
|
|
116
117
|
|
|
@@ -216,11 +217,10 @@ var SubMenu = function SubMenu(props) {
|
|
|
216
217
|
if (!(0, _includes.default)(className).call(className, _menuItem.MENU_ITEM_CONTAINER_NAME)) {
|
|
217
218
|
closeSubMenu();
|
|
218
219
|
}
|
|
219
|
-
}); // 缩略模式自动关闭子菜单
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
220
|
+
}); // // 缩略模式自动关闭子菜单
|
|
221
|
+
// if (triggerSubMenuAction === 'click' && mode === 'vertical' && collapsed) {
|
|
222
|
+
// closeSubMenu()
|
|
223
|
+
// }
|
|
224
224
|
|
|
225
225
|
var handleMouseEvent = function handleMouseEvent(status) {
|
|
226
226
|
if (disabled || triggerSubMenuAction === 'click') return;
|
|
@@ -241,7 +241,7 @@ var SubMenu = function SubMenu(props) {
|
|
|
241
241
|
// 保存路径
|
|
242
242
|
info.keyPath = (0, _concat.default)(_context = info.keyPath).call(_context, [keyValue]);
|
|
243
243
|
|
|
244
|
-
if (triggerSubMenuAction === 'click' &&
|
|
244
|
+
if (triggerSubMenuAction === 'click' && isVertical) {
|
|
245
245
|
closeSubMenu();
|
|
246
246
|
}
|
|
247
247
|
|
|
@@ -314,53 +314,12 @@ var SubMenu = function SubMenu(props) {
|
|
|
314
314
|
var titleStyle = {
|
|
315
315
|
paddingRight: "".concat(curPaddingRight, "px"),
|
|
316
316
|
paddingLeft: "".concat(curPaddingLeft, "px")
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
if (mode !== 'vertical') {
|
|
320
|
-
var _classNames2, _context4;
|
|
321
|
-
|
|
322
|
-
return /*#__PURE__*/_react.default.createElement("li", (0, _extends2.default)({
|
|
323
|
-
ref: subMenuRef,
|
|
324
|
-
className: (0, _classnames.default)(prefixCls, className, (_classNames2 = {}, (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-collapsed"), collapsed), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-disabled"), disabled), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-hover"), !disabled && visible), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-active"), Array.isArray(openKeys) && (0, _includes.default)(openKeys).call(openKeys, keyValue)), _classNames2)),
|
|
325
|
-
key: keyValue
|
|
326
|
-
}, mouseEvent, {
|
|
327
|
-
style: style
|
|
328
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
329
|
-
className: (0, _classnames.default)("".concat(prefixCls, "-title")),
|
|
330
|
-
style: titleStyle
|
|
331
|
-
}, icon && /*#__PURE__*/_react.default.cloneElement((0, _util.renderReactNodeFunction)(icon), {
|
|
332
|
-
className: (0, _classnames.default)("".concat(prefixCls, "-icon"))
|
|
333
|
-
}), renderItemTitle(), renderItemArrow()), /*#__PURE__*/_react.default.createElement("div", {
|
|
334
|
-
style: getCurrentStyle(),
|
|
335
|
-
ref: subMenuWrapperRef
|
|
336
|
-
}, /*#__PURE__*/_react.default.createElement("ul", {
|
|
337
|
-
className: (0, _classnames.default)("".concat(prefixCls, "-sub"), restProps.popupClassName)
|
|
338
|
-
}, (0, _map.default)(_context4 = (0, _reactChildren.toArray)(children)).call(_context4, function (item, index) {
|
|
339
|
-
var key = item.key || index;
|
|
340
|
-
return /*#__PURE__*/_react.default.cloneElement(item, {
|
|
341
|
-
key: key,
|
|
342
|
-
level: restProps.level + 1,
|
|
343
|
-
keyValue: key,
|
|
344
|
-
collapsed: collapsed,
|
|
345
|
-
mode: mode,
|
|
346
|
-
selectedKey: selectedKey,
|
|
347
|
-
openKeys: openKeys,
|
|
348
|
-
forceSubMenuRender: forceSubMenuRender,
|
|
349
|
-
triggerSubMenuAction: triggerSubMenuAction,
|
|
350
|
-
handleOnOpenChange: handleOnOpenChange,
|
|
351
|
-
handleOnClick: handleOnClick,
|
|
352
|
-
inlineIndent: inlineIndent,
|
|
353
|
-
paddingLeft: curPaddingLeft
|
|
354
|
-
});
|
|
355
|
-
}))));
|
|
356
|
-
} // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
317
|
+
}; // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
357
318
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
className: (0, _classnames.default)(prefixCls, className, (_classNames3 = {}, (0, _defineProperty2.default)(_classNames3, "light", theme === 'light'), (0, _defineProperty2.default)(_classNames3, "".concat(prefixCls, "-collapsed"), collapsed), (0, _defineProperty2.default)(_classNames3, "".concat(prefixCls, "-disabled"), disabled), (0, _defineProperty2.default)(_classNames3, "".concat(prefixCls, "-hover"), !disabled && visible), (0, _defineProperty2.default)(_classNames3, "".concat(prefixCls, "-active"), Array.isArray(openKeys) && (0, _includes.default)(openKeys).call(openKeys, keyValue)), _classNames3)),
|
|
319
|
+
var verticalView = (0, _usePopper.default)( /*#__PURE__*/_react.default.createElement("li", (0, _extends2.default)({
|
|
320
|
+
className: (0, _classnames.default)(prefixCls, className, (_classNames2 = {}, (0, _defineProperty2.default)(_classNames2, "light", theme === 'light'), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-collapsed"), collapsed), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-disabled"), disabled), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-hover"), !disabled && visible), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-active"), Array.isArray(openKeys) && (0, _includes.default)(openKeys).call(openKeys, keyValue)), _classNames2)),
|
|
361
321
|
ref: subMenuVerticalRef,
|
|
362
|
-
key: keyValue
|
|
363
|
-
style: style
|
|
322
|
+
key: keyValue
|
|
364
323
|
}, {
|
|
365
324
|
onMouseLeave: handleOnMouseLeave,
|
|
366
325
|
onMouseEnter: handleOnMouseEnter,
|
|
@@ -379,8 +338,8 @@ var SubMenu = function SubMenu(props) {
|
|
|
379
338
|
handleOnMouseEnter();
|
|
380
339
|
}
|
|
381
340
|
}, /*#__PURE__*/_react.default.createElement("ul", {
|
|
382
|
-
className: (0, _classnames.default)("".concat(prefixCls, "-sub"), restProps.popupClassName, (
|
|
383
|
-
}, (0, _map.default)(
|
|
341
|
+
className: (0, _classnames.default)("".concat(prefixCls, "-sub"), restProps.popupClassName, (_classNames3 = {}, (0, _defineProperty2.default)(_classNames3, "".concat(prefixCls, "-sub-second"), restProps.level === 1), (0, _defineProperty2.default)(_classNames3, "".concat(prefixCls, "-sub-third"), restProps.level === 2), _classNames3))
|
|
342
|
+
}, (0, _map.default)(_context4 = (0, _reactChildren.toArray)(children)).call(_context4, function (item, index) {
|
|
384
343
|
var key = item.key || index;
|
|
385
344
|
return /*#__PURE__*/_react.default.cloneElement(item, {
|
|
386
345
|
key: key,
|
|
@@ -402,10 +361,52 @@ var SubMenu = function SubMenu(props) {
|
|
|
402
361
|
arrow: false,
|
|
403
362
|
placement: 'rightTop',
|
|
404
363
|
gap: 0,
|
|
405
|
-
visible: visible,
|
|
364
|
+
visible: isVertical ? visible : false,
|
|
365
|
+
disabled: isVertical ? undefined : true,
|
|
406
366
|
prefixCls: 'kd-menu-popper',
|
|
407
367
|
popperClassName: theme === 'light' ? 'light' : ''
|
|
408
368
|
});
|
|
369
|
+
|
|
370
|
+
if (isVertical) {
|
|
371
|
+
return verticalView;
|
|
372
|
+
} else {
|
|
373
|
+
var _classNames4, _context5;
|
|
374
|
+
|
|
375
|
+
return /*#__PURE__*/_react.default.createElement("li", (0, _extends2.default)({
|
|
376
|
+
ref: subMenuRef,
|
|
377
|
+
className: (0, _classnames.default)(prefixCls, className, (_classNames4 = {}, (0, _defineProperty2.default)(_classNames4, "".concat(prefixCls, "-collapsed"), collapsed), (0, _defineProperty2.default)(_classNames4, "".concat(prefixCls, "-disabled"), disabled), _classNames4)),
|
|
378
|
+
key: keyValue
|
|
379
|
+
}, mouseEvent, {
|
|
380
|
+
style: style
|
|
381
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
382
|
+
className: (0, _classnames.default)("".concat(prefixCls, "-title")),
|
|
383
|
+
style: titleStyle
|
|
384
|
+
}, icon && /*#__PURE__*/_react.default.cloneElement((0, _util.renderReactNodeFunction)(icon), {
|
|
385
|
+
className: (0, _classnames.default)("".concat(prefixCls, "-icon"))
|
|
386
|
+
}), renderItemTitle(), renderItemArrow()), /*#__PURE__*/_react.default.createElement("div", {
|
|
387
|
+
style: getCurrentStyle(),
|
|
388
|
+
ref: subMenuWrapperRef
|
|
389
|
+
}, /*#__PURE__*/_react.default.createElement("ul", {
|
|
390
|
+
className: (0, _classnames.default)("".concat(prefixCls, "-sub"), restProps.popupClassName)
|
|
391
|
+
}, (0, _map.default)(_context5 = (0, _reactChildren.toArray)(children)).call(_context5, function (item, index) {
|
|
392
|
+
var key = item.key || index;
|
|
393
|
+
return /*#__PURE__*/_react.default.cloneElement(item, {
|
|
394
|
+
key: key,
|
|
395
|
+
level: restProps.level + 1,
|
|
396
|
+
keyValue: key,
|
|
397
|
+
collapsed: collapsed,
|
|
398
|
+
mode: mode,
|
|
399
|
+
selectedKey: selectedKey,
|
|
400
|
+
openKeys: openKeys,
|
|
401
|
+
forceSubMenuRender: forceSubMenuRender,
|
|
402
|
+
triggerSubMenuAction: triggerSubMenuAction,
|
|
403
|
+
handleOnOpenChange: handleOnOpenChange,
|
|
404
|
+
handleOnClick: handleOnClick,
|
|
405
|
+
inlineIndent: inlineIndent,
|
|
406
|
+
paddingLeft: curPaddingLeft
|
|
407
|
+
});
|
|
408
|
+
}))));
|
|
409
|
+
}
|
|
409
410
|
};
|
|
410
411
|
|
|
411
412
|
SubMenu.displayName = 'SubMenu';
|
package/lib/select/select.js
CHANGED
|
@@ -103,7 +103,6 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
103
103
|
setInitValue = _useMergedState2[1];
|
|
104
104
|
|
|
105
105
|
var realChildren = Array.isArray(options) ? options : (0, _reactChildren.toArray)(children); // options配置项和默认children
|
|
106
|
-
// console.log('real', realChildren)
|
|
107
106
|
|
|
108
107
|
var innerRef = _react.default.useRef();
|
|
109
108
|
|
|
@@ -288,6 +287,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
288
287
|
return (child === null || child === void 0 ? void 0 : child.value) === key;
|
|
289
288
|
}
|
|
290
289
|
})) || {};
|
|
290
|
+
var optionsObj = obj.props ? obj.props : obj || {};
|
|
291
291
|
|
|
292
292
|
if (value !== undefined) {
|
|
293
293
|
// onChange && onChange(labelInValue ? { value: key, label } : key)
|
|
@@ -304,13 +304,13 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
304
304
|
(0, _splice.default)(optsArr).call(optsArr, idx, 1);
|
|
305
305
|
} else {
|
|
306
306
|
valArr.push(key);
|
|
307
|
-
optsArr.push({
|
|
307
|
+
optsArr.push((0, _extends2.default)((0, _extends2.default)({}, optionsObj), {
|
|
308
308
|
value: key,
|
|
309
309
|
label: obj.props ? (_a = obj.props) === null || _a === void 0 ? void 0 : _a.children : obj.label || key
|
|
310
|
-
});
|
|
310
|
+
}));
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
onChange && onChange(labelInValue ? optsArr : valArr);
|
|
313
|
+
onChange && onChange(labelInValue ? optsArr : valArr, optsArr);
|
|
314
314
|
|
|
315
315
|
if (!isSelected) {
|
|
316
316
|
onDeselect && onDeselect(key); // 下拉项取消选中时调用,参数为选中项的value,多选模式下生效
|
|
@@ -320,7 +320,10 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
320
320
|
onChange && onChange(labelInValue ? {
|
|
321
321
|
value: key,
|
|
322
322
|
label: label
|
|
323
|
-
} : key)
|
|
323
|
+
} : key, (0, _extends2.default)((0, _extends2.default)({}, optionsObj), {
|
|
324
|
+
value: key,
|
|
325
|
+
label: label
|
|
326
|
+
}));
|
|
324
327
|
}
|
|
325
328
|
|
|
326
329
|
onSelect && onSelect(key);
|
|
@@ -336,7 +339,10 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
336
339
|
onChange && onChange(labelInValue ? {
|
|
337
340
|
value: key,
|
|
338
341
|
label: label
|
|
339
|
-
} : key)
|
|
342
|
+
} : key, (0, _extends2.default)((0, _extends2.default)({}, optionsObj), {
|
|
343
|
+
value: key,
|
|
344
|
+
label: label
|
|
345
|
+
}));
|
|
340
346
|
} else {
|
|
341
347
|
var _multipleRef$current2 = multipleRef.current,
|
|
342
348
|
_selectedVal = _multipleRef$current2.selectedVal,
|
|
@@ -350,15 +356,15 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
350
356
|
} else {
|
|
351
357
|
_selectedVal.push(key);
|
|
352
358
|
|
|
353
|
-
_selectMulOpts.push({
|
|
359
|
+
_selectMulOpts.push((0, _extends2.default)((0, _extends2.default)({}, optionsObj), {
|
|
354
360
|
value: key,
|
|
355
361
|
label: obj.props ? (_c = obj.props) === null || _c === void 0 ? void 0 : _c.children : obj.label || key
|
|
356
|
-
});
|
|
362
|
+
}));
|
|
357
363
|
} // setInitValue([...selectedVal])
|
|
358
364
|
|
|
359
365
|
|
|
360
366
|
setMulOptions((0, _toConsumableArray2.default)(_selectMulOpts));
|
|
361
|
-
onChange && onChange(labelInValue ? _selectMulOpts : _selectedVal);
|
|
367
|
+
onChange && onChange(labelInValue ? _selectMulOpts : _selectedVal, _selectMulOpts);
|
|
362
368
|
|
|
363
369
|
if (!isSelected) {
|
|
364
370
|
onDeselect && onDeselect(key); // 下拉项取消选中时调用,参数为选中项的value,多选模式下生效
|
|
@@ -379,9 +385,9 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
379
385
|
|
|
380
386
|
if ((realChildren === null || realChildren === void 0 ? void 0 : realChildren.length) !== selectedVal.length) {
|
|
381
387
|
(0, _map.default)(realChildren).call(realChildren, function (child) {
|
|
382
|
-
var
|
|
383
|
-
value =
|
|
384
|
-
children =
|
|
388
|
+
var _ref = child.props || child,
|
|
389
|
+
value = _ref.value,
|
|
390
|
+
children = _ref.children;
|
|
385
391
|
|
|
386
392
|
if (!(0, _includes.default)(selectedVal).call(selectedVal, value)) {
|
|
387
393
|
selectedVal.push(value);
|
|
@@ -393,12 +399,12 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
393
399
|
});
|
|
394
400
|
setMulOptions((0, _toConsumableArray2.default)(selectMulOpts));
|
|
395
401
|
} else {
|
|
396
|
-
multipleRef.current.selectedVal = [];
|
|
397
|
-
multipleRef.current.selectMulOpts = [];
|
|
402
|
+
multipleRef.current.selectedVal = selectedVal = [];
|
|
403
|
+
multipleRef.current.selectMulOpts = selectMulOpts = [];
|
|
398
404
|
setMulOptions([]);
|
|
399
405
|
}
|
|
400
406
|
|
|
401
|
-
onChange && onChange(labelInValue ? selectMulOpts : selectedVal);
|
|
407
|
+
onChange && onChange(labelInValue ? selectMulOpts : selectedVal, selectMulOpts);
|
|
402
408
|
}; // 筛选内容 ---可以优化,抽成hook
|
|
403
409
|
|
|
404
410
|
|
|
@@ -456,7 +462,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
456
462
|
(0, _splice.default)(selectedVal).call(selectedVal, idx, 1);
|
|
457
463
|
(0, _splice.default)(selectMulOpts).call(selectMulOpts, idx, 1);
|
|
458
464
|
setMulOptions((0, _toConsumableArray2.default)(selectMulOpts));
|
|
459
|
-
onChange && onChange(labelInValue ? selectMulOpts : selectedVal);
|
|
465
|
+
onChange && onChange(labelInValue ? selectMulOpts : selectedVal, selectMulOpts);
|
|
460
466
|
e.stopPropagation();
|
|
461
467
|
}; // 渲染后缀图标
|
|
462
468
|
|
|
@@ -686,8 +692,8 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
686
692
|
var _a;
|
|
687
693
|
|
|
688
694
|
if (selectRef === null || selectRef === void 0 ? void 0 : selectRef.current) {
|
|
689
|
-
var
|
|
690
|
-
width =
|
|
695
|
+
var _ref2 = (_a = selectRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(),
|
|
696
|
+
width = _ref2.width;
|
|
691
697
|
|
|
692
698
|
return {
|
|
693
699
|
width: (dropdownStyle === null || dropdownStyle === void 0 ? void 0 : dropdownStyle.width) || (width > 75 ? width : 75),
|