@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
|
@@ -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>;
|
|
@@ -42,6 +42,8 @@ var _isString2 = _interopRequireDefault(require("lodash/isString"));
|
|
|
42
42
|
|
|
43
43
|
var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
|
|
44
44
|
|
|
45
|
+
var _isSet2 = _interopRequireDefault(require("lodash/isSet"));
|
|
46
|
+
|
|
45
47
|
var _react = _interopRequireWildcard(require("react"));
|
|
46
48
|
|
|
47
49
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
@@ -776,6 +778,10 @@ class Cascader extends _baseComponent.default {
|
|
|
776
778
|
realKeys = formatKeys;
|
|
777
779
|
}
|
|
778
780
|
|
|
781
|
+
if ((0, _isSet2.default)(realKeys)) {
|
|
782
|
+
realKeys = [...realKeys];
|
|
783
|
+
}
|
|
784
|
+
|
|
779
785
|
const calRes = (0, _treeUtil.calcCheckedKeys)((0, _flatten2.default)(realKeys), keyEntities);
|
|
780
786
|
const checkedKeys = new _set.default(calRes.checkedKeys);
|
|
781
787
|
const halfCheckedKeys = new _set.default(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/cjs/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;
|
|
@@ -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/cjs/select/option.js
CHANGED
|
@@ -65,9 +65,9 @@ class Option extends _react.PureComponent {
|
|
|
65
65
|
const {
|
|
66
66
|
props
|
|
67
67
|
} = this;
|
|
68
|
-
const
|
|
68
|
+
const isDisabled = props.disabled;
|
|
69
69
|
|
|
70
|
-
if (!
|
|
70
|
+
if (!isDisabled) {
|
|
71
71
|
props.onSelect((0, _assign.default)((0, _assign.default)({}, rest), {
|
|
72
72
|
value,
|
|
73
73
|
label: label || children
|
package/lib/cjs/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/cjs/table/Table.js
CHANGED
|
@@ -566,10 +566,15 @@ class Table extends _baseComponent.default {
|
|
|
566
566
|
titleArr.push(sorter);
|
|
567
567
|
}
|
|
568
568
|
|
|
569
|
+
const stateFilteredValue = (0, _get2.default)(curQuery, 'filteredValue');
|
|
570
|
+
const defaultFilteredValue = (0, _get2.default)(curQuery, 'defaultFilteredValue');
|
|
571
|
+
const filteredValue = stateFilteredValue ? stateFilteredValue : defaultFilteredValue;
|
|
572
|
+
|
|
569
573
|
if ((0, _isArray.default)(column.filters) && column.filters.length || /*#__PURE__*/(0, _react.isValidElement)(column.filterDropdown)) {
|
|
570
574
|
const filter = /*#__PURE__*/_react.default.createElement(_ColumnFilter.default, (0, _assign.default)({
|
|
571
575
|
key: _constants.strings.DEFAULT_KEY_COLUMN_FILTER
|
|
572
576
|
}, curQuery, {
|
|
577
|
+
filteredValue: filteredValue,
|
|
573
578
|
onFilterDropdownVisibleChange: visible => _this.foundation.toggleShowFilter(dataIndex, visible),
|
|
574
579
|
onSelect: data => _this.foundation.handleFilterSelect(dataIndex, data)
|
|
575
580
|
}));
|
|
@@ -1154,11 +1159,12 @@ class Table extends _baseComponent.default {
|
|
|
1154
1159
|
willUpdateStates.cachedColumns = props.columns;
|
|
1155
1160
|
willUpdateStates.cachedChildren = null;
|
|
1156
1161
|
} else if (props.children && props.children !== state.cachedChildren) {
|
|
1157
|
-
const
|
|
1162
|
+
const newNestedColumns = (0, _getColumns.default)(props.children);
|
|
1163
|
+
const newFlattenColumns = (0, _utils.flattenColumns)(newNestedColumns);
|
|
1158
1164
|
const columns = (0, _utils.mergeColumns)(state.queries, newFlattenColumns, null, false);
|
|
1159
1165
|
willUpdateStates.flattenColumns = newFlattenColumns;
|
|
1160
1166
|
willUpdateStates.queries = [...columns];
|
|
1161
|
-
willUpdateStates.cachedColumns = [...
|
|
1167
|
+
willUpdateStates.cachedColumns = [...newNestedColumns];
|
|
1162
1168
|
willUpdateStates.cachedChildren = props.children;
|
|
1163
1169
|
} // Update controlled selection column
|
|
1164
1170
|
|
|
@@ -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/cjs/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/cjs/tree/index.js
CHANGED
|
@@ -236,6 +236,7 @@ class Tree extends _baseComponent.default {
|
|
|
236
236
|
selectedKeys: [],
|
|
237
237
|
checkedKeys: new _set.default(),
|
|
238
238
|
halfCheckedKeys: new _set.default(),
|
|
239
|
+
realCheckedKeys: new _set.default([]),
|
|
239
240
|
motionKeys: new _set.default([]),
|
|
240
241
|
motionType: 'hide',
|
|
241
242
|
expandedKeys: new _set.default(props.expandedKeys),
|
|
@@ -446,12 +447,16 @@ class Tree extends _baseComponent.default {
|
|
|
446
447
|
}
|
|
447
448
|
|
|
448
449
|
if (checkedKeyValues) {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
450
|
+
if (props.checkRelation === 'unRelated') {
|
|
451
|
+
newState.realCheckedKeys = new _set.default(checkedKeyValues);
|
|
452
|
+
} else if (props.checkRelation === 'related') {
|
|
453
|
+
const {
|
|
454
|
+
checkedKeys,
|
|
455
|
+
halfCheckedKeys
|
|
456
|
+
} = (0, _treeUtil.calcCheckedKeys)(checkedKeyValues, keyEntities);
|
|
457
|
+
newState.checkedKeys = checkedKeys;
|
|
458
|
+
newState.halfCheckedKeys = halfCheckedKeys;
|
|
459
|
+
}
|
|
455
460
|
}
|
|
456
461
|
} // update loadedKeys
|
|
457
462
|
|
|
@@ -461,7 +466,7 @@ class Tree extends _baseComponent.default {
|
|
|
461
466
|
} // update disableStrictly
|
|
462
467
|
|
|
463
468
|
|
|
464
|
-
if (treeData && props.disableStrictly) {
|
|
469
|
+
if (treeData && props.disableStrictly && props.checkRelation === 'related') {
|
|
465
470
|
newState.disabledKeys = (0, _treeUtil.calcDisabledKeys)(keyEntities);
|
|
466
471
|
}
|
|
467
472
|
|
|
@@ -782,6 +787,7 @@ Tree.propTypes = {
|
|
|
782
787
|
onDragStart: _propTypes.default.func,
|
|
783
788
|
onDrop: _propTypes.default.func,
|
|
784
789
|
labelEllipsis: _propTypes.default.bool,
|
|
790
|
+
checkRelation: _propTypes.default.string,
|
|
785
791
|
'aria-label': _propTypes.default.string
|
|
786
792
|
};
|
|
787
793
|
Tree.defaultProps = {
|
|
@@ -801,7 +807,8 @@ Tree.defaultProps = {
|
|
|
801
807
|
expandAction: false,
|
|
802
808
|
disableStrictly: false,
|
|
803
809
|
draggable: false,
|
|
804
|
-
autoExpandWhenDragEnter: true
|
|
810
|
+
autoExpandWhenDragEnter: true,
|
|
811
|
+
checkRelation: 'related'
|
|
805
812
|
};
|
|
806
813
|
Tree.TreeNode = _treeNode.default;
|
|
807
814
|
var _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
|
/**
|
|
@@ -174,34 +174,52 @@ class TreeSelect extends _baseComponent.default {
|
|
|
174
174
|
this.foundation.handleSelectionEnterPress(e);
|
|
175
175
|
};
|
|
176
176
|
|
|
177
|
-
this.
|
|
177
|
+
this.hasValue = () => {
|
|
178
178
|
const {
|
|
179
|
-
|
|
179
|
+
multiple,
|
|
180
|
+
checkRelation
|
|
180
181
|
} = this.props;
|
|
181
182
|
const {
|
|
182
|
-
|
|
183
|
+
realCheckedKeys,
|
|
184
|
+
checkedKeys,
|
|
185
|
+
selectedKeys
|
|
183
186
|
} = this.state;
|
|
184
|
-
|
|
187
|
+
let hasValue = false;
|
|
188
|
+
|
|
189
|
+
if (multiple) {
|
|
190
|
+
if (checkRelation === 'related') {
|
|
191
|
+
hasValue = Boolean(checkedKeys.size);
|
|
192
|
+
} else if (checkRelation === 'unRelated') {
|
|
193
|
+
hasValue = Boolean(realCheckedKeys.size);
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
hasValue = Boolean(selectedKeys.length);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return hasValue;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
this.showClearBtn = () => {
|
|
185
203
|
const {
|
|
186
204
|
showClear,
|
|
187
205
|
disabled,
|
|
188
|
-
|
|
206
|
+
searchPosition
|
|
189
207
|
} = this.props;
|
|
190
208
|
const {
|
|
191
|
-
|
|
192
|
-
checkedKeys,
|
|
209
|
+
inputValue,
|
|
193
210
|
isOpen,
|
|
194
211
|
isHovering
|
|
195
212
|
} = this.state;
|
|
196
|
-
const
|
|
197
|
-
return showClear && (hasValue || triggerSearchHasInputValue) && !disabled && (isOpen || isHovering);
|
|
213
|
+
const triggerSearchHasInputValue = searchPosition === _constants.strings.SEARCH_POSITION_TRIGGER && inputValue;
|
|
214
|
+
return showClear && (this.hasValue() || triggerSearchHasInputValue) && !disabled && (isOpen || isHovering);
|
|
198
215
|
};
|
|
199
216
|
|
|
200
217
|
this.renderTagList = () => {
|
|
201
218
|
const {
|
|
202
219
|
checkedKeys,
|
|
203
220
|
keyEntities,
|
|
204
|
-
disabledKeys
|
|
221
|
+
disabledKeys,
|
|
222
|
+
realCheckedKeys
|
|
205
223
|
} = this.state;
|
|
206
224
|
const {
|
|
207
225
|
treeNodeLabelProp,
|
|
@@ -209,13 +227,21 @@ class TreeSelect extends _baseComponent.default {
|
|
|
209
227
|
disabled,
|
|
210
228
|
disableStrictly,
|
|
211
229
|
size,
|
|
230
|
+
checkRelation,
|
|
212
231
|
renderSelectedItem: propRenderSelectedItem
|
|
213
232
|
} = this.props;
|
|
214
233
|
const renderSelectedItem = (0, _isFunction2.default)(propRenderSelectedItem) ? propRenderSelectedItem : item => ({
|
|
215
234
|
isRenderInTag: true,
|
|
216
235
|
content: (0, _get2.default)(item, treeNodeLabelProp, null)
|
|
217
236
|
});
|
|
218
|
-
|
|
237
|
+
let renderKeys = [];
|
|
238
|
+
|
|
239
|
+
if (checkRelation === 'related') {
|
|
240
|
+
renderKeys = (0, _treeUtil.normalizeKeyList)([...checkedKeys], keyEntities, leafOnly);
|
|
241
|
+
} else if (checkRelation === 'unRelated') {
|
|
242
|
+
renderKeys = [...realCheckedKeys];
|
|
243
|
+
}
|
|
244
|
+
|
|
219
245
|
const tagList = []; // eslint-disable-next-line @typescript-eslint/no-shadow
|
|
220
246
|
|
|
221
247
|
(0, _forEach.default)(renderKeys).call(renderKeys, key => {
|
|
@@ -303,11 +329,6 @@ class TreeSelect extends _baseComponent.default {
|
|
|
303
329
|
searchPosition,
|
|
304
330
|
filterTreeNode
|
|
305
331
|
} = this.props;
|
|
306
|
-
const {
|
|
307
|
-
selectedKeys,
|
|
308
|
-
checkedKeys
|
|
309
|
-
} = this.state;
|
|
310
|
-
const hasValue = multiple ? Boolean(checkedKeys.size) : Boolean(selectedKeys.length);
|
|
311
332
|
const isTriggerPositionSearch = filterTreeNode && searchPosition === _constants.strings.SEARCH_POSITION_TRIGGER; // searchPosition = trigger
|
|
312
333
|
|
|
313
334
|
if (isTriggerPositionSearch) {
|
|
@@ -315,7 +336,7 @@ class TreeSelect extends _baseComponent.default {
|
|
|
315
336
|
} // searchPosition = dropdown and single seleciton
|
|
316
337
|
|
|
317
338
|
|
|
318
|
-
if (!multiple || !hasValue) {
|
|
339
|
+
if (!multiple || !this.hasValue()) {
|
|
319
340
|
const renderText = this.foundation.getRenderTextInSingle();
|
|
320
341
|
const spanCls = (0, _classnames.default)({
|
|
321
342
|
["".concat(prefixcls, "-selection-placeholder")]: !renderText
|
|
@@ -568,14 +589,23 @@ class TreeSelect extends _baseComponent.default {
|
|
|
568
589
|
size,
|
|
569
590
|
searchAutoFocus,
|
|
570
591
|
placeholder,
|
|
571
|
-
maxTagCount
|
|
592
|
+
maxTagCount,
|
|
593
|
+
checkRelation
|
|
572
594
|
} = this.props;
|
|
573
595
|
const {
|
|
574
596
|
keyEntities,
|
|
575
597
|
checkedKeys,
|
|
576
|
-
inputValue
|
|
598
|
+
inputValue,
|
|
599
|
+
realCheckedKeys
|
|
577
600
|
} = this.state;
|
|
578
|
-
|
|
601
|
+
let keyList = [];
|
|
602
|
+
|
|
603
|
+
if (checkRelation === 'related') {
|
|
604
|
+
keyList = (0, _treeUtil.normalizeKeyList)(checkedKeys, keyEntities, leafOnly);
|
|
605
|
+
} else if (checkRelation === 'unRelated') {
|
|
606
|
+
keyList = [...realCheckedKeys];
|
|
607
|
+
}
|
|
608
|
+
|
|
579
609
|
return /*#__PURE__*/_react.default.createElement(_tagInput.default, {
|
|
580
610
|
maxTagCount: maxTagCount,
|
|
581
611
|
disabled: disabled,
|
|
@@ -900,6 +930,7 @@ class TreeSelect extends _baseComponent.default {
|
|
|
900
930
|
selectedKeys: [],
|
|
901
931
|
checkedKeys: new _set.default(),
|
|
902
932
|
halfCheckedKeys: new _set.default(),
|
|
933
|
+
realCheckedKeys: new _set.default([]),
|
|
903
934
|
disabledKeys: new _set.default(),
|
|
904
935
|
motionKeys: new _set.default([]),
|
|
905
936
|
motionType: 'hide',
|
|
@@ -1020,12 +1051,16 @@ class TreeSelect extends _baseComponent.default {
|
|
|
1020
1051
|
}
|
|
1021
1052
|
|
|
1022
1053
|
if (checkedKeyValues) {
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1054
|
+
if (props.checkRelation === 'unRelated') {
|
|
1055
|
+
newState.realCheckedKeys = new _set.default(checkedKeyValues);
|
|
1056
|
+
} else if (props.checkRelation === 'related') {
|
|
1057
|
+
const {
|
|
1058
|
+
checkedKeys,
|
|
1059
|
+
halfCheckedKeys
|
|
1060
|
+
} = (0, _treeUtil.calcCheckedKeys)(checkedKeyValues, keyEntities);
|
|
1061
|
+
newState.checkedKeys = checkedKeys;
|
|
1062
|
+
newState.halfCheckedKeys = halfCheckedKeys;
|
|
1063
|
+
}
|
|
1029
1064
|
}
|
|
1030
1065
|
} // loadedKeys
|
|
1031
1066
|
|
|
@@ -1040,7 +1075,7 @@ class TreeSelect extends _baseComponent.default {
|
|
|
1040
1075
|
} // ================ disableStrictly =================
|
|
1041
1076
|
|
|
1042
1077
|
|
|
1043
|
-
if (treeData && props.disableStrictly) {
|
|
1078
|
+
if (treeData && props.disableStrictly && props.checkRelation === 'related') {
|
|
1044
1079
|
newState.disabledKeys = (0, _treeUtil.calcDisabledKeys)(keyEntities);
|
|
1045
1080
|
}
|
|
1046
1081
|
|
|
@@ -1307,6 +1342,7 @@ TreeSelect.propTypes = {
|
|
|
1307
1342
|
optionListStyle: _propTypes.default.object,
|
|
1308
1343
|
searchRender: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.bool]),
|
|
1309
1344
|
renderSelectedItem: _propTypes.default.func,
|
|
1345
|
+
checkRelation: _propTypes.default.string,
|
|
1310
1346
|
'aria-label': _propTypes.default.string
|
|
1311
1347
|
};
|
|
1312
1348
|
TreeSelect.defaultProps = {
|
|
@@ -1335,6 +1371,7 @@ TreeSelect.defaultProps = {
|
|
|
1335
1371
|
expandAction: false,
|
|
1336
1372
|
clickToHide: true,
|
|
1337
1373
|
searchAutoFocus: false,
|
|
1374
|
+
checkRelation: 'related',
|
|
1338
1375
|
'aria-label': 'TreeSelect'
|
|
1339
1376
|
};
|
|
1340
1377
|
var _default = TreeSelect;
|
|
@@ -30,7 +30,7 @@ var _semiIcons = require("@douyinfe/semi-icons");
|
|
|
30
30
|
|
|
31
31
|
var _localeConsumer = _interopRequireDefault(require("../locale/localeConsumer"));
|
|
32
32
|
|
|
33
|
-
var _index = _interopRequireDefault(require("../
|
|
33
|
+
var _index = _interopRequireDefault(require("../button/index"));
|
|
34
34
|
|
|
35
35
|
var _index2 = _interopRequireDefault(require("../progress/index"));
|
|
36
36
|
|
|
@@ -200,6 +200,7 @@ class FileCard extends _react.PureComponent {
|
|
|
200
200
|
onPreviewClick,
|
|
201
201
|
showPicInfo,
|
|
202
202
|
renderPicInfo,
|
|
203
|
+
renderPicPreviewIcon,
|
|
203
204
|
renderThumbnail,
|
|
204
205
|
name,
|
|
205
206
|
index
|
|
@@ -207,6 +208,7 @@ class FileCard extends _react.PureComponent {
|
|
|
207
208
|
const showProgress = status === _constants.strings.FILE_STATUS_UPLOADING && percent !== 100;
|
|
208
209
|
const showRetry = status === _constants.strings.FILE_STATUS_UPLOAD_FAIL && this.props.showRetry;
|
|
209
210
|
const showReplace = status === _constants.strings.FILE_STATUS_SUCCESS && this.props.showReplace;
|
|
211
|
+
const showPreview = status === _constants.strings.FILE_STATUS_SUCCESS && !this.props.showReplace;
|
|
210
212
|
const filePicCardCls = (0, _classnames.default)({
|
|
211
213
|
["".concat(prefixCls, "-picture-file-card")]: true,
|
|
212
214
|
["".concat(prefixCls, "-picture-file-card-disabled")]: disabled,
|
|
@@ -214,7 +216,6 @@ class FileCard extends _react.PureComponent {
|
|
|
214
216
|
["".concat(prefixCls, "-picture-file-card-error")]: status === _constants.strings.FILE_STATUS_UPLOAD_FAIL,
|
|
215
217
|
["".concat(prefixCls, "-picture-file-card-uploading")]: showProgress
|
|
216
218
|
});
|
|
217
|
-
const closeCls = "".concat(prefixCls, "-picture-file-card-close");
|
|
218
219
|
|
|
219
220
|
const retry = /*#__PURE__*/_react.default.createElement("div", {
|
|
220
221
|
role: "button",
|
|
@@ -240,6 +241,19 @@ class FileCard extends _react.PureComponent {
|
|
|
240
241
|
className: "".concat(prefixCls, "-picture-file-card-icon-replace")
|
|
241
242
|
})));
|
|
242
243
|
|
|
244
|
+
const preview = /*#__PURE__*/_react.default.createElement("div", {
|
|
245
|
+
className: "".concat(prefixCls, "-picture-file-card-preview")
|
|
246
|
+
}, typeof renderPicPreviewIcon === 'function' ? renderPicPreviewIcon(this.props) : null);
|
|
247
|
+
|
|
248
|
+
const close = /*#__PURE__*/_react.default.createElement("div", {
|
|
249
|
+
role: "button",
|
|
250
|
+
tabIndex: 0,
|
|
251
|
+
className: "".concat(prefixCls, "-picture-file-card-close"),
|
|
252
|
+
onClick: e => this.onRemove(e)
|
|
253
|
+
}, /*#__PURE__*/_react.default.createElement(_semiIcons.IconClear, {
|
|
254
|
+
className: "".concat(prefixCls, "-picture-file-card-icon-close")
|
|
255
|
+
}));
|
|
256
|
+
|
|
243
257
|
const picInfo = typeof renderPicInfo === 'function' ? renderPicInfo(this.props) : /*#__PURE__*/_react.default.createElement("div", {
|
|
244
258
|
className: "".concat(prefixCls, "-picture-file-card-pic-info")
|
|
245
259
|
}, index + 1);
|
|
@@ -258,14 +272,7 @@ class FileCard extends _react.PureComponent {
|
|
|
258
272
|
size: "small",
|
|
259
273
|
orbitStroke: '#FFF',
|
|
260
274
|
"aria-label": "uploading file progress"
|
|
261
|
-
}) : null, showRetry ? retry : null, showReplace && replace, showPicInfo && picInfo, !disabled &&
|
|
262
|
-
className: closeCls,
|
|
263
|
-
onClick: e => this.onRemove(e)
|
|
264
|
-
}, /*#__PURE__*/_react.default.createElement(_semiIcons.IconClose, {
|
|
265
|
-
tabIndex: 0,
|
|
266
|
-
role: "button",
|
|
267
|
-
size: "extra-small"
|
|
268
|
-
})), this.renderPicValidateMsg());
|
|
275
|
+
}) : null, showRetry ? retry : null, showReplace && replace, showPreview && preview, showPicInfo && picInfo, !disabled && close, this.renderPicValidateMsg());
|
|
269
276
|
}
|
|
270
277
|
|
|
271
278
|
renderFile(locale) {
|
|
@@ -280,7 +287,8 @@ class FileCard extends _react.PureComponent {
|
|
|
280
287
|
previewFile,
|
|
281
288
|
status,
|
|
282
289
|
style,
|
|
283
|
-
onPreviewClick
|
|
290
|
+
onPreviewClick,
|
|
291
|
+
renderFileOperation
|
|
284
292
|
} = this.props;
|
|
285
293
|
const fileCardCls = (0, _classnames.default)({
|
|
286
294
|
["".concat(prefixCls, "-file-card")]: true,
|
|
@@ -310,6 +318,14 @@ class FileCard extends _react.PureComponent {
|
|
|
310
318
|
previewContent = previewFile(this.props);
|
|
311
319
|
}
|
|
312
320
|
|
|
321
|
+
const operation = typeof renderFileOperation === 'function' ? renderFileOperation(this.props) : /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
322
|
+
onClick: e => this.onRemove(e),
|
|
323
|
+
type: "tertiary",
|
|
324
|
+
icon: /*#__PURE__*/_react.default.createElement(_semiIcons.IconClose, null),
|
|
325
|
+
theme: "borderless",
|
|
326
|
+
size: "small",
|
|
327
|
+
className: closeCls
|
|
328
|
+
});
|
|
313
329
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
314
330
|
role: "listitem",
|
|
315
331
|
className: fileCardCls,
|
|
@@ -352,29 +368,22 @@ class FileCard extends _react.PureComponent {
|
|
|
352
368
|
tabIndex: 0,
|
|
353
369
|
className: "".concat(infoCls, "-retry"),
|
|
354
370
|
onClick: e => this.onRetry(e)
|
|
355
|
-
}, locale.retry) : null)),
|
|
356
|
-
onClick: e => this.onRemove(e),
|
|
357
|
-
type: "tertiary",
|
|
358
|
-
icon: /*#__PURE__*/_react.default.createElement(_semiIcons.IconClose, null),
|
|
359
|
-
theme: "borderless",
|
|
360
|
-
size: "small",
|
|
361
|
-
className: closeCls
|
|
362
|
-
}));
|
|
371
|
+
}, locale.retry) : null)), operation);
|
|
363
372
|
}
|
|
364
373
|
|
|
365
374
|
onRemove(e) {
|
|
366
375
|
e.stopPropagation();
|
|
367
|
-
this.props.onRemove(
|
|
376
|
+
this.props.onRemove();
|
|
368
377
|
}
|
|
369
378
|
|
|
370
379
|
onReplace(e) {
|
|
371
380
|
e.stopPropagation();
|
|
372
|
-
this.props.onReplace(
|
|
381
|
+
this.props.onReplace();
|
|
373
382
|
}
|
|
374
383
|
|
|
375
384
|
onRetry(e) {
|
|
376
385
|
e.stopPropagation();
|
|
377
|
-
this.props.onRetry(
|
|
386
|
+
this.props.onRetry();
|
|
378
387
|
}
|
|
379
388
|
|
|
380
389
|
render() {
|
|
@@ -29,6 +29,7 @@ export interface UploadProps {
|
|
|
29
29
|
fileList?: Array<FileItem>;
|
|
30
30
|
fileName?: string;
|
|
31
31
|
headers?: Record<string, any> | ((file: File) => Record<string, string>);
|
|
32
|
+
hotSpotLocation?: 'start' | 'end';
|
|
32
33
|
itemStyle?: CSSProperties;
|
|
33
34
|
limit?: number;
|
|
34
35
|
listType?: UploadListType;
|
|
@@ -56,6 +57,8 @@ export interface UploadProps {
|
|
|
56
57
|
renderFileItem?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
57
58
|
renderPicInfo?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
58
59
|
renderThumbnail?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
60
|
+
renderPicPreviewIcon?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
61
|
+
renderFileOperation?: (fileItem: RenderFileItemProps) => ReactNode;
|
|
59
62
|
showClear?: boolean;
|
|
60
63
|
showPicInfo?: boolean;
|
|
61
64
|
showReplace?: boolean;
|
|
@@ -99,6 +102,7 @@ declare class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
99
102
|
fileList: PropTypes.Requireable<any[]>;
|
|
100
103
|
fileName: PropTypes.Requireable<string>;
|
|
101
104
|
headers: PropTypes.Requireable<object>;
|
|
105
|
+
hotSpotLocation: PropTypes.Requireable<string>;
|
|
102
106
|
itemStyle: PropTypes.Requireable<object>;
|
|
103
107
|
limit: PropTypes.Requireable<number>;
|
|
104
108
|
listType: PropTypes.Requireable<"picture" | "list">;
|
|
@@ -124,6 +128,8 @@ declare class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
124
128
|
prompt: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
125
129
|
promptPosition: PropTypes.Requireable<"left" | "right" | "bottom">;
|
|
126
130
|
renderFileItem: PropTypes.Requireable<(...args: any[]) => any>;
|
|
131
|
+
renderPicPreviewIcon: PropTypes.Requireable<(...args: any[]) => any>;
|
|
132
|
+
renderFileOperation: PropTypes.Requireable<(...args: any[]) => any>;
|
|
127
133
|
renderPicInfo: PropTypes.Requireable<(...args: any[]) => any>;
|
|
128
134
|
renderThumbnail: PropTypes.Requireable<(...args: any[]) => any>;
|
|
129
135
|
showClear: PropTypes.Requireable<boolean>;
|