@douyinfe/semi-ui 2.51.4 → 2.52.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/dist/css/semi.css +285 -0
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +488 -214
- 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/_utils/index.d.ts +2 -1
- package/lib/cjs/_utils/index.js +0 -5
- package/lib/cjs/avatar/TopSlotSvg.d.ts +5 -0
- package/lib/cjs/avatar/TopSlotSvg.js +74 -0
- package/lib/cjs/avatar/index.d.ts +25 -0
- package/lib/cjs/avatar/index.js +126 -8
- package/lib/cjs/avatar/interface.d.ts +24 -1
- package/lib/cjs/cascader/index.d.ts +2 -3
- package/lib/cjs/cascader/index.js +19 -28
- package/lib/cjs/datePicker/datePicker.js +1 -1
- package/lib/cjs/datePicker/yearAndMonth.js +16 -20
- package/lib/cjs/dropdown/dropdownItem.js +2 -1
- package/lib/cjs/form/hoc/withField.d.ts +3 -3
- package/lib/cjs/input/index.d.ts +1 -0
- package/lib/cjs/input/index.js +12 -4
- package/lib/cjs/modal/Modal.d.ts +1 -0
- package/lib/cjs/modal/Modal.js +13 -5
- package/lib/cjs/modal/confirm.d.ts +5 -0
- package/lib/cjs/select/option.js +1 -2
- package/lib/cjs/slider/index.js +33 -1
- package/lib/cjs/table/ColumnFilter.d.ts +34 -18
- package/lib/cjs/table/ColumnFilter.js +134 -73
- package/lib/cjs/table/ResizableTable.js +1 -1
- package/lib/cjs/table/Table.d.ts +5 -5
- package/lib/cjs/table/Table.js +38 -13
- package/lib/cjs/table/index.d.ts +1 -1
- package/lib/cjs/table/interface.d.ts +30 -10
- package/lib/cjs/treeSelect/index.d.ts +2 -0
- package/lib/cjs/treeSelect/index.js +4 -0
- package/lib/es/_utils/index.d.ts +2 -1
- package/lib/es/_utils/index.js +0 -5
- package/lib/es/avatar/TopSlotSvg.d.ts +5 -0
- package/lib/es/avatar/TopSlotSvg.js +66 -0
- package/lib/es/avatar/index.d.ts +25 -0
- package/lib/es/avatar/index.js +126 -8
- package/lib/es/avatar/interface.d.ts +24 -1
- package/lib/es/cascader/index.d.ts +2 -3
- package/lib/es/cascader/index.js +19 -28
- package/lib/es/datePicker/datePicker.js +1 -1
- package/lib/es/datePicker/yearAndMonth.js +16 -20
- package/lib/es/dropdown/dropdownItem.js +2 -1
- package/lib/es/form/hoc/withField.d.ts +3 -3
- package/lib/es/input/index.d.ts +1 -0
- package/lib/es/input/index.js +12 -4
- package/lib/es/modal/Modal.d.ts +1 -0
- package/lib/es/modal/Modal.js +13 -5
- package/lib/es/modal/confirm.d.ts +5 -0
- package/lib/es/select/option.js +1 -2
- package/lib/es/slider/index.js +33 -1
- package/lib/es/table/ColumnFilter.d.ts +34 -18
- package/lib/es/table/ColumnFilter.js +135 -74
- package/lib/es/table/ResizableTable.js +1 -1
- package/lib/es/table/Table.d.ts +5 -5
- package/lib/es/table/Table.js +38 -13
- package/lib/es/table/index.d.ts +1 -1
- package/lib/es/table/interface.d.ts +30 -10
- package/lib/es/treeSelect/index.d.ts +2 -0
- package/lib/es/treeSelect/index.js +4 -0
- package/package.json +8 -8
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React, { ReactNode, MutableRefObject } from 'react';
|
|
2
|
-
import { BaseProps } from '../_base/baseComponent';
|
|
3
|
-
import { PaginationProps } from '../pagination';
|
|
4
|
-
import { CheckboxProps } from '../checkbox';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { ArrayElement } from '../_base/base';
|
|
2
|
+
import type { BaseProps } from '../_base/baseComponent';
|
|
3
|
+
import type { PaginationProps } from '../pagination';
|
|
4
|
+
import type { CheckboxProps } from '../checkbox';
|
|
5
|
+
import type { Locale } from '../locale/interface';
|
|
6
|
+
import type { ArrayElement } from '../_base/base';
|
|
8
7
|
import { strings } from '@douyinfe/semi-foundation/lib/cjs/table/constants';
|
|
9
|
-
import { BaseRowKeyType, BaseSortOrder, BaseGroupBy, BaseGroupByFn, BaseFixed, BaseAlign, BaseChangeInfoSorter, BaseSorter, BaseFilter, BaseChangeInfoFilter, BaseIncludeGroupRecord, BaseEllipsis } from '@douyinfe/semi-foundation/lib/cjs/table/foundation';
|
|
10
|
-
import { ScrollDirection, CSSDirection } from 'react-window';
|
|
8
|
+
import type { BaseRowKeyType, BaseSortOrder, BaseGroupBy, BaseGroupByFn, BaseFixed, BaseAlign, BaseChangeInfoSorter, BaseSorter, BaseFilter, BaseChangeInfoFilter, BaseIncludeGroupRecord, BaseEllipsis } from '@douyinfe/semi-foundation/lib/cjs/table/foundation';
|
|
9
|
+
import type { ScrollDirection, CSSDirection } from 'react-window';
|
|
10
|
+
import type { ColumnFilterProps } from './ColumnFilter';
|
|
11
11
|
export interface TableProps<RecordType extends Record<string, any> = any> extends BaseProps {
|
|
12
12
|
bordered?: boolean;
|
|
13
13
|
children?: ReactNode;
|
|
@@ -65,29 +65,37 @@ export interface ColumnProps<RecordType extends Record<string, any> = any> {
|
|
|
65
65
|
children?: Array<ColumnProps<RecordType>>;
|
|
66
66
|
className?: string;
|
|
67
67
|
colSpan?: number;
|
|
68
|
+
/** use `dataIndex` to get current column data item from record. If you use `sorter` or `onFilter`, a unique `dataIndex` is required */
|
|
68
69
|
dataIndex?: string;
|
|
69
70
|
defaultFilteredValue?: any[];
|
|
70
71
|
defaultSortOrder?: SortOrder;
|
|
71
72
|
filterChildrenRecord?: boolean;
|
|
72
|
-
filterDropdown?:
|
|
73
|
-
|
|
73
|
+
filterDropdown?: ColumnFilterProps['filterDropdown'];
|
|
74
|
+
/** render filter Dropdown panel content */
|
|
75
|
+
renderFilterDropdown?: ColumnFilterProps['renderFilterDropdown'];
|
|
76
|
+
/** filter Dropdown props */
|
|
77
|
+
filterDropdownProps?: ColumnFilterProps['filterDropdownProps'];
|
|
74
78
|
filterDropdownVisible?: boolean;
|
|
75
79
|
filterIcon?: FilterIcon;
|
|
76
80
|
filterMultiple?: boolean;
|
|
77
81
|
filteredValue?: any[];
|
|
82
|
+
/** `filters` is not required if you use `renderFilterDropdown` */
|
|
78
83
|
filters?: Filter[];
|
|
79
84
|
fixed?: Fixed;
|
|
85
|
+
/** the key required by React. If you have already set the `dataIndex`, the key does not need to be set again. */
|
|
80
86
|
key?: string | number;
|
|
81
87
|
render?: ColumnRender<RecordType>;
|
|
82
88
|
renderFilterDropdownItem?: RenderFilterDropdownItem;
|
|
83
89
|
sortChildrenRecord?: boolean;
|
|
84
90
|
sortOrder?: SortOrder;
|
|
91
|
+
/** enable sorting, `dataIndex` is required at the same time */
|
|
85
92
|
sorter?: Sorter<RecordType>;
|
|
86
93
|
sortIcon?: SortIcon;
|
|
87
94
|
title?: ColumnTitle;
|
|
88
95
|
useFullRender?: boolean;
|
|
89
96
|
width?: string | number;
|
|
90
97
|
onCell?: OnCell<RecordType>;
|
|
98
|
+
/** enable filtering, `dataIndex` is required at the same time */
|
|
91
99
|
onFilter?: OnFilter<RecordType>;
|
|
92
100
|
onFilterDropdownVisibleChange?: OnFilterDropdownVisibleChange;
|
|
93
101
|
onHeaderCell?: OnHeaderCell<RecordType>;
|
|
@@ -217,7 +225,19 @@ export interface RowSelectionProps<RecordType> {
|
|
|
217
225
|
onChange?: RowSelectionOnChange<RecordType>;
|
|
218
226
|
onSelect?: RowSelectionOnSelect<RecordType>;
|
|
219
227
|
onSelectAll?: RowSelectionOnSelectAll<RecordType>;
|
|
228
|
+
renderCell?: RowSelectionRenderCell<RecordType>;
|
|
220
229
|
}
|
|
230
|
+
export type RowSelectionRenderCell<RecordType> = (renderCellArgs: {
|
|
231
|
+
selected: boolean;
|
|
232
|
+
record: RecordType;
|
|
233
|
+
originNode: JSX.Element;
|
|
234
|
+
inHeader: boolean;
|
|
235
|
+
disabled: boolean;
|
|
236
|
+
indeterminate: boolean;
|
|
237
|
+
index?: number;
|
|
238
|
+
selectRow?: (selected: boolean, e: Event) => void;
|
|
239
|
+
selectAll?: (selected: boolean, e: Event) => void;
|
|
240
|
+
}) => ReactNode;
|
|
221
241
|
export type GetCheckboxProps<RecordType> = (record: RecordType) => CheckboxProps;
|
|
222
242
|
export type RowSelectionOnChange<RecordType> = (selectedRowKeys?: (string | number)[], selectedRows?: RecordType[]) => void;
|
|
223
243
|
export type RowSelectionOnSelect<RecordType> = (record?: RecordType, selected?: boolean, selectedRows?: RecordType[], nativeEvent?: React.MouseEvent) => void;
|
|
@@ -82,6 +82,7 @@ export interface TreeSelectProps extends Omit<BasicTreeSelectProps, OverrideComm
|
|
|
82
82
|
onChange?: OnChange;
|
|
83
83
|
onFocus?: (e: React.MouseEvent) => void;
|
|
84
84
|
onVisibleChange?: (isVisible: boolean) => void;
|
|
85
|
+
onClear?: (e: React.MouseEvent | React.KeyboardEvent<HTMLDivElement>) => void;
|
|
85
86
|
}
|
|
86
87
|
export type OverrideCommonState = 'keyEntities' | 'treeData' | 'disabledKeys' | 'flattenNodes';
|
|
87
88
|
export interface TreeSelectState extends Omit<BasicTreeSelectInnerData, OverrideCommonState | 'prevProps'>, Pick<TreeState, OverrideCommonState> {
|
|
@@ -121,6 +122,7 @@ declare class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState>
|
|
|
121
122
|
virtualize: PropTypes.Requireable<object>;
|
|
122
123
|
treeNodeFilterProp: PropTypes.Requireable<string>;
|
|
123
124
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
125
|
+
onClear: PropTypes.Requireable<(...args: any[]) => any>;
|
|
124
126
|
onSearch: PropTypes.Requireable<(...args: any[]) => any>;
|
|
125
127
|
onSelect: PropTypes.Requireable<(...args: any[]) => any>;
|
|
126
128
|
onExpand: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -1155,6 +1155,9 @@ class TreeSelect extends _baseComponent.default {
|
|
|
1155
1155
|
onLoad
|
|
1156
1156
|
} = this.props;
|
|
1157
1157
|
(0, _isFunction2.default)(onLoad) && onLoad(newLoadedKeys, data);
|
|
1158
|
+
},
|
|
1159
|
+
notifyClear: e => {
|
|
1160
|
+
this.props.onClear && this.props.onClear(e);
|
|
1158
1161
|
}
|
|
1159
1162
|
};
|
|
1160
1163
|
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, super.adapter), filterAdapter), treeSelectAdapter), treeAdapter), {
|
|
@@ -1326,6 +1329,7 @@ TreeSelect.propTypes = {
|
|
|
1326
1329
|
virtualize: _propTypes.default.object,
|
|
1327
1330
|
treeNodeFilterProp: _propTypes.default.string,
|
|
1328
1331
|
onChange: _propTypes.default.func,
|
|
1332
|
+
onClear: _propTypes.default.func,
|
|
1329
1333
|
onSearch: _propTypes.default.func,
|
|
1330
1334
|
onSelect: _propTypes.default.func,
|
|
1331
1335
|
onExpand: _propTypes.default.func,
|
package/lib/es/_utils/index.d.ts
CHANGED
|
@@ -11,7 +11,8 @@ export declare function stopPropagation(e: React.MouseEvent | React.FocusEvent<H
|
|
|
11
11
|
*
|
|
12
12
|
* skip clone function and react element
|
|
13
13
|
*/
|
|
14
|
-
export declare function cloneDeep(value:
|
|
14
|
+
export declare function cloneDeep<T>(value: T): T;
|
|
15
|
+
export declare function cloneDeep<T>(value: T, customizer: (value: any) => any): any;
|
|
15
16
|
/**
|
|
16
17
|
* [getHighLightTextHTML description]
|
|
17
18
|
*
|
package/lib/es/_utils/index.js
CHANGED
|
@@ -19,11 +19,6 @@ export function stopPropagation(e, noImmediate) {
|
|
|
19
19
|
e.nativeEvent.stopImmediatePropagation();
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
23
|
-
* use in Table, Form, Navigation
|
|
24
|
-
*
|
|
25
|
-
* skip clone function and react element
|
|
26
|
-
*/
|
|
27
22
|
export function cloneDeep(value, customizer) {
|
|
28
23
|
return _cloneDeepWith(value, v => {
|
|
29
24
|
if (typeof customizer === 'function') {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { getUuidShort } from '@douyinfe/semi-foundation/lib/es/utils/uuid';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
const TopSlotSvg = _ref => {
|
|
4
|
+
let {
|
|
5
|
+
gradientStart,
|
|
6
|
+
gradientEnd
|
|
7
|
+
} = _ref;
|
|
8
|
+
const id = getUuidShort();
|
|
9
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
10
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
11
|
+
width: "51",
|
|
12
|
+
height: "52",
|
|
13
|
+
viewBox: "0 0 51 52",
|
|
14
|
+
fill: "none"
|
|
15
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
16
|
+
filter: "url(#filter0_d_6_2)"
|
|
17
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
18
|
+
d: "M40.4918 46.5592C44.6795 43.176 46.261 34.1333 47.5301 25.6141C49.5854 11.8168 39.6662 1 25.8097 1C11.2857 1 3 11.4279 3 25.3518C3 33.7866 6.29361 43.8947 10.4602 46.5592C12.5868 47.9192 12.5868 47.9051 25.8097 47.9192C38.3651 47.9282 38.5352 48.14 40.4918 46.5592Z",
|
|
19
|
+
fill: `url(#${id})`
|
|
20
|
+
})), /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("filter", {
|
|
21
|
+
id: "filter0_d_6_2",
|
|
22
|
+
x: "0.789215",
|
|
23
|
+
y: "0.447304",
|
|
24
|
+
width: "49.2216",
|
|
25
|
+
height: "51.3549",
|
|
26
|
+
filterUnits: "userSpaceOnUse",
|
|
27
|
+
colorInterpolationFilters: "sRGB"
|
|
28
|
+
}, /*#__PURE__*/React.createElement("feFlood", {
|
|
29
|
+
floodOpacity: "0",
|
|
30
|
+
result: "BackgroundImageFix"
|
|
31
|
+
}), /*#__PURE__*/React.createElement("feColorMatrix", {
|
|
32
|
+
in: "SourceAlpha",
|
|
33
|
+
type: "matrix",
|
|
34
|
+
values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",
|
|
35
|
+
result: "hardAlpha"
|
|
36
|
+
}), /*#__PURE__*/React.createElement("feOffset", {
|
|
37
|
+
dy: "1.65809"
|
|
38
|
+
}), /*#__PURE__*/React.createElement("feGaussianBlur", {
|
|
39
|
+
stdDeviation: "1.10539"
|
|
40
|
+
}), /*#__PURE__*/React.createElement("feColorMatrix", {
|
|
41
|
+
type: "matrix",
|
|
42
|
+
values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0"
|
|
43
|
+
}), /*#__PURE__*/React.createElement("feBlend", {
|
|
44
|
+
mode: "normal",
|
|
45
|
+
in2: "BackgroundImageFix",
|
|
46
|
+
result: "effect1_dropShadow_6_2"
|
|
47
|
+
}), /*#__PURE__*/React.createElement("feBlend", {
|
|
48
|
+
mode: "normal",
|
|
49
|
+
in: "SourceGraphic",
|
|
50
|
+
in2: "effect1_dropShadow_6_2",
|
|
51
|
+
result: "shape"
|
|
52
|
+
})), /*#__PURE__*/React.createElement("linearGradient", {
|
|
53
|
+
id: id,
|
|
54
|
+
x1: "17.671",
|
|
55
|
+
y1: "31.7392",
|
|
56
|
+
x2: "17.671",
|
|
57
|
+
y2: "47.9333",
|
|
58
|
+
gradientUnits: "userSpaceOnUse"
|
|
59
|
+
}, /*#__PURE__*/React.createElement("stop", {
|
|
60
|
+
stopColor: gradientStart
|
|
61
|
+
}), /*#__PURE__*/React.createElement("stop", {
|
|
62
|
+
offset: "1",
|
|
63
|
+
stopColor: gradientEnd
|
|
64
|
+
}))));
|
|
65
|
+
};
|
|
66
|
+
export default TopSlotSvg;
|
package/lib/es/avatar/index.d.ts
CHANGED
|
@@ -40,6 +40,29 @@ export default class Avatar extends BaseComponent<AvatarProps, AvatarState> {
|
|
|
40
40
|
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
41
41
|
onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
|
|
42
42
|
onMouseLeave: PropTypes.Requireable<(...args: any[]) => any>;
|
|
43
|
+
bottomSlot: PropTypes.Requireable<PropTypes.InferProps<{
|
|
44
|
+
render: PropTypes.Requireable<(...args: any[]) => any>;
|
|
45
|
+
shape: PropTypes.Requireable<string>;
|
|
46
|
+
text: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
47
|
+
bgColor: PropTypes.Requireable<string>;
|
|
48
|
+
textColor: PropTypes.Requireable<string>;
|
|
49
|
+
className: PropTypes.Requireable<string>;
|
|
50
|
+
style: PropTypes.Requireable<object>;
|
|
51
|
+
}>>;
|
|
52
|
+
topSlot: PropTypes.Requireable<PropTypes.InferProps<{
|
|
53
|
+
render: PropTypes.Requireable<(...args: any[]) => any>;
|
|
54
|
+
gradientStart: PropTypes.Requireable<string>;
|
|
55
|
+
gradientEnd: PropTypes.Requireable<string>;
|
|
56
|
+
text: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
57
|
+
textColor: PropTypes.Requireable<string>;
|
|
58
|
+
className: PropTypes.Requireable<string>;
|
|
59
|
+
style: PropTypes.Requireable<object>;
|
|
60
|
+
}>>;
|
|
61
|
+
border: PropTypes.Requireable<NonNullable<boolean | PropTypes.InferProps<{
|
|
62
|
+
color: PropTypes.Requireable<string>;
|
|
63
|
+
motion: PropTypes.Requireable<boolean>;
|
|
64
|
+
}>>>;
|
|
65
|
+
contentMotion: PropTypes.Requireable<boolean>;
|
|
43
66
|
};
|
|
44
67
|
foundation: AvatarFoundation;
|
|
45
68
|
avatarRef: React.RefObject<HTMLElement | null>;
|
|
@@ -55,5 +78,7 @@ export default class Avatar extends BaseComponent<AvatarProps, AvatarState> {
|
|
|
55
78
|
handleFocusVisible: (event: React.FocusEvent) => void;
|
|
56
79
|
handleBlur: (event: React.FocusEvent) => void;
|
|
57
80
|
getContent: () => React.ReactNode;
|
|
81
|
+
renderBottomSlot: () => string | number | boolean | React.ReactFragment | JSX.Element;
|
|
82
|
+
renderTopSlot: () => string | number | boolean | React.ReactFragment | JSX.Element;
|
|
58
83
|
render(): JSX.Element;
|
|
59
84
|
}
|
package/lib/es/avatar/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import '@douyinfe/semi-foundation/lib/es/avatar/avatar.css';
|
|
|
15
15
|
import { noop } from '@douyinfe/semi-foundation/lib/es/utils/function';
|
|
16
16
|
import BaseComponent from '../_base/baseComponent';
|
|
17
17
|
import { handlePrevent } from '@douyinfe/semi-foundation/lib/es/utils/a11y';
|
|
18
|
+
import TopSlotSvg from "./TopSlotSvg";
|
|
18
19
|
const sizeSet = strings.SIZE;
|
|
19
20
|
const shapeSet = strings.SHAPE;
|
|
20
21
|
const colorSet = strings.COLOR;
|
|
@@ -88,6 +89,64 @@ export default class Avatar extends BaseComponent {
|
|
|
88
89
|
}
|
|
89
90
|
return content;
|
|
90
91
|
};
|
|
92
|
+
this.renderBottomSlot = () => {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
if (!this.props.bottomSlot) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
if (this.props.bottomSlot.render) {
|
|
98
|
+
return this.props.bottomSlot.render();
|
|
99
|
+
}
|
|
100
|
+
const renderContent = (_a = this.props.bottomSlot.render) !== null && _a !== void 0 ? _a : () => {
|
|
101
|
+
var _a;
|
|
102
|
+
const style = {};
|
|
103
|
+
if (this.props.bottomSlot.bgColor) {
|
|
104
|
+
style['backgroundColor'] = this.props.bottomSlot.bgColor;
|
|
105
|
+
}
|
|
106
|
+
if (this.props.bottomSlot.textColor) {
|
|
107
|
+
style['color'] = this.props.bottomSlot.textColor;
|
|
108
|
+
}
|
|
109
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
110
|
+
style: style,
|
|
111
|
+
className: cls(`${prefixCls}-bottom_slot-shape_${this.props.bottomSlot.shape}`, `${prefixCls}-bottom_slot-shape_${this.props.bottomSlot.shape}-${this.props.size}`, (_a = this.props.bottomSlot.className) !== null && _a !== void 0 ? _a : "")
|
|
112
|
+
}, this.props.bottomSlot.text);
|
|
113
|
+
};
|
|
114
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
115
|
+
className: cls([`${prefixCls}-bottom_slot`]),
|
|
116
|
+
style: (_b = this.props.bottomSlot.style) !== null && _b !== void 0 ? _b : {}
|
|
117
|
+
}, renderContent());
|
|
118
|
+
};
|
|
119
|
+
this.renderTopSlot = () => {
|
|
120
|
+
var _a, _b, _c, _d;
|
|
121
|
+
if (!this.props.topSlot) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
if (this.props.topSlot.render) {
|
|
125
|
+
return this.props.topSlot.render();
|
|
126
|
+
}
|
|
127
|
+
const textStyle = {};
|
|
128
|
+
if (this.props.topSlot.textColor) {
|
|
129
|
+
textStyle['color'] = this.props.topSlot.textColor;
|
|
130
|
+
}
|
|
131
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
132
|
+
style: (_a = this.props.topSlot.style) !== null && _a !== void 0 ? _a : {},
|
|
133
|
+
className: cls([`${prefixCls}-top_slot-wrapper`, (_b = this.props.topSlot.className) !== null && _b !== void 0 ? _b : "", {
|
|
134
|
+
[`${prefixCls}-animated`]: this.props.contentMotion
|
|
135
|
+
}])
|
|
136
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
137
|
+
className: cls([`${prefixCls}-top_slot-bg`, `${prefixCls}-top_slot-bg-${this.props.size}`])
|
|
138
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
139
|
+
className: cls([`${prefixCls}-top_slot-bg-svg`, `${prefixCls}-top_slot-bg-svg-${this.props.size}`])
|
|
140
|
+
}, /*#__PURE__*/React.createElement(TopSlotSvg, {
|
|
141
|
+
gradientStart: (_c = this.props.topSlot.gradientStart) !== null && _c !== void 0 ? _c : "var(--semi-color-primary)",
|
|
142
|
+
gradientEnd: (_d = this.props.topSlot.gradientEnd) !== null && _d !== void 0 ? _d : "var(--semi-color-primary)"
|
|
143
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
144
|
+
className: cls([`${prefixCls}-top_slot`])
|
|
145
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
146
|
+
style: textStyle,
|
|
147
|
+
className: cls([`${prefixCls}-top_slot-content`, `${prefixCls}-top_slot-content-${this.props.size}`])
|
|
148
|
+
}, this.props.topSlot.text)));
|
|
149
|
+
};
|
|
91
150
|
this.state = {
|
|
92
151
|
isImgExist: true,
|
|
93
152
|
hoverContent: '',
|
|
@@ -205,7 +264,8 @@ export default class Avatar extends BaseComponent {
|
|
|
205
264
|
}
|
|
206
265
|
}
|
|
207
266
|
render() {
|
|
208
|
-
|
|
267
|
+
var _a, _b;
|
|
268
|
+
const _c = this.props,
|
|
209
269
|
{
|
|
210
270
|
shape,
|
|
211
271
|
children,
|
|
@@ -219,9 +279,13 @@ export default class Avatar extends BaseComponent {
|
|
|
219
279
|
srcSet,
|
|
220
280
|
style,
|
|
221
281
|
alt,
|
|
222
|
-
gap
|
|
223
|
-
|
|
224
|
-
|
|
282
|
+
gap,
|
|
283
|
+
bottomSlot,
|
|
284
|
+
topSlot,
|
|
285
|
+
border,
|
|
286
|
+
contentMotion
|
|
287
|
+
} = _c,
|
|
288
|
+
others = __rest(_c, ["shape", "children", "size", "color", "className", "hoverMask", "onClick", "imgAttr", "src", "srcSet", "style", "alt", "gap", "bottomSlot", "topSlot", "border", "contentMotion"]);
|
|
225
289
|
const {
|
|
226
290
|
isImgExist,
|
|
227
291
|
hoverContent,
|
|
@@ -233,14 +297,15 @@ export default class Avatar extends BaseComponent {
|
|
|
233
297
|
[`${prefixCls}-${size}`]: size,
|
|
234
298
|
[`${prefixCls}-${color}`]: color && !isImg,
|
|
235
299
|
[`${prefixCls}-img`]: isImg,
|
|
236
|
-
[`${prefixCls}-focus`]: focusVisible
|
|
300
|
+
[`${prefixCls}-focus`]: focusVisible,
|
|
301
|
+
[`${prefixCls}-animated`]: contentMotion
|
|
237
302
|
}, className);
|
|
238
303
|
const hoverRender = hoverContent ? /*#__PURE__*/React.createElement("div", {
|
|
239
304
|
className: `${prefixCls}-hover`,
|
|
240
305
|
"x-semi-prop": "hoverContent"
|
|
241
306
|
}, hoverContent) : null;
|
|
242
|
-
|
|
243
|
-
style: style,
|
|
307
|
+
let avatar = /*#__PURE__*/React.createElement("span", Object.assign({}, others, {
|
|
308
|
+
style: border || bottomSlot || topSlot || border ? {} : style,
|
|
244
309
|
className: avatarCls,
|
|
245
310
|
onClick: onClick,
|
|
246
311
|
onMouseEnter: this.onEnter,
|
|
@@ -248,6 +313,36 @@ export default class Avatar extends BaseComponent {
|
|
|
248
313
|
role: 'listitem',
|
|
249
314
|
ref: this.avatarRef
|
|
250
315
|
}), this.getContent(), hoverRender);
|
|
316
|
+
if (border) {
|
|
317
|
+
const borderStyle = {};
|
|
318
|
+
if (border === null || border === void 0 ? void 0 : border.color) {
|
|
319
|
+
borderStyle['borderColor'] = border.color;
|
|
320
|
+
}
|
|
321
|
+
avatar = /*#__PURE__*/React.createElement("div", {
|
|
322
|
+
style: Object.assign({
|
|
323
|
+
position: "relative"
|
|
324
|
+
}, style)
|
|
325
|
+
}, avatar, /*#__PURE__*/React.createElement("span", {
|
|
326
|
+
style: borderStyle,
|
|
327
|
+
className: cls([`${prefixCls}-additionalBorder`, `${prefixCls}-additionalBorder-${size}`, {
|
|
328
|
+
[`${prefixCls}-${shape}`]: shape
|
|
329
|
+
}])
|
|
330
|
+
}), ((_a = this.props.border) === null || _a === void 0 ? void 0 : _a.motion) && /*#__PURE__*/React.createElement("span", {
|
|
331
|
+
style: borderStyle,
|
|
332
|
+
className: cls([`${prefixCls}-additionalBorder`, `${prefixCls}-additionalBorder-${size}`, {
|
|
333
|
+
[`${prefixCls}-${shape}`]: shape,
|
|
334
|
+
[`${prefixCls}-additionalBorder-animated`]: (_b = this.props.border) === null || _b === void 0 ? void 0 : _b.motion
|
|
335
|
+
}])
|
|
336
|
+
}));
|
|
337
|
+
}
|
|
338
|
+
if (bottomSlot || topSlot || border) {
|
|
339
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
340
|
+
className: cls([`${prefixCls}-wrapper`]),
|
|
341
|
+
style: style
|
|
342
|
+
}, avatar, topSlot && ["small", "default", "medium", "large", "extra-large"].includes(size) && shape === "circle" && this.renderTopSlot(), bottomSlot && ["small", "default", "medium", "large", "extra-large"].includes(size) && this.renderBottomSlot());
|
|
343
|
+
} else {
|
|
344
|
+
return avatar;
|
|
345
|
+
}
|
|
251
346
|
}
|
|
252
347
|
}
|
|
253
348
|
Avatar.defaultProps = {
|
|
@@ -275,6 +370,29 @@ Avatar.propTypes = {
|
|
|
275
370
|
onError: PropTypes.func,
|
|
276
371
|
onClick: PropTypes.func,
|
|
277
372
|
onMouseEnter: PropTypes.func,
|
|
278
|
-
onMouseLeave: PropTypes.func
|
|
373
|
+
onMouseLeave: PropTypes.func,
|
|
374
|
+
bottomSlot: PropTypes.shape({
|
|
375
|
+
render: PropTypes.func,
|
|
376
|
+
shape: PropTypes.oneOf(['circle', 'square']),
|
|
377
|
+
text: PropTypes.node,
|
|
378
|
+
bgColor: PropTypes.string,
|
|
379
|
+
textColor: PropTypes.string,
|
|
380
|
+
className: PropTypes.string,
|
|
381
|
+
style: PropTypes.object
|
|
382
|
+
}),
|
|
383
|
+
topSlot: PropTypes.shape({
|
|
384
|
+
render: PropTypes.func,
|
|
385
|
+
gradientStart: PropTypes.string,
|
|
386
|
+
gradientEnd: PropTypes.string,
|
|
387
|
+
text: PropTypes.node,
|
|
388
|
+
textColor: PropTypes.string,
|
|
389
|
+
className: PropTypes.string,
|
|
390
|
+
style: PropTypes.object
|
|
391
|
+
}),
|
|
392
|
+
border: PropTypes.oneOfType([PropTypes.shape({
|
|
393
|
+
color: PropTypes.string,
|
|
394
|
+
motion: PropTypes.bool
|
|
395
|
+
}), PropTypes.bool]),
|
|
396
|
+
contentMotion: PropTypes.bool
|
|
279
397
|
};
|
|
280
398
|
Avatar.elementType = 'Avatar';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
|
2
2
|
import { BaseProps } from '../_base/baseComponent';
|
|
3
3
|
export type AvatarShape = 'circle' | 'square';
|
|
4
4
|
export type AvatarSize = 'extra-extra-small' | 'extra-small' | 'small' | 'default' | 'medium' | 'large' | 'extra-large';
|
|
@@ -18,6 +18,29 @@ export interface AvatarProps extends BaseProps {
|
|
|
18
18
|
onMouseEnter?: React.MouseEventHandler;
|
|
19
19
|
onMouseLeave?: React.MouseEventHandler;
|
|
20
20
|
imgAttr?: React.ImgHTMLAttributes<HTMLImageElement>;
|
|
21
|
+
bottomSlot?: {
|
|
22
|
+
render?: () => React.ReactNode;
|
|
23
|
+
shape?: "circle" | "square";
|
|
24
|
+
text: React.ReactNode;
|
|
25
|
+
bgColor: string;
|
|
26
|
+
textColor: string;
|
|
27
|
+
className: string;
|
|
28
|
+
style?: CSSProperties;
|
|
29
|
+
};
|
|
30
|
+
topSlot?: {
|
|
31
|
+
render?: () => React.ReactNode;
|
|
32
|
+
gradientStart?: string;
|
|
33
|
+
gradientEnd?: string;
|
|
34
|
+
text: React.ReactNode;
|
|
35
|
+
textColor: string;
|
|
36
|
+
className: string;
|
|
37
|
+
style?: CSSProperties;
|
|
38
|
+
};
|
|
39
|
+
border?: {
|
|
40
|
+
color?: string;
|
|
41
|
+
motion?: boolean;
|
|
42
|
+
} & boolean;
|
|
43
|
+
contentMotion?: boolean;
|
|
21
44
|
}
|
|
22
45
|
export type AvatarGroupShape = 'circle' | 'square';
|
|
23
46
|
export type AvatarGroupSize = 'extra-extra-small' | 'extra-small' | 'small' | 'default' | 'medium' | 'large' | 'extra-large';
|
|
@@ -191,10 +191,9 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
191
191
|
componentWillUnmount(): void;
|
|
192
192
|
componentDidUpdate(prevProps: CascaderProps): void;
|
|
193
193
|
handleInputChange: (value: string) => void;
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
handleTagRemove: (e: any, tagValuePath: Array<string | number>) => void;
|
|
195
|
+
handleRemoveByKey: (key: any) => void;
|
|
196
196
|
renderTagItem: (nodeKey: string, idx: number) => string | number | boolean | React.ReactFragment | JSX.Element;
|
|
197
|
-
onRemoveInTagInput: (v: string) => void;
|
|
198
197
|
renderTagInput(): JSX.Element;
|
|
199
198
|
renderInput(): JSX.Element;
|
|
200
199
|
handleItemClick: (e: MouseEvent | KeyboardEvent, item: Entity | Data) => void;
|
package/lib/es/cascader/index.js
CHANGED
|
@@ -34,13 +34,14 @@ class Cascader extends BaseComponent {
|
|
|
34
34
|
this.handleInputChange = value => {
|
|
35
35
|
this.foundation.handleInputChange(value);
|
|
36
36
|
};
|
|
37
|
-
this.
|
|
38
|
-
this.foundation.
|
|
37
|
+
this.handleTagRemove = (e, tagValuePath) => {
|
|
38
|
+
this.foundation.handleTagRemove(e, tagValuePath);
|
|
39
39
|
};
|
|
40
|
-
this.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.
|
|
40
|
+
this.handleRemoveByKey = key => {
|
|
41
|
+
const {
|
|
42
|
+
keyEntities
|
|
43
|
+
} = this.state;
|
|
44
|
+
this.handleTagRemove(null, keyEntities[key].valuePath);
|
|
44
45
|
};
|
|
45
46
|
this.renderTagItem = (nodeKey, idx) => {
|
|
46
47
|
const {
|
|
@@ -68,18 +69,18 @@ class Cascader extends BaseComponent {
|
|
|
68
69
|
size: size === 'default' ? 'large' : size,
|
|
69
70
|
key: `tag-${nodeKey}-${idx}`,
|
|
70
71
|
color: "white",
|
|
71
|
-
tagKey: nodeKey,
|
|
72
72
|
className: tagCls,
|
|
73
73
|
closable: true,
|
|
74
|
-
onClose:
|
|
74
|
+
onClose: (tagChildren, e) => {
|
|
75
|
+
// When value has not changed, prevent clicking tag closeBtn to close tag
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
this.handleTagRemove(e, keyEntities[nodeKey].valuePath);
|
|
78
|
+
}
|
|
75
79
|
}, keyEntities[nodeKey].data[displayProp]);
|
|
76
80
|
}
|
|
77
81
|
}
|
|
78
82
|
return null;
|
|
79
83
|
};
|
|
80
|
-
this.onRemoveInTagInput = v => {
|
|
81
|
-
this.foundation.handleTagRemoveByKey(v);
|
|
82
|
-
};
|
|
83
84
|
this.handleItemClick = (e, item) => {
|
|
84
85
|
this.foundation.handleItemClick(e, item);
|
|
85
86
|
};
|
|
@@ -279,7 +280,6 @@ class Cascader extends BaseComponent {
|
|
|
279
280
|
}, labelNode);
|
|
280
281
|
};
|
|
281
282
|
this.renderCustomTrigger = () => {
|
|
282
|
-
var _a;
|
|
283
283
|
const {
|
|
284
284
|
disabled,
|
|
285
285
|
triggerRender,
|
|
@@ -290,26 +290,17 @@ class Cascader extends BaseComponent {
|
|
|
290
290
|
inputValue,
|
|
291
291
|
inputPlaceHolder,
|
|
292
292
|
resolvedCheckedKeys,
|
|
293
|
-
checkedKeys
|
|
294
|
-
keyEntities
|
|
293
|
+
checkedKeys
|
|
295
294
|
} = this.state;
|
|
296
295
|
let realValue;
|
|
297
296
|
if (multiple) {
|
|
298
297
|
if (this.mergeType === strings.NONE_MERGE_TYPE) {
|
|
299
|
-
realValue =
|
|
300
|
-
checkedKeys.forEach(key => {
|
|
301
|
-
var _a;
|
|
302
|
-
realValue.add((_a = keyEntities[key]) === null || _a === void 0 ? void 0 : _a.pos);
|
|
303
|
-
});
|
|
298
|
+
realValue = checkedKeys;
|
|
304
299
|
} else {
|
|
305
|
-
realValue =
|
|
306
|
-
resolvedCheckedKeys.forEach(key => {
|
|
307
|
-
var _a;
|
|
308
|
-
realValue.add((_a = keyEntities[key]) === null || _a === void 0 ? void 0 : _a.pos);
|
|
309
|
-
});
|
|
300
|
+
realValue = resolvedCheckedKeys;
|
|
310
301
|
}
|
|
311
302
|
} else {
|
|
312
|
-
realValue =
|
|
303
|
+
realValue = [...selectedKeys][0];
|
|
313
304
|
}
|
|
314
305
|
return /*#__PURE__*/React.createElement(Trigger, {
|
|
315
306
|
value: realValue,
|
|
@@ -322,7 +313,7 @@ class Cascader extends BaseComponent {
|
|
|
322
313
|
componentName: 'Cascader',
|
|
323
314
|
componentProps: Object.assign({}, this.props),
|
|
324
315
|
onSearch: this.handleInputChange,
|
|
325
|
-
onRemove: this.
|
|
316
|
+
onRemove: this.handleRemoveByKey
|
|
326
317
|
});
|
|
327
318
|
};
|
|
328
319
|
this.handleMouseOver = () => {
|
|
@@ -806,11 +797,11 @@ class Cascader extends BaseComponent {
|
|
|
806
797
|
showRestTagsPopover: showRestTagsPopover,
|
|
807
798
|
restTagsPopoverProps: restTagsPopoverProps,
|
|
808
799
|
maxTagCount: maxTagCount,
|
|
809
|
-
renderTagItem: this.renderTagItem,
|
|
800
|
+
renderTagItem: (value, index) => this.renderTagItem(value, index),
|
|
810
801
|
inputValue: inputValue,
|
|
811
802
|
onInputChange: this.handleInputChange,
|
|
812
803
|
// TODO Modify logic, not modify type
|
|
813
|
-
onRemove: this.
|
|
804
|
+
onRemove: v => this.handleTagRemove(null, v),
|
|
814
805
|
placeholder: placeholder,
|
|
815
806
|
expandRestTagsOnClick: false
|
|
816
807
|
});
|
|
@@ -463,7 +463,7 @@ export default class DatePicker extends BaseComponent {
|
|
|
463
463
|
return /range/i.test(type) && !_isFunction(triggerRender);
|
|
464
464
|
}
|
|
465
465
|
componentDidUpdate(prevProps) {
|
|
466
|
-
if (
|
|
466
|
+
if (prevProps.value !== this.props.value) {
|
|
467
467
|
this.foundation.initFromProps(Object.assign({}, this.props));
|
|
468
468
|
} else if (this.props.timeZone !== prevProps.timeZone) {
|
|
469
469
|
this.foundation.initFromProps({
|
|
@@ -41,6 +41,16 @@ class YearAndMonth extends BaseComponent {
|
|
|
41
41
|
currentYear,
|
|
42
42
|
currentMonth
|
|
43
43
|
} = props;
|
|
44
|
+
const currentLeftYear = currentYear.left || now.getFullYear();
|
|
45
|
+
const currentLeftMonth = currentMonth.left || now.getMonth() + 1;
|
|
46
|
+
currentYear = {
|
|
47
|
+
left: currentLeftYear,
|
|
48
|
+
right: currentLeftYear
|
|
49
|
+
};
|
|
50
|
+
currentMonth = {
|
|
51
|
+
left: currentLeftMonth,
|
|
52
|
+
right: currentMonth.right || currentLeftMonth + 1
|
|
53
|
+
};
|
|
44
54
|
this.state = {
|
|
45
55
|
years: getYears(props.startYear, props.endYear).map(year => ({
|
|
46
56
|
value: year,
|
|
@@ -50,14 +60,8 @@ class YearAndMonth extends BaseComponent {
|
|
|
50
60
|
value: idx + 1,
|
|
51
61
|
month: idx + 1
|
|
52
62
|
})),
|
|
53
|
-
currentYear
|
|
54
|
-
|
|
55
|
-
right: currentYear.right || now.getFullYear()
|
|
56
|
-
},
|
|
57
|
-
currentMonth: {
|
|
58
|
-
left: currentMonth.left || now.getMonth() + 1,
|
|
59
|
-
right: currentMonth.right || now.getMonth() + 2
|
|
60
|
-
}
|
|
63
|
+
currentYear,
|
|
64
|
+
currentMonth
|
|
61
65
|
};
|
|
62
66
|
this.yearRef = /*#__PURE__*/React.createRef();
|
|
63
67
|
this.monthRef = /*#__PURE__*/React.createRef();
|
|
@@ -94,19 +98,11 @@ class YearAndMonth extends BaseComponent {
|
|
|
94
98
|
}
|
|
95
99
|
static getDerivedStateFromProps(props, state) {
|
|
96
100
|
const willUpdateStates = {};
|
|
97
|
-
if (!_isEqual(props.currentYear, state.currentYear)) {
|
|
98
|
-
|
|
99
|
-
willUpdateStates.currentYear = {
|
|
100
|
-
left: props.currentYear.left || nowYear,
|
|
101
|
-
right: props.currentYear.right || nowYear
|
|
102
|
-
};
|
|
101
|
+
if (!_isEqual(props.currentYear, state.currentYear) && props.currentYear.left !== 0) {
|
|
102
|
+
willUpdateStates.currentYear = props.currentYear;
|
|
103
103
|
}
|
|
104
|
-
if (!_isEqual(props.currentMonth, state.currentMonth)) {
|
|
105
|
-
|
|
106
|
-
willUpdateStates.currentMonth = {
|
|
107
|
-
left: props.currentMonth.left || nowMonth + 1,
|
|
108
|
-
right: props.currentMonth.right || nowMonth + 2
|
|
109
|
-
};
|
|
104
|
+
if (!_isEqual(props.currentMonth, state.currentMonth) && props.currentMonth.left !== 0) {
|
|
105
|
+
willUpdateStates.currentMonth = props.currentMonth;
|
|
110
106
|
}
|
|
111
107
|
return willUpdateStates;
|
|
112
108
|
}
|