@douyinfe/semi-ui 2.4.1 → 2.5.0-beta.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/dist/css/semi.css +50 -27
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +398 -139
- 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/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/cascader/index.js +6 -0
- 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/select/index.d.ts +1 -1
- package/lib/cjs/select/option.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/tooltip/index.d.ts +1 -1
- 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/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/select/index.d.ts +1 -1
- package/lib/es/select/option.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/tooltip/index.d.ts +1 -1
- 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 -9
- package/select/option.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/defaultFilteredValue.tsx +123 -0
- package/table/_story/v2/index.js +4 -0
- package/table/interface.ts +1 -0
- package/tabs/interface.ts +1 -1
- package/tooltip/_story/tooltip.stories.js +83 -1
- 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/cjs/upload/index.js
CHANGED
|
@@ -16,6 +16,8 @@ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
|
|
|
16
16
|
|
|
17
17
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
18
18
|
|
|
19
|
+
var _pick2 = _interopRequireDefault(require("lodash/pick"));
|
|
20
|
+
|
|
19
21
|
var _noop2 = _interopRequireDefault(require("lodash/noop"));
|
|
20
22
|
|
|
21
23
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -136,14 +138,14 @@ class Upload extends _baseComponent.default {
|
|
|
136
138
|
previewFile,
|
|
137
139
|
listType,
|
|
138
140
|
itemStyle,
|
|
139
|
-
showRetry,
|
|
140
141
|
showPicInfo,
|
|
141
142
|
renderPicInfo,
|
|
143
|
+
renderPicPreviewIcon,
|
|
144
|
+
renderFileOperation,
|
|
142
145
|
renderFileItem,
|
|
143
146
|
renderThumbnail,
|
|
144
147
|
disabled,
|
|
145
|
-
onPreviewClick
|
|
146
|
-
showReplace
|
|
148
|
+
onPreviewClick
|
|
147
149
|
} = this.props;
|
|
148
150
|
|
|
149
151
|
const onRemove = () => this.remove(file);
|
|
@@ -156,20 +158,20 @@ class Upload extends _baseComponent.default {
|
|
|
156
158
|
this.replace(index);
|
|
157
159
|
};
|
|
158
160
|
|
|
159
|
-
const fileCardProps = (0, _assign.default)((0, _assign.default)({}, file), {
|
|
161
|
+
const fileCardProps = (0, _assign.default)((0, _assign.default)((0, _assign.default)({}, (0, _pick2.default)(this.props, ['showRetry', 'showReplace', ''])), file), {
|
|
160
162
|
previewFile,
|
|
161
163
|
listType,
|
|
162
164
|
onRemove,
|
|
163
165
|
onRetry,
|
|
164
166
|
index,
|
|
165
167
|
key: uid || (0, _concat.default)(_context = "".concat(name)).call(_context, index),
|
|
166
|
-
showRetry: typeof file.showRetry !== 'undefined' ? file.showRetry : showRetry,
|
|
167
168
|
style: itemStyle,
|
|
168
169
|
disabled,
|
|
169
170
|
showPicInfo,
|
|
170
171
|
renderPicInfo,
|
|
172
|
+
renderPicPreviewIcon,
|
|
173
|
+
renderFileOperation,
|
|
171
174
|
renderThumbnail,
|
|
172
|
-
showReplace: typeof file.showReplace !== 'undefined' ? file.showReplace : showReplace,
|
|
173
175
|
onReplace,
|
|
174
176
|
onPreviewClick: typeof onPreviewClick !== 'undefined' ? () => this.foundation.handlePreviewClick(file) : undefined
|
|
175
177
|
});
|
|
@@ -211,7 +213,8 @@ class Upload extends _baseComponent.default {
|
|
|
211
213
|
limit,
|
|
212
214
|
disabled,
|
|
213
215
|
children,
|
|
214
|
-
draggable
|
|
216
|
+
draggable,
|
|
217
|
+
hotSpotLocation
|
|
215
218
|
} = this.props;
|
|
216
219
|
const {
|
|
217
220
|
fileList: stateFileList,
|
|
@@ -269,7 +272,7 @@ class Upload extends _baseComponent.default {
|
|
|
269
272
|
className: mainCls,
|
|
270
273
|
role: "list",
|
|
271
274
|
"aria-label": "picture list"
|
|
272
|
-
}, (0, _map.default)(fileList).call(fileList, (file, index) => this.renderFile(file, index, locale)), showAddTriggerInList ? addContent : null)));
|
|
275
|
+
}, showAddTriggerInList && hotSpotLocation === 'start' ? addContent : null, (0, _map.default)(fileList).call(fileList, (file, index) => this.renderFile(file, index, locale)), showAddTriggerInList && hotSpotLocation === 'end' ? addContent : null)));
|
|
273
276
|
};
|
|
274
277
|
|
|
275
278
|
this.renderFileListDefault = () => {
|
|
@@ -609,6 +612,7 @@ Upload.propTypes = {
|
|
|
609
612
|
fileList: _propTypes.default.array,
|
|
610
613
|
fileName: _propTypes.default.string,
|
|
611
614
|
headers: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.func]),
|
|
615
|
+
hotSpotLocation: _propTypes.default.oneOf(['start', 'end']),
|
|
612
616
|
itemStyle: _propTypes.default.object,
|
|
613
617
|
limit: _propTypes.default.number,
|
|
614
618
|
listType: _propTypes.default.oneOf(_constants.strings.LIST_TYPE),
|
|
@@ -634,6 +638,8 @@ Upload.propTypes = {
|
|
|
634
638
|
prompt: _propTypes.default.node,
|
|
635
639
|
promptPosition: _propTypes.default.oneOf(_constants.strings.PROMPT_POSITION),
|
|
636
640
|
renderFileItem: _propTypes.default.func,
|
|
641
|
+
renderPicPreviewIcon: _propTypes.default.func,
|
|
642
|
+
renderFileOperation: _propTypes.default.func,
|
|
637
643
|
renderPicInfo: _propTypes.default.func,
|
|
638
644
|
renderThumbnail: _propTypes.default.func,
|
|
639
645
|
showClear: _propTypes.default.bool,
|
|
@@ -653,6 +659,7 @@ Upload.defaultProps = {
|
|
|
653
659
|
defaultFileList: [],
|
|
654
660
|
disabled: false,
|
|
655
661
|
listType: 'list',
|
|
662
|
+
hotSpotLocation: 'end',
|
|
656
663
|
multiple: false,
|
|
657
664
|
onAcceptInvalid: _noop2.default,
|
|
658
665
|
onChange: _noop2.default,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode, CSSProperties
|
|
1
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
2
2
|
import { BaseFileItem } from '@douyinfe/semi-foundation/lib/cjs/upload/foundation';
|
|
3
3
|
import { strings } from '@douyinfe/semi-foundation/lib/cjs/upload/constants';
|
|
4
4
|
import { ArrayElement } from '../_base/base';
|
|
@@ -45,14 +45,16 @@ export interface RenderFileItemProps extends FileItem {
|
|
|
45
45
|
index?: number;
|
|
46
46
|
previewFile?: (fileItem: RenderFileItemProps) => ReactNode;
|
|
47
47
|
listType: UploadListType;
|
|
48
|
-
onRemove: (
|
|
49
|
-
onRetry: (
|
|
50
|
-
onReplace: (
|
|
48
|
+
onRemove: () => void;
|
|
49
|
+
onRetry: () => void;
|
|
50
|
+
onReplace: () => void;
|
|
51
51
|
key: string;
|
|
52
52
|
showPicInfo?: boolean;
|
|
53
53
|
renderPicInfo?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
renderPicPreviewIcon?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
55
|
+
renderFileOperation?: (fileItem: RenderFileItemProps) => ReactNode;
|
|
56
|
+
showRetry?: boolean;
|
|
57
|
+
showReplace?: boolean;
|
|
56
58
|
style?: CSSProperties;
|
|
57
59
|
disabled: boolean;
|
|
58
60
|
onPreviewClick: () => void;
|
|
@@ -113,7 +113,7 @@ declare class AutoComplete<T extends AutoCompleteItems> extends BaseComponent<Au
|
|
|
113
113
|
onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
114
114
|
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
115
115
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
116
|
-
position: PropTypes.Requireable<"top" | "topLeft" | "topRight" | "left" | "leftTop" | "leftBottom" | "right" | "rightTop" | "rightBottom" | "bottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver">;
|
|
116
|
+
position: PropTypes.Requireable<"top" | "topLeft" | "topRight" | "left" | "leftTop" | "leftBottom" | "right" | "rightTop" | "rightBottom" | "bottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver">;
|
|
117
117
|
placeholder: PropTypes.Requireable<string>;
|
|
118
118
|
prefix: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
119
119
|
onChangeWithObject: PropTypes.Requireable<boolean>;
|
package/lib/es/cascader/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import _isFunction from "lodash/isFunction";
|
|
|
5
5
|
import _isEmpty from "lodash/isEmpty";
|
|
6
6
|
import _isString from "lodash/isString";
|
|
7
7
|
import _isEqual from "lodash/isEqual";
|
|
8
|
+
import _isSet from "lodash/isSet";
|
|
8
9
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
9
10
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
10
11
|
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
@@ -722,6 +723,10 @@ class Cascader extends BaseComponent {
|
|
|
722
723
|
realKeys = formatKeys;
|
|
723
724
|
}
|
|
724
725
|
|
|
726
|
+
if (_isSet(realKeys)) {
|
|
727
|
+
realKeys = [...realKeys];
|
|
728
|
+
}
|
|
729
|
+
|
|
725
730
|
const calRes = calcCheckedKeys(_flatten(realKeys), keyEntities);
|
|
726
731
|
const checkedKeys = new _Set(calRes.checkedKeys);
|
|
727
732
|
const halfCheckedKeys = new _Set(calRes.halfCheckedKeys); // disableStrictly
|
|
@@ -58,7 +58,7 @@ declare class Dropdown extends BaseComponent<DropdownProps, DropdownState> {
|
|
|
58
58
|
render: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
59
59
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
60
60
|
visible: PropTypes.Requireable<boolean>;
|
|
61
|
-
position: PropTypes.Requireable<"top" | "topLeft" | "topRight" | "left" | "leftTop" | "leftBottom" | "right" | "rightTop" | "rightBottom" | "bottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver">;
|
|
61
|
+
position: PropTypes.Requireable<"top" | "topLeft" | "topRight" | "left" | "leftTop" | "leftBottom" | "right" | "rightTop" | "rightBottom" | "bottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver">;
|
|
62
62
|
getPopupContainer: PropTypes.Requireable<(...args: any[]) => any>;
|
|
63
63
|
mouseEnterDelay: PropTypes.Requireable<number>;
|
|
64
64
|
mouseLeaveDelay: PropTypes.Requireable<number>;
|
|
@@ -80,7 +80,7 @@ declare class Form extends BaseComponent<BaseFormProps, BaseFormState> {
|
|
|
80
80
|
emptyContent?: React.ReactNode;
|
|
81
81
|
onDropdownVisibleChange?: (visible: boolean) => void;
|
|
82
82
|
zIndex?: number;
|
|
83
|
-
position?: "top" | "topLeft" | "topRight" | "left" | "leftTop" | "leftBottom" | "right" | "rightTop" | "rightBottom" | "bottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver";
|
|
83
|
+
position?: "top" | "topLeft" | "topRight" | "left" | "leftTop" | "leftBottom" | "right" | "rightTop" | "rightBottom" | "bottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver";
|
|
84
84
|
onSearch?: (value: string) => void;
|
|
85
85
|
dropdownClassName?: string;
|
|
86
86
|
dropdownStyle?: React.CSSProperties;
|
package/lib/es/form/field.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ declare const FormSelect: import("react").ComponentType<import("utility-types").
|
|
|
28
28
|
emptyContent?: import("react").ReactNode;
|
|
29
29
|
onDropdownVisibleChange?: (visible: boolean) => void;
|
|
30
30
|
zIndex?: number;
|
|
31
|
-
position?: "top" | "topLeft" | "topRight" | "left" | "leftTop" | "leftBottom" | "right" | "rightTop" | "rightBottom" | "bottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver";
|
|
31
|
+
position?: "top" | "topLeft" | "topRight" | "left" | "leftTop" | "leftBottom" | "right" | "rightTop" | "rightBottom" | "bottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver";
|
|
32
32
|
onSearch?: (value: string) => void;
|
|
33
33
|
dropdownClassName?: string;
|
|
34
34
|
dropdownStyle?: import("react").CSSProperties;
|
package/lib/es/select/index.d.ts
CHANGED
|
@@ -165,7 +165,7 @@ declare class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
165
165
|
emptyContent: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
166
166
|
onDropdownVisibleChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
167
167
|
zIndex: PropTypes.Requireable<number>;
|
|
168
|
-
position: PropTypes.Requireable<"top" | "topLeft" | "topRight" | "left" | "leftTop" | "leftBottom" | "right" | "rightTop" | "rightBottom" | "bottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver">;
|
|
168
|
+
position: PropTypes.Requireable<"top" | "topLeft" | "topRight" | "left" | "leftTop" | "leftBottom" | "right" | "rightTop" | "rightBottom" | "bottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver">;
|
|
169
169
|
onSearch: PropTypes.Requireable<(...args: any[]) => any>;
|
|
170
170
|
getPopupContainer: PropTypes.Requireable<(...args: any[]) => any>;
|
|
171
171
|
dropdownClassName: PropTypes.Requireable<string>;
|
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;
|
|
@@ -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/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;
|