@kdcloudjs/kdesign 1.3.4 → 1.3.7
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 +33 -0
- package/dist/kdesign-complete.less +19 -6
- package/dist/kdesign.css +38 -5
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +3505 -1836
- 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/button/style/index.css +36 -0
- package/es/button/style/index.less +14 -2
- package/es/checkbox/checkbox.js +7 -3
- 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/radio/radio.js +7 -3
- 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/button/style/index.css +36 -0
- package/lib/button/style/index.less +14 -2
- package/lib/checkbox/checkbox.js +7 -3
- 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/radio/radio.js +7 -3
- 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/_utils/usePopper.d.ts
CHANGED
package/es/_utils/usePopper.js
CHANGED
|
@@ -150,6 +150,8 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
150
150
|
mouseLeaveDelay = _props$mouseLeaveDela === void 0 ? 0.1 : _props$mouseLeaveDela,
|
|
151
151
|
_props$defaultVisible = props.defaultVisible,
|
|
152
152
|
defaultVisible = _props$defaultVisible === void 0 ? false : _props$defaultVisible,
|
|
153
|
+
_props$autoPlacement = props.autoPlacement,
|
|
154
|
+
autoPlacement = _props$autoPlacement === void 0 ? true : _props$autoPlacement,
|
|
153
155
|
_props$getTriggerElem = props.getTriggerElement,
|
|
154
156
|
getTriggerElement = _props$getTriggerElem === void 0 ? function (locatorNode) {
|
|
155
157
|
return locatorNode;
|
|
@@ -287,36 +289,38 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
287
289
|
var currentPos = trigger === 'contextMenu' ? mousePos : locatorPos;
|
|
288
290
|
var _currentPlacement = placement;
|
|
289
291
|
|
|
290
|
-
if (
|
|
291
|
-
|
|
292
|
-
|
|
292
|
+
if (autoPlacement) {
|
|
293
|
+
if (top - gap - popperHeight <= 5 && bottom + gap + popperHeight < document.body.clientHeight - 5) {
|
|
294
|
+
_currentPlacement = _currentPlacement.replace('top', 'bottom');
|
|
295
|
+
}
|
|
293
296
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
+
if (bottom + gap + popperHeight >= document.body.clientHeight - 5 && top - gap - popperHeight > 5) {
|
|
298
|
+
_currentPlacement = _currentPlacement.replace('bottom', 'top');
|
|
299
|
+
}
|
|
297
300
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
+
if (left + popperWidth >= document.body.clientWidth - 5 && right - popperWidth > 5) {
|
|
302
|
+
_currentPlacement = _currentPlacement.replace('Left', 'Right');
|
|
303
|
+
}
|
|
301
304
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
+
if (right - popperWidth <= 5 && left + popperWidth < document.body.clientWidth - 5) {
|
|
306
|
+
_currentPlacement = _currentPlacement.replace('Right', 'Left');
|
|
307
|
+
}
|
|
305
308
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
+
if (top + popperHeight >= document.body.clientHeight - 5 && bottom - popperHeight > 5) {
|
|
310
|
+
_currentPlacement = _currentPlacement.replace('Top', 'Bottom');
|
|
311
|
+
}
|
|
309
312
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
+
if (bottom - popperHeight <= 5 && top + popperHeight < document.body.clientHeight - 5) {
|
|
314
|
+
_currentPlacement = _currentPlacement.replace('Bottom', 'Top');
|
|
315
|
+
}
|
|
313
316
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
+
if (left - gap - popperWidth <= 5 && right + gap + popperWidth < document.body.clientWidth - 5) {
|
|
318
|
+
_currentPlacement = _currentPlacement.replace('left', 'right');
|
|
319
|
+
}
|
|
317
320
|
|
|
318
|
-
|
|
319
|
-
|
|
321
|
+
if (right + gap + popperWidth >= document.body.clientWidth - 5 && left - gap - popperWidth > 5) {
|
|
322
|
+
_currentPlacement = _currentPlacement.replace('right', 'left');
|
|
323
|
+
}
|
|
320
324
|
}
|
|
321
325
|
|
|
322
326
|
var leftLeft = currentPos.left - popperWidth - gap;
|
|
@@ -429,7 +433,7 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
429
433
|
setArrowPos(_arrowPos);
|
|
430
434
|
setCurrentPlacement(_currentPlacement);
|
|
431
435
|
}
|
|
432
|
-
}, [locatorRef, popperRef, container, trigger, mousePos, placement, gap, arrowOffset, arrowSize, arrowWidth]);
|
|
436
|
+
}, [locatorRef, popperRef, container, trigger, mousePos, placement, gap, arrowOffset, arrowSize, arrowWidth, autoPlacement]);
|
|
433
437
|
useEffect(function () {
|
|
434
438
|
if (canAlign) {
|
|
435
439
|
alignPopper();
|
|
@@ -444,7 +448,7 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
444
448
|
|
|
445
449
|
var popperContainerStyle = _extends(_extends(_extends({
|
|
446
450
|
position: 'absolute'
|
|
447
|
-
},
|
|
451
|
+
}, align), arrow ? arrowStyle : {}), popperStyle);
|
|
448
452
|
|
|
449
453
|
var popperProps = {
|
|
450
454
|
ref: popperRef,
|
package/es/anchor/anchor.js
CHANGED
|
@@ -320,7 +320,9 @@ var InternalAnchor = function InternalAnchor(props, ref) {
|
|
|
320
320
|
!isLocked && setOptionShow(visible);
|
|
321
321
|
};
|
|
322
322
|
|
|
323
|
-
var popperProps = _extends(_extends({
|
|
323
|
+
var popperProps = _extends(_extends({
|
|
324
|
+
autoPlacement: false
|
|
325
|
+
}, anchorProps), {
|
|
324
326
|
prefixCls: anchorPrefixCls,
|
|
325
327
|
defaultVisible: optionShow,
|
|
326
328
|
visible: optionShow,
|
|
@@ -328,6 +330,22 @@ var InternalAnchor = function InternalAnchor(props, ref) {
|
|
|
328
330
|
onVisibleChange: handleVisibleChange
|
|
329
331
|
});
|
|
330
332
|
|
|
333
|
+
var fixedRef = React.useRef(null);
|
|
334
|
+
|
|
335
|
+
if (type === 'advanced' && isLocked) {
|
|
336
|
+
if (fixedRef.current) {
|
|
337
|
+
var _fixedRef$current$get = fixedRef.current.getBoundingClientRect(),
|
|
338
|
+
left = _fixedRef$current$get.left,
|
|
339
|
+
top = _fixedRef$current$get.top;
|
|
340
|
+
|
|
341
|
+
popperProps.popperStyle = {
|
|
342
|
+
position: 'fixed',
|
|
343
|
+
left: left,
|
|
344
|
+
top: top
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
331
349
|
var addChildrenProps = function addChildrenProps(linksChildren) {
|
|
332
350
|
var _context4;
|
|
333
351
|
|
|
@@ -456,6 +474,7 @@ var InternalAnchor = function InternalAnchor(props, ref) {
|
|
|
456
474
|
type: "lock-solid"
|
|
457
475
|
});
|
|
458
476
|
return /*#__PURE__*/React.createElement("div", {
|
|
477
|
+
ref: fixedRef,
|
|
459
478
|
className: anchorAdvancedClass,
|
|
460
479
|
style: dropdownStyle
|
|
461
480
|
}, lockedIcon !== false && /*#__PURE__*/React.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));
|
|
@@ -241,6 +241,15 @@
|
|
|
241
241
|
.kd-btn-size-small.kd-btn-icon-only {
|
|
242
242
|
font-size: var(--kd-c-button-icon-font-size-small, 14px);
|
|
243
243
|
padding: 0 var(--kd-c-button-icon-spacing-padding-horizontal, 4px);
|
|
244
|
+
display: -webkit-inline-box;
|
|
245
|
+
display: -ms-inline-flexbox;
|
|
246
|
+
display: inline-flex;
|
|
247
|
+
-webkit-box-pack: center;
|
|
248
|
+
-ms-flex-pack: center;
|
|
249
|
+
justify-content: center;
|
|
250
|
+
-webkit-box-align: center;
|
|
251
|
+
-ms-flex-align: center;
|
|
252
|
+
align-items: center;
|
|
244
253
|
}
|
|
245
254
|
.kd-btn-size-small .kd-btn-group-basic-icon {
|
|
246
255
|
font-size: var(--kd-c-button-icon-font-size-small, 14px);
|
|
@@ -255,6 +264,15 @@
|
|
|
255
264
|
.kd-btn-size-middle.kd-btn-icon-only {
|
|
256
265
|
font-size: var(--kd-c-button-icon-font-size-middle, 16px);
|
|
257
266
|
padding: 0 var(--kd-c-button-icon-spacing-padding-horizontal, 4px);
|
|
267
|
+
display: -webkit-inline-box;
|
|
268
|
+
display: -ms-inline-flexbox;
|
|
269
|
+
display: inline-flex;
|
|
270
|
+
-webkit-box-pack: center;
|
|
271
|
+
-ms-flex-pack: center;
|
|
272
|
+
justify-content: center;
|
|
273
|
+
-webkit-box-align: center;
|
|
274
|
+
-ms-flex-align: center;
|
|
275
|
+
align-items: center;
|
|
258
276
|
}
|
|
259
277
|
.kd-btn-size-middle .kd-btn-group-basic-icon {
|
|
260
278
|
font-size: var(--kd-c-button-icon-font-size-middle, 16px);
|
|
@@ -269,6 +287,15 @@
|
|
|
269
287
|
.kd-btn-size-large.kd-btn-icon-only {
|
|
270
288
|
font-size: var(--kd-c-button-icon-font-size-large, 18px);
|
|
271
289
|
padding: 0 var(--kd-c-button-icon-spacing-padding-horizontal, 4px);
|
|
290
|
+
display: -webkit-inline-box;
|
|
291
|
+
display: -ms-inline-flexbox;
|
|
292
|
+
display: inline-flex;
|
|
293
|
+
-webkit-box-pack: center;
|
|
294
|
+
-ms-flex-pack: center;
|
|
295
|
+
justify-content: center;
|
|
296
|
+
-webkit-box-align: center;
|
|
297
|
+
-ms-flex-align: center;
|
|
298
|
+
align-items: center;
|
|
272
299
|
}
|
|
273
300
|
.kd-btn-size-large .kd-btn-group-basic-icon {
|
|
274
301
|
font-size: var(--kd-c-button-icon-font-size-large, 18px);
|
|
@@ -337,6 +364,15 @@
|
|
|
337
364
|
}
|
|
338
365
|
.kd-btn-loading {
|
|
339
366
|
cursor: default;
|
|
367
|
+
display: -webkit-inline-box;
|
|
368
|
+
display: -ms-inline-flexbox;
|
|
369
|
+
display: inline-flex;
|
|
370
|
+
-webkit-box-pack: center;
|
|
371
|
+
-ms-flex-pack: center;
|
|
372
|
+
justify-content: center;
|
|
373
|
+
-webkit-box-align: center;
|
|
374
|
+
-ms-flex-align: center;
|
|
375
|
+
align-items: center;
|
|
340
376
|
}
|
|
341
377
|
.kd-btn-block {
|
|
342
378
|
width: 100%;
|
|
@@ -114,6 +114,9 @@
|
|
|
114
114
|
&.@{btn-prefix-cls}-icon-only {
|
|
115
115
|
font-size: @btn-icon-small-font-size;
|
|
116
116
|
padding: 0 @btn-icon-padding-horizontal;
|
|
117
|
+
display: inline-flex;
|
|
118
|
+
justify-content: center;
|
|
119
|
+
align-items: center;
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
.@{btn-prefix-cls}-group-basic-icon {
|
|
@@ -127,6 +130,9 @@
|
|
|
127
130
|
&.@{btn-prefix-cls}-icon-only {
|
|
128
131
|
font-size: @btn-icon-middle-font-size;
|
|
129
132
|
padding: 0 @btn-icon-padding-horizontal;
|
|
133
|
+
display: inline-flex;
|
|
134
|
+
justify-content: center;
|
|
135
|
+
align-items: center;
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
.@{btn-prefix-cls}-group-basic-icon {
|
|
@@ -140,6 +146,9 @@
|
|
|
140
146
|
&.@{btn-prefix-cls}-icon-only {
|
|
141
147
|
font-size: @btn-icon-large-font-size;
|
|
142
148
|
padding: 0 @btn-icon-padding-horizontal;
|
|
149
|
+
display: inline-flex;
|
|
150
|
+
justify-content: center;
|
|
151
|
+
align-items: center;
|
|
143
152
|
}
|
|
144
153
|
|
|
145
154
|
.@{btn-prefix-cls}-group-basic-icon {
|
|
@@ -234,6 +243,9 @@
|
|
|
234
243
|
// 加载中按钮
|
|
235
244
|
&-loading {
|
|
236
245
|
cursor: default;
|
|
246
|
+
display: inline-flex;
|
|
247
|
+
justify-content: center;
|
|
248
|
+
align-items: center;
|
|
237
249
|
}
|
|
238
250
|
// 按钮开启块化撑满父元素
|
|
239
251
|
&-block {
|
|
@@ -271,11 +283,11 @@
|
|
|
271
283
|
background: @btn-group-trigger-color-background-hover;
|
|
272
284
|
border-color: @btn-group-trigger-color-background-hover;
|
|
273
285
|
}
|
|
274
|
-
|
|
286
|
+
|
|
275
287
|
&:active {
|
|
276
288
|
background: @btn-group-trigger-color-background-active;
|
|
277
289
|
}
|
|
278
|
-
|
|
290
|
+
|
|
279
291
|
&:disabled {
|
|
280
292
|
background: @btn-group-trigger-color-background-disabled !important;
|
|
281
293
|
}
|
package/es/checkbox/checkbox.js
CHANGED
|
@@ -72,6 +72,8 @@ var InternalCheckbox = function InternalCheckbox(props, ref) {
|
|
|
72
72
|
isBoolean(checked) && checked !== selected && setSelected(checked);
|
|
73
73
|
}, [checked, selected]);
|
|
74
74
|
useEffect(function () {
|
|
75
|
+
var _a;
|
|
76
|
+
|
|
75
77
|
var handleRepeatClick = function handleRepeatClick(e) {
|
|
76
78
|
var element = e.target;
|
|
77
79
|
|
|
@@ -80,10 +82,12 @@ var InternalCheckbox = function InternalCheckbox(props, ref) {
|
|
|
80
82
|
}
|
|
81
83
|
};
|
|
82
84
|
|
|
83
|
-
labelRef.current.addEventListener('click', handleRepeatClick);
|
|
85
|
+
(_a = labelRef === null || labelRef === void 0 ? void 0 : labelRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('click', handleRepeatClick);
|
|
84
86
|
return function () {
|
|
85
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
86
|
-
|
|
87
|
+
var _a; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
(_a = labelRef === null || labelRef === void 0 ? void 0 : labelRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('click', handleRepeatClick);
|
|
87
91
|
};
|
|
88
92
|
}, []);
|
|
89
93
|
|
package/es/form/Field.js
CHANGED
|
@@ -98,7 +98,8 @@ var Field = function Field(props) {
|
|
|
98
98
|
getInternalHooks = fieldContext.getInternalHooks,
|
|
99
99
|
vertical = fieldContext.vertical,
|
|
100
100
|
getDefaultValue = fieldContext.getDefaultValue,
|
|
101
|
-
local = fieldContext.local
|
|
101
|
+
local = fieldContext.local,
|
|
102
|
+
formDisabled = fieldContext.disabled;
|
|
102
103
|
|
|
103
104
|
var _getInternalHooks = getInternalHooks(INTERNAL_HOOK_KEY),
|
|
104
105
|
registerField = _getInternalHooks.registerField,
|
|
@@ -264,17 +265,17 @@ var Field = function Field(props) {
|
|
|
264
265
|
chDisabled = _ch$props.disabled,
|
|
265
266
|
chDefaultValue = _ch$props.defaultValue;
|
|
266
267
|
|
|
267
|
-
var onChange = function onChange(
|
|
268
|
+
var onChange = function onChange() {
|
|
268
269
|
if (chValue === undefined) {
|
|
269
|
-
setFieldValue(getInputValueFormProp(
|
|
270
|
+
setFieldValue(getInputValueFormProp(arguments.length <= 0 ? undefined : arguments[0]));
|
|
270
271
|
}
|
|
271
272
|
|
|
272
273
|
if (typeof faChange === 'function') {
|
|
273
|
-
faChange(
|
|
274
|
+
faChange.apply(void 0, arguments);
|
|
274
275
|
}
|
|
275
276
|
|
|
276
277
|
if (typeof chChange === 'function') {
|
|
277
|
-
chChange(
|
|
278
|
+
chChange.apply(void 0, arguments);
|
|
278
279
|
}
|
|
279
280
|
};
|
|
280
281
|
|
|
@@ -292,7 +293,7 @@ var Field = function Field(props) {
|
|
|
292
293
|
return _extends(_extends({}, rest), (_extends3 = {
|
|
293
294
|
onChange: onChange,
|
|
294
295
|
defaultValue: defaultValue
|
|
295
|
-
}, _defineProperty(_extends3, innerValuePropName, fieldValue), _defineProperty(_extends3, "disabled", chDisabled
|
|
296
|
+
}, _defineProperty(_extends3, innerValuePropName, fieldValue), _defineProperty(_extends3, "disabled", chDisabled !== undefined ? chDisabled : faDisabled !== undefined ? faDisabled : formDisabled), _extends3));
|
|
296
297
|
};
|
|
297
298
|
|
|
298
299
|
return /*#__PURE__*/React.createElement("div", {
|
package/es/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/es/form/Form.js
CHANGED
|
@@ -52,7 +52,8 @@ var Form = function Form(props, ref) {
|
|
|
52
52
|
onFinish = formProps.onFinish,
|
|
53
53
|
onFinishFailed = formProps.onFinishFailed,
|
|
54
54
|
onValuesChange = formProps.onValuesChange,
|
|
55
|
-
|
|
55
|
+
disabled = formProps.disabled,
|
|
56
|
+
restProps = __rest(formProps, ["children", "defaultValues", "className", "form", "labelAlign", "labelWidth", "layout", "name", "prefixCls", "wrapperWidth", "onFinish", "onFinishFailed", "onValuesChange", "disabled"]);
|
|
56
57
|
|
|
57
58
|
var formPrefixCls = getPrefixCls(prefixCls, 'form', customizePrefixCls);
|
|
58
59
|
var formClassName = classnames((_classnames = {}, _defineProperty(_classnames, "".concat(formPrefixCls), true), _defineProperty(_classnames, _concatInstanceProperty(_context = "".concat(formPrefixCls, "-")).call(_context, layout), true), _classnames), className);
|
|
@@ -90,6 +91,7 @@ var Form = function Form(props, ref) {
|
|
|
90
91
|
labelWidth: labelWidth,
|
|
91
92
|
wrapperWidth: wrapperWidth,
|
|
92
93
|
local: formLang,
|
|
94
|
+
disabled: disabled,
|
|
93
95
|
vertical: layout === 'vertical'
|
|
94
96
|
});
|
|
95
97
|
}, [formInstance, labelAlign, labelWidth, wrapperWidth, layout, formLang]);
|
package/es/form/interface.d.ts
CHANGED
package/es/menu/menu.js
CHANGED
|
@@ -75,31 +75,32 @@ var Menu = function Menu(props) {
|
|
|
75
75
|
openKeys = _React$useState4[0],
|
|
76
76
|
setOpenKeys = _React$useState4[1];
|
|
77
77
|
|
|
78
|
+
if (mode === 'inline') {
|
|
79
|
+
restProps.triggerSubMenuAction = 'click';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
useEffect(function () {
|
|
83
|
+
setOpenKeys([]);
|
|
84
|
+
setSelectedKey('');
|
|
85
|
+
openSubMenuSet.clear();
|
|
86
|
+
}, [mode]);
|
|
78
87
|
useEffect(function () {
|
|
79
88
|
if (userSelectedKey !== undefined) {
|
|
80
89
|
setSelectedKey(userSelectedKey);
|
|
81
90
|
}
|
|
82
91
|
}, [userSelectedKey]);
|
|
83
92
|
useEffect(function () {
|
|
84
|
-
if (userOpenKeys !== undefined) {
|
|
93
|
+
if (userOpenKeys !== undefined && Array.isArray(userOpenKeys)) {
|
|
85
94
|
setOpenKeys(userOpenKeys);
|
|
86
|
-
|
|
87
|
-
}, [userOpenKeys]);
|
|
88
|
-
useEffect(function () {
|
|
89
|
-
if (Array.isArray(userOpenKeys)) {
|
|
95
|
+
openSubMenuSet.clear();
|
|
90
96
|
userOpenKeys.forEach(function (d) {
|
|
91
97
|
openSubMenuSet.add(d);
|
|
92
98
|
});
|
|
93
99
|
}
|
|
94
|
-
}, []); //
|
|
95
|
-
|
|
96
|
-
if (mode === 'inline') {
|
|
97
|
-
restProps.triggerSubMenuAction = 'click';
|
|
98
|
-
} // React.useEffect(() => {
|
|
100
|
+
}, [userOpenKeys]); // React.useEffect(() => {
|
|
99
101
|
// setCollapsed(restProps.collapsed)
|
|
100
102
|
// }, [restProps.collapsed])
|
|
101
103
|
|
|
102
|
-
|
|
103
104
|
var handleOnClick = function handleOnClick(info) {
|
|
104
105
|
if (userSelectedKey === undefined) {
|
|
105
106
|
setSelectedKey(info.key);
|
package/es/menu/subMenu.js
CHANGED
|
@@ -31,7 +31,7 @@ import devWarning from '../_utils/devwarning';
|
|
|
31
31
|
import { MENU_ITEM_CONTAINER_NAME } from './menuItem';
|
|
32
32
|
|
|
33
33
|
var SubMenu = function SubMenu(props) {
|
|
34
|
-
var
|
|
34
|
+
var _classNames2, _classNames3, _context4;
|
|
35
35
|
|
|
36
36
|
var _React$useContext = React.useContext(ConfigContext),
|
|
37
37
|
getPrefixCls = _React$useContext.getPrefixCls,
|
|
@@ -59,8 +59,9 @@ var SubMenu = function SubMenu(props) {
|
|
|
59
59
|
handleOnOpenChange = _a.handleOnOpenChange,
|
|
60
60
|
_a$paddingLeft = _a.paddingLeft,
|
|
61
61
|
paddingLeft = _a$paddingLeft === void 0 ? 0 : _a$paddingLeft,
|
|
62
|
-
restProps = __rest(_a, ["prefixCls", "theme", "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"]);
|
|
63
63
|
|
|
64
|
+
var isVertical = mode === 'vertical'; // 初始化level
|
|
64
65
|
|
|
65
66
|
if (!restProps.level) {
|
|
66
67
|
restProps.level = 1;
|
|
@@ -82,7 +83,7 @@ var SubMenu = function SubMenu(props) {
|
|
|
82
83
|
var visible = Array.isArray(openKeys) && _includesInstanceProperty(openKeys).call(openKeys, keyValue);
|
|
83
84
|
|
|
84
85
|
React.useEffect(function () {
|
|
85
|
-
if (!visible) return;
|
|
86
|
+
if (!visible || isVertical) return;
|
|
86
87
|
var subMenuWrapperEle = subMenuWrapperRef.current;
|
|
87
88
|
var subMenuEle = subMenuRef.current;
|
|
88
89
|
|
|
@@ -187,11 +188,10 @@ var SubMenu = function SubMenu(props) {
|
|
|
187
188
|
if (!_includesInstanceProperty(className).call(className, MENU_ITEM_CONTAINER_NAME)) {
|
|
188
189
|
closeSubMenu();
|
|
189
190
|
}
|
|
190
|
-
}); // 缩略模式自动关闭子菜单
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
191
|
+
}); // // 缩略模式自动关闭子菜单
|
|
192
|
+
// if (triggerSubMenuAction === 'click' && mode === 'vertical' && collapsed) {
|
|
193
|
+
// closeSubMenu()
|
|
194
|
+
// }
|
|
195
195
|
|
|
196
196
|
var handleMouseEvent = function handleMouseEvent(status) {
|
|
197
197
|
if (disabled || triggerSubMenuAction === 'click') return;
|
|
@@ -212,7 +212,7 @@ var SubMenu = function SubMenu(props) {
|
|
|
212
212
|
// 保存路径
|
|
213
213
|
info.keyPath = _concatInstanceProperty(_context = info.keyPath).call(_context, [keyValue]);
|
|
214
214
|
|
|
215
|
-
if (triggerSubMenuAction === 'click' &&
|
|
215
|
+
if (triggerSubMenuAction === 'click' && isVertical) {
|
|
216
216
|
closeSubMenu();
|
|
217
217
|
}
|
|
218
218
|
|
|
@@ -285,53 +285,12 @@ var SubMenu = function SubMenu(props) {
|
|
|
285
285
|
var titleStyle = {
|
|
286
286
|
paddingRight: "".concat(curPaddingRight, "px"),
|
|
287
287
|
paddingLeft: "".concat(curPaddingLeft, "px")
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
if (mode !== 'vertical') {
|
|
291
|
-
var _classNames2, _context4;
|
|
292
|
-
|
|
293
|
-
return /*#__PURE__*/React.createElement("li", _extends({
|
|
294
|
-
ref: subMenuRef,
|
|
295
|
-
className: classNames(prefixCls, className, (_classNames2 = {}, _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)),
|
|
296
|
-
key: keyValue
|
|
297
|
-
}, mouseEvent, {
|
|
298
|
-
style: style
|
|
299
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
300
|
-
className: classNames("".concat(prefixCls, "-title")),
|
|
301
|
-
style: titleStyle
|
|
302
|
-
}, icon && /*#__PURE__*/React.cloneElement(renderReactNodeFunction(icon), {
|
|
303
|
-
className: classNames("".concat(prefixCls, "-icon"))
|
|
304
|
-
}), renderItemTitle(), renderItemArrow()), /*#__PURE__*/React.createElement("div", {
|
|
305
|
-
style: getCurrentStyle(),
|
|
306
|
-
ref: subMenuWrapperRef
|
|
307
|
-
}, /*#__PURE__*/React.createElement("ul", {
|
|
308
|
-
className: classNames("".concat(prefixCls, "-sub"), restProps.popupClassName)
|
|
309
|
-
}, _mapInstanceProperty(_context4 = toArray(children)).call(_context4, function (item, index) {
|
|
310
|
-
var key = item.key || index;
|
|
311
|
-
return /*#__PURE__*/React.cloneElement(item, {
|
|
312
|
-
key: key,
|
|
313
|
-
level: restProps.level + 1,
|
|
314
|
-
keyValue: key,
|
|
315
|
-
collapsed: collapsed,
|
|
316
|
-
mode: mode,
|
|
317
|
-
selectedKey: selectedKey,
|
|
318
|
-
openKeys: openKeys,
|
|
319
|
-
forceSubMenuRender: forceSubMenuRender,
|
|
320
|
-
triggerSubMenuAction: triggerSubMenuAction,
|
|
321
|
-
handleOnOpenChange: handleOnOpenChange,
|
|
322
|
-
handleOnClick: handleOnClick,
|
|
323
|
-
inlineIndent: inlineIndent,
|
|
324
|
-
paddingLeft: curPaddingLeft
|
|
325
|
-
});
|
|
326
|
-
}))));
|
|
327
|
-
} // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
288
|
+
}; // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
328
289
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
className: classNames(prefixCls, className, (_classNames3 = {}, _defineProperty(_classNames3, "light", theme === 'light'), _defineProperty(_classNames3, "".concat(prefixCls, "-collapsed"), collapsed), _defineProperty(_classNames3, "".concat(prefixCls, "-disabled"), disabled), _defineProperty(_classNames3, "".concat(prefixCls, "-hover"), !disabled && visible), _defineProperty(_classNames3, "".concat(prefixCls, "-active"), Array.isArray(openKeys) && _includesInstanceProperty(openKeys).call(openKeys, keyValue)), _classNames3)),
|
|
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)),
|
|
332
292
|
ref: subMenuVerticalRef,
|
|
333
|
-
key: keyValue
|
|
334
|
-
style: style
|
|
293
|
+
key: keyValue
|
|
335
294
|
}, {
|
|
336
295
|
onMouseLeave: handleOnMouseLeave,
|
|
337
296
|
onMouseEnter: handleOnMouseEnter,
|
|
@@ -350,8 +309,8 @@ var SubMenu = function SubMenu(props) {
|
|
|
350
309
|
handleOnMouseEnter();
|
|
351
310
|
}
|
|
352
311
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
353
|
-
className: classNames("".concat(prefixCls, "-sub"), restProps.popupClassName, (
|
|
354
|
-
}, _mapInstanceProperty(
|
|
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) {
|
|
355
314
|
var key = item.key || index;
|
|
356
315
|
return /*#__PURE__*/React.cloneElement(item, {
|
|
357
316
|
key: key,
|
|
@@ -373,10 +332,52 @@ var SubMenu = function SubMenu(props) {
|
|
|
373
332
|
arrow: false,
|
|
374
333
|
placement: 'rightTop',
|
|
375
334
|
gap: 0,
|
|
376
|
-
visible: visible,
|
|
335
|
+
visible: isVertical ? visible : false,
|
|
336
|
+
disabled: isVertical ? undefined : true,
|
|
377
337
|
prefixCls: 'kd-menu-popper',
|
|
378
338
|
popperClassName: theme === 'light' ? 'light' : ''
|
|
379
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
|
+
}
|
|
380
381
|
};
|
|
381
382
|
|
|
382
383
|
SubMenu.displayName = 'SubMenu';
|
package/es/radio/radio.js
CHANGED
|
@@ -86,6 +86,8 @@ var InternalRadio = function InternalRadio(props, ref) {
|
|
|
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
88
|
useEffect(function () {
|
|
89
|
+
var _a;
|
|
90
|
+
|
|
89
91
|
var handleRepeatClick = function handleRepeatClick(e) {
|
|
90
92
|
var element = e.target;
|
|
91
93
|
|
|
@@ -95,10 +97,12 @@ var InternalRadio = function InternalRadio(props, ref) {
|
|
|
95
97
|
};
|
|
96
98
|
|
|
97
99
|
var radioRef = mergedRef;
|
|
98
|
-
radioRef.current.addEventListener('click', handleRepeatClick);
|
|
100
|
+
(_a = radioRef === null || radioRef === void 0 ? void 0 : radioRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('click', handleRepeatClick);
|
|
99
101
|
return function () {
|
|
100
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
101
|
-
|
|
102
|
+
var _a; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
(_a = radioRef === null || radioRef === void 0 ? void 0 : radioRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('click', handleRepeatClick);
|
|
102
106
|
};
|
|
103
107
|
}, []);
|
|
104
108
|
return (
|