@douyinfe/semi-ui 2.4.0 → 2.5.0
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/cascader/__test__/cascader.test.js +24 -0
- package/cascader/_story/cascader.stories.js +73 -0
- package/cascader/index.tsx +5 -2
- package/datePicker/_story/v2/FixInputRangeFocus.jsx +25 -0
- package/datePicker/_story/v2/index.js +2 -1
- package/datePicker/datePicker.tsx +4 -0
- package/dist/css/semi.css +51 -27
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +481 -182
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/form/_story/demo.jsx +1 -0
- package/input/index.tsx +1 -0
- package/input/textarea.tsx +1 -1
- package/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/cascader/index.js +6 -0
- package/lib/cjs/datePicker/datePicker.js +16 -8
- package/lib/cjs/dropdown/index.d.ts +1 -1
- package/lib/cjs/form/baseForm.d.ts +1 -1
- package/lib/cjs/form/field.d.ts +1 -1
- package/lib/cjs/input/index.js +2 -1
- package/lib/cjs/input/textarea.js +1 -1
- package/lib/cjs/select/index.d.ts +3 -3
- package/lib/cjs/select/index.js +32 -28
- package/lib/cjs/select/option.js +2 -2
- package/lib/cjs/select/virtualRow.js +2 -2
- package/lib/cjs/table/Table.d.ts +1 -1
- package/lib/cjs/table/Table.js +8 -2
- package/lib/cjs/table/interface.d.ts +1 -0
- package/lib/cjs/tabs/interface.d.ts +1 -1
- package/lib/cjs/timePicker/TimePicker.js +2 -1
- package/lib/cjs/tooltip/index.d.ts +1 -1
- package/lib/cjs/tooltip/index.js +6 -2
- package/lib/cjs/tree/index.d.ts +2 -0
- package/lib/cjs/tree/index.js +15 -8
- package/lib/cjs/treeSelect/index.d.ts +2 -0
- package/lib/cjs/treeSelect/index.js +64 -27
- package/lib/cjs/upload/fileCard.js +31 -22
- package/lib/cjs/upload/index.d.ts +6 -0
- package/lib/cjs/upload/index.js +15 -8
- package/lib/cjs/upload/interface.d.ts +8 -6
- package/lib/es/autoComplete/index.d.ts +1 -1
- package/lib/es/cascader/index.js +5 -0
- package/lib/es/datePicker/datePicker.js +16 -8
- package/lib/es/dropdown/index.d.ts +1 -1
- package/lib/es/form/baseForm.d.ts +1 -1
- package/lib/es/form/field.d.ts +1 -1
- package/lib/es/input/index.js +2 -1
- package/lib/es/input/textarea.js +1 -1
- package/lib/es/select/index.d.ts +3 -3
- package/lib/es/select/index.js +30 -26
- package/lib/es/select/option.js +2 -2
- package/lib/es/select/virtualRow.js +2 -2
- package/lib/es/table/Table.d.ts +1 -1
- package/lib/es/table/Table.js +10 -2
- package/lib/es/table/interface.d.ts +1 -0
- package/lib/es/tabs/interface.d.ts +1 -1
- package/lib/es/timePicker/TimePicker.js +2 -1
- package/lib/es/tooltip/index.d.ts +1 -1
- package/lib/es/tooltip/index.js +6 -2
- package/lib/es/tree/index.d.ts +2 -0
- package/lib/es/tree/index.js +15 -8
- package/lib/es/treeSelect/index.d.ts +2 -0
- package/lib/es/treeSelect/index.js +64 -27
- package/lib/es/upload/fileCard.js +31 -24
- package/lib/es/upload/index.d.ts +6 -0
- package/lib/es/upload/index.js +14 -8
- package/lib/es/upload/interface.d.ts +8 -6
- package/package.json +9 -8
- package/select/index.tsx +18 -19
- package/select/option.tsx +2 -2
- package/select/virtualRow.tsx +2 -2
- package/table/Table.tsx +7 -2
- package/table/_story/table.stories.js +1 -2
- package/table/_story/v2/FixedHeaderMerge/index.jsx +98 -0
- package/table/_story/v2/FixedResizable/index.jsx +114 -0
- package/table/_story/v2/defaultFilteredValue.tsx +123 -0
- package/table/_story/v2/index.js +5 -0
- package/table/interface.ts +1 -0
- package/tabs/interface.ts +1 -1
- package/timePicker/TimePicker.tsx +1 -0
- package/tooltip/__test__/tooltip.test.js +48 -4
- package/tooltip/_story/tooltip.stories.js +83 -1
- package/tooltip/index.tsx +4 -4
- package/tree/__test__/treeMultiple.test.js +94 -0
- package/tree/_story/tree.stories.js +169 -0
- package/tree/index.tsx +12 -5
- package/treeSelect/__test__/treeMultiple.test.js +94 -0
- package/treeSelect/_story/treeSelect.stories.js +242 -0
- package/treeSelect/index.tsx +72 -40
- package/upload/_story/upload.stories.js +22 -6
- package/upload/fileCard.tsx +23 -23
- package/upload/index.tsx +15 -6
- package/upload/interface.ts +7 -5
package/lib/es/select/index.js
CHANGED
|
@@ -285,11 +285,19 @@ class Select extends BaseComponent {
|
|
|
285
285
|
el.focus();
|
|
286
286
|
} catch (error) {}
|
|
287
287
|
},
|
|
288
|
-
updateScrollTop:
|
|
289
|
-
var
|
|
288
|
+
updateScrollTop: index => {
|
|
289
|
+
var _context10, _context11;
|
|
290
290
|
|
|
291
291
|
// eslint-disable-next-line max-len
|
|
292
|
-
let
|
|
292
|
+
let optionClassName = ".".concat(prefixcls, "-option-selected");
|
|
293
|
+
|
|
294
|
+
if (index !== undefined) {
|
|
295
|
+
var _context9;
|
|
296
|
+
|
|
297
|
+
optionClassName = _concatInstanceProperty(_context9 = ".".concat(prefixcls, "-option:nth-child(")).call(_context9, index, ")");
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
let destNode = document.querySelector(_concatInstanceProperty(_context10 = _concatInstanceProperty(_context11 = "#".concat(prefixcls, "-")).call(_context11, this.selectOptionListID, " ")).call(_context10, optionClassName));
|
|
293
301
|
|
|
294
302
|
if (_Array$isArray(destNode)) {
|
|
295
303
|
// eslint-disable-next-line prefer-destructuring
|
|
@@ -317,11 +325,11 @@ class Select extends BaseComponent {
|
|
|
317
325
|
}
|
|
318
326
|
|
|
319
327
|
componentDidUpdate(prevProps, prevState) {
|
|
320
|
-
var
|
|
328
|
+
var _context12, _context13;
|
|
321
329
|
|
|
322
|
-
const prevChildrenKeys = _mapInstanceProperty(
|
|
330
|
+
const prevChildrenKeys = _mapInstanceProperty(_context12 = React.Children.toArray(prevProps.children)).call(_context12, child => child.key);
|
|
323
331
|
|
|
324
|
-
const nowChildrenKeys = _mapInstanceProperty(
|
|
332
|
+
const nowChildrenKeys = _mapInstanceProperty(_context13 = React.Children.toArray(this.props.children)).call(_context13, child => child.key);
|
|
325
333
|
|
|
326
334
|
let isOptionsChanged = false;
|
|
327
335
|
|
|
@@ -515,34 +523,30 @@ class Select extends BaseComponent {
|
|
|
515
523
|
this.foundation.handleOptionMouseEnter(optionIndex);
|
|
516
524
|
}
|
|
517
525
|
|
|
518
|
-
renderWithGroup(
|
|
526
|
+
renderWithGroup(visibleOptions) {
|
|
519
527
|
const content = [];
|
|
520
528
|
const groupStatus = new _Map();
|
|
521
529
|
|
|
522
|
-
_forEachInstanceProperty(
|
|
530
|
+
_forEachInstanceProperty(visibleOptions).call(visibleOptions, (option, optionIndex) => {
|
|
523
531
|
const parentGroup = option._parentGroup;
|
|
524
532
|
const optionContent = this.renderOption(option, optionIndex);
|
|
525
533
|
|
|
526
|
-
if (parentGroup && groupStatus.has(parentGroup.label)) {
|
|
527
|
-
// group content already insert
|
|
528
|
-
content.push(optionContent);
|
|
529
|
-
} else if (parentGroup) {
|
|
534
|
+
if (parentGroup && !groupStatus.has(parentGroup.label)) {
|
|
535
|
+
// when use with OptionGroup and group content not already insert
|
|
530
536
|
const groupContent = /*#__PURE__*/React.createElement(OptionGroup, _Object$assign({}, parentGroup, {
|
|
531
537
|
key: parentGroup.label
|
|
532
538
|
}));
|
|
533
539
|
groupStatus.set(parentGroup.label, true);
|
|
534
540
|
content.push(groupContent);
|
|
535
|
-
content.push(optionContent);
|
|
536
|
-
} else {
|
|
537
|
-
// when not use with OptionGroup
|
|
538
|
-
content.push(optionContent);
|
|
539
541
|
}
|
|
542
|
+
|
|
543
|
+
content.push(optionContent);
|
|
540
544
|
});
|
|
541
545
|
|
|
542
546
|
return content;
|
|
543
547
|
}
|
|
544
548
|
|
|
545
|
-
renderVirtualizeList(
|
|
549
|
+
renderVirtualizeList(visibleOptions) {
|
|
546
550
|
const {
|
|
547
551
|
virtualize
|
|
548
552
|
} = this.props;
|
|
@@ -557,10 +561,10 @@ class Select extends BaseComponent {
|
|
|
557
561
|
return /*#__PURE__*/React.createElement(List, {
|
|
558
562
|
ref: this.virtualizeListRef,
|
|
559
563
|
height: height || numbers.LIST_HEIGHT,
|
|
560
|
-
itemCount:
|
|
564
|
+
itemCount: visibleOptions.length,
|
|
561
565
|
itemSize: itemSize,
|
|
562
566
|
itemData: {
|
|
563
|
-
|
|
567
|
+
visibleOptions,
|
|
564
568
|
renderOption: this.renderOption
|
|
565
569
|
},
|
|
566
570
|
width: width || '100%',
|
|
@@ -571,7 +575,7 @@ class Select extends BaseComponent {
|
|
|
571
575
|
}
|
|
572
576
|
|
|
573
577
|
renderOptions(children) {
|
|
574
|
-
var
|
|
578
|
+
var _context14;
|
|
575
579
|
|
|
576
580
|
const {
|
|
577
581
|
dropdownMinWidth,
|
|
@@ -591,12 +595,12 @@ class Select extends BaseComponent {
|
|
|
591
595
|
multiple
|
|
592
596
|
} = this.props; // Do a filter first, instead of directly judging in forEach, so that the focusIndex can correspond to
|
|
593
597
|
|
|
594
|
-
const
|
|
598
|
+
const visibleOptions = _filterInstanceProperty(options).call(options, item => item._show);
|
|
595
599
|
|
|
596
|
-
let listContent = this.renderWithGroup(
|
|
600
|
+
let listContent = this.renderWithGroup(visibleOptions);
|
|
597
601
|
|
|
598
602
|
if (virtualize) {
|
|
599
|
-
listContent = this.renderVirtualizeList(
|
|
603
|
+
listContent = this.renderVirtualizeList(visibleOptions);
|
|
600
604
|
}
|
|
601
605
|
|
|
602
606
|
const style = _Object$assign({
|
|
@@ -609,7 +613,7 @@ class Select extends BaseComponent {
|
|
|
609
613
|
});
|
|
610
614
|
const isEmpty = !options.length || !_someInstanceProperty(options).call(options, item => item._show);
|
|
611
615
|
return /*#__PURE__*/React.createElement("div", {
|
|
612
|
-
id: _concatInstanceProperty(
|
|
616
|
+
id: _concatInstanceProperty(_context14 = "".concat(prefixcls, "-")).call(_context14, this.selectOptionListID),
|
|
613
617
|
className: dropdownClassName,
|
|
614
618
|
style: style
|
|
615
619
|
}, outerTopSlot, /*#__PURE__*/React.createElement("div", {
|
|
@@ -840,7 +844,7 @@ class Select extends BaseComponent {
|
|
|
840
844
|
}
|
|
841
845
|
|
|
842
846
|
renderSelection() {
|
|
843
|
-
var
|
|
847
|
+
var _context15;
|
|
844
848
|
|
|
845
849
|
const {
|
|
846
850
|
disabled,
|
|
@@ -924,7 +928,7 @@ class Select extends BaseComponent {
|
|
|
924
928
|
role: "combobox",
|
|
925
929
|
"aria-disabled": disabled,
|
|
926
930
|
"aria-expanded": isOpen,
|
|
927
|
-
"aria-controls": _concatInstanceProperty(
|
|
931
|
+
"aria-controls": _concatInstanceProperty(_context15 = "".concat(prefixcls, "-")).call(_context15, this.selectOptionListID),
|
|
928
932
|
"aria-haspopup": "listbox",
|
|
929
933
|
"aria-label": "select value",
|
|
930
934
|
"aria-invalid": this.props['aria-invalid'],
|
package/lib/es/select/option.js
CHANGED
|
@@ -36,9 +36,9 @@ class Option extends PureComponent {
|
|
|
36
36
|
const {
|
|
37
37
|
props
|
|
38
38
|
} = this;
|
|
39
|
-
const
|
|
39
|
+
const isDisabled = props.disabled;
|
|
40
40
|
|
|
41
|
-
if (!
|
|
41
|
+
if (!isDisabled) {
|
|
42
42
|
props.onSelect(_Object$assign(_Object$assign({}, rest), {
|
|
43
43
|
value,
|
|
44
44
|
label: label || children
|
package/lib/es/table/Table.d.ts
CHANGED
|
@@ -298,7 +298,7 @@ declare class Table<RecordType extends Record<string, any>> extends BaseComponen
|
|
|
298
298
|
showSizeChanger?: boolean;
|
|
299
299
|
showQuickJumper?: boolean;
|
|
300
300
|
popoverZIndex?: number;
|
|
301
|
-
popoverPosition?: "top" | "topLeft" | "topRight" | "left" | "leftTop" | "leftBottom" | "right" | "rightTop" | "rightBottom" | "bottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver";
|
|
301
|
+
popoverPosition?: "top" | "topLeft" | "topRight" | "left" | "leftTop" | "leftBottom" | "right" | "rightTop" | "rightBottom" | "bottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver";
|
|
302
302
|
hideOnSinglePage?: boolean;
|
|
303
303
|
hoverShowPageSelect?: boolean;
|
|
304
304
|
};
|
package/lib/es/table/Table.js
CHANGED
|
@@ -505,10 +505,17 @@ class Table extends BaseComponent {
|
|
|
505
505
|
titleArr.push(sorter);
|
|
506
506
|
}
|
|
507
507
|
|
|
508
|
+
const stateFilteredValue = _get(curQuery, 'filteredValue');
|
|
509
|
+
|
|
510
|
+
const defaultFilteredValue = _get(curQuery, 'defaultFilteredValue');
|
|
511
|
+
|
|
512
|
+
const filteredValue = stateFilteredValue ? stateFilteredValue : defaultFilteredValue;
|
|
513
|
+
|
|
508
514
|
if (_Array$isArray(column.filters) && column.filters.length || /*#__PURE__*/isValidElement(column.filterDropdown)) {
|
|
509
515
|
const filter = /*#__PURE__*/React.createElement(ColumnFilter, _Object$assign({
|
|
510
516
|
key: strings.DEFAULT_KEY_COLUMN_FILTER
|
|
511
517
|
}, curQuery, {
|
|
518
|
+
filteredValue: filteredValue,
|
|
512
519
|
onFilterDropdownVisibleChange: visible => _this.foundation.toggleShowFilter(dataIndex, visible),
|
|
513
520
|
onSelect: data => _this.foundation.handleFilterSelect(dataIndex, data)
|
|
514
521
|
}));
|
|
@@ -1097,11 +1104,12 @@ class Table extends BaseComponent {
|
|
|
1097
1104
|
willUpdateStates.cachedColumns = props.columns;
|
|
1098
1105
|
willUpdateStates.cachedChildren = null;
|
|
1099
1106
|
} else if (props.children && props.children !== state.cachedChildren) {
|
|
1100
|
-
const
|
|
1107
|
+
const newNestedColumns = getColumns(props.children);
|
|
1108
|
+
const newFlattenColumns = flattenColumns(newNestedColumns);
|
|
1101
1109
|
const columns = mergeColumns(state.queries, newFlattenColumns, null, false);
|
|
1102
1110
|
willUpdateStates.flattenColumns = newFlattenColumns;
|
|
1103
1111
|
willUpdateStates.queries = [...columns];
|
|
1104
|
-
willUpdateStates.cachedColumns = [...
|
|
1112
|
+
willUpdateStates.cachedColumns = [...newNestedColumns];
|
|
1105
1113
|
willUpdateStates.cachedChildren = props.children;
|
|
1106
1114
|
} // Update controlled selection column
|
|
1107
1115
|
|
|
@@ -63,6 +63,7 @@ export interface ColumnProps<RecordType extends Record<string, any> = any> {
|
|
|
63
63
|
className?: string;
|
|
64
64
|
colSpan?: number;
|
|
65
65
|
dataIndex?: string;
|
|
66
|
+
defaultFilteredValue?: any[];
|
|
66
67
|
defaultSortOrder?: SortOrder;
|
|
67
68
|
filterChildrenRecord?: boolean;
|
|
68
69
|
filterDropdown?: React.ReactNode;
|
|
@@ -296,6 +296,7 @@ export default class TimePicker extends BaseComponent {
|
|
|
296
296
|
panelFooter,
|
|
297
297
|
rangeSeparator,
|
|
298
298
|
onOpenChange,
|
|
299
|
+
onChangeWithDateFirst,
|
|
299
300
|
popupClassName: propPopupClassName,
|
|
300
301
|
hideDisabledOptions,
|
|
301
302
|
use12Hours,
|
|
@@ -307,7 +308,7 @@ export default class TimePicker extends BaseComponent {
|
|
|
307
308
|
motion,
|
|
308
309
|
autoAdjustOverflow
|
|
309
310
|
} = _a,
|
|
310
|
-
rest = __rest(_a, ["prefixCls", "placeholder", "disabled", "defaultValue", "className", "popupStyle", "size", "style", "locale", "localeCode", "zIndex", "getPopupContainer", "insetLabel", "insetLabelId", "inputStyle", "showClear", "panelHeader", "panelFooter", "rangeSeparator", "onOpenChange", "popupClassName", "hideDisabledOptions", "use12Hours", "minuteStep", "hourStep", "secondStep", "scrollItemProps", "triggerRender", "motion", "autoAdjustOverflow"]);
|
|
311
|
+
rest = __rest(_a, ["prefixCls", "placeholder", "disabled", "defaultValue", "className", "popupStyle", "size", "style", "locale", "localeCode", "zIndex", "getPopupContainer", "insetLabel", "insetLabelId", "inputStyle", "showClear", "panelHeader", "panelFooter", "rangeSeparator", "onOpenChange", "onChangeWithDateFirst", "popupClassName", "hideDisabledOptions", "use12Hours", "minuteStep", "hourStep", "secondStep", "scrollItemProps", "triggerRender", "motion", "autoAdjustOverflow"]);
|
|
311
312
|
|
|
312
313
|
const format = this.foundation.getDefaultFormatIfNeed();
|
|
313
314
|
const position = this.foundation.getPosition();
|
|
@@ -67,7 +67,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
67
67
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
68
68
|
motion: PropTypes.Requireable<boolean | object>;
|
|
69
69
|
autoAdjustOverflow: PropTypes.Requireable<boolean>;
|
|
70
|
-
position: PropTypes.Requireable<"top" | "topLeft" | "topRight" | "left" | "leftTop" | "leftBottom" | "right" | "rightTop" | "rightBottom" | "bottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver">;
|
|
70
|
+
position: PropTypes.Requireable<"top" | "topLeft" | "topRight" | "left" | "leftTop" | "leftBottom" | "right" | "rightTop" | "rightBottom" | "bottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver">;
|
|
71
71
|
getPopupContainer: PropTypes.Requireable<(...args: any[]) => any>;
|
|
72
72
|
mouseEnterDelay: PropTypes.Requireable<number>;
|
|
73
73
|
mouseLeaveDelay: PropTypes.Requireable<number>;
|
package/lib/es/tooltip/index.js
CHANGED
|
@@ -443,11 +443,15 @@ export default class Tooltip extends BaseComponent {
|
|
|
443
443
|
}
|
|
444
444
|
};
|
|
445
445
|
|
|
446
|
-
document.addEventListener('
|
|
446
|
+
document.addEventListener('mousedown', this.clickOutsideHandler, {
|
|
447
|
+
capture: true
|
|
448
|
+
});
|
|
447
449
|
},
|
|
448
450
|
unregisterClickOutsideHandler: () => {
|
|
449
451
|
if (this.clickOutsideHandler) {
|
|
450
|
-
document.removeEventListener('
|
|
452
|
+
document.removeEventListener('mousedown', this.clickOutsideHandler, {
|
|
453
|
+
capture: true
|
|
454
|
+
});
|
|
451
455
|
this.clickOutsideHandler = null;
|
|
452
456
|
}
|
|
453
457
|
},
|
package/lib/es/tree/index.d.ts
CHANGED
|
@@ -70,6 +70,7 @@ declare class Tree extends BaseComponent<TreeProps, TreeState> {
|
|
|
70
70
|
onDragStart: PropTypes.Requireable<(...args: any[]) => any>;
|
|
71
71
|
onDrop: PropTypes.Requireable<(...args: any[]) => any>;
|
|
72
72
|
labelEllipsis: PropTypes.Requireable<boolean>;
|
|
73
|
+
checkRelation: PropTypes.Requireable<string>;
|
|
73
74
|
'aria-label': PropTypes.Requireable<string>;
|
|
74
75
|
};
|
|
75
76
|
static defaultProps: {
|
|
@@ -90,6 +91,7 @@ declare class Tree extends BaseComponent<TreeProps, TreeState> {
|
|
|
90
91
|
disableStrictly: boolean;
|
|
91
92
|
draggable: boolean;
|
|
92
93
|
autoExpandWhenDragEnter: boolean;
|
|
94
|
+
checkRelation: string;
|
|
93
95
|
};
|
|
94
96
|
static TreeNode: typeof TreeNode;
|
|
95
97
|
inputRef: React.RefObject<typeof Input>;
|
package/lib/es/tree/index.js
CHANGED
|
@@ -177,6 +177,7 @@ class Tree extends BaseComponent {
|
|
|
177
177
|
selectedKeys: [],
|
|
178
178
|
checkedKeys: new _Set(),
|
|
179
179
|
halfCheckedKeys: new _Set(),
|
|
180
|
+
realCheckedKeys: new _Set([]),
|
|
180
181
|
motionKeys: new _Set([]),
|
|
181
182
|
motionType: 'hide',
|
|
182
183
|
expandedKeys: new _Set(props.expandedKeys),
|
|
@@ -387,12 +388,16 @@ class Tree extends BaseComponent {
|
|
|
387
388
|
}
|
|
388
389
|
|
|
389
390
|
if (checkedKeyValues) {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
391
|
+
if (props.checkRelation === 'unRelated') {
|
|
392
|
+
newState.realCheckedKeys = new _Set(checkedKeyValues);
|
|
393
|
+
} else if (props.checkRelation === 'related') {
|
|
394
|
+
const {
|
|
395
|
+
checkedKeys,
|
|
396
|
+
halfCheckedKeys
|
|
397
|
+
} = calcCheckedKeys(checkedKeyValues, keyEntities);
|
|
398
|
+
newState.checkedKeys = checkedKeys;
|
|
399
|
+
newState.halfCheckedKeys = halfCheckedKeys;
|
|
400
|
+
}
|
|
396
401
|
}
|
|
397
402
|
} // update loadedKeys
|
|
398
403
|
|
|
@@ -402,7 +407,7 @@ class Tree extends BaseComponent {
|
|
|
402
407
|
} // update disableStrictly
|
|
403
408
|
|
|
404
409
|
|
|
405
|
-
if (treeData && props.disableStrictly) {
|
|
410
|
+
if (treeData && props.disableStrictly && props.checkRelation === 'related') {
|
|
406
411
|
newState.disabledKeys = calcDisabledKeys(keyEntities);
|
|
407
412
|
}
|
|
408
413
|
|
|
@@ -723,6 +728,7 @@ Tree.propTypes = {
|
|
|
723
728
|
onDragStart: PropTypes.func,
|
|
724
729
|
onDrop: PropTypes.func,
|
|
725
730
|
labelEllipsis: PropTypes.bool,
|
|
731
|
+
checkRelation: PropTypes.string,
|
|
726
732
|
'aria-label': PropTypes.string
|
|
727
733
|
};
|
|
728
734
|
Tree.defaultProps = {
|
|
@@ -742,7 +748,8 @@ Tree.defaultProps = {
|
|
|
742
748
|
expandAction: false,
|
|
743
749
|
disableStrictly: false,
|
|
744
750
|
draggable: false,
|
|
745
|
-
autoExpandWhenDragEnter: true
|
|
751
|
+
autoExpandWhenDragEnter: true,
|
|
752
|
+
checkRelation: 'related'
|
|
746
753
|
};
|
|
747
754
|
Tree.TreeNode = TreeNode;
|
|
748
755
|
export default Tree;
|
|
@@ -168,6 +168,7 @@ declare class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState>
|
|
|
168
168
|
optionListStyle: PropTypes.Requireable<object>;
|
|
169
169
|
searchRender: PropTypes.Requireable<boolean | ((...args: any[]) => any)>;
|
|
170
170
|
renderSelectedItem: PropTypes.Requireable<(...args: any[]) => any>;
|
|
171
|
+
checkRelation: PropTypes.Requireable<string>;
|
|
171
172
|
'aria-label': PropTypes.Requireable<string>;
|
|
172
173
|
};
|
|
173
174
|
static defaultProps: Partial<TreeSelectProps>;
|
|
@@ -192,6 +193,7 @@ declare class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState>
|
|
|
192
193
|
removeTag: (removedKey: TreeNodeData['key']) => void;
|
|
193
194
|
handleClick: (e: React.MouseEvent) => void;
|
|
194
195
|
handleSelectionEnterPress: (e: React.KeyboardEvent<HTMLDivElement>) => void;
|
|
196
|
+
hasValue: () => boolean;
|
|
195
197
|
showClearBtn: () => boolean;
|
|
196
198
|
renderTagList: () => React.ReactNode[];
|
|
197
199
|
/**
|
|
@@ -115,34 +115,52 @@ class TreeSelect extends BaseComponent {
|
|
|
115
115
|
this.foundation.handleSelectionEnterPress(e);
|
|
116
116
|
};
|
|
117
117
|
|
|
118
|
-
this.
|
|
118
|
+
this.hasValue = () => {
|
|
119
119
|
const {
|
|
120
|
-
|
|
120
|
+
multiple,
|
|
121
|
+
checkRelation
|
|
121
122
|
} = this.props;
|
|
122
123
|
const {
|
|
123
|
-
|
|
124
|
+
realCheckedKeys,
|
|
125
|
+
checkedKeys,
|
|
126
|
+
selectedKeys
|
|
124
127
|
} = this.state;
|
|
125
|
-
|
|
128
|
+
let hasValue = false;
|
|
129
|
+
|
|
130
|
+
if (multiple) {
|
|
131
|
+
if (checkRelation === 'related') {
|
|
132
|
+
hasValue = Boolean(checkedKeys.size);
|
|
133
|
+
} else if (checkRelation === 'unRelated') {
|
|
134
|
+
hasValue = Boolean(realCheckedKeys.size);
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
hasValue = Boolean(selectedKeys.length);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return hasValue;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
this.showClearBtn = () => {
|
|
126
144
|
const {
|
|
127
145
|
showClear,
|
|
128
146
|
disabled,
|
|
129
|
-
|
|
147
|
+
searchPosition
|
|
130
148
|
} = this.props;
|
|
131
149
|
const {
|
|
132
|
-
|
|
133
|
-
checkedKeys,
|
|
150
|
+
inputValue,
|
|
134
151
|
isOpen,
|
|
135
152
|
isHovering
|
|
136
153
|
} = this.state;
|
|
137
|
-
const
|
|
138
|
-
return showClear && (hasValue || triggerSearchHasInputValue) && !disabled && (isOpen || isHovering);
|
|
154
|
+
const triggerSearchHasInputValue = searchPosition === strings.SEARCH_POSITION_TRIGGER && inputValue;
|
|
155
|
+
return showClear && (this.hasValue() || triggerSearchHasInputValue) && !disabled && (isOpen || isHovering);
|
|
139
156
|
};
|
|
140
157
|
|
|
141
158
|
this.renderTagList = () => {
|
|
142
159
|
const {
|
|
143
160
|
checkedKeys,
|
|
144
161
|
keyEntities,
|
|
145
|
-
disabledKeys
|
|
162
|
+
disabledKeys,
|
|
163
|
+
realCheckedKeys
|
|
146
164
|
} = this.state;
|
|
147
165
|
const {
|
|
148
166
|
treeNodeLabelProp,
|
|
@@ -150,13 +168,21 @@ class TreeSelect extends BaseComponent {
|
|
|
150
168
|
disabled,
|
|
151
169
|
disableStrictly,
|
|
152
170
|
size,
|
|
171
|
+
checkRelation,
|
|
153
172
|
renderSelectedItem: propRenderSelectedItem
|
|
154
173
|
} = this.props;
|
|
155
174
|
const renderSelectedItem = _isFunction(propRenderSelectedItem) ? propRenderSelectedItem : item => ({
|
|
156
175
|
isRenderInTag: true,
|
|
157
176
|
content: _get(item, treeNodeLabelProp, null)
|
|
158
177
|
});
|
|
159
|
-
|
|
178
|
+
let renderKeys = [];
|
|
179
|
+
|
|
180
|
+
if (checkRelation === 'related') {
|
|
181
|
+
renderKeys = normalizeKeyList([...checkedKeys], keyEntities, leafOnly);
|
|
182
|
+
} else if (checkRelation === 'unRelated') {
|
|
183
|
+
renderKeys = [...realCheckedKeys];
|
|
184
|
+
}
|
|
185
|
+
|
|
160
186
|
const tagList = []; // eslint-disable-next-line @typescript-eslint/no-shadow
|
|
161
187
|
|
|
162
188
|
_forEachInstanceProperty(renderKeys).call(renderKeys, key => {
|
|
@@ -245,11 +271,6 @@ class TreeSelect extends BaseComponent {
|
|
|
245
271
|
searchPosition,
|
|
246
272
|
filterTreeNode
|
|
247
273
|
} = this.props;
|
|
248
|
-
const {
|
|
249
|
-
selectedKeys,
|
|
250
|
-
checkedKeys
|
|
251
|
-
} = this.state;
|
|
252
|
-
const hasValue = multiple ? Boolean(checkedKeys.size) : Boolean(selectedKeys.length);
|
|
253
274
|
const isTriggerPositionSearch = filterTreeNode && searchPosition === strings.SEARCH_POSITION_TRIGGER; // searchPosition = trigger
|
|
254
275
|
|
|
255
276
|
if (isTriggerPositionSearch) {
|
|
@@ -257,7 +278,7 @@ class TreeSelect extends BaseComponent {
|
|
|
257
278
|
} // searchPosition = dropdown and single seleciton
|
|
258
279
|
|
|
259
280
|
|
|
260
|
-
if (!multiple || !hasValue) {
|
|
281
|
+
if (!multiple || !this.hasValue()) {
|
|
261
282
|
const renderText = this.foundation.getRenderTextInSingle();
|
|
262
283
|
const spanCls = cls({
|
|
263
284
|
["".concat(prefixcls, "-selection-placeholder")]: !renderText
|
|
@@ -514,14 +535,23 @@ class TreeSelect extends BaseComponent {
|
|
|
514
535
|
size,
|
|
515
536
|
searchAutoFocus,
|
|
516
537
|
placeholder,
|
|
517
|
-
maxTagCount
|
|
538
|
+
maxTagCount,
|
|
539
|
+
checkRelation
|
|
518
540
|
} = this.props;
|
|
519
541
|
const {
|
|
520
542
|
keyEntities,
|
|
521
543
|
checkedKeys,
|
|
522
|
-
inputValue
|
|
544
|
+
inputValue,
|
|
545
|
+
realCheckedKeys
|
|
523
546
|
} = this.state;
|
|
524
|
-
|
|
547
|
+
let keyList = [];
|
|
548
|
+
|
|
549
|
+
if (checkRelation === 'related') {
|
|
550
|
+
keyList = normalizeKeyList(checkedKeys, keyEntities, leafOnly);
|
|
551
|
+
} else if (checkRelation === 'unRelated') {
|
|
552
|
+
keyList = [...realCheckedKeys];
|
|
553
|
+
}
|
|
554
|
+
|
|
525
555
|
return /*#__PURE__*/React.createElement(TagInput, {
|
|
526
556
|
maxTagCount: maxTagCount,
|
|
527
557
|
disabled: disabled,
|
|
@@ -846,6 +876,7 @@ class TreeSelect extends BaseComponent {
|
|
|
846
876
|
selectedKeys: [],
|
|
847
877
|
checkedKeys: new _Set(),
|
|
848
878
|
halfCheckedKeys: new _Set(),
|
|
879
|
+
realCheckedKeys: new _Set([]),
|
|
849
880
|
disabledKeys: new _Set(),
|
|
850
881
|
motionKeys: new _Set([]),
|
|
851
882
|
motionType: 'hide',
|
|
@@ -966,12 +997,16 @@ class TreeSelect extends BaseComponent {
|
|
|
966
997
|
}
|
|
967
998
|
|
|
968
999
|
if (checkedKeyValues) {
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
1000
|
+
if (props.checkRelation === 'unRelated') {
|
|
1001
|
+
newState.realCheckedKeys = new _Set(checkedKeyValues);
|
|
1002
|
+
} else if (props.checkRelation === 'related') {
|
|
1003
|
+
const {
|
|
1004
|
+
checkedKeys,
|
|
1005
|
+
halfCheckedKeys
|
|
1006
|
+
} = calcCheckedKeys(checkedKeyValues, keyEntities);
|
|
1007
|
+
newState.checkedKeys = checkedKeys;
|
|
1008
|
+
newState.halfCheckedKeys = halfCheckedKeys;
|
|
1009
|
+
}
|
|
975
1010
|
}
|
|
976
1011
|
} // loadedKeys
|
|
977
1012
|
|
|
@@ -986,7 +1021,7 @@ class TreeSelect extends BaseComponent {
|
|
|
986
1021
|
} // ================ disableStrictly =================
|
|
987
1022
|
|
|
988
1023
|
|
|
989
|
-
if (treeData && props.disableStrictly) {
|
|
1024
|
+
if (treeData && props.disableStrictly && props.checkRelation === 'related') {
|
|
990
1025
|
newState.disabledKeys = calcDisabledKeys(keyEntities);
|
|
991
1026
|
}
|
|
992
1027
|
|
|
@@ -1252,6 +1287,7 @@ TreeSelect.propTypes = {
|
|
|
1252
1287
|
optionListStyle: PropTypes.object,
|
|
1253
1288
|
searchRender: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
|
|
1254
1289
|
renderSelectedItem: PropTypes.func,
|
|
1290
|
+
checkRelation: PropTypes.string,
|
|
1255
1291
|
'aria-label': PropTypes.string
|
|
1256
1292
|
};
|
|
1257
1293
|
TreeSelect.defaultProps = {
|
|
@@ -1280,6 +1316,7 @@ TreeSelect.defaultProps = {
|
|
|
1280
1316
|
expandAction: false,
|
|
1281
1317
|
clickToHide: true,
|
|
1282
1318
|
searchAutoFocus: false,
|
|
1319
|
+
checkRelation: 'related',
|
|
1283
1320
|
'aria-label': 'TreeSelect'
|
|
1284
1321
|
};
|
|
1285
1322
|
export default TreeSelect;
|