@douyinfe/semi-ui 2.30.2 → 2.31.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/dist/css/semi.css +66 -51
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +298 -132
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/_base/base.d.ts +3 -3
- package/lib/cjs/anchor/index.d.ts +1 -1
- package/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/button/Button.d.ts +1 -1
- package/lib/cjs/carousel/index.d.ts +1 -0
- package/lib/cjs/carousel/index.js +17 -1
- package/lib/cjs/cascader/index.js +2 -1
- package/lib/cjs/checkbox/checkbox.d.ts +1 -1
- package/lib/cjs/checkbox/checkboxGroup.d.ts +1 -1
- package/lib/cjs/descriptions/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/image/previewInner.d.ts +1 -2
- package/lib/cjs/image/previewInner.js +5 -6
- package/lib/cjs/layout/index.d.ts +1 -1
- package/lib/cjs/modal/confirm.d.ts +1 -1
- package/lib/cjs/popconfirm/index.js +10 -1
- package/lib/cjs/popover/index.d.ts +1 -0
- package/lib/cjs/progress/index.d.ts +3 -3
- package/lib/cjs/radio/radio.d.ts +1 -1
- package/lib/cjs/select/index.d.ts +2 -2
- package/lib/cjs/select/index.js +3 -7
- package/lib/cjs/select/virtualRow.js +3 -2
- package/lib/cjs/table/Body/index.js +4 -8
- package/lib/cjs/table/ColumnSelection.d.ts +4 -3
- package/lib/cjs/table/Table.d.ts +9 -1
- package/lib/cjs/table/Table.js +30 -11
- package/lib/cjs/table/TableCell.js +30 -7
- package/lib/cjs/table/TableContextProvider.d.ts +1 -1
- package/lib/cjs/table/TableContextProvider.js +5 -3
- package/lib/cjs/table/TableHeaderRow.js +28 -9
- package/lib/cjs/table/index.d.ts +3 -0
- package/lib/cjs/table/index.js +11 -3
- package/lib/cjs/table/interface.d.ts +1 -0
- package/lib/cjs/table/table-context.d.ts +2 -0
- package/lib/cjs/tabs/interface.d.ts +1 -1
- package/lib/cjs/tag/index.js +4 -2
- package/lib/cjs/tagInput/index.d.ts +1 -1
- package/lib/cjs/tagInput/index.js +1 -3
- package/lib/cjs/tooltip/index.d.ts +4 -0
- package/lib/cjs/tooltip/index.js +21 -6
- package/lib/cjs/treeSelect/index.d.ts +1 -1
- package/lib/cjs/treeSelect/index.js +18 -18
- package/lib/cjs/typography/copyable.d.ts +3 -0
- package/lib/cjs/typography/copyable.js +30 -9
- package/lib/es/_base/base.d.ts +3 -3
- package/lib/es/anchor/index.d.ts +1 -1
- package/lib/es/autoComplete/index.d.ts +1 -1
- package/lib/es/button/Button.d.ts +1 -1
- package/lib/es/carousel/index.d.ts +1 -0
- package/lib/es/carousel/index.js +16 -2
- package/lib/es/cascader/index.js +2 -1
- package/lib/es/checkbox/checkbox.d.ts +1 -1
- package/lib/es/checkbox/checkboxGroup.d.ts +1 -1
- package/lib/es/descriptions/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/image/previewInner.d.ts +1 -2
- package/lib/es/image/previewInner.js +5 -6
- package/lib/es/layout/index.d.ts +1 -1
- package/lib/es/modal/confirm.d.ts +1 -1
- package/lib/es/popconfirm/index.js +10 -1
- package/lib/es/popover/index.d.ts +1 -0
- package/lib/es/progress/index.d.ts +3 -3
- package/lib/es/radio/radio.d.ts +1 -1
- package/lib/es/select/index.d.ts +2 -2
- package/lib/es/select/index.js +3 -6
- package/lib/es/select/virtualRow.js +3 -2
- package/lib/es/table/Body/index.js +4 -7
- package/lib/es/table/ColumnSelection.d.ts +4 -3
- package/lib/es/table/Table.d.ts +9 -1
- package/lib/es/table/Table.js +30 -11
- package/lib/es/table/TableCell.js +31 -8
- package/lib/es/table/TableContextProvider.d.ts +1 -1
- package/lib/es/table/TableContextProvider.js +5 -3
- package/lib/es/table/TableHeaderRow.js +29 -10
- package/lib/es/table/index.d.ts +3 -0
- package/lib/es/table/index.js +10 -3
- package/lib/es/table/interface.d.ts +1 -0
- package/lib/es/table/table-context.d.ts +2 -0
- package/lib/es/tabs/interface.d.ts +1 -1
- package/lib/es/tag/index.js +7 -2
- package/lib/es/tagInput/index.d.ts +1 -1
- package/lib/es/tagInput/index.js +1 -3
- package/lib/es/tooltip/index.d.ts +4 -0
- package/lib/es/tooltip/index.js +21 -6
- package/lib/es/treeSelect/index.d.ts +1 -1
- package/lib/es/treeSelect/index.js +17 -18
- package/lib/es/typography/copyable.d.ts +3 -0
- package/lib/es/typography/copyable.js +28 -9
- package/package.json +8 -8
package/lib/es/table/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import NormalTable from './Table';
|
|
|
4
4
|
import ResizableTable from './ResizableTable';
|
|
5
5
|
import Column from './Column';
|
|
6
6
|
import { strings } from '@douyinfe/semi-foundation/lib/es/table/constants';
|
|
7
|
+
import ConfigContext from '../configProvider/context';
|
|
7
8
|
|
|
8
9
|
class Table extends React.PureComponent {
|
|
9
10
|
constructor(props) {
|
|
@@ -15,16 +16,21 @@ class Table extends React.PureComponent {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
render() {
|
|
18
|
-
// eslint-disable-next-line prefer-destructuring
|
|
19
|
+
var _a; // eslint-disable-next-line prefer-destructuring
|
|
20
|
+
|
|
21
|
+
|
|
19
22
|
const props = this.props;
|
|
23
|
+
const direction = (_a = this.props.direction) !== null && _a !== void 0 ? _a : this.context.direction;
|
|
20
24
|
|
|
21
25
|
if (props.resizable) {
|
|
22
26
|
return /*#__PURE__*/React.createElement(ResizableTable, Object.assign({}, props, {
|
|
23
|
-
ref: this.tableRef
|
|
27
|
+
ref: this.tableRef,
|
|
28
|
+
direction: direction
|
|
24
29
|
}));
|
|
25
30
|
} else {
|
|
26
31
|
return /*#__PURE__*/React.createElement(NormalTable, Object.assign({}, props, {
|
|
27
|
-
ref: this.tableRef
|
|
32
|
+
ref: this.tableRef,
|
|
33
|
+
direction: direction
|
|
28
34
|
}));
|
|
29
35
|
}
|
|
30
36
|
}
|
|
@@ -40,5 +46,6 @@ Table.propTypes = Object.assign(Object.assign({}, NormalTable.propTypes), {
|
|
|
40
46
|
Table.defaultProps = {
|
|
41
47
|
hideExpandedColumn: true
|
|
42
48
|
};
|
|
49
|
+
Table.contextType = ConfigContext;
|
|
43
50
|
export * from './interface';
|
|
44
51
|
export default Table;
|
|
@@ -56,6 +56,7 @@ export interface TableProps<RecordType extends Record<string, any> = any> extend
|
|
|
56
56
|
onHeaderRow?: OnHeaderRow<RecordType>;
|
|
57
57
|
onRow?: OnRow<RecordType>;
|
|
58
58
|
sticky?: Sticky;
|
|
59
|
+
direction?: Direction;
|
|
59
60
|
}
|
|
60
61
|
export interface ColumnProps<RecordType extends Record<string, any> = any> {
|
|
61
62
|
[x: string]: any;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ColumnProps, GetVirtualizedListRef, RowKey } from './interface';
|
|
3
3
|
import { BaseHeadWidth } from '@douyinfe/semi-foundation/lib/es/table/foundation';
|
|
4
|
+
import type { ContextValue } from '../configProvider/context';
|
|
4
5
|
export interface TableContextProps {
|
|
5
6
|
children?: React.ReactNode;
|
|
6
7
|
anyColumnFixed?: boolean;
|
|
@@ -15,6 +16,7 @@ export interface TableContextProps {
|
|
|
15
16
|
renderSelection?: (record?: Record<string, any>, isHeader?: boolean) => React.ReactNode;
|
|
16
17
|
getVirtualizedListRef?: GetVirtualizedListRef;
|
|
17
18
|
setBodyHasScrollbar?: (bodyHasScrollBar: boolean) => void;
|
|
19
|
+
direction?: ContextValue['direction'];
|
|
18
20
|
}
|
|
19
21
|
declare const TableContext: React.Context<TableContextProps>;
|
|
20
22
|
export default TableContext;
|
package/lib/es/tag/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import Avatar from '../avatar/index';
|
|
|
21
21
|
import { IconClose } from '@douyinfe/semi-icons';
|
|
22
22
|
import { handlePrevent } from '@douyinfe/semi-foundation/lib/es/utils/a11y';
|
|
23
23
|
import '@douyinfe/semi-foundation/lib/es/tag/tag.css';
|
|
24
|
+
import cls from 'classnames';
|
|
24
25
|
export * from './interface';
|
|
25
26
|
const prefixCls = cssClasses.PREFIX;
|
|
26
27
|
const tagColors = strings.TAG_COLOR;
|
|
@@ -169,10 +170,14 @@ export default class Tag extends Component {
|
|
|
169
170
|
}, /*#__PURE__*/React.createElement(IconClose, {
|
|
170
171
|
size: "small"
|
|
171
172
|
})) : null;
|
|
173
|
+
|
|
174
|
+
const stringChild = _isString(children);
|
|
175
|
+
|
|
176
|
+
const contentCls = cls(`${prefixCls}-content`, `${prefixCls}-content-${stringChild ? 'ellipsis' : 'center'}`);
|
|
172
177
|
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
173
|
-
"aria-label": this.props['aria-label'] ||
|
|
178
|
+
"aria-label": this.props['aria-label'] || stringChild ? `${closable ? 'Closable ' : ''}Tag: ${children}` : ''
|
|
174
179
|
}, wrapProps), avatarSrc ? this.renderAvatar() : null, /*#__PURE__*/React.createElement("div", {
|
|
175
|
-
className:
|
|
180
|
+
className: contentCls
|
|
176
181
|
}, children), closeIcon);
|
|
177
182
|
}
|
|
178
183
|
|
|
@@ -46,7 +46,7 @@ export interface TagInputProps {
|
|
|
46
46
|
style?: React.CSSProperties;
|
|
47
47
|
suffix?: React.ReactNode;
|
|
48
48
|
validateStatus?: ValidateStatus;
|
|
49
|
-
value?: string[]
|
|
49
|
+
value?: string[];
|
|
50
50
|
autoFocus?: boolean;
|
|
51
51
|
'aria-label'?: string;
|
|
52
52
|
preventScroll?: boolean;
|
package/lib/es/tagInput/index.js
CHANGED
|
@@ -140,15 +140,13 @@ class TagInput extends BaseComponent {
|
|
|
140
140
|
key: elementKey,
|
|
141
141
|
visible: true,
|
|
142
142
|
"aria-label": `${!disabled ? 'Closable ' : ''}Tag: ${value}`
|
|
143
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
144
|
-
className: `${prefixCls}-tag-content-wrapper`
|
|
145
143
|
}, showIconHandler && /*#__PURE__*/React.createElement(DragHandle, null), /*#__PURE__*/React.createElement(Paragraph, {
|
|
146
144
|
className: typoCls,
|
|
147
145
|
ellipsis: {
|
|
148
146
|
showTooltip: showContentTooltip,
|
|
149
147
|
rows: 1
|
|
150
148
|
}
|
|
151
|
-
}, value))
|
|
149
|
+
}, value));
|
|
152
150
|
}
|
|
153
151
|
});
|
|
154
152
|
};
|
|
@@ -63,6 +63,7 @@ export interface TooltipProps extends BaseProps {
|
|
|
63
63
|
preventScroll?: boolean;
|
|
64
64
|
disableFocusListener?: boolean;
|
|
65
65
|
afterClose?: () => void;
|
|
66
|
+
keepDOM?: boolean;
|
|
66
67
|
}
|
|
67
68
|
interface TooltipState {
|
|
68
69
|
visible: boolean;
|
|
@@ -79,6 +80,7 @@ interface TooltipState {
|
|
|
79
80
|
transitionStyle: Record<string, any>;
|
|
80
81
|
isPositionUpdated: boolean;
|
|
81
82
|
id: string;
|
|
83
|
+
displayNone: boolean;
|
|
82
84
|
}
|
|
83
85
|
export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
84
86
|
static contextType: React.Context<ContextValue>;
|
|
@@ -120,6 +122,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
120
122
|
guardFocus: PropTypes.Requireable<boolean>;
|
|
121
123
|
returnFocusOnClose: PropTypes.Requireable<boolean>;
|
|
122
124
|
preventScroll: PropTypes.Requireable<boolean>;
|
|
125
|
+
keepDOM: PropTypes.Requireable<boolean>;
|
|
123
126
|
};
|
|
124
127
|
static defaultProps: {
|
|
125
128
|
arrowBounding: {
|
|
@@ -151,6 +154,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
151
154
|
onEscKeyDown: (...args: any[]) => void;
|
|
152
155
|
disableFocusListener: boolean;
|
|
153
156
|
disableArrowKeyDown: boolean;
|
|
157
|
+
keepDOM: boolean;
|
|
154
158
|
};
|
|
155
159
|
eventManager: Event;
|
|
156
160
|
triggerEl: React.RefObject<unknown>;
|
package/lib/es/tooltip/index.js
CHANGED
|
@@ -85,7 +85,12 @@ export default class Tooltip extends BaseComponent {
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
this.didLeave = () => {
|
|
88
|
-
this.
|
|
88
|
+
if (this.props.keepDOM) {
|
|
89
|
+
this.foundation.setDisplayNone(true);
|
|
90
|
+
} else {
|
|
91
|
+
this.foundation.removePortal();
|
|
92
|
+
}
|
|
93
|
+
|
|
89
94
|
this.foundation.unBindEvent();
|
|
90
95
|
};
|
|
91
96
|
|
|
@@ -155,6 +160,7 @@ export default class Tooltip extends BaseComponent {
|
|
|
155
160
|
visible,
|
|
156
161
|
portalEventSet,
|
|
157
162
|
placement,
|
|
163
|
+
displayNone,
|
|
158
164
|
transitionState,
|
|
159
165
|
id,
|
|
160
166
|
isPositionUpdated
|
|
@@ -209,7 +215,9 @@ export default class Tooltip extends BaseComponent {
|
|
|
209
215
|
} = _ref;
|
|
210
216
|
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
211
217
|
className: classNames(className, animationClassName),
|
|
212
|
-
style: Object.assign(Object.assign(Object.assign(Object.assign({}, animationStyle), {
|
|
218
|
+
style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, animationStyle), displayNone ? {
|
|
219
|
+
display: "none"
|
|
220
|
+
} : {}), {
|
|
213
221
|
transformOrigin
|
|
214
222
|
}), style), {
|
|
215
223
|
opacity: isPositionUpdated ? opacity : "0"
|
|
@@ -299,8 +307,8 @@ export default class Tooltip extends BaseComponent {
|
|
|
299
307
|
placement: props.position || 'top',
|
|
300
308
|
transitionStyle: {},
|
|
301
309
|
isPositionUpdated: false,
|
|
302
|
-
id: props.wrapperId
|
|
303
|
-
|
|
310
|
+
id: props.wrapperId,
|
|
311
|
+
displayNone: false
|
|
304
312
|
};
|
|
305
313
|
this.foundation = new TooltipFoundation(this.adapter);
|
|
306
314
|
this.eventManager = new Event();
|
|
@@ -424,6 +432,11 @@ export default class Tooltip extends BaseComponent {
|
|
|
424
432
|
this.eventManager.emit('positionUpdated');
|
|
425
433
|
});
|
|
426
434
|
},
|
|
435
|
+
setDisplayNone: (displayNone, cb) => {
|
|
436
|
+
this.setState({
|
|
437
|
+
displayNone
|
|
438
|
+
}, cb);
|
|
439
|
+
},
|
|
427
440
|
updatePlacementAttr: placement => {
|
|
428
441
|
this.setState({
|
|
429
442
|
placement
|
|
@@ -730,7 +743,8 @@ Tooltip.propTypes = {
|
|
|
730
743
|
wrapWhenSpecial: PropTypes.bool,
|
|
731
744
|
guardFocus: PropTypes.bool,
|
|
732
745
|
returnFocusOnClose: PropTypes.bool,
|
|
733
|
-
preventScroll: PropTypes.bool
|
|
746
|
+
preventScroll: PropTypes.bool,
|
|
747
|
+
keepDOM: PropTypes.bool
|
|
734
748
|
};
|
|
735
749
|
Tooltip.defaultProps = {
|
|
736
750
|
arrowBounding: numbers.ARROW_BOUNDING,
|
|
@@ -756,5 +770,6 @@ Tooltip.defaultProps = {
|
|
|
756
770
|
returnFocusOnClose: false,
|
|
757
771
|
onEscKeyDown: _noop,
|
|
758
772
|
disableFocusListener: false,
|
|
759
|
-
disableArrowKeyDown: false
|
|
773
|
+
disableArrowKeyDown: false,
|
|
774
|
+
keepDOM: false
|
|
760
775
|
};
|
|
@@ -245,7 +245,7 @@ declare class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState>
|
|
|
245
245
|
getTreeNodeKey: (treeNode: TreeNodeData) => string;
|
|
246
246
|
handlePopoverClose: (isVisible: any) => void;
|
|
247
247
|
renderTreeNode: (treeNode: FlattenNode, ind: number, style: React.CSSProperties) => JSX.Element;
|
|
248
|
-
itemKey: (index: number, data:
|
|
248
|
+
itemKey: (index: number, data: Record<string, any>) => any;
|
|
249
249
|
renderNodeList: () => JSX.Element;
|
|
250
250
|
renderTree: () => JSX.Element;
|
|
251
251
|
render(): JSX.Element;
|
|
@@ -34,6 +34,7 @@ import { isSemiIcon } from '../_utils';
|
|
|
34
34
|
import { IconChevronDown, IconClear, IconSearch } from '@douyinfe/semi-icons';
|
|
35
35
|
import CheckboxGroup from '../checkbox/checkboxGroup';
|
|
36
36
|
import Popover from '../popover/index';
|
|
37
|
+
import VirtualRow from '../select/virtualRow';
|
|
37
38
|
const prefixcls = cssClasses.PREFIX;
|
|
38
39
|
const prefixTree = cssClasses.PREFIX_TREE;
|
|
39
40
|
const key = 0;
|
|
@@ -766,8 +767,11 @@ class TreeSelect extends BaseComponent {
|
|
|
766
767
|
};
|
|
767
768
|
|
|
768
769
|
this.itemKey = (index, data) => {
|
|
769
|
-
|
|
770
|
-
|
|
770
|
+
const {
|
|
771
|
+
visibleOptions
|
|
772
|
+
} = data; // Find the item at the specified index.
|
|
773
|
+
|
|
774
|
+
const item = visibleOptions[index]; // Return a value that uniquely identifies this item.
|
|
771
775
|
|
|
772
776
|
return item.key;
|
|
773
777
|
};
|
|
@@ -801,23 +805,18 @@ class TreeSelect extends BaseComponent {
|
|
|
801
805
|
});
|
|
802
806
|
}
|
|
803
807
|
|
|
804
|
-
const
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
style,
|
|
808
|
-
data
|
|
809
|
-
} = _ref;
|
|
810
|
-
return this.renderTreeNode(data[index], index, style);
|
|
808
|
+
const data = {
|
|
809
|
+
visibleOptions: flattenNodes,
|
|
810
|
+
renderOption: this.renderTreeNode
|
|
811
811
|
};
|
|
812
|
-
|
|
813
812
|
return /*#__PURE__*/React.createElement(AutoSizer, {
|
|
814
813
|
defaultHeight: virtualize.height,
|
|
815
814
|
defaultWidth: virtualize.width
|
|
816
|
-
},
|
|
815
|
+
}, _ref => {
|
|
817
816
|
let {
|
|
818
817
|
height,
|
|
819
818
|
width
|
|
820
|
-
} =
|
|
819
|
+
} = _ref;
|
|
821
820
|
return /*#__PURE__*/React.createElement(VirtualList, {
|
|
822
821
|
itemCount: flattenNodes.length,
|
|
823
822
|
itemSize: virtualize.itemSize,
|
|
@@ -825,12 +824,12 @@ class TreeSelect extends BaseComponent {
|
|
|
825
824
|
width: width,
|
|
826
825
|
// @ts-ignore avoid strict check of itemKey
|
|
827
826
|
itemKey: this.itemKey,
|
|
828
|
-
itemData:
|
|
827
|
+
itemData: data,
|
|
829
828
|
className: `${prefixTree}-virtual-list`,
|
|
830
829
|
style: {
|
|
831
830
|
direction
|
|
832
831
|
}
|
|
833
|
-
},
|
|
832
|
+
}, VirtualRow);
|
|
834
833
|
});
|
|
835
834
|
};
|
|
836
835
|
|
|
@@ -1140,11 +1139,11 @@ class TreeSelect extends BaseComponent {
|
|
|
1140
1139
|
};
|
|
1141
1140
|
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, super.adapter), filterAdapter), treeSelectAdapter), treeAdapter), {
|
|
1142
1141
|
updateLoadKeys: (data, resolve) => {
|
|
1143
|
-
this.setState(
|
|
1142
|
+
this.setState(_ref2 => {
|
|
1144
1143
|
let {
|
|
1145
1144
|
loadedKeys,
|
|
1146
1145
|
loadingKeys
|
|
1147
|
-
} =
|
|
1146
|
+
} = _ref2;
|
|
1148
1147
|
return this.foundation.handleNodeLoad(loadedKeys, loadingKeys, data, resolve);
|
|
1149
1148
|
});
|
|
1150
1149
|
},
|
|
@@ -1181,11 +1180,11 @@ class TreeSelect extends BaseComponent {
|
|
|
1181
1180
|
notifyChangeWithObject: (node, e) => {
|
|
1182
1181
|
this.props.onChange && this.props.onChange(node, e);
|
|
1183
1182
|
},
|
|
1184
|
-
notifyExpand: (expandedKeys,
|
|
1183
|
+
notifyExpand: (expandedKeys, _ref3) => {
|
|
1185
1184
|
let {
|
|
1186
1185
|
expanded: bool,
|
|
1187
1186
|
node
|
|
1188
|
-
} =
|
|
1187
|
+
} = _ref3;
|
|
1189
1188
|
this.props.onExpand && this.props.onExpand([...expandedKeys], {
|
|
1190
1189
|
expanded: bool,
|
|
1191
1190
|
node
|
|
@@ -8,6 +8,7 @@ export interface CopyableProps extends BaseProps {
|
|
|
8
8
|
duration?: number;
|
|
9
9
|
forwardRef?: React.RefObject<any>;
|
|
10
10
|
successTip?: React.ReactNode;
|
|
11
|
+
icon?: React.ReactNode;
|
|
11
12
|
onCopy?: (e: React.MouseEvent, content: string, res: boolean) => void;
|
|
12
13
|
}
|
|
13
14
|
interface CopyableState {
|
|
@@ -23,6 +24,7 @@ export declare class Copyable extends React.PureComponent<CopyableProps, Copyabl
|
|
|
23
24
|
duration: PropTypes.Requireable<number>;
|
|
24
25
|
style: PropTypes.Requireable<object>;
|
|
25
26
|
className: PropTypes.Requireable<string>;
|
|
27
|
+
icon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
26
28
|
};
|
|
27
29
|
static defaultProps: {
|
|
28
30
|
content: string;
|
|
@@ -38,6 +40,7 @@ export declare class Copyable extends React.PureComponent<CopyableProps, Copyabl
|
|
|
38
40
|
setCopied: (item: string, timer: number) => void;
|
|
39
41
|
resetCopied: () => void;
|
|
40
42
|
renderSuccessTip: () => string | number | boolean | React.ReactFragment | JSX.Element;
|
|
43
|
+
renderCopyIcon: () => JSX.Element;
|
|
41
44
|
render(): JSX.Element;
|
|
42
45
|
}
|
|
43
46
|
export default Copyable;
|
|
@@ -59,6 +59,31 @@ export class Copyable extends React.PureComponent {
|
|
|
59
59
|
}, locale => /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(IconTick, null), locale.copied));
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
+
this.renderCopyIcon = () => {
|
|
63
|
+
const {
|
|
64
|
+
icon
|
|
65
|
+
} = this.props;
|
|
66
|
+
const copyProps = {
|
|
67
|
+
role: "button",
|
|
68
|
+
tabIndex: 0,
|
|
69
|
+
onClick: this.copy,
|
|
70
|
+
onKeyPress: e => isEnterPress(e) && this.copy(e)
|
|
71
|
+
};
|
|
72
|
+
{
|
|
73
|
+
/* TODO: replace `a` tag with `span` in next major version
|
|
74
|
+
NOTE: may have effect on style */
|
|
75
|
+
}
|
|
76
|
+
const defaultIcon =
|
|
77
|
+
/*#__PURE__*/
|
|
78
|
+
// eslint-disable-next-line jsx-a11y/anchor-is-valid
|
|
79
|
+
React.createElement("a", {
|
|
80
|
+
className: `${prefixCls}-action-copy-icon`
|
|
81
|
+
}, /*#__PURE__*/React.createElement(IconCopy, Object.assign({
|
|
82
|
+
onClick: this.copy
|
|
83
|
+
}, copyProps)));
|
|
84
|
+
return /*#__PURE__*/React.isValidElement(icon) ? /*#__PURE__*/React.cloneElement(icon, copyProps) : defaultIcon;
|
|
85
|
+
};
|
|
86
|
+
|
|
62
87
|
this.state = {
|
|
63
88
|
copied: false,
|
|
64
89
|
item: ''
|
|
@@ -96,14 +121,7 @@ export class Copyable extends React.PureComponent {
|
|
|
96
121
|
ref: forwardRef
|
|
97
122
|
}, copied ? this.renderSuccessTip() : /*#__PURE__*/React.createElement(Tooltip, {
|
|
98
123
|
content: typeof copyTip !== 'undefined' ? copyTip : locale.copy
|
|
99
|
-
},
|
|
100
|
-
className: `${prefixCls}-action-copy-icon`
|
|
101
|
-
}, /*#__PURE__*/React.createElement(IconCopy, {
|
|
102
|
-
role: "button",
|
|
103
|
-
tabIndex: 0,
|
|
104
|
-
onClick: this.copy,
|
|
105
|
-
onKeyPress: e => isEnterPress(e) && this.copy(e)
|
|
106
|
-
})))));
|
|
124
|
+
}, this.renderCopyIcon())));
|
|
107
125
|
}
|
|
108
126
|
|
|
109
127
|
}
|
|
@@ -114,7 +132,8 @@ Copyable.propTypes = {
|
|
|
114
132
|
copyTip: PropTypes.node,
|
|
115
133
|
duration: PropTypes.number,
|
|
116
134
|
style: PropTypes.object,
|
|
117
|
-
className: PropTypes.string
|
|
135
|
+
className: PropTypes.string,
|
|
136
|
+
icon: PropTypes.node
|
|
118
137
|
};
|
|
119
138
|
Copyable.defaultProps = {
|
|
120
139
|
content: '',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.31.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"lib/*"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@douyinfe/semi-animation": "2.
|
|
21
|
-
"@douyinfe/semi-animation-react": "2.
|
|
22
|
-
"@douyinfe/semi-foundation": "2.
|
|
23
|
-
"@douyinfe/semi-icons": "2.
|
|
24
|
-
"@douyinfe/semi-illustrations": "2.
|
|
25
|
-
"@douyinfe/semi-theme-default": "2.
|
|
20
|
+
"@douyinfe/semi-animation": "2.31.0",
|
|
21
|
+
"@douyinfe/semi-animation-react": "2.31.0",
|
|
22
|
+
"@douyinfe/semi-foundation": "2.31.0",
|
|
23
|
+
"@douyinfe/semi-icons": "2.31.0",
|
|
24
|
+
"@douyinfe/semi-illustrations": "2.31.0",
|
|
25
|
+
"@douyinfe/semi-theme-default": "2.31.0",
|
|
26
26
|
"async-validator": "^3.5.0",
|
|
27
27
|
"classnames": "^2.2.6",
|
|
28
28
|
"copy-text-to-clipboard": "^2.1.1",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
],
|
|
70
70
|
"author": "",
|
|
71
71
|
"license": "MIT",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "28b48a92313bbd889681618ca0898c931e6ee721",
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
75
75
|
"@babel/plugin-transform-runtime": "^7.15.8",
|