@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
|
@@ -27,12 +27,13 @@ declare class Portal extends PureComponent<PortalProps, PortalState> {
|
|
|
27
27
|
};
|
|
28
28
|
el: HTMLElement;
|
|
29
29
|
context: ContextValue;
|
|
30
|
-
constructor(props: PortalProps);
|
|
30
|
+
constructor(props: PortalProps, context: ContextValue);
|
|
31
31
|
componentDidMount(): void;
|
|
32
|
+
initContainer: (context: ContextValue, catchError?: boolean) => HTMLElement;
|
|
32
33
|
componentDidUpdate(prevProps: PortalProps): void;
|
|
33
34
|
componentWillUnmount(): void;
|
|
34
35
|
addStyle: (style?: {}) => void;
|
|
35
|
-
addClass: (prefixCls: string, ...classNames: string[]) => void;
|
|
36
|
+
addClass: (prefixCls: string, context?: ContextValue, ...classNames: string[]) => void;
|
|
36
37
|
render(): React.ReactPortal;
|
|
37
38
|
}
|
|
38
39
|
export default Portal;
|
package/lib/cjs/_portal/index.js
CHANGED
|
@@ -24,12 +24,46 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
24
24
|
const defaultGetContainer = () => document.body;
|
|
25
25
|
|
|
26
26
|
class Portal extends _react.PureComponent {
|
|
27
|
-
constructor(props) {
|
|
27
|
+
constructor(props, context) {
|
|
28
28
|
var _this;
|
|
29
29
|
|
|
30
30
|
super(props);
|
|
31
31
|
_this = this;
|
|
32
32
|
|
|
33
|
+
this.initContainer = function (context) {
|
|
34
|
+
let catchError = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
35
|
+
|
|
36
|
+
var _a, _b;
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
let container = undefined;
|
|
40
|
+
|
|
41
|
+
if (!_this.el) {
|
|
42
|
+
_this.el = document.createElement('div');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!((_a = _this.state) === null || _a === void 0 ? void 0 : _a.container)) {
|
|
46
|
+
_this.el = document.createElement('div');
|
|
47
|
+
const getContainer = _this.props.getPopupContainer || context.getPopupContainer || defaultGetContainer;
|
|
48
|
+
const portalContainer = getContainer();
|
|
49
|
+
portalContainer.appendChild(_this.el);
|
|
50
|
+
|
|
51
|
+
_this.addStyle(_this.props.style);
|
|
52
|
+
|
|
53
|
+
_this.addClass(_this.props.prefixCls, context, _this.props.className);
|
|
54
|
+
|
|
55
|
+
container = portalContainer;
|
|
56
|
+
return container;
|
|
57
|
+
}
|
|
58
|
+
} catch (e) {
|
|
59
|
+
if (!catchError) {
|
|
60
|
+
throw e;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (_b = _this.state) === null || _b === void 0 ? void 0 : _b.container;
|
|
65
|
+
};
|
|
66
|
+
|
|
33
67
|
this.addStyle = function () {
|
|
34
68
|
let style = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
35
69
|
|
|
@@ -41,12 +75,13 @@ class Portal extends _react.PureComponent {
|
|
|
41
75
|
};
|
|
42
76
|
|
|
43
77
|
this.addClass = function (prefixCls) {
|
|
78
|
+
let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.context;
|
|
44
79
|
const {
|
|
45
80
|
direction
|
|
46
|
-
} =
|
|
81
|
+
} = context;
|
|
47
82
|
|
|
48
|
-
for (var _len = arguments.length, classNames = new Array(_len >
|
|
49
|
-
classNames[_key -
|
|
83
|
+
for (var _len = arguments.length, classNames = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
84
|
+
classNames[_key - 2] = arguments[_key];
|
|
50
85
|
}
|
|
51
86
|
|
|
52
87
|
const cls = (0, _classnames.default)(prefixCls, ...classNames, {
|
|
@@ -58,36 +93,15 @@ class Portal extends _react.PureComponent {
|
|
|
58
93
|
}
|
|
59
94
|
};
|
|
60
95
|
|
|
61
|
-
try {
|
|
62
|
-
this.el = document.createElement('div');
|
|
63
|
-
} catch (e) {}
|
|
64
|
-
|
|
65
96
|
this.state = {
|
|
66
|
-
container:
|
|
97
|
+
container: this.initContainer(context, true)
|
|
67
98
|
};
|
|
68
99
|
}
|
|
69
100
|
|
|
70
101
|
componentDidMount() {
|
|
71
|
-
|
|
72
|
-
this.el = document.createElement('div');
|
|
73
|
-
}
|
|
102
|
+
const container = this.initContainer(this.context);
|
|
74
103
|
|
|
75
|
-
|
|
76
|
-
state,
|
|
77
|
-
props,
|
|
78
|
-
context
|
|
79
|
-
} = this;
|
|
80
|
-
const getContainer = props.getPopupContainer || context.getPopupContainer || defaultGetContainer;
|
|
81
|
-
const container = getContainer();
|
|
82
|
-
|
|
83
|
-
if (container !== state.container) {
|
|
84
|
-
// const computedStyle = window.getComputedStyle(container);
|
|
85
|
-
// if (computedStyle.position !== 'relative') {
|
|
86
|
-
// container.style.position = 'relative';
|
|
87
|
-
// }
|
|
88
|
-
container.appendChild(this.el);
|
|
89
|
-
this.addStyle(props.style);
|
|
90
|
-
this.addClass(props.prefixCls, props.className);
|
|
104
|
+
if (container !== this.state.container) {
|
|
91
105
|
this.setState({
|
|
92
106
|
container
|
|
93
107
|
});
|
|
@@ -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>;
|
|
@@ -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/cjs/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>>;
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
|
|
9
|
-
|
|
10
8
|
var _times2 = _interopRequireDefault(require("lodash/times"));
|
|
11
9
|
|
|
12
10
|
var _noop2 = _interopRequireDefault(require("lodash/noop"));
|
|
@@ -121,28 +119,21 @@ class NavItem extends _baseComponent.default {
|
|
|
121
119
|
notifyMouseLeave: function () {
|
|
122
120
|
return _this.props.onMouseLeave(...arguments);
|
|
123
121
|
},
|
|
124
|
-
getIsCollapsed: () => this.props.isCollapsed || Boolean(this.context && this.context.isCollapsed),
|
|
125
|
-
getSelected: () =>
|
|
126
|
-
getIsOpen: () => Boolean(this.context && this.context.openKeys && this.context.openKeys.includes(this.props.itemKey))
|
|
127
|
-
getIsInSubNav: () => this.props.isInSubNav || Boolean(this.context && this.context.isInSubNav),
|
|
128
|
-
getMode: () => {
|
|
129
|
-
var _a, _b;
|
|
130
|
-
|
|
131
|
-
return (_a = this.props.mode) !== null && _a !== void 0 ? _a : (_b = this.context) === null || _b === void 0 ? void 0 : _b.mode;
|
|
132
|
-
}
|
|
122
|
+
getIsCollapsed: () => this.props.isCollapsed || Boolean(this.context && this.context.isCollapsed) || false,
|
|
123
|
+
getSelected: () => Boolean(this.context && this.context.selectedKeys && this.context.selectedKeys.includes(this.props.itemKey)),
|
|
124
|
+
getIsOpen: () => Boolean(this.context && this.context.openKeys && this.context.openKeys.includes(this.props.itemKey))
|
|
133
125
|
});
|
|
134
126
|
}
|
|
135
127
|
|
|
136
128
|
renderIcon(icon, pos) {
|
|
137
129
|
let isToggleIcon = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
138
130
|
let key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
139
|
-
const mode = this.adapter.getMode();
|
|
140
131
|
|
|
141
132
|
if (this.props.isSubNav) {
|
|
142
133
|
return null;
|
|
143
134
|
}
|
|
144
135
|
|
|
145
|
-
if (!icon && mode === _constants.strings.MODE_HORIZONTAL) {
|
|
136
|
+
if (!icon && this.context.mode === _constants.strings.MODE_HORIZONTAL) {
|
|
146
137
|
return null;
|
|
147
138
|
}
|
|
148
139
|
|
|
@@ -180,19 +171,16 @@ class NavItem extends _baseComponent.default {
|
|
|
180
171
|
linkOptions,
|
|
181
172
|
disabled,
|
|
182
173
|
level = 0,
|
|
183
|
-
tabIndex
|
|
184
|
-
isInSubNav: isInSubNavInProps,
|
|
185
|
-
mode: modeInProps
|
|
174
|
+
tabIndex
|
|
186
175
|
} = this.props;
|
|
187
176
|
const {
|
|
188
|
-
|
|
177
|
+
mode,
|
|
178
|
+
isInSubNav,
|
|
189
179
|
prefixCls,
|
|
190
180
|
limitIndent
|
|
191
181
|
} = this.context;
|
|
192
182
|
const isCollapsed = this.adapter.getIsCollapsed();
|
|
193
183
|
const selected = this.adapter.getSelected();
|
|
194
|
-
const isInSubNav = this.adapter.getIsInSubNav();
|
|
195
|
-
const mode = this.adapter.getMode();
|
|
196
184
|
let itemChildren = null;
|
|
197
185
|
|
|
198
186
|
if (!(0, _isNullOrUndefined.default)(children)) {
|
|
@@ -241,16 +229,13 @@ class NavItem extends _baseComponent.default {
|
|
|
241
229
|
}, itemChildren);
|
|
242
230
|
} else {
|
|
243
231
|
// Items are divided into normal and sub-wrap
|
|
244
|
-
const isFirstLayer = !(0, _isUndefined2.default)(isInSubNavInProps) && !isInSubNavInProps || (0, _isUndefined2.default)(isInSubNavInProps) && (0, _isUndefined2.default)(isInSubNavInContext);
|
|
245
232
|
const popoverItemCls = (0, _classnames.default)("".concat(className || "".concat(clsPrefix, "-normal")), {
|
|
246
233
|
[clsPrefix]: true,
|
|
247
234
|
["".concat(clsPrefix, "-sub")]: isSubNav,
|
|
248
235
|
["".concat(clsPrefix, "-selected")]: selected && !isSubNav,
|
|
249
236
|
["".concat(clsPrefix, "-collapsed")]: isCollapsed,
|
|
250
237
|
["".concat(clsPrefix, "-disabled")]: disabled,
|
|
251
|
-
["".concat(clsPrefix, "-has-link")]: typeof link === 'string'
|
|
252
|
-
["".concat(_constants.cssClasses.PREFIX, "-first-layer")]: isFirstLayer,
|
|
253
|
-
["".concat(clsPrefix, "-horizontal")]: modeInProps === _constants.strings.MODE_HORIZONTAL
|
|
238
|
+
["".concat(clsPrefix, "-has-link")]: typeof link === 'string'
|
|
254
239
|
});
|
|
255
240
|
const ariaProps = {
|
|
256
241
|
'aria-disabled': disabled
|
|
@@ -330,5 +315,4 @@ NavItem.defaultProps = {
|
|
|
330
315
|
onMouseLeave: _noop2.default,
|
|
331
316
|
disabled: false,
|
|
332
317
|
tabIndex: 0
|
|
333
|
-
};
|
|
334
|
-
NavItem.elementType = 'Nav.Item';
|
|
318
|
+
};
|
|
@@ -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>;
|
|
@@ -129,25 +129,16 @@ class SubNav extends _baseComponent.default {
|
|
|
129
129
|
|
|
130
130
|
return _this._invokeContextFunc('onClick', ...args);
|
|
131
131
|
},
|
|
132
|
-
getIsSelected: itemKey =>
|
|
133
|
-
getIsOpen: () =>
|
|
134
|
-
getIsCollapsed: () => this.props.isCollapsed || Boolean(this.context && this.context.isCollapsed),
|
|
135
|
-
getMode: () => {
|
|
136
|
-
var _a, _b;
|
|
137
|
-
|
|
138
|
-
return (_a = this.props.mode) !== null && _a !== void 0 ? _a : (_b = this.context) === null || _b === void 0 ? void 0 : _b.mode;
|
|
139
|
-
}
|
|
132
|
+
getIsSelected: itemKey => Boolean(!(0, _isNullOrUndefined.default)(itemKey) && (0, _get2.default)(this.context, 'selectedKeys', []).includes(String(itemKey))),
|
|
133
|
+
getIsOpen: () => Boolean(this.context && this.context.openKeys && this.context.openKeys.includes(String(this.props.itemKey)))
|
|
140
134
|
});
|
|
141
135
|
}
|
|
142
136
|
|
|
143
137
|
renderIcon(icon, pos, withTransition) {
|
|
144
138
|
let isToggleIcon = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
145
139
|
let key = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
146
|
-
|
|
147
|
-
var _a;
|
|
148
|
-
|
|
149
140
|
const {
|
|
150
|
-
prefixCls
|
|
141
|
+
prefixCls
|
|
151
142
|
} = this.context;
|
|
152
143
|
let iconSize = 'large';
|
|
153
144
|
|
|
@@ -155,15 +146,14 @@ class SubNav extends _baseComponent.default {
|
|
|
155
146
|
iconSize = 'default';
|
|
156
147
|
}
|
|
157
148
|
|
|
158
|
-
const isOpen = this.adapter.getIsOpen();
|
|
159
149
|
const className = (0, _classnames.default)("".concat(prefixCls, "-item-icon"), {
|
|
160
|
-
["".concat(prefixCls, "-item-icon-toggle-").concat(
|
|
161
|
-
["".concat(prefixCls, "-item-icon-info")]: !isToggleIcon
|
|
162
|
-
["".concat(prefixCls, "-icon-rotate-").concat(isOpen ? "180" : "0", "-no-transition")]: !withTransition && isToggleIcon
|
|
150
|
+
["".concat(prefixCls, "-item-icon-toggle-").concat(this.context.toggleIconPosition)]: isToggleIcon,
|
|
151
|
+
["".concat(prefixCls, "-item-icon-info")]: !isToggleIcon
|
|
163
152
|
});
|
|
153
|
+
const isOpen = this.adapter.getIsOpen();
|
|
164
154
|
const iconElem = /*#__PURE__*/_react.default.isValidElement(icon) ? withTransition ? /*#__PURE__*/_react.default.createElement(_cssAnimation.default, {
|
|
165
155
|
animationState: isOpen ? "enter" : "leave",
|
|
166
|
-
startClassName: "".concat(
|
|
156
|
+
startClassName: "".concat(_constants.cssClasses.PREFIX, "-icon-rotate-").concat(isOpen ? "180" : "0")
|
|
167
157
|
}, _ref => {
|
|
168
158
|
let {
|
|
169
159
|
animationClassName
|
|
@@ -193,19 +183,17 @@ class SubNav extends _baseComponent.default {
|
|
|
193
183
|
level
|
|
194
184
|
} = this.props;
|
|
195
185
|
const {
|
|
186
|
+
mode,
|
|
196
187
|
isInSubNav,
|
|
197
|
-
|
|
188
|
+
isCollapsed,
|
|
189
|
+
prefixCls,
|
|
198
190
|
subNavMotion,
|
|
199
191
|
limitIndent
|
|
200
192
|
} = this.context;
|
|
201
|
-
const mode = this.adapter.getMode();
|
|
202
193
|
const isOpen = this.adapter.getIsOpen();
|
|
203
|
-
const isCollapsed = this.adapter.getIsCollapsed();
|
|
204
194
|
const titleCls = (0, _classnames.default)("".concat(prefixCls, "-sub-title"), {
|
|
205
195
|
["".concat(prefixCls, "-sub-title-selected")]: this.adapter.getIsSelected(itemKey),
|
|
206
|
-
["".concat(prefixCls, "-sub-title-disabled")]: disabled
|
|
207
|
-
["".concat(prefixCls, "-first-layer")]: !isInSubNav,
|
|
208
|
-
["".concat(prefixCls, "-sub-title-horizontal")]: mode === _constants.strings.MODE_HORIZONTAL
|
|
196
|
+
["".concat(prefixCls, "-sub-title-disabled")]: disabled
|
|
209
197
|
});
|
|
210
198
|
let withTransition = false;
|
|
211
199
|
let toggleIconType = '';
|
|
@@ -246,7 +234,6 @@ class SubNav extends _baseComponent.default {
|
|
|
246
234
|
}
|
|
247
235
|
|
|
248
236
|
const isIconChevronRightShow = !isCollapsed && isInSubNav && mode === _constants.strings.MODE_HORIZONTAL || isCollapsed && isInSubNav;
|
|
249
|
-
const toggleIconPositionLeft = this.context.toggleIconPosition === _constants.strings.TOGGLE_ICON_LEFT;
|
|
250
237
|
|
|
251
238
|
const titleDiv = /*#__PURE__*/_react.default.createElement("div", {
|
|
252
239
|
role: "menuitem",
|
|
@@ -259,9 +246,9 @@ class SubNav extends _baseComponent.default {
|
|
|
259
246
|
"aria-expanded": isOpen ? 'true' : 'false'
|
|
260
247
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
261
248
|
className: "".concat(prefixCls, "-item-inner")
|
|
262
|
-
}, placeholderIcons,
|
|
249
|
+
}, placeholderIcons, this.context.toggleIconPosition === _constants.strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIconType, _constants.strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-left'), icon || indent || isInSubNav && mode !== _constants.strings.MODE_HORIZONTAL ? this.renderIcon(icon, _constants.strings.ICON_POS_LEFT, false, false, 'key-inSubNav-position-left') : null, /*#__PURE__*/_react.default.createElement("span", {
|
|
263
250
|
className: "".concat(prefixCls, "-item-text")
|
|
264
|
-
}, text),
|
|
251
|
+
}, text), this.context.toggleIconPosition === _constants.strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIconType, _constants.strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-right')));
|
|
265
252
|
|
|
266
253
|
return titleDiv;
|
|
267
254
|
}
|
|
@@ -272,12 +259,12 @@ class SubNav extends _baseComponent.default {
|
|
|
272
259
|
maxHeight
|
|
273
260
|
} = this.props;
|
|
274
261
|
const {
|
|
262
|
+
isCollapsed,
|
|
263
|
+
mode,
|
|
275
264
|
subNavMotion,
|
|
276
|
-
prefixCls
|
|
265
|
+
prefixCls
|
|
277
266
|
} = this.context;
|
|
278
|
-
const isCollapsed = this.adapter.getIsCollapsed();
|
|
279
267
|
const isOpen = this.adapter.getIsOpen();
|
|
280
|
-
const mode = this.adapter.getMode();
|
|
281
268
|
const isHorizontal = mode === _constants.strings.MODE_HORIZONTAL;
|
|
282
269
|
const subNavCls = (0, _classnames.default)("".concat(prefixCls, "-sub"), {
|
|
283
270
|
["".concat(prefixCls, "-sub-open")]: isOpen,
|
|
@@ -308,14 +295,14 @@ class SubNav extends _baseComponent.default {
|
|
|
308
295
|
disabled
|
|
309
296
|
} = this.props;
|
|
310
297
|
const {
|
|
298
|
+
mode,
|
|
311
299
|
isInSubNav,
|
|
300
|
+
isCollapsed,
|
|
312
301
|
subNavCloseDelay,
|
|
313
302
|
subNavOpenDelay,
|
|
314
|
-
prefixCls
|
|
303
|
+
prefixCls,
|
|
315
304
|
getPopupContainer
|
|
316
305
|
} = this.context;
|
|
317
|
-
const isCollapsed = this.adapter.getIsCollapsed();
|
|
318
|
-
const mode = this.adapter.getMode();
|
|
319
306
|
const isOpen = this.adapter.getIsOpen();
|
|
320
307
|
const openKeysIsControlled = this.adapter.getOpenKeysIsControlled();
|
|
321
308
|
const subNavCls = (0, _classnames.default)({
|
|
@@ -360,10 +347,10 @@ class SubNav extends _baseComponent.default {
|
|
|
360
347
|
text
|
|
361
348
|
} = this.props;
|
|
362
349
|
const {
|
|
363
|
-
|
|
350
|
+
mode,
|
|
351
|
+
isCollapsed,
|
|
352
|
+
prefixCls
|
|
364
353
|
} = this.context;
|
|
365
|
-
const mode = this.adapter.getMode();
|
|
366
|
-
const isCollapsed = this.adapter.getIsCollapsed();
|
|
367
354
|
let titleDiv = this.renderTitleDiv();
|
|
368
355
|
const subUl = this.renderSubUl(); // When mode=horizontal, it is displayed in Dropdown
|
|
369
356
|
|
|
@@ -381,11 +368,9 @@ class SubNav extends _baseComponent.default {
|
|
|
381
368
|
onMouseEnter: onMouseEnter,
|
|
382
369
|
onMouseLeave: onMouseLeave,
|
|
383
370
|
disabled: disabled,
|
|
384
|
-
text: text
|
|
385
|
-
mode: mode
|
|
371
|
+
text: text
|
|
386
372
|
}, /*#__PURE__*/_react.default.createElement(_navContext.default.Provider, {
|
|
387
373
|
value: Object.assign(Object.assign({}, this.context), {
|
|
388
|
-
mode: mode,
|
|
389
374
|
isInSubNav: true
|
|
390
375
|
})
|
|
391
376
|
}, titleDiv, subUl));
|
|
@@ -448,8 +433,7 @@ SubNav.propTypes = {
|
|
|
448
433
|
onMouseLeave: _propTypes.default.func,
|
|
449
434
|
// Is it disabled
|
|
450
435
|
disabled: _propTypes.default.bool,
|
|
451
|
-
level: _propTypes.default.number
|
|
452
|
-
active: _propTypes.default.bool
|
|
436
|
+
level: _propTypes.default.number
|
|
453
437
|
};
|
|
454
438
|
SubNav.defaultProps = {
|
|
455
439
|
level: 0,
|
|
@@ -465,7 +449,5 @@ SubNav.defaultProps = {
|
|
|
465
449
|
"aria-hidden": true
|
|
466
450
|
})
|
|
467
451
|
},
|
|
468
|
-
disabled: false
|
|
469
|
-
|
|
470
|
-
};
|
|
471
|
-
SubNav.elementType = 'Nav.Sub';
|
|
452
|
+
disabled: false
|
|
453
|
+
};
|
|
@@ -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>;
|
|
@@ -27,12 +27,13 @@ declare class Portal extends PureComponent<PortalProps, PortalState> {
|
|
|
27
27
|
};
|
|
28
28
|
el: HTMLElement;
|
|
29
29
|
context: ContextValue;
|
|
30
|
-
constructor(props: PortalProps);
|
|
30
|
+
constructor(props: PortalProps, context: ContextValue);
|
|
31
31
|
componentDidMount(): void;
|
|
32
|
+
initContainer: (context: ContextValue, catchError?: boolean) => HTMLElement;
|
|
32
33
|
componentDidUpdate(prevProps: PortalProps): void;
|
|
33
34
|
componentWillUnmount(): void;
|
|
34
35
|
addStyle: (style?: {}) => void;
|
|
35
|
-
addClass: (prefixCls: string, ...classNames: string[]) => void;
|
|
36
|
+
addClass: (prefixCls: string, context?: ContextValue, ...classNames: string[]) => void;
|
|
36
37
|
render(): React.ReactPortal;
|
|
37
38
|
}
|
|
38
39
|
export default Portal;
|