@douyinfe/semi-ui 2.4.1 → 2.6.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/calendar/monthCalendar.tsx +14 -13
- package/cascader/__test__/cascader.test.js +24 -0
- package/cascader/_story/cascader.stories.js +73 -0
- package/cascader/index.tsx +26 -5
- package/cascader/item.tsx +25 -5
- package/datePicker/_story/v2/FixInputRangeFocus.jsx +25 -0
- package/datePicker/_story/v2/index.js +2 -1
- package/datePicker/dateInput.tsx +8 -5
- package/datePicker/datePicker.tsx +9 -1
- package/datePicker/month.tsx +14 -7
- package/datePicker/monthsGrid.tsx +17 -5
- package/datePicker/navigation.tsx +8 -4
- package/datePicker/quickControl.tsx +1 -0
- package/datePicker/yearAndMonth.tsx +1 -1
- package/dist/css/semi.css +71 -35
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +696 -263
- 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/__test__/formApi.test.js +182 -0
- package/form/_story/FormApi/arrayDemo.jsx +4 -7
- package/form/_story/Layout/slotDemo.jsx +2 -2
- package/form/_story/demo.jsx +18 -1
- package/form/_story/form.stories.js +6 -6
- package/form/baseForm.tsx +2 -2
- package/form/hoc/withField.tsx +1 -1
- package/lib/cjs/_base/base.css +5 -5
- package/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/calendar/monthCalendar.js +21 -5
- package/lib/cjs/cascader/index.d.ts +9 -2
- package/lib/cjs/cascader/index.js +20 -1
- package/lib/cjs/cascader/item.d.ts +6 -2
- package/lib/cjs/cascader/item.js +33 -4
- package/lib/cjs/datePicker/dateInput.d.ts +0 -2
- package/lib/cjs/datePicker/dateInput.js +17 -6
- package/lib/cjs/datePicker/datePicker.js +19 -12
- package/lib/cjs/datePicker/month.d.ts +1 -0
- package/lib/cjs/datePicker/month.js +18 -2
- package/lib/cjs/datePicker/monthsGrid.js +16 -4
- package/lib/cjs/datePicker/navigation.js +8 -0
- package/lib/cjs/datePicker/quickControl.js +1 -0
- package/lib/cjs/datePicker/yearAndMonth.js +1 -0
- package/lib/cjs/dropdown/index.d.ts +1 -1
- package/lib/cjs/form/baseForm.d.ts +1 -1
- package/lib/cjs/form/baseForm.js +2 -2
- package/lib/cjs/form/field.d.ts +1 -1
- package/lib/cjs/form/hoc/withField.js +1 -1
- package/lib/cjs/scrollList/scrollItem.d.ts +2 -1
- package/lib/cjs/scrollList/scrollItem.js +13 -3
- 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/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/_base/base.css +5 -5
- package/lib/es/autoComplete/index.d.ts +1 -1
- package/lib/es/calendar/monthCalendar.js +22 -5
- package/lib/es/cascader/index.d.ts +9 -2
- package/lib/es/cascader/index.js +19 -1
- package/lib/es/cascader/item.d.ts +6 -2
- package/lib/es/cascader/item.js +31 -4
- package/lib/es/datePicker/dateInput.d.ts +0 -2
- package/lib/es/datePicker/dateInput.js +17 -6
- package/lib/es/datePicker/datePicker.js +19 -12
- package/lib/es/datePicker/month.d.ts +1 -0
- package/lib/es/datePicker/month.js +18 -2
- package/lib/es/datePicker/monthsGrid.js +16 -4
- package/lib/es/datePicker/navigation.js +8 -0
- package/lib/es/datePicker/quickControl.js +2 -0
- package/lib/es/datePicker/yearAndMonth.js +1 -0
- package/lib/es/dropdown/index.d.ts +1 -1
- package/lib/es/form/baseForm.d.ts +1 -1
- package/lib/es/form/baseForm.js +2 -2
- package/lib/es/form/field.d.ts +1 -1
- package/lib/es/form/hoc/withField.js +1 -1
- package/lib/es/scrollList/scrollItem.d.ts +2 -1
- package/lib/es/scrollList/scrollItem.js +13 -3
- 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/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 -9
- package/scrollList/_story/ScrollList/index.js +3 -0
- package/scrollList/_story/WheelList/index.js +3 -0
- package/scrollList/scrollItem.tsx +30 -9
- 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/Perf/Virtualized/index.jsx +6 -0
- 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 +114 -0
- package/table/_story/v2/index.js +5 -0
- package/table/interface.ts +1 -0
- package/tabs/interface.ts +1 -1
- 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/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/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;
|
|
@@ -4,9 +4,9 @@ import cls from 'classnames';
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/upload/constants';
|
|
6
6
|
import { getFileSize } from '@douyinfe/semi-foundation/lib/es/upload/utils';
|
|
7
|
-
import { IconAlertCircle, IconClose, IconFile, IconRefresh } from '@douyinfe/semi-icons';
|
|
7
|
+
import { IconAlertCircle, IconClose, IconClear, IconFile, IconRefresh } from '@douyinfe/semi-icons';
|
|
8
8
|
import LocaleConsumer from '../locale/localeConsumer';
|
|
9
|
-
import
|
|
9
|
+
import Button from '../button/index';
|
|
10
10
|
import Progress from '../progress/index';
|
|
11
11
|
import Tooltip from '../tooltip/index';
|
|
12
12
|
import Spin from '../spin/index';
|
|
@@ -167,6 +167,7 @@ class FileCard extends PureComponent {
|
|
|
167
167
|
onPreviewClick,
|
|
168
168
|
showPicInfo,
|
|
169
169
|
renderPicInfo,
|
|
170
|
+
renderPicPreviewIcon,
|
|
170
171
|
renderThumbnail,
|
|
171
172
|
name,
|
|
172
173
|
index
|
|
@@ -174,6 +175,7 @@ class FileCard extends PureComponent {
|
|
|
174
175
|
const showProgress = status === strings.FILE_STATUS_UPLOADING && percent !== 100;
|
|
175
176
|
const showRetry = status === strings.FILE_STATUS_UPLOAD_FAIL && this.props.showRetry;
|
|
176
177
|
const showReplace = status === strings.FILE_STATUS_SUCCESS && this.props.showReplace;
|
|
178
|
+
const showPreview = status === strings.FILE_STATUS_SUCCESS && !this.props.showReplace;
|
|
177
179
|
const filePicCardCls = cls({
|
|
178
180
|
["".concat(prefixCls, "-picture-file-card")]: true,
|
|
179
181
|
["".concat(prefixCls, "-picture-file-card-disabled")]: disabled,
|
|
@@ -181,7 +183,6 @@ class FileCard extends PureComponent {
|
|
|
181
183
|
["".concat(prefixCls, "-picture-file-card-error")]: status === strings.FILE_STATUS_UPLOAD_FAIL,
|
|
182
184
|
["".concat(prefixCls, "-picture-file-card-uploading")]: showProgress
|
|
183
185
|
});
|
|
184
|
-
const closeCls = "".concat(prefixCls, "-picture-file-card-close");
|
|
185
186
|
const retry = /*#__PURE__*/React.createElement("div", {
|
|
186
187
|
role: "button",
|
|
187
188
|
tabIndex: 0,
|
|
@@ -204,6 +205,17 @@ class FileCard extends PureComponent {
|
|
|
204
205
|
}, /*#__PURE__*/React.createElement(ReplaceSvg, {
|
|
205
206
|
className: "".concat(prefixCls, "-picture-file-card-icon-replace")
|
|
206
207
|
})));
|
|
208
|
+
const preview = /*#__PURE__*/React.createElement("div", {
|
|
209
|
+
className: "".concat(prefixCls, "-picture-file-card-preview")
|
|
210
|
+
}, typeof renderPicPreviewIcon === 'function' ? renderPicPreviewIcon(this.props) : null);
|
|
211
|
+
const close = /*#__PURE__*/React.createElement("div", {
|
|
212
|
+
role: "button",
|
|
213
|
+
tabIndex: 0,
|
|
214
|
+
className: "".concat(prefixCls, "-picture-file-card-close"),
|
|
215
|
+
onClick: e => this.onRemove(e)
|
|
216
|
+
}, /*#__PURE__*/React.createElement(IconClear, {
|
|
217
|
+
className: "".concat(prefixCls, "-picture-file-card-icon-close")
|
|
218
|
+
}));
|
|
207
219
|
const picInfo = typeof renderPicInfo === 'function' ? renderPicInfo(this.props) : /*#__PURE__*/React.createElement("div", {
|
|
208
220
|
className: "".concat(prefixCls, "-picture-file-card-pic-info")
|
|
209
221
|
}, index + 1);
|
|
@@ -222,14 +234,7 @@ class FileCard extends PureComponent {
|
|
|
222
234
|
size: "small",
|
|
223
235
|
orbitStroke: '#FFF',
|
|
224
236
|
"aria-label": "uploading file progress"
|
|
225
|
-
}) : null, showRetry ? retry : null, showReplace && replace, showPicInfo && picInfo, !disabled &&
|
|
226
|
-
className: closeCls,
|
|
227
|
-
onClick: e => this.onRemove(e)
|
|
228
|
-
}, /*#__PURE__*/React.createElement(IconClose, {
|
|
229
|
-
tabIndex: 0,
|
|
230
|
-
role: "button",
|
|
231
|
-
size: "extra-small"
|
|
232
|
-
})), this.renderPicValidateMsg());
|
|
237
|
+
}) : null, showRetry ? retry : null, showReplace && replace, showPreview && preview, showPicInfo && picInfo, !disabled && close, this.renderPicValidateMsg());
|
|
233
238
|
}
|
|
234
239
|
|
|
235
240
|
renderFile(locale) {
|
|
@@ -244,7 +249,8 @@ class FileCard extends PureComponent {
|
|
|
244
249
|
previewFile,
|
|
245
250
|
status,
|
|
246
251
|
style,
|
|
247
|
-
onPreviewClick
|
|
252
|
+
onPreviewClick,
|
|
253
|
+
renderFileOperation
|
|
248
254
|
} = this.props;
|
|
249
255
|
const fileCardCls = cls({
|
|
250
256
|
["".concat(prefixCls, "-file-card")]: true,
|
|
@@ -274,6 +280,14 @@ class FileCard extends PureComponent {
|
|
|
274
280
|
previewContent = previewFile(this.props);
|
|
275
281
|
}
|
|
276
282
|
|
|
283
|
+
const operation = typeof renderFileOperation === 'function' ? renderFileOperation(this.props) : /*#__PURE__*/React.createElement(Button, {
|
|
284
|
+
onClick: e => this.onRemove(e),
|
|
285
|
+
type: "tertiary",
|
|
286
|
+
icon: /*#__PURE__*/React.createElement(IconClose, null),
|
|
287
|
+
theme: "borderless",
|
|
288
|
+
size: "small",
|
|
289
|
+
className: closeCls
|
|
290
|
+
});
|
|
277
291
|
return /*#__PURE__*/React.createElement("div", {
|
|
278
292
|
role: "listitem",
|
|
279
293
|
className: fileCardCls,
|
|
@@ -294,7 +308,7 @@ class FileCard extends PureComponent {
|
|
|
294
308
|
position: "top",
|
|
295
309
|
showArrow: false,
|
|
296
310
|
content: locale.replace
|
|
297
|
-
}, /*#__PURE__*/React.createElement(
|
|
311
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
298
312
|
onClick: e => this.onReplace(e),
|
|
299
313
|
type: "tertiary",
|
|
300
314
|
theme: "borderless",
|
|
@@ -316,29 +330,22 @@ class FileCard extends PureComponent {
|
|
|
316
330
|
tabIndex: 0,
|
|
317
331
|
className: "".concat(infoCls, "-retry"),
|
|
318
332
|
onClick: e => this.onRetry(e)
|
|
319
|
-
}, locale.retry) : null)),
|
|
320
|
-
onClick: e => this.onRemove(e),
|
|
321
|
-
type: "tertiary",
|
|
322
|
-
icon: /*#__PURE__*/React.createElement(IconClose, null),
|
|
323
|
-
theme: "borderless",
|
|
324
|
-
size: "small",
|
|
325
|
-
className: closeCls
|
|
326
|
-
}));
|
|
333
|
+
}, locale.retry) : null)), operation);
|
|
327
334
|
}
|
|
328
335
|
|
|
329
336
|
onRemove(e) {
|
|
330
337
|
e.stopPropagation();
|
|
331
|
-
this.props.onRemove(
|
|
338
|
+
this.props.onRemove();
|
|
332
339
|
}
|
|
333
340
|
|
|
334
341
|
onReplace(e) {
|
|
335
342
|
e.stopPropagation();
|
|
336
|
-
this.props.onReplace(
|
|
343
|
+
this.props.onReplace();
|
|
337
344
|
}
|
|
338
345
|
|
|
339
346
|
onRetry(e) {
|
|
340
347
|
e.stopPropagation();
|
|
341
|
-
this.props.onRetry(
|
|
348
|
+
this.props.onRetry();
|
|
342
349
|
}
|
|
343
350
|
|
|
344
351
|
render() {
|
package/lib/es/upload/index.d.ts
CHANGED
|
@@ -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>;
|
package/lib/es/upload/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _pick from "lodash/pick";
|
|
1
2
|
import _noop from "lodash/noop";
|
|
2
3
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
3
4
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
@@ -111,14 +112,14 @@ class Upload extends BaseComponent {
|
|
|
111
112
|
previewFile,
|
|
112
113
|
listType,
|
|
113
114
|
itemStyle,
|
|
114
|
-
showRetry,
|
|
115
115
|
showPicInfo,
|
|
116
116
|
renderPicInfo,
|
|
117
|
+
renderPicPreviewIcon,
|
|
118
|
+
renderFileOperation,
|
|
117
119
|
renderFileItem,
|
|
118
120
|
renderThumbnail,
|
|
119
121
|
disabled,
|
|
120
|
-
onPreviewClick
|
|
121
|
-
showReplace
|
|
122
|
+
onPreviewClick
|
|
122
123
|
} = this.props;
|
|
123
124
|
|
|
124
125
|
const onRemove = () => this.remove(file);
|
|
@@ -131,20 +132,20 @@ class Upload extends BaseComponent {
|
|
|
131
132
|
this.replace(index);
|
|
132
133
|
};
|
|
133
134
|
|
|
134
|
-
const fileCardProps = _Object$assign(_Object$assign({}, file), {
|
|
135
|
+
const fileCardProps = _Object$assign(_Object$assign(_Object$assign({}, _pick(this.props, ['showRetry', 'showReplace', ''])), file), {
|
|
135
136
|
previewFile,
|
|
136
137
|
listType,
|
|
137
138
|
onRemove,
|
|
138
139
|
onRetry,
|
|
139
140
|
index,
|
|
140
141
|
key: uid || _concatInstanceProperty(_context = "".concat(name)).call(_context, index),
|
|
141
|
-
showRetry: typeof file.showRetry !== 'undefined' ? file.showRetry : showRetry,
|
|
142
142
|
style: itemStyle,
|
|
143
143
|
disabled,
|
|
144
144
|
showPicInfo,
|
|
145
145
|
renderPicInfo,
|
|
146
|
+
renderPicPreviewIcon,
|
|
147
|
+
renderFileOperation,
|
|
146
148
|
renderThumbnail,
|
|
147
|
-
showReplace: typeof file.showReplace !== 'undefined' ? file.showReplace : showReplace,
|
|
148
149
|
onReplace,
|
|
149
150
|
onPreviewClick: typeof onPreviewClick !== 'undefined' ? () => this.foundation.handlePreviewClick(file) : undefined
|
|
150
151
|
});
|
|
@@ -186,7 +187,8 @@ class Upload extends BaseComponent {
|
|
|
186
187
|
limit,
|
|
187
188
|
disabled,
|
|
188
189
|
children,
|
|
189
|
-
draggable
|
|
190
|
+
draggable,
|
|
191
|
+
hotSpotLocation
|
|
190
192
|
} = this.props;
|
|
191
193
|
const {
|
|
192
194
|
fileList: stateFileList,
|
|
@@ -244,7 +246,7 @@ class Upload extends BaseComponent {
|
|
|
244
246
|
className: mainCls,
|
|
245
247
|
role: "list",
|
|
246
248
|
"aria-label": "picture list"
|
|
247
|
-
}, _mapInstanceProperty(fileList).call(fileList, (file, index) => this.renderFile(file, index, locale)), showAddTriggerInList ? addContent : null)));
|
|
249
|
+
}, showAddTriggerInList && hotSpotLocation === 'start' ? addContent : null, _mapInstanceProperty(fileList).call(fileList, (file, index) => this.renderFile(file, index, locale)), showAddTriggerInList && hotSpotLocation === 'end' ? addContent : null)));
|
|
248
250
|
};
|
|
249
251
|
|
|
250
252
|
this.renderFileListDefault = () => {
|
|
@@ -584,6 +586,7 @@ Upload.propTypes = {
|
|
|
584
586
|
fileList: PropTypes.array,
|
|
585
587
|
fileName: PropTypes.string,
|
|
586
588
|
headers: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
|
|
589
|
+
hotSpotLocation: PropTypes.oneOf(['start', 'end']),
|
|
587
590
|
itemStyle: PropTypes.object,
|
|
588
591
|
limit: PropTypes.number,
|
|
589
592
|
listType: PropTypes.oneOf(strings.LIST_TYPE),
|
|
@@ -609,6 +612,8 @@ Upload.propTypes = {
|
|
|
609
612
|
prompt: PropTypes.node,
|
|
610
613
|
promptPosition: PropTypes.oneOf(strings.PROMPT_POSITION),
|
|
611
614
|
renderFileItem: PropTypes.func,
|
|
615
|
+
renderPicPreviewIcon: PropTypes.func,
|
|
616
|
+
renderFileOperation: PropTypes.func,
|
|
612
617
|
renderPicInfo: PropTypes.func,
|
|
613
618
|
renderThumbnail: PropTypes.func,
|
|
614
619
|
showClear: PropTypes.bool,
|
|
@@ -628,6 +633,7 @@ Upload.defaultProps = {
|
|
|
628
633
|
defaultFileList: [],
|
|
629
634
|
disabled: false,
|
|
630
635
|
listType: 'list',
|
|
636
|
+
hotSpotLocation: 'end',
|
|
631
637
|
multiple: false,
|
|
632
638
|
onAcceptInvalid: _noop,
|
|
633
639
|
onChange: _noop,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode, CSSProperties
|
|
1
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
2
2
|
import { BaseFileItem } from '@douyinfe/semi-foundation/lib/es/upload/foundation';
|
|
3
3
|
import { strings } from '@douyinfe/semi-foundation/lib/es/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;
|