@douyinfe/semi-ui 2.3.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/datePicker/_story/RenderDate/index.js +13 -3
- package/datePicker/_story/RenderFullDate/index.js +36 -14
- package/datePicker/_story/RenderFullDate/index.scss +1 -1
- package/datePicker/_story/datePicker.stories.js +19 -11
- package/datePicker/_story/v2/PanelOpen.jsx +39 -0
- package/datePicker/_story/v2/index.js +2 -1
- package/datePicker/datePicker.tsx +1 -0
- package/dist/css/semi.css +84 -36
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +487 -170
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/form/_story/demo.jsx +1 -0
- package/input/index.tsx +1 -0
- package/input/textarea.tsx +6 -4
- package/inputNumber/__test__/inputNumber.test.js +36 -8
- package/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/cascader/index.js +6 -0
- package/lib/cjs/datePicker/datePicker.js +12 -8
- package/lib/cjs/dropdown/index.d.ts +1 -1
- package/lib/cjs/form/baseForm.d.ts +1 -1
- package/lib/cjs/form/field.d.ts +1 -1
- package/lib/cjs/input/index.js +2 -1
- package/lib/cjs/input/textarea.js +5 -3
- package/lib/cjs/navigation/Item.js +1 -1
- package/lib/cjs/navigation/SubNav.js +1 -1
- package/lib/cjs/scrollList/scrollItem.d.ts +5 -1
- package/lib/cjs/scrollList/scrollItem.js +7 -0
- package/lib/cjs/select/index.d.ts +1 -1
- package/lib/cjs/select/index.js +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 +17 -7
- package/lib/cjs/table/interface.d.ts +1 -0
- package/lib/cjs/tabs/interface.d.ts +1 -1
- package/lib/cjs/timePicker/TimePicker.d.ts +2 -0
- package/lib/cjs/timePicker/TimePicker.js +4 -4
- package/lib/cjs/timePicker/index.d.ts +1 -0
- 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/tree/treeNode.js +10 -1
- package/lib/cjs/treeSelect/index.d.ts +2 -0
- package/lib/cjs/treeSelect/index.js +75 -30
- package/lib/cjs/typography/util.js +0 -1
- package/lib/cjs/upload/fileCard.js +31 -22
- package/lib/cjs/upload/index.d.ts +6 -0
- package/lib/cjs/upload/index.js +15 -8
- package/lib/cjs/upload/interface.d.ts +8 -6
- package/lib/es/autoComplete/index.d.ts +1 -1
- package/lib/es/cascader/index.js +5 -0
- package/lib/es/datePicker/datePicker.js +12 -8
- package/lib/es/dropdown/index.d.ts +1 -1
- package/lib/es/form/baseForm.d.ts +1 -1
- package/lib/es/form/field.d.ts +1 -1
- package/lib/es/input/index.js +2 -1
- package/lib/es/input/textarea.js +5 -3
- package/lib/es/navigation/Item.js +1 -1
- package/lib/es/navigation/SubNav.js +1 -1
- package/lib/es/scrollList/scrollItem.d.ts +5 -1
- package/lib/es/scrollList/scrollItem.js +7 -0
- package/lib/es/select/index.d.ts +1 -1
- package/lib/es/select/index.js +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 +19 -7
- package/lib/es/table/interface.d.ts +1 -0
- package/lib/es/tabs/interface.d.ts +1 -1
- package/lib/es/timePicker/TimePicker.d.ts +2 -0
- package/lib/es/timePicker/TimePicker.js +4 -4
- package/lib/es/timePicker/index.d.ts +1 -0
- 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/tree/treeNode.js +9 -1
- package/lib/es/treeSelect/index.d.ts +2 -0
- package/lib/es/treeSelect/index.js +76 -31
- package/lib/es/typography/util.js +0 -1
- 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/navigation/Item.tsx +1 -1
- package/navigation/SubNav.tsx +1 -1
- package/package.json +9 -8
- package/scrollList/scrollItem.tsx +10 -3
- package/select/index.tsx +6 -1
- package/select/option.tsx +2 -2
- package/table/Table.tsx +16 -8
- package/table/_story/table.stories.js +1 -0
- package/table/_story/v2/FixedColumnsChange/index.jsx +104 -0
- package/table/_story/v2/FixedHeaderMerge/index.jsx +98 -0
- package/table/_story/v2/FixedZIndex/index.jsx +87 -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/timePicker/TimePicker.tsx +4 -1
- package/timePicker/__test__/timePicker.test.js +42 -3
- package/timePicker/_story/timepicker.stories.js +18 -0
- 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/tree/treeNode.tsx +9 -2
- package/treeSelect/__test__/treeMultiple.test.js +94 -0
- package/treeSelect/__test__/treeSelect.test.js +157 -0
- package/treeSelect/_story/treeSelect.stories.js +242 -0
- package/treeSelect/index.tsx +93 -52
- package/typography/_story/typography.stories.js +8 -0
- package/typography/util.tsx +0 -1
- 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/input/textarea.js
CHANGED
|
@@ -241,19 +241,21 @@ class TextArea extends BaseComponent {
|
|
|
241
241
|
minLength: stateMinLength
|
|
242
242
|
} = this.state;
|
|
243
243
|
const wrapperCls = cls(className, "".concat(prefixCls, "-textarea-wrapper"), {
|
|
244
|
-
["".concat(prefixCls, "-textarea-wrapper-disabled")]: disabled
|
|
244
|
+
["".concat(prefixCls, "-textarea-wrapper-disabled")]: disabled,
|
|
245
|
+
["".concat(prefixCls, "-textarea-wrapper-readonly")]: readonly,
|
|
245
246
|
[_concatInstanceProperty(_context = "".concat(prefixCls, "-textarea-wrapper-")).call(_context, validateStatus)]: Boolean(validateStatus),
|
|
246
247
|
["".concat(prefixCls, "-textarea-wrapper-focus")]: isFocus // [`${prefixCls}-textarea-wrapper-resize`]: !autosize && resize,
|
|
247
248
|
|
|
248
249
|
}); // const ref = this.props.forwardRef || this.textAreaRef;
|
|
249
250
|
|
|
250
251
|
const itemCls = cls("".concat(prefixCls, "-textarea"), {
|
|
251
|
-
["".concat(prefixCls, "-textarea-disabled")]: disabled
|
|
252
|
+
["".concat(prefixCls, "-textarea-disabled")]: disabled,
|
|
253
|
+
["".concat(prefixCls, "-textarea-readonly")]: readonly,
|
|
252
254
|
["".concat(prefixCls, "-textarea-autosize")]: autosize,
|
|
253
255
|
["".concat(prefixCls, "-textarea-showClear")]: showClear
|
|
254
256
|
});
|
|
255
257
|
|
|
256
|
-
const itemProps = _Object$assign(_Object$assign({}, _omit(rest, 'insetLabel', 'getValueLength', 'onClear', 'showClear')), {
|
|
258
|
+
const itemProps = _Object$assign(_Object$assign({}, _omit(rest, 'insetLabel', 'insetLabelId', 'getValueLength', 'onClear', 'showClear')), {
|
|
257
259
|
className: itemCls,
|
|
258
260
|
disabled,
|
|
259
261
|
readOnly: readonly,
|
|
@@ -176,7 +176,7 @@ export default class NavItem extends BaseComponent {
|
|
|
176
176
|
} else {
|
|
177
177
|
let placeholderIcons = null;
|
|
178
178
|
|
|
179
|
-
if (mode === strings.MODE_VERTICAL && !limitIndent) {
|
|
179
|
+
if (mode === strings.MODE_VERTICAL && !limitIndent && !isCollapsed) {
|
|
180
180
|
const iconAmount = icon && !indent ? level : level - 1;
|
|
181
181
|
placeholderIcons = _times(iconAmount, () => this.renderIcon(null, strings.ICON_POS_RIGHT, false));
|
|
182
182
|
}
|
|
@@ -200,7 +200,7 @@ export default class SubNav extends BaseComponent {
|
|
|
200
200
|
|
|
201
201
|
let placeholderIcons = null;
|
|
202
202
|
|
|
203
|
-
if (mode === strings.MODE_VERTICAL && !limitIndent) {
|
|
203
|
+
if (mode === strings.MODE_VERTICAL && !limitIndent && !isCollapsed) {
|
|
204
204
|
/* Different icons' amount means different indents.*/
|
|
205
205
|
const iconAmount = icon && !indent ? level : level - 1;
|
|
206
206
|
placeholderIcons = _times(iconAmount, index => this.renderIcon(null, strings.ICON_POS_RIGHT, false, undefined, index));
|
|
@@ -3,7 +3,10 @@ import BaseComponent from '../_base/baseComponent';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { Item, ScrollItemAdapter } from '@douyinfe/semi-foundation/lib/es/scrollList/itemFoundation';
|
|
5
5
|
import { Motion } from '../_base/base';
|
|
6
|
-
|
|
6
|
+
interface DebounceSelectFn {
|
|
7
|
+
(e: React.UIEvent, newSelectedNode: HTMLElement): void;
|
|
8
|
+
cancel(): void;
|
|
9
|
+
}
|
|
7
10
|
export interface ScrollItemProps<T extends Item> {
|
|
8
11
|
mode?: string;
|
|
9
12
|
cycled?: boolean;
|
|
@@ -52,6 +55,7 @@ export default class ScrollItem<T extends Item> extends BaseComponent<ScrollItem
|
|
|
52
55
|
debouncedSelect: DebounceSelectFn;
|
|
53
56
|
constructor(props?: {});
|
|
54
57
|
get adapter(): ScrollItemAdapter<ScrollItemProps<T>, ScrollItemState, T>;
|
|
58
|
+
componentWillUnmount(): void;
|
|
55
59
|
componentDidMount(): void;
|
|
56
60
|
componentDidUpdate(prevProps: ScrollItemProps<T>): void;
|
|
57
61
|
_cacheNode: (name: string, node: Element) => Element;
|
|
@@ -429,6 +429,13 @@ export default class ScrollItem extends BaseComponent {
|
|
|
429
429
|
});
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
+
componentWillUnmount() {
|
|
433
|
+
if (this.props.cycled) {
|
|
434
|
+
this.throttledAdjustList.cancel();
|
|
435
|
+
this.debouncedSelect.cancel();
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
432
439
|
componentDidMount() {
|
|
433
440
|
this.foundation.init();
|
|
434
441
|
const {
|
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/index.js
CHANGED
|
@@ -506,7 +506,7 @@ class Select extends BaseComponent {
|
|
|
506
506
|
role: "button",
|
|
507
507
|
"aria-label": "Use the input box to create an optional item",
|
|
508
508
|
onClick: e => this.onSelect(option, optionIndex, e),
|
|
509
|
-
key:
|
|
509
|
+
key: option.key || option.label
|
|
510
510
|
}, customCreateItem)
|
|
511
511
|
);
|
|
512
512
|
}
|
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
|
|
|
@@ -1238,15 +1246,18 @@ class Table extends BaseComponent {
|
|
|
1238
1246
|
const _dataSource = [...dataSource];
|
|
1239
1247
|
const filteredSortedDataSource = this.foundation.getFilteredSortedDataSource(_dataSource, stateQueries);
|
|
1240
1248
|
this.foundation.setCachedFilteredSortedDataSource(filteredSortedDataSource);
|
|
1241
|
-
states.dataSource = filteredSortedDataSource;
|
|
1242
|
-
|
|
1243
|
-
states.pagination = _isObject(statePagination) ? _Object$assign(_Object$assign({}, statePagination), {
|
|
1244
|
-
currentPage: _isObject(propsPagination) && propsPagination.currentPage ? propsPagination.currentPage : 1
|
|
1245
|
-
}) : statePagination;
|
|
1249
|
+
states.dataSource = filteredSortedDataSource;
|
|
1246
1250
|
|
|
1247
1251
|
if (this.props.groupBy) {
|
|
1248
1252
|
states.groups = null;
|
|
1249
1253
|
}
|
|
1254
|
+
} // when dataSource has change, should reset currentPage
|
|
1255
|
+
|
|
1256
|
+
|
|
1257
|
+
if (dataSource !== prevProps.dataSource) {
|
|
1258
|
+
states.pagination = _isObject(statePagination) ? _Object$assign(_Object$assign({}, statePagination), {
|
|
1259
|
+
currentPage: _isObject(propsPagination) && propsPagination.currentPage ? propsPagination.currentPage : 1
|
|
1260
|
+
}) : statePagination;
|
|
1250
1261
|
}
|
|
1251
1262
|
|
|
1252
1263
|
if (_Object$keys(states).length) {
|
|
@@ -1433,6 +1444,7 @@ class Table extends BaseComponent {
|
|
|
1433
1444
|
return /*#__PURE__*/React.createElement("div", {
|
|
1434
1445
|
ref: this.rootWrapRef,
|
|
1435
1446
|
className: classnames(className, "".concat(prefixCls, "-wrapper")),
|
|
1447
|
+
"data-column-fixed": anyColumnFixed,
|
|
1436
1448
|
style: wrapStyle,
|
|
1437
1449
|
id: id
|
|
1438
1450
|
}, /*#__PURE__*/React.createElement(TableContextProvider, _Object$assign({}, tableContextValue), /*#__PURE__*/React.createElement(Spin, {
|
|
@@ -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;
|
|
@@ -69,6 +69,7 @@ export declare type TimePickerProps = {
|
|
|
69
69
|
zIndex?: number | string;
|
|
70
70
|
onBlur?: React.FocusEventHandler<HTMLInputElement>;
|
|
71
71
|
onChange?: TimePickerAdapter['notifyChange'];
|
|
72
|
+
onChangeWithDateFirst?: boolean;
|
|
72
73
|
onFocus?: React.FocusEventHandler<HTMLInputElement>;
|
|
73
74
|
onOpenChange?: (open: boolean) => void;
|
|
74
75
|
};
|
|
@@ -169,6 +170,7 @@ export default class TimePicker extends BaseComponent<TimePickerProps, TimePicke
|
|
|
169
170
|
onFocus: (...args: any[]) => void;
|
|
170
171
|
onBlur: (...args: any[]) => void;
|
|
171
172
|
onChange: (...args: any[]) => void;
|
|
173
|
+
onChangeWithDateFirst: boolean;
|
|
172
174
|
use12Hours: boolean;
|
|
173
175
|
focusOnOpen: boolean;
|
|
174
176
|
onKeyDown: (...args: any[]) => void;
|
|
@@ -149,9 +149,7 @@ export default class TimePicker extends BaseComponent {
|
|
|
149
149
|
notifyOpenChange: function () {
|
|
150
150
|
return _this2.props.onOpenChange(...arguments);
|
|
151
151
|
},
|
|
152
|
-
notifyChange:
|
|
153
|
-
return _this2.props.onChange && _this2.props.onChange(...arguments);
|
|
154
|
-
},
|
|
152
|
+
notifyChange: (agr1, arg2) => this.props.onChange && this.props.onChange(agr1, arg2),
|
|
155
153
|
notifyFocus: function () {
|
|
156
154
|
return _this2.props.onFocus && _this2.props.onFocus(...arguments);
|
|
157
155
|
},
|
|
@@ -298,6 +296,7 @@ export default class TimePicker extends BaseComponent {
|
|
|
298
296
|
panelFooter,
|
|
299
297
|
rangeSeparator,
|
|
300
298
|
onOpenChange,
|
|
299
|
+
onChangeWithDateFirst,
|
|
301
300
|
popupClassName: propPopupClassName,
|
|
302
301
|
hideDisabledOptions,
|
|
303
302
|
use12Hours,
|
|
@@ -309,7 +308,7 @@ export default class TimePicker extends BaseComponent {
|
|
|
309
308
|
motion,
|
|
310
309
|
autoAdjustOverflow
|
|
311
310
|
} = _a,
|
|
312
|
-
rest = __rest(_a, ["prefixCls", "placeholder", "disabled", "defaultValue", "className", "popupStyle", "size", "style", "locale", "localeCode", "zIndex", "getPopupContainer", "insetLabel", "insetLabelId", "inputStyle", "showClear", "panelHeader", "panelFooter", "rangeSeparator", "onOpenChange", "popupClassName", "hideDisabledOptions", "use12Hours", "minuteStep", "hourStep", "secondStep", "scrollItemProps", "triggerRender", "motion", "autoAdjustOverflow"]);
|
|
311
|
+
rest = __rest(_a, ["prefixCls", "placeholder", "disabled", "defaultValue", "className", "popupStyle", "size", "style", "locale", "localeCode", "zIndex", "getPopupContainer", "insetLabel", "insetLabelId", "inputStyle", "showClear", "panelHeader", "panelFooter", "rangeSeparator", "onOpenChange", "onChangeWithDateFirst", "popupClassName", "hideDisabledOptions", "use12Hours", "minuteStep", "hourStep", "secondStep", "scrollItemProps", "triggerRender", "motion", "autoAdjustOverflow"]);
|
|
313
312
|
|
|
314
313
|
const format = this.foundation.getDefaultFormatIfNeed();
|
|
315
314
|
const position = this.foundation.getPosition();
|
|
@@ -469,6 +468,7 @@ TimePicker.defaultProps = _Object$assign({
|
|
|
469
468
|
onFocus: _noop,
|
|
470
469
|
onBlur: _noop,
|
|
471
470
|
onChange: _noop,
|
|
471
|
+
onChangeWithDateFirst: true,
|
|
472
472
|
use12Hours: false,
|
|
473
473
|
focusOnOpen: false,
|
|
474
474
|
onKeyDown: _noop,
|
|
@@ -91,6 +91,7 @@ export default class LocaleTimePicker extends React.PureComponent<LocalePickerPr
|
|
|
91
91
|
onFocus: (...args: any[]) => void;
|
|
92
92
|
onBlur: (...args: any[]) => void;
|
|
93
93
|
onChange: (...args: any[]) => void;
|
|
94
|
+
onChangeWithDateFirst: boolean;
|
|
94
95
|
use12Hours: boolean;
|
|
95
96
|
focusOnOpen: boolean;
|
|
96
97
|
onKeyDown: (...args: any[]) => void;
|
|
@@ -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;
|
package/lib/es/tree/treeNode.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _isEmpty from "lodash/isEmpty";
|
|
1
2
|
import _get from "lodash/get";
|
|
2
3
|
import _isString from "lodash/isString";
|
|
3
4
|
import _isFunction from "lodash/isFunction";
|
|
@@ -470,7 +471,14 @@ export default class TreeNode extends PureComponent {
|
|
|
470
471
|
ref: this.setRef
|
|
471
472
|
}, dragProps));
|
|
472
473
|
} else {
|
|
473
|
-
|
|
474
|
+
if (_isEmpty(style)) {
|
|
475
|
+
return customLabel;
|
|
476
|
+
} else {
|
|
477
|
+
// In virtualization, props.style will contain location information
|
|
478
|
+
return /*#__PURE__*/React.cloneElement(customLabel, {
|
|
479
|
+
style: _Object$assign(_Object$assign({}, _get(customLabel, ['props', 'style'])), style)
|
|
480
|
+
});
|
|
481
|
+
}
|
|
474
482
|
}
|
|
475
483
|
}
|
|
476
484
|
|
|
@@ -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
|
/**
|
|
@@ -17,7 +17,7 @@ import ReactDOM from 'react-dom';
|
|
|
17
17
|
import cls from 'classnames';
|
|
18
18
|
import PropTypes from 'prop-types';
|
|
19
19
|
import TreeSelectFoundation from '@douyinfe/semi-foundation/lib/es/treeSelect/foundation';
|
|
20
|
-
import { convertDataToEntities, flattenTreeData, calcExpandedKeysForValues, calcMotionKeys, findKeysForValues, calcCheckedKeys, calcExpandedKeys, getValueOrKey, normalizeKeyList, calcDisabledKeys, normalizeValue } from '@douyinfe/semi-foundation/lib/es/tree/treeUtil';
|
|
20
|
+
import { convertDataToEntities, flattenTreeData, calcExpandedKeysForValues, calcMotionKeys, findKeysForValues, calcCheckedKeys, calcExpandedKeys, getValueOrKey, normalizeKeyList, calcDisabledKeys, normalizeValue, updateKeys } from '@douyinfe/semi-foundation/lib/es/tree/treeUtil';
|
|
21
21
|
import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/treeSelect/constants';
|
|
22
22
|
import { numbers as popoverNumbers } from '@douyinfe/semi-foundation/lib/es/popover/constants';
|
|
23
23
|
import { FixedSizeList as VirtualList } from 'react-window';
|
|
@@ -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',
|
|
@@ -896,7 +927,7 @@ class TreeSelect extends BaseComponent {
|
|
|
896
927
|
} // if treeData keys changes, we won't show animation
|
|
897
928
|
|
|
898
929
|
|
|
899
|
-
if (treeData && props.motion && !_isEqual(
|
|
930
|
+
if (treeData && props.motion && !_isEqual(_Object$keys(newState.keyEntities), _Object$keys(prevState.keyEntities))) {
|
|
900
931
|
if (prevProps && props.motion) {
|
|
901
932
|
newState.motionKeys = new _Set([]);
|
|
902
933
|
newState.motionType = null;
|
|
@@ -942,7 +973,11 @@ class TreeSelect extends BaseComponent {
|
|
|
942
973
|
newState.selectedKeys = findKeysForValues(normalizeValue(props.defaultValue, withObject), valueEntities, isMultiple);
|
|
943
974
|
} else if (treeData) {
|
|
944
975
|
// If `treeData` changed, we also need check it
|
|
945
|
-
|
|
976
|
+
if (props.value) {
|
|
977
|
+
newState.selectedKeys = findKeysForValues(normalizeValue(props.value, withObject) || '', valueEntities, isMultiple);
|
|
978
|
+
} else {
|
|
979
|
+
newState.selectedKeys = updateKeys(prevState.selectedKeys, keyEntities);
|
|
980
|
+
}
|
|
946
981
|
}
|
|
947
982
|
} else {
|
|
948
983
|
// checkedKeys: multiple mode controlled || data changed
|
|
@@ -954,16 +989,24 @@ class TreeSelect extends BaseComponent {
|
|
|
954
989
|
checkedKeyValues = findKeysForValues(normalizeValue(props.defaultValue, withObject), valueEntities, isMultiple);
|
|
955
990
|
} else if (treeData) {
|
|
956
991
|
// If `treeData` changed, we also need check it
|
|
957
|
-
|
|
992
|
+
if (props.value) {
|
|
993
|
+
checkedKeyValues = findKeysForValues(normalizeValue(props.value, withObject) || [], valueEntities, isMultiple);
|
|
994
|
+
} else {
|
|
995
|
+
checkedKeyValues = updateKeys(prevState.checkedKeys, keyEntities);
|
|
996
|
+
}
|
|
958
997
|
}
|
|
959
998
|
|
|
960
999
|
if (checkedKeyValues) {
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
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
|
+
}
|
|
967
1010
|
}
|
|
968
1011
|
} // loadedKeys
|
|
969
1012
|
|
|
@@ -978,7 +1021,7 @@ class TreeSelect extends BaseComponent {
|
|
|
978
1021
|
} // ================ disableStrictly =================
|
|
979
1022
|
|
|
980
1023
|
|
|
981
|
-
if (treeData && props.disableStrictly) {
|
|
1024
|
+
if (treeData && props.disableStrictly && props.checkRelation === 'related') {
|
|
982
1025
|
newState.disabledKeys = calcDisabledKeys(keyEntities);
|
|
983
1026
|
}
|
|
984
1027
|
|
|
@@ -1244,6 +1287,7 @@ TreeSelect.propTypes = {
|
|
|
1244
1287
|
optionListStyle: PropTypes.object,
|
|
1245
1288
|
searchRender: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
|
|
1246
1289
|
renderSelectedItem: PropTypes.func,
|
|
1290
|
+
checkRelation: PropTypes.string,
|
|
1247
1291
|
'aria-label': PropTypes.string
|
|
1248
1292
|
};
|
|
1249
1293
|
TreeSelect.defaultProps = {
|
|
@@ -1272,6 +1316,7 @@ TreeSelect.defaultProps = {
|
|
|
1272
1316
|
expandAction: false,
|
|
1273
1317
|
clickToHide: true,
|
|
1274
1318
|
searchAutoFocus: false,
|
|
1319
|
+
checkRelation: 'related',
|
|
1275
1320
|
'aria-label': 'TreeSelect'
|
|
1276
1321
|
};
|
|
1277
1322
|
export default TreeSelect;
|
|
@@ -62,7 +62,6 @@ const getRenderText = function (originEle, rows) {
|
|
|
62
62
|
ellipsisContainer.style.zIndex = '-1000'; // clean up css overflow
|
|
63
63
|
|
|
64
64
|
ellipsisContainer.style.textOverflow = 'clip';
|
|
65
|
-
ellipsisContainer.style.whiteSpace = 'normal';
|
|
66
65
|
ellipsisContainer.style.webkitLineClamp = 'none'; // Render fake container
|
|
67
66
|
|
|
68
67
|
ReactDOM.render( /*#__PURE__*/React.createElement(React.Fragment, null), ellipsisContainer); // Check if ellipsis in measure div is height enough for content
|