@douyinfe/semi-ui 2.6.0-beta.0 → 2.7.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/button/__test__/button.test.js +7 -0
- package/button/buttonGroup.tsx +5 -2
- package/button/index.tsx +1 -1
- package/cascader/__test__/cascader.test.js +159 -81
- package/cascader/_story/cascader.stories.js +36 -23
- package/cascader/index.tsx +26 -5
- package/datePicker/_story/v2/InsetInput.jsx +104 -0
- package/datePicker/_story/v2/InsetInputE2E.jsx +69 -0
- package/datePicker/_story/v2/index.js +2 -0
- package/datePicker/dateInput.tsx +95 -9
- package/datePicker/datePicker.tsx +89 -15
- package/datePicker/index.tsx +15 -0
- package/datePicker/insetInput.tsx +76 -0
- package/datePicker/monthsGrid.tsx +14 -7
- package/dist/css/semi.css +105 -2
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +949 -163
- 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/hooks/useFormApi.tsx +3 -2
- package/input/_story/input.stories.js +13 -0
- package/lib/cjs/button/Button.d.ts +4 -4
- package/lib/cjs/button/buttonGroup.d.ts +3 -2
- package/lib/cjs/button/buttonGroup.js +6 -2
- package/lib/cjs/button/index.d.ts +5 -6
- package/lib/cjs/cascader/index.d.ts +1 -0
- package/lib/cjs/cascader/index.js +38 -9
- package/lib/cjs/datePicker/dateInput.d.ts +9 -2
- package/lib/cjs/datePicker/dateInput.js +92 -9
- package/lib/cjs/datePicker/datePicker.d.ts +7 -2
- package/lib/cjs/datePicker/datePicker.js +123 -18
- package/lib/cjs/datePicker/index.js +24 -2
- package/lib/cjs/datePicker/insetInput.d.ts +21 -0
- package/lib/cjs/datePicker/insetInput.js +80 -0
- package/lib/cjs/datePicker/monthsGrid.js +19 -7
- package/lib/cjs/form/hooks/useFormApi.d.ts +2 -1
- package/lib/cjs/iconButton/index.d.ts +2 -2
- package/lib/cjs/navigation/Item.d.ts +2 -2
- package/lib/cjs/navigation/Item.js +8 -6
- package/lib/cjs/navigation/SubNav.js +2 -2
- package/lib/cjs/radio/radioGroup.js +6 -0
- package/lib/cjs/select/index.js +5 -2
- package/lib/cjs/table/Body/index.d.ts +2 -0
- package/lib/cjs/table/Body/index.js +13 -4
- package/lib/cjs/tag/group.d.ts +2 -0
- package/lib/cjs/tag/group.js +4 -2
- package/lib/cjs/tooltip/index.js +6 -2
- package/lib/cjs/tree/index.js +5 -3
- package/lib/cjs/tree/interface.d.ts +1 -0
- package/lib/cjs/tree/nodeList.js +3 -1
- package/lib/cjs/treeSelect/index.js +11 -3
- package/lib/es/button/Button.d.ts +4 -4
- package/lib/es/button/buttonGroup.d.ts +3 -2
- package/lib/es/button/buttonGroup.js +5 -2
- package/lib/es/button/index.d.ts +5 -6
- package/lib/es/cascader/index.d.ts +1 -0
- package/lib/es/cascader/index.js +35 -6
- package/lib/es/datePicker/dateInput.d.ts +9 -2
- package/lib/es/datePicker/dateInput.js +91 -9
- package/lib/es/datePicker/datePicker.d.ts +7 -2
- package/lib/es/datePicker/datePicker.js +124 -18
- package/lib/es/datePicker/index.js +20 -0
- package/lib/es/datePicker/insetInput.d.ts +21 -0
- package/lib/es/datePicker/insetInput.js +65 -0
- package/lib/es/datePicker/monthsGrid.js +19 -7
- package/lib/es/form/hooks/useFormApi.d.ts +2 -1
- package/lib/es/iconButton/index.d.ts +2 -2
- package/lib/es/navigation/Item.d.ts +2 -2
- package/lib/es/navigation/Item.js +8 -6
- package/lib/es/navigation/SubNav.js +2 -2
- package/lib/es/radio/radioGroup.js +6 -0
- package/lib/es/select/index.js +5 -2
- package/lib/es/table/Body/index.d.ts +2 -0
- package/lib/es/table/Body/index.js +13 -4
- package/lib/es/tag/group.d.ts +2 -0
- package/lib/es/tag/group.js +4 -2
- package/lib/es/tooltip/index.js +6 -2
- package/lib/es/tree/index.js +5 -3
- package/lib/es/tree/interface.d.ts +1 -0
- package/lib/es/tree/nodeList.js +3 -1
- package/lib/es/treeSelect/index.js +11 -3
- package/navigation/Item.tsx +15 -12
- package/navigation/SubNav.tsx +4 -4
- package/package.json +9 -9
- package/radio/__test__/radioGroup.test.jsx +9 -1
- package/radio/_story/radio.stories.js +22 -1
- package/radio/radioGroup.tsx +9 -0
- package/select/_story/select.stories.js +73 -2
- package/select/index.tsx +5 -3
- package/table/Body/index.tsx +15 -4
- package/table/__test__/table.test.js +18 -0
- package/table/_story/v2/FixedExpandedRow/index.jsx +95 -0
- package/table/_story/v2/index.js +2 -1
- package/tag/group.tsx +5 -3
- package/tooltip/_story/tooltip.stories.js +702 -625
- package/tooltip/index.tsx +2 -2
- package/tree/__test__/tree.test.js +87 -2
- package/tree/_story/tree.stories.js +65 -5
- package/tree/index.tsx +4 -2
- package/tree/interface.ts +1 -0
- package/tree/nodeList.tsx +3 -2
- package/treeSelect/__test__/treeSelect.test.js +28 -0
- package/treeSelect/_story/treeSelect.stories.js +55 -2
- package/treeSelect/index.tsx +14 -3
|
@@ -418,8 +418,13 @@ class Body extends _baseComponent.default {
|
|
|
418
418
|
const {
|
|
419
419
|
flattenedColumns,
|
|
420
420
|
getCellWidths
|
|
421
|
-
} = _this.context;
|
|
422
|
-
|
|
421
|
+
} = _this.context; // we use memoized cellWidths to avoid re-render expanded row (fix #686)
|
|
422
|
+
|
|
423
|
+
if (flattenedColumns !== _this.flattenedColumns) {
|
|
424
|
+
_this.flattenedColumns = flattenedColumns;
|
|
425
|
+
_this.cellWidths = getCellWidths(flattenedColumns);
|
|
426
|
+
}
|
|
427
|
+
|
|
423
428
|
return /*#__PURE__*/_react.default.createElement(_ExpandedRow.default, {
|
|
424
429
|
style: style,
|
|
425
430
|
components: components,
|
|
@@ -431,7 +436,7 @@ class Body extends _baseComponent.default {
|
|
|
431
436
|
index: index,
|
|
432
437
|
virtualized: virtualized,
|
|
433
438
|
key: (0, _utils.genExpandedRowKey)(key),
|
|
434
|
-
cellWidths: cellWidths
|
|
439
|
+
cellWidths: _this.cellWidths
|
|
435
440
|
});
|
|
436
441
|
};
|
|
437
442
|
/**
|
|
@@ -601,7 +606,9 @@ class Body extends _baseComponent.default {
|
|
|
601
606
|
};
|
|
602
607
|
this.listRef = /*#__PURE__*/_react.default.createRef();
|
|
603
608
|
const {
|
|
604
|
-
getVirtualizedListRef
|
|
609
|
+
getVirtualizedListRef,
|
|
610
|
+
flattenedColumns,
|
|
611
|
+
getCellWidths
|
|
605
612
|
} = context;
|
|
606
613
|
|
|
607
614
|
if (getVirtualizedListRef) {
|
|
@@ -613,6 +620,8 @@ class Body extends _baseComponent.default {
|
|
|
613
620
|
}
|
|
614
621
|
|
|
615
622
|
this.foundation = new _bodyFoundation.default(this.adapter);
|
|
623
|
+
this.flattenedColumns = flattenedColumns;
|
|
624
|
+
this.cellWidths = getCellWidths(flattenedColumns);
|
|
616
625
|
this.observer = null;
|
|
617
626
|
}
|
|
618
627
|
|
package/lib/cjs/tag/group.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface TagGroupProps {
|
|
|
7
7
|
style?: React.CSSProperties;
|
|
8
8
|
className?: string;
|
|
9
9
|
maxTagCount?: number;
|
|
10
|
+
restCount?: number;
|
|
10
11
|
tagList?: (TagProps | React.ReactNode)[];
|
|
11
12
|
size?: 'small' | 'large';
|
|
12
13
|
showPopover?: boolean;
|
|
@@ -26,6 +27,7 @@ export default class TagGroup extends PureComponent<TagGroupProps> {
|
|
|
26
27
|
style: PropTypes.Requireable<object>;
|
|
27
28
|
className: PropTypes.Requireable<string>;
|
|
28
29
|
maxTagCount: PropTypes.Requireable<number>;
|
|
30
|
+
restCount: PropTypes.Requireable<number>;
|
|
29
31
|
tagList: PropTypes.Requireable<any[]>;
|
|
30
32
|
size: PropTypes.Requireable<string>;
|
|
31
33
|
mode: PropTypes.Requireable<string>;
|
package/lib/cjs/tag/group.js
CHANGED
|
@@ -77,9 +77,10 @@ class TagGroup extends _react.PureComponent {
|
|
|
77
77
|
renderMergeTags(tags) {
|
|
78
78
|
const {
|
|
79
79
|
maxTagCount,
|
|
80
|
-
tagList
|
|
80
|
+
tagList,
|
|
81
|
+
restCount
|
|
81
82
|
} = this.props;
|
|
82
|
-
const n = tagList.length - maxTagCount;
|
|
83
|
+
const n = restCount ? restCount : tagList.length - maxTagCount;
|
|
83
84
|
let renderTags = tags;
|
|
84
85
|
const normalTags = (0, _slice.default)(tags).call(tags, 0, maxTagCount);
|
|
85
86
|
const restTags = (0, _slice.default)(tags).call(tags, maxTagCount);
|
|
@@ -156,6 +157,7 @@ TagGroup.propTypes = {
|
|
|
156
157
|
style: _propTypes.default.object,
|
|
157
158
|
className: _propTypes.default.string,
|
|
158
159
|
maxTagCount: _propTypes.default.number,
|
|
160
|
+
restCount: _propTypes.default.number,
|
|
159
161
|
tagList: _propTypes.default.array,
|
|
160
162
|
size: _propTypes.default.oneOf(tagSize),
|
|
161
163
|
mode: _propTypes.default.string,
|
package/lib/cjs/tooltip/index.js
CHANGED
|
@@ -229,7 +229,9 @@ class Tooltip extends _baseComponent.default {
|
|
|
229
229
|
} = _ref;
|
|
230
230
|
return /*#__PURE__*/_react.default.createElement("div", (0, _assign.default)({
|
|
231
231
|
className: (0, _classnames.default)(className, animateCls),
|
|
232
|
-
style: (0, _assign.default)((0, _assign.default)((0, _assign.default)({
|
|
232
|
+
style: (0, _assign.default)((0, _assign.default)((0, _assign.default)({
|
|
233
|
+
visibility: 'visible'
|
|
234
|
+
}, animateStyle), {
|
|
233
235
|
transformOrigin
|
|
234
236
|
}), style)
|
|
235
237
|
}, portalEventSet, animateEvents, {
|
|
@@ -241,7 +243,9 @@ class Tooltip extends _baseComponent.default {
|
|
|
241
243
|
className: className
|
|
242
244
|
}, portalEventSet, {
|
|
243
245
|
"x-placement": placement,
|
|
244
|
-
style:
|
|
246
|
+
style: (0, _assign.default)({
|
|
247
|
+
visibility: motion ? undefined : 'visible'
|
|
248
|
+
}, style)
|
|
245
249
|
}), content, icon);
|
|
246
250
|
return /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
247
251
|
getPopupContainer: this.props.getPopupContainer,
|
package/lib/cjs/tree/index.js
CHANGED
|
@@ -275,7 +275,8 @@ class Tree extends _baseComponent.default {
|
|
|
275
275
|
const isSeaching = Boolean(props.filterTreeNode && prevState.inputValue && prevState.inputValue.length);
|
|
276
276
|
const newState = {
|
|
277
277
|
prevProps: props
|
|
278
|
-
};
|
|
278
|
+
};
|
|
279
|
+
const isExpandControlled = ('expandedKeys' in props); // Accept a props field as a parameter to determine whether to update the field
|
|
279
280
|
|
|
280
281
|
const needUpdate = name => {
|
|
281
282
|
const firstInProps = !prevProps && name in props;
|
|
@@ -319,7 +320,8 @@ class Tree extends _baseComponent.default {
|
|
|
319
320
|
}
|
|
320
321
|
}
|
|
321
322
|
|
|
322
|
-
const
|
|
323
|
+
const dataUpdated = needUpdate('treeDataSimpleJson') || needUpdate('treeData');
|
|
324
|
+
const expandAllWhenDataChange = dataUpdated && props.expandAll;
|
|
323
325
|
|
|
324
326
|
if (!isSeaching) {
|
|
325
327
|
// Update expandedKeys
|
|
@@ -345,7 +347,7 @@ class Tree extends _baseComponent.default {
|
|
|
345
347
|
newState.expandedKeys = (0, _treeUtil.calcExpandedKeys)(props.defaultExpandedKeys, keyEntities);
|
|
346
348
|
} else if (!prevProps && props.defaultValue) {
|
|
347
349
|
newState.expandedKeys = (0, _treeUtil.calcExpandedKeysForValues)(props.defaultValue, keyEntities, props.multiple, valueEntities);
|
|
348
|
-
} else if (!prevProps && props.value) {
|
|
350
|
+
} else if ((!prevProps || !isExpandControlled && dataUpdated) && props.value) {
|
|
349
351
|
newState.expandedKeys = (0, _treeUtil.calcExpandedKeysForValues)(props.value, keyEntities, props.multiple, valueEntities);
|
|
350
352
|
}
|
|
351
353
|
|
|
@@ -109,6 +109,7 @@ export interface NodeListProps {
|
|
|
109
109
|
motionKeys: Set<string>;
|
|
110
110
|
motionType: string;
|
|
111
111
|
flattenList: FlattenNode[] | undefined;
|
|
112
|
+
searchTargetIsDeep?: boolean;
|
|
112
113
|
renderTreeNode: (treeNode: FlattenNode, ind?: number, style?: React.CSSProperties) => ReactNode;
|
|
113
114
|
}
|
|
114
115
|
export declare type TransitionNodes<T> = Array<T | Array<T>>;
|
package/lib/cjs/tree/nodeList.js
CHANGED
|
@@ -49,6 +49,7 @@ class NodeList extends _react.PureComponent {
|
|
|
49
49
|
super(props);
|
|
50
50
|
|
|
51
51
|
this.onMotionEnd = () => {
|
|
52
|
+
typeof this.props.onMotionEnd === 'function' && this.props.onMotionEnd();
|
|
52
53
|
this.setState({
|
|
53
54
|
transitionNodes: []
|
|
54
55
|
});
|
|
@@ -107,12 +108,13 @@ class NodeList extends _react.PureComponent {
|
|
|
107
108
|
const {
|
|
108
109
|
flattenNodes,
|
|
109
110
|
motionType,
|
|
111
|
+
searchTargetIsDeep,
|
|
110
112
|
renderTreeNode
|
|
111
113
|
} = this.props;
|
|
112
114
|
const {
|
|
113
115
|
transitionNodes
|
|
114
116
|
} = this.state;
|
|
115
|
-
const mapData = transitionNodes.length ? transitionNodes : flattenNodes;
|
|
117
|
+
const mapData = transitionNodes.length && !searchTargetIsDeep ? transitionNodes : flattenNodes;
|
|
116
118
|
const options = (0, _map.default)(mapData).call(mapData, treeNode => {
|
|
117
119
|
const isMotionNode = (0, _isArray.default)(treeNode);
|
|
118
120
|
|
|
@@ -795,7 +795,8 @@ class TreeSelect extends _baseComponent.default {
|
|
|
795
795
|
const {
|
|
796
796
|
flattenNodes,
|
|
797
797
|
motionKeys,
|
|
798
|
-
motionType
|
|
798
|
+
motionType,
|
|
799
|
+
filteredKeys
|
|
799
800
|
} = this.state;
|
|
800
801
|
const {
|
|
801
802
|
direction
|
|
@@ -804,6 +805,7 @@ class TreeSelect extends _baseComponent.default {
|
|
|
804
805
|
virtualize,
|
|
805
806
|
motionExpand
|
|
806
807
|
} = this.props;
|
|
808
|
+
const isExpandControlled = ('expandedKeys' in this.props);
|
|
807
809
|
|
|
808
810
|
if (!virtualize || (0, _isEmpty2.default)(virtualize)) {
|
|
809
811
|
return /*#__PURE__*/_react.default.createElement(_nodeList.default, {
|
|
@@ -811,6 +813,8 @@ class TreeSelect extends _baseComponent.default {
|
|
|
811
813
|
flattenList: this._flattenNodes,
|
|
812
814
|
motionKeys: motionExpand ? motionKeys : new _set.default([]),
|
|
813
815
|
motionType: motionType,
|
|
816
|
+
// When motionKeys is empty, but filteredKeys is not empty (that is, the search hits), this situation should be distinguished from ordinary motionKeys
|
|
817
|
+
searchTargetIsDeep: isExpandControlled && motionExpand && (0, _isEmpty2.default)(motionKeys) && !(0, _isEmpty2.default)(filteredKeys),
|
|
814
818
|
onMotionEnd: this.onMotionEnd,
|
|
815
819
|
renderTreeNode: this.renderTreeNode
|
|
816
820
|
});
|
|
@@ -951,6 +955,10 @@ class TreeSelect extends _baseComponent.default {
|
|
|
951
955
|
this.clickOutsideHandler = null;
|
|
952
956
|
this.foundation = new _foundation.default(this.adapter);
|
|
953
957
|
this.treeSelectID = (0, _slice.default)(_context2 = Math.random().toString(36)).call(_context2, 2);
|
|
958
|
+
|
|
959
|
+
this.onMotionEnd = () => {
|
|
960
|
+
this.adapter.rePositionDropdown();
|
|
961
|
+
};
|
|
954
962
|
} // eslint-disable-next-line max-lines-per-function
|
|
955
963
|
|
|
956
964
|
|
|
@@ -1131,8 +1139,8 @@ class TreeSelect extends _baseComponent.default {
|
|
|
1131
1139
|
notifySelect: (selectKey, bool, node) => {
|
|
1132
1140
|
this.props.onSelect && this.props.onSelect(selectKey, bool, node);
|
|
1133
1141
|
},
|
|
1134
|
-
notifySearch: input => {
|
|
1135
|
-
this.props.onSearch && this.props.onSearch(input);
|
|
1142
|
+
notifySearch: (input, filteredExpandedKeys) => {
|
|
1143
|
+
this.props.onSearch && this.props.onSearch(input, filteredExpandedKeys);
|
|
1136
1144
|
},
|
|
1137
1145
|
cacheFlattenNodes: bool => {
|
|
1138
1146
|
this._flattenNodes = bool ? (0, _treeUtil2.cloneDeep)(this.state.flattenNodes) : null;
|
|
@@ -46,15 +46,15 @@ export default class Button extends PureComponent<ButtonProps> {
|
|
|
46
46
|
disabled: PropTypes.Requireable<boolean>;
|
|
47
47
|
prefixCls: PropTypes.Requireable<string>;
|
|
48
48
|
style: PropTypes.Requireable<object>;
|
|
49
|
-
size: PropTypes.Requireable<
|
|
50
|
-
type: PropTypes.Requireable<
|
|
49
|
+
size: PropTypes.Requireable<"default" | "small" | "large">;
|
|
50
|
+
type: PropTypes.Requireable<"warning" | "primary" | "tertiary" | "secondary" | "danger">;
|
|
51
51
|
block: PropTypes.Requireable<boolean>;
|
|
52
52
|
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
53
53
|
onMouseDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
54
54
|
circle: PropTypes.Requireable<boolean>;
|
|
55
55
|
loading: PropTypes.Requireable<boolean>;
|
|
56
|
-
htmlType: PropTypes.Requireable<
|
|
57
|
-
theme: PropTypes.Requireable<
|
|
56
|
+
htmlType: PropTypes.Requireable<"button" | "reset" | "submit">;
|
|
57
|
+
theme: PropTypes.Requireable<"solid" | "light" | "borderless">;
|
|
58
58
|
className: PropTypes.Requireable<string>;
|
|
59
59
|
onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
|
|
60
60
|
onMouseLeave: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -9,6 +9,7 @@ export interface ButtonGroupProps extends BaseProps {
|
|
|
9
9
|
type?: Type;
|
|
10
10
|
size?: Size;
|
|
11
11
|
theme?: Theme;
|
|
12
|
+
className?: string;
|
|
12
13
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
13
14
|
}
|
|
14
15
|
export default class ButtonGroup extends BaseComponent<ButtonGroupProps> {
|
|
@@ -16,8 +17,8 @@ export default class ButtonGroup extends BaseComponent<ButtonGroupProps> {
|
|
|
16
17
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
17
18
|
disabled: PropTypes.Requireable<boolean>;
|
|
18
19
|
type: PropTypes.Requireable<string>;
|
|
19
|
-
size: PropTypes.Requireable<
|
|
20
|
-
theme: PropTypes.Requireable<
|
|
20
|
+
size: PropTypes.Requireable<"default" | "small" | "large">;
|
|
21
|
+
theme: PropTypes.Requireable<"solid" | "light" | "borderless">;
|
|
21
22
|
'aria-label': PropTypes.Requireable<string>;
|
|
22
23
|
};
|
|
23
24
|
static defaultProps: {
|
|
@@ -18,6 +18,7 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
18
18
|
import React, { isValidElement, cloneElement } from 'react';
|
|
19
19
|
import BaseComponent from '../_base/baseComponent';
|
|
20
20
|
import PropTypes from 'prop-types';
|
|
21
|
+
import classNames from 'classnames';
|
|
21
22
|
import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/button/constants';
|
|
22
23
|
import '@douyinfe/semi-foundation/lib/es/button/button.css';
|
|
23
24
|
const prefixCls = cssClasses.PREFIX;
|
|
@@ -30,11 +31,13 @@ export default class ButtonGroup extends BaseComponent {
|
|
|
30
31
|
disabled,
|
|
31
32
|
size,
|
|
32
33
|
type,
|
|
34
|
+
className,
|
|
33
35
|
'aria-label': ariaLabel
|
|
34
36
|
} = _a,
|
|
35
|
-
rest = __rest(_a, ["children", "disabled", "size", "type", 'aria-label']);
|
|
37
|
+
rest = __rest(_a, ["children", "disabled", "size", "type", "className", 'aria-label']);
|
|
36
38
|
|
|
37
39
|
let inner;
|
|
40
|
+
const cls = classNames("".concat(prefixCls, "-group"), className);
|
|
38
41
|
|
|
39
42
|
if (children) {
|
|
40
43
|
var _context;
|
|
@@ -49,7 +52,7 @@ export default class ButtonGroup extends BaseComponent {
|
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
return /*#__PURE__*/React.createElement("div", {
|
|
52
|
-
className:
|
|
55
|
+
className: cls,
|
|
53
56
|
role: "group",
|
|
54
57
|
"aria-label": ariaLabel
|
|
55
58
|
}, inner);
|
package/lib/es/button/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ButtonProps as BaseButtonProps } from './Button';
|
|
3
2
|
import { IconButtonProps } from '../iconButton';
|
|
4
3
|
export { ButtonProps as BaseButtonProps, HtmlType, Size, Theme, Type } from './Button';
|
|
5
4
|
export { HorizontalPaddingType } from '../iconButton';
|
|
6
5
|
export { ButtonGroupProps } from './buttonGroup';
|
|
7
6
|
export { SplitButtonGroupProps } from './splitButtonGroup';
|
|
8
|
-
export interface ButtonProps extends IconButtonProps
|
|
7
|
+
export interface ButtonProps extends IconButtonProps {
|
|
9
8
|
}
|
|
10
9
|
declare class Button extends React.PureComponent<ButtonProps> {
|
|
11
10
|
static propTypes: {
|
|
@@ -18,18 +17,18 @@ declare class Button extends React.PureComponent<ButtonProps> {
|
|
|
18
17
|
noHorizontalPadding: import("prop-types").Requireable<string | boolean | any[]>;
|
|
19
18
|
children: import("prop-types").Requireable<import("prop-types").ReactNodeLike>;
|
|
20
19
|
theme: import("prop-types").Requireable<string>;
|
|
21
|
-
iconPosition: import("prop-types").Requireable<
|
|
20
|
+
iconPosition: import("prop-types").Requireable<"left" | "right">;
|
|
22
21
|
className: import("prop-types").Requireable<string>;
|
|
23
22
|
onMouseEnter: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
24
23
|
onMouseLeave: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
25
24
|
disabled: import("prop-types").Requireable<boolean>;
|
|
26
|
-
size: import("prop-types").Requireable<
|
|
27
|
-
type: import("prop-types").Requireable<
|
|
25
|
+
size: import("prop-types").Requireable<"default" | "small" | "large">;
|
|
26
|
+
type: import("prop-types").Requireable<"warning" | "primary" | "tertiary" | "secondary" | "danger">;
|
|
28
27
|
block: import("prop-types").Requireable<boolean>;
|
|
29
28
|
onClick: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
30
29
|
onMouseDown: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
31
30
|
circle: import("prop-types").Requireable<boolean>;
|
|
32
|
-
htmlType: import("prop-types").Requireable<
|
|
31
|
+
htmlType: import("prop-types").Requireable<"button" | "reset" | "submit">;
|
|
33
32
|
'aria-label': import("prop-types").Requireable<string>;
|
|
34
33
|
};
|
|
35
34
|
constructor(props?: {});
|
|
@@ -187,6 +187,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
187
187
|
renderContent: () => JSX.Element;
|
|
188
188
|
renderPlusN: (hiddenTag: Array<ReactNode>) => JSX.Element;
|
|
189
189
|
renderMultipleTags: () => JSX.Element;
|
|
190
|
+
renderDisplayText: () => ReactNode;
|
|
190
191
|
renderSelectContent: () => JSX.Element;
|
|
191
192
|
renderSuffix: () => JSX.Element;
|
|
192
193
|
renderPrefix: () => JSX.Element;
|
package/lib/es/cascader/index.js
CHANGED
|
@@ -9,10 +9,10 @@ import _isSet from "lodash/isSet";
|
|
|
9
9
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
10
10
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
11
11
|
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
12
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
12
13
|
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
|
13
14
|
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
14
15
|
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
|
15
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
16
16
|
import React, { Fragment } from 'react';
|
|
17
17
|
import ReactDOM from 'react-dom';
|
|
18
18
|
import cls from 'classnames';
|
|
@@ -210,6 +210,36 @@ class Cascader extends BaseComponent {
|
|
|
210
210
|
return /*#__PURE__*/React.createElement(React.Fragment, null, displayTag, !_isEmpty(hiddenTag) && this.renderPlusN(hiddenTag));
|
|
211
211
|
};
|
|
212
212
|
|
|
213
|
+
this.renderDisplayText = () => {
|
|
214
|
+
const {
|
|
215
|
+
displayProp,
|
|
216
|
+
separator,
|
|
217
|
+
displayRender
|
|
218
|
+
} = this.props;
|
|
219
|
+
const {
|
|
220
|
+
selectedKeys
|
|
221
|
+
} = this.state;
|
|
222
|
+
let displayText = '';
|
|
223
|
+
|
|
224
|
+
if (selectedKeys.size) {
|
|
225
|
+
const displayPath = this.foundation.getItemPropPath([...selectedKeys][0], displayProp);
|
|
226
|
+
|
|
227
|
+
if (displayRender && typeof displayRender === 'function') {
|
|
228
|
+
displayText = displayRender(displayPath);
|
|
229
|
+
} else {
|
|
230
|
+
displayText = _mapInstanceProperty(displayPath).call(displayPath, (path, index) => {
|
|
231
|
+
var _context3;
|
|
232
|
+
|
|
233
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
234
|
+
key: _concatInstanceProperty(_context3 = "".concat(path, "-")).call(_context3, index)
|
|
235
|
+
}, index < displayPath.length - 1 ? /*#__PURE__*/React.createElement(React.Fragment, null, path, separator) : path);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return displayText;
|
|
241
|
+
};
|
|
242
|
+
|
|
213
243
|
this.renderSelectContent = () => {
|
|
214
244
|
const {
|
|
215
245
|
placeholder,
|
|
@@ -217,7 +247,6 @@ class Cascader extends BaseComponent {
|
|
|
217
247
|
multiple
|
|
218
248
|
} = this.props;
|
|
219
249
|
const {
|
|
220
|
-
selectedKeys,
|
|
221
250
|
checkedKeys
|
|
222
251
|
} = this.state;
|
|
223
252
|
const searchable = Boolean(filterTreeNode);
|
|
@@ -232,9 +261,9 @@ class Cascader extends BaseComponent {
|
|
|
232
261
|
|
|
233
262
|
return this.renderMultipleTags();
|
|
234
263
|
} else {
|
|
235
|
-
const displayText =
|
|
264
|
+
const displayText = this.renderDisplayText();
|
|
236
265
|
const spanCls = cls({
|
|
237
|
-
["".concat(prefixcls, "-selection-placeholder")]: !displayText
|
|
266
|
+
["".concat(prefixcls, "-selection-placeholder")]: !displayText
|
|
238
267
|
});
|
|
239
268
|
return /*#__PURE__*/React.createElement("span", {
|
|
240
269
|
className: spanCls
|
|
@@ -779,7 +808,7 @@ class Cascader extends BaseComponent {
|
|
|
779
808
|
}
|
|
780
809
|
|
|
781
810
|
renderTagInput() {
|
|
782
|
-
var
|
|
811
|
+
var _context4;
|
|
783
812
|
|
|
784
813
|
const {
|
|
785
814
|
size,
|
|
@@ -799,7 +828,7 @@ class Cascader extends BaseComponent {
|
|
|
799
828
|
const tagValue = [];
|
|
800
829
|
const realKeys = this.mergeType === strings.NONE_MERGE_TYPE ? checkedKeys : resolvedCheckedKeys;
|
|
801
830
|
|
|
802
|
-
_forEachInstanceProperty(
|
|
831
|
+
_forEachInstanceProperty(_context4 = [...realKeys]).call(_context4, checkedKey => {
|
|
803
832
|
if (!_isEmpty(keyEntities[checkedKey])) {
|
|
804
833
|
tagValue.push(keyEntities[checkedKey].valuePath);
|
|
805
834
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import DateInputFoundation, { DateInputAdapter, DateInputFoundationProps, RangeType } from '@douyinfe/semi-foundation/lib/es/datePicker/inputFoundation';
|
|
3
|
+
import DateInputFoundation, { DateInputAdapter, DateInputFoundationProps, RangeType, InsetInputChangeProps, InsetInputChangeFoundationProps } from '@douyinfe/semi-foundation/lib/es/datePicker/inputFoundation';
|
|
4
4
|
import { noop } from '@douyinfe/semi-foundation/lib/es/utils/function';
|
|
5
|
-
import BaseComponent, { BaseProps } from '../_base/baseComponent';
|
|
6
5
|
import { ValueType } from '@douyinfe/semi-foundation/lib/es/datePicker/foundation';
|
|
6
|
+
import BaseComponent, { BaseProps } from '../_base/baseComponent';
|
|
7
7
|
export interface DateInputProps extends DateInputFoundationProps, BaseProps {
|
|
8
8
|
insetLabel?: React.ReactNode;
|
|
9
9
|
prefix?: React.ReactNode;
|
|
@@ -13,6 +13,8 @@ export interface DateInputProps extends DateInputFoundationProps, BaseProps {
|
|
|
13
13
|
onBlur?: (e: React.MouseEvent<HTMLInputElement>) => void;
|
|
14
14
|
onFocus?: (e: React.MouseEvent<HTMLInputElement>, rangeType?: RangeType) => void;
|
|
15
15
|
onClear?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
16
|
+
onInsetInputChange?: (options: InsetInputChangeProps) => void;
|
|
17
|
+
value?: Date[];
|
|
16
18
|
}
|
|
17
19
|
export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
18
20
|
static propTypes: {
|
|
@@ -39,6 +41,8 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
39
41
|
rangeInputStartRef: PropTypes.Requireable<object>;
|
|
40
42
|
rangeInputEndRef: PropTypes.Requireable<object>;
|
|
41
43
|
rangeSeparator: PropTypes.Requireable<string>;
|
|
44
|
+
insetInput: PropTypes.Requireable<boolean>;
|
|
45
|
+
insetInputValue: PropTypes.Requireable<object>;
|
|
42
46
|
};
|
|
43
47
|
static defaultProps: {
|
|
44
48
|
showClear: boolean;
|
|
@@ -69,11 +73,14 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
69
73
|
handleRangeInputEndKeyPress: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
70
74
|
handleRangeInputFocus: (e: React.MouseEvent<HTMLElement>, rangeType: RangeType) => void;
|
|
71
75
|
handleRangeStartFocus: React.MouseEventHandler<HTMLElement>;
|
|
76
|
+
handleInsetInputChange: (options: InsetInputChangeFoundationProps) => void;
|
|
72
77
|
getRangeInputValue: (rangeStart: string, rangeEnd: string) => string;
|
|
73
78
|
renderRangePrefix(): JSX.Element;
|
|
74
79
|
renderRangeSeparator(rangeStart: string, rangeEnd: string): JSX.Element;
|
|
75
80
|
renderRangeClearBtn(rangeStart: string, rangeEnd: string): JSX.Element;
|
|
76
81
|
renderRangeSuffix(suffix: React.ReactNode): JSX.Element;
|
|
77
82
|
renderRangeInput(rangeProps: DateInputProps): JSX.Element;
|
|
83
|
+
renderInputInset(): JSX.Element;
|
|
84
|
+
renderTriggerInput(): JSX.Element;
|
|
78
85
|
render(): JSX.Element;
|
|
79
86
|
}
|
|
@@ -15,7 +15,9 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
15
15
|
}
|
|
16
16
|
return t;
|
|
17
17
|
};
|
|
18
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events
|
|
18
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
19
|
+
|
|
20
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
19
21
|
|
|
20
22
|
/* eslint-disable max-lines-per-function */
|
|
21
23
|
|
|
@@ -29,9 +31,10 @@ import DateInputFoundation from '@douyinfe/semi-foundation/lib/es/datePicker/inp
|
|
|
29
31
|
import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/datePicker/constants';
|
|
30
32
|
import { noop } from '@douyinfe/semi-foundation/lib/es/utils/function';
|
|
31
33
|
import isNullOrUndefined from '@douyinfe/semi-foundation/lib/es/utils/isNullOrUndefined';
|
|
34
|
+
import { IconCalendar, IconCalendarClock, IconClear } from '@douyinfe/semi-icons';
|
|
32
35
|
import BaseComponent from '../_base/baseComponent';
|
|
33
36
|
import Input from '../input/index';
|
|
34
|
-
import {
|
|
37
|
+
import { InsetDateInput, InsetTimeInput } from './insetInput'; // eslint-disable-next-line @typescript-eslint/ban-types
|
|
35
38
|
|
|
36
39
|
export default class DateInput extends BaseComponent {
|
|
37
40
|
constructor(props) {
|
|
@@ -69,6 +72,10 @@ export default class DateInput extends BaseComponent {
|
|
|
69
72
|
this.handleRangeInputFocus(e, 'rangeStart');
|
|
70
73
|
};
|
|
71
74
|
|
|
75
|
+
this.handleInsetInputChange = options => {
|
|
76
|
+
this.foundation.handleInsetInputChange(options);
|
|
77
|
+
};
|
|
78
|
+
|
|
72
79
|
this.getRangeInputValue = (rangeStart, rangeEnd) => {
|
|
73
80
|
var _context, _context2;
|
|
74
81
|
|
|
@@ -117,7 +124,8 @@ export default class DateInput extends BaseComponent {
|
|
|
117
124
|
},
|
|
118
125
|
notifyTabPress: function () {
|
|
119
126
|
return _this.props.onRangeEndTabPress(...arguments);
|
|
120
|
-
}
|
|
127
|
+
},
|
|
128
|
+
notifyInsetInputChange: options => this.props.onInsetInputChange(options)
|
|
121
129
|
});
|
|
122
130
|
}
|
|
123
131
|
|
|
@@ -222,11 +230,11 @@ export default class DateInput extends BaseComponent {
|
|
|
222
230
|
const rangePlaceholder = _Array$isArray(placeholder) ? placeholder : [placeholder, placeholder];
|
|
223
231
|
const [rangeStartPlaceholder, rangeEndPlaceholder] = rangePlaceholder;
|
|
224
232
|
const inputLeftWrapperCls = cls("".concat(prefixCls, "-range-input-wrapper-start"), "".concat(prefixCls, "-range-input-wrapper"), {
|
|
225
|
-
["".concat(prefixCls, "-range-input-wrapper-active")]: rangeInputFocus === 'rangeStart',
|
|
233
|
+
["".concat(prefixCls, "-range-input-wrapper-active")]: rangeInputFocus === 'rangeStart' && !disabled,
|
|
226
234
|
["".concat(prefixCls, "-range-input-wrapper-start-with-prefix")]: this.props.prefix || this.props.insetLabel
|
|
227
235
|
});
|
|
228
236
|
const inputRightWrapperCls = cls("".concat(prefixCls, "-range-input-wrapper-end"), "".concat(prefixCls, "-range-input-wrapper"), {
|
|
229
|
-
["".concat(prefixCls, "-range-input-wrapper-active")]: rangeInputFocus === 'rangeEnd'
|
|
237
|
+
["".concat(prefixCls, "-range-input-wrapper-active")]: rangeInputFocus === 'rangeEnd' && !disabled
|
|
230
238
|
});
|
|
231
239
|
return /*#__PURE__*/React.createElement(React.Fragment, null, this.renderRangePrefix(), /*#__PURE__*/React.createElement("div", {
|
|
232
240
|
onClick: e => !disabled && this.handleRangeInputFocus(e, 'rangeStart'),
|
|
@@ -265,7 +273,70 @@ export default class DateInput extends BaseComponent {
|
|
|
265
273
|
})), this.renderRangeClearBtn(rangeStart, rangeEnd), this.renderRangeSuffix(suffix));
|
|
266
274
|
}
|
|
267
275
|
|
|
268
|
-
|
|
276
|
+
renderInputInset() {
|
|
277
|
+
const {
|
|
278
|
+
type,
|
|
279
|
+
handleInsetDateFocus,
|
|
280
|
+
handleInsetTimeFocus,
|
|
281
|
+
value,
|
|
282
|
+
insetInputValue,
|
|
283
|
+
prefixCls,
|
|
284
|
+
rangeInputStartRef,
|
|
285
|
+
rangeInputEndRef,
|
|
286
|
+
density
|
|
287
|
+
} = this.props;
|
|
288
|
+
|
|
289
|
+
const _isRangeType = _includesInstanceProperty(type).call(type, 'Range');
|
|
290
|
+
|
|
291
|
+
const newInsetInputValue = this.foundation.getInsetInputValue({
|
|
292
|
+
value,
|
|
293
|
+
insetInputValue
|
|
294
|
+
});
|
|
295
|
+
const {
|
|
296
|
+
datePlaceholder,
|
|
297
|
+
timePlaceholder
|
|
298
|
+
} = this.foundation.getInsetInputPlaceholder();
|
|
299
|
+
const insetInputWrapperCls = "".concat(prefixCls, "-inset-input-wrapper");
|
|
300
|
+
const separatorCls = "".concat(prefixCls, "-inset-input-separator");
|
|
301
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
302
|
+
className: insetInputWrapperCls,
|
|
303
|
+
"x-type": type
|
|
304
|
+
}, /*#__PURE__*/React.createElement(InsetDateInput, {
|
|
305
|
+
forwardRef: rangeInputStartRef,
|
|
306
|
+
insetInputValue: newInsetInputValue,
|
|
307
|
+
placeholder: datePlaceholder,
|
|
308
|
+
valuePath: 'monthLeft.dateInput',
|
|
309
|
+
onChange: this.handleInsetInputChange,
|
|
310
|
+
onFocus: e => handleInsetDateFocus(e, 'rangeStart')
|
|
311
|
+
}), /*#__PURE__*/React.createElement(InsetTimeInput, {
|
|
312
|
+
disabled: !newInsetInputValue.monthLeft.dateInput,
|
|
313
|
+
insetInputValue: newInsetInputValue,
|
|
314
|
+
placeholder: timePlaceholder,
|
|
315
|
+
type: type,
|
|
316
|
+
valuePath: 'monthLeft.timeInput',
|
|
317
|
+
onChange: this.handleInsetInputChange,
|
|
318
|
+
onFocus: handleInsetTimeFocus
|
|
319
|
+
}), _isRangeType && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
320
|
+
className: separatorCls
|
|
321
|
+
}, density === 'compact' ? null : '-'), /*#__PURE__*/React.createElement(InsetDateInput, {
|
|
322
|
+
forwardRef: rangeInputEndRef,
|
|
323
|
+
insetInputValue: newInsetInputValue,
|
|
324
|
+
placeholder: datePlaceholder,
|
|
325
|
+
valuePath: 'monthRight.dateInput',
|
|
326
|
+
onChange: this.handleInsetInputChange,
|
|
327
|
+
onFocus: e => handleInsetDateFocus(e, 'rangeEnd')
|
|
328
|
+
}), /*#__PURE__*/React.createElement(InsetTimeInput, {
|
|
329
|
+
disabled: !newInsetInputValue.monthRight.dateInput,
|
|
330
|
+
insetInputValue: newInsetInputValue,
|
|
331
|
+
placeholder: timePlaceholder,
|
|
332
|
+
type: type,
|
|
333
|
+
valuePath: 'monthRight.timeInput',
|
|
334
|
+
onChange: this.handleInsetInputChange,
|
|
335
|
+
onFocus: handleInsetTimeFocus
|
|
336
|
+
})));
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
renderTriggerInput() {
|
|
269
340
|
const _a = this.props,
|
|
270
341
|
{
|
|
271
342
|
placeholder,
|
|
@@ -297,9 +368,11 @@ export default class DateInput extends BaseComponent {
|
|
|
297
368
|
onRangeBlur,
|
|
298
369
|
onRangeEndTabPress,
|
|
299
370
|
rangeInputFocus,
|
|
300
|
-
rangeSeparator
|
|
371
|
+
rangeSeparator,
|
|
372
|
+
insetInput,
|
|
373
|
+
insetInputValue
|
|
301
374
|
} = _a,
|
|
302
|
-
rest = __rest(_a, ["placeholder", "type", "value", "inputValue", "inputStyle", "disabled", "showClear", "inputReadOnly", "insetLabel", "validateStatus", "block", "prefixCls", "multiple", "dateFnsLocale", "onBlur", "onClear", "onFocus", "prefix", "autofocus", "size", "rangeInputStartRef", "rangeInputEndRef", "onRangeClear", "onRangeBlur", "onRangeEndTabPress", "rangeInputFocus", "rangeSeparator"]);
|
|
375
|
+
rest = __rest(_a, ["placeholder", "type", "value", "inputValue", "inputStyle", "disabled", "showClear", "inputReadOnly", "insetLabel", "validateStatus", "block", "prefixCls", "multiple", "dateFnsLocale", "onBlur", "onClear", "onFocus", "prefix", "autofocus", "size", "rangeInputStartRef", "rangeInputEndRef", "onRangeClear", "onRangeBlur", "onRangeEndTabPress", "rangeInputFocus", "rangeSeparator", "insetInput", "insetInputValue"]);
|
|
303
376
|
|
|
304
377
|
const dateIcon = /*#__PURE__*/React.createElement(IconCalendar, {
|
|
305
378
|
"aria-hidden": true
|
|
@@ -350,6 +423,13 @@ export default class DateInput extends BaseComponent {
|
|
|
350
423
|
}));
|
|
351
424
|
}
|
|
352
425
|
|
|
426
|
+
render() {
|
|
427
|
+
const {
|
|
428
|
+
insetInput
|
|
429
|
+
} = this.props;
|
|
430
|
+
return insetInput ? this.renderInputInset() : this.renderTriggerInput();
|
|
431
|
+
}
|
|
432
|
+
|
|
353
433
|
}
|
|
354
434
|
DateInput.propTypes = {
|
|
355
435
|
onClick: PropTypes.func,
|
|
@@ -374,7 +454,9 @@ DateInput.propTypes = {
|
|
|
374
454
|
rangeInputFocus: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
375
455
|
rangeInputStartRef: PropTypes.object,
|
|
376
456
|
rangeInputEndRef: PropTypes.object,
|
|
377
|
-
rangeSeparator: PropTypes.string
|
|
457
|
+
rangeSeparator: PropTypes.string,
|
|
458
|
+
insetInput: PropTypes.bool,
|
|
459
|
+
insetInputValue: PropTypes.object
|
|
378
460
|
};
|
|
379
461
|
DateInput.defaultProps = {
|
|
380
462
|
showClear: true,
|