@douyinfe/semi-ui 2.27.1-alpha.3 → 2.27.2
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 +4 -74
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +271 -291
- 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/_portal/index.d.ts +3 -2
- package/lib/cjs/_portal/index.js +42 -28
- package/lib/cjs/button/Button.d.ts +1 -1
- package/lib/cjs/button/index.d.ts +1 -1
- package/lib/cjs/datePicker/dateInput.d.ts +1 -1
- package/lib/cjs/datePicker/datePicker.d.ts +1 -1
- package/lib/cjs/datePicker/monthsGrid.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/navigation/Item.d.ts +0 -4
- package/lib/cjs/navigation/Item.js +9 -25
- package/lib/cjs/navigation/SubNav.d.ts +0 -5
- package/lib/cjs/navigation/SubNav.js +26 -44
- package/lib/cjs/typography/base.d.ts +1 -1
- package/lib/cjs/typography/numeral.d.ts +1 -1
- package/lib/cjs/typography/paragraph.d.ts +1 -1
- package/lib/cjs/typography/text.d.ts +1 -1
- package/lib/cjs/typography/title.d.ts +2 -2
- package/lib/es/_portal/index.d.ts +3 -2
- package/lib/es/_portal/index.js +42 -28
- package/lib/es/button/Button.d.ts +1 -1
- package/lib/es/button/index.d.ts +1 -1
- package/lib/es/datePicker/dateInput.d.ts +1 -1
- package/lib/es/datePicker/datePicker.d.ts +1 -1
- package/lib/es/datePicker/monthsGrid.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/navigation/Item.d.ts +0 -4
- package/lib/es/navigation/Item.js +9 -25
- package/lib/es/navigation/SubNav.d.ts +0 -5
- package/lib/es/navigation/SubNav.js +26 -44
- package/lib/es/typography/base.d.ts +1 -1
- package/lib/es/typography/numeral.d.ts +1 -1
- package/lib/es/typography/paragraph.d.ts +1 -1
- package/lib/es/typography/text.d.ts +1 -1
- package/lib/es/typography/title.d.ts +2 -2
- package/package.json +8 -8
package/lib/es/_portal/index.js
CHANGED
|
@@ -9,12 +9,46 @@ import '@douyinfe/semi-foundation/lib/es/_portal/portal.css';
|
|
|
9
9
|
const defaultGetContainer = () => document.body;
|
|
10
10
|
|
|
11
11
|
class Portal extends PureComponent {
|
|
12
|
-
constructor(props) {
|
|
12
|
+
constructor(props, context) {
|
|
13
13
|
var _this;
|
|
14
14
|
|
|
15
15
|
super(props);
|
|
16
16
|
_this = this;
|
|
17
17
|
|
|
18
|
+
this.initContainer = function (context) {
|
|
19
|
+
let catchError = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
20
|
+
|
|
21
|
+
var _a, _b;
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
let container = undefined;
|
|
25
|
+
|
|
26
|
+
if (!_this.el) {
|
|
27
|
+
_this.el = document.createElement('div');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!((_a = _this.state) === null || _a === void 0 ? void 0 : _a.container)) {
|
|
31
|
+
_this.el = document.createElement('div');
|
|
32
|
+
const getContainer = _this.props.getPopupContainer || context.getPopupContainer || defaultGetContainer;
|
|
33
|
+
const portalContainer = getContainer();
|
|
34
|
+
portalContainer.appendChild(_this.el);
|
|
35
|
+
|
|
36
|
+
_this.addStyle(_this.props.style);
|
|
37
|
+
|
|
38
|
+
_this.addClass(_this.props.prefixCls, context, _this.props.className);
|
|
39
|
+
|
|
40
|
+
container = portalContainer;
|
|
41
|
+
return container;
|
|
42
|
+
}
|
|
43
|
+
} catch (e) {
|
|
44
|
+
if (!catchError) {
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (_b = _this.state) === null || _b === void 0 ? void 0 : _b.container;
|
|
50
|
+
};
|
|
51
|
+
|
|
18
52
|
this.addStyle = function () {
|
|
19
53
|
let style = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
20
54
|
|
|
@@ -26,12 +60,13 @@ class Portal extends PureComponent {
|
|
|
26
60
|
};
|
|
27
61
|
|
|
28
62
|
this.addClass = function (prefixCls) {
|
|
63
|
+
let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.context;
|
|
29
64
|
const {
|
|
30
65
|
direction
|
|
31
|
-
} =
|
|
66
|
+
} = context;
|
|
32
67
|
|
|
33
|
-
for (var _len = arguments.length, classNames = new Array(_len >
|
|
34
|
-
classNames[_key -
|
|
68
|
+
for (var _len = arguments.length, classNames = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
69
|
+
classNames[_key - 2] = arguments[_key];
|
|
35
70
|
}
|
|
36
71
|
|
|
37
72
|
const cls = classnames(prefixCls, ...classNames, {
|
|
@@ -43,36 +78,15 @@ class Portal extends PureComponent {
|
|
|
43
78
|
}
|
|
44
79
|
};
|
|
45
80
|
|
|
46
|
-
try {
|
|
47
|
-
this.el = document.createElement('div');
|
|
48
|
-
} catch (e) {}
|
|
49
|
-
|
|
50
81
|
this.state = {
|
|
51
|
-
container:
|
|
82
|
+
container: this.initContainer(context, true)
|
|
52
83
|
};
|
|
53
84
|
}
|
|
54
85
|
|
|
55
86
|
componentDidMount() {
|
|
56
|
-
|
|
57
|
-
this.el = document.createElement('div');
|
|
58
|
-
}
|
|
87
|
+
const container = this.initContainer(this.context);
|
|
59
88
|
|
|
60
|
-
|
|
61
|
-
state,
|
|
62
|
-
props,
|
|
63
|
-
context
|
|
64
|
-
} = this;
|
|
65
|
-
const getContainer = props.getPopupContainer || context.getPopupContainer || defaultGetContainer;
|
|
66
|
-
const container = getContainer();
|
|
67
|
-
|
|
68
|
-
if (container !== state.container) {
|
|
69
|
-
// const computedStyle = window.getComputedStyle(container);
|
|
70
|
-
// if (computedStyle.position !== 'relative') {
|
|
71
|
-
// container.style.position = 'relative';
|
|
72
|
-
// }
|
|
73
|
-
container.appendChild(this.el);
|
|
74
|
-
this.addStyle(props.style);
|
|
75
|
-
this.addClass(props.prefixCls, props.className);
|
|
89
|
+
if (container !== this.state.container) {
|
|
76
90
|
this.setState({
|
|
77
91
|
container
|
|
78
92
|
});
|
|
@@ -48,7 +48,7 @@ export default class Button extends PureComponent<ButtonProps> {
|
|
|
48
48
|
prefixCls: PropTypes.Requireable<string>;
|
|
49
49
|
style: PropTypes.Requireable<object>;
|
|
50
50
|
size: PropTypes.Requireable<"default" | "small" | "large">;
|
|
51
|
-
type: PropTypes.Requireable<"warning" | "primary" | "
|
|
51
|
+
type: PropTypes.Requireable<"warning" | "primary" | "tertiary" | "secondary" | "danger">;
|
|
52
52
|
block: PropTypes.Requireable<boolean>;
|
|
53
53
|
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
54
54
|
onMouseDown: PropTypes.Requireable<(...args: any[]) => any>;
|
package/lib/es/button/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ declare class Button extends React.PureComponent<ButtonProps> {
|
|
|
23
23
|
onMouseLeave: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
24
24
|
disabled: import("prop-types").Requireable<boolean>;
|
|
25
25
|
size: import("prop-types").Requireable<"default" | "small" | "large">;
|
|
26
|
-
type: import("prop-types").Requireable<"warning" | "primary" | "
|
|
26
|
+
type: import("prop-types").Requireable<"warning" | "primary" | "tertiary" | "secondary" | "danger">;
|
|
27
27
|
block: import("prop-types").Requireable<boolean>;
|
|
28
28
|
onClick: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
29
29
|
onMouseDown: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
@@ -26,7 +26,7 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
26
26
|
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
27
27
|
value: PropTypes.Requireable<any[]>;
|
|
28
28
|
disabled: PropTypes.Requireable<boolean>;
|
|
29
|
-
type: PropTypes.Requireable<"
|
|
29
|
+
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
|
|
30
30
|
showClear: PropTypes.Requireable<boolean>;
|
|
31
31
|
format: PropTypes.Requireable<string>;
|
|
32
32
|
inputStyle: PropTypes.Requireable<object>;
|
|
@@ -46,7 +46,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
46
46
|
'aria-invalid': PropTypes.Requireable<boolean>;
|
|
47
47
|
'aria-labelledby': PropTypes.Requireable<string>;
|
|
48
48
|
'aria-required': PropTypes.Requireable<boolean>;
|
|
49
|
-
type: PropTypes.Requireable<"
|
|
49
|
+
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
|
|
50
50
|
size: PropTypes.Requireable<"default" | "small" | "large">;
|
|
51
51
|
clearIcon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
52
52
|
density: PropTypes.Requireable<"default" | "compact">;
|
|
@@ -19,7 +19,7 @@ export interface MonthsGridProps extends MonthsGridFoundationProps, BaseProps {
|
|
|
19
19
|
export declare type MonthsGridState = MonthsGridFoundationState;
|
|
20
20
|
export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGridState> {
|
|
21
21
|
static propTypes: {
|
|
22
|
-
type: PropTypes.Requireable<"
|
|
22
|
+
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
|
|
23
23
|
defaultValue: PropTypes.Requireable<NonNullable<string | number | object>>;
|
|
24
24
|
defaultPickerValue: PropTypes.Requireable<NonNullable<string | number | object>>;
|
|
25
25
|
multiple: PropTypes.Requireable<boolean>;
|
|
@@ -135,7 +135,7 @@ declare class Form<Values extends Record<string, any> = any> extends BaseCompone
|
|
|
135
135
|
preventScroll?: boolean;
|
|
136
136
|
showRestTagsPopover?: boolean;
|
|
137
137
|
restTagsPopoverProps?: import("../popover").PopoverProps;
|
|
138
|
-
} & Pick<import("../tooltip").TooltipProps, "
|
|
138
|
+
} & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "motion" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
|
|
139
139
|
static Checkbox: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox").CheckboxProps & import("./interface").RCIncludeType>;
|
|
140
140
|
static CheckboxGroup: React.ComponentType<import("utility-types").Subtract<import("../checkbox").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps & React.RefAttributes<any>>;
|
|
141
141
|
static Radio: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../radio").RadioProps & import("./interface").RCIncludeType>;
|
package/lib/es/form/field.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ declare const FormSelect: import("react").ComponentType<import("utility-types").
|
|
|
83
83
|
preventScroll?: boolean;
|
|
84
84
|
showRestTagsPopover?: boolean;
|
|
85
85
|
restTagsPopoverProps?: import("../popover").PopoverProps;
|
|
86
|
-
} & Pick<import("../tooltip").TooltipProps, "
|
|
86
|
+
} & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "motion" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay"> & import("react").RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
|
|
87
87
|
declare const FormCheckboxGroup: import("react").ComponentType<import("utility-types").Subtract<import("../checkbox/checkboxGroup").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps & import("react").RefAttributes<any>>;
|
|
88
88
|
declare const FormCheckbox: import("react").ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox/checkbox").CheckboxProps & import("./interface").RCIncludeType>;
|
|
89
89
|
declare const FormRadioGroup: import("react").ComponentType<import("utility-types").Subtract<import("../radio/radioGroup").RadioGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps & import("react").RefAttributes<any>>;
|
|
@@ -19,9 +19,6 @@ export interface NavItemProps extends ItemProps, BaseProps {
|
|
|
19
19
|
onClick?(clickItems: SelectedData): void;
|
|
20
20
|
onMouseEnter?: React.MouseEventHandler<HTMLLIElement>;
|
|
21
21
|
onMouseLeave?: React.MouseEventHandler<HTMLLIElement>;
|
|
22
|
-
selected?: boolean;
|
|
23
|
-
mode?: string;
|
|
24
|
-
isInSubNav?: boolean;
|
|
25
22
|
}
|
|
26
23
|
export interface SelectedData extends SelectedItemProps<NavItemProps> {
|
|
27
24
|
text?: React.ReactNode;
|
|
@@ -31,7 +28,6 @@ export interface NavItemState {
|
|
|
31
28
|
}
|
|
32
29
|
export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
|
|
33
30
|
static contextType: React.Context<NavContextType>;
|
|
34
|
-
static elementType: string;
|
|
35
31
|
static propTypes: {
|
|
36
32
|
text: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
|
|
37
33
|
itemKey: PropTypes.Requireable<NonNullable<string | number>>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _isUndefined from "lodash/isUndefined";
|
|
2
1
|
import _times from "lodash/times";
|
|
3
2
|
import _noop from "lodash/noop";
|
|
4
3
|
|
|
@@ -98,28 +97,21 @@ export default class NavItem extends BaseComponent {
|
|
|
98
97
|
notifyMouseLeave: function () {
|
|
99
98
|
return _this.props.onMouseLeave(...arguments);
|
|
100
99
|
},
|
|
101
|
-
getIsCollapsed: () => this.props.isCollapsed || Boolean(this.context && this.context.isCollapsed),
|
|
102
|
-
getSelected: () =>
|
|
103
|
-
getIsOpen: () => Boolean(this.context && this.context.openKeys && this.context.openKeys.includes(this.props.itemKey))
|
|
104
|
-
getIsInSubNav: () => this.props.isInSubNav || Boolean(this.context && this.context.isInSubNav),
|
|
105
|
-
getMode: () => {
|
|
106
|
-
var _a, _b;
|
|
107
|
-
|
|
108
|
-
return (_a = this.props.mode) !== null && _a !== void 0 ? _a : (_b = this.context) === null || _b === void 0 ? void 0 : _b.mode;
|
|
109
|
-
}
|
|
100
|
+
getIsCollapsed: () => this.props.isCollapsed || Boolean(this.context && this.context.isCollapsed) || false,
|
|
101
|
+
getSelected: () => Boolean(this.context && this.context.selectedKeys && this.context.selectedKeys.includes(this.props.itemKey)),
|
|
102
|
+
getIsOpen: () => Boolean(this.context && this.context.openKeys && this.context.openKeys.includes(this.props.itemKey))
|
|
110
103
|
});
|
|
111
104
|
}
|
|
112
105
|
|
|
113
106
|
renderIcon(icon, pos) {
|
|
114
107
|
let isToggleIcon = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
115
108
|
let key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
116
|
-
const mode = this.adapter.getMode();
|
|
117
109
|
|
|
118
110
|
if (this.props.isSubNav) {
|
|
119
111
|
return null;
|
|
120
112
|
}
|
|
121
113
|
|
|
122
|
-
if (!icon && mode === strings.MODE_HORIZONTAL) {
|
|
114
|
+
if (!icon && this.context.mode === strings.MODE_HORIZONTAL) {
|
|
123
115
|
return null;
|
|
124
116
|
}
|
|
125
117
|
|
|
@@ -157,19 +149,16 @@ export default class NavItem extends BaseComponent {
|
|
|
157
149
|
linkOptions,
|
|
158
150
|
disabled,
|
|
159
151
|
level = 0,
|
|
160
|
-
tabIndex
|
|
161
|
-
isInSubNav: isInSubNavInProps,
|
|
162
|
-
mode: modeInProps
|
|
152
|
+
tabIndex
|
|
163
153
|
} = this.props;
|
|
164
154
|
const {
|
|
165
|
-
|
|
155
|
+
mode,
|
|
156
|
+
isInSubNav,
|
|
166
157
|
prefixCls,
|
|
167
158
|
limitIndent
|
|
168
159
|
} = this.context;
|
|
169
160
|
const isCollapsed = this.adapter.getIsCollapsed();
|
|
170
161
|
const selected = this.adapter.getSelected();
|
|
171
|
-
const isInSubNav = this.adapter.getIsInSubNav();
|
|
172
|
-
const mode = this.adapter.getMode();
|
|
173
162
|
let itemChildren = null;
|
|
174
163
|
|
|
175
164
|
if (!isNullOrUndefined(children)) {
|
|
@@ -218,17 +207,13 @@ export default class NavItem extends BaseComponent {
|
|
|
218
207
|
}, itemChildren);
|
|
219
208
|
} else {
|
|
220
209
|
// Items are divided into normal and sub-wrap
|
|
221
|
-
const isFirstLayer = !_isUndefined(isInSubNavInProps) && !isInSubNavInProps || _isUndefined(isInSubNavInProps) && _isUndefined(isInSubNavInContext);
|
|
222
|
-
|
|
223
210
|
const popoverItemCls = cls("".concat(className || "".concat(clsPrefix, "-normal")), {
|
|
224
211
|
[clsPrefix]: true,
|
|
225
212
|
["".concat(clsPrefix, "-sub")]: isSubNav,
|
|
226
213
|
["".concat(clsPrefix, "-selected")]: selected && !isSubNav,
|
|
227
214
|
["".concat(clsPrefix, "-collapsed")]: isCollapsed,
|
|
228
215
|
["".concat(clsPrefix, "-disabled")]: disabled,
|
|
229
|
-
["".concat(clsPrefix, "-has-link")]: typeof link === 'string'
|
|
230
|
-
["".concat(cssClasses.PREFIX, "-first-layer")]: isFirstLayer,
|
|
231
|
-
["".concat(clsPrefix, "-horizontal")]: modeInProps === strings.MODE_HORIZONTAL
|
|
216
|
+
["".concat(clsPrefix, "-has-link")]: typeof link === 'string'
|
|
232
217
|
});
|
|
233
218
|
const ariaProps = {
|
|
234
219
|
'aria-disabled': disabled
|
|
@@ -306,5 +291,4 @@ NavItem.defaultProps = {
|
|
|
306
291
|
onMouseLeave: _noop,
|
|
307
292
|
disabled: false,
|
|
308
293
|
tabIndex: 0
|
|
309
|
-
};
|
|
310
|
-
NavItem.elementType = 'Nav.Item';
|
|
294
|
+
};
|
|
@@ -22,15 +22,12 @@ export interface SubNavProps extends BaseProps {
|
|
|
22
22
|
onMouseLeave?: React.MouseEventHandler<HTMLLIElement>;
|
|
23
23
|
text?: React.ReactNode;
|
|
24
24
|
toggleIcon?: ToggleIcon;
|
|
25
|
-
active?: boolean;
|
|
26
|
-
mode?: string;
|
|
27
25
|
}
|
|
28
26
|
export interface SubNavState {
|
|
29
27
|
isHovered: boolean;
|
|
30
28
|
}
|
|
31
29
|
export default class SubNav extends BaseComponent<SubNavProps, SubNavState> {
|
|
32
30
|
static contextType: React.Context<NavContextType>;
|
|
33
|
-
static elementType: string;
|
|
34
31
|
static propTypes: {
|
|
35
32
|
/**
|
|
36
33
|
* Unique identification
|
|
@@ -73,7 +70,6 @@ export default class SubNav extends BaseComponent<SubNavProps, SubNavState> {
|
|
|
73
70
|
onMouseLeave: PropTypes.Requireable<(...args: any[]) => any>;
|
|
74
71
|
disabled: PropTypes.Requireable<boolean>;
|
|
75
72
|
level: PropTypes.Requireable<number>;
|
|
76
|
-
active: PropTypes.Requireable<boolean>;
|
|
77
73
|
};
|
|
78
74
|
static defaultProps: {
|
|
79
75
|
level: number;
|
|
@@ -86,7 +82,6 @@ export default class SubNav extends BaseComponent<SubNavProps, SubNavState> {
|
|
|
86
82
|
closed: JSX.Element;
|
|
87
83
|
};
|
|
88
84
|
disabled: boolean;
|
|
89
|
-
active: boolean;
|
|
90
85
|
};
|
|
91
86
|
titleRef: React.RefObject<HTMLDivElement>;
|
|
92
87
|
itemRef: React.RefObject<HTMLLIElement>;
|
|
@@ -105,25 +105,16 @@ export default class SubNav extends BaseComponent {
|
|
|
105
105
|
|
|
106
106
|
return _this._invokeContextFunc('onClick', ...args);
|
|
107
107
|
},
|
|
108
|
-
getIsSelected: itemKey =>
|
|
109
|
-
getIsOpen: () =>
|
|
110
|
-
getIsCollapsed: () => this.props.isCollapsed || Boolean(this.context && this.context.isCollapsed),
|
|
111
|
-
getMode: () => {
|
|
112
|
-
var _a, _b;
|
|
113
|
-
|
|
114
|
-
return (_a = this.props.mode) !== null && _a !== void 0 ? _a : (_b = this.context) === null || _b === void 0 ? void 0 : _b.mode;
|
|
115
|
-
}
|
|
108
|
+
getIsSelected: itemKey => Boolean(!isNullOrUndefined(itemKey) && _get(this.context, 'selectedKeys', []).includes(String(itemKey))),
|
|
109
|
+
getIsOpen: () => Boolean(this.context && this.context.openKeys && this.context.openKeys.includes(String(this.props.itemKey)))
|
|
116
110
|
});
|
|
117
111
|
}
|
|
118
112
|
|
|
119
113
|
renderIcon(icon, pos, withTransition) {
|
|
120
114
|
let isToggleIcon = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
121
115
|
let key = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
122
|
-
|
|
123
|
-
var _a;
|
|
124
|
-
|
|
125
116
|
const {
|
|
126
|
-
prefixCls
|
|
117
|
+
prefixCls
|
|
127
118
|
} = this.context;
|
|
128
119
|
let iconSize = 'large';
|
|
129
120
|
|
|
@@ -131,15 +122,14 @@ export default class SubNav extends BaseComponent {
|
|
|
131
122
|
iconSize = 'default';
|
|
132
123
|
}
|
|
133
124
|
|
|
134
|
-
const isOpen = this.adapter.getIsOpen();
|
|
135
125
|
const className = cls("".concat(prefixCls, "-item-icon"), {
|
|
136
|
-
["".concat(prefixCls, "-item-icon-toggle-").concat(
|
|
137
|
-
["".concat(prefixCls, "-item-icon-info")]: !isToggleIcon
|
|
138
|
-
["".concat(prefixCls, "-icon-rotate-").concat(isOpen ? "180" : "0", "-no-transition")]: !withTransition && isToggleIcon
|
|
126
|
+
["".concat(prefixCls, "-item-icon-toggle-").concat(this.context.toggleIconPosition)]: isToggleIcon,
|
|
127
|
+
["".concat(prefixCls, "-item-icon-info")]: !isToggleIcon
|
|
139
128
|
});
|
|
129
|
+
const isOpen = this.adapter.getIsOpen();
|
|
140
130
|
const iconElem = /*#__PURE__*/React.isValidElement(icon) ? withTransition ? /*#__PURE__*/React.createElement(CSSAnimation, {
|
|
141
131
|
animationState: isOpen ? "enter" : "leave",
|
|
142
|
-
startClassName: "".concat(
|
|
132
|
+
startClassName: "".concat(cssClasses.PREFIX, "-icon-rotate-").concat(isOpen ? "180" : "0")
|
|
143
133
|
}, _ref => {
|
|
144
134
|
let {
|
|
145
135
|
animationClassName
|
|
@@ -169,19 +159,17 @@ export default class SubNav extends BaseComponent {
|
|
|
169
159
|
level
|
|
170
160
|
} = this.props;
|
|
171
161
|
const {
|
|
162
|
+
mode,
|
|
172
163
|
isInSubNav,
|
|
173
|
-
|
|
164
|
+
isCollapsed,
|
|
165
|
+
prefixCls,
|
|
174
166
|
subNavMotion,
|
|
175
167
|
limitIndent
|
|
176
168
|
} = this.context;
|
|
177
|
-
const mode = this.adapter.getMode();
|
|
178
169
|
const isOpen = this.adapter.getIsOpen();
|
|
179
|
-
const isCollapsed = this.adapter.getIsCollapsed();
|
|
180
170
|
const titleCls = cls("".concat(prefixCls, "-sub-title"), {
|
|
181
171
|
["".concat(prefixCls, "-sub-title-selected")]: this.adapter.getIsSelected(itemKey),
|
|
182
|
-
["".concat(prefixCls, "-sub-title-disabled")]: disabled
|
|
183
|
-
["".concat(prefixCls, "-first-layer")]: !isInSubNav,
|
|
184
|
-
["".concat(prefixCls, "-sub-title-horizontal")]: mode === strings.MODE_HORIZONTAL
|
|
172
|
+
["".concat(prefixCls, "-sub-title-disabled")]: disabled
|
|
185
173
|
});
|
|
186
174
|
let withTransition = false;
|
|
187
175
|
let toggleIconType = '';
|
|
@@ -222,7 +210,6 @@ export default class SubNav extends BaseComponent {
|
|
|
222
210
|
}
|
|
223
211
|
|
|
224
212
|
const isIconChevronRightShow = !isCollapsed && isInSubNav && mode === strings.MODE_HORIZONTAL || isCollapsed && isInSubNav;
|
|
225
|
-
const toggleIconPositionLeft = this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT;
|
|
226
213
|
const titleDiv = /*#__PURE__*/React.createElement("div", {
|
|
227
214
|
role: "menuitem",
|
|
228
215
|
// to avoid nested horizontal navigation be focused
|
|
@@ -234,9 +221,9 @@ export default class SubNav extends BaseComponent {
|
|
|
234
221
|
"aria-expanded": isOpen ? 'true' : 'false'
|
|
235
222
|
}, /*#__PURE__*/React.createElement("div", {
|
|
236
223
|
className: "".concat(prefixCls, "-item-inner")
|
|
237
|
-
}, placeholderIcons,
|
|
224
|
+
}, placeholderIcons, this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIconType, strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-left'), icon || indent || isInSubNav && mode !== strings.MODE_HORIZONTAL ? this.renderIcon(icon, strings.ICON_POS_LEFT, false, false, 'key-inSubNav-position-left') : null, /*#__PURE__*/React.createElement("span", {
|
|
238
225
|
className: "".concat(prefixCls, "-item-text")
|
|
239
|
-
}, text),
|
|
226
|
+
}, text), this.context.toggleIconPosition === strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIconType, strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-right')));
|
|
240
227
|
return titleDiv;
|
|
241
228
|
}
|
|
242
229
|
|
|
@@ -246,12 +233,12 @@ export default class SubNav extends BaseComponent {
|
|
|
246
233
|
maxHeight
|
|
247
234
|
} = this.props;
|
|
248
235
|
const {
|
|
236
|
+
isCollapsed,
|
|
237
|
+
mode,
|
|
249
238
|
subNavMotion,
|
|
250
|
-
prefixCls
|
|
239
|
+
prefixCls
|
|
251
240
|
} = this.context;
|
|
252
|
-
const isCollapsed = this.adapter.getIsCollapsed();
|
|
253
241
|
const isOpen = this.adapter.getIsOpen();
|
|
254
|
-
const mode = this.adapter.getMode();
|
|
255
242
|
const isHorizontal = mode === strings.MODE_HORIZONTAL;
|
|
256
243
|
const subNavCls = cls("".concat(prefixCls, "-sub"), {
|
|
257
244
|
["".concat(prefixCls, "-sub-open")]: isOpen,
|
|
@@ -280,14 +267,14 @@ export default class SubNav extends BaseComponent {
|
|
|
280
267
|
disabled
|
|
281
268
|
} = this.props;
|
|
282
269
|
const {
|
|
270
|
+
mode,
|
|
283
271
|
isInSubNav,
|
|
272
|
+
isCollapsed,
|
|
284
273
|
subNavCloseDelay,
|
|
285
274
|
subNavOpenDelay,
|
|
286
|
-
prefixCls
|
|
275
|
+
prefixCls,
|
|
287
276
|
getPopupContainer
|
|
288
277
|
} = this.context;
|
|
289
|
-
const isCollapsed = this.adapter.getIsCollapsed();
|
|
290
|
-
const mode = this.adapter.getMode();
|
|
291
278
|
const isOpen = this.adapter.getIsOpen();
|
|
292
279
|
const openKeysIsControlled = this.adapter.getOpenKeysIsControlled();
|
|
293
280
|
const subNavCls = cls({
|
|
@@ -332,10 +319,10 @@ export default class SubNav extends BaseComponent {
|
|
|
332
319
|
text
|
|
333
320
|
} = this.props;
|
|
334
321
|
const {
|
|
335
|
-
|
|
322
|
+
mode,
|
|
323
|
+
isCollapsed,
|
|
324
|
+
prefixCls
|
|
336
325
|
} = this.context;
|
|
337
|
-
const mode = this.adapter.getMode();
|
|
338
|
-
const isCollapsed = this.adapter.getIsCollapsed();
|
|
339
326
|
let titleDiv = this.renderTitleDiv();
|
|
340
327
|
const subUl = this.renderSubUl(); // When mode=horizontal, it is displayed in Dropdown
|
|
341
328
|
|
|
@@ -353,11 +340,9 @@ export default class SubNav extends BaseComponent {
|
|
|
353
340
|
onMouseEnter: onMouseEnter,
|
|
354
341
|
onMouseLeave: onMouseLeave,
|
|
355
342
|
disabled: disabled,
|
|
356
|
-
text: text
|
|
357
|
-
mode: mode
|
|
343
|
+
text: text
|
|
358
344
|
}, /*#__PURE__*/React.createElement(NavContext.Provider, {
|
|
359
345
|
value: Object.assign(Object.assign({}, this.context), {
|
|
360
|
-
mode: mode,
|
|
361
346
|
isInSubNav: true
|
|
362
347
|
})
|
|
363
348
|
}, titleDiv, subUl));
|
|
@@ -418,8 +403,7 @@ SubNav.propTypes = {
|
|
|
418
403
|
onMouseLeave: PropTypes.func,
|
|
419
404
|
// Is it disabled
|
|
420
405
|
disabled: PropTypes.bool,
|
|
421
|
-
level: PropTypes.number
|
|
422
|
-
active: PropTypes.bool
|
|
406
|
+
level: PropTypes.number
|
|
423
407
|
};
|
|
424
408
|
SubNav.defaultProps = {
|
|
425
409
|
level: 0,
|
|
@@ -435,7 +419,5 @@ SubNav.defaultProps = {
|
|
|
435
419
|
"aria-hidden": true
|
|
436
420
|
})
|
|
437
421
|
},
|
|
438
|
-
disabled: false
|
|
439
|
-
|
|
440
|
-
};
|
|
441
|
-
SubNav.elementType = 'Nav.Sub';
|
|
422
|
+
disabled: false
|
|
423
|
+
};
|
|
@@ -64,7 +64,7 @@ export default class Base extends Component<BaseTypographyProps, BaseTypographyS
|
|
|
64
64
|
spacing: PropTypes.Requireable<"normal" | "extended">;
|
|
65
65
|
strong: PropTypes.Requireable<boolean>;
|
|
66
66
|
size: PropTypes.Requireable<"small" | "normal">;
|
|
67
|
-
type: PropTypes.Requireable<"warning" | "success" | "primary" | "
|
|
67
|
+
type: PropTypes.Requireable<"warning" | "success" | "primary" | "tertiary" | "secondary" | "danger" | "quaternary">;
|
|
68
68
|
style: PropTypes.Requireable<object>;
|
|
69
69
|
className: PropTypes.Requireable<string>;
|
|
70
70
|
icon: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
|
|
@@ -38,7 +38,7 @@ export default class Numeral extends PureComponent<NumeralProps> {
|
|
|
38
38
|
underline: PropTypes.Requireable<boolean>;
|
|
39
39
|
link: PropTypes.Requireable<NonNullable<boolean | object>>;
|
|
40
40
|
strong: PropTypes.Requireable<boolean>;
|
|
41
|
-
type: PropTypes.Requireable<"warning" | "success" | "primary" | "
|
|
41
|
+
type: PropTypes.Requireable<"warning" | "success" | "primary" | "tertiary" | "secondary" | "danger" | "quaternary">;
|
|
42
42
|
size: PropTypes.Requireable<"small" | "normal">;
|
|
43
43
|
style: PropTypes.Requireable<object>;
|
|
44
44
|
className: PropTypes.Requireable<string>;
|
|
@@ -29,7 +29,7 @@ export default class Paragraph extends PureComponent<ParagraphProps> {
|
|
|
29
29
|
link: PropTypes.Requireable<NonNullable<boolean | object>>;
|
|
30
30
|
underline: PropTypes.Requireable<boolean>;
|
|
31
31
|
strong: PropTypes.Requireable<boolean>;
|
|
32
|
-
type: PropTypes.Requireable<"warning" | "success" | "primary" | "
|
|
32
|
+
type: PropTypes.Requireable<"warning" | "success" | "primary" | "tertiary" | "secondary" | "danger" | "quaternary">;
|
|
33
33
|
size: PropTypes.Requireable<"small" | "normal">;
|
|
34
34
|
spacing: PropTypes.Requireable<"normal" | "extended">;
|
|
35
35
|
style: PropTypes.Requireable<object>;
|
|
@@ -32,7 +32,7 @@ export default class Text extends PureComponent<TextProps> {
|
|
|
32
32
|
underline: PropTypes.Requireable<boolean>;
|
|
33
33
|
link: PropTypes.Requireable<NonNullable<boolean | object>>;
|
|
34
34
|
strong: PropTypes.Requireable<boolean>;
|
|
35
|
-
type: PropTypes.Requireable<"warning" | "success" | "primary" | "
|
|
35
|
+
type: PropTypes.Requireable<"warning" | "success" | "primary" | "tertiary" | "secondary" | "danger" | "quaternary">;
|
|
36
36
|
size: PropTypes.Requireable<"small" | "normal">;
|
|
37
37
|
style: PropTypes.Requireable<object>;
|
|
38
38
|
className: PropTypes.Requireable<string>;
|
|
@@ -36,8 +36,8 @@ export default class Title extends PureComponent<TitleProps> {
|
|
|
36
36
|
link: PropTypes.Requireable<NonNullable<boolean | object>>;
|
|
37
37
|
underline: PropTypes.Requireable<boolean>;
|
|
38
38
|
strong: PropTypes.Requireable<boolean>;
|
|
39
|
-
type: PropTypes.Requireable<"warning" | "success" | "primary" | "
|
|
40
|
-
heading: PropTypes.Requireable<
|
|
39
|
+
type: PropTypes.Requireable<"warning" | "success" | "primary" | "tertiary" | "secondary" | "danger" | "quaternary">;
|
|
40
|
+
heading: PropTypes.Requireable<1 | 2 | 3 | 4 | 6 | 5>;
|
|
41
41
|
style: PropTypes.Requireable<object>;
|
|
42
42
|
className: PropTypes.Requireable<string>;
|
|
43
43
|
component: PropTypes.Requireable<string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.27.
|
|
3
|
+
"version": "2.27.2",
|
|
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.27.
|
|
21
|
-
"@douyinfe/semi-animation-react": "2.27.
|
|
22
|
-
"@douyinfe/semi-foundation": "2.27.
|
|
23
|
-
"@douyinfe/semi-icons": "2.27.
|
|
24
|
-
"@douyinfe/semi-illustrations": "2.27.
|
|
25
|
-
"@douyinfe/semi-theme-default": "2.27.
|
|
20
|
+
"@douyinfe/semi-animation": "2.27.2",
|
|
21
|
+
"@douyinfe/semi-animation-react": "2.27.2",
|
|
22
|
+
"@douyinfe/semi-foundation": "2.27.2",
|
|
23
|
+
"@douyinfe/semi-icons": "2.27.2",
|
|
24
|
+
"@douyinfe/semi-illustrations": "2.27.2",
|
|
25
|
+
"@douyinfe/semi-theme-default": "2.27.2",
|
|
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": "6efa0e3f18bac28642eadca29f6d3fa27e5d6ba4",
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
75
75
|
"@babel/plugin-transform-runtime": "^7.15.8",
|